cppad-20160000.1/0002755000175200017650000000000012656322034012424 5ustar coincoin-webcppad-20160000.1/makefile.in0000644000175200017650000012664312656321777014560 0ustar coincoin-web# 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@ subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/makefile.am $(top_srcdir)/configure \ $(am__configure_deps) $(am__myinclude_HEADERS_DIST) \ $(nobase_myinclude_HEADERS) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = cppad/configure.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@) 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 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkgconfigdir)" \ "$(DESTDIR)$(myincludedir)" "$(DESTDIR)$(myincludedir)" DATA = $(pkgconfig_DATA) am__myinclude_HEADERS_DIST = cppad_ipopt/src/cppad_ipopt_nlp.hpp HEADERS = $(myinclude_HEADERS) $(nobase_myinclude_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir dist dist-all distcheck 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 CSCOPE = cscope 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 example/atomic compare_c \ introduction/get_started introduction/exp_apx print_for \ multi_thread multi_thread/test_multi test_more am__DIST_COMMON = $(srcdir)/makefile.in \ $(top_srcdir)/cppad/configure.hpp.in \ $(top_srcdir)/pkgconfig/cppad-uninstalled.pc.in \ $(top_srcdir)/pkgconfig/cppad.pc.in AUTHORS COPYING ChangeLog \ INSTALL NEWS README ar-lib compile config.guess config.sub \ depcomp install-sh missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print 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@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DL_LIB = @DL_LIB@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # $Id: makefile.in 3769 2015-12-29 16:13:16Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # BUILT_SOURCES = $(top_srcdir)/cppad/configure.hpp @CppAD_POSTFIX_FALSE@postfix_dir = . # @CppAD_POSTFIX_TRUE@postfix_dir = $(POSTFIX_DIR) @CppAD_ADOLC_FALSE@SPEED_ADOLC_TESTS = # # Did user specify a value for ADOLC_DIR in configure command line @CppAD_ADOLC_TRUE@SPEED_ADOLC_TESTS = speed/adolc @CppAD_FADBAD_FALSE@SPEED_FADBAD_TESTS = # # Did user specify a value for FADBAD_DIR in configure command line @CppAD_FADBAD_TRUE@SPEED_FADBAD_TESTS = speed/fadbad @CppAD_SACADO_FALSE@SPEED_SACADO_TESTS = # # Did user specify a value for SACADO_DIR in configure command line @CppAD_SACADO_TRUE@SPEED_SACADO_TESTS = speed/sacado @CppAD_IPOPT_FALSE@IPOPT_TESTS = # # Did user specify a value for IPOPT_DIR in configure command line @CppAD_IPOPT_TRUE@IPOPT_TESTS = \ @CppAD_IPOPT_TRUE@ example/ipopt_solve \ @CppAD_IPOPT_TRUE@ cppad_ipopt/example \ @CppAD_IPOPT_TRUE@ cppad_ipopt/speed \ @CppAD_IPOPT_TRUE@ cppad_ipopt/test @CppAD_IPOPT_FALSE@IPOPT_DIRS = # @CppAD_IPOPT_TRUE@IPOPT_DIRS = \ @CppAD_IPOPT_TRUE@ cppad_ipopt/src \ @CppAD_IPOPT_TRUE@ $(IPOPT_TESTS) @CppAD_IPOPT_FALSE@IPOPT_HEADER = # @CppAD_IPOPT_TRUE@IPOPT_HEADER = \ @CppAD_IPOPT_TRUE@ cppad_ipopt/src/cppad_ipopt_nlp.hpp # # Is the library archiving program present @CppAD_HAVE_AR_TRUE@SPEED_TESTS = \ @CppAD_HAVE_AR_TRUE@ $(SPEED_ADOLC_TESTS) \ @CppAD_HAVE_AR_TRUE@ speed/cppad \ @CppAD_HAVE_AR_TRUE@ speed/double \ @CppAD_HAVE_AR_TRUE@ speed/example \ @CppAD_HAVE_AR_TRUE@ $(SPEED_FADBAD_TESTS) \ @CppAD_HAVE_AR_TRUE@ speed/profile \ @CppAD_HAVE_AR_TRUE@ $(SPEED_SACADO_TESTS) # @CppAD_HAVE_AR_TRUE@SPEED_DIRS = \ @CppAD_HAVE_AR_TRUE@ speed/src \ @CppAD_HAVE_AR_TRUE@ $(SPEED_TESTS) # --------------------------------------------------------------------------- myincludedir = $(includedir)/$(postfix_dir) # myinclude_HEADERS = \ $(IPOPT_HEADER) # nobase_myinclude_HEADERS = \ cppad/utility.hpp \ cppad/base_require.hpp \ cppad/utility/check_numeric_type.hpp \ cppad/utility/check_simple_vector.hpp \ cppad/configure.hpp \ cppad/cppad.hpp \ cppad/utility/elapsed_seconds.hpp \ cppad/example/base_adolc.hpp \ cppad/example/cppad_eigen.hpp \ cppad/example/eigen_plugin.hpp \ cppad/example/matrix_mul.hpp \ cppad/utility/error_handler.hpp \ cppad/utility/index_sort.hpp \ cppad/ipopt/solve.hpp \ cppad/ipopt/solve_callback.hpp \ cppad/ipopt/solve_result.hpp \ cppad/local/abort_recording.hpp \ cppad/local/abs.hpp \ cppad/local/abs_op.hpp \ cppad/local/acos_op.hpp \ cppad/local/acosh.hpp \ cppad/local/acosh_op.hpp \ cppad/local/ad_assign.hpp \ cppad/local/ad_binary.hpp \ cppad/local/ad_ctor.hpp \ cppad/local/add_eq.hpp \ cppad/local/add.hpp \ cppad/local/add_op.hpp \ cppad/local/ad_io.hpp \ cppad/local/ad_fun.hpp \ cppad/local/ad.hpp \ cppad/local/ad_tape.hpp \ cppad/local/ad_to_string.hpp \ cppad/local/ad_valued.hpp \ cppad/local/arithmetic.hpp \ cppad/local/asin_op.hpp \ cppad/local/asinh.hpp \ cppad/local/asinh_op.hpp \ cppad/local/atan2.hpp \ cppad/local/atan_op.hpp \ cppad/local/atanh.hpp \ cppad/local/atanh_op.hpp \ cppad/local/atomic_base.hpp \ cppad/local/azmul.hpp \ cppad/local/base_complex.hpp \ cppad/local/base_cond_exp.hpp \ cppad/local/base_double.hpp \ cppad/local/base_float.hpp \ cppad/local/base_limits.hpp \ cppad/local/base_std_math.hpp \ cppad/local/base_to_string.hpp \ cppad/local/bender_quad.hpp \ cppad/local/bool_fun.hpp \ cppad/local/bool_valued.hpp \ cppad/local/capacity_order.hpp \ cppad/local/checkpoint.hpp \ cppad/local/check_for_nan.hpp \ cppad/local/color_general.hpp \ cppad/local/color_symmetric.hpp \ cppad/local/compare.hpp \ cppad/local/comp_op.hpp \ cppad/local/compute_assign.hpp \ cppad/local/cond_exp.hpp \ cppad/local/cond_op.hpp \ cppad/local/convert.hpp \ cppad/local/cosh_op.hpp \ cppad/local/cos_op.hpp \ cppad/local/cppad_assert.hpp \ cppad/local/cppad_colpack.hpp \ cppad/local/cskip_op.hpp \ cppad/local/csum_op.hpp \ cppad/local/declare_ad.hpp \ cppad/local/define.hpp \ cppad/local/dependent.hpp \ cppad/local/discrete.hpp \ cppad/local/discrete_op.hpp \ cppad/local/div_eq.hpp \ cppad/local/div.hpp \ cppad/local/div_op.hpp \ cppad/local/drivers.hpp \ cppad/local/epsilon.hpp \ cppad/local/equal_op_seq.hpp \ cppad/local/erf.hpp \ cppad/local/erf_op.hpp \ cppad/local/exp_op.hpp \ cppad/local/expm1.hpp \ cppad/local/expm1_op.hpp \ cppad/local/for_jac_sweep.hpp \ cppad/local/for_one.hpp \ cppad/local/for_sparse_jac.hpp \ cppad/local/for_two.hpp \ cppad/local/forward0sweep.hpp \ cppad/local/forward1sweep.hpp \ cppad/local/forward2sweep.hpp \ cppad/local/forward.hpp \ cppad/local/fun_check.hpp \ cppad/local/fun_construct.hpp \ cppad/local/fun_eval.hpp \ cppad/local/hash_code.hpp \ cppad/local/hessian.hpp \ cppad/local/identical.hpp \ cppad/local/independent.hpp \ cppad/local/integer.hpp \ cppad/local/jacobian.hpp \ cppad/local/load_op.hpp \ cppad/local/log_op.hpp \ cppad/local/log1p.hpp \ cppad/local/log1p_op.hpp \ cppad/local/lu_ratio.hpp \ cppad/local/mul_eq.hpp \ cppad/local/mul.hpp \ cppad/local/mul_op.hpp \ cppad/local/near_equal_ext.hpp \ cppad/local/numeric_limits.hpp \ cppad/local/num_skip.hpp \ cppad/local/old_atomic.hpp \ cppad/local/omp_max_thread.hpp \ cppad/local/op_code.hpp \ cppad/local/op.hpp \ cppad/local/optimize.hpp \ cppad/local/opt_val_hes.hpp \ cppad/local/ordered.hpp \ cppad/local/parallel_ad.hpp \ cppad/local/parameter_op.hpp \ cppad/local/par_var.hpp \ cppad/local/player.hpp \ cppad/local/pod_vector.hpp \ cppad/local/pow.hpp \ cppad/local/pow_op.hpp \ cppad/local/print_for.hpp \ cppad/local/print_op.hpp \ cppad/local/prototype_op.hpp \ cppad/local/recorder.hpp \ cppad/local/reverse.hpp \ cppad/local/reverse_sweep.hpp \ cppad/local/rev_hes_sweep.hpp \ cppad/local/rev_jac_sweep.hpp \ cppad/local/rev_one.hpp \ cppad/local/rev_sparse_hes.hpp \ cppad/local/rev_sparse_jac.hpp \ cppad/local/rev_two.hpp \ cppad/local/set_get_in_parallel.hpp \ cppad/local/sign.hpp \ cppad/local/sign_op.hpp \ cppad/local/sin_op.hpp \ cppad/local/sinh_op.hpp \ cppad/local/sparse_binary_op.hpp \ cppad/local/sparse_hessian.hpp \ cppad/local/sparse.hpp \ cppad/local/sparse_jacobian.hpp \ cppad/local/sparse_list.hpp \ cppad/local/sparse_pack.hpp \ cppad/local/sparse_pattern.hpp \ cppad/local/sparse_set.hpp \ cppad/local/sparse_unary_op.hpp \ cppad/local/sqrt_op.hpp \ cppad/local/standard_math.hpp \ cppad/local/std_math_98.hpp \ cppad/local/std_set.hpp \ cppad/local/store_op.hpp \ cppad/local/sub_eq.hpp \ cppad/local/sub.hpp \ cppad/local/sub_op.hpp \ cppad/local/tanh_op.hpp \ cppad/local/tan_op.hpp \ cppad/local/tape_link.hpp \ cppad/local/test_vector.hpp \ cppad/local/testvector.hpp \ cppad/local/unary_minus.hpp \ cppad/local/unary_plus.hpp \ cppad/local/undef.hpp \ cppad/local/user_ad.hpp \ cppad/local/value.hpp \ cppad/local/var2par.hpp \ cppad/local/vec_ad.hpp \ cppad/local/zdouble.hpp \ cppad/local/zmul_op.hpp \ cppad/utility/lu_factor.hpp \ cppad/utility/lu_invert.hpp \ cppad/utility/lu_solve.hpp \ cppad/utility/memory_leak.hpp \ cppad/utility/nan.hpp \ cppad/utility/near_equal.hpp \ cppad/utility/ode_err_control.hpp \ cppad/utility/ode_gear_control.hpp \ cppad/utility/ode_gear.hpp \ cppad/utility/omp_alloc.hpp \ cppad/utility/poly.hpp \ cppad/utility/pow_int.hpp \ cppad/utility/romberg_mul.hpp \ cppad/utility/romberg_one.hpp \ cppad/utility/rosen_34.hpp \ cppad/utility/runge_45.hpp \ cppad/utility/to_string.hpp \ cppad/speed/det_33.hpp \ cppad/speed/det_by_lu.hpp \ cppad/speed/det_by_minor.hpp \ 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/utility/speed_test.hpp \ cppad/speed/uniform_01.hpp \ cppad/utility/thread_alloc.hpp \ cppad/utility/time_test.hpp \ cppad/utility/track_new_del.hpp \ cppad/utility/vector.hpp # End nobase_myinclude_HEADERS (check_makefile.sh uses this comment) # --------------------------------------------------------------- # # No objects or executables are required to install CppAD. # See 'make test' below for building the tests. SUBDIRS = \ $(IPOPT_DIRS) \ $(SPEED_DIRS) \ example \ example/atomic \ compare_c \ introduction/get_started \ introduction/exp_apx \ print_for \ multi_thread \ multi_thread/test_multi \ test_more # # note that bin/gpl_license.sh is deleted by dist-hook EXTRA_DIST = \ bin \ build.sh \ doc.omh \ doc \ gpl-3.0.txt \ epl-v10.html \ omh \ uw_copy_040507.html \ \ compare_c/CMakeLists.txt \ cppad/CMakeLists.txt \ pkgconfig/CMakeLists.txt \ example/CMakeLists.txt \ example/atomic/CMakeLists.txt \ example/ipopt_solve/CMakeLists.txt \ test_more/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 \ multi_thread/bthread/CMakeLists.txt \ multi_thread/CMakeLists.txt \ multi_thread/openmp/CMakeLists.txt \ multi_thread/pthread/CMakeLists.txt \ print_for/CMakeLists.txt test_directory_list = \ $(IPOPT_TESTS) \ $(SPEED_TESTS) \ example \ example/atomic \ compare_c \ introduction/get_started \ introduction/exp_apx \ multi_thread \ multi_thread/test_multi \ print_for \ test_more # doc_postfix = $(DESTDIR)$(datadir)/doc/$(postfix_dir) doc_package = $(DESTDIR)$(datadir)/doc/$(postfix_dir)/$(PACKAGE)-$(VERSION) inc_postfix = $(DESTDIR)/$(myincludedir) # pkgconfigdir = $(datadir)/pkgconfig pkgconfig_DATA = pkgconfig/cppad.pc all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: makefile @: $(srcdir)/makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu makefile makefile: $(srcdir)/makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(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 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 $@ pkgconfig/cppad-uninstalled.pc: $(top_builddir)/config.status $(top_srcdir)/pkgconfig/cppad-uninstalled.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ done uninstall-pkgconfigDATA: @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) install-myincludeHEADERS: $(myinclude_HEADERS) @$(NORMAL_INSTALL) @list='$(myinclude_HEADERS)'; test -n "$(myincludedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(myincludedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(myincludedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(myincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(myincludedir)" || exit $$?; \ done uninstall-myincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(myinclude_HEADERS)'; test -n "$(myincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(myincludedir)'; $(am__uninstall_files_from_dir) install-nobase_myincludeHEADERS: $(nobase_myinclude_HEADERS) @$(NORMAL_INSTALL) @list='$(nobase_myinclude_HEADERS)'; test -n "$(myincludedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(myincludedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(myincludedir)" || exit 1; \ fi; \ $(am__nobase_list) | while read dir files; do \ xfiles=; for file in $$files; do \ if test -f "$$file"; then xfiles="$$xfiles $$file"; \ else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \ test -z "$$xfiles" || { \ test "x$$dir" = x. || { \ echo " $(MKDIR_P) '$(DESTDIR)$(myincludedir)/$$dir'"; \ $(MKDIR_P) "$(DESTDIR)$(myincludedir)/$$dir"; }; \ echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(myincludedir)/$$dir'"; \ $(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(myincludedir)/$$dir" || exit $$?; }; \ done uninstall-nobase_myincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(nobase_myinclude_HEADERS)'; test -n "$(myincludedir)" || list=; \ $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \ dir='$(DESTDIR)$(myincludedir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(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-recursive 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" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive 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 -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @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 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || 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 \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build/sub \ && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive 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." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: 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: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-myincludeHEADERS \ uninstall-nobase_myincludeHEADERS uninstall-pkgconfigDATA .MAKE: $(am__recursive_targets) all check install install-am \ install-data-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 \ 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 .PRECIOUS: makefile $(top_srcdir)/cppad/configure.hpp: cppad/configure.hpp cp cppad/configure.hpp $(top_srcdir)/cppad/configure.hpp @CppAD_HAVE_AR_FALSE@ SPEED_TESTS = @CppAD_HAVE_AR_FALSE@ SPEED_DIRS = test: all rm -f test.log touch test.log echo "#! /bin/sh -e" > test.sh for dir in $(test_directory_list) ; do ( \ echo "#" >> test.sh ; \ echo "echo \"Running make test in $$dir\"" >> test.sh ; \ echo "cd $$dir " >> test.sh ; \ echo "make test" >> test.sh ; \ echo "cd $(ABS_TOP_BUILDDIR)" >> test.sh ; \ ) done 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. .NOEXPORT: cppad-20160000.1/omh/0002755000175200017650000000000012656321777013224 5ustar coincoin-webcppad-20160000.1/omh/subversion.omh0000644000175200017650000000665012656321764016131 0ustar coincoin-web$Id: subversion.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin subversion$$ $spell 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$$ $head File Format$$ The files corresponding to this download procedure are in Unix format; i.e., each line ends with just a line feed. $head Subversion$$ You must have $href%http://subversion.tigris.org/%subversion%$$ installed to use this download procedure. In Unix, you can check if subversion is already installed in your path by entering the command $codep which svn $$ $head OMhelp$$ The documentation for CppAD is built from the source code files using $href%http://www.seanet.com/~bradbell/omhelp/%OMhelp%$$. In Unix, you can check if OMhelp is already installed in your path by entering the command $codep 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% %$$ 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 %$$ $head Stable Versions$$ Subversion downloads are available for a set of stable versions (after the specified date, only bug fixes get applied). The following link will list the available $icode dir$$ values corresponding to $href% 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% %$$ To see if this has been done correctly, check for the following file: $codei% %dir%/cppad/cppad.hpp %$$ Note that it will correspond to the most recent release for this stable version. $head Release Versions$$ Subversion downloads are available for a set of release versions (no changes are applied). The following link will list the available $icode dir$$ values corresponding to $href% 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% %$$ To see if this has been done correctly, check for the following file: $codei% %dir%/cppad/cppad.hpp %$$ $head Build the Documentation$$ Now build the documentation for this version using the commands $codei% cd %dir% ./build.sh configure omhelp %$$ $head Continue with Installation$$ Once the steps above are completed, you can proceed with the install instructions in the documentation you just built. Start by opening the file $codei% %dir%/doc/index.xml %$$ in a web browser and proceeding to the install instructions in that documentation, skipping the Download section and starting with the Configure command. $end cppad-20160000.1/omh/numeric_type.omh0000644000175200017650000000762512656321764016440 0ustar coincoin-web$Id: numeric_type.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin NumericType$$ $spell const std valarray $$ $section Definition of a Numeric Type$$ $mindex int$$ $head Type Requirements$$ A $icode NumericType$$ is any type that satisfies the requirements below. The following is a list of some numeric types: $code int$$, $code float$$, $code double$$, $code AD$$, $code AD< AD >$$. The routine $cref CheckNumericType$$ can be used to check that a type satisfies these conditions. $head Default Constructor$$ The syntax $codei% %NumericType% %x%; %$$ creates a $icode NumericType$$ object with an unspecified value. $head Constructor From Integer$$ If $icode i$$ is an $code int$$, the syntax $codei% %NumericType% %x%(%i%); %$$ creates a $icode NumericType$$ object with a value equal to $icode i$$ where $icode i$$ can be $code const$$. $head Copy Constructor$$ If $icode x$$ is a $icode NumericType$$ object the syntax $codei% %NumericType% %y%(%x%); %$$ creates a $icode NumericType$$ object $icode y$$ with the same value as $icode x$$ where $icode x$$ can be $code const$$. $head Assignment$$ If $icode x$$ and $icode y$$ are $icode NumericType$$ objects, the syntax $codei% %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% %$$ may not be legal. $head Operators$$ Suppose $icode x$$, $icode y$$ and $icode z$$ $icode NumericType$$ objects where $icode x$$ and $icode y$$ may be $code const$$. In the result type column, $icode NumericType$$ can be replaced by any type that can be used just like a $icode NumericType$$ object. $table $bold Operation$$ $cnext $bold Description$$ $cnext $bold Result Type$$ $rnext $codei%+%x%$$ $cnext unary plus $cnext $icode NumericType$$ $rnext $codei%-%x%$$ $cnext unary minus $cnext $icode NumericType$$ $rnext $icode%x% + %y%$$ $cnext binary addition $cnext $icode NumericType$$ $rnext $icode%x% - %y%$$ $cnext binary subtraction $cnext $icode NumericType$$ $rnext $icode%x% * %y%$$ $cnext binary multiplication $cnext $icode NumericType$$ $rnext $icode%x% / %y%$$ $cnext binary division $cnext $icode NumericType$$ $rnext $icode%z% += %y%$$ $cnext computed assignment addition $cnext unspecified $rnext $icode%z% -= %y%$$ $cnext computed assignment subtraction $cnext unspecified $rnext $icode%z% *= %y%$$ $cnext computed assignment multiplication $cnext unspecified $rnext $icode%z% /= %y%$$ $cnext computed assignment division $cnext unspecified $tend $head Example$$ $children% example/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$$ $list number$$ List three operators that are not supported by every numeric type but that are supported by the numeric types $code int$$, $code float$$, $code double$$. $lnext Which of the following are numeric types: $code std::complex$$, $code std::valarray$$, $code std::vector$$ ? $lend $end cppad-20160000.1/omh/glossary.omh0000644000175200017650000002216312656321764015572 0ustar coincoin-web$Id: glossary.omh 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. -------------------------------------------------------------------------- */ $begin glossary$$ $aindex head subhead$$ $spell std Vec cos bool Op Diff Var Cpp enum Taylor $$ $section Glossary$$ $mindex efficient$$ $head AD Function$$ Given an $cref ADFun$$ object $icode f$$ there is a corresponding AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$. This operation sequence defines a function $latex F : B^n \rightarrow B^m $$ where $icode B$$ is the space corresponding to objects of type $icode Base$$, $icode n$$ is the size of the $cref/domain/seq_property/Domain/$$ space, and $icode m$$ is the size of the $cref/range/seq_property/Range/$$ space. We refer to $latex F$$ as the AD function corresponding to the operation sequence stored in the object $icode f$$. (See the $cref/FunCheck discussion/FunCheck/Discussion/$$ for possible differences between $latex F(x)$$ and the algorithm that defined the operation sequence.) $head AD of Base$$ An object is called an AD of $icode Base$$ object its type is either $codei%AD<%Base%>%$$ (see the default and copy $cref/constructors/ad_ctor/$$ or $codei%VecAD<%Base%>::reference%$$ (see $cref VecAD$$) for some $icode Base$$ type. $head AD Type Above Base$$ If $icode Base$$ is a type, an AD type above $icode Base$$ is the following sequence of types: $codei% AD<%Base%> %,% AD< AD<%Base%> > %,% AD< AD< AD<%Base%> > > %,% %...% %$$ $head Base Function$$ A function $latex f : B \rightarrow B$$ 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$$. $head Base Type$$ If $icode x$$ is an $codei%AD<%Base%>%$$ object, $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 $latex \[ e_i^j = \left\{ \begin{array}{ll} 1 & {\rm if} \; i = j \\ 0 & {\rm otherwise} \end{array} \right. \] $$ $head Operation$$ $subhead Atomic$$ An atomic $icode Type$$ operation is an operation that has a $icode Type$$ result and is not made up of other more basic operations. $subhead Sequence$$ A sequence of atomic $icode Type$$ operations is called a $icode Type$$ operation sequence. A sequence of atomic $cref/AD of Base/glossary/AD of Base/$$ operations is referred to as an AD of $icode Base$$ operation sequence. The abbreviated notation AD operation sequence is often used when it is not necessary to specify the base type. $subhead Dependent$$ Suppose that $icode x$$ and $icode y$$ are $icode Type$$ objects and the result of $codei% %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%); %$$ 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. In this case, we say that the $icode Type$$ operation sequence depends on $icode x$$ and $icode y$$. $subhead Independent$$ Suppose that $icode i$$ and $icode n$$ are $code size_t$$ objects, and $icode%x%[%i%]%$$, $icode y$$ are $icode Type$$ objects, 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%]; %$$ 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 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. $head Sparsity Pattern$$ CppAD describes a sparse matrix as a vector of sets with each vector component corresponding to a row and the elements of the set corresponding to the possibly non-zero columns. A vector of $code bool$$ can represent a vector of sets using one bit per element. (Some vectors of $code bool$$ use one byte per element but $cref/vectorBool/CppAD_vector/vectorBool/$$ is an example class that uses one bit per element.) The problem is that this representation uses one bit for both the elements that are there and the ones that are not. $pre $$ A vector of $code std::set$$ does not represent the elements that are not present, but it uses about three $code size_t$$ values for each element that is present. For example, if $code size_t$$ uses 32 bits, a vector of $code std::set$$ uses about 100 bits for each element that is present in the vector of sets. Thus, a vector of $code std::set$$ should be more efficient for very sparse matrix representations. $subhead Vector of Boolean$$ Given a matrix $latex A \in B^{m \times n}$$, a vector of $code bool$$ $latex B$$ of length $latex m \times n$$ is a sparsity pattern for $latex A$$ if for $latex i = 0, \ldots , m-1$$ and $latex j = 0 , \ldots n-1$$, $latex \[ A_{i,j} \neq 0 \; \Rightarrow \; B_{i * n + j} = {\rm true} \] $$ Given two sparsity patterns $latex B$$ and $icode C$$ for a matrix $icode A$$, we say that $icode B$$ is more efficient than $icode C$$ if $icode B$$ has fewer true elements than $icode C$$. For example, if $latex A$$ is the identity matrix, $latex \[ B_{i * n + j} = (i = j) \] $$ defines an efficient sparsity pattern for $latex A$$. $subhead Vector of Sets$$ Given a matrix $latex A \in B^{m \times n}$$, a vector of sets $latex S$$ of length $latex m$$ is a sparsity pattern for $latex A$$ if for $latex i = 0, \ldots , m-1$$ $latex \[ A_{i,j} \neq 0 \; \Rightarrow \; j \in S_i \] $$ Given two sparsity patterns $latex S$$ and $icode T$$ for a matrix $icode A$$, we say that $icode S$$ is more efficient than $icode T$$ if $icode S$$ has fewer elements than $icode T$$. For example, if $latex A$$ is the identity matrix, $latex \[ S_i = \{ i \} \] $$ defines an efficient sparsity pattern for $latex A$$. $head Tape$$ $subhead Active$$ A new tape is created and becomes active after each call of the form (see $cref Independent$$) $codei% 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/$$) $codei% %f%.Dependent( %x%, %y%) %$$ After such a transfer, the tape becomes inactive. $subhead Independent Variable$$ While the tape is active, we refer to the elements of $icode x$$ as the independent variables for the tape. When the tape becomes inactive, the corresponding objects become $cref/parameters/glossary/Parameter/$$. $subhead Dependent Variables$$ While the tape is active, we use the term dependent variables for the tape for any objects whose value depends on the independent variables for the tape. When the tape becomes inactive, the corresponding objects become $cref/parameters/glossary/Parameter/$$. $head Taylor Coefficient$$ Suppose $latex X : B \rightarrow B^n$$ is a is $latex p$$ times continuously differentiable function in some neighborhood of zero. For $latex k = 0 , \ldots , p$$, we use the column vector $latex x^{(k)} \in B^n$$ for the $th k$$ order Taylor coefficient corresponding to $latex X$$ which is defined by $latex \[ 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) \]$$ where the remainder $latex R(t)$$ divided by $latex t^p$$ converges to zero and $latex t$$ goes to zero. $head Variable$$ An $codei%AD<%Base%>%$$ object $icode u$$ is a variable if 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. For example, directly after the code sequence $codei% 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; %$$ $icode u$$ is currently a $cref/parameter/glossary/Parameter/$$ (not a variable). $pre $$ Note that we often drop the word currently and just refer to an $codei%AD<%Base%>%$$ object as a variable or parameter. $end cppad-20160000.1/omh/utility.omh0000644000175200017650000000631712656321764015435 0ustar coincoin-web$Id: utility.omh 3769 2015-12-29 16:13:16Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin utility$$ $spell CppAD namespace alloc cppad.hpp $$ $section Some General Purpose Utilities$$ These routines can be include individually; for example, $codep # include $$ only includes the definitions necessary for the $code CppAD::vector$$ class. They can also be included as a group, separate from the rest of CppAD, using $codep # include $$ They will also be included, along with the rest of CppAD, using $codep # include $$ $children% cppad/utility/error_handler.hpp% cppad/utility/near_equal.hpp% cppad/utility/speed_test.hpp% cppad/utility/time_test.hpp% omh/numeric_type.omh% cppad/utility/check_numeric_type.hpp% omh/simple_vector.omh% cppad/utility/check_simple_vector.hpp% cppad/utility/nan.hpp% cppad/utility/pow_int.hpp% cppad/utility/poly.hpp% omh/lu_det_and_solve.omh% cppad/utility/romberg_one.hpp% cppad/utility/romberg_mul.hpp% cppad/utility/runge_45.hpp% cppad/utility/rosen_34.hpp% cppad/utility/ode_err_control.hpp% cppad/utility/ode_gear.hpp% cppad/utility/ode_gear_control.hpp% cppad/utility/vector.hpp% omh/thread_alloc.omh% cppad/utility/index_sort.hpp% cppad/utility/to_string.hpp %$$ $head Testing$$ The routines listed below support numerical correctness and speed testing: $table $rref NearEqual$$ $rref time_test$$ $rref speed_test$$ $rref SpeedTest$$ $tend $head C++ Concepts$$ We refer to a the set of classes that satisfy certain conditions as a C++ concept. The following concepts are used by the CppAD Template library: $table $rref NumericType$$ $rref CheckNumericType$$ $rref SimpleVector$$ $rref CheckSimpleVector$$ $tend $head General Numerical Routines$$ The routines listed below are general purpose numerical routines written with the floating point type a C++ template parameter. This enables them to be used with algorithmic differentiation types, as well as for other purposes. $table $rref nan$$ $rref pow_int$$ $rref Poly$$ $rref LuDetAndSolve$$ $rref RombergOne$$ $rref RombergMul$$ $rref Runge45$$ $rref Rosen34$$ $rref OdeErrControl$$ $rref OdeGear$$ $rref OdeGearControl$$ $tend $head Miscellaneous$$ $subhead Error Handler$$ All of the routines in the CppAD namespace use the following general purpose error handler: $table $rref ErrorHandler$$ $tend $subhead Simple Vector Template Class$$ A simple implementation of a template vector class (that is easy to view in a C++ debugger): $table $rref CppAD_vector$$ $tend $subhead Multi-Threading Memory Allocation$$ $table $rref thread_alloc$$ $tend $subhead Sorting Indices$$ $table $rref index_sort$$ $tend $subhead to_string$$ $table $rref to_string$$ $tend $end cppad-20160000.1/omh/wish_list.omh0000644000175200017650000001310112656321764015724 0ustar coincoin-web$Id: wish_list.omh 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. -------------------------------------------------------------------------- */ $begin wish_list$$ $spell op Recomputation jacobian nz RevSparseJac optimizer Rel Gt Eq CondExpLt Checkpointing grep recomputed afun iterator std cos Adolc xml hpp CppAD Atan cppad mul div instantiate instantiation Bool runge $$ $section The CppAD Wish List$$ $head Base Requirements$$ Change the $cref/Base requirements/base_require/$$ to use template specialization instead of functions so that there is a default value for each function. The default would result in a $cref/known/cppad_assert/Known/$$ assert when the operation is used and not defined by the base class. An example of this type of template specialization can be found in the implementation of $cref to_string$$. $head PrintFor Optimization$$ Do not remove $cref PrintFor$$ operations during $cref optimize$$ because they are very useful when debugging expected calculations on the tape. If not this, we at least need to disable optimization of $cref checkpoint$$ functions. $head checkpoint$$ There should be some examples and tests for both speed and memory use that demonstrate that checkpointing is useful. $head Machine Epsilon in Examples$$ Use a multiple of $code std::numeric_limits::epsilon()$$ instead $code 1e-10$$ for a small number in correctness checks; e.g., see $cref sqrt.cpp$$. $head Adolc$$ Create a documentation page that shows how to convert Adolc commands to CppAD commands. $head Optimizing Nested Conditional Expressions$$ If one $cref/optimizes/optimize/$$ 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 expressions $code true_x$$, $code false_x$$, $code true_y$$, $code false_y$$ will be evaluated (two will be skipped depending on the result of $code left_z == right_z$$). Not all of the expressions corresponding to $code left_x$$, $code right_x$$, $code left_y$$, $code right_y$$ need to be evaluate, but they are. The optimizer could be improved to skip two more expressions (depending on the result of $code left_z == right_z$$). $head Forward Mode Recomputation$$ If the results of $cref forward_order$$ have already been computed and are still stored in the $cref ADFun$$ object (see $cref size_order$$), then they do not need to be recomputed and the results can just be returned. $head Iterator Interface$$ All of the CppAD simple vector interfaces should also have an iterator version for the following reasons: $list number$$ It would not be necessary to copy information to simple vectors when it was originally stored in a different type of container. $lnext 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). $lend $head Compilation Speed$$ One could build a CppAD library for use with the type $code AD$$. This would speed up compilation for the most common usage where the $icode Base$$ type is $code double$$. $head 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 Comparison Changes and Optimization$$ The comparison operators used to not be taped when $cref/NDEBUG/Faq/Speed/NDEBUG/$$ was defined. They are now taped so that the $cref compare_change$$ interface works even for compiler optimize code. This caused a significant slow down in the $cref cppad_det_lu.cpp$$ speed test (with no options specified). Perhaps there should be an option to skip the comparison taping. $head Software Guidelines$$ 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 $$ 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 cppad-20160000.1/omh/atomic_base.omh0000644000175200017650000000720412656321764016174 0ustar coincoin-web/* $Id: atomic_base.omh 3717 2015-08-31 22:16:15Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin 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%.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/local/atomic_base.hpp% example/atomic/get_started.cpp% example/atomic/norm_sq.cpp% example/atomic/reciprocal.cpp% example/atomic/sparsity.cpp% example/atomic/tangent.cpp% example/atomic/hes_sparse.cpp% example/atomic/mat_mul.cpp %$$ $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_hes_sparse.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 cppad-20160000.1/omh/faq.omh0000644000175200017650000001633712656321764014504 0ustar coincoin-web$Id: faq.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin Faq$$ $escape !$$ $spell instantiating cppad@list.coin-or.org faq std whatsnew sqrt cmath Namespace Dvector Gcc CppAD Lu $$ $section Frequently Asked Questions and Answers$$ $mindex FAQ operator reporting ErrorHandler avoid record taping mode CPPAD_TESTVECTOR standard math function storage$$ $head Assignment and Independent$$ Why does the code sequence $codei% Independent(%u%); %v% = %u%[0]; %$$ behave differently from the code sequence $codei% %v% = %u%[0]; Independent(%u%); %$$ Before the call to $cref Independent$$, $icode%u%[0]%$$ is a $cref/parameter/glossary/Parameter/$$ and after the call it is a variable. Thus in the first case, $icode v$$ is a variable and in the second case it is a parameter. $head Bugs$$ What should I do if I suspect that there is a bug in CppAD ? $pre $$ $list number$$ The first step is to search this page for mention of some feature that perhaps you interpreting as a bug (and is not). If this does not solve your problem, continue to the next step. $lnext The second step is to check the $cref whats_new$$ messages from the date of the release that you are using to the current date. If the bug has been mentioned and fixed, then $cref install$$ the current version of CppAD. If this does not solve your problem, continue to the next step. $lnext Create a simple as possible demonstration of the bug; see the file $code bug/template.sh$$ for a template that you can edit for that purpose. The smaller the program, the better the bug report. $lnext Send an e-mail message to the mailing list $href% http://list.coin-or.org/mailman/listinfo/cppad% cppad@list.coin-or.org %$$ with a description of the bug. Attaching your program that demonstrates the bug. $lend $head CompareChange$$ If you attempt to use the $cref CompareChange$$ function when $code NDEBUG$$ is true, you will get an error message stating that $code CompareChange$$ is not a member of the $cref ADFun$$ template class. $head Complex Types$$ Which of the following complex types is better: $codei% 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%> > %$$ On the other hand, the C++ standard only specifies $codei%std::complex<%Type%>%$$ where $icode Type$$ is $code float$$, $code double$$, or $code lone double$$. The effect of instantiating the template complex for any other type is unspecified. $head Exceptions$$ Why, in all the examples, do you pass back a boolean variable instead of throwing an exception ? $pre $$ 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 $cref ErrorHandler$$ utility to signal exceptions. Specifications for redefining this action are provided. $head Independent Variables$$ Is it possible to evaluate the same tape recording with different values for the independent variables ? $pre $$ Yes (see $cref forward_zero$$). $head 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 ? $pre $$ The example routine $cref LuSolve$$ can be used to do this because the inverse is a special case of the solution of linear equations. The examples $cref jac_lu_det.cpp$$ and $cref hes_lu_det.cpp$$ use LuSolve to compute derivatives of the determinant with respect to the components of the matrix. $head 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 ? $pre $$ In general, the best mode depends on the number of domain and range components in the function that your are differentiating. Each call to $cref Forward$$ computes the derivative of all the range directions with respect to one domain direction. Each call to $cref Reverse$$ computes the derivative of one range direction with respect to all the domain directions. The times required for (speed of) calls $code Forward$$ and $code Reverse$$ are about equal. The $cref/Parameter/seq_property/Parameter/$$ function can be used to quickly determine that some range directions have derivative zero. $head Namespace$$ $subhead Test Vector Preprocessor Symbol$$ Why do you use $code CPPAD_TESTVECTOR$$ instead of a namespace for the CppAD $cref testvector$$ class ? $pre $$ The preprocessor symbol $small $cref/CPPAD_TESTVECTOR/testvector/$$ $$ determines which $cref SimpleVector$$ template class is used for extensive testing. The default definition for $code CPPAD_TESTVECTOR$$ is the $cref/CppAD::vector/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 $code CPPAD$$ (some old deprecated symbols begin with $code CppAD$$). $subhead Using$$ Why do I have trouble when the following command $codep using namespace CppAD $$ is at the global level (not within a function or some other limited scope). $pre $$ Some versions of $code # include $$ for gcc and Visual C++ define the standard math functions, (for example $codei%double sqrt(double %x%)%$$) at the global level. It is necessary to put your $code using$$ commands within the scope of a function, or some other limited scope, in order to shadow these improper global definitions. $head Speed$$ How do I get the best speed performance out of CppAD ? $subhead NDEBUG$$ You should compile your code with optimization, without debugging, and with the preprocessor symbol $code NDEBUG$$ defined. (The $cref speed_cppad$$ tests do this.) Note that defining $code NDEBUG$$ will turn off all of the error checking and reporting that is done using $cref ErrorHandler$$. $subhead Optimize$$ It is also possible that preforming a tape $cref/optimization/optimize/$$ will improve the speed of evaluation more than the time required for the optimization. $subhead Memory Allocation$$ You may also increase execution speed by calling $code hold_memory$$ with $cref/value/ta_hold_memory/value/$$ equal to true. $head Tape Storage: Disk or Memory$$ Does CppAD store the tape on disk or in memory ? $pre $$ CppAD uses memory to store a different tape for recording operations for each $codei%AD<%Base%>%$$ type that is used. If you have a very large number calculations that are recorded on a tape, the tape will keep growing to hold the necessary information. Eventually, virtual memory may be used to store the tape and the calculations may slow down because of necessary disk access. $end cppad-20160000.1/omh/appendix.omh0000644000175200017650000000160712656321764015537 0ustar coincoin-web$Id: appendix.omh 3759 2015-11-30 19:54:58Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin Appendix$$ $spell $$ $section Appendix$$ $childtable% omh/faq.omh% omh/theory/theory.omh% omh/glossary.omh% omh/bib.omh% omh/wish_list.omh% omh/whats_new/whats_new.omh% omh/deprecated/deprecated.omh% compare_c/CMakeLists.txt% omh/numeric_ad.omh% omh/addon.omh% omh/license.omh %$$ $end cppad-20160000.1/omh/cos_forward.omh0000644000175200017650000000422612656321764016237 0ustar coincoin-web$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. A copy of 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 CosForward$$ $spell 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) \] $$ and in the $xref/ ForwardTheory/ Standard Math Functions/ Differential Equation/ standard math function differential equation/ 1 /$$, $latex A(x) = 0$$, $latex B(x) = 1$$, and $latex D(x) = - \sin(x)$$. We use $latex a$$, $latex b$$, $latex d$$, $latex s$$ and $latex z$$ to denote the Taylor coefficients for $latex A [ X (t) ] $$, $latex B [ X (t) ]$$, $latex D [ X (t) ] $$, $latex \sin [ 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} z^{(0)} & = & \cos ( x^{(0)} ) \\ e^{(j)} & = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} \\ & = & -s^{(j)} \\ z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \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} \sum_{k=1}^{j+1} k x^{(k)} s^{(j+1-k)} \end{array} \] $$ Using $latex c$$ for the Taylor coefficients of $latex \cos[ X(t) ]$$ the order $latex j+1$$ coefficient can be generated using the lower order coefficients for $latex \sin[ X(t) ]$$ and $latex \cos[ X(t) ]$$ by the following formula: $latex \[ c^{(j+1)} = - \frac{1}{j+1} \sum_{k=1}^{j+1} k x^{(k)} s^{(j+1-k)} \] $$ $end cppad-20160000.1/omh/atomic.omh0000644000175200017650000000134112656321764015176 0ustar coincoin-web// $Id: atomic.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin atomic$$ $section Atomic AD Functions$$ $mindex operation$$ $childtable% cppad/local/checkpoint.hpp% omh/atomic_base.omh %$$ $end cppad-20160000.1/omh/sin_forward.omh0000644000175200017650000000421312656321764016240 0ustar coincoin-web$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. A copy of 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 SinForward$$ $spell 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) \] $$ and in the $xref/ ForwardTheory/ Standard Math Functions/ Differential Equation/ standard math function differential equation/ 1 /$$, $latex A(x) = 0$$, $latex B(x) = 1$$, and $latex D(x) = \cos(x)$$. We use $latex a$$, $latex b$$, $latex d$$, $latex c$$ and $latex z$$ to denote the Taylor coefficients for $latex A [ X (t) ] $$, $latex B [ X (t) ]$$, $latex D [ X (t) ] $$, $latex \cos [ 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} z^{(0)} & = & \sin ( x^{(0)} ) \\ e^{(j)} & = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} \\ & = & c^{(j)} \\ z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } \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} \sum_{k=1}^{j+1} k x^{(k)} c^{(j+1-k)} \end{array} \] $$ Using $latex s$$ for the Taylor coefficients of $latex \sin[ X(t) ]$$ the order $latex j+1$$ coefficient can be generated using the lower order coefficients for $latex \sin[ X(t) ]$$ and $latex \cos[ X(t) ]$$ by the following formula: $latex \[ s^{(j+1)} = \frac{1}{j+1} \sum_{k=1}^{j+1} k x^{(k)} c^{(j+1-k)} \] $$ $end cppad-20160000.1/omh/det_by_lu_hpp.omh0000644000175200017650000000154012656321764016540 0ustar coincoin-web$Id: det_by_lu_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin det_by_lu.hpp$$ $spell det_by_lu ifndef endif $$ $section Source: det_by_lu$$ $mindex source$$ $code # ifndef CPPAD_DET_BY_LU_HPP $pre $$ # define CPPAD_DET_BY_LU_HPP $verbatim%cppad/speed/det_by_lu.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/speed/0002755000175200017650000000000012656321764014320 5ustar coincoin-webcppad-20160000.1/omh/speed/speed_utility.omh0000644000175200017650000000324512656321764017712 0ustar coincoin-web$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. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin speed_utility$$ $section Speed Testing Utilities$$ $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 %$$ $head Speed Main Program$$ $table $rref speed_main$$ $tend $head Speed Utility Routines$$ $table $rref det_by_lu$$ $rref det_by_minor$$ $rref det_of_minor$$ $rref det_33$$ $rref det_grad_33$$ $rref mat_sum_sq$$ $rref ode_evaluate$$ $rref sparse_jac_fun$$ $rref sparse_hes_fun$$ $rref uniform_01$$ $tend $head Library Routines$$ $table $rref LuFactor$$ $rref LuInvert$$ $rref LuSolve$$ $rref Poly$$ $tend $head Source Code$$ $table $rref det_by_lu.hpp$$ $rref det_by_minor.hpp$$ $rref det_grad_33.hpp$$ $rref det_of_minor.hpp$$ $rref lu_factor.hpp$$ $rref lu_invert.hpp$$ $rref lu_solve.hpp$$ $rref mat_sum_sq.hpp$$ $rref poly.hpp$$ $rref sparse_jac_fun.hpp$$ $rref sparse_hes_fun.hpp$$ $rref uniform_01.hpp$$ $tend $end cppad-20160000.1/omh/speed/speed_cppad.omh0000644000175200017650000000325512656321764017277 0ustar coincoin-web$Id: speed_cppad.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin speed_cppad$$ $spell cmake cppad CppAD Cygwin Microsoft chdir Workspace dsw exe sln $$ $section Speed Test Derivatives Using CppAD$$ $head 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). $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/$$: $codei% 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% %$$ 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 %$$ $end cppad-20160000.1/omh/speed/speed_double.omh0000644000175200017650000000312412656321764017455 0ustar coincoin-web$Id: speed_double.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin speed_double$$ $spell cmake cppad CppAD Cygwin Microsoft chdir Workspace dsw exe sln $$ $section Speed Test of Functions in Double$$ $head 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. $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/$$: $codei% 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% %$$ 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 %$$ $end cppad-20160000.1/omh/speed/speed_sacado.omh0000644000175200017650000000333412656321764017440 0ustar coincoin-web$Id: speed_sacado.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin speed_sacado$$ $spell cmake SacadoDir CppAD Cygwin $$ $section Speed Test Derivatives Using Sacado$$ $head 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). $head sacado_prefix$$ To run these tests, you must include the $cref sacado_prefix$$ in you $cref/cmake command/cmake/CMake Command/$$. $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/$$: $codei% 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% %$$ 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 %$$ $end cppad-20160000.1/omh/speed/speed.omh0000644000175200017650000000266112656321764016130 0ustar coincoin-web$Id: speed.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin speed$$ $spell cppad CppAD Cygwin Microsoft chdir Workspace dsw exe sln $$ $section Speed Test an Operator Overloading AD Package$$ $head 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 $href% https://projects.coin-or.org/ADOL-C% Adolc %$$, $href% http://www.coin-or.org/CppAD/% CppAD %$$, $href% http://www.fadbad.com/% Fadbad %$$ and $href% http://trilinos.sandia.gov/packages/sacado/% Sacado %$$. 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 %$$ $end cppad-20160000.1/omh/speed/speed_fadbad.omh0000644000175200017650000000333412656321764017407 0ustar coincoin-web$Id: speed_fadbad.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin speed_fadbad$$ $spell cmake FadbadDir CppAD Cygwin $$ $section Speed Test Derivatives Using Fadbad$$ $head 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). $head fadbad_prefix$$ To run these tests, you must include the $cref fadbad_prefix$$ in you $cref/cmake command/cmake/CMake Command/$$. $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/$$: $codei% 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% %$$ 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 %$$ $end cppad-20160000.1/omh/speed/speed_adolc.omh0000644000175200017650000000335012656321764017266 0ustar coincoin-web$Id: speed_adolc.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin speed_adolc$$ $spell cmake AdolcDir CppAD Cygwin $$ $section Speed Test of Derivatives Using Adolc$$ $head 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). $head adolc_prefix$$ To run these tests, you must include the $cref adolc_prefix$$ in you $cref/cmake command/cmake/CMake Command/$$. $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/$$: $codei% 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% %$$ 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 %$$ $end cppad-20160000.1/omh/deprecated/0002755000175200017650000000000012656321764015320 5ustar coincoin-webcppad-20160000.1/omh/deprecated/deprecated.omh0000644000175200017650000000263512656321764020131 0ustar coincoin-web// $Id: deprecated.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin deprecated$$ $spell CppAD Bool $$ $section CppAD Deprecated API Features$$ $childtable% omh/deprecated/include_deprecated.omh% omh/deprecated/fun_deprecated.omh% omh/deprecated/compare_change.omh% cppad/local/omp_max_thread.hpp% cppad/utility/track_new_del.hpp% omh/deprecated/omp_alloc.omh% cppad/utility/memory_leak.hpp% cppad/local/epsilon.hpp% cppad/local/test_vector.hpp% cppad_ipopt/src/cppad_ipopt_nlp.hpp% cppad/local/old_atomic.hpp% cppad/local/zdouble.hpp %$$ $table $cref/CppADCreateUnaryBool/BoolFun/Deprecated 2007-07-31/$$ $cnext $title BoolFun$$ $rnext $cref/CppADCreateDiscrete/Discrete/CppADCreateDiscrete Deprecated 2007-07-28/$$ $cnext $title Discrete$$ $rnext $cref auto_tools$$ $cnext $title auto_tools$$ $rnext $cref/nan(zero)/nan/nan(zero)/$$ $cnext $codei%nan(%zero%)%$$ $tend $end cppad-20160000.1/omh/deprecated/include_deprecated.omh0000644000175200017650000001007112656321764021625 0ustar coincoin-web$Id: include_deprecated.omh 3762 2015-12-01 14:35:37Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin include_deprecated$$ $spell sudo mv Rosen cppad.hpp CppAD Runge cp dir ln lu Romberg Mul $$ $section Deprecated Include Files$$ $head Deprecated 2015-11-30$$ The $cref utility$$ individual include files have been deprecated; e.g., $codep # include $$ You should instead use $codep # include $$ $head Deprecated 2006-12-17$$ The following is a list of deprecated include file names and the corresponding names that should be used. For example, if your program uses the deprecated preprocessor command $codep # include $$ you should change it to the command $codep # include $$ $head Linking New Files to Deprecated Commands$$ On Unix systems, references in your source code of the from $codei% # include %$$ will refer to the older versions of CppAD unless you preform the following steps (this only needs to be done once, not for every install): $codei% cp %prefix_dir%/include sudo mv CppAD CppAD.old sudo ln -s cppad CppAD %$$ where $cref/prefix_dir/auto_tools/prefix_dir/$$ is the prefix directory corresponding to your $cref/Unix installation/auto_tools/$$. This will link form the deprecated commands to the commands that should be used: $table $bold Deprecated$$ $pre $$ $cnext $bold Should Use$$ $pre $$ $cnext $bold Documentation$$ $rnext CppAD/CheckNumericType.h $pre $$ $cnext cppad/check_numeric_type.hpp $pre $$ $cnext $cref CheckNumericType$$ $rnext CppAD/CheckSimpleVector.h $pre $$ $cnext cppad/check_simple_vector.hpp $pre $$ $cnext $cref CheckSimpleVector$$ $rnext CppAD/CppAD.h $pre $$ $cnext cppad/cppad.hpp $pre $$ $cnext $cref CppAD$$ $rnext CppAD/CppAD_vector.h $pre $$ $cnext cppad/vector.hpp $pre $$ $cnext $cref CppAD_vector$$ $rnext CppAD/ErrorHandler.h $pre $$ $cnext cppad/error_handler.hpp $pre $$ $cnext $cref ErrorHandler$$ $rnext CppAD/LuFactor.h $pre $$ $cnext cppad/lu_factor.hpp $pre $$ $cnext $cref LuFactor$$ $rnext CppAD/LuInvert.h $pre $$ $cnext cppad/lu_invert.hpp $pre $$ $cnext $cref LuInvert$$ $rnext CppAD/LuSolve.h $pre $$ $cnext cppad/lu_solve.hpp $pre $$ $cnext $cref LuSolve$$ $rnext CppAD/NearEqual.h $pre $$ $cnext cppad/near_equal.hpp $pre $$ $cnext $cref NearEqual$$ $rnext CppAD/OdeErrControl.h $pre $$ $cnext cppad/ode_err_control.hpp $pre $$ $cnext $cref OdeErrControl$$ $rnext CppAD/OdeGear.h $pre $$ $cnext cppad/ode_gear.hpp $pre $$ $cnext $cref OdeGear$$ $rnext CppAD/OdeGearControl.h $pre $$ $cnext cppad/ode_gear_control.hpp $pre $$ $cnext $cref OdeGearControl$$ $rnext CppAD/Poly.h $pre $$ $cnext cppad/poly.hpp $pre $$ $cnext $cref Poly$$ $rnext CppAD/PowInt.h $pre $$ $cnext cppad/pow_int.hpp $pre $$ $cnext $cref pow_int$$ $rnext CppAD/RombergMul.h $pre $$ $cnext cppad/romberg_mul.hpp $pre $$ $cnext $cref RombergMul$$ $rnext CppAD/RombergOne.h $pre $$ $cnext cppad/romberg_one.hpp $pre $$ $cnext $cref RombergOne$$ $rnext CppAD/Rosen34.h $pre $$ $cnext cppad/rosen_34.hpp $pre $$ $cnext $cref Rosen34$$ $rnext CppAD/Runge45.h $pre $$ $cnext cppad/runge_45.hpp $pre $$ $cnext $cref Runge45$$ $rnext CppAD/SpeedTest.h $pre $$ $cnext cppad/speed_test.hpp $pre $$ $cnext $cref SpeedTest$$ $rnext CppAD/TrackNewDel.h $pre $$ $cnext cppad/track_new_del.hpp $pre $$ $cnext $cref TrackNewDel$$ $tend $end cppad-20160000.1/omh/deprecated/omp_alloc.omh0000644000175200017650000000327012656321764017772 0ustar coincoin-web// $Id: omp_alloc.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin omp_alloc$$ $spell openmp cppad/utility/omp_alloc.hpp CppAD $$ $section A Quick OpenMP Memory Allocator Used by CppAD$$ $mindex multi-threading allocation$$ $head Syntax$$ $code # include $$ $head Purpose$$ The C++ $code new$$ and $code 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 $code omp_alloc$$ memory allocator keeps that memory $cref omp_available$$ for the thread so that it can be re-used without waiting for a lock. All the CppAD memory allocations use this utility. The $cref omp_free_available$$ function should be used to return memory to the system (once it is no longer required by a thread). $head Include$$ The routines in sections below are defined by $code cppad/omp_alloc.hpp$$. This file is included by $code cppad/cppad.hpp$$, but it can also be included separately with out the rest of the $code CppAD$$. $head Deprecated 2011-08-23$$ Use $cref thread_alloc$$ instead. $childtable% cppad/utility/omp_alloc.hpp% test_more/omp_alloc.cpp %$$ $end */ cppad-20160000.1/omh/deprecated/fun_deprecated.omh0000644000175200017650000001200112656321764020765 0ustar coincoin-web$Id: fun_deprecated.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin FunDeprecated$$ $spell bool VecAD CppAD const Taylor sizeof var $$ $section ADFun Object Deprecated Member Functions$$ $head Syntax$$ $icode%f%.Dependent(%y%) %$$ $icode%o% = %f%.Order() %$$ $icode%m% = %f%.Memory() %$$ $icode%s% = %f%.Size() %$$ $icode%t% = %f%.taylor_size() %$$ $icode%u% = %f%.use_VecAD() %$$ $icode%v% = %f%.size_taylor() %$$ $icode%w% = %f%.capacity_taylor() %$$ $head Purpose$$ The $codei%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. $head Dependent$$ A recording of and AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ is started by a call of the form $codei% Independent(%x%) %$$ If there is only one such recording at the current time, you can use $icode%f%.Dependent(%y%)%$$ in place of $codei% %f%.Dependent(%x%, %y%) %$$ See $cref Dependent$$ for a description of this operation. $subhead Deprecated 2007-08-07$$ This syntax was deprecated when CppAD was extended to allow for more than one $codei%AD<%Base%>%$$ recording to be active at one time. This was necessary to allow for multiple threading applications. $head Order$$ The result $icode o$$ has prototype $codei% size_t %o% %$$ and is the order of the previous forward operation using the function $icode f$$. This is the highest order of the $cref/Taylor coefficients/glossary/Taylor Coefficient/$$ that are currently stored in $icode f$$. $subhead Deprecated 2006-03-31$$ Zero order corresponds to function values being stored in $icode f$$. In the future, we would like to be able to erase the function values so that $icode f$$ uses less memory. In this case, the return value of $code Order$$ would not make sense. Use $cref size_order$$ to obtain the number of Taylor coefficients currently stored in the ADFun object $icode f$$ (which is equal to the order plus one). $head Memory$$ The result $codei% size_t %m% %$$ and is the number of memory units ($code sizeof$$) required for the information currently stored in $icode f$$. This memory is returned to the system when the destructor for $icode f$$ is called. $subhead Deprecated 2006-03-31$$ It used to be the case that an ADFun object just kept increasing its buffers to the maximum size necessary during its lifetime. It would then return the buffers to the system when its destructor 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 $code Memory$$ function is no longer well defined. $head Size$$ The result $icode s$$ has prototype $codei% 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 $icode f$$ is roughly proportional to $icode s$$. $subhead Deprecated 2006-04-03$$ There are other sizes attached to an ADFun object, for example, the number of operations in the sequence. In order to avoid confusion with these other sizes, use $cref/size_var/seq_property/size_var/$$ to obtain the number of variables in the operation sequence. $head taylor_size$$ The result $icode t$$ has prototype $codei% size_t %t% %$$ and is the number of Taylor coefficient orders currently calculated and stored in the ADFun object $icode f$$. $subhead Deprecated 2006-06-17$$ This function has been replaced by $cref size_order$$. $head use_VecAD$$ The result $icode u$$ has prototype $codei% bool %u% %$$ If it is true, the AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ stored in $icode f$$ contains $cref/VecAD/VecAD/VecAD::reference/$$ operands. Otherwise $icode u$$ is false. $subhead Deprecated 2006-04-08$$ You can instead use $codei% %u% = %f%.size_VecAD() > 0 %$$ $head size_taylor$$ The result $icode v$$ has prototype $codei% size_t %v% %$$ and is the number of Taylor coefficient orders currently calculated and stored in the ADFun object $icode f$$. $subhead Deprecated 2014-03-18$$ This function has been replaced by $cref size_order$$. $head capacity_taylor$$ The result $icode w$$ has prototype $codei% size_t %w% %$$ and is the number of Taylor coefficient orders currently allocated in the ADFun object $icode f$$. $subhead Deprecated 2014-03-18$$ This function has been replaced by $cref capacity_order$$. $end cppad-20160000.1/omh/deprecated/compare_change.omh0000644000175200017650000000475112656321764020765 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin CompareChange$$ $spell const $$ $section Comparison Changes During Zero Order Forward Mode$$ $mindex ADFun CompareChange$$ $head Syntax$$ $icode%c% = %f%.CompareChange()%$$ $pre $$ $bold See Also$$ $cref FunCheck$$ $head Deprecated 2015-01-20$$ This routine has been deprecated, use $cref compare_change$$ instead. $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. This function may be not agree with the algorithm that was used to create the corresponding AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ because of changes in AD $cref/comparison/Compare/$$ results. The $code CompareChange$$ function can be used to detect these changes. $head f$$ The object $icode f$$ has prototype $codei% const ADFun<%Base%> %f% %$$ $head c$$ The result $icode c$$ has prototype $codei% size_t %c% %$$ It is the number of $codei%AD<%Base%>%$$ $cref/comparison/Compare/$$ operations, corresponding to the previous call to $cref Forward$$ $codei% %f%.Forward(0, %x%) %$$ that have a different result from when $icode F$$ was created by taping an algorithm. $head Discussion$$ If $icode c$$ is not zero, the boolean values resulting from some of the $cref/comparison operations/Compare/$$ corresponding to $icode x$$ are different from when the AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ was created. In this case, you may want to re-tape the algorithm with the $cref/independent variables/glossary/Tape/Independent Variable/$$ equal to the values in $icode x$$ (so AD operation sequence properly represents the algorithm for this value of independent variables). On the other hand, re-taping the AD operation sequence usually takes significantly more time than evaluation using $cref forward_zero$$. If the functions values have not changed (see $cref FunCheck$$) it may not be worth re-taping a new AD operation sequence. $end cppad-20160000.1/omh/lu_invert_hpp.omh0000644000175200017650000000153212656321764016602 0ustar coincoin-web$Id: lu_invert_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin lu_invert.hpp$$ $spell Lu ifndef endif $$ $section Source: LuInvert$$ $mindex source$$ $code # ifndef CPPAD_LU_INVERT_HPP $pre $$ # define CPPAD_LU_INVERT_HPP $verbatim%cppad/utility/lu_invert.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/det_by_minor_hpp.omh0000644000175200017650000000156512656321764017253 0ustar coincoin-web$Id: det_by_minor_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin det_by_minor.hpp$$ $spell det_by_minor ifndef endif $$ $section Source: det_by_minor$$ $mindex source$$ $code # ifndef CPPAD_DET_BY_MINOR_HPP $pre $$ # define CPPAD_DET_BY_MINOR_HPP $verbatim%cppad/speed/det_by_minor.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/introduction.omh0000644000175200017650000001007512656321764016447 0ustar coincoin-web$Id: introduction.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin Introduction$$ $spell exp_eps Griewank Andreas CppAD $$ $section An Introduction by Example to Algorithmic Differentiation$$ $mindex AD Automatic$$ $head Purpose$$ This is an introduction by example to Algorithmic Differentiation. Its purpose is to aid in understand what AD calculates, how the calculations are preformed, and the amount of computation and memory required for a forward or reverse sweep. $head Preface$$ $subhead 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). $subhead 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). $subhead 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. $subhead 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. $subhead 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). $head Outline$$ $list Alpha$$ Demonstrate the use of CppAD to calculate derivatives of a polynomial: $cref get_started.cpp$$. $lnext Present two algorithms that approximate the exponential function. The first algorithm $cref exp_2.hpp$$ is simpler and does not include any logical variables or loops. The second algorithm $cref exp_eps.hpp$$ includes logical operations and a $code while$$ loop. For each of these algorithms, do the following: $list number$$ Define the mathematical function corresponding to the algorithm ($cref exp_2$$ and $cref exp_eps$$). $lnext Write out the floating point operation sequence, and corresponding values, that correspond to executing the algorithm for a specific input ($cref exp_2_for0$$ and $cref exp_eps_for0$$). $lnext Compute a forward sweep derivative of the operation sequence ($cref exp_2_for1$$ and $cref exp_eps_for1$$). $lnext Compute a reverse sweep derivative of the operation sequence ($cref exp_2_rev1$$ and $cref exp_eps_rev1$$). $lnext Use CppAD to compute both a forward and reverse sweep of the operation sequence ($cref exp_2_cppad$$ and $cref exp_eps_cppad$$). $lend $lnext The program $cref exp_apx_main.cpp$$ runs all of the test routines that validate the calculations in the $cref exp_2$$ and $cref exp_eps$$ presentation. $lend $head Reference$$ An in-depth review of AD theory and methods can be found in the book $icode Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation $$, Andreas Griewank, SIAM Frontiers in Applied Mathematics, 2000. $childtable% introduction/get_started/get_started.cpp% introduction/exp_apx/exp_2.hpp% introduction/exp_apx/exp_eps.hpp% introduction/exp_apx/main.cpp %$$ $end cppad-20160000.1/omh/multi_thread.omh0000644000175200017650000000605312656321764016410 0ustar coincoin-web// $Id: multi_thread.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin multi_thread$$ $spell 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 in $cref/parallel/ta_in_parallel/$$ execution mode. This section collects this information in one place. $head CPPAD_MAX_NUM_THREADS$$ The value $code CPPAD_MAX_NUM_THREADS$$ is an absolute maximum for the number of threads that CppAD should support. If this preprocessor symbol is defined before including any CppAD header files, it must be an integer greater than or equal to one. Otherwise, $cref/cppad_max_num_threads/cmake/cppad_max_num_threads/$$ is used to define this preprocessor symbol. Note that the minimum allowable value for $icode cppad_max_num_threads$$ is 4; i.e., you can only get smaller values for $code CPPAD_MAX_NUM_THREADS$$ by defining it before including the CppAD header files. $head parallel_setup$$ Using any of the following routines in a multi-threading environment requires that $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ has been completed: $cref/CppAD::vector/CppAD_vector/Memory and Parallel Mode/$$, $cref/CheckSimpleVector/CheckSimpleVector/Parallel Mode/$$, $cref/CheckNumericType/CheckNumericType/Parallel Mode/$$, $cref parallel_ad$$. $head hold_memory$$ Memory allocation should be much faster after calling $code hold_memory$$ with $cref/value/ta_hold_memory/value/$$ equal to true. This may even be true if there is only one thread. $head Parallel AD$$ One must first call $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ and then call $cref parallel_ad$$ before using $code AD$$ types in $cref/parallel/ta_in_parallel/$$ execution mode. $head Initialization$$ The following routines must be called at least once before being used in parallel mode: $cref/CheckSimpleVector/CheckSimpleVector/Parallel Mode/$$, $cref/CheckNumericType/CheckNumericType/Parallel Mode/$$, $cref/discrete functions/Discrete/Parallel Mode/$$, $cref/Rosen34/Rosen34/Parallel Mode/$$, $cref/Runge45/Runge45/Parallel Mode/$$. $head Same Thread$$ Some operations must be preformed by the same thread: $cref/ADFun/FunConstruct/Parallel Mode/$$, $cref Independent$$, $cref Dependent$$. $head Parallel Prohibited$$ The following routine cannot be called in parallel mode: $cref/ErrorHandler constructor/ErrorHandler/Constructor/Parallel Mode/$$. $childtable% cppad/local/parallel_ad.hpp% multi_thread/thread_test.cpp %$$ $end cppad-20160000.1/omh/sparse_jac_fun.omh0000644000175200017650000000156412656321764016713 0ustar coincoin-web$Id: sparse_jac_fun.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin sparse_jac_fun.hpp$$ $spell jac ifndef endif $$ $section Source: sparse_jac_fun$$ $mindex source$$ $code # ifndef CPPAD_SPARSE_JAC_FUN_HPP $pre $$ # define CPPAD_SPARSE_JAC_FUN_HPP $verbatim%cppad/speed/sparse_jac_fun.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/forward/0002755000175200017650000000000012656321765014665 5ustar coincoin-webcppad-20160000.1/omh/forward/forward.omh0000644000175200017650000000165012656321764017035 0ustar coincoin-web// $Id: forward.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 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/local/capacity_order.hpp% cppad/local/num_skip.hpp %$$ $end cppad-20160000.1/omh/forward/forward_one.omh0000644000175200017650000000640512656321764017701 0ustar coincoin-web// $Id: forward_one.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin forward_one$$ $spell 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 $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The result of the syntax above is $latex \[ y1 = F^{(1)} (x0) * x1 \] $$ where $latex F^{(1)} (x0)$$ is the Jacobian of $latex F$$ evaluated at $icode x0$$. $head f$$ The object $icode f$$ has prototype $codei% 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() %$$ must be greater than or equal one. After this call it will be will be two (see $cref size_order$$). $head x0$$ The vector $icode x0$$ in the formula $latex \[ 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%) %$$ If there is no previous call with the first argument zero, the value of the $cref/independent/Independent/$$ variables during the recording of the AD sequence of operations is used for $icode x0$$. $head x1$$ The argument $icode x1$$ has prototype $codei% const %Vector%& %x1% %$$ (see $cref/Vector/forward_one/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 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 Example$$ 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 $latex \[ \begin{array}{rcl} Y(t) & = & F[ X(t) ] \\ X(t) & = & x^{(0)} t^0 + x^{(1)} * t^1 + \cdots, + x^{(q)} * t^q + o( t^q ) \\ Y(t) & = & y^{(0)} t^0 + y^{(1)} * t^1 + \cdots, + y^{(q)} * t^q + o( t^q ) \end{array} \] $$ and $latex o( t^q ) * t^{-q} \rightarrow 0$$ as $latex t \rightarrow 0$$. For this special case, $latex q = 1$$, $latex x^{(0)}$$ $codei%= %x0%$$, $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) \] $$ Taking the derivative with respect to $latex t$$, at $latex t = 0$$, we obtain $latex \[ y^{(1)} = F^{(1)} [ x^{(0)} ] x^{(1)} \] $$ which agrees with the specifications for $icode y1$$ in the $cref/purpose/forward_one/Purpose/$$ above. $end cppad-20160000.1/omh/forward/size_order.omh0000644000175200017650000000575512656321765017551 0ustar coincoin-web// $Id: size_order.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 size_order$$ $spell var Taylor const $$ $section Number Taylor Coefficient Orders Currently Stored$$ $head Syntax$$ $icode%s% = %f%.size_order()%$$ $subhead See Also$$ $cref seq_property$$ $head Purpose$$ Determine the number of Taylor coefficient orders, per variable,direction, currently calculated and stored in the ADFun object $icode f$$. See the discussion under $cref/Constructor/size_order/Constructor/$$, $cref/Forward/size_order/Forward/$$, and $cref/capacity_order/size_order/capacity_order/$$ for a description of when this value can change. $head f$$ The object $icode f$$ has prototype $codei% const ADFun<%Base%> %f% %$$ $head s$$ The result $icode s$$ has prototype $codei% 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 $icode f$$. $head Constructor$$ Directly after the $cref FunConstruct$$ syntax $codei% ADFun<%Base%> %f%(%x%, %y%) %$$ the value of $icode s$$ returned by $code size_order$$ is one. This is because there is an implicit call to $code Forward$$ that computes the zero order Taylor coefficients during this constructor. $head Forward$$ After a call to $cref/Forward/forward_order/$$ with the syntax $codei% %f%.Forward(%q%, %x_q%) %$$ the value of $icode s$$ returned by $code size_order$$ would be $latex q + 1$$. The call to $code Forward$$ above uses the lower order Taylor coefficients to compute and store the $th q$$ order Taylor coefficients for all the variables in the operation sequence corresponding to $icode f$$. Thus there are $latex q + 1$$ (order zero through $icode q$$) Taylor coefficients per variable,direction. (You can determine the number of variables in the operation sequence using the $cref/size_var/seq_property/size_var/$$ function.) $head capacity_order$$ If the number of Taylor coefficient orders 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%) %$$ does not affect the value $icode s$$ returned by $code size_order$$. Otherwise, the value $icode s$$ returned by $code size_order$$ is equal to $icode c$$ (only Taylor coefficients of order zero through $latex c-1$$ have been retained). $head Example$$ The file $cref forward.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. $end cppad-20160000.1/omh/forward/compare_change.omh0000644000175200017650000001135212656321765020325 0ustar coincoin-web// $Id: compare_change.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin compare_change$$ $spell op const $$ $section Comparison Changes Between Taping and Zero Order Forward$$ $mindex ADFun compare_change$$ $head Syntax$$ $icode%f%.compare_change_count(%count%) %$$ $icode%number% = %f%.compare_change_number() %$$ $icode%op_index% = %f%.compare_change_op_index() %$$ $bold See Also$$ $cref FunCheck$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$; i.e, given $latex x \in B^n$$, $latex F(x)$$ is defined by $codei% %F%(%x%) = %f%.Forward(0, %x%) %$$ see $cref forward_zero$$. If $latex x$$ is such that all the algorithm $cref/comparison/Compare/$$ operations have the same result as when the algorithm was taped, The function $latex F(x)$$ and the algorithm will have the same values. (This is a sufficient, but not necessary condition). $head f$$ In the $code compare_change_number$$ and $code compare_change_op_index$$ syntax, the object $icode f$$ has prototype $codei% const ADFun<%Base%> %f% %$$ In the $code compare_change_count$$ syntax, the object $icode f$$ has prototype $codei% ADFun<%Base%> %f% %$$ $head count$$ The argument $icode count$$ has prototype $icode% size_t %count% %$$ It specifies which comparison change should correspond to the information stored in $icode f$$ during subsequent calls to $cref forward_zero$$; i.e., $codei% %f%.Forward(0, %x%) %$$ For example, if $icode%count% == 1%$$, the operator index corresponding to the first comparison change will be stored. This is the default value used if $icode count$$ is not specified. $subhead Speed$$ The special case where $icode count == 0$$, should be faster because the comparisons are not checked during $codei% %f%.Forward(0, %x%) %$$ $head number$$ The return value $icode number$$ has prototype $codei% size_t %number% %$$ If $icode count$$ is non-zero, $icode number$$ is the number of $codei%AD<%Base%>%$$ $cref/comparison/Compare/$$ operations, corresponding to the previous call to $codei% %f%.Forward(0, %x%) %$$ that have a different result for this value of $icode x$$ than the value used when $icode f$$ was created by taping an algorithm. If $icode count$$ is zero, or if no calls to $icode%f%.Forward(0, %x%)%$$ follow the previous setting of $icode count$$, $icode number$$ is zero. $subhead Discussion$$ If $icode count$$ and $icode number$$ are non-zero, you may want to re-tape the algorithm with the $cref/independent variables/glossary/Tape/Independent Variable/$$ equal to the values in $icode x$$, so the AD operation sequence properly represents the algorithm for this value of independent variables. On the other hand, re-taping the AD operation sequence usually takes significantly more time than evaluation using $cref forward_zero$$. If the functions values have not changed (see $cref FunCheck$$) it may not be worth re-taping a new AD operation sequence. $head op_index$$ The return value $icode op_index$$ has prototype $codei% size_t %op_index% %$$ If $icode count$$ is non-zero, $icode op_index$$ is the operator index corresponding the $icode count$$-th comparison change during the previous call to $codei% %f%.Forward(0, %x%) %$$ If $icode count$$ is greater than the corresponding $icode number$$, there is no such comparison change and $icode op_index$$ will also be zero. If $icode count$$ is zero, if the function $icode f$$ has been $cref/optimized/optimize/$$, or if no calls to $icode%f%.Forward(0, %x%)%$$ follow the previous setting of $icode count$$, $icode op_index$$ is zero. $subhead Purpose$$ The operator index can be used to generate an error during the taping process so that the corresponding algorithm can be inspected. In some cases, it is possible to re-design this part of the algorithm to avoid the particular comparison operation. For example, using an $cref/conditional expression/CondExp/$$ may be appropriate in some cases. See $cref/abort_op_index/Independent/abort_op_index/$$ in the syntax $codei% Independent(%x%, %abort_op_index%) %$$ $children% example/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 cppad-20160000.1/omh/forward/forward_two.omh0000644000175200017650000001050412656321765017725 0ustar coincoin-web// $Id: forward_two.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin forward_two$$ $spell Jacobian Taylor const $$ $section Second Order Forward Mode: Derivative Values$$ $mindex two$$ $head Syntax$$ $icode%y2% = %f%.Forward(1, %x2%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The 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$$ $pre $$ where $latex F^{(1)} (x0)$$ is the Jacobian of $latex F$$, and $latex F_i^{(2)} (x0)$$ is the Hessian of th $th i$$ component of $latex F$$, evaluated at $icode x0$$. $head f$$ The object $icode f$$ has prototype $codei% 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() %$$ must be greater than or equal two. After this call it will be will be three (see $cref size_order$$). $head x0$$ The vector $icode x0$$ in the formula for $icode%y2%[%i%]%$$ corresponds to the previous call to $cref forward_zero$$ using this ADFun object $icode f$$; i.e., $codei% %f%.Forward(0, %x0%) %$$ If there is no previous call with the first argument zero, the value of the $cref/independent/Independent/$$ variables during the recording of the AD sequence of operations is used for $icode x0$$. $head x1$$ The vector $icode x1$$ in the formula for $icode%y2%[%i%]%$$ corresponds to the previous call to $cref forward_one$$ using this ADFun object $icode f$$; i.e., $codei% %f%.Forward(1, %x1%) %$$ $head x2$$ The argument $icode x2$$ has prototype $codei% const %Vector%& %x2% %$$ (see $cref/Vector/forward_two/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 y2$$ The result $icode y2$$ has prototype $codei% %Vector% %y2% %$$ (see $cref/Vector/forward_two/Vector/$$ below) The size of $icode y1$$ is equal to $icode m$$, the dimension of the $cref/range/seq_property/Range/$$ space for $icode f$$. Its value is given element-wise by the formula in the $cref/purpose/forward_two/Purpose/$$ above. $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 Example$$ 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 $latex \[ \begin{array}{rcl} Y(t) & = F[ X(t) ] \\ X(t) & = & x^{(0)} t^0 + x^{(1)} * t^1 + \cdots, + x^{(q)} * t^q + o( t^q ) \\ Y(t) & = & y^{(0)} t^0 + y^{(1)} * t^1 + \cdots, + y^{(q)} * t^q + o( t^q ) \end{array} \] $$ and $latex o( t^q ) * t^{-q} \rightarrow 0$$ as $latex t \rightarrow 0$$. For this special case, $latex q = 2$$, $latex x^{(0)}$$ $codei%= %x0%$$, $latex x^{(1)}$$ $codei%= %x1%$$, $latex X(t) = x^{(0)} + x^{(1)} t + x^{(2)} t^2$$, and $latex \[ y^{(0)} + y^{(1)} t + y^{(2)} t^2 = F [ x^{(0)} + x^{(1)} t + x^{(2)} t^2 ] + o(t^2) \] $$ Restricting our attention to the $th i$$ component, and taking the derivative with respect to $latex t$$, we obtain $latex \[ y_i^{(1)} + 2 y_i^{(2)} t = F_i^{(1)} [ x^{(0)} + x^{(1)} t + x^{(2)} t^2 ] [ x^{(1)} + 2 x^{(2)} t ] + o(t) \] $$ Taking a second derivative with respect to $latex t$$, and evaluating at $latex t = 0$$, we obtain $latex \[ 2 y_i^{(2)} = [ x^{(1)} ]^T F_i^{(2)} [ x^{(0)} ] x^{(1)} + F_i^{(1)} [ x^{(0)} ] 2 x^{(2)} \] $$ which agrees with the specification for $icode%y2%[%i%]%$$ in the $cref/purpose/forward_two/Purpose/$$ above. $end cppad-20160000.1/omh/forward/forward_order.omh0000644000175200017650000001465412656321765020241 0ustar coincoin-web// $Id: forward_order.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin forward_order$$ $spell std::cout ostream xk xp yp Ind vp uj Taylor const xq yq $$ $section Multiple Order Forward Mode$$ $mindex any$$ $head Syntax$$ $icode%yq% = %f%.Forward(%q%, %xq% ) %$$ $icode%yq% = %f%.Forward(%q%, %xq%, %s%) %$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. Given a function $latex X : B \rightarrow B^n$$, defined by its $cref/Taylor coefficients/glossary/Taylor Coefficient/$$, forward mode computes the Taylor coefficients for the function $latex \[ Y (t) = F [ X(t) ] \]$$ $subhead Function Values$$ If you are using forward mode to compute values for $latex F(x)$$, $cref forward_zero$$ is simpler to understand than this explanation of the general case. $subhead Derivative Values$$ If you are using forward mode to compute values for $latex F^{(1)} (x) * dx$$, $cref forward_one$$ is simpler to understand than this explanation of the general case. $head Notation$$ $subhead n$$ We use $icode n$$ to denote the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. $subhead m$$ We use $icode m$$ to denote the dimension of the $cref/range/seq_property/Range/$$ space for $icode f$$. $head f$$ The $cref ADFun$$ object $icode f$$ has prototype $codei% 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 %$$ $head One Order$$ If $icode%xq%.size() == %n%$$, 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 %$$ $head q$$ The argument $icode q$$ has prototype $codei% 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% %$$ (see $cref/Vector/forward_order/Vector/$$ below). As above, we use $icode n$$ to denote the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. The size of $icode xq$$ must be either $icode n$$ or $icode%n%*(%q%+1)%$$. After this call we will have $codei% %f%.size_order() == %q% + 1 %$$ $subhead One Order$$ If $icode%xq%.size() == %n%$$, the $th q$$ order Taylor coefficient for $latex X(t)$$ is defined by $pre $$ $latex x^{(q)} = $$ $icode xq$$. For $latex k = 0 , \ldots , q-1$$, the Taylor coefficient $latex x^{(k)}$$ is defined by $icode xk$$ in the previous call to $codei% %f%.Forward(%k%, %xk%) %$$ $subhead Multiple Orders$$ If $icode%xq%.size() == %n%*(%q%+1)%$$, For $latex k = 0 , \ldots , q$$, $latex j = 0 , \ldots , n-1$$, the $th j$$ component of the $th k$$ order Taylor coefficient for $latex X(t)$$ is defined by $pre $$ $latex x_j^{(k)} = $$ $icode%%xq%[ (%q%+1) * %j% + %k% ]%$$ $subhead Restrictions$$ Note if $icode f$$ uses $cref old_atomic$$ functions, the size of $icode xq$$ must be $icode n$$. $head s$$ If the argument $icode s$$ is not present, $code std::cout$$ is used in its place. Otherwise, this argument has prototype $codei% std::ostream& %s% %$$ If order zero is begin calculated, $icode s$$ specifies where the output corresponding to $cref PrintFor$$ will be written. If order zero is not being calculated, $icode s$$ is not used $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(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) \] $$ $head Y(t)$$ The function $latex Y : B \rightarrow B^m$$ is defined by $latex Y(t) = F[ X(t) ] $$. We use $latex y^{(k)} \in B^m$$ 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 ) \] $$ 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) \] $$ $head yq$$ The return value $icode yq$$ has prototype $codei% %Vector% %yq% %$$ (see $cref/Vector/forward_order/Vector/$$ below). $subhead One Order$$ If $icode%xq%.size() == %n%$$, the vector $icode yq$$ has size $icode m$$. The $th q$$ order Taylor coefficient for $latex Y(t)$$ is returned as $codei% %yq%$$ $latex = y^{(q)}$$. $subhead Multiple Orders$$ If $icode%xq%.size() == %n%*(%q%+1)%$$, the vector $icode yq$$ has size $icode%m%*(%q%+1)%$$. For $latex k = 0 , \ldots , q$$, for $latex i = 0 , \ldots , m-1$$, the $th i$$ component of the $th k$$ order Taylor coefficient for $latex Y(t)$$ is returned as $codei% %yq%[ (%q%+1) * %i% + %k% ]%$$ $latex = y_i^{(k)}$$ $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 Zero Order$$ The case where $latex q = 0$$ and $icode%xq%.size() == %n%$$, corresponds to the zero order $cref/special case/forward_zero/Special Case/$$. $head First Order$$ The case where $latex q = 1$$ and $icode%xq%.size() == %n%$$, corresponds to the first order $cref/special case/forward_one/Special Case/$$. $head Second Order$$ The case where $latex q = 2$$ and $icode%xq%.size() == %n%$$, corresponds to the second order $cref/special case/forward_two/Special Case/$$. $children% example/forward.cpp% example/forward_order.cpp %$$ $head Example$$ The file $cref forward.cpp$$ ( $cref forward_order.cpp$$ ) contains an example and test using one order (multiple orders). They return true if they succeed and false otherwise. $end cppad-20160000.1/omh/forward/forward_dir.omh0000644000175200017650000001272212656321765017676 0ustar coincoin-web// $Id: forward_dir.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin forward_dir$$ $spell Taylor const dir cpp yq xq xk std::cout ostream $$ $section Multiple Directions Forward Mode$$ $head Syntax$$ $icode%yq% = %f%.Forward(%q%, %r%, %xq%) %$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. Given a function $latex X : B \rightarrow B^n$$, defined by its $cref/Taylor coefficients/glossary/Taylor Coefficient/$$, forward mode computes the Taylor coefficients for the function $latex \[ Y (t) = F [ X(t) ] \]$$ $head Notation$$ $subhead n$$ We use $icode n$$ to denote the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. $subhead m$$ We use $icode m$$ to denote the dimension of the $cref/range/seq_property/Range/$$ space for $icode f$$. $head f$$ The $cref ADFun$$ object $icode f$$ has prototype $codei% 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% %$$ $head q$$ This argument has prototype $codei% 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 $icode f$$ so use $cref forward_zero$$ to compute the zero order coefficients. $head r$$ This argument has prototype $codei% size_t %r% %$$ It specifies the number of directions that are computed together. If ($icode%r% == 1%$$), you are only using one direction and $cref forward_order$$ is simpler, and should be faster, than this more general case. $head xq$$ The argument $icode xq$$ has prototype $codei% const %Vector%& %xq% %$$ and its size must be $icode%n%*%r%$$ (see $cref/Vector/forward_dir/Vector/$$ below). For $latex \ell = 0 , \ldots , r-1$$, $latex j = 0 , \ldots , n-1$$, the $th j$$ component of the $th q$$ order Taylor coefficient for $latex X_\ell (t)$$ is defined by $pre $$ $latex x_j^{(q),\ell} = $$ $icode%xq%[ %r% * %j% + %ell% ]%$$ $head Zero Order$$ For $latex j = 0 , \ldots , n-1$$, the $th j$$ component of the zero order Taylor coefficient for $latex X_\ell (t)$$ is defined by $pre $$ $latex x_j^{(0)} = $$ $icode%xk%[ %j% ]%$$ where $icode xk$$ corresponds to the previous call $codei% %f%.Forward(%k%, %xk%) %$$ with $icode%k% = 0%$$. $head Non-Zero Lower Orders$$ For $latex \ell = 0 , \ldots , r-1$$, $latex j = 0 , \ldots , n-1$$, $latex k = 1, \ldots , q-1$$, the $th j$$ component of the $th k$$ order Taylor coefficient for $latex X_\ell (t)$$ is defined by $pre $$ $latex x_j^{(k),\ell} = $$ $icode%xk%[ %r% * %j% + %ell% ]%$$ where $icode xk$$ corresponds to the previous call $codei% %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 (t) = x^{(0)} + x^{(1),\ell} * t^1 + \cdots + x^{(q),\ell} t^q \] $$ Note that the $th k$$ derivative of $latex X_\ell (t)$$ is related to its Taylor coefficients by $latex \[ \begin{array}{rcl} 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 (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 hight order coefficients; i.e., $latex \[ Y_\ell (t) = y^{(0)} + y^{(1),\ell} * t^1 + \cdots + y^{(q),\ell} * t^q + o( t^q ) \] $$ where $latex o( t^q ) * t^{-q} \rightarrow 0$$ as $latex t \rightarrow 0$$. Note that the $th k$$ derivative of $latex Y_\ell (t)$$ is related to its Taylor coefficients by $latex \[ \begin{array}{rcl} y^{(0)} & = & Y_\ell (0) \\ y^{(k), \ell} & = & \frac{1}{k !} Y_\ell^{(k)} (0) \end{array} \] $$ for $latex k = 1 , \ldots , q$$. $head yq$$ The argument $icode yq$$ has prototype $codei% %Vector% %yq% %$$ and its size is $icode%m%*%r%$$ (see $cref/Vector/forward_dir/Vector/$$ below). For $latex \ell = 0 , \ldots , r-1$$, $latex i = 0 , \ldots , m-1$$, the $th i$$ component of the $th q$$ order Taylor coefficient for $latex Y_\ell (t)$$ is given by $pre $$ $latex y_i^{(q),\ell} = $$ $icode%yq%[ %r% * %i% + %ell% ]%$$ $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. $children% example/forward_dir.cpp %$$ $head Example$$ The file $cref forward_dir.cpp$$ contains an example and test using one order (multiple orders). They return true if they succeed and false otherwise. $end cppad-20160000.1/omh/forward/forward_zero.omh0000644000175200017650000000645112656321765020101 0ustar coincoin-web// $Id: forward_zero.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin forward_zero$$ $spell std::cout ostream const Taylor dy Jacobian $$ $section Zero Order Forward Mode: Function Values$$ $head Syntax$$ $icode%y0% = %f%.Forward(0, %x0%) %$$ $icode%y0% = %f%.Forward(0, %x0%, %s%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The result of the syntax above is $latex \[ y0 = F(x0) \] $$ See the $cref/FunCheck discussion/FunCheck/Discussion/$$ for possible differences between $latex F(x)$$ and the algorithm that defined the operation sequence. $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 this call to $code Forward$$, the value returned by $codei% %f%.size_order() %$$ will be equal to one (see $cref size_order$$). $head x0$$ The argument $icode x0$$ has prototype $codei% const %Vector%& %x0% %$$ (see $cref/Vector/forward_zero/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 s$$ If the argument $icode s$$ is not present, $code std::cout$$ is used in its place. Otherwise, this argument has prototype $codei% std::ostream& %s% %$$ It specifies where the output corresponding to $cref PrintFor$$, and this zero order forward mode call, will be written. $head y0$$ The result $icode y0$$ has prototype $codei% %Vector% %y0% %$$ (see $cref/Vector/forward_zero/Vector/$$ below) and its value is $latex F(x)$$ at $icode%x% = %x0%$$. The size of $icode y0$$ is equal to $icode m$$, the dimension of the $cref/range/seq_property/Range/$$ space for $icode f$$. $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 Example$$ 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 $latex \[ \begin{array}{rcl} Y(t) & = & F[ X(t) ] \\ X(t) & = & x^{(0)} t^0 + x^{(1)} * t^1 + \cdots, + x^{(q)} * t^q + o( t^q ) \\ Y(t) & = & y^{(0)} t^0 + y^{(1)} * t^1 + \cdots, + y^{(q)} * t^q + o( t^q ) \end{array} \] $$ and $latex o( t^q ) * t^{-q} \rightarrow 0$$ as $latex t \rightarrow 0$$. For this special case, $latex q = 0$$, $latex x^{(0)}$$ $codei%= %x0%$$, $latex X(t) = x^{(0)}$$, and $latex \[ 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. $end cppad-20160000.1/omh/base_require/0002755000175200017650000000000012656321765015667 5ustar coincoin-webcppad-20160000.1/omh/base_require/base_ordered.omh0000644000175200017650000000434712656321765021020 0ustar coincoin-web// $Id: base_ordered.omh 3665 2015-02-26 04:59:01Z bradbell $$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin base_ordered$$ $spell alloc abs_geq const bool namespace CppAD inline $$ $section Base Type Requirements for Ordered Comparisons$$ $head Purpose$$ The following operations (in the CppAD namespace) are required to use the type $codei%AD<%Base%>%$$: $table $bold Syntax$$ $cnext $bold Result$$ $rnext $icode%b% = GreaterThanZero(%x%)%$$ $pre $$ $cnext $latex x > 0$$ $rnext $icode%b% = GreaterThanOrZero(%x%)%$$ $pre $$ $cnext $latex x \geq 0$$ $rnext $icode%b% = LessThanZero(%x%)%$$ $pre $$ $cnext $latex x < 0$$ $rnext $icode%b% = LessThanOrZero(%x%)%$$ $pre $$ $cnext $latex x \leq 0$$ $rnext $icode%b% = abs_geq(%x%, %y%)%$$ $pre $$ $cnext $latex |x| \geq |y|$$. $tend where the arguments and return value have the prototypes $codei% const %Base%& %x% const %Base%& %y% bool %% %b% %$$ $head Ordered Type$$ If the type $icode Base$$ supports ordered operations, these functions should have their corresponding definitions. For example, $codei% namespace CppAD { inline bool GreaterThanZero(const %Base% &x) { return (x > 0); } } %$$ The other functions would replace $code >$$ by the corresponding operator. For example, see $cref/base_alloc/base_alloc.hpp/Ordered/$$. $head Not Ordered$$ If the type $icode Base$$ does not support ordering, one might (but need not) define $code GreaterThanZero$$ as follows: $codei% namespace CppAD { inline bool GreaterThanZero(const %Base% &x) { // attempt to use GreaterThanZero with a %Base% argument assert(0); return x; } } %$$ The other functions would have the corresponding definition. For example, see $cref/complex Ordered/base_complex.hpp/Ordered/$$. $end */ cppad-20160000.1/omh/base_require/base_member.omh0000644000175200017650000000411412656321765020633 0ustar coincoin-web/* $Id: base_member.omh 3665 2015-02-26 04:59:01Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin base_member$$ $spell bool const op Bool definition alloc $$ $section Required Base Class Member Functions$$ $head Notation$$ $table $bold Symbol$$ $cnext $bold Meaning$$ $rnext $icode Base$$ $cnext The base type corresponding to $codei%AD<%Base%>%$$ $rnext $icode b$$ $cnext An object of type $code bool$$ $rnext $icode d$$ $cnext An object of type $code double$$ $rnext $icode x$$ $cnext An object of type $codei%const %Base%&%$$ $rnext $icode y$$ $cnext An object of type $codei%const %Base%&%$$ $rnext $icode z$$ $cnext An object of type $icode Base$$ $rnext $tend $head Default Constructor$$ $icode%Base z%$$ $head Double Constructor$$ $icode%Base z%(%d%)%$$ $head Copy Constructor$$ $icode%Base z%(%x%)%$$ $head Unary Operators$$ For $code op$$ equal to $code +$$, $code -$$ the following operation must be supported: $codei% %z% = %op% %x%$$ $head Assignment Operators$$ For $icode op$$ equal to $icode =$$, $code +=$$, $code -=$$, $code *=$$, and $code /=$$ the following operation must be supported: $codei% %z% %op% %x%$$ $head Binary Operators$$ For $icode op$$ equal to $code +$$, $code -$$, $code *$$, and $code /$$ the following operation must be supported: $codei% %z% = %x% %op% %y%$$ $head Bool Operators$$ For $icode op$$ equal to $code ==$$, $code !=$$, $code <=$$, the following operation must be supported: $codei% %b% = %x% %op% %y%$$ $head Example$$ See the heading Class Definition in $cref/base_alloc/base_alloc.hpp/Class Definition/$$. $end cppad-20160000.1/omh/base_require/base_example.omh0000644000175200017650000000156112656321765021022 0ustar coincoin-web/* $Id: base_example.omh 3665 2015-02-26 04:59:01Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin base_example$$ $section Example AD Base Types That are not AD$$ $contents% example/base_alloc.hpp% example/base_require.cpp% cppad/example/base_adolc.hpp% cppad/local/base_float.hpp% cppad/local/base_double.hpp% cppad/local/base_complex.hpp %$$ $end cppad-20160000.1/omh/base_require/base_identical.omh0000644000175200017650000000735312656321765021330 0ustar coincoin-web// $Id: base_identical.omh 3757 2015-11-30 12:03:07Z bradbell $$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin base_identical$$ $spell alloc adolc Op const CppAD adolc namespace bool inline $$ $section Base Type Requirements for Identically Equal Comparisons$$ $mindex require$$ $head EqualOpSeq$$ If function $cref EqualOpSeq$$ is used with arguments of type $codei%AD<%Base%>%$$, the type $icode Base$$ must support the syntax $codei% %b% = CppAD::EqualOpSeq(%u%, %v%) %$$ This should return true if and only if $icode u$$ is identically equal to $icode v$$ and it makes no different which one is used. The arguments $icode u$$ and $icode v$$ have prototype $codei% const %Base%& %u% const %Base%& %v% %$$ The return value $icode b$$ has prototype $codei% bool %b% %$$ $subhead The Simple Case$$ If $icode Base$$ is a relatively simple type, the $code EqualOpSeq$$ function can be defined by $codei% namespace CppAD { inline %Base% EqualOpSeq(const %Base%& u, const %Base%& v) { return u == v; } } %$$ For example, see $cref/base_alloc/base_alloc.hpp/EqualOpSeq/$$. $subhead More Complicated Cases$$ The variables $icode u$$ and $icode v$$ are not identically equal in the following case (which CppAD automatically defines $code EqualOpSeq$$ for): The type $icode Base$$ is $codei%AD%$$, $icode x[0] = x[1] = 1.$$, then $cref independent$$ is used to make $icode x$$ the independent variable vector, and then $icode u = x[0]$$, $icode v = x[1]$$, Note that during a future $cref Forward$$ calculation, $icode u$$ and $icode v$$ could correspond to different values. For example, see $cref/adolc EqualOpSeq/base_adolc.hpp/EqualOpSeq/$$. $head Identical$$ $subhead IdenticalPar$$ A $icode Base$$ is a $cref/parameter/glossary/Parameter/$$ when used in an $codei%AD<%Base%>%$$ operation sequence. It is however still possible for a parameter to change its value. For example, the $icode Base$$ value $icode u$$ is not identically a parameter equal in the following case (which CppAD automatically defines $code IdenticalPar$$ for): The type $icode Base$$ is $codei%AD%$$, $icode x[0] = 1.$$, then $cref independent$$ is used to make $icode x$$ the independent variable vector, and then $icode u = x[0]$$, Note that during a future $cref Forward$$ calculation, $icode u$$ could correspond to different values. $subhead Prototypes$$ The argument $icode u$$ has prototype $codei% const %Base% %u% %$$ If it is present, the argument $icode v$$ has prototype $codei% const %Base% %v% %$$ The result $icode b$$ has prototype $codei% bool %b% %$$ $subhead Identical Functions$$ The type $icode Base$$ must support the following functions (in the CppAD namespace): $table $bold Syntax$$ $cnext $bold Result$$ $rnext $icode%b% = IdenticalPar(%u%)%$$ $pre $$ $cnext the $icode Base$$ value will always be the same $rnext $icode%b% = IdenticalZero(%u%)%$$ $pre $$ $cnext $icode u$$ equals zero and $codei%IdenticalPar(%u%)%$$ $rnext $icode%b% = IdenticalOne(%u%)%$$ $pre $$ $cnext $icode u$$ equals one and $codei%IdenticalPar(%u%)%$$ $rnext $icode%b% = IdenticalEqualPar(%u%, %v%)%$$ $pre $$ $cnext $icode u$$ equals $icode v$$, $codei%IdenticalPar(%u%)%$$ and $codei%IdenticalPar(%v%)%$$ $tend $subhead Examples$$ See $cref/base_alloc/base_alloc.hpp/Identical/$$. $end */ cppad-20160000.1/omh/install/0002755000175200017650000000000012656321765014667 5ustar coincoin-webcppad-20160000.1/omh/install/cmake_check.omh0000644000175200017650000000443312656321765017613 0ustar coincoin-web/* $Id: cmake_check.omh 3726 2015-09-21 13:25:17Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin cmake_check$$ $spell nlp cppad makefiles ipopt CppAD cmake nmake $$ $section Checking the CppAD Examples and Tests$$ $head Purpose$$ After you configure your system with the $cref/cmake command/cmake/CMake Command/$$ you can run the CppAD example and tests to make sure that CppAD functions properly on your system. $head Check All$$ In the $code build$$ subdirectory of the $cref/distribution directory/download/Distribution Directory/$$ execute the command $codep 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 /Compressed Archives /Windows File Extraction and Testing /$$. $head Subsets$$ It is possible to build and run the following subsets of the examples and tests: $table Command $cnext Description $rnext $code make check_compare_c$$ $cnext $tref compare_c$$ $rnext $code make check_introduction$$ $cnext the programs in the $cref Introduction$$ $rnext $code make check_example$$ $cnext most of the $cref Example$$ programs $rnext $code make check_print_for$$ $cnext the $cref PrintFor$$ command $rnext $code make check_test_more$$ $cnext correctness tests that are not examples $rnext $code make check_multi_thread$$ $cnext $cref multi_thread$$ tests (run correctness only) $rnext $code make check_speed$$ $cnext single threading $cref speed$$ tests (run correctness only) $rnext $code make check_cppad_ipopt$$ $cnext the $cref cppad_ipopt_nlp$$ speed and correctness tests $rnext $tend $end cppad-20160000.1/omh/install/fadbad_prefix.omh0000644000175200017650000000410012656321765020143 0ustar coincoin-web// $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. A copy of 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 fadbad_prefix$$ $dollar @$$ $spell 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 $href%http://www.fadbad.com%FADBAD%$$; see $cref speed_fadbad$$. $head fadbad_prefix$$ If FADBAD is installed on your system, you can specify a value for its install $icode fadbad_prefix$$ on the $cref cmake$$ command line. The value of $icode fadbad_prefix$$ must be such that, for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% %fadbad_prefix%/%dir%/FADBAD++/badiff.h %$$ is a valid way to reference to the include file $code badiff.h$$; $head Speed Tests$$ If you include $icode fadbad_prefix$$ on the $cref cmake$$ command line, you will be able to run the FADBAD speed correctness tests by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% cd build/speed/fadbad make check_speed_fadbad %$$ After executing $code make check$$, you can run a specific FADBAD speed test by executing the command $code ./speed_fadbad$$; see $cref speed_main$$ for the meaning of the command line options to this program. $children% bin/get_fadbad.sh %$$ $head get_fadbad$$ If you are using Unix, you can download and install a copy of Fadbad using $cref get_fadbad.sh$$. The corresponding $icode fadbad_prefix$$ would be $code build/prefix$$. $end cppad-20160000.1/omh/install/adolc_prefix.omh0000644000175200017650000000751312656321765020037 0ustar coincoin-web// $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. A copy of 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 adolc_prefix$$ $dollar @$$ $spell 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 $href%https://projects.coin-or.org/ADOL-C%ADOL-C%$$. The includes speed comparison with other AD packages; see $cref speed_adolc$$. It also includes examples that combine ADOL-C with CppAD; see $table $rref base_adolc.hpp$$ $rref mul_level_adolc.cpp$$ $rref mul_level_adolc_ode.cpp$$ $tend $head adolc_prefix$$ If ADOL-C is installed on your system, you can specify a value for its install $icode adolc_prefix$$ on the $cref cmake$$ command line. The value of $icode adolc_prefix$$ must be such that, for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% %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% %$$ In other words ColPack is installed and with the same prefix as ACOL-C; see $cref get_colpack.sh$$. $head Examples$$ If you include $icode adolc_prefix$$ on the $cref cmake$$ command line, you will be able to run the ADOL-C examples listed above by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% cd build/example make check_example %$$ If you do this, you will see an indication that the examples $code mul_level_adolc$$ and $code mul_level_adolc_ode$$ have passed their correctness check. $head Speed Tests$$ If you include $icode adolc_prefix$$ on the $cref cmake$$ command line, you will be able to run the ADOL-C speed correctness tests by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% cd build/speed/adolc make check_speed_adolc %$$ After executing $code make check_speed_adolc$$, you can run a specific ADOL-C speed tests by executing the command $code ./speed_adolc$$; see $cref speed_main$$ for the meaning of the command line options to this program. $head Unix$$ If you are using Unix, you may have to add $icode adolc_prefix$$ to $code LD_LIBRARY_PATH$$. For example, if you use the $code bash$$ shell to run your programs, you could include $codei% LD_LIBRARY_PATH=%adolc_prefix%/lib:@{LD_LIBRARY_PATH} export LD_LIBRARY_PATH %$$ in your $code @HOME/.bashrc$$ file. $head Cygwin$$ If you are using Cygwin, 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 %$$ in order for ADOL-C to run properly. If $icode adolc_prefix$$ begins with a disk specification, you must use the Cygwin format for the disk specification. For example, if $code d:/adolc_base$$ is the proper directory, $code /cygdrive/d/adolc_base$$ should be used for $icode adolc_prefix$$. $children% bin/get_adolc.sh %$$ $head get_adolc$$ If you are using Unix, you can download and install a copy of Adolc using $cref get_adolc.sh$$. The corresponding $icode adolc_prefix$$ would be $code build/prefix$$. $end cppad-20160000.1/omh/install/cmake.omh0000644000175200017650000003154712656321765016464 0ustar coincoin-web$Id: cmake.omh 3760 2015-12-01 04:12: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. A copy of 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 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 $$ $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$$ The $href%http://www.cmake.org/cmake/help/install.html%cmake%$$ program enables one to create a single set of scripts, called $code CMakeLists.txt$$, 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. $head CMake Command$$ The command below 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. $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: $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% \ \ -D adolc_prefix=%adolc_prefix% \ -D colpack_prefix=%colpack_prefix% \ -D eigen_prefix=%eigen_prefix% \ -D fadbad_prefix=%fadbad_prefix% \ -D ipopt_prefix=%ipopt_prefix% \ -D sacado_prefix=%sacado_prefix% \ \ -D cppad_cxx_flags=%cppad_cxx_flags% \ -D cppad_profile_flag=%cppad_profile_flag% \ \ -D cppad_testvector=%cppad_testvector% \ -D cppad_max_num_threads=%cppad_max_num_threads% \ -D cppad_sparse_list=%cppad_sparse_list% \ -D cppad_tape_id_type=%cppad_tape_id_type% \ -D cppad_tape_addr_type=%cppad_tape_addr_type% \ -D cppad_deprecated=%cppad_deprecated% \ \ .. %$$ $head cmake_verbose_makefile$$ This value should be either $code YES$$ or $code NO$$. The default value, when it is not present, is $code NO$$. If it is $code YES$$, then the output of the $code make$$ commands will include all of the files and flags used to run the compiler and linker. This can be useful for seeing how to compile and link your own applications. $head generator$$ The CMake program is capable of generating different kinds of files. Below is a table with a few of the possible files $table $icode generator$$ $cnext Description $rnext $code "Unix Makefiles"$$ $cnext make files for unix operating system $rnext $code "NMake Makefiles"$$ $cnext make files for Visual Studio $tend Other generator choices are available; see the cmake $href%http://www.cmake.org/cmake/help/cmake2.6docs.html#section_Generators% generators%$$ documentation. $head cppad_prefix$$ This is the top level absolute path below which all of the CppAD files are installed by the command $codei% make install %$$ For example, if $icode cppad_prefix$$ is $code /usr$$, $icode cmake_install_includedirs$$ is $code include$$, and $icode cppad_postfix$$ is not specified, the file $code cppad.hpp$$ is installed in the location $codei% /usr/include/cppad/cppad.hpp %$$ The default value for $icode cppad_prefix$$ is $code /usr$$. $head cppad_postfix$$ This is the bottom level relative path below which all of the CppAD files are installed. For example, if $icode cppad_prefix$$ is $code /usr$$, $icode cmake_install_includedirs$$ is $code include$$, and $icode cppad_postfix$$ is $code coin$$, the file $code cppad.hpp$$ is installed in the location $codei% /usr/include/coin/cppad/cppad.hpp %$$ The default value for $icode cppad_postfix$$ is empty; i.e, there is no bottom level relative directory for the installed files. $head cmake_install_includedirs$$ This is one directory, or a list of directories separated by spaces or by semi-colons. This first entry in the list is the middle level relative path below which the CppAD include files are installed. The entire list is used for searching for include files. For example, if $icode cppad_prefix$$ is $code /usr$$, $icode cmake_install_includedirs$$ is $code include$$, and $icode cppad_postfix$$ is not specified, the file $code cppad.hpp$$ is installed in the location $codei% /usr/include/cppad/cppad.hpp %$$ The default value for this directory list is $code include$$. $head 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 $icode cppad_prefix$$ is $code /usr$$, $icode cmake_install_libdirs$$ is $code lib$$, $icode cppad_postfix$$ is not specified, and $icode ipopt_prefix$$ is specified, the file $code libcppad_ipopt.a$$ is installed in the location $codei% /usr/lib/libcppad_ipopt.a %$$ The default value for this directory list is $code lib$$. $head cmake_install_datadir$$ This is the middle level relative path below which the CppAD data files are installed. For example, if $icode cppad_prefix$$ is $code /usr$$, $icode cmake_install_datadir$$ is $code share$$, and $icode cppad_postfix$$ is not specified, the $cref pkgconfig$$ file $code cppad.pc$$ is installed in the location $codei% /usr/share/pkgconfig/cppad.pc %$$ The default value for $icode cmake_install_datadir$$ is $code share$$. $head cmake_install_docdir$$ This is the middle level relative path below which the CppAD documentation files are installed. For example, if $icode cppad_prefix$$ is $code /usr$$, $icode cmake_install_docdir$$ is $code share/doc$$, and $icode cppad_postfix$$ is not specified, the file $code cppad.xml$$ is installed in the location $codei% /usr/share/doc/cppad/cppad.xml %$$ There is no default value for $icode cmake_install_docdir$$. If it is not specified, the documentation files are not installed. $head package_prefix$$ Each of these packages corresponds to optional CppAD examples, that can be compiled and tested if the corresponding prefix is provided: $table $rref adolc_prefix$$ $rref colpack_prefix$$ $rref eigen_prefix$$ $rref fadbad_prefix$$ $rref ipopt_prefix$$ $rref sacado_prefix$$ $tend $head cppad_cxx_flags$$ This specifies the addition compiler flags, besides the debug and release flags, that are used when compiling the CppAD examples and tests. The default value for these flags is the empty string $code ""$$. These flags must be valid for the C++ compiler 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" $$ $subhead C++11$$ In order for the compiler to take advantage of features that are new in C++11, the $icode cppad_cxx_flags$$ must enable these features. The compiler may still be used with a flag that disables the new features (unless it is a Microsoft compiler; i.e., $code _MSC_VER$$ is defined). $head cppad_profile_flag$$ This specifies an addition compiler and link flag that is used for $cref/profiling/speed_main/package/profile/$$ the speed tests. A profile version of the speed test is only build when this argument is present. $subhead Eigen and Fadbad$$ The packages $cref/eigen/eigen_prefix/$$ and $cref/fadbad/fadbad_prefix/$$ currently generate a lot of shadowed variable warnings. If the $code -Wshadow$$ flag is present, it is automatically removed when compiling examples and test that use these packages. $head cppad_testvector$$ See $tref cppad_testvector$$. $head cppad_max_num_threads$$ The value $icode cppad_max_num_threads$$ must be greater than or equal to four; i.e., $icode%max_num_threads% >= 4%$$. The current default value for $icode cppad_max_num_threads$$ is 48, but it may change in future versions of CppAD. The value $icode cppad_max_num_threads$$ in turn specifies the default value for the preprocessor symbol $cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$. $head cppad_sparse_list$$ There are two possible values for this option, $code YES$$ and $code NO$$. This affect the internal data structure used to store a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ when the users version of the sparsity pattern is a vector of $code std::set$$. If $icode cppad_sparse_list$$ is $code NO$$ the vectors of standard sets are also used internally. If $icode cppad_sparse_list$$ is $code YES$$, a special sparse list structure is used instead. This should affect the speed and memory required by the $cref sparse_jacobian$$, $cref sparse_hessian$$, and $cref/sparse drivers/sparse/$$ The default value for $icode cppad_sparse_list$$ is $code YES$$ $head cppad_tape_id_type$$ The type $icode cppad_tape_id_type$$ is used for identifying different tapes. The valid values for this type are $code unsigned char$$, $code unsigned short int$$, $code unsigned int$$, and $code size_t$$. The smaller the value of $codei%sizeof(%cppad_tape_id_type%)%$$, the less memory is used. On the other hand, the value $codei% 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/$$. $subhead cstdint$$ If all of the following $code cstdint$$ types are defined, they can also be used as the value of $icode cppad_tape_addr_type$$: $code uint8_t$$, $code uint16_t$$, $code uint32_t$$, $code uint64_t$$. $head cppad_tape_addr_type$$ The type $icode cppad_tape_addr_type$$ is used for address in the AD recordings (tapes). The valid values for this argument are $code unsigned char$$, $code unsigned short int$$, $code unsigned int$$, $code size_t$$. The smaller the value of $codei%sizeof(%cppad_tape_addr_type%)%$$, the less memory is used. On the other hand, the value $codei% std::numeric_limits<%cppad_tape_addr_type%>::max() %$$ must be larger than any of the following: $cref/size_op/seq_property/size_op/$$, $cref/size_op_arg/seq_property/size_op_arg/$$, $cref/size_par/seq_property/size_text/$$, $cref/size_par/seq_property/size_par/$$, $cref/size_par/seq_property/size_VecAD/$$. $subhead cstdint$$ If all of the following $code cstdint$$ types are defined, they can also be used as the value of $icode cppad_tape_addr_type$$: $code uint8_t$$, $code uint16_t$$, $code uint32_t$$, $code uint64_t$$. $head cppad_deprecated$$ The default value for $icode cppad_deprecated$$ is $code NO$$. If it is $code YES$$, then all the CppAD $cref deprecated$$ features are included in the $cref/installation/install/Instructions/Step 4: Installation/$$. Otherwise, some of the deprecated features may be excluded from the installation. (The intention here is to exclude more deprecated features as time marches on.) $children% omh/install/adolc_prefix.omh% 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 %$$ $end cppad-20160000.1/omh/install/testvector.omh0000644000175200017650000000400312656321765017571 0ustar coincoin-web// $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. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin cppad_testvector$$ $spell CppAD cppad eigen std testvector namespace cmake $$ $section Choosing the CppAD Test Vector Template Class$$ $head Purpose$$ The value $icode cppad_testvector$$ in the $cref/cmake command/cmake/CMake Command/$$ must be one of the following: $code boost$$, $code cppad$$, $code eigen$$, or $code std$$. It specifies which type of vector is corresponds to the template class $cref/CPPAD_TESTVECTOR/testvector/$$ which is used for many of the CppAD examples and tests. $head std$$ If $icode%cppad_testvector%$$ is $icode std$$, the $code std::vector$$ template class is used to define $code CPPAD_TESTVECTOR$$. $head cppad$$ If $icode%cppad_testvector%$$ is $icode cppad$$, the $cref cppad_vector$$ template class is used to define $code CPPAD_TESTVECTOR$$. $head boost$$ 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 %$$ 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 %$$ module must be able to automatically figure out where Boost is installed. $head eigen$$ If $icode%cppad_testvector%$$ is $icode eigen$$, one of the eigen template classes is used to define $code CPPAD_TESTVECTOR$$. In this case, $cref eigen_prefix$$ must be specified on the $code cmake$$ command line. $end cppad-20160000.1/omh/install/eigen_prefix.omh0000644000175200017650000000452712656321765020046 0ustar coincoin-web// $Id: eigen_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. A copy of 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 eigen_prefix$$ $dollar @$$ $spell 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%$$: $table $rref cppad_eigen.hpp$$ $rref eigen_array.cpp$$ $rref eigen_det.cpp$$ $tend $head eigen_prefix$$ If Eigen is installed on your system, you can specify a value for its install $icode eigen_prefix$$ on the $cref cmake$$ command line. The value of $icode eigen_prefix$$ must be such that, for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% %eigen_prefix%/%dir%/Eigen/Core %$$ is a valid way to reference to the include file $code Core$$; $head Examples$$ If you include $icode eigen_prefix$$ on the $cref cmake$$ command line, you will be able to run the Eigen examples list above by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% cd build/example make check_example %$$ If you do this, you will see an indication that the examples $code eigen_array$$ and $code eigen_det$$ have passed their correctness check. options to this program. $head Test Vector$$ If you have specified $icode eigen_prefix$$ you can choose $codei% -D cppad_testvector=eigen %$$ on the $cref/cmake command/cmake/CMake Command/$$ line. This we set the CppAD $cref testvector$$ to use Eigen vectors. $children% bin/get_eigen.sh %$$ $head get_eigen$$ If you are using Unix, you can download and install a copy of Eigen using $cref get_eigen.sh$$. The corresponding $icode eigen_prefix$$ would be $code build/prefix$$. $end cppad-20160000.1/omh/install/install.omh0000644000175200017650000000266312656321765017047 0ustar coincoin-web$Id: install.omh 3760 2015-12-01 04:12: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. A copy of 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 Install$$ $dollar @$$ $spell makefiles nmake cmake tarball CppAD $$ $section CppAD Download, Test, and Install Instructions$$ $head Instructions$$ $subhead Step 1: Download$$ Use the $cref download$$ instructions to obtain a copy or CppAD. $subhead Step 2: Cmake$$ Use the $cref cmake$$ instructions to configure CppAD. $subhead Step 3: Check$$ Use the $cref cmake_check$$ instructions to check the CppAD examples and tests. $subhead Step 4: Installation$$ Use the command $codep make install $$ to install CppAD. If you created $code nmake$$ makefiles, you will have to use $codep 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/auto_tools.omh %$$ $end cppad-20160000.1/omh/install/download.omh0000644000175200017650000002045512656321765017207 0ustar coincoin-web$Id: download.omh 3786 2016-02-08 13:14:26Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin download$$ $escape $$ $spell vcdir vcvarsall Microsoft tarball yyyy mm dd tarballs mkdir cmake nmake Makefiles omhelp svn https org dir exe gpl xvzf CppAD cppad gzip yyyymmdd rel lic epl tgz hpp $$ $dollar @$$ $section Download The CppAD Source Code$$ $head 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. $head Distribution Directory$$ We refer to the CppAD source directory created by the download instruction below as the distribution directory. To be specific, the distribution directory contains the file $code cppad/cppad.hpp$$. $head Compressed Archives$$ These files have been archived using $code tar$$ and compressed using $code gzip$$: $table $bold version$$ $pre $$ $cnext $bold license$$ $pre $$ $cnext $bold link$$ $rnext current $cnext EPL $cnext $href% http://www.coin-or.org/download/source/CppAD/cppad-20160000.1.epl.tgz% cppad-20160000.1.epl.tgz%$$ $rnext current $cnext GPL $cnext $href% http://www.coin-or.org/download/source/CppAD/cppad-20160000.1.gpl.tgz% cppad-20160000.1.gpl.tgz%$$ $rnext old $cnext Both $cnext $href%http://www.coin-or.org/download/source/CppAD/%CppAD download page%$$ $tend $subhead Current Version$$ The current versions listed above correspond to the subversion $href%https://projects.coin-or.org/CppAD/browser/trunk%trunk%$$ and the git $href%https://github.com/bradbell/cppad%master%$$. These tarballs only last for a few days. $subhead Release Versions$$ Release versions of the compressed tar files are available on the $href%http://www.coin-or.org/download/source/CppAD/%CppAD download page%$$. This includes all the releases going back to 2007. These file have the form $codei% cppad-%yyyymmdd%.%rel%.%lic%.tgz %$$ The license code $icode lic$$ is $code gpl$$, $code epl$$ or $code cpl$$ where $code gpl$$ denotes the GNU General Public License, $code epl$$ denotes the Eclipse Public License, and $code cpl$$ denotes the Common Public License (not being used for new versions). The version number $icode yyyymmdd$$ is the date at which the features of the program were frozen where $icode yyyy$$ is the year, $icode mm$$ is the month, and $icode dd$$ is the day. The release number $icode rel$$ corresponds to a bug fix index where higher numbers corresponding to more bug fixes. $subhead Monthly Versions$$ Monthly versions of the compressed tar files are available on the $href%http://www.coin-or.org/download/source/CppAD/%CppAD 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 %$$ where the license code $icode lic$$ is $code gpl$$ or $code epl$$ and $icode yyyy$$ is the current year. $subhead Unix File Extraction$$ On unix, you can use the command $codei% tar -xvzf cppad-%version%.%lic%.tgz %$$ where $icode version$$ either refers to the current version, or one of the release versions. This will decompress and extract the CppAD into the distribution directory $codei%cppad-%version%$$. To see if this has been done correctly, check for the following file: $codei% cppad-%version%/cppad/cppad.hpp %$$ $subhead Windows File Extraction and Testing$$ If you know how to extract the distribution directory from the tar file, just do so. Otherwise, below is one way you can do it. (Note that if $code 7z.exe$$, $code cmake.exe$$, and $code nmake.exe$$ are you 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 tarball: $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) $codei% mkdir build cd build cmake -G "NMake Makefiles" .. nmake check %$$ $lend $subhead Install Instructions$$ The instructions on the web correspond to the current version of CppAD. If you are using an old version of CppAD You should follow the install instructions in the $code doc$$ subdirectory of the distribution directory. $head Subversion$$ $subhead Limitations$$ This download procedure has the following limitations: $list number$$ The $href%http://subversion.tigris.org/%subversion%$$ program must be installed on your system. $lnext No documentation is included by this download procedure, though it can be build from the source code; see $cref/install instructions/download/Subversion/Install Instructions/$$ below. $lnext Only the $href%http://opensource.org/licenses/EPL-1.0%EPL licensed%$$ version of CppAD can be obtained by this download procedure (some old versions correspond to CPL instead of EPL). $lend $subhead Current Version$$ To obtain current version of CppAD, execute the following commands $codei% svn export https://projects.coin-or.org/svn/CppAD/trunk %dir% %$$ To see if this has been done correctly, check for the following file: $codei% %dir%/cppad/cppad.hpp %$$ We refer to your directory choice $icode dir$$ above as the distribution directory. $subhead Stable Versions$$ Subversion downloads are available for a set of stable versions (after the specified date, only bug fixes get applied). The following link will list the available $icode dir$$ values corresponding to $href%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 export 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 %$$ Note that it will correspond to the most recent release for this stable version. $subhead Release Versions$$ Subversion downloads are available for a set of release versions (no changes are applied). The following link will list the available $icode dir$$ values corresponding to $href%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 export 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 %$$ $subhead Install Instructions$$ If you are using subversion to download an old version of CppAD, you will have to build the documentation to get the corresponding install instructions. 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 $$ shows it is in your path. Once you have done this, in the distribution directory execute the following command: $codei% ./build.sh omhelp %$$ You will then be able to follow the install instructions in the $code doc$$ subdirectory of the distribution directory. $end cppad-20160000.1/omh/install/pkgconfig.omh0000644000175200017650000000600112656321765017336 0ustar coincoin-web// $Id: pkgconfig.omh 3760 2015-12-01 04:12: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. A copy of 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 pkgconfig$$ $spell cmake datadir ipopt CppAD pkg-config Cflags Dir builddir prefixdir cppad pkgconfig uninstalled $$ $section CppAD pkg-config Files$$ $mindex pc$$ $head Purpose$$ The $code pkg-config$$ package helps with the use of installed libraries; see its $href%http://people.freedesktop.org/~dbn/pkg-config-guide.html%guide%$$ for more information. $head Usage$$ The necessary flags for compiling code that includes CppAD can be obtained with the command $codep 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 $codep pkg-config --libs cppad $$ Note that this command assumes $code ipopt.pc$$ is in the search path $code PKG_CONFIG_PATH$$. $head Defined Fields$$ $table $icode Name$$ $cnext A human-readable name for the CppAD package. $rnext $icode Description$$ $cnext A brief description of the CppAD package. $rnext $icode URL$$ $cnext 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. $rnext $icode Cflags$$ $cnext 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 $rnext $icode Requires$$ $cnext 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 $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/$$ $rnext $icode%builddir%/pkgconfig/cppad-uninstalled.pc%$$ $cnext for testing before $code make install$$ $tend $end cppad-20160000.1/omh/install/sacado_prefix.omh0000644000175200017650000000413312656321765020202 0ustar coincoin-web// $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. A copy of 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 sacado_prefix$$ $dollar @$$ $spell 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 $href%http://trilinos.sandia.gov/packages/sacado%Sacado%$$; see $cref speed_sacado$$. $head sacado_prefix$$ If Sacado is installed on your system, you can specify a value for its install $icode sacado_prefix$$ on the $cref cmake$$ command line. The value of $icode sacado_prefix$$ must be such that, for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% %sacado_prefix%/%dir%/Sacado.hpp %$$ is a valid way to reference to the include file $code Sacado.hpp$$; $head Speed Tests$$ If you include $icode sacado_prefix$$ on the $cref cmake$$ command line, you will be able to run the Sacado speed correctness tests by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% cd build/speed/sacado make check_speed_sacado %$$ After executing $code make check_speed_sacado$$, you can run a specific Sacado speed test by executing the command $code ./speed_sacado$$; see $cref speed_main$$ for the meaning of the command line options to this program. $children% bin/get_sacado.sh %$$ $head get_sacado$$ If you are using Unix, you can download and install a copy of Sacado using $cref get_sacado.sh$$. The corresponding $icode sacado_prefix$$ would be $code build/prefix$$. $end cppad-20160000.1/omh/install/auto_tools.omh0000644000175200017650000004005512656321765017566 0ustar coincoin-web$Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin auto_tools$$ $escape $$ $dollar ^$$ $spell ctor testvector Eigen colpack num cxx boostvector inv fopenmp openmp cout Addr sizeof op_arg err_retu const printf avector.h Ipopt Ip gzip Linux fi exp_apx tgz gpl Dev sed cppad gprof config stdvector std ublas hpp adouble badiff usr cygdrive htm xml Dir xvzf gz workspace Makefile exe Cygwin Microsoft dsw CppAD Adolc Fadbad Sacado ls aclocal yum devel $$ $section Auto Tools Unix Test and Installation$$ $mindex speed profile prefix std vector boost eigen sparse internal sets ctor implicit explicit compile flags OpenMP postfix Adolc Fadbad Ipopt Sacado memory usage tape$$ $head Deprecated 2012-12-26$$ These install instructions have been deprecated and no improvements have been added since 2012. For example, this install procedure will not detect any of the $code c++11$$ extensions. You should use the $cref cmake$$ instructions to install CppAD. $head Distribution Directory$$ You must first obtain a copy of the CppAD distribution directory using the $cref download$$ instructions. The install instructions below correspond to the $cref/current version/download/Compressed Archives/Current Version/$$ which has distribution directory $code cppad-20121230$$. $head Work Directory$$ Create the directory $code cppad-20121230/build$$, which will be referred to as the build directory below. $head Configure$$ Execute the following command in the build directory: $codei% ./configure \ --prefix=%prefix_dir% \ --with-Documentation \ --with-%test%vector \ --with-sparse_%option% \ --with-deprecated \ MAX_NUM_THREADS=%max_num_threads% \ CXX_FLAGS=%cxx_flags% \ OPENMP_FLAGS=%openmp_flags% \ POSTFIX_DIR=%postfix_dir% \ ADOLC_DIR=%adolc_dir% \ BOOST_DIR=%boost_dir% \ EIGEN_DIR=%eigen_dir% \ FADBAD_DIR=%fadbad_dir% \ SADADO_DIR=%sacado_dir% \ IPOPT_DIR=%ipopt_dir% \ TAPE_ADDR_TYPE=%tape_addr_type% \ TAPE_ID_TYPE=%tape_id_type% %$$ where only the $code configure$$ line need appear; i.e., the entries in all of the other lines are optional. The text in italic is replaced values that you choose; see discussion below. $head make$$ CppAD has some object libraries that are used for its correctness tests. (Currently, none of these libraries get installed.) You can build these libraries by executing the command $codei% make %$$ in the build directory. $subhead Examples and Tests$$ Once you have executed the $code make$$ command, you can run the correctness and speed tests. $pre $$ The following command will build all the correctness and speed tests. In addition, it will run all the correctness tests: $codep make test $$ $pre $$ The following links describe how to build and run subsets of these tests: $table $cref/get_started/get_started.cpp/Running/$$ $cnext $title get_started.cpp$$ $rnext $cref/exp_apx_main/exp_apx_main.cpp/Running Tests/$$ $cnext $title exp_apx_main.cpp$$ $rnext $cref/example/example.cpp/Running Tests/$$ $cnext $title example.cpp$$ $rnext $cref/print_for_cout/print_for_cout.cpp/Running/$$ $cnext $title print_for_cout.cpp$$ $rnext $cref/speed_example/speed_example.cpp/Running Tests/$$ $cnext $title speed_example.cpp$$ $rnext $cref/speed_double/speed_double/Running Tests/$$ $cnext $title speed_double$$ $rnext $cref/speed_adolc/speed_adolc/Running Tests/$$ $cnext $title speed_adolc$$ $rnext $cref/speed_cppad/speed_cppad/Running Tests/$$ $cnext $title speed_cppad$$ $rnext $cref/speed_fadbad/speed_fadbad/Running Tests/$$ $cnext $title speed_fadbad$$ $rnext $cref/speed_sacado/speed_sacado/Running Tests/$$ $cnext $title speed_sacado$$ $tend In addition, you can run a large subset of correctness tests (that are not intended to be examples) by executing the following commands starting in the build directory: $codei% cd test_more make test %$$ $head Profiling CppAD$$ The CppAD derivative speed tests mentioned above can be profiled. You can test that the results computed during this profiling are correct by executing the following commands starting in the build directory: $codei% cd speed/profile make test %$$ After executing $code make test$$, you can run a profile speed test by executing the command $code ./profile$$; see $cref speed_main$$ for the meaning of the command line options to this program. $pre $$ After you have run a profiling speed test, you can then obtain the profiling results with $codei% gprof -b profile %$$ If you are using a windows operating system with Cygwin or MinGW, you may have to replace $code profile$$ by $code profile.exe$$ in the $code gprof$$ command above; i.e., $codep gprof -b profile.exe $$ In C++, template parameters and argument types become part of a routines's name. This can make the $code gprof$$ output hard to read (the routine names can be very long). You can remove the template parameters and argument types from the routine names by executing the following command $codep gprof -b profile | sed -f gprof.sed $$ If you are using a windows operating system with Cygwin or MinGW, you would need to use $codep gprof -b profile.exe | sed -f gprof.sed $$ $head prefix_dir$$ The default value for prefix directory is $code ^HOME$$ i.e., by default the CppAD include files will $cref/install/auto_tools/make install/$$ below $code ^HOME$$. If you want to install elsewhere, you will have to use this option. As an example of using the $codei%--prefix=%prefix_dir%$$ option, if you specify $codep ./configure --prefix=/usr/local $$ the CppAD include files will be installed in the directory $codei% /usr/local/include/cppad %$$ If $cref/--with-Documentation/auto_tools/--with-Documentation/$$ is specified, the CppAD documentation files will be installed in the directory $codei% /usr/local/share/doc/cppad-20121230 %$$ $head --with-Documentation$$ If the command line argument $code --with-Documentation$$ is specified, the CppAD documentation HTML and XML files are copied to the directory $codei% %prefix_dir%/share/doc/%postfix_dir%/cppad-20121230 %$$ (see $cref/postfix_dir/auto_tools/postfix_dir/$$). The top of the CppAD HTML documentation tree (with mathematics displayed as LaTex command) will be located at $codei% %prefix_dir%/share/doc/%postfix_dir%/cppad-20121230/cppad.htm %$$ and the top of the XML documentation tree (with mathematics displayed as MathML) will be located at $codei% %prefix_dir%/share/doc/%postfix_dir%/cppad-20121230/cppad.xml %$$ $head --with-testvector$$ The $cref/CPPAD_TESTVECTOR/testvector/$$ template class is used for many of the CppAD examples and tests. The default for this template class is $codei%CppAD::vector<%Scalar%>%$$. If one, and only one, of the following command line arguments is specified: $codep --with-stdvector --with-boostvector --with-eigenvector $$ the corresponding of the following template classes is used $codei% std::vector<%Scalar%> boost::numeric::ublas::vector<%Scalar%> Eigen::matrix<%Scalar%, Eigen::Dynamic, 1> %$$ See also, $cref/boost_dir/auto_tools/boost_dir/$$ and $cref/eigen_dir/auto_tools/eigen_dir/$$. $head --with-sparse_option$$ There are two options for the preprocessor symbol $code CPPAD_INTERNAL_SPARSE_SET$$. If $code --with-sparse_set$$ ($code --with-sparse_list$$) is specified, this symbol is $code sparse_set$$ ($code sparse_list$$). This should affect the speed and memory required by the $cref sparse_jacobian$$, $cref sparse_hessian$$, and the $cref/sparse drivers/sparse/$$. $head --with-deprecated$$ If this configure argument is present, then all the $cref deprecated$$ features are included in the install. Otherwise, they are not included. $head max_num_threads$$ this specifies the value for the default value for the preprocessor symbol $cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$. It must be greater than or equal to four; i.e., $icode%max_num_threads% >= 4%$$. $head cxx_flags$$ If the command line argument $icode CompilerFlags$$ is present, it specifies compiler flags. For example, $codei% CXX_FLAGS="-Wall -ansi" %$$ would specify that warning flags $code -Wall$$ and $code -ansi$$ should be included in all the C++ compile commands. The error and warning flags chosen must be valid options for the C++ compiler. The default value for $icode CompilerFlags$$ is the empty string. $head openmp_flags$$ If the command line argument $icode OpenmpFlags$$ is present, it specifies the necessary flags so that the compiler will properly interpret OpenMP directives. For example, when using the GNU $code g++$$ compiler, the following setting includes the OpenMP tests: $codei% OPENMP_FLAGS=-fopenmp %$$ If you specify configure command, the CppAD OpenMP correctness and speed tests will be built; see $cref/threading/thread_test.cpp/Running Tests/threading/$$ multi-threading tests. $head postfix_dir$$ By default, the postfix directory is empty; i.e., there is no postfix directory. As an example of using the $codei%POSTFIX_DIR=%postfix_dir%$$ option, if you specify $codep ./configure --prefix=/usr/local POSTFIX_DIR=coin $$ the CppAD include files will be $cref/installed/auto_tools/make install/$$ in the directory $codei% /usr/local/include/coin/cppad %$$ If $cref/--with-Documentation/auto_tools/--with-Documentation/$$ is specified, the CppAD documentation files will be installed in the directory $codei% /usr/local/share/doc/coin/cppad-20121230 %$$ $head adolc_dir$$ If you have $href%https://projects.coin-or.org/ADOL-C%ADOL-C%$$ installed on your system, you can specify a value for $icode adolc_dir$$ in the $cref/configure/auto_tools/Configure/$$ command line. The value of $icode adolc_dir$$ must be such that $codei% %adolc_dir%/include/adolc/adouble.h %$$ is a valid way to reference $code adouble.h$$. In this case, you can run the Adolc speed correctness tests by executing the following commands starting in the build directory: $codei% cd speed/adolc make test %$$ After executing $code make test$$, you can run an Adolc speed tests by executing the command $code ./adolc$$; see $cref speed_main$$ for the meaning of the command line options to this program. Note that these speed tests assume Adolc has been configure with its sparse matrix computations enabled using $codei% --with-colpack=%colpack_dir% %$$ $subhead Linux$$ If you are using Linux, you will have to add $icode%adolc_dir%/lib%$$ to $code LD_LIBRARY_PATH$$. For example, if you use the $code bash$$ shell to run your programs, you could include $codei% LD_LIBRARY_PATH=%adolc_dir%/lib:^{LD_LIBRARY_PATH} export LD_LIBRARY_PATH %$$ in your $code ^HOME/.bash_profile$$ file. $subhead Cygwin$$ If you are using Cygwin, you will have to add to following lines to the file $code .bash_profile$$ in your home directory: $codei% PATH=%adolc_dir%/bin:^{PATH} export PATH %$$ in order for Adolc to run properly. If $icode adolc_dir$$ begins with a disk specification, you must use the Cygwin format for the disk specification. For example, if $code d:/adolc_base$$ is the proper directory, $code /cygdrive/d/adolc_base$$ should be used for $icode adolc_dir$$. $head boost_dir$$ If the command line argument $codei% BOOST_DIR=%boost_dir% %$$ is present, it must be such that files $codei% %boost_dir%/include/boost/numeric/ublas/vector.hpp %boost_dir%/include/boost/thread.hpp %$$ are present. In this case, these files will be used by CppAD. See also, $cref/--with-boostvector/auto_tools/--with-testvector/$$ $head eigen_dir$$ If you have $href%http://eigen.tuxfamily.org%Eigen%$$ installed on your system, you can specify a value for $icode eigen_dir$$. It must be such that $codei% %eigen_dir%/include/Eigen/Core %$$ is a valid include file. In this case CppAD will compile and test the Eigen examples; e.g., $cref eigen_array.cpp$$. See also, $cref/--with-eigenvector/auto_tools/--with-testvector/$$ $head fadbad_dir$$ If you have $href% http://www.fadbad.com/% Fadbad 2.1 %$$ installed on your system, you can specify a value for $icode fadbad_dir$$. It must be such that $codei% %fadbad_dir%/include/FADBAD++/badiff.h %$$ is a valid reference to $code badiff.h$$. In this case, you can run the Fadbad speed correctness tests by executing the following commands starting in the build directory: $codei% cd speed/fadbad make test %$$ After executing $code make test$$, you can run a Fadbad speed tests by executing the command $code ./fadbad$$; see $cref speed_main$$ for the meaning of the command line options to this program. $head ipopt_dir$$ If you have $href% http://www.coin-or.org/projects/Ipopt.xml% Ipopt %$$ installed on your system, you can specify a value for $icode ipopt_dir$$. It must be such that $codei% %ipopt_dir%/include/coin/IpIpoptApplication.hpp %$$ is a valid reference to $code IpIpoptApplication.hpp$$. In this case, the CppAD interface to Ipopt $cref/examples/cppad_ipopt_nlp/Example/$$ can be built and tested by executing the following commands starting in the build directory: $codei% make # cd cppad_ipopt/example make test # cd ../test make test # cd ../speed make test %$$ Once this has been done, you can execute the program $code ./speed$$ in the $code build/cppad_ipopt/speed$$ directory; see $cref ipopt_ode_speed.cpp$$. $head sacado_dir$$ If you have $href% http://trilinos.sandia.gov/packages/sacado/% Sacado %$$ installed on your system, you can specify a value for $icode sacado_dir$$. It must be such that $codei% %sacado_dir%/include/Sacado.hpp %$$ is a valid reference to $code Sacado.hpp$$. In this case, you can run the Sacado speed correctness tests by executing the following commands starting in the build directory: $codei% cd speed/sacado make test %$$ After executing $code make test$$, you can run a Sacado speed tests by executing the command $code ./sacado$$; see $cref speed_main$$ for the meaning of the command line options to this program. $head tape_addr_type$$ If the command line argument $icode tape_addr_type$$ is present, it specifies the type used for address in the AD recordings (tapes). The valid values for this argument are $code unsigned short int$$, $code unsigned int$$, $code size_t$$. The smaller the value of $icode%sizeof(%tape_addr_type%)%$$, the less memory is used. On the other hand, the value $codei% std::numeric_limits<%tape_addr_type%>::max() %$$ must be larger than any of the following: $cref/size_op/seq_property/size_op/$$, $cref/size_op_arg/seq_property/size_op_arg/$$, $cref/size_par/seq_property/size_text/$$, $cref/size_par/seq_property/size_par/$$, $cref/size_par/seq_property/size_VecAD/$$. $head tape_id_type$$ If the command line argument $icode tape_id_type$$ is present, it specifies the type used for identifying tapes. The valid values for this argument are $code unsigned short int$$, $code unsigned int$$, $code size_t$$. The smaller the value of $icode%sizeof(%tape_id_type%)%$$, the less memory is used. On the other hand, the value $codei% std::numeric_limits<%tape_id_type%>::max() %$$ must be larger than the maximum number of tapes per thread times $cref/max_num_threads/auto_tools/max_num_threads/$$. $head make install$$ Once you are satisfied that the tests are giving correct results, you can install CppAD into easy to use directories by executing the command $codep make install $$ This will install CppAD in the location specified by $cref/prefix_dir/auto_tools/prefix_dir/$$. You must have permission to write in the $icode prefix_dir$$ directory to execute this command. You may optionally specify a destination directory for the install; i.e., $codei% make install DESTDIR=%DestinationDirectory% %$$ $end cppad-20160000.1/omh/install/ipopt_prefix.omh0000644000175200017650000000371512656321765020110 0ustar coincoin-web// $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. A copy of 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 ipopt_prefix$$ $dollar @$$ $spell 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$$ example and tests as well as installing the $code cppad_ipopt$$ library during the $code make install$$ step. $head ipopt_prefix$$ If you have $href%http://www.coin-or.org/projects/Ipopt.xml%Ipopt%$$ installed on your system, you can specify the value for $icode ipopt_prefix$$ on the $cref cmake$$ command line. The value of $icode ipopt_prefix$$ must be such that, for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% %ipopt_prefix%/%dir%/coin/IpIpoptApplication.hpp %$$ is a valid way to reference to the include file $code IpIpoptApplication.hpp$$. $head Examples and Tests$$ If you include $icode ipopt_prefix$$ on the $cref cmake$$ command line, you will be able to run the Ipopt examples and tests by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% cd cppad_ipopt make check_ipopt %$$ $children% bin/get_ipopt.sh %$$ $head get_ipopt$$ If you are using Unix, you can download and install a copy of Ipopt using $cref get_ipopt.sh$$. The corresponding $icode ipopt_prefix$$ would be $code build/prefix$$. $end cppad-20160000.1/omh/install/colpack_prefix.omh0000644000175200017650000000435512656321765020372 0ustar coincoin-web// $Id: colpack_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. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin colpack_prefix$$ $dollar @$$ $spell 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 $cref/cmake command/cmake/CMake Command/$$ line, the CppAD $cref sparse_jacobian$$ calculations use the $href%http://cscapes.cs.purdue.edu/dox/ColPack/html%ColPack%$$ package. $head colpack_prefix$$ If ColPack is installed on your system, you can specify a value for its install $icode colpack_prefix$$ on the $cref cmake$$ command line. The value of $icode colpack_prefix$$ must be such that, for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% %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 %$$ at the global level. For this reason, CppAD does not include these files. It is therefore necessary to link the object library $code cppad_lib$$ when using ColPack. $children%example/colpack_jac.cpp %example/colpack_hes.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 a copy of ColPack using $cref get_colpack.sh$$. The corresponding $icode colpack_prefix$$ would be $code build/prefix$$. $end cppad-20160000.1/omh/det_grad_33_hpp.omh0000644000175200017650000000155612656321765016660 0ustar coincoin-web$Id: det_grad_33_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin det_grad_33.hpp$$ $spell det_grad_33 ifndef endif $$ $section Source: det_grad_33$$ $mindex source$$ $code # ifndef CPPAD_DET_GRAD_33_HPP $pre $$ # define CPPAD_DET_GRAD_33_HPP $verbatim%cppad/speed/det_grad_33.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/addon.omh0000644000175200017650000000461612656321765015020 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin addon$$ $spell Addons addon libdir includedir libcppad adcomp CppAD cppad.hpp ons namespace cg pycppad $$ $section CppAD Addons$$ $head Name$$ Each CppAD addon has a short name which we denote by $icode name$$ below, a longer name $icode longer$$ and a $icode description$$: $table $icode name$$ $pre $$ $cnext $icode longer$$ $pre $$ $cnext $icode description$$ $rnext $href%https://github.com/joaoleal/CppADCodeGen/%cg%$$ $cnext $code CppADCodeGen$$ $cnext C++ Source Code Generation of CppAD Derivative Calculations $rnext $href%http://www.seanet.com/~bradbell/pycppad/pycppad.htm%py%$$ $cnext $code pycppad$$ $cnext A Python Interface to CppAD $rnext $href%https://github.com/kaskr/adcomp%tmb%$$ $cnext $code adcomp$$ $cnext An R Interface to CppAD with Random Effects Modeling Utilities $rnext $href%http://moby.ihme.washington.edu/bradbell/cppad_mixed%mixed%$$ $cnext $code cppad_mixed$$ $cnext A C++ Interface to Random Effects Laplace Approximation $tend $head Include Files$$ If $icode includedir$$ is the directory where the include files are installed, the file $codei% %includedir%/cppad/%name%.hpp %$$ and the directory $codei% %includedir%/cppad/%name% %$$ are reserved for use by the $icode name$$ addon. $head Library Files$$ If $icode libdir$$ is the directory where CppAD library files are installed, files with the name $codei% %libdir%/libcppad_%name%.%ext% %libdir%/libcppad_%name%_%anything%.%ext% %$$ where $icode anything$$ and $icode ext$$ are arbitrary, are reserved for use by the $icode name$$ addon. $head Preprocessor Symbols$$ C++ preprocessor symbols that begin with $codei% CPPAD_%NAME%_ %$$ where $icode NAME$$ is a upper-case version of $icode name$$, are reserved for use by the $icode name$$ addon. $head Namespace$$ The C++ namespace $codei% CppAD::%name% %$$ is reserved for use by the $icode name$$ addon. $end cppad-20160000.1/omh/lu_factor_hpp.omh0000644000175200017650000000153212656321765016552 0ustar coincoin-web$Id: lu_factor_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin lu_factor.hpp$$ $spell Lu ifndef endif $$ $section Source: LuFactor$$ $mindex source$$ $code # ifndef CPPAD_LU_FACTOR_HPP $pre $$ # define CPPAD_LU_FACTOR_HPP $verbatim%cppad/utility/lu_factor.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/preprocessor.omh0000644000175200017650000000574612656321765016466 0ustar coincoin-web// $Id: preprocessor.omh 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. -------------------------------------------------------------------------- */ $begin preprocessor$$ $spell const nullptr CppADvector Vec $$ $section CppAD API Preprocessor Symbols$$ $mindex CPPAD_ NULL pointer$$ $head Purpose$$ The CppAD include files define preprocessor symbols all of which begin with $code CPPAD_$$. Note that there are some old, deprecated preprocessor symbols that begin with $code CppAD$$. In this section we list all of the CppAD preprocessor symbols that are part of the CppAD Application Interface (API). $head Documented Here$$ $subhead CPPAD_NULL$$ Is a null pointer used by CppAD, instead of just using the value zero which was often done in C++98, which has been replaced by the value $code nullptr$$ in C++11. $subhead CPPAD_PACKAGE_STRING$$ Is a $code const char*$$ representation of this version of CppAD. $subhead CPPAD_USE_CPLUSPLUS_2011$$ This preprocessor symbol has the value has the value $code 1$$ if C++11 features are being used by CppAD. Otherwise it has the value zero. $head Documented Elsewhere$$ $table $cref/CPPAD_BOOL_BINARY/BoolFun/Create Binary/$$ $rnext $cref/CPPAD_BOOL_UNARY/BoolFun/Create Unary/$$ $rnext $cref/CPPAD_DISCRETE_FUNCTION/Discrete/$$ $rnext $cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$ $rnext $cref/CPPAD_NUMERIC_LIMITS/base_limits/CPPAD_NUMERIC_LIMITS/$$ $rnext $cref/CPPAD_STANDARD_MATH_UNARY/base_std_math/CPPAD_STANDARD_MATH_UNARY/$$ $rnext $cref/CPPAD_TAPE_ADDR_TYPE/cmake/cppad_tape_addr_type/$$ $rnext $cref/CPPAD_TAPE_ID_TYPE/cmake/cppad_tape_id_type/$$ $rnext $cref/CPPAD_TESTVECTOR/testvector/$$ $rnext $cref/CPPAD_TO_STRING/base_to_string/CPPAD_TO_STRING/$$ $tend $head Deprecated$$ $table $cref/CppADCreateDiscrete/Discrete/CppADCreateDiscrete Deprecated 2007-07-28/$$ $rnext $cref/CppADvector/test_vector/Deprecated 2012-07-03/$$ $rnext $cref/CPPAD_TEST_VECTOR/test_vector/$$ $rnext $cref/CPPAD_TRACK_NEW_VEC/TrackNewDel/TrackNewVec/Macro/$$ $rnext $cref/CPPAD_TRACK_DEL_VEC/TrackNewDel/TrackDelVec/Macro/$$ $rnext $cref/CPPAD_TRACK_EXTEND/TrackNewDel/TrackExtend/Macro/$$ $rnext $cref/CPPAD_TRACK_COUNT/TrackNewDel/TrackCount/Macro/$$ $rnext $cref/CPPAD_USER_ATOMIC/old_atomic/$$ $rnext $cref/CppADTrackNewVec/TrackNewDel/TrackNewVec/Previously Deprecated/$$ $rnext $cref/CppADTrackDelVec/TrackNewDel/TrackDelVec/Previously Deprecated/$$ $rnext $cref/CppADTrackExtend/TrackNewDel/TrackExtend/Previously Deprecated/$$ $rnext $cref/CppADTrackCount/TrackNewDel/TrackCount/Previously Deprecated/$$ $tend $end cppad-20160000.1/omh/det_33_hpp.omh0000644000175200017650000000151312656321765015654 0ustar coincoin-web$Id: det_33_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin det_33.hpp$$ $spell det_33 ifndef endif $$ $section Source: det_33$$ $mindex source$$ $code # ifndef CPPAD_DET_33_HPP $pre $$ # define CPPAD_DET_33_HPP $verbatim%cppad/speed/det_33.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/theory/0002755000175200017650000000000012656321765014533 5ustar coincoin-webcppad-20160000.1/omh/theory/exp_reverse.omh0000644000175200017650000000347512656321765017576 0ustar coincoin-web$Id: exp_reverse.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. A copy of 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 cppad-20160000.1/omh/theory/sin_cos_reverse.omh0000644000175200017650000000520412656321765020427 0ustar coincoin-web$Id: sin_cos_reverse.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. A copy of 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 cppad-20160000.1/omh/theory/forward_theory.omh0000644000175200017650000001301712656321765020276 0ustar coincoin-web$Id: forward_theory.omh 3686 2015-05-11 16:14:25Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin 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 cppad-20160000.1/omh/theory/erf_forward.omh0000644000175200017650000000341012656321765017534 0ustar coincoin-web$Id:$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin 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 cppad-20160000.1/omh/theory/log_forward.omh0000644000175200017650000000406712656321765017552 0ustar coincoin-web$Id: log_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. A copy of 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 cppad-20160000.1/omh/theory/reverse_theory.omh0000644000175200017650000001235412656321765020310 0ustar coincoin-web$Id: reverse_theory.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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/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 cppad-20160000.1/omh/theory/tan_forward.omh0000644000175200017650000000446412656321765017554 0ustar coincoin-web$Id: tan_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin 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 cppad-20160000.1/omh/theory/atan_forward.omh0000644000175200017650000000441012656321765017704 0ustar coincoin-web$Id: atan_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. A copy of 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 cppad-20160000.1/omh/theory/erf_reverse.omh0000644000175200017650000000347112656321765017552 0ustar coincoin-web$Id:$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin 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 cppad-20160000.1/omh/theory/acos_forward.omh0000644000175200017650000000600412656321765017707 0ustar coincoin-web$Id: acos_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. A copy of 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 cppad-20160000.1/omh/theory/theory.omh0000644000175200017650000000141112656321765016545 0ustar coincoin-web$Id: theory.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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/theory/forward_theory.omh% omh/theory/reverse_theory.omh% omh/theory/reverse_identity.omh%$$ $end cppad-20160000.1/omh/theory/log_reverse.omh0000644000175200017650000000501612656321765017554 0ustar coincoin-web$Id: log_reverse.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. A copy of 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 cppad-20160000.1/omh/theory/tan_reverse.omh0000644000175200017650000000631312656321765017556 0ustar coincoin-web$Id: tan_reverse.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin 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 cppad-20160000.1/omh/theory/sqrt_forward.omh0000644000175200017650000000367512656321765017766 0ustar coincoin-web$Id: sqrt_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. A copy of 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 cppad-20160000.1/omh/theory/asin_forward.omh0000644000175200017650000000572112656321765017721 0ustar coincoin-web$Id: asin_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. A copy of 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 cppad-20160000.1/omh/theory/atan_reverse.omh0000644000175200017650000000664212656321765017724 0ustar coincoin-web$Id: atan_reverse.omh 3682 2015-05-08 21:59:05Z 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. A copy of 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 cppad-20160000.1/omh/theory/acos_reverse.omh0000644000175200017650000000773312656321765017730 0ustar coincoin-web$Id: acos_reverse.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. A copy of 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 cppad-20160000.1/omh/theory/exp_forward.omh0000644000175200017650000000377712656321765017574 0ustar coincoin-web$Id: exp_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. A copy of 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 cppad-20160000.1/omh/theory/sin_cos_forward.omh0000644000175200017650000000514712656321765020426 0ustar coincoin-web$Id: sin_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. A copy of 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 cppad-20160000.1/omh/theory/reverse_identity.omh0000644000175200017650000001057612656321765020633 0ustar coincoin-web$Id: reverse_identity.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 cppad-20160000.1/omh/theory/sqrt_reverse.omh0000644000175200017650000000376712656321765017777 0ustar coincoin-web$Id: sqrt_reverse.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin 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 cppad-20160000.1/omh/theory/asin_reverse.omh0000644000175200017650000000770212656321765017731 0ustar coincoin-web$Id: asin_reverse.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. A copy of 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 cppad-20160000.1/omh/seq_property.omh0000644000175200017650000001424412656321765016465 0ustar coincoin-web$Id: seq_property.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin seq_property$$ $spell inuse Addr CppAD sizeof op arg enum Taylor const bool var VecAD $$ $section ADFun Sequence Properties$$ $head Syntax$$ $icode%n% = %f%.Domain() %$$ $icode%m% = %f%.Range() %$$ $icode%p% = %f%.Parameter(%i%) %$$ $icode%s% = %f%.size_var() %$$ $icode%s% = %f%.size_par() %$$ $icode%s% = %f%.size_op() %$$ $icode%s% = %f%.size_op_arg() %$$ $icode%s% = %f%.size_text() %$$ $icode%s% = %f%.size_VecAD() %$$ $icode%s% = %f%.size_op_seq() %$$ $subhead See Also$$ $cref size_order$$, $cref capacity_order$$. $head Purpose$$ The operations above return properties of the AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ stored in the ADFun object $icode f$$. (If there is no operation sequence stored in $icode f$$, $code size_var$$ returns zero.) $head f$$ The object $icode f$$ has prototype $codei% const ADFun<%Base%> %f% %$$ (see $codei%ADFun<%Base%>%$$ $cref/constructor/FunConstruct/$$). $head Domain$$ The result $icode n$$ has prototype $codei% 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%) %$$ that starting recording the operation sequence currently stored in $icode f$$ (see $cref FunConstruct$$ and $cref Dependent$$). $head Range$$ The result $icode m$$ has prototype $codei% 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%) %$$ or $codei% %f%.Dependent(%y%) %$$ depending on which stored the operation sequence currently in $icode f$$ (see $cref FunConstruct$$ and $cref Dependent$$). $head Parameter$$ The argument $icode i$$ has prototype $codei% size_t %i% %$$ and $latex 0 \leq i < m$$. The result $icode p$$ has prototype $codei% bool %p% %$$ It is true if the $th i$$ component of range space for $latex F$$ corresponds to a $cref/parameter/glossary/Parameter/$$ in the operation sequence. In this case, the $th i$$ component of $latex F$$ is constant and $latex \[ \D{F_i}{x_j} (x) = 0 \] $$ for $latex j = 0 , \ldots , n-1$$ and all $latex x \in B^n$$. $head size_var$$ The result $icode s$$ has prototype $codei% 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 $icode f$$ is roughly proportional to $icode s$$. (The function call $cref/f.size_order()/size_order/$$ returns the number of Taylor coefficient orders, per variable,direction, currently stored in $icode f$$.) $pre $$ If there is no operation sequence stored in $icode f$$, $code size_var$$ returns zero (see $cref/default constructor/FunConstruct/Default Constructor/$$). $head size_par$$ The result $icode s$$ has prototype $codei% 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 $icode f$$. Note that one $icode Base$$ value is required for each parameter. $head size_op$$ The result $icode s$$ has prototype $codei% 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 $cref/size_var/seq_property/size_var/$$. Note that one $code enum$$ value is required for each operator. $head size_op_arg$$ The result $icode s$$ has prototype $codei% 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. $head size_text$$ The result $icode s$$ has prototype $codei% size_t %s% %$$ and is the total characters used in the $cref PrintFor$$ commands in this operation sequence. $head size_VecAD$$ The result $icode s$$ has prototype $codei% size_t %s% %$$ and is the number of $cref VecAD$$ vectors, plus the number of elements in the vectors. Only $code VecAD$$ vectors that depend on the independent variables are stored in the operation sequence. $head size_op_seq$$ The result $icode s$$ has prototype $codei% 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 $codei% %s% = %f%.size_op() * sizeof(CppAD::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%) %$$ 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. $head Example$$ $children% example/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 cppad-20160000.1/omh/omp_alloc_dep.omh0000644000175200017650000000646112656321765016530 0ustar coincoin-web/* $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. A copy of 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 efficient$$ $spell 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 it is just as fast, or faster, to free and then reallocate the memory. $head Syntax$$ $codei%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 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/get_memory/min_bytes/$$ equal to $icode num_bytes$$ would result in a value for $cref/cap_bytes/get_memory/cap_bytes/$$ that is the same as when $code v_ptr$$ 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/get_thread_num/$$ must be the same as during the corresponding call to $cref get_memory$$, or the current execution mode must be sequential (not $cref/parallel/in_parallel/$$). $head NDEBUG$$ If $code NDEBUG$$ is defined, $icode v_ptr$$ is not checked (this is faster). Otherwise, a list of in use pointers is searched to make sure that $icode v_ptr$$ is in the list. $end ------------------------------------------------------------------------------- $begin old_max_num_threads$$ $spell inv CppAD num omp_alloc $$ $section Set Maximum Number of Threads for omp_alloc Allocator$$ $mindex max_num_threads parallel OpenMP initialize$$ $head Removed$$ This function has been removed from the CppAD API. Use the function $cref/set_max_num_threads/max_num_threads/$$ in its place. $head Syntax$$ $codei%omp_alloc::max_num_threads(%number%)%$$ $head Purpose$$ By default there is only one thread and all execution is in sequential mode (not $cref/parallel/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/in_parallel/$$ execution mode. $end ------------------------------------------------------------------------------- cppad-20160000.1/omh/lu_solve_hpp.omh0000644000175200017650000000152412656321765016425 0ustar coincoin-web$Id: lu_solve_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin lu_solve.hpp$$ $spell Lu ifndef endif $$ $section Source: LuSolve$$ $mindex source$$ $code # ifndef CPPAD_LU_SOLVE_HPP $pre $$ # define CPPAD_LU_SOLVE_HPP $verbatim%cppad/utility/lu_solve.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/new_feature.omh0000644000175200017650000000360312656321765016232 0ustar coincoin-web$Id: new_feature.omh 3785 2016-02-08 12:53:06Z 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. A copy of 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 NewFeature$$ $spell cppad.hpp CppAD Makefile Microsoft OMhelp cvs dsp nobase $$ $section Adding a New Feature to the CppAD Distribution$$ $head Overview$$ Suppose that you add a new feature to CppAD and the corresponding include file is $icode%Name%.h%$$. You should check each of the following steps: $list number$$ Add the new file $icode%Name%.h%$$ to the cvs repository. $lnext Add a test file called $codei%example/%Name%.cpp%$$ that check for correct results (and run the test to make sure it works). $lnext Add the new file $codei%example/%Name%.cpp%$$ to the cvs repository. $lnext Add a call to the new test in the file $code example/example.cpp$$. $lnext Add the file $icode%Name%.cpp%$$ to the list of $code Example_SOURCES$$ in the file $code example/Makefile.am$$. $lnext Add the file $icode%Name%.cpp%$$ to the list of source files corresponding to the Microsoft C++ project file $code example/Example.dsp$$. $lnext Add the file $icode%Name%.h%$$ to the list of $code nobase_include_HEADERS$$ in the file $code Makefile.am$$. $lnext Add the new feature to the OMhelp documentation tree. $lnext Add the new feature the cppad/cppad.hpp include tree. $lnext Mention the new feature in the WhatsNew file for the current year. $lend $end cppad-20160000.1/omh/sparse_hes_fun.omh0000644000175200017650000000156412656321765016736 0ustar coincoin-web$Id: sparse_hes_fun.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin sparse_hes_fun.hpp$$ $spell hes ifndef endif $$ $section Source: sparse_hes_fun$$ $mindex source$$ $code # ifndef CPPAD_SPARSE_HES_FUN_HPP $pre $$ # define CPPAD_SPARSE_HES_FUN_HPP $verbatim%cppad/speed/sparse_hes_fun.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/numeric_ad.omh0000644000175200017650000000152512656321765016035 0ustar coincoin-web$Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin numeric_ad$$ $spell CppAD namespace alloc $$ $section Some Numerical AD Utilities$$ The routines listed below are numerical utilities that are designed to work with CppAD in particular. $childtable% cppad/local/bender_quad.hpp% cppad/local/opt_val_hes.hpp% cppad/local/lu_ratio.hpp %$$ $end cppad-20160000.1/omh/lu_det_and_solve.omh0000644000175200017650000000151412656321765017233 0ustar coincoin-web$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. A copy of 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 LuDetAndSolve$$ $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 %$$ $end cppad-20160000.1/omh/det_of_minor_hpp.omh0000644000175200017650000000156512656321765017246 0ustar coincoin-web$Id: det_of_minor_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin det_of_minor.hpp$$ $spell det_of_minor ifndef endif $$ $section Source: det_of_minor$$ $mindex source$$ $code # ifndef CPPAD_DET_OF_MINOR_HPP $pre $$ # define CPPAD_DET_OF_MINOR_HPP $verbatim%cppad/speed/det_of_minor.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/simple_vector.omh0000644000175200017650000001515212656321765016603 0ustar coincoin-web$Id: simple_vector.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin SimpleVector$$ $spell 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$$, is any template class that satisfies the requirements below. The following is a list of some simple vector template classes: $table $bold Name$$ $cnext $bold Documentation$$ $rnext $code std::vector$$ $cnext Section 16.3 of $cref/The C++ Programming Language/Bib/The C++ Programming Language/$$ $rnext $code std::valarray$$ $cnext Section 22.4 of $cref/The C++ Programming Language/Bib/The C++ Programming Language/$$ $rnext $code CppAD::vector$$ $cnext $tref CppAD_vector$$ $tend $head Elements of Specified Type$$ 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%> %$$ The routine $cref CheckSimpleVector$$ can be used to check that a class is a simple vector class with a specified element type. $head Default Constructor$$ The syntax $codei% %SimpleVector%<%Scalar%> %x%; %$$ creates an empty vector $icode x$$ ($icode%x%.size()%$$ is zero) that can later contain elements of the specified type (see $cref/resize/SimpleVector/Resize/$$ below). $head Sizing Constructor$$ If $icode n$$ has type $code size_t$$, $codei% %SimpleVector%<%Scalar%> %x%(%n%) %$$ creates a vector $icode x$$ with $icode n$$ elements each of the specified type. $head Copy Constructor$$ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object, $codei% %SimpleVector%<%Scalar%> %y%(%x%) %$$ creates a vector with the same type and number of elements as $icode x$$. The $icode Scalar$$ assignment operator ( $code =$$ ) is used to set each element of $icode y$$ equal to the corresponding element of $icode x$$. This is a `deep copy' in that the values of the elements of $icode x$$ and $icode y$$ can be set independently after the copy. The argument $icode x$$ is passed by reference and may be $code const$$. $head Element Constructor and Destructor$$ The default constructor for type $icode Scalar$$ is called for every element in a vector when the vector element is created. The $icode Scalar$$ destructor is called when it is removed from the vector (this includes when the vector is destroyed). $head Assignment$$ If $icode x$$ and $icode y$$ are $icode%SimpleVector%<%Scalar%>%$$ objects, $codei% %y% = %x% %$$ uses the $icode Scalar$$ assignment operator ( $code =$$ ) to set each element of $icode y$$ equal to the corresponding element of $icode x$$. This is a `deep assignment' in that the values of the elements of $icode x$$ and $icode y$$ can be set independently after the assignment. The vectors $icode x$$ and $icode y$$ must have the same number of elements. The argument $icode x$$ is passed by reference and may be $code const$$. $pre $$ The type returned by this assignment is unspecified; for example, it might be void in which case the syntax $codei% %z% = %y% = %x% %$$ would not be valid. $head Size$$ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object and $code n$$ has type $code size_t$$, $codei% %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$$. $head Resize$$ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object and $code n$$ has type $code size_t$$, $codei% %x%.resize(%n%) %$$ changes the number of elements contained in the vector $icode x$$ to be $icode n$$. The value of the elements of $icode x$$ are not specified after this operation; i.e., any values previously stored in $icode x$$ are lost. (The object $icode x$$ can not be $code const$$.) $head Value Type$$ If $icode Vector$$ is any simple vector class, the syntax $codei% %Vector%::value_type %$$ is the type of the elements corresponding to the vector class; i.e., $codei% %SimpleVector%<%Scalar%>::value_type %$$ is equal to $icode Scalar$$. $head Element Access$$ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object and $icode i$$ has type $code size_t$$, $codei% %x%[%i%] %$$ returns an object of an unspecified type, referred to here as $icode elementType$$. $subhead Using Value$$ If $icode elementType$$ is not the same as $icode Scalar$$, the conversion operator $codei% static_cast<%Scalar%>(%x%[%i%]) %$$ is used implicitly when $icode%x%[%i%]%$$ is used in an expression with values of type $icode Scalar$$. For this type of usage, the object $icode x$$ may be $code const$$. $subhead Assignment$$ If $icode y$$ is an object of type $icode Scalar$$, $codei% %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% %$$ would not be valid. $head Example$$ $children% example/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$$ $list number$$ If $icode Vector$$ is a simple vector template class, the following code may not be valid: $codei% %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: $code std::vector$$, $code CppAD::vector$$. Do this both where the compiler option $code -DNDEBUG$$ is and is not present on the compilation command line. $lnext If $icode Vector$$ is a simple vector template class, the following code may not be valid: $codei% %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: $code std::valarray$$, $code CppAD::vector$$. Do this both where the compiler option $code -DNDEBUG$$ is and is not present on the compilation command line. $lend $end cppad-20160000.1/omh/whats_new/0002755000175200017650000000000012656321765015220 5ustar coincoin-webcppad-20160000.1/omh/whats_new/whats_new.omh0000644000175200017650000000320712656321765017724 0ustar coincoin-web$Id: whats_new.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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$$ $spell CppAD $$ $section Changes and Additions to CppAD$$ $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. $children% omh/whats_new/whats_new_15.omh% omh/whats_new/whats_new_14.omh% omh/whats_new/whats_new_13.omh% omh/whats_new/whats_new_12.omh% omh/whats_new/whats_new_11.omh% omh/whats_new/whats_new_10.omh% omh/whats_new/whats_new_09.omh% omh/whats_new/whats_new_08.omh% omh/whats_new/whats_new_07.omh% omh/whats_new/whats_new_06.omh% omh/whats_new/whats_new_05.omh% omh/whats_new/whats_new_04.omh% omh/whats_new/whats_new_03.omh %$$ $head This Year$$ $cref whats_new_15$$ $head Previous Years$$ $cref whats_new_14$$ $cref whats_new_13$$ $cref whats_new_12$$ $cref whats_new_11$$, $cref whats_new_10$$, $cref whats_new_09$$, $cref whats_new_08$$, $cref whats_new_07$$, $cref whats_new_06$$, $cref whats_new_05$$, $cref whats_new_04$$, $cref whats_new_03$$. $end cppad-20160000.1/omh/whats_new/whats_new_10.omh0000644000175200017650000002312412656321765020224 0ustar coincoin-web$Id: whats_new_10.omh 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. -------------------------------------------------------------------------- */ $begin whats_new_10$$ $spell 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/auto_tools/ipopt_dir/$$ is specified on the $code configure$$ command line). $head 08-21$$ Fix problems with linking of $cref cppad_ipopt_nlp$$ test with both older and newer versions of $code ipopt$$. $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/auto_tools/Configure/$$ command has been improved so that it can work both with versions of ipopt that use $code pkg-config$$ and ones that don't. $head 07-11$$ Old versions of the ipopt library were located in $icode%ipopt_dir%/lib/libipopt.%*%$$ (see $cref/ipopt_dir/auto_tools/ipopt_dir/$$), but newer versions will be located in $icode%ipopt_dir%/lib/coin/libipopt.%*%$$. The directory $icode%ipopt_dir%/lib/coin%$$ has been added to the library search path so that the $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/Vector of Boolean/$$ 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/auto_tools/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/auto_tools/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 cppad-20160000.1/omh/whats_new/whats_new_11.omh0000644000175200017650000007463712656321765020244 0ustar coincoin-web$Id: whats_new_11.omh 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. -------------------------------------------------------------------------- */ $begin whats_new_11$$ $spell 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/auto_tools/--with-testvector/$$ for $cref/boost_dir/auto_tools/boost_dir/$$. This enables one to specify $icode boost_dir$$ for $cref team_bthread.cpp$$ with out using boost vectors. $head 11-20$$ $list number$$ Move $code sum_i_inv.cpp$$ to $cref harmonic.cpp$$. $lnext Include the date, time, CppAD version, and $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.cpp$$. $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_work.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 multi_thread/openmp$$. and create $code 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%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/auto_tools/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/auto_tools/Configure/$$ information for building the tests. $lnext Document the $code --with-openmp$$ configure command line argument. $lnext Move $code openmp/multi_newton.hpp$$ to $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 auto_tools$$ instructions for running the individual correctness and speed tests were out of date. This has been fixed; see $cref/example and tests/auto_tools/make/Examples and Tests/$$. $lnext Move $code parallel_ad.cpp$$ from $code example$$ directory to $code openmp$$ directory (and convert it from a function to a program). $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 $cref/sparsity/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/auto_tools/tape_addr_type/$$ option was added to the $cref/configure/auto_tools/Configure/$$ command line. $lnext The function $cref/size_op_seq/seq_property/size_op_seq/$$ results uses $code sizeof(CppAD_TAPE_ADDR_TYPE)$$ 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/auto_tools/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/option_list/atomic/$$ option to the speed test program and use $cref old_mat_mul.hpp$$ during the $cref cppad_mat_mul.cpp$$ speed test when the atomic option is specified. $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 $cref/cppad_sparse_list/cmake/cppad_sparse_list/$$ choice during the install process. $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 $cref/subversion download/download/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/auto_tools/Configure/$$ command in it. $lnext Since the change on 01-09, the file $code omh/whats_new_11.omh$$ has been required to build the 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/auto_tools/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/auto_tools/ipopt_dir/$$ was not defined on the $code configure$$ command line. $lnext The speed test library $code libspeed.a$$ was being installed (it is only intended for testing). $lend These problems are fixed in the trunk and these fixes will be copied to the corresponding stable and release versions; i.e., $codei% http://www.coin-or.org/download/source/CppAD/cppad-20110101.1.%license%.tgz %$$ will not have this problem. $end cppad-20160000.1/omh/whats_new/whats_new_03.omh0000644000175200017650000005150312656321765020230 0ustar coincoin-web$Id: whats_new_03.omh 3686 2015-05-11 16:14:25Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin 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 cppad-20160000.1/omh/whats_new/whats_new_12.omh0000644000175200017650000007736412656321765020245 0ustar coincoin-web$Id: whats_new_12.omh 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. -------------------------------------------------------------------------- */ $begin whats_new_12$$ $dollar @$$ $spell 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 auto_tools$$ 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 auto_tools$$ so that it works with the new $code cppad.pc$$. $lnext Fix the old installation $cref/--with-Documentation/auto_tools/--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 $cref/cppad_sparse_list/cmake/cppad_sparse_list/$$. $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 version number in link to the $cref/current download files/download/Compressed Archives/Current Version/$$. $lnext Change the $cref/subversion/download/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/auto_tools/$$ 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/auto_tools/$$ 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/auto_tools/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/auto_tools/fadbad_dir/$$ directory install instructions were changed. To be specific, $code FADBAD++$$ was changed to $code include/FADBAD++$$. This makes it more like the other optional packages. $head 10-25$$ The test $cref runge45_1.cpp$$ was failing when using gcc-4.5.2. 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/option_list/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 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 $cref/--with-sparse_option/auto_tools/--with-sparse_option/$$. $lnext A new speed test, $cref compare_c$$, compares the speed of the same source code compiled with C and C++. $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 $cref 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/vector_bool.cpp$$. $lend $head 07-07$$ Add the $code CPPAD_TAPE_ID_TYPE$$ argument to the $cref/configure/auto_tools/Configure/$$ command line. $head 07-05$$ Deprecate $cref/CPPAD_TEST_VECTOR/test_vector/$$ and use $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/auto_tools/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 $cref eigen_plugin.hpp$$ so that an Eigen vector can be used as a $cref/SimpleVector/$$. $head 07-01$$ $list number$$ Change $cref cppad_eigen.hpp$$ to match new specifications and example in eigen help files on $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/auto_tools/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/option_list/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/auto_tools/boost_dir/$$ configure command line value has been changed to be the corresponding prefix during the installation of boost. To be specific, it used to be that $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/auto_tools/max_num_threads/$$ argument to the unix $cref/configure/auto_tools/Configure/$$ command. $head 04-06$$ $list number$$ A change was made to the way that the tapes were managed to reduce 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/auto_tools/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 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/auto_tools/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 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/auto_tools/boost_dir/$$ override the default library. $head 01-27$$ There were some problems with $cref/configure's/auto_tools/Configure/$$ automatic detection of the boost multi-threading library. These have been fixed. $head 01-24$$ 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 multi_thread/test.sh$$ from source directory (no need to copy to build directory). $lend $head 01-16$$ The test program $code multi_thread/test.sh$$ failed if the $cref/openmp_flags/auto_tools/openmp_flags/$$ not present in the $code configure$$ command. This has been fixed. In addition, this $code test.sh$$ has been made faster by cycling through the available threading systems instead of doing every system for every test. $head 01-15$$ Fix $code make test$$ so it works when $cref/configure/auto_tools/Configure/$$ is run in the distribution directory $codei%cppad-%yyyymmdd%$$ (not just when it is run in a different directory). $head 01-12$$ The $code -lpthread$$ library was missing from the $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$$, in the file $cref multi_newton_work.cpp$$. $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.cpp/xout/$$. The correction was in the file $cref multi_newton_work.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.cpp$$ 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_combine/multi_newton_work.cpp/multi_newton_combine/$$ joined two solutions into one. It is possible that one of the solutions that needs to be joined is on 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 cppad-20160000.1/omh/whats_new/whats_new_04.omh0000644000175200017650000007170012656321765020232 0ustar coincoin-web$Id: whats_new_04.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin whats_new_04$$ $spell 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/auto_tools/$$ required the user to touch the files to get the dates in proper order. This is no longer necessary. $head 11-01$$ Some of the dependency directories and files, for example $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/auto_tools/$$ 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/auto_tools/$$ $code make$$ command. $head 09-23$$ There was a reference to $icode B$$ that should have been $icode X$$ in the description of the $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/auto_tools/$$ to try to run $code autoconf$$ and this did not work on systems with very old versions of $code autoconf$$. This has been fixed. $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/auto_tools/$$ instructions were modified so just one make command was executed at the top level. This was necessary because the order of the makes is now important (as previously suggested, the makes did not work properly). $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/auto_tools/$$ instructions place $code ./$$ in front of current directory program names; for example, $code ./GetStarted$$ instead of $code GetStarted$$ (because some unix systems do not have the current directory 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/auto_tools/$$. $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 cppad-20160000.1/omh/whats_new/whats_new_13.omh0000644000175200017650000004205712656321765020235 0ustar coincoin-web$Id: whats_new_13.omh 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. -------------------------------------------------------------------------- */ $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 auto_tools$$ (created when optional implicit constructor from any type was added). This has been fixed by adding the $code --with-implicit_ctor$$ option (later changed to $cref/--with-deprecated/auto_tools/--with-deprecated/$$). $lend $head 12-27$$ The constructor from an arbitrary type to $codei%AD<%Base%>%$$ was implicit, but there was no specification to this effect. The caused problems when using CppAD with $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/Compressed Archives/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/nesting conditional expressions /wish_list /Optimizing Nested Conditional Expressions /$$. $head 10-23$$ $list number$$ Fix a bug in the optimization of calls to $cref atomic$$ functions. This bug existed before recent change to optimizing conditional expressions. This required adding the $cref/dependency/RevSparseJac/dependency/$$ argument to the reverse Jacobian sparsity pattern calculation. $lnext Fix the deprecated autotools install (see $cref auto_tools$$) which was broken by the changes on 10-22. To be specific, the example for $cref number_skip$$ was not being included. $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_any.cpp$$ example. $lnext Fix bug in $cref RevSparseJac$$ for case when $cref/q/RevSparseJac/q/$$ was not equal to $icode m$$ (range dimension) and sparsity pattern was a 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 cppad-20160000.1/omh/whats_new/whats_new_05.omh0000644000175200017650000006576012656321765020244 0ustar coincoin-web$Id: whats_new_05.omh 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. -------------------------------------------------------------------------- */ $begin whats_new_05$$ $spell 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 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 ADTape tape; static 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 ADTape *Tape(void) { static 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/auto_tools/Configure/$$ command. $pre $$ Put a try and catch block around all of the uses of $code new$$ so that if a memory allocation error occurs, 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_any.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/auto_tools/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/auto_tools/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/auto_tools/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/auto_tools/prefix_dir/$$ and $icode postfix_dir$$ ($icode postfix_dir$$ has since been removed) options to the $code configure$$ command line. This gives the user more control over the location where CppAD is installed. $head 09-24$$ The stiff Ode routines, $cref OdeGear$$ and $cref OdeGearControl$$, were added to the $cref/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/auto_tools/Configure/$$ command. The $cref/Unix installation instructions/auto_tools/$$ were overhauled to make the larger set of options easy to understand. $head 09-14$$ 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/auto_tools/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 compute_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/auto_tools/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/auto_tools/cxx_flags/$$ for all the C++ compile commands, was added to the $cref/Unix installation instructions/auto_tools/$$. $head 02-24$$ The routine $cref LuSolve$$ was split into $cref LuFactor$$ and $cref LuInvert$$. This enables one to efficiently solve equations where the matrix does not change and the right hand side for one equation depends on the 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 cppad-20160000.1/omh/whats_new/whats_new_14.omh0000644000175200017650000003400212656321765020225 0ustar coincoin-web$Id: whats_new_14.omh 3760 2015-12-01 04:12: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. A copy of 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 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_hes_sparse.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/auto-tools/auto_tools/$$ 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/auto_tools/$$ 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 auto-tools $cref/unix install/auto_tools/$$ instructions to use the $cref cmake$$ install instructions. These instructions should work on any system, not just unix. $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/option_list/$$. $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/option_list/optimize/$$ option. Future auxillary information will be passed back in a manner similar to $cref/n_sweep/link_sparse_jacobian/n_sweep/$$ for the sparse jacobian test. $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/option_list/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/option_list/$$ 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 cppad-20160000.1/omh/whats_new/whats_new_06.omh0000644000175200017650000010204012656321765020224 0ustar coincoin-web$Id: whats_new_06.omh 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. -------------------------------------------------------------------------- */ $begin whats_new_06$$ $spell 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_main.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|auto_tools|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/auto_tools/--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 example.cpp$$ and $code test_more/test_more.cpp$$ programs were changed to print out the number of tests that passed or failed instead of just "All the tests passed" or "At least one of the tests failed". $pre $$ The windows project files for 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_main.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 $cref/evaluate functions and derivative values/FunEval/$$. $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 compute_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/-=/compute_assign/$$, $cref/*=/compute_assign/$$, and $cref%/=%compute_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/+=/compute_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 computed 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/auto_tools/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 cppad-20160000.1/omh/whats_new/whats_new_15.omh0000644000175200017650000007247312656321765020244 0ustar coincoin-web$Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin whats_new_15$$ $dollar @$$ $spell addon runge lcppad ind const enum ctor dimensioned cskip_op adolc zdouble expm1 eigen expm1 atanh acosh asinh src op onetape CppAD colpack hes cppad Jacobian gettimeofday cmake hpp dir includedirs libdirs datadir docdir std cxx erf var NumRes chrono aeps CondExpGt hasnan Adolc resize bool alloc adouble gmtime asctime ipopt fadbad sacado unreferenced azmul retape $$ $section CppAD Changes and Additions During 2015$$ $head Introduction$$ This section contains a list of the changes to CppAD during 2015 (in reverse order by date). The purpose of this section is to assist you in learning about changes between various versions of CppAD. $head 12-29$$ Separate $cref to_string$$ from $cref ad_to_string$$ so that it can be used without the rest of CppAD; i.e., by including $codei% # include %$$ $head 12-28$$ $list number$$ Add the $cref to_string$$ utility. $lnext Add $cref base_to_string$$ to the Base type requirements. $lnext A $cref/Base requirements/wish_list/Base Requirements/$$ item was added to the wish list. $lnext The $cref wish_list$$ item to reorganize the include directory has been removed. It was completed when the utilities was moved to $code cppad/utility$$; see $cref/11-30/whats_new_15/11-30/$$. $lend $head 12-08$$ $list number$$ A convention was included for addon $cref/library files/addon/Library Files/$$. $lnext Change new $cref utility$$ specifications to allow for individual file includes; e.g., $code $$. $lend $head 12-01$$ Fix problem with $cref auto_tools$$ install handling of the deprecated files. This included changing the auto-tools $code --with-implicit_ctor$$ option to $cref/--with-deprecated/auto_tools/--with-deprecated/$$. $head 11-30$$ $list number$$ The $code library$$ section has been moved to the $cref/utilities/utility/$$ section. In addition, the corresponding source code files in $code cppad$$ have been moved to $code cppad/utility$$. $lnext The individual $cref utility$$ include files have been deprecated; see $cref include_deprecated$$. For example, $codep # include $$ You should us the utility include instead; i.e., $codep # include $$ $lnext The $cref numeric_ad$$ routines where moved from the $code library$$ the a separate documentation section. $lnext Change $code cmake_install_prefix$$ to $cref/cppad_prefix/cmake/cppad_prefix/$$ and Change $code cmake_install_postfix$$ to $cref/cppad_postfix/cmake/cppad_postfix/$$. $lnext Change $code cppad_implicit_ctor_from_any_type$$ to $cref/cppad_deprecated/cmake/cppad_deprecated/$$ and change its specifications to refer to all deprecated features. $lend $head 11-25$$ $list number$$ CppAD now installs the object library $codep -lcppad_lib $$ to be included when linking. Currently, it is only required when $cref colpack_prefix$$ is specified on the $cref/cmake command/cmake/CMake Command/$$. $lnext It is no longer necessary to compile and link the file $codep cppad_colpack.cpp $$ when $cref colpack_prefix$$ is specified during the install process; see $cref/cmake command/cmake/CMake Command/$$. (It is included in $code cppad_lib$$). $lend $head 11-24$$ $list number$$ The $code check_for_nan$$ output now includes the first dependent variable $cref/index/check_for_nan/Error Message/index/$$ that is $code nan$$ in its error message. $lnext Change the $cref/deprecated include/include_deprecated/$$ reference $code pow_int.h$$ to $code pow_int.hpp$$ in $cref pow_int$$. $lend $head 11-14$$ There was a bug in the new $cref/get_check_for_nan/check_for_nan/get_check_for_nan/$$ feature that writes independent variable values to a temporary file; see $cref/11-06/whats_new_15/11-06/$$ below. This has been fixed. $head 11-08$$ $list number$$ Fixed a bug in the $cref RevSparseJac$$ routine. To be specific, the argument $cref/r/RevSparseJac/r/$$ was transposed from what the documentation said. (This has no effect in the usual case where $icode r$$ is the identity.) $lnext Added the $cref bool_sparsity.cpp$$ examples which show how to conserve memory when computing sparsity patterns. $lnext Modified the $cref ipopt_solve$$ procedure to take advantage of the memory conserving sparsity pattern calculations when $cref/retape/ipopt_solve/options/Retape/$$ is false. $lnext Added the $cref/bit_per_unit/CppAD_vector/vectorBool/bit_per_unit/$$ function to the $code vectorBool$$ class. (This aids the memory conservation mentioned above.) $lend $head 11-06$$ It is often difficult to determine what cause a $code nan$$ result during an operation with an $cref ADFun$$ object. The new feature $cref/get_check_for_nan/check_for_nan/get_check_for_nan/$$ was added to make this easier. $head 10-21$$ There was a mistake in the documentation for $cref index_sort$$, the argument $cref/ind/index_sort/ind/$$ is not $code const$$. $head 10-16$$ Add a $cref/PrintFor optimization/wish_list/PrintFor Optimization/$$ item to the wish list. $head 10-06$$ $list number$$ Add $cref/CPPAD_USE_CPLUSPLUS_2011 /preprocessor /Documented Here /CPPAD_USE_CPLUSPLUS_2011 /$$, $code CPPAD_NUMERIC_LIMITS$$, and $code CPPAD_STANDARD_MATH_UNARY$$, to the $cref preprocessor$$ section. In addition, remove checking that all user API preprocessor symbols are in this section form the $cref wish_list$$. $lnext Alphabetize and make some corrections to $cref/list of examples/ListAllExamples/$$. $lnext The documentation for some of the $cref deprecated$$ features was missing the date when they were deprecated. This has been fixed; e.g., see $cref/Deprecated 2012-12-26/auto_tools/Deprecated 2012-12-26/$$. $lend $head 10-04$$ $list number$$ $cref base_require$$: Add the macro $cref/CPPAD_NUMERIC_LIMITS/base_limits/CPPAD_NUMERIC_LIMITS/$$ to aid in setting the numeric limits for a user defined $icode Base$$ class. $lnext $cref base_require$$: The $cref/quiet_NaN/numeric_limits/quiet_NaN/$$ function has been added to the CppAD $code numeric_limits$$. Note the reason for not using $cref/std::numeric_limits/numeric_limits/std::numeric_limits/$$. $lnext The $cref/nan(zero)/nan/nan(zero)/$$ function computes a $code nan$$ by dividing zero by zero which results in a warning when using some compilers. This function has been deprecated and the corresponding $cref wish_list$$ item has been removed. $lnext Move documentation for $cref zdouble$$ to $cref deprecated$$ section and documentation for $cref numeric_limits$$ to $cref ADValued$$. $lnext Remove all uses of, and references to, $cref zdouble$$ from the $cref/examples/Example/$$. $lend $head 10-03$$ $cref base_require$$: It is no longer necessary to define the specialization for $codei%CppAD::epsilon<%Base>()%$$ for each $icode Base$$ type. $head 10-02$$ There was a bug in $code test_more/azmul.cpp$$ whereby the vector $code z$$ had the wrong dimension (in two places). This has been fixed. $head 09-28$$ $list number$$ Use the current $cref atomic_option$$ setting to determine which type of sparsity patterns to use for $cref/dependency/dependency.cpp/$$ calculations during $cref optimize$$ procedure. It used to be that the $cref/bool_sparsity_enum/atomic_option/atomic_sparsity/bool_sparsity_enum/$$ was used when $cref/pack_sparsity_enum/atomic_option/atomic_sparsity/pack_sparsity_enum/$$ was specified. $lnext It is not longer an error to take the derivative of the square root function, because the result may be the part of a $cref/conditional expression/CondExp/$$ that is not used. $lnext Update the $cref wish_list$$ section. $lend $head 09-27$$ $list number$$ It is no longer necessary to use the $cref zdouble$$ class when computing with $cref/multiple levels of AD/mul_level/$$ $cref/conditional expressions/CondExp/$$ and $cref/reverse mode/reverse/$$. $lnext The $code zdouble$$ class has been deprecated. Use the $cref azmul$$ function for absolute zero (when it is needed). $lend $head 09-25$$ $cref base_require$$: $cref/absolute zero multiplication/base_require/Absolute Zero, azmul/$$ is now required for user defined base types. This makes it possible to combine $cref/conditional expression/CondExp/$$, $cref/multiple levels/mul_level/$$, $cref/reverse/Reverse/$$, and a base type that has standard ieee multiplication; e.g., $code double$$. In other words, not all multiplications will need to have an absolute zero (as is the case with the $cref zdouble$$ base class. $head 09-24$$ Fix some Visual Studio 2013 C++ level four $code /W4$$ warnings (previous warnings were are level 3). In addition, disable warning $code 4100$$ unreferenced formal parameter, and warning $code 4127$$ conditional expression is constant. $head 09-23$$ CppAD can optionally test its use with the external packages $cref/eigen/get_eigen.sh/$$, $cref/ipopt/get_ipopt.sh/$$, and $cref/colpack/get_colpack.sh/$$. In addition, it can compare its $cref speed$$ with the external AD packages $cref/adolc/get_adolc.sh/$$, $cref/fadbad/get_fadbad.sh/$$, and $cref/sacado/get_sacado.sh/$$. The scripts that download and install a local copy of these external packages have been modified to automatically skip installation when it has already been done. $head 09-21$$ Improve discussion of $cref/windows download and testing /download /Compressed Archives /Windows File Extraction and Testing /$$. $head 09-20$$ $list number$$ Add the $cref/cppad_profile_flag/cmake/cppad_profile_flag/$$ to the list of possible $code cmake$$ command arguments. $lnext More of the warnings generated by Visual Studio 2013 have been fixed. One remaining warning is about $code asctime$$ and $code gmtime$$ not being thread safe. $lend $head 09-19$$ $list number$$ There was a bug in the $cref/numeric_limits/base_alloc.hpp/numeric_limits/$$ section of the example user defined base type. This has been fixed. $lnext There were some compile and link errors when running the tests using Visual Studio 2013. These have been fixed. $lnext Many of the warnings generated by Visual Studio 2013 have been fixed. $lend $head 09-16$$ The conditional expressions, $cref CondExp$$, were not working for the type $code< CppAD::AD >$$ where $code adouble$$ is the ADOL-C AD type. This has been fixed by adding a call to $cref/CPPAD_COND_EXP_REL/base_adolc.hpp/CondExpRel/$$ in $code base_adolc.hpp$$. $head 09-03$$ $list number$$ There was a bug in the $cref/vectorBool/CppAD_vector/vectorBool/$$ $cref/assignment/CppAD_vector/Assignment/$$. To be specific, it not allow a size zero vector to be assigned using a vector any other size. This has been fixed. $lnext The addition of the $cref/pack/atomic_option/atomic_sparsity/pack_sparsity_enum/$$ option on 08-31 introduced a bug in the calculation of $cref RevSparseHes$$. The $cref checkpoint.cpp$$ example was changed to demonstrate this problem and the bug was fixed. $lend $head 09-02$$ The $cref/dependency pattern/dependency.cpp/Dependency Pattern/$$ was not being computed correctly for the $cref sign$$, $cref Discrete$$, and $cref VecAD$$ operations. This has been fixed. This could have caused problems using $cref checkpoint$$ functions that used any of these operations. $head 08-31$$ $list number$$ Mention the fact that using checkpoint functions can make $cref/recordings faster/checkpoint/Purpose/Faster Recording/$$. $lnext Add the $cref/pack/atomic_option/atomic_sparsity/pack_sparsity_enum/$$ sparsity option for $cref atomic_base$$ operations. $lnext Add the pack sparsity option to $cref/checkpoint/checkpoint/sparsity/$$ functions. $lnext Added the $cref atomic_sparsity.cpp$$ example. $lnext Remove mention of OpenMP from $cref/thread_alloc::thread_num/ta_thread_num/$$ ($cref thread_alloc$$ never was OpenMP specific). $lend $head 08-30$$ $list number$$ The $cref/sparsity/atomic_ctor/atomic_base/sparsity/$$ argument was added to the $code atomic_base$$ constructor and the $cref/checkpoint/checkpoint/sparsity/$$ constructor. $lnext Make $cref atomic_norm_sq.cpp$$ an example with no set sparsity and $cref atomic_reciprocal.cpp$$ an example with no bool sparsity. $lnext Improve discussion of $code Independent$$ and $cref/parallel mode/Independent/Parallel Mode/$$. $lend $head 08-29$$ Some asserts in the $cref checkpoint$$ implementation were not using the CppAD $cref ErrorHandler$$. This has been fixed. $head 08-28$$ Free $cref checkpoint$$ function sparsity patters during $cref forward$$ operations that use its atomic operation. (They kept between sparsity calculations because they do not change.) $head 08-26$$ Fix a bug in $cref RevSparseJac$$ when used to compute sparsity pattern for a subset of the rows in a $cref checkpoint$$ function. $head 08-25$$ Reduce the amount of memory required for $cref checkpoint$$ functions (since sparsity patterns are now being held so they do not need to be recalculated). $head 08-20$$ Added an example that computes the sparsity pattern for a subset of the $cref/Jacobian/sparsity_sub.cpp/ForSparseJac/$$ and a subset of the $cref/Hessian/sparsity_sub.cpp/RevSparseHes/$$. $head 08-17$$ $list number$$ Do some optimization of the $cref checkpoint$$ feature so that sparsity patterns are stored and not recalculated. $lnext Fix a warning (introduced on 08-11) where the $code CppAD::vector$$ $cref/data/CppAD_vector/data/$$ function was being shadowed by a local variable. $lnext The source code control for CppAD has a link to $code compile$$, instead of real file. This sometimes caused problems with the deprecated $cref auto_tools$$ install procedure and has been fixed. $lend $head 08-16$$ $list number$$ Improve the documentation for checkpoint functions. To be specific, change the $cref/syntax/checkpoint/Syntax/$$ to use the name $icode atom_fun$$. In addition, include the fact that $icode atom_fun$$ must not be destructed for as along as the corresponding atomic operations are used. $lnext Add the $cref/size_var/checkpoint/size_var/$$ function to the checkpoint objects. $lend $head 08-09$$ Add the preservation of data to the specifications of a $code CppAD::vector$$ during a $cref/resize/CppAD_vector/resize/$$ when the capacity of the vector does not change. In addition, added and example of this to $cref cppad_vector.cpp$$. $head 08-06$$ The $cref zdouble$$ $cref/numeric_limits/base_limits/$$ were not being computed properly. This has been fixed. $head 07-31$$ Added the $cref sparse_sub_hes.cpp$$ example, a way to compute the sparsity for a subset of variables without using $cref/multiple levels of AD/mul_level/$$. $head 06-16$$ $list number$$ There were some $cref/unknown/cppad_assert/Unknown/$$ asserts when the sparsity pattern $icode p$$ in $cref/sparse_jacobian/sparse_jacobian/p/$$ and $cref/sparse_hessian/sparse_hessian/p/$$ was not properly dimensioned. These have been changed to $cref/known/cppad_assert/Known/$$ asserts to give better error reporting. $lnext In the special case where sparse Hessian $cref/work/sparse_hessian/work/$$ or sparse Jacobian $cref/work/sparse_hessian/work/$$ was specified and the set of elements to be computed was empty, the work vector is empty after the call (and it appears to need to be calculated on subsequent calls). This resulted in a bug when the sparsity pattern was not provided on subsequent calls (and has been fixed). $lend $head 06-11$$ $list number$$ Some C++11 features were not being taken advantage of after the change on $cref/05-10/whats_new_15/05-10/$$. To be specific, move semantics, the high resolution clock, and null pointers. This has been fixed. $lnext In the example $cref zdouble.cpp$$, the vector $code a1z$$ was not properly dimensioned. This has been fixed and the dimensions of all the variables have been clarified. $lend $head 06-09$$ Add an $cref/abort_op_index/Independent/abort_op_index/$$ item to the wish list. It has since been removed (domain errors may not affect the results due to $cref/conditional expressions/CondExp/$$). $head 06-07$$ Add a $cref/absolute zero/base_require/Absolute Zero, azmul/$$ item and a $cref numeric_limits$$ item to the wish list. The absolute zero item has been completed and the numeric limit item was modified on implementation. Remove the multiple directions with list item. $head 05-26$$ $subhead cond_exp_1$$ There was a problem using $cref/conditional expressions/CondExp/$$ with $cref/multiple levels of AD/mul_level/$$ where the result of the conditional expression might not be determined during forward mode. This would generate an assert of the form: $codei% Error detected by false result for IdenticalPar(%side%) at line %number% in the file %...%/cppad/local/cskip_op.hpp %$$ where $icode side$$ was $code left$$ or $code right$$ and $icode number$$ was the line number of an assert in $code cskip_op.hpp$$. This has been fixed. $subhead cond_exp_2$$ There was a problem with using $cref/conditional expressions/CondExp/$$ and $cref/reverse mode/reverse/$$ with $cref/multiple levels of AD/mul_level/$$. This was problem was represented by the file $code bug/cond_exp_2.sh$$. $list number$$ The problem above has been fixed by adding the base type $code zdouble$$, see $cref/CppAD motivation/zdouble/Motivation/CppAD/$$ for this new type. (It is no longer necessary to use $code zdouble$$ to get an absolute zero because CppAD now uses $cref azmul$$ where an absolute zero is required.) $lnext The sections $cref mul_level$$, $cref change_param.cpp$$, $cref mul_level.cpp$$, and $cref mul_level_ode.cpp$$ were changed to use $cref zdouble$$. $lnext The $cref/adolc/adolc_prefix/$$ multi-level examples $cref mul_level_adolc.cpp$$ and $cref mul_level_adolc_ode.cpp$$ were changed to mention the limitations because Adolc does not have an $cref/absolute zero/zdouble/Absolute Zero/$$. $lnext The example above were also changed so that AD variable names that indicated the level of AD for the variable. $lnext $cref base_require$$: The base type requirements were modified to include mention of $cref/absolute zero/base_require/Absolute Zero, azmul/$$. In addition, the base type requirements $cref/API warning/base_require/API Warning/$$ is now more informative. $lend $head 05-11$$ Reorganize the $cref unary_standard_math$$ documentation. $head 05-10$$ $list number$$ Add the exponential minus one function $cref log1p$$. $lnext $cref base_require$$: If you are defining your own base type, note that $cref/log1p/base_std_math/erf, asinh, acosh, atanh, expm1, log1p/$$ was added to the base type requirements. $lnext Use the single preprocessor flag $code CPPAD_USE_CPLUSPLUS_2011$$ to signal that the functions $cref/erf, asinh, acosh, atanh, expm1, log1p /base_std_math /erf, asinh, acosh, atanh, expm1, log1p /$$ are part of the base type requirements. $lend $head 05-09$$ $list number$$ Add the exponential minus one function $cref expm1$$. If you are defining your own base type, note that $cref/expm1/base_std_math/erf, asinh, acosh, atanh, expm1, log1p/$$ was added to the base type requirements. $lnext Fix some warnings about comparing signed and unsigned integers when using $cref/eigen/cppad_testvector/eigen/$$ for the CppAD test vector. (The eigen vector $code size()$$ function returns an $code int$$ instead of a $code size_t$$.) $lend $head 05-08$$ $list number$$ Add the inverse hyperbolic sine function $cref atanh$$. If you are defining your own base type, note that $cref/atanh/base_std_math/erf, asinh, acosh, atanh, expm1, log1p/$$ was added to the base type requirements. $lnext Fix a bug in the implementation of the $code acosh$$ multiple direction forward mode $cref forward_dir$$ (when compiler has $cref/acosh/acosh/CPPAD_USE_CPLUSPLUS_2011/$$). $lend $head 05-07$$ Add the inverse hyperbolic sine function $cref acosh$$. If you are defining your own base type, note that $cref/acosh/base_std_math/erf, asinh, acosh, atanh, expm1, log1p/$$ was added to the base type requirements. $head 05-05$$ Add the inverse hyperbolic sine function $cref asinh$$. If you are defining your own base type, note that $cref/asinh/base_std_math/erf, asinh, acosh, atanh, expm1, log1p/$$ was added to the base type requirements. $head 04-18$$ In the sparse jacobian and sparse hessian calculations, If $icode work$$ is present, and has already been computed, the sparsity pattern $icode p$$ is not used. This has been added to the documentation; see $cref/sparse jacobian/sparse_jacobian/work/p/$$ and $cref/sparse hessian/sparse_hessian/work/p/$$ documentation for $icode work$$ and $icode p$$. $head 03-13$$ Remove the syntax $codei% AD<%Base%> %y% = %x% %$$ for the $cref/AD constructor/ad_ctor/$$ documentation because it does not work when the constructor is $cref/explicit/ad_ctor/x/explicit/$$. Also document the restriction that the constructor in the $cref/assignment/ad_assign/$$ must be implicit. $head 03-06$$ The developers of the $href%https://github.com/kaskr/adcomp%TMB%$$ package reported that for large $cref ADFun$$ tapes, the $cref optimize$$ routine uses a large amount of memory because it allocates a standard set for each variable on the tape. These sets are only necessary for variables in $cref/conditional expressions/condexp/$$ that can be skipped once the independent variables have a set value. The problem has been reduced by using a NULL pointer for the empty set and similar changes. It still needs more work. $head 02-28$$ It used to be the case that the $cref/Reverse mode/reverse/$$ would propagate $cref nan$$ through the $cref/conditional expression/condexp/$$ case that is not used. For example, if $codep Independent(ax); AD aeps = 1e-10; ay[0] = CondExpGt( ax[0], aeps, 1.0/ax[0], 1.0/aeps ); ADFun f(ax, ay); $$ The corresponding reverse mode calculation, at $code x[0] = 0.0$$, would result in $codep Error detected by false result for ! ( hasnan(value) && check_for_nan_ ) $$ This has been fixed so that only the conditional expression case that is used affects the reverse mode results. The example $cref cond_exp.cpp$$ was changed to reflect this (a check for $code nan$$ was changed to a check for zero). Note that this fix only works when $cref/IdenticalPar/base_identical/Identical/IdenticalPar/$$ is true for the base type of the result in the conditional expression; e.g., one can still get a $code nan$$ effect from the case that is not selected when using $code AD< AD >$$ conditional expressions. $head 02-18$$ If the compiler supports the c++11 feature $code std::chrono:high_resolution_clock$$ then use it for the $cref elapsed_seconds$$ function. $head 02-16$$ The new example $cref sub_sparse_hes.cpp$$ shows one way to compute a Hessian for a subset of variables without having to compute the sparsity pattern for the entire functions. $head 02-14$$ Fix another bug in the derivative calculations for the c++11 version of the error function; see $cref/CPPAD_USE_CPLUSPLUS_2011/erf/CPPAD_USE_CPLUSPLUS_2011/$$. $head 02-11$$ Fix a bug in the optimization of conditional expressions. To be specific, if $cref/NDEBUG/faq/Speed/NDEBUG/$$ is not defined, one could get an assert with the message: $codep Error detected by false result for var_index_ >= NumRes(op_) $$ $head 02-10$$ The change on $cref/2014-12-23/whats_new_14/12-23/$$ introduced a bug when the c++11 version of the error function was used with an $cref/optimized/optimize/$$ function. see $cref/CPPAD_USE_CPLUSPLUS_2011/erf/CPPAD_USE_CPLUSPLUS_2011/$$. There was also a bug in the sparsity calculations for when this erf function was included. These bugs have been fixed. $head 02-09$$ The test $code test_more/optimize.cpp$$ was failing on some systems because an exactly equality check should have been a near equal check. This has been fixed. $head 02-07$$ On some systems, the library corresponding to $code speed/src$$ could not be found. This library is only used for testing and so has been changed to always be static (hence does not need to be found at run time). $head 02-06$$ There was a bug in the coloring method change on $cref/2015-01-07/whats_new_15/01-07/$$. To be specific, $icode%work%.color_method%$$ was not being set to $code "cppad.symmetric"$$ after $icode%work%.color_method.clear()%$$. This has been fixed. $head 02-04$$ $list number$$ Enable the same install of CppAD to be used both with and without C++11 features; e.g., with both $code g++ --std=c++11$$ and with $code g++ --std=c++98$$. Previously if the $cref/cppad_cxx_flags/cmake/cppad_cxx_flags/$$ specified C++11, then it could only be used in that way. $lnext The $cref/cmake command/cmake/CMake Command/$$ now requires the version of $code cmake$$ to be greater than or equal 2.8 (due a bug in $code cmake$$ version 2.6). $lend $head 02-03$$ Improved the searching for the boost multi-threading library which is used for by the $cref team_bthread.cpp$$ case of the $cref thread_test.cpp$$ example and test. $head 02-02$$ Improve the documentation for the $cref/cmake command/cmake/CMake Command/$$ line options $codei% cmake_install_%dir% %$$ for $icode dir$$ equal to $code prefix$$, $code postfix$$, $code includedirs$$, $code libdirs$$, $code datadir$$, and $code docdir$$. $head 01-30$$ Fix bug in $cref link_sparse_hessian$$ speed test introduced on $cref/01-09/whats_new_15/01-09/$$ below. $head 01-29$$ Fix some warnings generated by $code g++ 4.9.2$$. $head 01-26$$ The change of global variables to local in $code cppad/local/op_code.hpp$$ on $cref/2014-50-14/whats_new_14/05-14/$$ created a bug in $cref parallel_ad$$ (some local statics needed to be initialized). This has been fixed. $head 01-23$$ There was a bug in the $cref cmake$$ install detection of compiler features. One symptom of this bug was that on systems that had the $code gettimeofday$$ function, the cmake install would sometimes report $codei% cppad_has_gettimeofday = 0 %$$ This has been fixed. $head 01-21$$ The deprecated $cref auto_tools$$ procedure had a bug in the detection of when the size of an $code unsigned int$$ was the same as the size of a $code size_t$$. This has been fixed. $head 01-20$$ $list number$$ The new $cref compare_change$$ interface has been created and the old $cref CompareChange$$ function has been deprecated; see the $cref compare_change.cpp$$ example. This enables one to determine the source code during taping that corresponds to changes in the comparisons during $cref/zero order forward/forward_zero/$$ operations; see $cref/abort_op_index/Independent/abort_op_index/$$. $lnext This new $cref compare_change$$ interface can detect comparison changes even if $cref/NDEBUG/Faq/Speed/NDEBUG/$$ is defined and even if $cref/f.optimize()/optimize/$$ has been called. The deprecated function $code CompareChange$$ used to always return zero after $codei% %f%.optimize() %$$ and was not even defined when $code NDEBUG$$ was defined. There was a resulting speed effect for this; see the wish list $cref/compare change/wish_list/Comparison Changes and Optimization/$$ entry. $lnext The date when some features where deprecated has been added to the documentation. For example, see $cref/Deprecated 2006-12-17/include_deprecated/Deprecated 2006-12-17/$$. $lend $head 01-09$$ $list number$$ The change 01-07 below included (but did not mention) using a sparse, instead of full, structure for the Hessian in the test. This has also been done for the $cref/sparse Jacobian/link_sparse_jacobian/$$ test. $lnext For both the $cref/sparse_jacobian/link_sparse_jacobian/$$ and $cref/sparse_hessian/link_sparse_hessian/$$ tests, the sparse function is only chosen once (it used to be different for every repeat). This reduced the amount of computation not connected what is being tested. It also make the $cref/onetape/speed_main/option_list/onetape/$$ a valid option for these tests. $lnext There was a bug in the $cref/multiple direction forward/forward_dir/$$ routine. Results for function values that are $cref/parameter/parvar/$$ were not being computed properly (all the derivatives are zero in this case). This has been fixed. $lend $head 01-07$$ The following changes were merged in from the $code color_hes$$ branch: $list number$$ Specify the type of $cref/coloring/sparse_hessian/work/color_method/$$ for the sparse hessian calculations. To be specific, instead of $code "cppad"$$ and $code "colpack"$$, the choices are $code "cppad.symmetric"$$, $code "cppad.general"$$, and $code "colpack.star"$$. This is not compatible with the change on $cref/01-02/whats_new_15/01-02/$$, which was so recent that this should not be a problem. $lnext The $cref/n_sweep/link_sparse_hessian/n_sweep/$$ values were not being returned properly by $cref cppad_sparse_hessian.cpp$$ and $cref adolc_sparse_hessian.cpp$$. The CppAD version has been fixed and the ADOL-C version has been set to zero. $lnext The $cref link_sparse_hessian$$ example case was to sparse for good testing (by mistake). This has been fixed. $lnext Add $icode n_sweep$$ to $cref/link_sparse_hessian/link_sparse_hessian/n_sweep/$$ and $cref/speed_main/speed_main/Speed Results/n_sweep/$$. $lnext Change the $code cppad$$ sparse Hessian $cref/color_method/sparse_hessian/work/color_method/$$ to take advantage of the symmetry of the Hessian (in a similar fashion to the $code colpack$$ coloring method). $lend $head 01-02$$ Added to option to uses $cref/colpack/colpack_prefix/$$ for the sparse Hessian $cref/coloring method/sparse_hessian/work/color_method/$$; see the example $cref colpack_hes.cpp$$. $end cppad-20160000.1/omh/whats_new/whats_new_07.omh0000644000175200017650000006740612656321765020245 0ustar coincoin-web$Id: whats_new_07.omh 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. -------------------------------------------------------------------------- */ $begin whats_new_07$$ $spell 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/license.omh$$. $head 12-25$$ The $cref install$$ instructions have been improved. $head 12-21$$ The $cref/--with-Documentation/auto_tools/--with-Documentation/$$ option on the $code configure$$ command line caused an error on some systems because it attempted to copy to many files. This has been fixed by copying the directory instead of the individual files. $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/auto_tools/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/auto_tools/$$ procedure has been modified so that the one configure flag $code --with-Speed$$ builds all the possible executables related to the speed testing. $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/auto_tools/Configure/$$ script was not executable. This has been fixed. $head 11-02$$ The instructions for downloading the current version using $cref/subversion/download/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 $cref/subversion/download/Subversion/$$ method for downloading CppAD has been added. $pre $$ The installation was broken on some systems because the $cref/configure/auto_tools/Configure/$$ command tried to run the $code autoconf$$ and $code automake$$ programs. This has been fixed by adding $code AM_MAINTAINER_MODE$$ to the $code autoconf$$ input file. $pre $$ Extend the $cref/subversion/download/Subversion/$$ methods to include a full installation and old versions. $head 10-23$$ The $cref/cxx_flags/auto_tools/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/auto_tools/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/auto_tools/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/auto_tools/Configure/$$ command line. In fact, some of the $cref speed$$ tests also had compilation errors when $code BOOST_DIR$$ was include in the configure command. This has been fixed. $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/computed assignment/compute_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/computed assignment/compute_assign/$$ operators has been grouped together. In addition, a computed 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_any.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 $cref/Sparsity/Sparse/$$ calculations. This has been fixed. $head 02-02$$ Fix minor errors and improve $cref/profiling/auto_tools/Profiling CppAD/$$ documentation. Also change the problem sizes used for the $cref speed$$ tests. $head 02-01$$ There seems to be a bug in the cygwin version of g++ version 3.4.4 with the -O2 flag whereby some static variables in static member functions 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 cppad-20160000.1/omh/whats_new/whats_new_08.omh0000644000175200017650000003344012656321765020235 0ustar coincoin-web$Id: whats_new_08.omh 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. -------------------------------------------------------------------------- */ $begin whats_new_08$$ $spell 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/auto_tools/Configure/$$ command to check for extras libraries that are necessary for linking the ipopt example. $head 06-18$$ Add specifications for the Ipopt class $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$. This is only an example class it may change with future 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 computed 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/auto_tools/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 cppad-20160000.1/omh/whats_new/whats_new_09.omh0000644000175200017650000004214312656321765020236 0ustar coincoin-web$Id: whats_new_09.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 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/Sparse/$$ 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/option_list/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/auto_tools/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/auto_tools/$$ 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 cppad-20160000.1/omh/mat_sum_sq_hpp.omh0000644000175200017650000000153712656321765016751 0ustar coincoin-web$Id: mat_sum_sq_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin mat_sum_sq.hpp$$ $spell sq ifndef endif $$ $section Source: mat_sum_sq$$ $mindex source$$ $code # ifndef CPPAD_MAT_SUM_SQ_HPP $pre $$ # define CPPAD_MAT_SUM_SQ_HPP $verbatim%cppad/speed/mat_sum_sq.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/thread_alloc.omh0000644000175200017650000000322112656321765016343 0ustar coincoin-web// $Id: thread_alloc.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin thread_alloc$$ $spell openmp cppad/utility/thread_alloc.hpp CppAD $$ $section A Fast Multi-Threading Memory Allocator$$ $mindex allocation$$ $head Syntax$$ $code # include $$ $head Purpose$$ The C++ $code new$$ and $code 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 $code thread_alloc$$ memory allocator keeps that memory $cref/available/ta_available/$$ for the thread so that it can be re-used without waiting for a lock. All the CppAD memory allocations use this utility. The $cref/free_available/ta_free_available/$$ function should be used to return memory to the system (once it is no longer required by a thread). $head Include$$ The routines in sections below are defined by $code cppad/thread_alloc.hpp$$. This file is included by $code cppad/cppad.hpp$$, but it can also be included separately with out the rest of the $code CppAD$$. $childtable% example/thread_alloc.cpp% cppad/utility/thread_alloc.hpp %$$ $end */ cppad-20160000.1/omh/license.omh0000644000175200017650000000133012656321777015346 0ustar coincoin-web$Id: license.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 License$$ $spell CppAD $$ $section Your License for the CppAD Software$$ $pre $$ $fixed $verbatim%gpl-3.0.txt%$$ $$ $end cppad-20160000.1/omh/mul_level.omh0000644000175200017650000001101212656321765015703 0ustar coincoin-web$Id: mul_level.omh 3735 2015-10-01 13:43:46Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin mul_level$$ $spell Taylor fout const var Cpp Arg $$ $section Using Multiple Levels of AD$$ $head Background$$ If $icode f$$ is an $codei%ADFun<%Base%>%$$ object, the vectors returned by $cref/f.Forward/Forward/$$, and $cref/f.Reverse/Reverse/$$, have values of type $icode Base$$ and not $codei%AD<%Base%>%$$. This reflects the fact that operations used to calculate these function values are not recorded by the tape corresponding to $codei%AD<%Base%>%$$ operations. $head 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 $icode%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: $list number$$ The function defining the differential equation could be calculated using the class $codei AD< AD >$$. $lnext The operations during the calculation of Taylor's method could be done using the $codei AD$$ class. $lnext Derivatives of the solution of the differential equation could then be calculated using the $code double$$ class. $lend $head Procedure$$ $subhead First Start AD$$ If some of the $cref/parameters/glossary/Parameter/$$ in the $codei AD< AD >$$ recording depend on the $cref/variables/glossary/Variable/$$ in the $codei AD$$ recording, we must first declaring these variables; i.e., $codei% Independent(%a1x%) %$$ where $icode a1x$$ is a $cref SimpleVector$$ with elements of type $codei AD$$. This will start recording a new tape of operations performed using $codei AD$$ class objects. $subhead Start AD< AD > Recording$$ The next step is to declare the independent variables using $codei% Independent(%a2x%) %$$ where $icode a2x$$ is a $cref SimpleVector$$ with elements of type $codei AD< AD >$$. This will start recording a new tape of operations performed using $codei AD< AD >$$ class objects. $subhead Inner Function$$ The next step is to calculation the inner function using $codei AD< AD >$$ class objects. We then stop the recording using $codei% %a1f%.Dependent(%a2x%, %a2y%) %$$ where $icode a2y$$ is a $cref SimpleVector$$ with elements of type $codei AD< AD >$$ and $icode a1f$$ is an $codei%ADFun< AD >%$$ object. $subhead Second Start AD< AD >$$ If none of the $cref/parameters/glossary/Parameter/$$ in the $codei AD< AD >$$ recording depend on the $cref/variables/glossary/Variable/$$ in the $codei AD$$ recording, it is preferred to delay declaring these variables to this point; i.e., $codei% Independent(%a1x%) %$$ where $icode a1x$$ is a $cref SimpleVector$$ with elements of type $codei AD$$. This will start recording a new tape of operations performed using $codei AD$$ class objects. $subhead Outer Function$$ The next step is to calculation the outer function using $codei AD$$ class objects. Note that derivatives of the inner function can be included in the calculation of the outer function using $icode a1f$$. We then stop the recording of $codei AD$$ operations using $codei% %g%.Dependent(%a1x%, %a1y%) %$$ where $icode a1y$$ is a $cref SimpleVector$$ with elements of type $codei AD$$ and $icode g$$ is an $codei%ADFun%$$ object. $subhead Derivatives of Outer Function$$ The AD function object $icode g$$ can then be used to calculate the derivatives of the outer function. $children% example/mul_level.cpp% example/change_param.cpp %$$ $head Example$$ The files $cref mul_level.cpp$$ and $cref change_param.cpp$$ contain an examples and tests of this procedure. They return true if they succeed and false otherwise. The file $cref mul_level_ode.cpp$$ is a more complex example use of multiple tapes. $end cppad-20160000.1/omh/example_list.omh0000644000175200017650000001423212656321765016414 0ustar coincoin-web$Id: example_list.omh 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. -------------------------------------------------------------------------- */ $begin General$$ $spell Cpp $$ $section General Examples$$ $mindex realistic$$ $head Description$$ Most of the examples in CppAD are part of the documentation for a specific feature; for example, $cref add.cpp$$ is an example using the $cref/addition operator/ad_binary/$$. The examples list in this section are of a more general nature. $childtable% example/ad_fun.cpp% example/ad_in_c.cpp% example/conj_grad.cpp% cppad/example/cppad_eigen.hpp % example/hes_minor_det.cpp% example/hes_lu_det.cpp% example/interface2c.cpp% example/jac_minor_det.cpp% example/jac_lu_det.cpp% omh/mul_level.omh% example/ode_stiff.cpp% example/mul_level_ode.cpp% example/mul_level_adolc_ode.cpp% example/ode_taylor.cpp% example/stack_machine.cpp %$$ $end ----------------------------------------------------------------------------- $begin ExampleUtility$$ $spell CppAD $$ $section Utility Routines used by CppAD Examples$$ $childtable% example/example.cpp% speed/example/example.cpp% example/lu_vec_ad.cpp %$$ $end ----------------------------------------------------------------------------- $begin ListAllExamples$$ $spell CppAD $$ $section List of All the CppAD Examples$$ $comment omit: TestOne.cpp OneCase.cpp lu_vec_ad.cpp $$ $table $rref a11c_bthread.cpp$$ $rref a11c_openmp.cpp$$ $rref a11c_pthread.cpp$$ $rref abort_recording.cpp$$ $rref Abs.cpp$$ $rref acos.cpp$$ $rref acosh.cpp$$ $rref add.cpp$$ $rref AddEq.cpp$$ $rref ad_assign.cpp$$ $rref ad_ctor.cpp$$ $rref ad_fun.cpp$$ $rref ad_input.cpp$$ $rref ad_in_c.cpp$$ $rref ad_output.cpp$$ $rref asin.cpp$$ $rref asinh.cpp$$ $rref atan.cpp$$ $rref atan2.cpp$$ $rref atanh.cpp$$ $rref atomic_get_started.cpp$$ $rref atomic_hes_sparse.cpp$$ $rref atomic_matrix_mul.hpp$$ $rref atomic_mat_mul.cpp$$ $rref atomic_norm_sq.cpp$$ $rref atomic_reciprocal.cpp$$ $rref atomic_sparsity.cpp$$ $rref atomic_tangent.cpp$$ $rref azmul.cpp$$ $rref base_adolc.hpp$$ $rref base_alloc.hpp$$ $rref base_complex.hpp$$ $rref base_require.cpp$$ $rref bender_quad.cpp$$ $rref bool_fun.cpp$$ $rref bool_sparsity.cpp$$ $rref capacity_order.cpp$$ $rref change_param.cpp$$ $rref checkpoint.cpp$$ $rref check_for_nan.cpp$$ $rref check_numeric_type.cpp$$ $rref check_simple_vector.cpp$$ $rref colpack_hes.cpp$$ $rref colpack_jac.cpp$$ $rref compare.cpp$$ $rref compare_change.cpp$$ $rref complex_poly.cpp$$ $rref cond_exp.cpp$$ $rref conj_grad.cpp$$ $rref cos.cpp$$ $rref cosh.cpp$$ $rref cppad_eigen.hpp$$ $rref cppad_vector.cpp$$ $rref dependency.cpp$$ $rref det_by_lu.cpp$$ $rref det_by_minor.cpp$$ $rref det_of_minor.cpp$$ $rref div.cpp$$ $rref div_eq.cpp$$ $rref eigen_array.cpp$$ $rref eigen_det.cpp$$ $rref eigen_plugin.hpp$$ $rref elapsed_seconds.cpp$$ $rref equal_op_seq.cpp$$ $rref erf.cpp$$ $rref error_handler.cpp$$ $rref example.cpp$$ $rref exp.cpp$$ $rref expm1.cpp$$ $rref expm1.cpp$$ $rref forward.cpp$$ $rref forward_dir.cpp$$ $rref forward_order.cpp$$ $rref for_one.cpp$$ $rref for_sparse_jac.cpp$$ $rref for_two.cpp$$ $rref fun_assign.cpp$$ $rref fun_check.cpp$$ $rref get_started.cpp$$ $rref harmonic.cpp$$ $rref harmonic_time.cpp$$ $rref harmonic_work.cpp$$ $rref hessian.cpp$$ $rref hes_lagrangian.cpp$$ $rref hes_lu_det.cpp$$ $rref hes_minor_det.cpp$$ $rref hes_times_dir.cpp$$ $rref independent.cpp$$ $rref index_sort.cpp$$ $rref integer.cpp$$ $rref interface2c.cpp$$ $rref interp_onetape.cpp$$ $rref interp_retape.cpp$$ $rref ipopt_solve_get_started.cpp$$ $rref ipopt_solve_ode_inverse.cpp$$ $rref ipopt_solve_retape.cpp$$ $rref jacobian.cpp$$ $rref jac_lu_det.cpp$$ $rref jac_minor_det.cpp$$ $rref log.cpp$$ $rref log10.cpp$$ $rref log1p.cpp$$ $rref lu_factor.cpp$$ $rref lu_invert.cpp$$ $rref lu_ratio.cpp$$ $rref lu_solve.cpp$$ $rref lu_vec_ad_ok.cpp$$ $rref mat_sum_sq.cpp$$ $rref mul.cpp$$ $rref multi_newton.cpp$$ $rref multi_newton_time.cpp$$ $rref multi_newton_work.cpp$$ $rref mul_eq.cpp$$ $rref mul_level.cpp$$ $rref mul_level_adolc.cpp$$ $rref mul_level_adolc_ode.cpp$$ $rref mul_level_ode.cpp$$ $rref nan.cpp$$ $rref near_equal.cpp$$ $rref near_equal_ext.cpp$$ $rref number_skip.cpp$$ $rref numeric_type.cpp$$ $rref num_limits.cpp$$ $rref ode_err_control.cpp$$ $rref ode_err_maxabs.cpp$$ $rref ode_evaluate.cpp$$ $rref ode_gear.cpp$$ $rref ode_gear_control.cpp$$ $rref ode_stiff.cpp$$ $rref ode_taylor.cpp$$ $rref optimize.cpp$$ $rref opt_val_hes.cpp$$ $rref par_var.cpp$$ $rref poly.cpp$$ $rref pow.cpp$$ $rref pow_int.cpp$$ $rref print_for_cout.cpp$$ $rref print_for_string.cpp$$ $rref reverse_any.cpp$$ $rref reverse_one.cpp$$ $rref reverse_three.cpp$$ $rref reverse_two.cpp$$ $rref rev_one.cpp$$ $rref rev_sparse_hes.cpp$$ $rref rev_sparse_jac.cpp$$ $rref rev_two.cpp$$ $rref Rombergmul.cpp$$ $rref romberg_one.cpp$$ $rref rosen_34.cpp$$ $rref runge45_1.cpp$$ $rref runge45_2.cpp$$ $rref seq_property.cpp$$ $rref simple_ad_bthread.cpp$$ $rref simple_ad_openmp.cpp$$ $rref simple_ad_pthread.cpp$$ $rref simple_vector.cpp$$ $rref sin.cpp$$ $rref sinh.cpp$$ $rref sparse_hessian.cpp$$ $rref sparse_hes_fun.cpp$$ $rref sparse_jacobian.cpp$$ $rref sparse_jac_fun.cpp$$ $rref sparse_sub_hes.cpp$$ $rref sparsity_sub.cpp$$ $rref speed_example.cpp$$ $rref speed_program.cpp$$ $rref speed_test.cpp$$ $rref sqrt.cpp$$ $rref stack_machine.cpp$$ $rref sub.cpp$$ $rref sub_eq.cpp$$ $rref sub_sparse_hes.cpp$$ $rref tan.cpp$$ $rref tanh.cpp$$ $rref tape_index.cpp$$ $rref team_bthread.cpp$$ $rref team_example.cpp$$ $rref team_openmp.cpp$$ $rref team_pthread.cpp$$ $rref team_thread.hpp$$ $rref thread_alloc.cpp$$ $rref thread_test.cpp$$ $rref time_test.cpp$$ $rref to_string.cpp$$ $rref unary_minus.cpp$$ $rref unary_plus.cpp$$ $rref value.cpp$$ $rref var2par.cpp$$ $rref vector_bool.cpp$$ $rref vec_ad.cpp$$ $tend $end cppad-20160000.1/omh/uniform_01_hpp.omh0000644000175200017650000000154712656321765016561 0ustar coincoin-web$Id: uniform_01_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin uniform_01.hpp$$ $spell uniform_01 ifndef endif $$ $section Source: uniform_01$$ $mindex source$$ $code # ifndef CPPAD_UNIFORM_01_HPP $pre $$ # define CPPAD_UNIFORM_01_HPP $verbatim%cppad/speed/uniform_01.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/reverse/0002755000175200017650000000000012656321765014674 5ustar coincoin-webcppad-20160000.1/omh/reverse/reverse_any.omh0000644000175200017650000001407312656321765017726 0ustar coincoin-web// $Id: reverse_any.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin reverse_any$$ $spell 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 $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$$. To be specific, it computes the derivative $latex W^{(1)} (u)$$ at $latex u = x$$ which is specified by the following notation: $head Notation$$ $subhead u^(k)$$ For $latex k = 0, \ldots , q-1$$, the vector $latex u^{(k)} \in B^n$$ is defined as the value of $icode x_k$$ in the previous calls of the form $codei% %f%.Forward(%k%, %x_k%) %$$ If there is no previous call with $latex k = 0$$, $latex u^{(0)}$$ is the value of the independent variables when the corresponding AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ was recorded. $subhead X(t, u)$$ The function $latex X : B \times B^{n \times q} \rightarrow B^n$$ is defined by $latex \[ X ( t , u ) = u^{(0)} + u^{(1)} * t + \cdots + u^{(q-1)} * t^{q-1} \] $$ 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) \] $$ $subhead Y(t, u)$$ The function $latex Y : B \times B^{n \times q} \rightarrow B^m$$ is defined by $latex \[ 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 ] \] $$ 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} \end{array} \right. \] $$ $subhead W(u)$$ The function $latex W : B^{n \times q} \rightarrow B$$ is defined by $latex \[ W(u) = \sum_{k=0}^{q-1} ( w^{(k)} )^\R{T} \frac{1}{k !} \Dpow{k}{t} Y(0, u) \] $$ $head f$$ The object $icode f$$ has prototype $codei% const ADFun<%Base%> %f% %$$ Before this call to $code Reverse$$, the value returned by $codei% %f%.size_order() %$$ must be greater than or equal $icode q$$ (see $cref size_order$$). $head q$$ The argument $icode q$$ has prototype $codei% size_t %q% %$$ and specifies the number of Taylor coefficient orders to be differentiated (for each variable). $head w$$ The argument $icode w$$ has prototype $codei% const %Vector% &%w% %$$ (see $cref/Vector/reverse_any/Vector/$$ below) and its size must be equal to $icode m$$ or $icode%m% * %q%$$, It specifies the weighting vector $icode w$$ in the definition of $cref/W(u)/reverse_any/Notation/W(u)/$$. $head dw$$ The return value $icode dw$$ has prototype $codei% %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} \] $$ where $latex u = x$$ is value of the Taylor coefficients where the derivative is evaluated. $pre $$ If the argument $icode w$$ has size $icode m$$, $latex \[ dw[ j * q + q - k - 1 ] = W^{(1)} ( x )_{j,k} \] $$ where $latex u = x$$ is value of the Taylor coefficients where the derivative is evaluated. Note the reverse order in which the order indices are stored. This is an unfortunate consequence of keeping $code Reverse$$ backward compatible. $head First Order$$ We consider the case where $icode%q% = 1%$$ and $icode%w%.size() == %m%$$. In this case $latex \[ \begin{array}{rcl} W(u) & = & w_0 Y_0 (0, u) + \cdots + w_m Y_m (0, u) \\ W(u) & = & w_0 F_0 [ X(0, u) ] + \cdots + w_m F_m [ X(0, u) ] \\ W^{(1)} (x) & = & w_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$$. $head Second Order$$ We consider the case where $icode%q% = 2%$$ and $icode%w%.size() == %m%$$. In this case $latex \[ \begin{array}{rcl} W(u) & = & w_0 \partial_t Y_0 (0, u) + \cdots + w_m \partial_t Y_m (0, u) \\ W(u) & = & w_0 \partial_t \{ F_0 [ X(t, u) ] \}_{t = 0} + \cdots + 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)} \\ \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)} ) \\ \partial_{u(1)} W(x) & = & w_0 F_0^{(1)} ( x^{(0)} ) + \cdots + w_m F_m^{(1)} ( x^{(0)} ) \end{array} \] $$ where $latex \partial{u(0)} $$ denotes partial with respect to $latex u^{(0)}$$. These are the same as the result documented in $cref reverse_two$$. $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 Example$$ $children% example/reverse_three.cpp% example/reverse_any.cpp %$$ $list number$$ The file $cref reverse_three.cpp$$ contains an example and test of using reverse mode to compute third order derivatives. $lnext The file $cref reverse_any.cpp$$ contains an example and test of the general reverse mode case. $lend $end cppad-20160000.1/omh/reverse/reverse_two.omh0000644000175200017650000001151112656321765017742 0ustar coincoin-web// $Id: reverse_two.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin reverse_two$$ $section Second Order Reverse Mode$$ $mindex derivative$$ $spell taylor const dw $$ $head Syntax$$ $icode%dw% = %f%.Reverse(2, %w%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^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 x^(k)$$ For $latex k = 0, 1$$, the vector $latex x^{(k)} \in B^n$$ is defined as the value of $icode x_k$$ in the previous call (counting this call) of the form $codei% %f%.Forward(%k%, %x_k%) %$$ If there is no previous call with $latex k = 0$$, $latex x^{(0)}$$ is the value of the independent variables when the corresponding AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$ was recorded. $head W$$ The functions $latex W_0 : B^n \rightarrow B$$ and $latex W_1 : B^n \rightarrow B$$ are defined by $latex \[ \begin{array}{rcl} W_0 ( u ) & = & w_0 * F_0 ( u ) + \cdots + w_{m-1} * F_{m-1} (u) \\ W_1 ( u ) & = & w_0 * F_0^{(1)} ( u ) * x^{(1)} + \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_1^{(1)} (u) & = & w_0 * \left( x^{(1)} \right)^\R{T} * F_0^{(2)} ( u ) + \cdots + w_{m-1} * \left( x^{(1)} \right)^\R{T} F_{m-1}^{(2)} (u) \end{array} \] $$ at $latex u = x^{(0)}$$. $head f$$ The object $icode f$$ has prototype $codei% const ADFun<%Base%> %f% %$$ Before this call to $code Reverse$$, the value returned by $codei% %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% %$$ (see $cref/Vector/reverse_two/Vector/$$ below) and its size must be equal to $icode m$$, the dimension of the $cref/range/seq_property/Range/$$ space for $icode f$$. $head dw$$ The result $icode dw$$ has prototype $codei% %Vector% %dw% %$$ (see $cref/Vector/reverse_two/Vector/$$ below). It contains both the derivative $latex W^{(1)} (x)$$ and the derivative $latex U^{(1)} (x)$$. The size of $icode dw$$ is equal to $latex n \times 2$$, where $latex n$$ is the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. $subhead First Order Partials$$ For $latex j = 0 , \ldots , n - 1$$, $latex \[ dw [ j * 2 + 0 ] = \D{ W_0 }{ u_j } \left( x^{(0)} \right) = w_0 * \D{ F_0 }{ u_j } \left( x^{(0)} \right) + \cdots + w_{m-1} * \D{ F_{m-1} }{ u_j } \left( x^{(0)} \right) \] $$ This part of $icode dw$$ contains the same values as are returned by $cref reverse_one$$. $subhead Second Order Partials$$ For $latex j = 0 , \ldots , n - 1$$, $latex \[ dw [ j * 2 + 1 ] = \D{ W_1 }{ u_j } \left( x^{(0)} \right) = \sum_{\ell=0}^{n-1} x_\ell^{(1)} \left[ w_0 * \DD{ F_0 }{ u_\ell }{ u_j } \left( x^{(0)} \right) + \cdots + w_{m-1} * \DD{ F_{m-1} }{ u_\ell }{ u_j } \left( x^{(0)} \right) \right] \] $$ $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 Times Direction$$ Suppose that $latex w$$ is the $th i$$ elementary vector. It follows that for $latex j = 0, \ldots, n-1$$ $latex \[ \begin{array}{rcl} dw[ j * 2 + 1 ] & = & w_i \sum_{\ell=0}^{n-1} \DD{F_i}{ u_j }{ u_\ell } \left( x^{(0)} \right) x_\ell^{(1)} \\ & = & \left[ F_i^{(2)} \left( x^{(0)} \right) * x^{(1)} \right]_j \end{array} \] $$ Thus the vector $latex ( dw[1], dw[3], \ldots , dw[ n * q - 1 ] )$$ is equal to the Hessian of $latex F_i (x)$$ times the direction $latex x^{(1)}$$. In the special case where $latex x^{(1)}$$ is the $th l$$ $cref/elementary vector/glossary/Elementary Vector/$$, $latex \[ dw[ j * 2 + 1 ] = \DD{ F_i }{ x_j }{ x_\ell } \left( x^{(0)} \right) \] $$ $head Example$$ $children% example/reverse_two.cpp% example/hes_times_dir.cpp %$$ The files $cref reverse_two.cpp$$ and $cref hes_times_dir.cpp$$ contain a examples and tests of reverse mode calculations. They return true if they succeed and false otherwise. $end cppad-20160000.1/omh/reverse/reverse.omh0000644000175200017650000000217412656321765017056 0ustar coincoin-web// $Id: reverse.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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$$ $spell xq $$ $section Reverse Mode$$ $head Multiple Directions$$ Reverse mode after $cref/Forward(q, r, xq)/forward_dir/$$ with number of directions $icode%r% != 1%$$ is not yet supported. There is one exception, $cref 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). $childtable% omh/reverse/reverse_one.omh% omh/reverse/reverse_two.omh% omh/reverse/reverse_any.omh %$$ $end cppad-20160000.1/omh/reverse/reverse_one.omh0000644000175200017650000000561612656321765017723 0ustar coincoin-web// $Id: reverse_one.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin reverse_one$$ $section First Order Reverse Mode$$ $mindex derivative$$ $spell taylor const dw $$ $head Syntax$$ $icode%dw% = %f%.Reverse(1, %w%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The function $latex W : B^n \rightarrow B$$ is defined by $latex \[ W(x) = w_0 * F_0 ( x ) + \cdots + w_{m-1} * F_{m-1} (x) \] $$ The result of this operation is the derivative $latex dw = W^{(1)} (x)$$; i.e., $latex \[ dw = w_0 * F_0^{(1)} ( x ) + \cdots + w_{m-1} * F_{m-1}^{(1)} (x) \] $$ Note that if $latex w$$ is the $th i$$ $cref/elementary vector/glossary/Elementary Vector/$$, $latex dw = F_i^{(1)} (x)$$. $head f$$ The object $icode f$$ has prototype $codei% const ADFun<%Base%> %f% %$$ Before this call to $code Reverse$$, the value returned by $codei% %f%.size_order() %$$ must be greater than or equal one (see $cref size_order$$). $head x$$ The vector $icode x$$ in expression for $icode dw$$ above corresponds to the previous call to $cref forward_zero$$ using this ADFun object $icode f$$; i.e., $codei% %f%.Forward(0, %x%) %$$ If there is no previous call with the first argument zero, the value of the $cref/independent/Independent/$$ variables during the recording of the AD sequence of operations is used for $icode x$$. $head w$$ The argument $icode w$$ has prototype $codei% const %Vector% &%w% %$$ (see $cref/Vector/reverse_one/Vector/$$ below) and its size must be equal to $icode m$$, the dimension of the $cref/range/seq_property/Range/$$ space for $icode f$$. $head dw$$ The result $icode dw$$ has prototype $codei% %Vector% %dw% %$$ (see $cref/Vector/reverse_one/Vector/$$ below) and its value is the derivative $latex W^{(1)} (x)$$. The size of $icode dw$$ is equal to $icode n$$, the dimension of the $cref/domain/seq_property/Domain/$$ space for $icode f$$. $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 Example$$ $children% example/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 cppad-20160000.1/omh/poly_hpp.omh0000644000175200017650000000147512656321765015565 0ustar coincoin-web$Id: poly_hpp.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin poly.hpp$$ $spell Lu ifndef endif $$ $section Source: Poly$$ $mindex source$$ $code # ifndef CPPAD_POLY_HPP $pre $$ # define CPPAD_POLY_HPP $verbatim%cppad/utility/poly.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/omh/example.omh0000644000175200017650000000300512656321765015355 0ustar coincoin-web$Id: example.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin Example$$ $spell CppAD Cygwin Microsoft chdir nmake mak Workspace dsw exe Example example $$ $section Examples$$ $head Introduction$$ This section organizes the information related to the CppAD examples. Each CppAD operation has its own specific example, for example $cref add.cpp$$ is an example for $cref/addition/ad_binary/$$. 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. $head Running Examples$$ The $cref/installation instructions/Install/$$ show how the examples can be run on your system. $head The CppAD Test Vector Template Class$$ Many of the examples use the $small $cref/CPPAD_TESTVECTOR/testvector/$$ $$ preprocessor symbol to determine which $cref SimpleVector$$ template class is used with the examples. $contents% omh/example_list.omh% cppad/local/testvector.hpp %$$ $end cppad-20160000.1/omh/bib.omh0000644000175200017650000000276112656321765014466 0ustar coincoin-web$Id: bib.omh 3785 2016-02-08 12:53:06Z 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. A copy of 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 Bib$$ $spell ed Bjarne Stroustrup Saul Griewank Andreas Vetterling Flannery Teukolsky Abramowitz Stegun Shampine Rosenbrock $$ $section Bibliography$$ $head Abramowitz and Stegun$$ Handbook of Mathematical Functions, Dover, New York. $head The C++ Programming Language$$ Bjarne Stroustrup, The C++ Programming Language, Special ed., AT&T, 2000 $head Evaluating Derivatives$$ Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation, Andreas Griewank, SIAM, Philadelphia, 2000 $head 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 $head Shampine, L.F.$$ Implementation of Rosenbrock Methods, ACM Transactions on Mathematical Software, Vol. 8, No. 2, June 1982. $end cppad-20160000.1/omh/ode_evaluate.omh0000644000175200017650000000154312656321765016364 0ustar coincoin-web$Id: ode_evaluate.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin ode_evaluate.hpp$$ $spell ifndef endif $$ $section Source: ode_evaluate$$ $mindex source$$ $code # ifndef CPPAD_ODE_EVALUATE_HPP $pre $$ # define CPPAD_ODE_EVALUATE_HPP $verbatim%cppad/speed/ode_evaluate.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ $end cppad-20160000.1/ChangeLog0000644000175200017650000000037111210357004014163 0ustar coincoin-web* 2008-08-26 Brad Bell - A developers ChangeLog can be found in the svn log; e.g., - https://projects.coin-or.org/CppAD/timeline - A user's ChangeLog is located at -- http://www.coin-or.org/CppAD/Doc/whats_new.htm cppad-20160000.1/cppad/0002755000175200017650000000000012656321766013526 5ustar coincoin-webcppad-20160000.1/cppad/base_require.hpp0000644000175200017650000001056612656321765016712 0ustar coincoin-web// $Id: base_require.hpp 3768 2015-12-28 18:58:35Z bradbell $ # ifndef CPPAD_BASE_REQUIRE_HPP # define CPPAD_BASE_REQUIRE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin base_require$$ $spell azmul ostream alloc eps std Lt Le Eq Ge Gt cppad.hpp namespace optimizations bool const CppAD enum Lt Le Eq Ge Gt 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$$. $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 $codep */ # define CPPAD_AZMUL(Base) \ inline Base azmul(const Base& x, const Base& y) \ { Base zero(0.0); \ if( x == zero ) \ return zero; \ return x * y; \ } /* $$ $childtable% omh/base_require/base_member.omh% cppad/local/base_cond_exp.hpp% omh/base_require/base_identical.omh% omh/base_require/base_ordered.omh% cppad/local/base_std_math.hpp% cppad/local/base_limits.hpp% cppad/local/base_to_string.hpp% omh/base_require/base_example.omh %$$ $end */ // definitions that must come before base implementations # include # include # include # include // grouping documentation by feature # 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 cppad-20160000.1/cppad/configure.hpp.in0000644000175200017650000001404012656321765016621 0ustar coincoin-web// $Id: configure.hpp.in 3760 2015-12-01 04:12:28Z bradbell $ # ifndef CPPAD_CONFIGURE_HPP # define CPPAD_CONFIGURE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin configure$$ $spell CppAD $$ $section Configuration Preprocessor Symbols Used by CppAD$$ $head Preprocessor Symbols$$ All of the preprocessor symbols used by CppAD begin with $code CPPAD_$$ (there are some deprecated symbols that begin with $code CppAD$$). $end */ /*! \file configure.hpp Replacement for config.h so that all preprocessor symbols begin with CPPAD_ */ /*! \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_COLPACK Was a colpack_prefix specified on the cmake command line. */ # define CPPAD_HAS_COLPACK @cppad_has_colpack@ /*! def CPPAD_INTERNAL_SPARSE_SET is the internal representation used for sparse vectors of std::set either sparse_set or sparse_list). */ # define CPPAD_INTERNAL_SPARSE_SET @cppad_internal_sparse_set@ /*! \def CPPAD_DEPRECATED If this symbol is one, an implicit constor of AD is defined where the argument has any type. Otherwise this constructor is explicit. */ # define CPPAD_DEPRECATED @cppad_deprecated@ /*! \def CPPAD_BOOSTVECTOR If this symbol is one, and _MSC_VER is not defined, we are using boost vector for CPPAD_TESTVECTOR. It this symbol is zero, 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_SIZE_T_NOT_UNSIGNED_INT If this symbol is zero, the type size_t is the same as the type unsigned int, otherwise this symbol is one. */ # define CPPAD_SIZE_T_NOT_UNSIGNED_INT @cppad_size_t_not_unsigned_int@ /*! \def CPPAD_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 \c std::numeric_limits, the \c <= operator, and conversion to \c size_t. Make sure that the type chosen returns true for is_pod in pod_vector.hpp. This type is later defined as \c 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 \c std::numeric_limits, the \c <= operator, and conversion to \c size_t. Make sure that the type chosen returns true for is_pod in pod_vector.hpp. This type is later defined as \c tape_id_t in the CppAD namespace. */ # define CPPAD_TAPE_ID_TYPE @cppad_tape_id_type@ /*! \def CPPAD_MAX_NUM_THREADS Specifies the maximum number of threads that CppAD can support (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 cppad-20160000.1/cppad/CMakeLists.txt0000644000175200017650000002427712656321765016277 0ustar coincoin-web# $Id: CMakeLists.txt 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. # ----------------------------------------------------------------------------- # Build the cppad/configure.hpp file. # Inherit environment from ../CMakeLists.txt # ----------------------------------------------------------------------------- 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 ) MESSAGE(STATUS "${output_variable} = ${${output_variable}}" ) ENDMACRO(check_match) # ----------------------------------------------------------------------------- # command line arguments # # cppad_testvector command_line_arg(cppad_testvector cppad STRING "Namespace of vector used for testing, one of: boost, cppad, eigen, std" ) # # cppad_max_num_threads command_line_arg(cppad_max_num_threads 48 STRING "maximum number of threads that CppAD can use use" ) # cppad_sparse_list command_line_arg(cppad_sparse_list YES BOOL "use sparse list for internal sparse set representation" ) # # cppad_tape_id_type command_line_arg(cppad_tape_id_type "unsigned int" STRING "type used to identify different tapes, size must be <= sizeof(size_t)" ) # # cppad_tape_addr_type command_line_arg(cppad_tape_addr_type "unsigned int" STRING "type used to identify variables on one tape, size must be <= sizeof(size_t)" ) # # cppad_deprecated command_line_arg(cppad_deprecated NO BOOL "implicit (instead of explicit) conversion from any type to AD" ) # ----------------------------------------------------------------------------- # cppad_deprecated IF( cppad_deprecated ) SET(cppad_deprecated 1) ELSE( cppad_deprecated ) SET(cppad_deprecated 0) ENDIF( cppad_deprecated ) # ----------------------------------------------------------------------------- # cppad_internal_sparse_set # IF( cppad_sparse_list ) SET(cppad_internal_sparse_set sparse_list ) ELSE( cppad_sparse_list ) SET(cppad_internal_sparse_set sparse_set ) ENDIF( cppad_sparse_list ) MESSAGE(STATUS "cppad_internal_sparse_set = ${cppad_internal_sparse_set}" ) # # ----------------------------------------------------------------------------- # 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_cstdint_8_to_64 # SET(source " # include template inline bool is_pod(void) { return false; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } int main(void) { return 0; } " ) check_source_runs("${source}" cppad_has_cstdint_8_to_64) IF( NOT cppad_has_cstdint_8_to_64 ) SET(cppad_cplusplus_201100_ok 0) ENDIF( NOT cppad_has_cstdint_8_to_64 ) # ----------------------------------------------------------------------------- # cppad_compiler_has_erf # cppad_compiler_has_asinh # cppad_compiler_has_acosh # cppad_compiler_has_atanh # cppad_compiler_has_expm1 # SET(source_template " # include int main(void) { std::c11_function(0.0); return 0; } " ) 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_high_resolution_clock # SET(source " # include int main(void) { std::chrono::time_point start, end; start = std::chrono::high_resolution_clock::now(); end = std::chrono::high_resolution_clock::now(); std::chrono::duration difference = end - start; double elapsed_seconds = difference.count(); if( elapsed_seconds > 0.0 ) return 0; return 1; } " ) check_source_runs("${source}" cppad_has_high_resolution_clock) IF( NOT cppad_has_high_resolution_clock ) SET(cppad_cplusplus_201100_ok 0) ENDIF( NOT cppad_has_high_resolution_clock ) # ============================================================================= # End C++11 features # MESSAGE(STATUS "cppad_cplusplus_201100_ok = ${cppad_cplusplus_201100_ok}") # ----------------------------------------------------------------------------- # cppad_has_gettimeofday # SET(source " # include int main(void) { struct timeval time; gettimeofday(&time, 0); return 0; }" ) check_source_runs("${source}" cppad_has_gettimeofday) # ----------------------------------------------------------------------------- # cppad_size_t_not_unsigned_int # SET(source " # include template inline bool is_pod(void) { return false; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } int main(void) { return 0; } " ) check_source_runs("${source}" cppad_size_t_not_unsigned_int) # ----------------------------------------------------------------------------- # 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 ) # ----------------------------------------------------------------------------- # Copy a file to another location and modify its contents. # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/configure.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/configure.hpp ) cppad-20160000.1/cppad/cppad.hpp0000644000175200017650000000522512656321765015327 0ustar coincoin-web// $Id: cppad.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_CPPAD_HPP # define CPPAD_CPPAD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /*! \file 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 cppad-20160000.1/cppad/deprecated/0002755000175200017650000000000012656321766015626 5ustar coincoin-webcppad-20160000.1/cppad/deprecated/time_test.hpp0000644000175200017650000000003612656321765020330 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/Rosen34.h0000644000175200017650000000003612656321765017230 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/speed_test.hpp0000644000175200017650000000003612656321765020472 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/SpeedTest.h0000644000175200017650000000003612656321765017673 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/check_numeric_type.hpp0000644000175200017650000000003612656321765022173 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/track_new_del.hpp0000644000175200017650000000003612656321765021134 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/vector.hpp0000644000175200017650000000003612656321765017635 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/TrackNewDel.h0000644000175200017650000000003612656321765020136 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/OdeGear.h0000644000175200017650000000003612656321765017301 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/CppAD_vector.h0000644000175200017650000000003612656321765020304 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/CheckSimpleVector.h0000644000175200017650000000003612656321765021345 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/romberg_mul.hpp0000644000175200017650000000003612656321765020645 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/RombergMul.h0000644000175200017650000000003612656321765020046 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/near_equal.hpp0000644000175200017650000000003612656321765020447 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/NearEqual.h0000644000175200017650000000003612656321765017650 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/ode_err_control.hpp0000644000175200017650000000003612656321765021512 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/pow_int.hpp0000644000175200017650000000003612656321766020013 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/PowInt.h0000644000175200017650000000003612656321766017214 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/lu_solve.hpp0000644000175200017650000000003612656321766020164 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/Runge45.h0000644000175200017650000000003612656321766017225 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/rosen_34.hpp0000644000175200017650000000003612656321766017770 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/romberg_one.hpp0000644000175200017650000000003612656321766020632 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/RombergOne.h0000644000175200017650000000003612656321766020033 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/CheckNumericType.h0000644000175200017650000000003612656321766021176 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/memory_leak.hpp0000644000175200017650000000003612656321766020640 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/ode_gear.hpp0000644000175200017650000000003612656321766020101 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/omp_alloc.hpp0000644000175200017650000000003612656321766020301 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/ode_gear_control.hpp0000644000175200017650000000003612656321766021641 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/lu_invert.hpp0000644000175200017650000000003612656321766020343 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/OdeGearControl.h0000644000175200017650000000003612656321766020643 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/check_simple_vector.hpp0000644000175200017650000000003612656321766022344 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/LuInvert.h0000644000175200017650000000003612656321766017544 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/nan.hpp0000644000175200017650000000003612656321766017110 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/lu_factor.hpp0000644000175200017650000000003612656321766020312 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/index_sort.hpp0000644000175200017650000000003612656321766020512 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/LuFactor.h0000644000175200017650000000003612656321766017513 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/OdeErrControl.h0000644000175200017650000000003612656321766020515 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/thread_alloc.hpp0000644000175200017650000000003612656321766020755 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/Poly.h0000644000175200017650000000003612656321766016717 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/poly.hpp0000644000175200017650000000003612656321766017317 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/error_handler.hpp0000644000175200017650000000003612656321766021162 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/CppAD.h0000644000175200017650000000003612656321766016723 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/ErrorHandler.h0000644000175200017650000000003612656321766020363 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/runge_45.hpp0000644000175200017650000000003612656321766017764 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/LuSolve.h0000644000175200017650000000003612656321766017365 0ustar coincoin-web# include cppad-20160000.1/cppad/deprecated/elapsed_seconds.hpp0000644000175200017650000000003612656321766021467 0ustar coincoin-web# include cppad-20160000.1/cppad/speed/0002755000175200017650000000000012656321766014626 5ustar coincoin-webcppad-20160000.1/cppad/speed/ode_evaluate.hpp0000644000175200017650000001401512656321766017773 0ustar coincoin-web// $Id: ode_evaluate.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ODE_EVALUATE_HPP # define CPPAD_ODE_EVALUATE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ode_evaluate$$ $spell Runge fabs retaped Jacobian const Cpp cppad hpp fp namespace exp $$ $section Evaluate a Function Defined in Terms of an ODE$$ $mindex ode_evaluate$$ $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). It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. $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 and n-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$$. It returns true if it succeeds and false otherwise. $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 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 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); } } } } // END C++ # endif cppad-20160000.1/cppad/speed/det_grad_33.hpp0000644000175200017650000000663712656321766017427 0ustar coincoin-web// $Id: det_grad_33.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DET_GRAD_33_HPP # define CPPAD_DET_GRAD_33_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin det_grad_33$$ $spell cppad CppAD det cppad.hpp namespace const bool $$ $section Check Gradient of Determinant of 3 by 3 matrix$$ $mindex det_grad_33 correct$$ $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). It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. $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 cppad-20160000.1/cppad/speed/uniform_01.hpp0000644000175200017650000000517512656321766017324 0ustar coincoin-web// $Id: uniform_01.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_UNIFORM_01_HPP # define CPPAD_UNIFORM_01_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin uniform_01$$ $spell CppAD cppad.hpp namespace $$ $section Simulate a [0,1] Uniform Random Variate$$ $mindex uniform_01$$ $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). It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. $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 cppad-20160000.1/cppad/speed/det_33.hpp0000644000175200017650000000561612656321766016426 0ustar coincoin-web// $Id: det_33.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DET_33_HPP # define CPPAD_DET_33_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin det_33$$ $spell cppad CppAD det cppad.hpp namespace const bool $$ $section Check Determinant of 3 by 3 matrix$$ $mindex det_33 correct$$ $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). It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. $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; // 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], 1e-10, 1e-10); return ok; } } // END C++ # endif cppad-20160000.1/cppad/speed/sparse_jac_fun.hpp0000644000175200017650000001346712656321766020332 0ustar coincoin-web// $Id: sparse_jac_fun.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_JAC_FUN_HPP # define CPPAD_SPARSE_JAC_FUN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sparse_jac_fun$$ $spell Jacobian jac cppad hpp fp CppAD namespace const bool exp arg $$ $section Evaluate a Function That Has a Sparse Jacobian$$ $mindex sparse_jac_fun$$ $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). It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. $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 row$$ 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 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$$. It returns true if it succeeds and false otherwise. $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 cppad-20160000.1/cppad/speed/det_of_minor.hpp0000644000175200017650000001633112656321766020005 0ustar coincoin-web// $Id: det_of_minor.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DET_OF_MINOR_HPP # define CPPAD_DET_OF_MINOR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin det_of_minor$$ $spell CppAD cppad.hpp hpp std Det const namespace $$ $section Determinant of a Minor$$ $mindex det_of_minor matrix$$ $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). It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. $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$$. It returns true if it succeeds and false otherwise. $head Source Code$$ The file $cref det_of_minor.hpp$$ contains the source for this template function. $end --------------------------------------------------------------------------- */ // BEGIN C++ namespace CppAD { // BEGIN CppAD namespace template Scalar det_of_minor( const std::vector& a , size_t m , size_t n , std::vector& r , 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 representaion 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 cppad-20160000.1/cppad/speed/sparse_hes_fun.hpp0000644000175200017650000001561612656321766020352 0ustar coincoin-web// $Id: sparse_hes_fun.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_HES_FUN_HPP # define CPPAD_SPARSE_HES_FUN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sparse_hes_fun$$ $spell hes cppad hpp fp CppAD namespace const bool exp arg $$ $section Evaluate a Function That Has a Sparse Hessian$$ $mindex sparse_hes_fun$$ $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). It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. $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$$. It returns true if it succeeds and false otherwise. $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 cppad-20160000.1/cppad/speed/det_by_lu.hpp0000644000175200017650000001067112656321766017310 0ustar coincoin-web// $Id: det_by_lu.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DET_BY_LU_HPP # define CPPAD_DET_BY_LU_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin det_by_lu$$ $spell CppAD cppad lu hpp typedef const hpp Det CPPAD_TESTVECTOR namespace $$ $section Determinant Using Expansion by Lu Factorization$$ $mindex det_by_lu factor$$ $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). It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. $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$$. It returns true if it succeeds and false otherwise. $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 { // The AD complex case is used by examples by not used by speed tests // Must define a specializatgion of LeqZero,AbsGeq for the ADComplex case typedef std::complex Complex; typedef CppAD::AD ADComplex; CPPAD_BOOL_UNARY(Complex, LeqZero ) CPPAD_BOOL_BINARY(Complex, AbsGeq ) template class det_by_lu { private: const size_t m_; const size_t n_; CPPAD_TESTVECTOR(Scalar) A_; CPPAD_TESTVECTOR(Scalar) B_; CPPAD_TESTVECTOR(Scalar) X_; public: det_by_lu(size_t n) : m_(0), n_(n), A_(n * n) { } template inline Scalar operator()(const Vector &x) { using CppAD::exp; 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 cppad-20160000.1/cppad/speed/mat_sum_sq.hpp0000644000175200017650000000704612656321766017514 0ustar coincoin-web// $Id: mat_sum_sq.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_MAT_SUM_SQ_HPP # define CPPAD_MAT_SUM_SQ_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin mat_sum_sq$$ $spell sq namespace const CppAD sq cppad.hpp $$ $section Sum Elements of a Matrix Times Itself$$ $mindex mat_sum_sq multiply speed test$$ $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). It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. $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$$. It returns true if it succeeds and false otherwise. $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 cppad-20160000.1/cppad/speed/det_by_minor.hpp0000644000175200017650000000761312656321766020016 0ustar coincoin-web// $Id: det_by_minor.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DET_BY_MINOR_HPP # define CPPAD_DET_BY_MINOR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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). It is only intended for example and testing purposes, so it is not automatically included by $cref/cppad.hpp/cppad/$$. $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$$. It returns true if it succeeds and false otherwise. $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 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 // END C++ # endif cppad-20160000.1/cppad/utility/0002755000175200017650000000000012656321766015231 5ustar coincoin-webcppad-20160000.1/cppad/utility/error_handler.hpp0000644000175200017650000001422512656321766020572 0ustar coincoin-web// $Id: error_handler.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_ERROR_HANDLER_HPP # define CPPAD_ERROR_HANDLER_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ErrorHandler$$ $spell cppad.hpp CppAD exp bool const $$ $section Replacing the CppAD Error Handler$$ $mindex replace assert exception ErrorHandler$$ $head Syntax$$ $codei%# include %$$ $codei%ErrorHandler %info%(%handler%) %$$ $codei%ErrorHandler::Call(%known%, %line%, %file%, %exp%, %msg%) %$$ $head Constructor$$ When you construct a $code ErrorHandler$$ object, the current CppAD error handler is replaced by $icode handler$$. When the object is destructed, the previous CppAD error handler is restored. $subhead Parallel Mode$$ The $code ErrorHandler$$ constructor and destructor cannot be called in $cref/parallel/ta_in_parallel/$$ execution mode. Furthermore, this rule is not abided by, a raw C++ $code assert$$, instead of one that uses this error handler, will be generated. $head Call$$ When $code ErrorHandler::Call$$ is called, the current CppAD error handler is used to report an error. This starts out as a default error handler and can be replaced using the $code ErrorHandler$$ constructor. $head info$$ The object $icode info$$ is used to store information that is necessary to restore the previous CppAD error handler. This is done when the destructor for $icode info$$ is called. $head handler$$ The argument $icode handler$$ has prototype $codei% void (*%handler%) (bool, int, const char *, const char *, const char *); %$$ When an error is detected, it is called with the syntax $codei% %handler% (%known%, %line%, %file%, %exp%, %msg%) %$$ This routine should not return; i.e., upon detection of the error, the routine calling $icode handler$$ does not know how to proceed. $head known$$ The $icode handler$$ argument $icode known$$ has prototype $codei% bool %known% %$$ If it is true, the error being reported is from a know problem. $head line$$ The $icode handler$$ argument $icode line$$ has prototype $codei% int %line% %$$ It reports the source code line number where the error is detected. $head file$$ The $icode handler$$ argument $icode file$$ has prototype $codei% const char *%file% %$$ and is a $code '\0'$$ terminated character vector. It reports the source code file where the error is detected. $head exp$$ The $icode handler$$ argument $icode exp$$ has prototype $codei% const char *%exp% %$$ and is a $code '\0'$$ terminated character vector. It is a source code boolean expression that should have been true, but is false, and thereby causes this call to $icode handler$$. $head msg$$ The $icode handler$$ argument $icode msg$$ has prototype $codei% const char *%msg% %$$ and is a $code '\0'$$ terminated character vector. It reports the meaning of the error from the C++ programmers point of view. $children% example/error_handler.cpp% cppad/local/cppad_assert.hpp %$$ $head Example$$ The file $cref error_handler.cpp$$ contains an example and test a test of using this routine. It returns true if it succeeds and false otherwise. $end --------------------------------------------------------------------------- */ # include # include # include # include # include namespace CppAD { // BEGIN CppAD namespace class ErrorHandler { template friend void parallel_ad(void); public: typedef void (*Handler) (bool, int, const char *, const char *, const char *); // construct a new handler ErrorHandler(Handler handler) : previous( Current() ) { if( set_get_in_parallel(0) ) { bool known = true; int line = __LINE__; const char* file = __FILE__; const char* exp = "! set_get_in_parallel(0)"; const char* msg = "Using ErrorHandler constructor in parallel mode."; Call(known, line, file, exp, msg); } Current() = handler; } // destructor for an error handler ~ErrorHandler(void) { if( set_get_in_parallel(0) ) { bool known = true; int line = __LINE__; const char* file = __FILE__; const char* exp = "! set_get_in_parallel(0)"; const char* msg = "Using ErrorHandler destructor in parallel mode."; Call(known, line, file, exp, msg); } Current() = previous; } // report an error static void Call( bool known, int line , const char *file , const char *exp , const char *msg ) { Handler handler = Current(); handler(known, line, file, exp, msg); } private: const Handler previous; // The default error handler static void Default( bool known, int line , const char *file , const char *exp , const char *msg ) { using std::cerr; using std::endl; cerr << CPPAD_PACKAGE_STRING; if( known ) cerr << " error from a known source:" << endl; else cerr << " error from unknown source" << endl; if( msg[0] != '\0' ) cerr << msg << endl; cerr << "Error detected by false result for" << endl; cerr << " " << exp << endl; cerr << "at line " << line << " in the file " << endl; cerr << " " << file << endl; // terminate program execution assert(false); // termination when NDEBUG is defined std::exit(1); } // current error handler static Handler &Current(void) { static bool first_call = true; static Handler current = Default; if( first_call ) { if( set_get_in_parallel(0) ) { bool known = false; int line = __LINE__; const char* file = __FILE__; const char* exp = ""; const char* msg = ""; Call(known, line, file, exp, msg); } first_call = false; } return current; } }; } // END CppAD namespace # endif cppad-20160000.1/cppad/utility/runge_45.hpp0000644000175200017650000002644012656321766017376 0ustar coincoin-web// $Id: runge_45.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_RUNGE_45_HPP # define CPPAD_RUNGE_45_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Runge45$$ $spell std fabs cppad.hpp bool xf templated const Runge-Kutta CppAD xi ti tf Karp $$ $section An Embedded 4th and 5th Order Runge-Kutta ODE Solver$$ $mindex Runge45 Runge Kutta solve differential equation$$ $head Syntax$$ $codei%# include %$$ $icode%xf% = Runge45(%F%, %M%, %ti%, %tf%, %xi%) %$$ $icode%xf% = Runge45(%F%, %M%, %ti%, %tf%, %xi%, %e%) %$$ $head Purpose$$ This is an implementation of the Cash-Karp embedded 4th and 5th order Runge-Kutta ODE solver described in Section 16.2 of $cref/Numerical Recipes/Bib/Numerical Recipes/$$. We use $latex n$$ for the size of the vector $icode xi$$. Let $latex \B{R}$$ denote the real numbers and let $latex F : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. The return value $icode xf$$ contains a 5th order approximation for the value $latex X(tf)$$ where $latex X : [ti , tf] \rightarrow \B{R}^n$$ is defined by the following initial value problem: $latex \[ \begin{array}{rcl} X(ti) & = & xi \\ X'(t) & = & F[t , X(t)] \end{array} \] $$ If your set of ordinary differential equations are stiff, an implicit method may be better (perhaps $cref Rosen34$$.) $head Operation Sequence$$ The $cref/operation sequence/glossary/Operation/Sequence/$$ for $icode Runge$$ does not depend on any of its $icode Scalar$$ input values provided that the operation sequence for $codei% %F%.Ode(%t%, %x%, %f%) %$$ does not on any of its $icode Scalar$$ inputs (see below). $head Include$$ The file $code cppad/runge_45.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head xf$$ The return value $icode xf$$ has the prototype $codei% %Vector% %xf% %$$ and the size of $icode xf$$ is equal to $icode n$$ (see description of $cref/Vector/Runge45/Vector/$$ below). $latex \[ X(tf) = xf + O( h^6 ) \] $$ where $latex h = (tf - ti) / M$$ is the step size. If $icode xf$$ contains not a number $cref nan$$, see the discussion for $cref/f/Runge45/Fun/f/$$. $head Fun$$ The class $icode Fun$$ and the object $icode F$$ satisfy the prototype $codei% %Fun% &%F% %$$ The object $icode F$$ (and the class $icode Fun$$) must have a member function named $code Ode$$ that supports the syntax $codei% %F%.Ode(%t%, %x%, %f%) %$$ $subhead t$$ The argument $icode t$$ to $icode%F%.Ode%$$ has prototype $codei% const %Scalar% &%t% %$$ (see description of $cref/Scalar/Runge45/Scalar/$$ below). $subhead x$$ The argument $icode x$$ to $icode%F%.Ode%$$ has prototype $codei% const %Vector% &%x% %$$ and has size $icode n$$ (see description of $cref/Vector/Runge45/Vector/$$ below). $subhead f$$ The argument $icode f$$ to $icode%F%.Ode%$$ has prototype $codei% %Vector% &%f% %$$ On input and output, $icode f$$ is a vector of size $icode n$$ and the input values of the elements of $icode f$$ do not matter. On output, $icode f$$ is set equal to $latex F(t, x)$$ in the differential equation. If any of the elements of $icode f$$ have the value not a number $code nan$$ the routine $code Runge45$$ returns with all the elements of $icode xf$$ and $icode e$$ equal to $code nan$$. $subhead Warning$$ The argument $icode f$$ to $icode%F%.Ode%$$ must have a call by reference in its prototype; i.e., do not forget the $code &$$ in the prototype for $icode f$$. $head M$$ The argument $icode M$$ has prototype $codei% size_t %M% %$$ It specifies the number of steps to use when solving the differential equation. This must be greater than or equal one. The step size is given by $latex h = (tf - ti) / M$$, thus the larger $icode M$$, the more accurate the return value $icode xf$$ is as an approximation for $latex X(tf)$$. $head ti$$ The argument $icode ti$$ has prototype $codei% const %Scalar% &%ti% %$$ (see description of $cref/Scalar/Runge45/Scalar/$$ below). It specifies the initial time for $icode t$$ in the differential equation; i.e., the time corresponding to the value $icode xi$$. $head tf$$ The argument $icode tf$$ has prototype $codei% const %Scalar% &%tf% %$$ It specifies the final time for $icode t$$ in the differential equation; i.e., the time corresponding to the value $icode xf$$. $head xi$$ The argument $icode xi$$ has the prototype $codei% const %Vector% &%xi% %$$ and the size of $icode xi$$ is equal to $icode n$$. It specifies the value of $latex X(ti)$$ $head e$$ The argument $icode e$$ is optional and has the prototype $codei% %Vector% &%e% %$$ If $icode e$$ is present, the size of $icode e$$ must be equal to $icode n$$. The input value of the elements of $icode e$$ does not matter. On output it contains an element by element estimated bound for the absolute value of the error in $icode xf$$ $latex \[ e = O( h^5 ) \] $$ where $latex h = (tf - ti) / M$$ is the step size. If on output, $icode e$$ contains not a number $code nan$$, see the discussion for $cref/f/Runge45/Fun/f/$$. $head Scalar$$ The type $icode Scalar$$ must satisfy the conditions for a $cref NumericType$$ type. The routine $cref CheckNumericType$$ will generate an error message if this is not the case. $subhead fabs$$ In addition, the following function must be defined for $icode Scalar$$ objects $icode a$$ and $icode b$$ $codei% %a% = fabs(%b%) %$$ Note that this operation is only used for computing $icode e$$; hence the operation sequence for $icode xf$$ can still be independent of the arguments to $code Runge45$$ even if $codei% fabs(%b%) = std::max(-%b%, %b%) %$$. $head Vector$$ The type $icode Vector$$ must be a $cref SimpleVector$$ class with $cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $head Parallel Mode$$ For each set of types $cref/Scalar/Runge45/Scalar/$$, $cref/Vector/Runge45/Vector/$$, and $cref/Fun/Runge45/Fun/$$, the first call to $code Runge45$$ must not be $cref/parallel/ta_in_parallel/$$ execution mode. $head Example$$ $children% example/runge45_1.cpp% example/runge45_2.cpp %$$ The file $cref runge45_1.cpp$$ contains a simple example and test of $code Runge45$$. It returns true if it succeeds and false otherwise. $pre $$ The file $cref runge45_2.cpp$$ contains an example using $code Runge45$$ in the context of algorithmic differentiation. It also returns true if it succeeds and false otherwise. $head Source Code$$ The source code for this routine is in the file $code cppad/runge_45.hpp$$. $end -------------------------------------------------------------------------- */ # include # include # include # include # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL # include namespace CppAD { // BEGIN CppAD namespace template Vector Runge45( Fun &F , size_t M , const Scalar &ti , const Scalar &tf , const Vector &xi ) { Vector e( xi.size() ); return Runge45(F, M, ti, tf, xi, e); } template Vector Runge45( Fun &F , size_t M , const Scalar &ti , const Scalar &tf , const Vector &xi , Vector &e ) { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; // check numeric type specifications CheckNumericType(); // check simple vector class specifications CheckSimpleVector(); // Cash-Karp parameters for embedded Runge-Kutta method // are static to avoid recalculation on each call and // do not use Vector to avoid possible memory leak static Scalar a[6] = { Scalar(0), Scalar(1) / Scalar(5), Scalar(3) / Scalar(10), Scalar(3) / Scalar(5), Scalar(1), Scalar(7) / Scalar(8) }; static Scalar b[5 * 5] = { Scalar(1) / Scalar(5), Scalar(0), Scalar(0), Scalar(0), Scalar(0), Scalar(3) / Scalar(40), Scalar(9) / Scalar(40), Scalar(0), Scalar(0), Scalar(0), Scalar(3) / Scalar(10), -Scalar(9) / Scalar(10), Scalar(6) / Scalar(5), Scalar(0), Scalar(0), -Scalar(11) / Scalar(54), Scalar(5) / Scalar(2), -Scalar(70) / Scalar(27), Scalar(35) / Scalar(27), Scalar(0), Scalar(1631) / Scalar(55296), Scalar(175) / Scalar(512), Scalar(575) / Scalar(13824), Scalar(44275) / Scalar(110592), Scalar(253) / Scalar(4096) }; static Scalar c4[6] = { Scalar(2825) / Scalar(27648), Scalar(0), Scalar(18575) / Scalar(48384), Scalar(13525) / Scalar(55296), Scalar(277) / Scalar(14336), Scalar(1) / Scalar(4), }; static Scalar c5[6] = { Scalar(37) / Scalar(378), Scalar(0), Scalar(250) / Scalar(621), Scalar(125) / Scalar(594), Scalar(0), Scalar(512) / Scalar(1771) }; CPPAD_ASSERT_KNOWN( M >= 1, "Error in Runge45: the number of steps is less than one" ); CPPAD_ASSERT_KNOWN( e.size() == xi.size(), "Error in Runge45: size of e not equal to size of xi" ); size_t i, j, k, m; // indices size_t n = xi.size(); // number of components in X(t) Scalar ns = Scalar(int(M)); // number of steps as Scalar object Scalar h = (tf - ti) / ns; // step size Scalar zero_or_nan = Scalar(0); // zero (nan if Ode returns has a nan) for(i = 0; i < n; i++) // initialize e = 0 e[i] = zero_or_nan; // vectors used to store values returned by F Vector fh(6 * n), xtmp(n), ftmp(n), x4(n), x5(n), xf(n); xf = xi; // initialize solution for(m = 0; m < M; m++) { // time at beginning of this interval // (convert to int to avoid MS compiler warning) Scalar t = ti * (Scalar(int(M - m)) / ns) + tf * (Scalar(int(m)) / ns); // loop over integration steps x4 = x5 = xf; // start x4 and x5 at same point for each step for(j = 0; j < 6; j++) { // loop over function evaluations for this step xtmp = xf; // location for next function evaluation for(k = 0; k < j; k++) { // loop over previous function evaluations Scalar bjk = b[ (j-1) * 5 + k ]; for(i = 0; i < n; i++) { // loop over elements of x xtmp[i] += bjk * fh[i * 6 + k]; } } // ftmp = F(t + a[j] * h, xtmp) F.Ode(t + a[j] * h, xtmp, ftmp); // if ftmp has a nan, set zero_or_nan to nan for(i = 0; i < n; i++) zero_or_nan *= ftmp[i]; for(i = 0; i < n; i++) { // loop over elements of x Scalar fhi = ftmp[i] * h; fh[i * 6 + j] = fhi; x4[i] += c4[j] * fhi; x5[i] += c5[j] * fhi; x5[i] += zero_or_nan; } } // accumulate error bound for(i = 0; i < n; i++) { // cant use abs because cppad.hpp may not be included Scalar diff = x5[i] - x4[i]; e[i] += fabs(diff); e[i] += zero_or_nan; } // advance xf for this step using x5 xf = x5; } return xf; } } // End CppAD namespace # endif cppad-20160000.1/cppad/utility/lu_solve.hpp0000644000175200017650000002326612656321766017601 0ustar coincoin-web// $Id: lu_solve.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_LU_SOLVE_HPP # define CPPAD_LU_SOLVE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin LuSolve$$ $escape #$$ $spell cppad.hpp det exp Leq typename bool const namespace std Geq Lu CppAD signdet logdet $$ $section Compute Determinant and Solve Linear Equations$$ $mindex LuSolve Lu$$ $pre $$ $head Syntax$$ $codei%# include %$$ $icode%signdet% = LuSolve(%n%, %m%, %A%, %B%, %X%, %logdet%)%$$ $head Description$$ Use an LU factorization of the matrix $icode A$$ to compute its determinant and solve for $icode X$$ in the linear of equation $latex \[ A * X = B \] $$ where $icode A$$ is an $icode n$$ by $icode n$$ matrix, $icode X$$ is an $icode n$$ by $icode m$$ matrix, and $icode B$$ is an $latex n x m$$ matrix. $head Include$$ The file $code cppad/lu_solve.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head Factor and Invert$$ This routine is an easy to user interface to $cref LuFactor$$ and $cref LuInvert$$ for computing determinants and solutions of linear equations. These separate routines should be used if one right hand side $icode B$$ depends on the solution corresponding to another right hand side (with the same value of $icode A$$). In this case only one call to $code LuFactor$$ is required but there will be multiple calls to $code LuInvert$$. $head Matrix Storage$$ All matrices are stored in row major order. To be specific, if $latex Y$$ is a vector that contains a $latex p$$ by $latex q$$ matrix, the size of $latex Y$$ must be equal to $latex p * q $$ and for $latex i = 0 , \ldots , p-1$$, $latex j = 0 , \ldots , q-1$$, $latex \[ Y_{i,j} = Y[ i * q + j ] \] $$ $head signdet$$ The return value $icode signdet$$ is a $code int$$ value that specifies the sign factor for the determinant of $icode A$$. This determinant of $icode A$$ is zero if and only if $icode signdet$$ is zero. $head n$$ The argument $icode n$$ has type $code size_t$$ and specifies the number of rows in the matrices $icode A$$, $icode X$$, and $icode B$$. The number of columns in $icode A$$ is also equal to $icode n$$. $head m$$ The argument $icode m$$ has type $code size_t$$ and specifies the number of columns in the matrices $icode X$$ and $icode B$$. If $icode m$$ is zero, only the determinant of $icode A$$ is computed and the matrices $icode X$$ and $icode B$$ are not used. $head A$$ The argument $icode A$$ has the prototype $codei% const %FloatVector% &%A% %$$ and the size of $icode A$$ must equal $latex n * n$$ (see description of $cref/FloatVector/LuSolve/FloatVector/$$ below). This is the $latex n$$ by $icode n$$ matrix that we are computing the determinant of and that defines the linear equation. $head B$$ The argument $icode B$$ has the prototype $codei% const %FloatVector% &%B% %$$ and the size of $icode B$$ must equal $latex n * m$$ (see description of $cref/FloatVector/LuSolve/FloatVector/$$ below). This is the $latex n$$ by $icode m$$ matrix that defines the right hand side of the linear equations. If $icode m$$ is zero, $icode B$$ is not used. $head X$$ The argument $icode X$$ has the prototype $codei% %FloatVector% &%X% %$$ and the size of $icode X$$ must equal $latex n * m$$ (see description of $cref/FloatVector/LuSolve/FloatVector/$$ below). The input value of $icode X$$ does not matter. On output, the elements of $icode X$$ contain the solution of the equation we wish to solve (unless $icode signdet$$ is equal to zero). If $icode m$$ is zero, $icode X$$ is not used. $head logdet$$ The argument $icode logdet$$ has prototype $codei% %Float% &%logdet% %$$ On input, the value of $icode logdet$$ does not matter. On output, it has been set to the log of the determinant of $icode A$$ (but not quite). To be more specific, the determinant of $icode A$$ is given by the formula $codei% %det% = %signdet% * exp( %logdet% ) %$$ This enables $code LuSolve$$ to use logs of absolute values in the case where $icode Float$$ corresponds to a real number. $head Float$$ The type $icode Float$$ must satisfy the conditions for a $cref NumericType$$ type. The routine $cref CheckNumericType$$ will generate an error message if this is not the case. In addition, the following operations must be defined for any pair of $icode Float$$ objects $icode x$$ and $icode y$$: $table $bold Operation$$ $cnext $bold Description$$ $rnext $codei%log(%x%)%$$ $cnext returns the logarithm of $icode x$$ as a $icode Float$$ object $tend $head FloatVector$$ The type $icode FloatVector$$ must be a $cref SimpleVector$$ class with $cref/elements of type Float/SimpleVector/Elements of Specified Type/$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $head LeqZero$$ Including the file $code lu_solve.hpp$$ defines the template function $codei% template bool LeqZero<%Float%>(const %Float% &%x%) %$$ in the $code CppAD$$ namespace. This function returns true if $icode x$$ is less than or equal to zero and false otherwise. It is used by $code LuSolve$$ to avoid taking the log of zero (or a negative number if $icode Float$$ corresponds to real numbers). This template function definition assumes that the operator $code <=$$ is defined for $icode Float$$ objects. If this operator is not defined for your use of $icode Float$$, you will need to specialize this template so that it works for your use of $code LuSolve$$. $pre $$ Complex numbers do not have the operation or $code <=$$ defined. In addition, in the complex case, one can take the log of a negative number. The specializations $codei% bool LeqZero< std::complex > (const std::complex &%x%) bool LeqZero< std::complex >(const std::complex &%x%) %$$ are defined by including $code lu_solve.hpp$$. These return true if $icode x$$ is zero and false otherwise. $head AbsGeq$$ Including the file $code lu_solve.hpp$$ defines the template function $codei% template bool AbsGeq<%Float%>(const %Float% &%x%, const %Float% &%y%) %$$ If the type $icode Float$$ does not support the $code <=$$ operation and it is not $code std::complex$$ or $code std::complex$$, see the documentation for $code AbsGeq$$ in $cref/LuFactor/LuFactor/AbsGeq/$$. $children% example/lu_solve.cpp% omh/lu_solve_hpp.omh %$$ $head Example$$ The file $cref lu_solve.cpp$$ contains an example and test of using this routine. It returns true if it succeeds and false otherwise. $head Source$$ The file $cref lu_solve.hpp$$ contains the current source code that implements these specifications. $end -------------------------------------------------------------------------- */ // BEGIN C++ # include # include // link exp for float and double cases # include # include # include # include # include # include namespace CppAD { // BEGIN CppAD namespace // LeqZero template inline bool LeqZero(const Float &x) { return x <= Float(0); } inline bool LeqZero( const std::complex &x ) { return x == std::complex(0); } inline bool LeqZero( const std::complex &x ) { return x == std::complex(0); } // LuSolve template int LuSolve( size_t n , size_t m , const FloatVector &A , const FloatVector &B , FloatVector &X , Float &logdet ) { // check numeric type specifications CheckNumericType(); // check simple vector class specifications CheckSimpleVector(); size_t p; // index of pivot element (diagonal of L) int signdet; // sign of the determinant Float pivot; // pivot element // the value zero const Float zero(0); // pivot row and column order in the matrix std::vector ip(n); std::vector jp(n); // ------------------------------------------------------- CPPAD_ASSERT_KNOWN( size_t(A.size()) == n * n, "Error in LuSolve: A must have size equal to n * n" ); CPPAD_ASSERT_KNOWN( size_t(B.size()) == n * m, "Error in LuSolve: B must have size equal to n * m" ); CPPAD_ASSERT_KNOWN( size_t(X.size()) == n * m, "Error in LuSolve: X must have size equal to n * m" ); // ------------------------------------------------------- // copy A so that it does not change FloatVector Lu(A); // copy B so that it does not change X = B; // Lu factor the matrix A signdet = LuFactor(ip, jp, Lu); // compute the log of the determinant logdet = Float(0); for(p = 0; p < n; p++) { // pivot using the max absolute element pivot = Lu[ ip[p] * n + jp[p] ]; // check for determinant equal to zero if( pivot == zero ) { // abort the mission logdet = Float(0); return 0; } // update the determinant if( LeqZero ( pivot ) ) { logdet += log( - pivot ); signdet = - signdet; } else logdet += log( pivot ); } // solve the linear equations LuInvert(ip, jp, Lu, X); // return the sign factor for the determinant return signdet; } } // END CppAD namespace // END C++ # endif cppad-20160000.1/cppad/utility/elapsed_seconds.hpp0000644000175200017650000001170312656321766021075 0ustar coincoin-web// $Id: elapsed_seconds.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_ELAPSED_SECONDS_HPP # define CPPAD_ELAPSED_SECONDS_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin elapsed_seconds$$ $spell cppad.hpp Microsoft gettimeofday std chrono $$ $section Returns Elapsed Number of Seconds$$ $mindex elapsed_seconds time$$ $head Syntax$$ $codei%# include %$$ $icode%s% = elapsed_seconds()%$$ $head Purpose$$ This routine is accurate to within .02 seconds (see $cref elapsed_seconds.cpp$$). It does not necessary work for time intervals that are greater than a day. $list number$$ If the C++11 $code std::chrono::high_resolution_clock$$ is available, it will be used for timing. $lnext Otherwise, if running under the Microsoft compiler, $code ::GetSystemTime$$ will be used for timing. $lnext Otherwise, if $code gettimeofday$$ is available, it is used for timing. $lnext Otherwise, $code std::clock()$$ will be used for timing. $lend $head s$$ is a $code double$$ equal to the number of seconds since the first call to $code elapsed_seconds$$. $head Microsoft Systems$$ It you are using $code ::GetSystemTime$$, you will need to link in the external routine called $cref microsoft_timer$$. $children% speed/example/elapsed_seconds.cpp %$$ $head Example$$ The routine $cref elapsed_seconds.cpp$$ is an example and test of this routine. $end ----------------------------------------------------------------------- */ // For some unknown reason under Fedora (which needs to be understood), // if you move this include for cppad_assert.hpp below include for define.hpp, // cd work/speed/example // make test.sh // fails with the error message 'gettimeofday' not defined. # include // define CPPAD_NULL # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL # include # if CPPAD_USE_CPLUSPLUS_2011 # include # elif _MSC_VER extern double microsoft_timer(void); # elif CPPAD_HAS_GETTIMEOFDAY # include # else # include # endif namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file elapsed_seconds.hpp \brief Function that returns the elapsed seconds from first call. */ /*! Returns the elapsed number since the first call to this function. This routine tries is accurate to within .02 seconds. It does not necessary work for time intervals that are less than a day. \li If running under the Microsoft system, it uses \c ::%GetSystemTime for timing. \li Otherwise, if \c gettimeofday is available, it is used. \li Otherwise, \c std::clock() is used. \return The number of seconds since the first call to \c elapsed_seconds. */ inline double elapsed_seconds(void) // -------------------------------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; static bool first_ = true; static std::chrono::time_point start_; if( first_ ) { start_ = std::chrono::high_resolution_clock::now(); first_ = false; return 0.0; } std::chrono::time_point now; now = std::chrono::high_resolution_clock::now(); std::chrono::duration difference = now - start_; return difference.count(); } // -------------------------------------------------------------------------- # elif _MSC_VER { return microsoft_timer(); } // -------------------------------------------------------------------------- # elif CPPAD_HAS_GETTIMEOFDAY { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; static bool first_ = true; static struct timeval tv_; struct timeval tv; if( first_ ) { gettimeofday(&tv_, CPPAD_NULL); first_ = false; return 0.; } gettimeofday(&tv, CPPAD_NULL); assert( tv.tv_sec >= tv_.tv_sec ); double sec = double(tv.tv_sec - tv_.tv_sec); double usec = double(tv.tv_usec) - double(tv_.tv_usec); double diff = sec + 1e-6*usec; return diff; } // -------------------------------------------------------------------------- # else // Not CPPAD_USE_CPLUSPLUS_2011 or CPPAD_HAS_GETTIMEOFDAY { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; static bool first_ = true; static double tic_; double tic; if( first_ ) { tic_ = double(std::clock()); first_ = false; return 0.; } tic = double( std::clock() ); double diff = (tic - tic_) / double(CLOCKS_PER_SEC); return diff; } # endif // -------------------------------------------------------------------------- } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/utility/rosen_34.hpp0000644000175200017650000003177212656321766017406 0ustar coincoin-web// $Id: rosen_34.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_ROSEN_34_HPP # define CPPAD_ROSEN_34_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Rosen34$$ $spell cppad.hpp bool xf templated const Rosenbrock CppAD xi ti tf Karp Rosen Shampine ind dep $$ $section A 3rd and 4th Order Rosenbrock ODE Solver$$ $mindex Rosen34 solve stiff differential equation$$ $head Syntax$$ $codei%# include %$$ $icode%xf% = Rosen34(%F%, %M%, %ti%, %tf%, %xi%) %$$ $icode%xf% = Rosen34(%F%, %M%, %ti%, %tf%, %xi%, %e%) %$$ $head Description$$ This is an embedded 3rd and 4th order Rosenbrock ODE solver (see Section 16.6 of $cref/Numerical Recipes/Bib/Numerical Recipes/$$ for a description of Rosenbrock ODE solvers). In particular, we use the formulas taken from page 100 of $cref/Shampine, L.F./Bib/Shampine, L.F./$$ (except that the fraction 98/108 has been correction to be 97/108). $pre $$ We use $latex n$$ for the size of the vector $icode xi$$. Let $latex \B{R}$$ denote the real numbers and let $latex F : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. The return value $icode xf$$ contains a 5th order approximation for the value $latex X(tf)$$ where $latex X : [ti , tf] \rightarrow \B{R}^n$$ is defined by the following initial value problem: $latex \[ \begin{array}{rcl} X(ti) & = & xi \\ X'(t) & = & F[t , X(t)] \end{array} \] $$ If your set of ordinary differential equations are not stiff an explicit method may be better (perhaps $cref Runge45$$.) $head Include$$ The file $code cppad/rosen_34.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head xf$$ The return value $icode xf$$ has the prototype $codei% %Vector% %xf% %$$ and the size of $icode xf$$ is equal to $icode n$$ (see description of $cref/Vector/Rosen34/Vector/$$ below). $latex \[ X(tf) = xf + O( h^5 ) \] $$ where $latex h = (tf - ti) / M$$ is the step size. If $icode xf$$ contains not a number $cref nan$$, see the discussion of $cref/f/Rosen34/Fun/Nan/$$. $head Fun$$ The class $icode Fun$$ and the object $icode F$$ satisfy the prototype $codei% %Fun% &%F% %$$ This must support the following set of calls $codei% %F%.Ode(%t%, %x%, %f%) %F%.Ode_ind(%t%, %x%, %f_t%) %F%.Ode_dep(%t%, %x%, %f_x%) %$$ $subhead t$$ In all three cases, the argument $icode t$$ has prototype $codei% const %Scalar% &%t% %$$ (see description of $cref/Scalar/Rosen34/Scalar/$$ below). $subhead x$$ In all three cases, the argument $icode x$$ has prototype $codei% const %Vector% &%x% %$$ and has size $icode n$$ (see description of $cref/Vector/Rosen34/Vector/$$ below). $subhead f$$ The argument $icode f$$ to $icode%F%.Ode%$$ has prototype $codei% %Vector% &%f% %$$ On input and output, $icode f$$ is a vector of size $icode n$$ and the input values of the elements of $icode f$$ do not matter. On output, $icode f$$ is set equal to $latex F(t, x)$$ (see $icode F(t, x)$$ in $cref/Description/Rosen34/Description/$$). $subhead f_t$$ The argument $icode f_t$$ to $icode%F%.Ode_ind%$$ has prototype $codei% %Vector% &%f_t% %$$ On input and output, $icode f_t$$ is a vector of size $icode n$$ and the input values of the elements of $icode f_t$$ do not matter. On output, the $th i$$ element of $icode f_t$$ is set equal to $latex \partial_t F_i (t, x)$$ (see $icode F(t, x)$$ in $cref/Description/Rosen34/Description/$$). $subhead f_x$$ The argument $icode f_x$$ to $icode%F%.Ode_dep%$$ has prototype $codei% %Vector% &%f_x% %$$ On input and output, $icode f_x$$ is a vector of size $icode%n%*%n%$$ and the input values of the elements of $icode f_x$$ do not matter. On output, the [$icode%i%*%n%+%j%$$] element of $icode f_x$$ is set equal to $latex \partial_{x(j)} F_i (t, x)$$ (see $icode F(t, x)$$ in $cref/Description/Rosen34/Description/$$). $subhead Nan$$ If any of the elements of $icode f$$, $icode f_t$$, or $icode f_x$$ have the value not a number $code nan$$, the routine $code Rosen34$$ returns with all the elements of $icode xf$$ and $icode e$$ equal to $code nan$$. $subhead Warning$$ The arguments $icode f$$, $icode f_t$$, and $icode f_x$$ must have a call by reference in their prototypes; i.e., do not forget the $code &$$ in the prototype for $icode f$$, $icode f_t$$ and $icode f_x$$. $subhead Optimization$$ Every call of the form $codei% %F%.Ode_ind(%t%, %x%, %f_t%) %$$ is directly followed by a call of the form $codei% %F%.Ode_dep(%t%, %x%, %f_x%) %$$ where the arguments $icode t$$ and $icode x$$ have not changed between calls. In many cases it is faster to compute the values of $icode f_t$$ and $icode f_x$$ together and then pass them back one at a time. $head M$$ The argument $icode M$$ has prototype $codei% size_t %M% %$$ It specifies the number of steps to use when solving the differential equation. This must be greater than or equal one. The step size is given by $latex h = (tf - ti) / M$$, thus the larger $icode M$$, the more accurate the return value $icode xf$$ is as an approximation for $latex X(tf)$$. $head ti$$ The argument $icode ti$$ has prototype $codei% const %Scalar% &%ti% %$$ (see description of $cref/Scalar/Rosen34/Scalar/$$ below). It specifies the initial time for $icode t$$ in the differential equation; i.e., the time corresponding to the value $icode xi$$. $head tf$$ The argument $icode tf$$ has prototype $codei% const %Scalar% &%tf% %$$ It specifies the final time for $icode t$$ in the differential equation; i.e., the time corresponding to the value $icode xf$$. $head xi$$ The argument $icode xi$$ has the prototype $codei% const %Vector% &%xi% %$$ and the size of $icode xi$$ is equal to $icode n$$. It specifies the value of $latex X(ti)$$ $head e$$ The argument $icode e$$ is optional and has the prototype $codei% %Vector% &%e% %$$ If $icode e$$ is present, the size of $icode e$$ must be equal to $icode n$$. The input value of the elements of $icode e$$ does not matter. On output it contains an element by element estimated bound for the absolute value of the error in $icode xf$$ $latex \[ e = O( h^4 ) \] $$ where $latex h = (tf - ti) / M$$ is the step size. $head Scalar$$ The type $icode Scalar$$ must satisfy the conditions for a $cref NumericType$$ type. The routine $cref CheckNumericType$$ will generate an error message if this is not the case. In addition, the following operations must be defined for $icode Scalar$$ objects $icode a$$ and $icode b$$: $table $bold Operation$$ $cnext $bold Description$$ $rnext $icode%a% < %b%$$ $cnext less than operator (returns a $code bool$$ object) $tend $head Vector$$ The type $icode Vector$$ must be a $cref SimpleVector$$ class with $cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $head Parallel Mode$$ For each set of types $cref/Scalar/Rosen34/Scalar/$$, $cref/Vector/Rosen34/Vector/$$, and $cref/Fun/Rosen34/Fun/$$, the first call to $code Rosen34$$ must not be $cref/parallel/ta_in_parallel/$$ execution mode. $head Example$$ $children% example/rosen_34.cpp %$$ The file $cref rosen_34.cpp$$ contains an example and test a test of using this routine. It returns true if it succeeds and false otherwise. $head Source Code$$ The source code for this routine is in the file $code cppad/rosen_34.hpp$$. $end -------------------------------------------------------------------------- */ # include # include # include # include # include # include # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL # include namespace CppAD { // BEGIN CppAD namespace template Vector Rosen34( Fun &F , size_t M , const Scalar &ti , const Scalar &tf , const Vector &xi ) { Vector e( xi.size() ); return Rosen34(F, M, ti, tf, xi, e); } template Vector Rosen34( Fun &F , size_t M , const Scalar &ti , const Scalar &tf , const Vector &xi , Vector &e ) { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; // check numeric type specifications CheckNumericType(); // check simple vector class specifications CheckSimpleVector(); // Parameters for Shampine's Rosenbrock method // are static to avoid recalculation on each call and // do not use Vector to avoid possible memory leak static Scalar a[3] = { Scalar(0), Scalar(1), Scalar(3) / Scalar(5) }; static Scalar b[2 * 2] = { Scalar(1), Scalar(0), Scalar(24) / Scalar(25), Scalar(3) / Scalar(25) }; static Scalar ct[4] = { Scalar(1) / Scalar(2), - Scalar(3) / Scalar(2), Scalar(121) / Scalar(50), Scalar(29) / Scalar(250) }; static Scalar cg[3 * 3] = { - Scalar(4), Scalar(0), Scalar(0), Scalar(186) / Scalar(25), Scalar(6) / Scalar(5), Scalar(0), - Scalar(56) / Scalar(125), - Scalar(27) / Scalar(125), - Scalar(1) / Scalar(5) }; static Scalar d3[3] = { Scalar(97) / Scalar(108), Scalar(11) / Scalar(72), Scalar(25) / Scalar(216) }; static Scalar d4[4] = { Scalar(19) / Scalar(18), Scalar(1) / Scalar(4), Scalar(25) / Scalar(216), Scalar(125) / Scalar(216) }; CPPAD_ASSERT_KNOWN( M >= 1, "Error in Rosen34: the number of steps is less than one" ); CPPAD_ASSERT_KNOWN( e.size() == xi.size(), "Error in Rosen34: size of e not equal to size of xi" ); size_t i, j, k, l, m; // indices size_t n = xi.size(); // number of components in X(t) Scalar ns = Scalar(double(M)); // number of steps as Scalar object Scalar h = (tf - ti) / ns; // step size Scalar zero = Scalar(0); // some constants Scalar one = Scalar(1); Scalar two = Scalar(2); // permutation vectors needed for LU factorization routine CppAD::vector ip(n), jp(n); // vectors used to store values returned by F Vector E(n * n), Eg(n), f_t(n); Vector g(n * 3), x3(n), x4(n), xf(n), ftmp(n), xtmp(n), nan_vec(n); // initialize e = 0, nan_vec = nan for(i = 0; i < n; i++) { e[i] = zero; nan_vec[i] = nan(zero); } xf = xi; // initialize solution for(m = 0; m < M; m++) { // time at beginning of this interval Scalar t = ti * (Scalar(int(M - m)) / ns) + tf * (Scalar(int(m)) / ns); // value of x at beginning of this interval x3 = x4 = xf; // evaluate partial derivatives at beginning of this interval F.Ode_ind(t, xf, f_t); F.Ode_dep(t, xf, E); // E = f_x if( hasnan(f_t) || hasnan(E) ) { e = nan_vec; return nan_vec; } // E = I - f_x * h / 2 for(i = 0; i < n; i++) { for(j = 0; j < n; j++) E[i * n + j] = - E[i * n + j] * h / two; E[i * n + i] += one; } // LU factor the matrix E # ifndef NDEBUG int sign = LuFactor(ip, jp, E); # else LuFactor(ip, jp, E); # endif CPPAD_ASSERT_KNOWN( sign != 0, "Error in Rosen34: I - f_x * h / 2 not invertible" ); // loop over integration steps for(k = 0; k < 3; k++) { // set location for next function evaluation xtmp = xf; for(l = 0; l < k; l++) { // loop over previous function evaluations Scalar bkl = b[(k-1)*2 + l]; for(i = 0; i < n; i++) { // loop over elements of x xtmp[i] += bkl * g[i*3 + l] * h; } } // ftmp = F(t + a[k] * h, xtmp) F.Ode(t + a[k] * h, xtmp, ftmp); if( hasnan(ftmp) ) { e = nan_vec; return nan_vec; } // Form Eg for this integration step for(i = 0; i < n; i++) Eg[i] = ftmp[i] + ct[k] * f_t[i] * h; for(l = 0; l < k; l++) { for(i = 0; i < n; i++) Eg[i] += cg[(k-1)*3 + l] * g[i*3 + l]; } // Solve the equation E * g = Eg LuInvert(ip, jp, E, Eg); // save solution and advance x3, x4 for(i = 0; i < n; i++) { g[i*3 + k] = Eg[i]; x3[i] += h * d3[k] * Eg[i]; x4[i] += h * d4[k] * Eg[i]; } } // Form Eg for last update to x4 only for(i = 0; i < n; i++) Eg[i] = ftmp[i] + ct[3] * f_t[i] * h; for(l = 0; l < 3; l++) { for(i = 0; i < n; i++) Eg[i] += cg[2*3 + l] * g[i*3 + l]; } // Solve the equation E * g = Eg LuInvert(ip, jp, E, Eg); // advance x4 and accumulate error bound for(i = 0; i < n; i++) { x4[i] += h * d4[3] * Eg[i]; // cant use abs because cppad.hpp may not be included Scalar diff = x4[i] - x3[i]; if( diff < zero ) e[i] -= diff; else e[i] += diff; } // advance xf for this step using x4 xf = x4; } return xf; } } // End CppAD namespace # endif cppad-20160000.1/cppad/utility/time_test.hpp0000644000175200017650000001372612656321766017746 0ustar coincoin-web// $Id: time_test.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_TIME_TEST_HPP # define CPPAD_TIME_TEST_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin time_test$$ $spell gettimeofday vec cppad.hpp Microsoft namespace std const cout ctime ifdef const endif cpp $$ $section Determine Amount of Time to Execute a Test$$ $mindex time_test speed$$ $head Syntax$$ $codei%# include %$$ $icode%time% = time_test(%test%, %time_min%)%$$ $icode%time% = time_test(%test%, %time_min%, %test_size%)%$$ $head Purpose$$ The $code time_test$$ function executes a timing test and reports the amount of wall clock time for execution. $head Motivation$$ It is important to separate small calculation units and test them individually. This way individual changes can be tested in the context of the routine that they are in. On many machines, accurate timing of a very short execution sequences is not possible. In addition, there may be set up and tear down time for a test that we do not really want included in the timing. For this reason $code time_test$$ automatically determines how many times to repeat the section of the test that we wish to time. $head Include$$ The file $code cppad/time_test.hpp$$ defines the $code time_test$$ function. This file is included by $code cppad/cppad.hpp$$ and it can also be included separately with out the rest of the $code CppAD$$ routines. $head test$$ The $code time_test$$ argument $icode test$$ is a function, or function object. In the case where $icode test_size$$ is not present, $icode test$$ supports the syntax $codei% %test%(%repeat%) %$$ In the case where $icode test_size$$ is present, $icode test$$ supports the syntax $codei% %test%(%size%, %repeat%) %$$ In either case, the return value for $icode test$$ is $code void$$. $subhead size$$ If the argument $icode size$$ is present, it has prototype $codei% size_t %size% %$$ and is equal to the $icode test_size$$ argument to $code time_test$$. $subhead repeat$$ The $icode test$$ argument $icode repeat$$ has prototype $codei% size_t %repeat% %$$ It will be equal to the $icode size$$ argument to $code time_test$$. $head time_min$$ The argument $icode time_min$$ has prototype $codei% double %time_min% %$$ It specifies the minimum amount of time in seconds that the $icode test$$ routine should take. The $icode repeat$$ argument to $icode test$$ is increased until this amount of execution time (or more) is reached. $head test_size$$ This argument has prototype $codei% size_t %test_size% %$$ It specifies the $icode size$$ argument to $icode test$$. $head time$$ The return value $icode time$$ has prototype $codei% double %time% %$$ and is the number of wall clock seconds that it took to execute $icode test$$ divided by the value used for $icode repeat$$. $head Timing$$ The routine $cref elapsed_seconds$$ will be used to determine the amount of time it took to execute the test. $children% cppad/utility/elapsed_seconds.hpp% speed/example/time_test.cpp %$$ $head Example$$ The routine $cref time_test.cpp$$ is an example and test of $code time_test$$. $end ----------------------------------------------------------------------- */ # include # include # include # include # include # define CPPAD_EXTRA_RUN_BEFORE_TIMING 0 namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file time_test.hpp \brief Function that preforms one timing test (for speed of execution). */ /*! Preform one wall clock execution timing test. \tparam Test Either the type void (*)(size_t) or a function object type that supports the same syntax. \param test The function, or function object, that supports the operation test(repeat) where \c repeat is the number of times to repeat the tests operaiton that is being timed. \param time_min is the minimum amount of time that \c test should take to preform the repetitions of the operation being timed. */ template double time_test(Test test, double time_min ) { # if CPPAD_EXTRA_RUN_BEFORE_TIMING test(1); # endif size_t repeat = 0; double s0 = elapsed_seconds(); double s1 = s0; while( s1 - s0 < time_min ) { repeat = std::max(size_t(1), 2 * repeat); s0 = elapsed_seconds(); test(repeat); s1 = elapsed_seconds(); } double time = (s1 - s0) / double(repeat); return time; } /*! Preform one wall clock execution timing test. \tparam Test Either the type void (*)(size_t, size_t) or a function object type that supports the same syntax. \param test The function, or function object, that supports the operation test(size, repeat) where \c is the size for this test and \c repeat is the number of times to repeat the tests operaiton that is being timed. \param time_min is the minimum amount of time that \c test should take to preform the repetitions of the operation being timed. \param test_size will be used for the value of \c size in the call to \c test. */ template double time_test(Test test, double time_min, size_t test_size) { # if CPPAD_EXTRA_RUN_BEFORE_TIMING test(test_size, 1); # endif size_t repeat = 0; double s0 = elapsed_seconds(); double s1 = s0; while( s1 - s0 < time_min ) { repeat = std::max(size_t(1), 2 * repeat); s0 = elapsed_seconds(); test(test_size, repeat); s1 = elapsed_seconds(); } double time = (s1 - s0) / double(repeat); return time; } } // END_CPPAD_NAMESPACE # undef CPPAD_EXTRA_RUN_BEFORE_TIMING // END PROGRAM # endif cppad-20160000.1/cppad/utility/romberg_one.hpp0000644000175200017650000001224412656321766020241 0ustar coincoin-web// $Id: romberg_one.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_ROMBERG_ONE_HPP # define CPPAD_ROMBERG_ONE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin RombergOne$$ $spell cppad.hpp bool const Cpp RombergOne $$ $section One DimensionalRomberg Integration$$ $mindex integrate Romberg$$ $head Syntax$$ $codei%# include %$$ $icode%r% = RombergOne(%F%, %a%, %b%, %n%, %e%)%$$ $head Description$$ Returns the Romberg integration estimate $latex r$$ for a one dimensional integral $latex \[ r = \int_a^b F(x) {\bf d} x + O \left[ (b - a) / 2^{n-1} \right]^{2(p+1)} \] $$ $head Include$$ The file $code cppad/romberg_one.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head r$$ The return value $icode r$$ has prototype $codei% %Float% %r% %$$ It is the estimate computed by $code RombergOne$$ for the integral above. $head F$$ The object $icode F$$ can be of any type, but it must support the operation $codei% %F%(%x%) %$$ The argument $icode x$$ to $icode F$$ has prototype $codei% const %Float% &%x% %$$ The return value of $icode F$$ is a $icode Float$$ object (see description of $cref/Float/RombergOne/Float/$$ below). $head a$$ The argument $icode a$$ has prototype $codei% const %Float% &%a% %$$ It specifies the lower limit for the integration. $head b$$ The argument $icode b$$ has prototype $codei% const %Float% &%b% %$$ It specifies the upper limit for the integration. $head n$$ The argument $icode n$$ has prototype $codei% size_t %n% %$$ A total number of $latex 2^{n-1} + 1$$ evaluations of $icode%F%(%x%)%$$ are used to estimate the integral. $head p$$ The argument $icode p$$ has prototype $codei% size_t %p% %$$ It must be less than or equal $latex n$$ and determines the accuracy order in the approximation for the integral that is returned by $code RombergOne$$. To be specific $latex \[ r = \int_a^b F(x) {\bf d} x + O \left[ (b - a) / 2^{n-1} \right]^{2(p+1)} \] $$ $head e$$ The argument $icode e$$ has prototype $codei% %Float% &%e% %$$ The input value of $icode e$$ does not matter and its output value is an approximation for the error in the integral estimates; i.e., $latex \[ e \approx \left| r - \int_a^b F(x) {\bf d} x \right| \] $$ $head Float$$ The type $icode Float$$ must satisfy the conditions for a $cref NumericType$$ type. The routine $cref CheckNumericType$$ will generate an error message if this is not the case. In addition, if $icode x$$ and $icode y$$ are $icode Float$$ objects, $codei% %x% < %y% %$$ returns the $code bool$$ value true if $icode x$$ is less than $icode y$$ and false otherwise. $children% example/romberg_one.cpp %$$ $head Example$$ $comment% example/romberg_one.cpp %$$ The file $cref romberg_one.cpp$$ contains an example and test a test of using this routine. It returns true if it succeeds and false otherwise. $head Source Code$$ The source code for this routine is in the file $code cppad/romberg_one.hpp$$. $end */ # include # include # include namespace CppAD { // BEGIN CppAD namespace template Float RombergOne( Fun &F , const Float &a , const Float &b , size_t n , size_t p , Float &e ) { size_t ipow2 = 1; size_t k, i; Float pow2, sum, x; Float zero = Float(0); Float two = Float(2); // check specifications for a NumericType CheckNumericType(); CPPAD_ASSERT_KNOWN( n >= 2, "RombergOne: n must be greater than or equal 2" ); CppAD::vector r(n); // set r[i] = trapazoidal rule with 2^i intervals in [a, b] r[0] = ( F(a) + F(b) ) * (b - a) / two; for(i = 1; i < n; i++) { ipow2 *= 2; // there must be a conversion from int to any numeric type pow2 = Float(int(ipow2)); sum = zero; for(k = 1; k < ipow2; k += 2) { // start = a + (b-a)/pow2, increment = 2*(b-a)/pow2 x = ( (pow2 - Float(int(k))) * a + k * b ) / pow2; sum = sum + F(x); } // combine function evaluations in sum with those in T[i-1] r[i] = r[i-1] / two + sum * (b - a) / pow2; } // now compute the higher order estimates size_t ipow4 = 1; // order of accuract for previous estimate Float pow4, pow4minus; for(i = 0; i < p; i++) { // compute estimate accurate to O[ step^(2*(i+1)) ] // put resutls in r[n-1], r[n-2], ... , r[n-i+1] ipow4 *= 4; pow4 = Float(int(ipow4)); pow4minus = Float(ipow4-1); for(k = n-1; k > i; k--) r[k] = ( pow4 * r[k] - r[k-1] ) / pow4minus; } // error estimate for r[n] e = r[n-1] - r[n-2]; if( e < zero ) e = - e; return r[n-1]; } } // END CppAD namespace # endif cppad-20160000.1/cppad/utility/speed_test.hpp0000644000175200017650000002572212656321766020107 0ustar coincoin-web// $Id: speed_test.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_SPEED_TEST_HPP # define CPPAD_SPEED_TEST_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin speed_test$$ $spell gettimeofday vec cppad.hpp Microsoft namespace std const cout ctime ifdef const endif cpp $$ $section Run One Speed Test and Return Results$$ $mindex speed_test$$ $head Syntax$$ $codei%# include %$$ $icode%rate_vec% = speed_test(%test%, %size_vec%, %time_min%)%$$ $head Purpose$$ The $code speed_test$$ function executes a speed test for various sized problems and reports the rate of execution. $head Motivation$$ It is important to separate small calculation units and test them individually. This way individual changes can be tested in the context of the routine that they are in. On many machines, accurate timing of a very short execution sequences is not possible. In addition, there may be set up and tear down time for a test that we do not really want included in the timing. For this reason $code speed_test$$ automatically determines how many times to repeat the section of the test that we wish to time. $head Include$$ The file $code cppad/speed_test.hpp$$ defines the $code speed_test$$ function. This file is included by $code cppad/cppad.hpp$$ and it can also be included separately with out the rest of the $code CppAD$$ routines. $head Vector$$ We use $icode Vector$$ to denote a $cref/simple vector class/SimpleVector/$$ with elements of type $code size_t$$. $head test$$ The $code speed_test$$ argument $icode test$$ is a function with the syntax $codei% %test%(%size%, %repeat%) %$$ and its return value is $code void$$. $subhead size$$ The $icode test$$ argument $icode size$$ has prototype $codei% size_t %size% %$$ It specifies the size for this test. $subhead repeat$$ The $icode test$$ argument $icode repeat$$ has prototype $codei% size_t %repeat% %$$ It specifies the number of times to repeat the test. $head size_vec$$ The $code speed_test$$ argument $icode size_vec$$ has prototype $codei% const %Vector%& %size_vec% %$$ This vector determines the size for each of the tests problems. $head time_min$$ The argument $icode time_min$$ has prototype $codei% double %time_min% %$$ It specifies the minimum amount of time in seconds that the $icode test$$ routine should take. The $icode repeat$$ argument to $icode test$$ is increased until this amount of execution time is reached. $head rate_vec$$ The return value $icode rate_vec$$ has prototype $codei% %Vector%& %rate_vec% %$$ We use $latex n$$ to denote its size which is the same as the vector $icode size_vec$$. For $latex i = 0 , \ldots , n-1$$, $codei% %rate_vec%[%i%] %$$ is the ratio of $icode repeat$$ divided by time in seconds for the problem with size $icode%size_vec%[%i%]%$$. $head Timing$$ If your system supports the unix $code gettimeofday$$ function, it will be used to measure time. Otherwise, time is measured by the difference in $codep (double) clock() / (double) CLOCKS_PER_SEC $$ in the context of the standard $code $$ definitions. $children% speed/example/speed_test.cpp %$$ $head Example$$ The routine $cref speed_test.cpp$$ is an example and test of $code speed_test$$. $end ----------------------------------------------------------------------- */ # include # include # include # include namespace CppAD { // BEGIN CppAD namespace // implemented as an inline so that can include in multiple link modules // with this same file template inline Vector speed_test( void test(size_t size, size_t repeat), const Vector& size_vec , double time_min ) { // check that size_vec is a simple vector with size_t elements CheckSimpleVector(); size_t n = size_vec.size(); Vector rate_vec(n); size_t i; for(i = 0; i < n; i++) { size_t size = size_vec[i]; size_t repeat = 1; double s0 = elapsed_seconds(); double s1 = elapsed_seconds(); while( s1 - s0 < time_min ) { repeat = 2 * repeat; s0 = elapsed_seconds(); test(size, repeat); s1 = elapsed_seconds(); } rate_vec[i] = (size_t)(.5 + repeat / (s1 - s0)); } return rate_vec; } } // END CppAD namespace /* $begin SpeedTest$$ $spell cppad.hpp Microsoft namespace std const cout ctime ifdef const endif cpp $$ $section Run One Speed Test and Print Results$$ $mindex SpeedTest$$ $head Syntax$$ $codei%# include %$$ $codei%SpeedTest(%Test%, %first%, %inc%, %last%)%$$ $head Purpose$$ The $code SpeedTest$$ function executes a speed test for various sized problems and reports the results on standard output; i.e. $code std::cout$$. The size of each test problem is included in its report (unless $icode first$$ is equal to $icode last$$). $head Motivation$$ It is important to separate small calculation units and test them individually. This way individual changes can be tested in the context of the routine that they are in. On many machines, accurate timing of a very short execution sequences is not possible. In addition, there may be set up time for a test that we do not really want included in the timing. For this reason $code SpeedTest$$ automatically determines how many times to repeat the section of the test that we wish to time. $head Include$$ The file $code speed_test.hpp$$ contains the $code SpeedTest$$ function. This file is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head Test$$ The $code SpeedTest$$ argument $icode Test$$ is a function with the syntax $codei% %name% = %Test%(%size%, %repeat%) %$$ $subhead size$$ The $icode Test$$ argument $icode size$$ has prototype $codei% size_t %size% %$$ It specifies the size for this test. $subhead repeat$$ The $icode Test$$ argument $icode repeat$$ has prototype $codei% size_t %repeat% %$$ It specifies the number of times to repeat the test. $subhead name$$ The $icode Test$$ result $icode name$$ has prototype $codei% std::string %name% %$$ The results for this test are reported on $code std::cout$$ with $icode name$$ as an identifier for the test. It is assumed that, for the duration of this call to $code SpeedTest$$, $icode Test$$ will always return the same value for $icode name$$. If $icode name$$ is the empty string, no test name is reported by $code SpeedTest$$. $head first$$ The $code SpeedTest$$ argument $icode first$$ has prototype $codei% size_t %first% %$$ It specifies the size of the first test problem reported by this call to $code SpeedTest$$. $head last$$ The $code SpeedTest$$ argument $icode last$$ has prototype $codei% size_t %last% %$$ It specifies the size of the last test problem reported by this call to $code SpeedTest$$. $head inc$$ The $code SpeedTest$$ argument $icode inc$$ has prototype $codei% int %inc% %$$ It specifies the increment between problem sizes; i.e., all values of $icode size$$ in calls to $icode Test$$ are given by $codei% %size% = %first% + %j% * %inc% %$$ where $icode j$$ is a positive integer. The increment can be positive or negative but it cannot be zero. The values $icode first$$, $icode last$$ and $icode inc$$ must satisfy the relation $latex \[ inc * ( last - first ) \geq 0 \] $$ $head rate$$ The value displayed in the $code rate$$ column on $code std::cout$$ is defined as the value of $icode repeat$$ divided by the corresponding elapsed execution time in seconds. The elapsed execution time is measured by the difference in $codep (double) clock() / (double) CLOCKS_PER_SEC $$ in the context of the standard $code $$ definitions. $head Errors$$ If one of the restrictions above is violated, the CppAD error handler is used to report the error. You can redefine this action using the instructions in $cref ErrorHandler$$ $head Example$$ $children% speed/example/speed_program.cpp %$$ The program $cref speed_program.cpp$$ is an example usage of $code SpeedTest$$. $end ----------------------------------------------------------------------- */ // BEGIN C++ # include # include # include # include namespace CppAD { // BEGIN CppAD namespace inline void SpeedTestNdigit(size_t value, size_t &ndigit, size_t &pow10) { pow10 = 10; ndigit = 1; while( pow10 <= value ) { pow10 *= 10; ndigit += 1; } } // implemented as an inline so that can include in multiple link modules // with this same file inline void SpeedTest( std::string Test(size_t size, size_t repeat), size_t first, int inc, size_t last ) { using std::cout; using std::endl; size_t size; size_t repeat; size_t rate; size_t digit; size_t ndigit; size_t pow10; size_t maxSize; size_t maxSizeDigit; double s0; double s1; std::string name; CPPAD_ASSERT_KNOWN( inc != 0 && first != 0 && last != 0, "inc, first, or last is zero in call to SpeedTest" ); CPPAD_ASSERT_KNOWN( (inc > 0 && first <= last) || (inc < 0 && first >= last), "SpeedTest: increment is positive and first > last or " "increment is negative and first < last" ); // compute maxSize maxSize = size = first; while( (inc > 0 && size <= last) || (inc < 0 && size >= last) ) { if( size > maxSize ) maxSize = size; // next size if( ((int) size) + inc > 0 ) size += inc; else size = 0; } SpeedTestNdigit(maxSize, maxSizeDigit, pow10); size = first; while( (inc > 0 && size <= last) || (inc < 0 && size >= last) ) { repeat = 1; s0 = elapsed_seconds(); s1 = elapsed_seconds(); while( s1 - s0 < 1. ) { repeat = 2 * repeat; s0 = elapsed_seconds(); name = Test(size, repeat); s1 = elapsed_seconds(); } rate = (size_t)(.5 + repeat / (s1 - s0)); if( size == first && name != "" ) cout << name << endl; if( first != last ) { // convert int(size_t) to avoid warning on _MSC_VER sys std::cout << "size = " << int(size); SpeedTestNdigit(size, ndigit, pow10); while( ndigit < maxSizeDigit ) { cout << " "; ndigit++; } cout << " "; } cout << "rate = "; SpeedTestNdigit(rate, ndigit, pow10); while( ndigit > 0 ) { pow10 /= 10; digit = rate / pow10; // convert int(size_t) to avoid warning on _MSC_VER sys std::cout << int(digit); rate = rate % pow10; ndigit -= 1; if( (ndigit > 0) && (ndigit % 3 == 0) ) cout << ","; } cout << endl; // next size if( ((int) size) + inc > 0 ) size += inc; else size = 0; } return; } } // END CppAD namespace // END C++ # endif cppad-20160000.1/cppad/utility/check_numeric_type.hpp0000644000175200017650000001225412656321766021604 0ustar coincoin-web// $Id: check_numeric_type.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_CHECK_NUMERIC_TYPE_HPP # define CPPAD_CHECK_NUMERIC_TYPE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin CheckNumericType$$ $spell alloc cppad.hpp CppAD $$ $section Check NumericType Class Concept$$ $mindex numeric CheckNumericType$$ $head Syntax$$ $codei%# include %$$ $codei%CheckNumericType<%NumericType%>()%$$ $head Purpose$$ The syntax $codei% CheckNumericType<%NumericType%>() %$$ preforms compile and run time checks that the type specified by $icode NumericType$$ satisfies all the requirements for a $cref NumericType$$ class. If a requirement is not satisfied, a an error message makes it clear what condition is not satisfied. $head Include$$ The file $code cppad/check_numeric_type.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest if the CppAD include files. $head Parallel Mode$$ The routine $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ must be called before it can be used in $cref/parallel/ta_in_parallel/$$ mode. $head Example$$ $children% example/check_numeric_type.cpp %$$ The file $cref check_numeric_type.cpp$$ contains an example and test of this function. It returns true, if it succeeds an false otherwise. The comments in this example suggest a way to change the example so an error message occurs. $end --------------------------------------------------------------------------- */ # include # include namespace CppAD { # ifdef NDEBUG template void CheckNumericType(void) { } # else template NumericType CheckNumericType(void) { // Section 3.6.2 of ISO/IEC 14882:1998(E) states: "The storage for // objects with static storage duration (3.7.1) shall be zero- // initialized (8.5) before any other initialization takes place." static size_t count[CPPAD_MAX_NUM_THREADS]; size_t thread = thread_alloc::thread_num(); if( count[thread] > 0 ) return NumericType(0); count[thread]++; /* contructors */ NumericType check_NumericType_default_constructor; NumericType check_NumericType_constructor_from_int(1); const NumericType x(1); NumericType check_NumericType_copy_constructor(x); // assignment NumericType check_NumericType_assignment; check_NumericType_assignment = x; /* unary operators */ const NumericType check_NumericType_unary_plus(1); NumericType check_NumericType_unary_plus_result = + check_NumericType_unary_plus; const NumericType check_NumericType_unary_minus(1); NumericType check_NumericType_unary_minus_result = - check_NumericType_unary_minus; /* binary operators */ const NumericType check_NumericType_binary_addition(1); NumericType check_NumericType_binary_addition_result = check_NumericType_binary_addition + x; const NumericType check_NumericType_binary_subtraction(1); NumericType check_NumericType_binary_subtraction_result = check_NumericType_binary_subtraction - x; const NumericType check_NumericType_binary_multiplication(1); NumericType check_NumericType_binary_multiplication_result = check_NumericType_binary_multiplication * x; const NumericType check_NumericType_binary_division(1); NumericType check_NumericType_binary_division_result = check_NumericType_binary_division / x; /* computed assignment operators */ NumericType check_NumericType_computed_assignment_addition(1); check_NumericType_computed_assignment_addition += x; NumericType check_NumericType_computed_assignment_subtraction(1); check_NumericType_computed_assignment_subtraction -= x; NumericType check_NumericType_computed_assignment_multiplication(1); check_NumericType_computed_assignment_multiplication *= x; NumericType check_NumericType_computed_assignment_division(1); check_NumericType_computed_assignment_division /= x; /* use all values so as to avoid warnings */ check_NumericType_default_constructor = x; return + check_NumericType_default_constructor + check_NumericType_constructor_from_int + check_NumericType_copy_constructor + check_NumericType_assignment + check_NumericType_unary_plus_result + check_NumericType_unary_minus_result + check_NumericType_binary_addition_result + check_NumericType_binary_subtraction_result + check_NumericType_binary_multiplication_result + check_NumericType_binary_division_result + check_NumericType_computed_assignment_addition + check_NumericType_computed_assignment_subtraction + check_NumericType_computed_assignment_multiplication + check_NumericType_computed_assignment_division ; } # endif } // end namespace CppAD # endif cppad-20160000.1/cppad/utility/track_new_del.hpp0000644000175200017650000003327612656321766020554 0ustar coincoin-web// $Id: track_new_del.hpp 3769 2015-12-29 16:13:16Z bradbell $ # ifndef CPPAD_TRACK_NEW_DEL_HPP # define CPPAD_TRACK_NEW_DEL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin TrackNewDel$$ $spell cppad.hpp Cpp newptr Vec oldptr newlen ncopy const $$ $section Routines That Track Use of New and Delete$$ $mindex memory NDEBUG CPPAD_TRACK_NEW_VEC CppADTrackNewVec CPPAD_TRACK_DEL_VEC CppADTrackDelVec CPPAD_TRACK_EXTEND CppADTrackExtend CPPAD_TRACK_COUNT thread multi$$ $head Deprecated 2007-07-23$$ All these routines have been deprecated. You should use the $cref thread_alloc$$ memory allocator instead (which works better in both a single thread and properly in multi-threading environment). $head Syntax$$ $codei%# include %$$ $icode%newptr% = TrackNewVec(%file%, %line%, %newlen%, %oldptr%) %$$ $codei%TrackDelVec(%file%, %line%, %oldptr%) %$$ $icode%newptr% = TrackExtend(%file%, %line%, %newlen%, %ncopy%, %oldptr%) %$$ $icode%count% = TrackCount(%file%, %line%)%$$ $head Purpose$$ These routines aid in the use of $code new[]$$ and $code delete[]$$ during the execution of a C++ program. $head Include$$ The file $code cppad/track_new_del.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the CppAD include files. $head file$$ The argument $icode file$$ has prototype $codei% const char *%file% %$$ It should be the source code file name where the call to $code TrackNew$$ is located. The best way to accomplish this is the use the preprocessor symbol $code __FILE__$$ for this argument. $head line$$ The argument $icode line$$ has prototype $codei% int %line% %$$ It should be the source code file line number where the call to $code TrackNew$$ is located. The best way to accomplish this is the use the preprocessor symbol $code __LINE__$$ for this argument. $head oldptr$$ The argument $icode oldptr$$ has prototype $codei% %Type% *%oldptr% %$$ This argument is used to identify the type $icode Type$$. $head newlen$$ The argument $icode newlen$$ has prototype $codei% size_t %newlen% %$$ $head head newptr$$ The return value $icode newptr$$ has prototype $codei% %Type% *%newptr% %$$ It points to the newly allocated vector of objects that were allocated using $codei% new Type[%newlen%] %$$ $head ncopy$$ The argument $icode ncopy$$ has prototype $codei% size_t %ncopy% %$$ This specifies the number of elements that are copied from the old array to the new array. The value of $icode ncopy$$ must be less than or equal $icode newlen$$. $head TrackNewVec$$ If $code NDEBUG$$ is defined, this routine only sets $codei% %newptr% = %Type% new[%newlen%] %$$ The value of $icode oldptr$$ does not matter (except that it is used to identify $icode Type$$). If $code NDEBUG$$ is not defined, $code TrackNewVec$$ also tracks the this memory allocation. In this case, if memory cannot be allocated $cref ErrorHandler$$ is used to generate a message stating that there was not sufficient memory. $subhead Macro$$ The preprocessor macro call $codei% CPPAD_TRACK_NEW_VEC(%newlen%, %oldptr%) %$$ expands to $codei% CppAD::TrackNewVec(__FILE__, __LINE__, %newlen%, %oldptr%) %$$ $subhead Previously Deprecated$$ The preprocessor macro $code CppADTrackNewVec$$ is the same as $code CPPAD_TRACK_NEW_VEC$$ and was previously deprecated. $head TrackDelVec$$ This routine is used to a vector of objects that have been allocated using $code TrackNew$$ or $code TrackExtend$$. If $code NDEBUG$$ is defined, this routine only frees memory with $codei% delete [] %oldptr% %$$ If $code NDEBUG$$ is not defined, $code TrackDelete$$ also checks that $icode oldptr$$ was allocated by $code TrackNew$$ or $code TrackExtend$$ and has not yet been freed. If this is not the case, $cref ErrorHandler$$ is used to generate an error message. $subhead Macro$$ The preprocessor macro call $codei% CPPAD_TRACK_DEL_VEC(%oldptr%) %$$ expands to $codei% CppAD::TrackDelVec(__FILE__, __LINE__, %oldptr%) %$$ $subhead Previously Deprecated$$ The preprocessor macro $code CppADTrackDelVec$$ is the same as $code CPPAD_TRACK_DEL_VEC$$ was previously deprecated. $head TrackExtend$$ This routine is used to allocate a new vector (using $code TrackNewVec$$), copy $icode ncopy$$ elements from the old vector to the new vector. If $icode ncopy$$ is greater than zero, $icode oldptr$$ must have been allocated using $code TrackNewVec$$ or $code TrackExtend$$. In this case, the vector pointed to by $icode oldptr$$ must be have at least $icode ncopy$$ elements and it will be deleted (using $code TrackDelVec$$). Note that the dependence of $code TrackExtend$$ on $code NDEBUG$$ is indirectly through the routines $code TrackNewVec$$ and $code TrackDelVec$$. $subhead Macro$$ The preprocessor macro call $codei% CPPAD_TRACK_EXTEND(%newlen%, %ncopy%, %oldptr%) %$$ expands to $codei% CppAD::TrackExtend(__FILE__, __LINE__, %newlen%, %ncopy%, %oldptr%) %$$ $subhead Previously Deprecated$$ The preprocessor macro $code CppADTrackExtend$$ is the same as $code CPPAD_TRACK_EXTEND$$ and was previously deprecated. $head TrackCount$$ The return value $icode count$$ has prototype $codei% size_t %count% %$$ If $code NDEBUG$$ is defined, $icode count$$ will be zero. Otherwise, it will be the number of vectors that have been allocated (by $code TrackNewVec$$ or $code TrackExtend$$) and not yet freed (by $code TrackDelete$$). $subhead Macro$$ The preprocessor macro call $codei% CPPAD_TRACK_COUNT() %$$ expands to $codei% CppAD::TrackCount(__FILE__, __LINE__) %$$ $subhead Previously Deprecated$$ The preprocessor macro $code CppADTrackCount$$ is the same as $code CPPAD_TRACK_COUNT$$ and was previously deprecated. $head Multi-Threading$$ These routines cannot be used $cref/in_parallel/ta_in_parallel/$$ execution mode. Use the $cref thread_alloc$$ routines instead. $head Example$$ $children% test_more/track_new_del.cpp %$$ The file $cref TrackNewDel.cpp$$ contains an example and test of these functions. It returns true, if it succeeds, and false otherwise. $end ------------------------------------------------------------------------------ */ # include # include # include # include # include # ifndef CPPAD_TRACK_DEBUG # define CPPAD_TRACK_DEBUG 0 # endif // ------------------------------------------------------------------------- # define CPPAD_TRACK_NEW_VEC(newlen, oldptr) \ CppAD::TrackNewVec(__FILE__, __LINE__, newlen, oldptr) # define CPPAD_TRACK_DEL_VEC(oldptr) \ CppAD::TrackDelVec(__FILE__, __LINE__, oldptr) # define CPPAD_TRACK_EXTEND(newlen, ncopy, oldptr) \ CppAD::TrackExtend(__FILE__, __LINE__, newlen, ncopy, oldptr) # define CPPAD_TRACK_COUNT() \ CppAD::TrackCount(__FILE__, __LINE__) // ------------------------------------------------------------------------- # define CppADTrackNewVec CPPAD_TRACK_NEW_VEC # define CppADTrackDelVec CPPAD_TRACK_DEL_VEC # define CppADTrackExtend CPPAD_TRACK_EXTEND # define CppADTrackCount CPPAD_TRACK_COUNT // ------------------------------------------------------------------------- namespace CppAD { // Begin CppAD namespace // TrackElement ------------------------------------------------------------ class TrackElement { public: std::string file; // corresponding file name int line; // corresponding line number void *ptr; // value returned by TrackNew TrackElement *next; // next element in linked list // default contructor (used to initialize root) TrackElement(void) : file(""), line(0), ptr(CPPAD_NULL), next(CPPAD_NULL) { } TrackElement(const char *f, int l, void *p) : file(f), line(l), ptr(p), next(CPPAD_NULL) { CPPAD_ASSERT_UNKNOWN( p != CPPAD_NULL); } // There is only one tracking list and it starts it here static TrackElement *Root(void) { CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); static TrackElement root; return &root; } // Print one tracking element static void Print(TrackElement* E) { CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); using std::cout; cout << "E = " << E; cout << ", E->next = " << E->next; cout << ", E->ptr = " << E->ptr; cout << ", E->line = " << E->line; cout << ", E->file = " << E->file; cout << std::endl; } // Print the linked list for a thread static void Print(void) { CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); using std::cout; using std::endl; TrackElement *E = Root(); // convert int(size_t) to avoid warning on _MSC_VER systems cout << "Begin Track List" << endl; while( E->next != CPPAD_NULL ) { E = E->next; Print(E); } cout << "End Track List:" << endl; cout << endl; } }; // TrackError ---------------------------------------------------------------- inline void TrackError( const char *routine, const char *file, int line, const char *msg ) { CPPAD_ASSERT_UNKNOWN( ! thread_alloc::in_parallel() ); std::ostringstream buf; buf << routine << ": at line " << line << " in file " << file << std::endl << msg; std::string str = buf.str(); size_t n = str.size(); size_t i; char *message = new char[n + 1]; for(i = 0; i < n; i++) message[i] = str[i]; message[n] = '\0'; CPPAD_ASSERT_KNOWN( false , message); } // TrackNewVec --------------------------------------------------------------- # ifdef NDEBUG template inline Type *TrackNewVec( const char *file, int line, size_t len, Type * /* oldptr */ ) { # if CPPAD_TRACK_DEBUG static bool first = true; if( first ) { std::cout << "NDEBUG is defined for TrackNewVec" << std::endl; first = false; } # endif return (new Type[len]); } # else template Type *TrackNewVec( const char *file , int line , size_t len , Type * /* oldptr */ ) { CPPAD_ASSERT_KNOWN( ! thread_alloc::in_parallel() , "attempt to use TrackNewVec in parallel execution mode." ); // try to allocate the new memrory Type *newptr = CPPAD_NULL; try { newptr = new Type[len]; } catch(...) { TrackError("TrackNewVec", file, line, "Cannot allocate sufficient memory" ); } // create tracking element void *vptr = static_cast(newptr); TrackElement *E = new TrackElement(file, line, vptr); // get the root TrackElement *root = TrackElement::Root(); // put this elemenent at the front of linked list E->next = root->next; root->next = E; # if CPPAD_TRACK_DEBUG std::cout << "TrackNewVec: "; TrackElement::Print(E); # endif return newptr; } # endif // TrackDelVec -------------------------------------------------------------- # ifdef NDEBUG template inline void TrackDelVec(const char *file, int line, Type *oldptr) { # if CPPAD_TRACK_DEBUG static bool first = true; if( first ) { std::cout << "NDEBUG is defined in TrackDelVec" << std::endl; first = false; } # endif delete [] oldptr; } # else template void TrackDelVec( const char *file , int line , Type *oldptr ) { CPPAD_ASSERT_KNOWN( ! thread_alloc::in_parallel() , "attempt to use TrackDelVec in parallel execution mode." ); TrackElement *P; TrackElement *E; // search list for pointer P = TrackElement::Root(); E = P->next; void *vptr = static_cast(oldptr); while(E != CPPAD_NULL && E->ptr != vptr) { P = E; E = E->next; } // check if pointer was not in list if( E == CPPAD_NULL || E->ptr != vptr ) TrackError( "TrackDelVec", file, line, "Invalid value for the argument oldptr.\n" "Possible linking of debug and NDEBUG compilations of CppAD." ); # if CPPAD_TRACK_DEBUG std::cout << "TrackDelVec: "; TrackElement::Print(E); # endif // remove tracking element from list P->next = E->next; // delete allocated pointer delete [] oldptr; // delete tracking element delete E; return; } # endif // TrackExtend -------------------------------------------------------------- template Type *TrackExtend( const char *file , int line , size_t newlen , size_t ncopy , Type *oldptr ) { CPPAD_ASSERT_KNOWN( ! thread_alloc::in_parallel() , "attempt to use TrackExtend in parallel execution mode." ); # if CPPAD_TRACK_DEBUG using std::cout; cout << "TrackExtend: file = " << file; cout << ", line = " << line; cout << ", newlen = " << newlen; cout << ", ncopy = " << ncopy; cout << ", oldptr = " << oldptr; cout << std::endl; # endif CPPAD_ASSERT_KNOWN( ncopy <= newlen, "TrackExtend: ncopy is greater than newlen." ); // allocate the new memrory Type *newptr = TrackNewVec(file, line, newlen, oldptr); // copy the data size_t i; for(i = 0; i < ncopy; i++) newptr[i] = oldptr[i]; // delete the old vector if( ncopy > 0 ) TrackDelVec(file, line, oldptr); return newptr; } // TrackCount -------------------------------------------------------------- inline size_t TrackCount(const char *file, int line) { CPPAD_ASSERT_KNOWN( ! thread_alloc::in_parallel() , "attempt to use TrackCount in parallel execution mode." ); size_t count = 0; TrackElement *E = TrackElement::Root(); while( E->next != CPPAD_NULL ) { ++count; E = E->next; } return count; } // --------------------------------------------------------------------------- } // End CppAD namespace // preprocessor symbols local to this file # undef CPPAD_TRACK_DEBUG # endif cppad-20160000.1/cppad/utility/vector.hpp0000644000175200017650000005760012656321766017252 0ustar coincoin-web// $Id: vector.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_VECTOR_HPP # define CPPAD_VECTOR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin CppAD_vector$$ $spell rvalues thread_alloc cppad.hpp Bool resize cout endl std Cpp const vec ostream elem $$ $section The CppAD::vector Template Class$$ $mindex vector CppAD [] push thread_alloc$$ $head Syntax$$ $code%# include $$ $head Description$$ The include file $code cppad/vector.hpp$$ defines the vector template class $code CppAD::vector$$. This is a $cref SimpleVector$$ template class and in addition it has the features listed below: $head Include$$ The file $code cppad/vector.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the CppAD include files. $head capacity$$ If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$, and $icode cap$$ is a $code size_t$$ object, $codei% %cap% = %x%.capacity() %$$ set $icode cap$$ to the number of $icode Scalar$$ objects that could fit in the memory currently allocated for $icode x$$. Note that $codei% %x%.size() <= %x%.capacity() %$$ $head Assignment$$ If $icode x$$ and $icode y$$ are $codei%CppAD::vector<%Scalar%>%$$ objects, $codei% %y% = %x% %$$ has all the properties listed for a $cref/simple vector assignment/SimpleVector/Assignment/$$ plus the following: $subhead Check Size$$ The $code CppAD::vector$$ template class will check that the size of $icode x$$ is either zero or the size of $icode y$$ before doing the assignment. If this is not the case, $code CppAD::vector$$ will use $cref ErrorHandler$$ to generate an appropriate error report. Allowing for assignment to a vector with size zero makes the following code work: $codei% CppAD::vector<%Scalar%> %y%; %y% = %x%; %$$ $subhead Return Reference$$ A reference to the vector $icode y$$ is returned. An example use of this reference is in multiple assignments of the form $codei% %z% = %y% = %x% %$$ $subhead Move Semantics$$ If the C++ compiler supports move semantic rvalues using the $code &&$$ syntax, then it will be used during the vector assignment statement. This means that return values and other temporaries are not be copied, but rather pointers are transferred. $head Element Access$$ If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object and $code i$$ has type $code size_t$$, $codei% %x%[%i%] %$$ has all the properties listed for a $cref/simple vector element access/SimpleVector/Element Access/$$ plus the following: $pre $$ The object $icode%x%[%i%]%$$ has type $icode Scalar$$ (is not possibly a different type that can be converted to $icode Scalar$$). $pre $$ If $icode i$$ is not less than the size of the $icode x$$, $code CppAD::vector$$ will use $cref ErrorHandler$$ to generate an appropriate error report. $head push_back$$ If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object with size equal to $icode n$$ and $icode s$$ has type $icode Scalar$$, $codei% %x%.push_back(%s%) %$$ extends the vector $icode x$$ so that its new size is $icode n$$ plus one and $icode%x%[%n%]%$$ is equal to $icode s$$ (equal in the sense of the $icode Scalar$$ assignment operator). $head push_vector$$ If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object with size equal to $icode n$$ and $icode v$$ is a $cref/simple vector/SimpleVector/$$ with elements of type $icode Scalar$$ and size $icode m$$, $codei% %x%.push_vector(%v%) %$$ extends the vector $icode x$$ so that its new size is $icode%n%+%m%$$ and $icode%x%[%n% + %i%]%$$ is equal to $icode%v%[%i%]%$$ for $icode%i = 1 , ... , m-1%$$ (equal in the sense of the $icode Scalar$$ assignment operator). $head Output$$ If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object and $icode os$$ is an $code std::ostream$$, and the operation $codei% %os% << %x% %$$ will output the vector $icode x$$ to the standard output stream $icode os$$. The elements of $icode x$$ are enclosed at the beginning by a $code {$$ character, they are separated by $code ,$$ characters, and they are enclosed at the end by $code }$$ character. It is assumed by this operation that if $icode e$$ is an object with type $icode Scalar$$, $codei% %os% << %e% %$$ will output the value $icode e$$ to the standard output stream $icode os$$. $head resize$$ The call $icode%x%.resize(%n%)%$$ set the size of $icode x$$ equal to $icode n$$. If $icode%n% <= %x%.capacity()%$$, no memory is freed or allocated, the capacity of $icode x$$ does not change, and the data in $icode x$$ is preserved. If $icode%n% > %x%.capacity()%$$, new memory is allocated and the data in $icode x$$ is lost (not copied to the new memory location). $head clear$$ All memory allocated for the vector is freed and both its size and capacity are set to zero. The can be useful when using very large vectors and when checking for memory leaks (and there are global vectors) see the $cref/memory/CppAD_vector/Memory and Parallel Mode/$$ discussion. $head data$$ If $icode x$$ is a $codei%CppAD::vector<%Scalar%>%$$ object $codei% %x%.data() %$$ returns a pointer to a $icode Scalar$$ object such that for $codei%0 <= %i% < %x%.size()%$$, $icode%x%[%i%]%$$ and $icode%x%.data()[%i%]%$$ are the same $icode Scalar$$ object. If $icode x$$ is $code const$$, the pointer is $code const$$. If $icode%x%.capacity()%$$ is zero, the value of the pointer is not defined. The pointer may no longer be valid after the following operations on $icode x$$: its destructor, $code clear$$, $code resize$$, $code push_back$$, $code push_vector$$, assignment to another vector when original size of $icode x$$ is zero. $head vectorBool$$ The file $code $$ also defines the class $code CppAD::vectorBool$$. This has the same specifications as $code CppAD::vector$$ with the following exceptions: $subhead Memory$$ The class $code vectorBool$$ conserves on memory (on the other hand, $code CppAD::vector$$ is expected to be faster than $code vectorBool$$). $subhead bit_per_unit$$ The static function call $codei% %s% = vectorBool::bit_per_unit() %$$ returns the $code size_t$$ value $icode s$$ which is equal to the number of boolean values (bits) that are packed into one operational unit. For example, a logical $code or$$ acts on this many boolean values with one operation. $subhead data$$ The $cref/data/CppAD_vector/data/$$ function is not supported by $code vectorBool$$. $subhead Output$$ The $code CppAD::vectorBool$$ output operator prints each boolean value as a $code 0$$ for false, a $code 1$$ for true, and does not print any other output; i.e., the vector is written a long sequence of zeros and ones with no surrounding $code {$$, $code }$$ and with no separating commas or spaces. $subhead Element Type$$ If $icode x$$ has type $code vectorBool$$ and $icode i$$ has type $code size_t$$, the element access value $icode%x%[%i%]%$$ has an unspecified type, referred to here as $icode elementType$$, that supports the following operations: $list number$$ $icode elementType$$ can be converted to $code bool$$; e.g. the following syntax is supported: $codei% static_cast( %x%[%i%] ) %$$ $lnext $icode elementType$$ supports the assignment operator $code =$$ where the right hand side is a $code bool$$ or an $icode elementType$$ object; e.g., if $icode y$$ has type $code bool$$, the following syntax is supported: $codei% %x%[%i%] = %y% %$$ $lnext The result of an assignment to an $icode elementType$$ also has type $icode elementType$$. Thus, if $icode z$$ has type $code bool$$, the following syntax is supported: $codei% %z% = %x%[%i%] = %y% %$$ $lend $head Memory and Parallel Mode$$ These vectors use the multi-threaded fast memory allocator $cref thread_alloc$$: $list number$$ The routine $cref/parallel_setup/ta_parallel_setup/$$ must be called before these vectors can be used $cref/in parallel/ta_in_parallel/$$. $lnext Using these vectors affects the amount of memory $cref/in_use/ta_inuse/$$ and $cref/available/ta_available/$$. $lnext Calling $cref/clear/CppAD_vector/clear/$$, makes the corresponding memory available (though $code thread_alloc$$) to the current thread. $lnext Available memory can then be completely freed using $cref/free_available/ta_free_available/$$. $lend $head Example$$ $children% example/cppad_vector.cpp% example/vector_bool.cpp %$$ The files $cref cppad_vector.cpp$$ and $cref vector_bool.cpp$$ each contain an example and test of this template class. They return true if they succeed and false otherwise. $head Exercise$$ Create and run a program that contains the following code: $codep CppAD::vector x(3); size_t i; for(i = 0; i < 3; i++) x[i] = 4. - i; std::cout << "x = " << x << std::endl; $$ $end $end ------------------------------------------------------------------------ */ # include # include # include # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file vector.hpp File used to define CppAD::vector and CppAD::vectorBool */ // --------------------------------------------------------------------------- /*! The CppAD Simple Vector template class. */ template class vector { private: /// maximum number of Type elements current allocation can hold size_t capacity_; /// number of Type elements currently in this vector size_t length_; /// pointer to the first type elements /// (not defined and should not be used when capacity_ = 0) Type* data_; /// delete data pointer void delete_data(Type* data_ptr) { thread_alloc::delete_array(data_ptr); } public: /// type of the elements in the vector typedef Type value_type; /// default constructor sets capacity_ = length_ = data_ = 0 inline vector(void) : capacity_(0), length_(0), data_(CPPAD_NULL) { } /// sizing constructor inline vector( /// number of elements in this vector size_t n ) : capacity_(0), length_(0), data_(CPPAD_NULL) { resize(n); } /// copy constructor inline vector( /// the *this vector will be a copy of \c x const vector& x ) : capacity_(0), length_(0), data_(CPPAD_NULL) { resize(x.length_); // copy the data for(size_t i = 0; i < length_; i++) data_[i] = x.data_[i]; } /// destructor ~vector(void) { if( capacity_ > 0 ) delete_data(data_); } /// maximum number of elements current allocation can store inline size_t capacity(void) const { return capacity_; } /// number of elements currently in this vector. inline size_t size(void) const { return length_; } /// raw pointer to the data inline Type* data(void) { return data_; } /// const raw pointer to the data inline const Type* data(void) const { return data_; } /// change the number of elements in this vector. inline void resize( /// new number of elements for this vector size_t n ) { length_ = n; // check if we can use current memory if( capacity_ >= length_ ) return; // check if there is old memory to be freed if( capacity_ > 0 ) delete_data(data_); // get new memory and set capacity data_ = thread_alloc::create_array(length_, capacity_); } /// free memory and set number of elements to zero inline void clear(void) { length_ = 0; // check if there is old memory to be freed if( capacity_ > 0 ) delete_data(data_); capacity_ = 0; } /// vector assignment operator inline vector& operator=( /// right hand size of the assingment operation const vector& x ) { size_t i; // If original lenght is zero, then resize it. // Otherwise a length mismatch is an error. if( length_ == 0 ) resize( x.length_ ); CPPAD_ASSERT_KNOWN( length_ == x.length_ , "vector: size miss match in assignment operation" ); for(i = 0; i < length_; i++) data_[i] = x.data_[i]; return *this; } # if CPPAD_USE_CPLUSPLUS_2011 /// vector assignment operator with move semantics inline vector& operator=( /// right hand size of the assingment operation vector&& x ) { CPPAD_ASSERT_KNOWN( length_ == x.length_ || (length_ == 0), "vector: size miss match in assignment operation" ); if( this != &x ) { clear(); // length_ = x.length_; capacity_ = x.capacity_; data_ = x.data_; // x.length_ = 0; x.capacity_ = 0; x.data_ = CPPAD_NULL; } return *this; } # endif /// non-constant element access; i.e., we can change this element value Type& operator[]( /// element index, must be less than length size_t i ) { CPPAD_ASSERT_KNOWN( i < length_, "vector: index greater than or equal vector size" ); return data_[i]; } /// constant element access; i.e., we cannot change this element value const Type& operator[]( /// element index, must be less than length size_t i ) const { CPPAD_ASSERT_KNOWN( i < length_, "vector: index greater than or equal vector size" ); return data_[i]; } /// add an element to the back of this vector void push_back( /// value of the element const Type& s ) { // case where no allocation is necessary if( length_ + 1 <= capacity_ ) { data_[length_++] = s; return; } CPPAD_ASSERT_UNKNOWN( length_ == capacity_ ); // store old length, capacity and data size_t old_length = length_; size_t old_capacity = capacity_; Type* old_data = data_; // set the new length, capacity and data length_ = 0; capacity_ = 0; resize(old_length + 1); // copy old data values for(size_t i = 0; i < old_length; i++) data_[i] = old_data[i]; // put the new element in the vector CPPAD_ASSERT_UNKNOWN( old_length + 1 <= capacity_ ); data_[old_length] = s; // free old data if( old_capacity > 0 ) delete_data(old_data); CPPAD_ASSERT_UNKNOWN( old_length + 1 == length_ ); CPPAD_ASSERT_UNKNOWN( length_ <= capacity_ ); } /*! add vector to the back of this vector (we could not use push_back becasue MS V++ 7.1 did not resolve to non-template member function when scalar is used.) */ template void push_vector( /// value of the vector that we are adding const Vector& v ) { CheckSimpleVector(); size_t m = v.size(); // case where no allcoation is necessary if( length_ + m <= capacity_ ) { for(size_t i = 0; i < m; i++) data_[length_++] = v[i]; return; } // store old length, capacity and data size_t old_length = length_; size_t old_capacity = capacity_; Type* old_data = data_; // set new length, capacity and data length_ = 0; capacity_ = 0; resize(old_length + m); // copy old data values for(size_t i = 0; i < old_length; i++) data_[i] = old_data[i]; // put the new elements in the vector CPPAD_ASSERT_UNKNOWN( old_length + m <= capacity_ ); for(size_t i = 0; i < m; i++) data_[old_length + i] = v[i]; // free old data if( old_capacity > 0 ) delete_data(old_data); CPPAD_ASSERT_UNKNOWN( old_length + m == length_ ); CPPAD_ASSERT_UNKNOWN( length_ <= capacity_ ); } }; /// output a vector template inline std::ostream& operator << ( /// stream to write the vector to std::ostream& os , /// vector that is output const CppAD::vector& vec ) { size_t i = 0; size_t n = vec.size(); os << "{ "; while(i < n) { os << vec[i++]; if( i < n ) os << ", "; } os << " }"; return os; } // --------------------------------------------------------------------------- /*! Class that is used to hold a non-constant element of a vector. */ class vectorBoolElement { /// the boolean data is packed with sizeof(UnitType) bits per value typedef size_t UnitType; private: /// pointer to the UnitType value holding this eleemnt UnitType* unit_; /// mask for the bit corresponding to this element /// (all zero except for bit that corresponds to this element) UnitType mask_; public: /// constructor from member values vectorBoolElement( /// unit for this element UnitType* unit , /// mask for this element UnitType mask ) : unit_(unit) , mask_(mask) { } /// constuctor from another element vectorBoolElement( /// other element const vectorBoolElement& e ) : unit_(e.unit_) , mask_(e.mask_) { } /// conversion to a boolean value operator bool() const { return (*unit_ & mask_) != 0; } /// assignment of this element to a bool vectorBoolElement& operator=( /// right hand side for assignment bool bit ) { if(bit) *unit_ |= mask_; else *unit_ &= ~mask_; return *this; } /// assignment of this element to another element vectorBoolElement& operator=(const vectorBoolElement& e) { if( *(e.unit_) & e.mask_ ) *unit_ |= mask_; else *unit_ &= ~mask_; return *this; } }; class vectorBool { /// the boolean data is packed with sizeof(UnitType) bits per value typedef size_t UnitType; private: /// number of bits packed into each UnitType value in data_ static const size_t bit_per_unit_ = std::numeric_limits::digits; /// number of UnitType values in data_ size_t n_unit_; /// number of bits currently stored in this vector size_t length_; /// pointer to where the bits are stored UnitType *data_; /// minimum number of UnitType values that can store length_ bits /// (note that this is really a function of length_) size_t unit_min(void) { if( length_ == 0 ) return 0; return (length_ - 1) / bit_per_unit_ + 1; } public: /// type corresponding to the elements of this vector /// (note that non-const elements actually use vectorBoolElement) typedef bool value_type; // static member function static size_t bit_per_unit(void) { return bit_per_unit_; } /// default constructor (sets all member data to zero) inline vectorBool(void) : n_unit_(0), length_(0), data_(CPPAD_NULL) { } /// sizing constructor inline vectorBool( /// number of bits in this vector size_t n ) : n_unit_(0), length_(n), data_(CPPAD_NULL) { if( length_ > 0 ) { // set n_unit and data size_t min_unit = unit_min(); data_ = thread_alloc::create_array(min_unit, n_unit_); } } /// copy constructor inline vectorBool( /// the *this vector will be a copy of \c v const vectorBool& v ) : n_unit_(0), length_(v.length_), data_(CPPAD_NULL) { if( length_ > 0 ) { // set n_unit and data size_t min_unit = unit_min(); data_ = thread_alloc::create_array(min_unit, n_unit_); // copy values using UnitType assignment operator CPPAD_ASSERT_UNKNOWN( min_unit <= v.n_unit_ ); size_t i; for(i = 0; i < min_unit; i++) data_[i] = v.data_[i]; } } /// destructor ~vectorBool(void) { if( n_unit_ > 0 ) thread_alloc::delete_array(data_); } /// number of elements in this vector inline size_t size(void) const { return length_; } /// maximum number of elements current allocation can store inline size_t capacity(void) const { return n_unit_ * bit_per_unit_; } /// change number of elements in this vector inline void resize( /// new number of elements for this vector size_t n ) { length_ = n; // check if we can use the current memory size_t min_unit = unit_min(); if( n_unit_ >= min_unit ) return; // check if there is old memory to be freed if( n_unit_ > 0 ) thread_alloc::delete_array(data_); // get new memory and set n_unit data_ = thread_alloc::create_array(min_unit, n_unit_); } /// free memory and set number of elements to zero inline void clear(void) { length_ = 0; // check if there is old memory to be freed if( n_unit_ > 0 ) thread_alloc::delete_array(data_); n_unit_ = 0; } /// vector assignment operator inline vectorBool& operator=( /// right hand size of the assingment operation const vectorBool& v ) { size_t i; // If original lenght is zero, then resize it. // Otherwise a length mismatch is an error. if( length_ == 0 ) resize( v.length_ ); CPPAD_ASSERT_KNOWN( length_ == v.length_ , "vectorBool: size miss match in assignment operation" ); size_t min_unit = unit_min(); CPPAD_ASSERT_UNKNOWN( min_unit <= n_unit_ ); CPPAD_ASSERT_UNKNOWN( min_unit <= v.n_unit_ ); for(i = 0; i < min_unit; i++) data_[i] = v.data_[i]; return *this; } # if CPPAD_USE_CPLUSPLUS_2011 /// vector assignment operator with move semantics inline vectorBool& operator=( /// right hand size of the assingment operation vectorBool&& x ) { CPPAD_ASSERT_KNOWN( length_ == x.length_ || (length_ == 0), "vectorBool: size miss match in assignment operation" ); if( this != &x ) { clear(); // length_ = x.length_; n_unit_ = x.n_unit_; data_ = x.data_; // x.length_ = 0; x.n_unit_ = 0; x.data_ = CPPAD_NULL; } return *this; } # endif /// non-constant element access; i.e., we can change this element value vectorBoolElement operator[]( /// element index, must be less than length size_t k ) { size_t i, j; CPPAD_ASSERT_KNOWN( k < length_, "vectorBool: index greater than or equal vector size" ); i = k / bit_per_unit_; j = k - i * bit_per_unit_; return vectorBoolElement(data_ + i , UnitType(1) << j ); } /// constant element access; i.e., we cannot change this element value bool operator[](size_t k) const { size_t i, j; UnitType unit, mask; CPPAD_ASSERT_KNOWN( k < length_, "vectorBool: index greater than or equal vector size" ); i = k / bit_per_unit_; j = k - i * bit_per_unit_; unit = data_[i]; mask = UnitType(1) << j; return (unit & mask) != 0; } /// add an element to the back of this vector void push_back( /// value of the element bool bit ) { CPPAD_ASSERT_UNKNOWN( unit_min() <= n_unit_ ); size_t i, j; UnitType mask; if( length_ + 1 > n_unit_ * bit_per_unit_ ) { CPPAD_ASSERT_UNKNOWN( unit_min() == n_unit_ ); // store old n_unit and data values size_t old_n_unit = n_unit_; UnitType* old_data = data_; // set new n_unit and data values data_ = thread_alloc::create_array(n_unit_+1, n_unit_); // copy old data values for(i = 0; i < old_n_unit; i++) data_[i] = old_data[i]; // free old data if( old_n_unit > 0 ) thread_alloc::delete_array(old_data); } i = length_ / bit_per_unit_; j = length_ - i * bit_per_unit_; mask = UnitType(1) << j; if( bit ) data_[i] |= mask; else data_[i] &= ~mask; length_++; } /// add vector to the back of this vector template void push_vector( /// value of the vector that we are adding const Vector& v ) { CheckSimpleVector(); size_t min_unit = unit_min(); CPPAD_ASSERT_UNKNOWN( length_ <= n_unit_ * bit_per_unit_ ); // some temporaries size_t i, j, k, ell; UnitType mask; bool bit; // store old length size_t old_length = length_; // new length and minium number of units; length_ = length_ + v.size(); min_unit = unit_min(); if( length_ >= n_unit_ * bit_per_unit_ ) { // store old n_unit and data value size_t old_n_unit = n_unit_; UnitType* old_data = data_; // set new n_unit and data values data_ = thread_alloc::create_array(min_unit, n_unit_); // copy old data values for(i = 0; i < old_n_unit; i++) data_[i] = old_data[i]; // free old data if( old_n_unit > 0 ) thread_alloc::delete_array(old_data); } ell = old_length; for(k = 0; k < v.size(); k++) { i = ell / bit_per_unit_; j = ell - i * bit_per_unit_; bit = v[k]; mask = UnitType(1) << j; if( bit ) data_[i] |= mask; else data_[i] &= ~mask; ell++; } CPPAD_ASSERT_UNKNOWN( length_ == ell ); CPPAD_ASSERT_UNKNOWN( length_ <= n_unit_ * bit_per_unit_ ); } }; /// output a vector inline std::ostream& operator << ( /// steam to write the vector to std::ostream& os , /// vector that is output const vectorBool& v ) { size_t i = 0; size_t n = v.size(); while(i < n) os << v[i++]; return os; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/utility/memory_leak.hpp0000644000175200017650000001515512656321766020253 0ustar coincoin-web// $Id: memory_leak.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_MEMORY_LEAK_HPP # define CPPAD_MEMORY_LEAK_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin memory_leak$$ $spell cppad num alloc hpp bool inuse $$ $section Memory Leak Detection$$ $mindex memory_leak check static$$ $head Deprecated 2012-04-06$$ This routine has been deprecated. You should instead use the routine $cref ta_free_all$$. $head Syntax$$ $codei%# include %$$ $icode%flag% = %memory_leak() %$$ $icode%flag% = %memory_leak(%add_static%)%$$ $head Purpose$$ This routine checks that the are no memory leaks caused by improper use of $cref thread_alloc$$ memory allocator. The deprecated memory allocator $cref TrackNewDel$$ is also checked. Memory errors in the deprecated $cref omp_alloc$$ allocator are reported as being in $code thread_alloc$$. $head thread$$ It is assumed that $cref/in_parallel()/ta_in_parallel/$$ is false and $cref/thread_num/ta_thread_num/$$ is zero when $code memory_leak$$ is called. $head add_static$$ This argument has prototype $codei% size_t %add_static% %$$ and its default value is zero. Static variables hold onto memory forever. If the argument $icode add_static$$ is present (and non-zero), $code memory_leak$$ adds this amount of memory to the $cref/inuse/ta_inuse/$$ sum that corresponds to static variables in the program. A call with $icode add_static$$ should be make after a routine that has static variables which use $cref/get_memory/ta_get_memory/$$ to allocate memory. The value of $icode add_static$$ should be the difference of $codei% thread_alloc::inuse(0) %$$ before and after the call. Since multiple statics may be allocated in different places in the program, it is expected that there will be multiple calls that use this option. $head flag$$ The return value $icode flag$$ has prototype $codei% bool %flag% %$$ If $icode add_static$$ is non-zero, the return value for $code memory_leak$$ is false. Otherwise, the return value for $code memory_leak$$ should be false (indicating that the only allocated memory corresponds to static variables). $head inuse$$ It is assumed that, when $code memory_leak$$ is called, there should not be any memory $cref/inuse/ta_inuse/$$ or $cref omp_inuse$$ for any thread (except for inuse memory corresponding to static variables). If there is, a message is printed and $code memory_leak$$ returns false. $head available$$ It is assumed that, when $code memory_leak$$ is called, there should not be any memory $cref/available/ta_available/$$ or $cref omp_available$$ for any thread; i.e., it all has been returned to the system. If there is memory still available for any thread, $code memory_leak$$ returns false. $head TRACK_COUNT$$ It is assumed that, when $code memory_leak$$ is called, $cref/TrackCount/TrackNewDel/TrackCount/$$ will return a zero value. If it returns a non-zero value, $code memory_leak$$ returns false. $head Error Message$$ If this is the first call to $code memory_leak$$, no message is printed. Otherwise, if it returns true, an error message is printed to standard output describing the memory leak that was detected. $end */ # include # include # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file memory_leak.hpp File that implements a memory check at end of a CppAD program */ /*! Function that checks allocator \c thread_alloc for misuse that results in memory leaks. Deprecated routines in track_new_del.hpp and omp_alloc.hpp are also checked. \param add_static [in] The amount specified by \c add_static is added to the amount of memory that is expected to be used by thread zero for static variables. \return If \c add_static is non-zero, the return value is \c false. Otherwise, if one of the following errors is detected, the return value is \c true: \li Thread zero does not have the expected amount of inuse memory (for static variables). \li A thread, other than thread zero, has any inuse memory. \li Any thread has available memory. \par If an error is detected, diagnostic information is printed to standard output. */ inline bool memory_leak(size_t add_static = 0) { // CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL not necessary given asserts below static size_t thread_zero_static_inuse = 0; using std::cout; using std::endl; using CppAD::thread_alloc; using CppAD::omp_alloc; // -------------------------------------------------------------------- CPPAD_ASSERT_KNOWN( ! thread_alloc::in_parallel(), "memory_leak: in_parallel() is true." ); CPPAD_ASSERT_KNOWN( thread_alloc::thread_num() == 0, "memory_leak: thread_num() is not zero." ); if( add_static != 0 ) { thread_zero_static_inuse += add_static; return false; } bool leak = false; size_t thread = 0; // check that memory in use for thread zero corresponds to statics size_t num_bytes = thread_alloc::inuse(thread); if( num_bytes != thread_zero_static_inuse ) { leak = true; cout << "thread zero: static inuse = " << thread_zero_static_inuse; cout << "current inuse(thread) = " << num_bytes << endl; } // check that no memory is currently available for this thread num_bytes = thread_alloc::available(thread); if( num_bytes != 0 ) { leak = true; cout << "thread zero: available = "; cout << num_bytes << endl; } for(thread = 1; thread < CPPAD_MAX_NUM_THREADS; thread++) { // check that no memory is currently in use for this thread num_bytes = thread_alloc::inuse(thread); if( num_bytes != 0 ) { leak = true; cout << "thread " << thread << ": inuse(thread) = "; cout << num_bytes << endl; } // check that no memory is currently available for this thread num_bytes = thread_alloc::available(thread); if( num_bytes != 0 ) { leak = true; cout << "thread " << thread << ": available(thread) = "; cout << num_bytes << endl; } } // ---------------------------------------------------------------------- // check track_new_del if( CPPAD_TRACK_COUNT() != 0 ) { leak = true; CppAD::TrackElement::Print(); } return leak; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/utility/ode_gear_control.hpp0000644000175200017650000003324612656321766021255 0ustar coincoin-web// $Id: ode_gear_control.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_ODE_GEAR_CONTROL_HPP # define CPPAD_ODE_GEAR_CONTROL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin OdeGearControl$$ $spell cppad.hpp CppAD xf xi smin smax eabs ef maxabs nstep tf sini erel dep const tb ta exp $$ $section An Error Controller for Gear's Ode Solvers$$ $mindex OdeGearControl Gear differential equation$$ $head Syntax$$ $codei%# include %$$ $icode%xf% = OdeGearControl(%F%, %M%, %ti%, %tf%, %xi%, %smin%, %smax%, %sini%, %eabs%, %erel%, %ef% , %maxabs%, %nstep% )%$$ $head Purpose$$ Let $latex \B{R}$$ denote the real numbers and let $latex f : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. We define $latex X : [ti , tf] \rightarrow \B{R}^n$$ by the following initial value problem: $latex \[ \begin{array}{rcl} X(ti) & = & xi \\ X'(t) & = & f[t , X(t)] \end{array} \] $$ The routine $cref OdeGear$$ is a stiff multi-step method that can be used to approximate the solution to this equation. The routine $code OdeGearControl$$ sets up this multi-step method and controls the error during such an approximation. $head Include$$ The file $code cppad/ode_gear_control.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head Notation$$ The template parameter types $cref/Scalar/OdeGearControl/Scalar/$$ and $cref/Vector/OdeGearControl/Vector/$$ are documented below. $head xf$$ The return value $icode xf$$ has the prototype $codei% %Vector% %xf% %$$ and the size of $icode xf$$ is equal to $icode n$$ (see description of $cref/Vector/OdeGear/Vector/$$ below). It is the approximation for $latex X(tf)$$. $head Fun$$ The class $icode Fun$$ and the object $icode F$$ satisfy the prototype $codei% %Fun% &%F% %$$ This must support the following set of calls $codei% %F%.Ode(%t%, %x%, %f%) %F%.Ode_dep(%t%, %x%, %f_x%) %$$ $subhead t$$ The argument $icode t$$ has prototype $codei% const %Scalar% &%t% %$$ (see description of $cref/Scalar/OdeGear/Scalar/$$ below). $subhead x$$ The argument $icode x$$ has prototype $codei% const %Vector% &%x% %$$ and has size $icode N$$ (see description of $cref/Vector/OdeGear/Vector/$$ below). $subhead f$$ The argument $icode f$$ to $icode%F%.Ode%$$ has prototype $codei% %Vector% &%f% %$$ On input and output, $icode f$$ is a vector of size $icode N$$ and the input values of the elements of $icode f$$ do not matter. On output, $icode f$$ is set equal to $latex f(t, x)$$ (see $icode f(t, x)$$ in $cref/Purpose/OdeGear/Purpose/$$). $subhead f_x$$ The argument $icode f_x$$ has prototype $codei% %Vector% &%f_x% %$$ On input and output, $icode f_x$$ is a vector of size $latex N * N$$ and the input values of the elements of $icode f_x$$ do not matter. On output, $latex \[ f\_x [i * n + j] = \partial_{x(j)} f_i ( t , x ) \] $$ $subhead Warning$$ The arguments $icode f$$, and $icode f_x$$ must have a call by reference in their prototypes; i.e., do not forget the $code &$$ in the prototype for $icode f$$ and $icode f_x$$. $head M$$ The argument $icode M$$ has prototype $codei% size_t %M% %$$ It specifies the order of the multi-step method; i.e., the order of the approximating polynomial (after the initialization process). The argument $icode M$$ must greater than or equal one. $head ti$$ The argument $icode ti$$ has prototype $codei% const %Scalar% &%ti% %$$ It specifies the initial time for the integration of the differential equation. $head tf$$ The argument $icode tf$$ has prototype $codei% const %Scalar% &%tf% %$$ It specifies the final time for the integration of the differential equation. $head xi$$ The argument $icode xi$$ has prototype $codei% const %Vector% &%xi% %$$ and size $icode n$$. It specifies value of $latex X(ti)$$. $head smin$$ The argument $icode smin$$ has prototype $codei% const %Scalar% &%smin% %$$ The minimum value of $latex T[M] - T[M-1]$$ in a call to $code OdeGear$$ will be $latex smin$$ except for the last two calls where it may be as small as $latex smin / 2$$. The value of $icode smin$$ must be less than or equal $icode smax$$. $head smax$$ The argument $icode smax$$ has prototype $codei% const %Scalar% &%smax% %$$ It specifies the maximum step size to use during the integration; i.e., the maximum value for $latex T[M] - T[M-1]$$ in a call to $code OdeGear$$. $head sini$$ The argument $icode sini$$ has prototype $codei% %Scalar% &%sini% %$$ The value of $icode sini$$ is the minimum step size to use during initialization of the multi-step method; i.e., for calls to $code OdeGear$$ where $latex m < M$$. The value of $icode sini$$ must be less than or equal $icode smax$$ (and can also be less than $icode smin$$). $head eabs$$ The argument $icode eabs$$ has prototype $codei% const %Vector% &%eabs% %$$ and size $icode n$$. Each of the elements of $icode eabs$$ must be greater than or equal zero. It specifies a bound for the absolute error in the return value $icode xf$$ as an approximation for $latex X(tf)$$. (see the $cref/error criteria discussion/OdeGearControl/Error Criteria Discussion/$$ below). $head erel$$ The argument $icode erel$$ has prototype $codei% const %Scalar% &%erel% %$$ and is greater than or equal zero. It specifies a bound for the relative error in the return value $icode xf$$ as an approximation for $latex X(tf)$$ (see the $cref/error criteria discussion/OdeGearControl/Error Criteria Discussion/$$ below). $head ef$$ The argument value $icode ef$$ has prototype $codei% %Vector% &%ef% %$$ and size $icode n$$. The input value of its elements does not matter. On output, it contains an estimated bound for the absolute error in the approximation $icode xf$$; i.e., $latex \[ ef_i > | X( tf )_i - xf_i | \] $$ $head maxabs$$ The argument $icode maxabs$$ is optional in the call to $code OdeGearControl$$. If it is present, it has the prototype $codei% %Vector% &%maxabs% %$$ and size $icode n$$. The input value of its elements does not matter. On output, it contains an estimate for the maximum absolute value of $latex X(t)$$; i.e., $latex \[ maxabs[i] \approx \max \left\{ | X( t )_i | \; : \; t \in [ti, tf] \right\} \] $$ $head nstep$$ The argument $icode nstep$$ has the prototype $codei% %size_t% &%nstep% %$$ Its input value does not matter and its output value is the number of calls to $cref OdeGear$$ used by $code OdeGearControl$$. $head Error Criteria Discussion$$ The relative error criteria $icode erel$$ and absolute error criteria $icode eabs$$ are enforced during each step of the integration of the ordinary differential equations. In addition, they are inversely scaled by the step size so that the total error bound is less than the sum of the error bounds. To be specific, if $latex \tilde{X} (t)$$ is the approximate solution at time $latex t$$, $icode ta$$ is the initial step time, and $icode tb$$ is the final step time, $latex \[ \left| \tilde{X} (tb)_j - X (tb)_j \right| \leq \frac{tf - ti}{tb - ta} \left[ eabs[j] + erel \; | \tilde{X} (tb)_j | \right] \] $$ If $latex X(tb)_j$$ is near zero for some $latex tb \in [ti , tf]$$, and one uses an absolute error criteria $latex eabs[j]$$ of zero, the error criteria above will force $code OdeGearControl$$ to use step sizes equal to $cref/smin/OdeGearControl/smin/$$ for steps ending near $latex tb$$. In this case, the error relative to $icode maxabs$$ can be judged after $code OdeGearControl$$ returns. If $icode ef$$ is to large relative to $icode maxabs$$, $code OdeGearControl$$ can be called again with a smaller value of $icode smin$$. $head Scalar$$ The type $icode Scalar$$ must satisfy the conditions for a $cref NumericType$$ type. The routine $cref CheckNumericType$$ will generate an error message if this is not the case. In addition, the following operations must be defined for $icode Scalar$$ objects $icode a$$ and $icode b$$: $table $bold Operation$$ $cnext $bold Description$$ $rnext $icode%a% <= %b%$$ $cnext returns true (false) if $icode a$$ is less than or equal (greater than) $icode b$$. $rnext $icode%a% == %b%$$ $cnext returns true (false) if $icode a$$ is equal to $icode b$$. $rnext $codei%log(%a%)%$$ $cnext returns a $icode Scalar$$ equal to the logarithm of $icode a$$ $rnext $codei%exp(%a%)%$$ $cnext returns a $icode Scalar$$ equal to the exponential of $icode a$$ $tend $head Vector$$ The type $icode Vector$$ must be a $cref SimpleVector$$ class with $cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $head Example$$ $children% example/ode_gear_control.cpp %$$ The file $cref ode_gear_control.cpp$$ contains an example and test a test of using this routine. It returns true if it succeeds and false otherwise. $head Theory$$ Let $latex e(s)$$ be the error as a function of the step size $latex s$$ and suppose that there is a constant $latex K$$ such that $latex e(s) = K s^m$$. Let $latex a$$ be our error bound. Given the value of $latex e(s)$$, a step of size $latex \lambda s$$ would be ok provided that $latex \[ \begin{array}{rcl} a & \geq & e( \lambda s ) (tf - ti) / ( \lambda s ) \\ a & \geq & K \lambda^m s^m (tf - ti) / ( \lambda s ) \\ a & \geq & \lambda^{m-1} s^{m-1} (tf - ti) e(s) / s^m \\ a & \geq & \lambda^{m-1} (tf - ti) e(s) / s \\ \lambda^{m-1} & \leq & \frac{a}{e(s)} \frac{s}{tf - ti} \end{array} \] $$ Thus if the right hand side of the last inequality is greater than or equal to one, the step of size $latex s$$ is ok. $head Source Code$$ The source code for this routine is in the file $code cppad/ode_gear_control.hpp$$. $end -------------------------------------------------------------------------- */ // link exp and log for float and double # include # include namespace CppAD { // Begin CppAD namespace template Vector OdeGearControl( Fun &F , size_t M , const Scalar &ti , const Scalar &tf , const Vector &xi , const Scalar &smin , const Scalar &smax , Scalar &sini , const Vector &eabs , const Scalar &erel , Vector &ef , Vector &maxabs, size_t &nstep ) { // check simple vector class specifications CheckSimpleVector(); // dimension of the state space size_t n = size_t(xi.size()); CPPAD_ASSERT_KNOWN( M >= 1, "Error in OdeGearControl: M is less than one" ); CPPAD_ASSERT_KNOWN( smin <= smax, "Error in OdeGearControl: smin is greater than smax" ); CPPAD_ASSERT_KNOWN( sini <= smax, "Error in OdeGearControl: sini is greater than smax" ); CPPAD_ASSERT_KNOWN( size_t(eabs.size()) == n, "Error in OdeGearControl: size of eabs is not equal to n" ); CPPAD_ASSERT_KNOWN( size_t(maxabs.size()) == n, "Error in OdeGearControl: size of maxabs is not equal to n" ); // some constants const Scalar zero(0); const Scalar one(1); const Scalar one_plus( Scalar(3) / Scalar(2) ); const Scalar two(2); const Scalar ten(10); // temporary indices size_t i, k; // temporary Scalars Scalar step, sprevious, lambda, axi, a, root, r; // vectors of Scalars Vector T (M + 1); Vector X( (M + 1) * n ); Vector e(n); Vector xf(n); // initial integer values size_t m = 1; nstep = 0; // initialize T T[0] = ti; // initialize X, ef, maxabs for(i = 0; i < n; i++) for(i = 0; i < n; i++) { X[i] = xi[i]; ef[i] = zero; X[i] = xi[i]; if( zero <= xi[i] ) maxabs[i] = xi[i]; else maxabs[i] = - xi[i]; } // initial step size step = smin; while( T[m-1] < tf ) { sprevious = step; // check maximum if( smax <= step ) step = smax; // check minimum if( m < M ) { if( step <= sini ) step = sini; } else if( step <= smin ) step = smin; // check if near the end if( tf <= T[m-1] + one_plus * step ) T[m] = tf; else T[m] = T[m-1] + step; // try using this step size nstep++; OdeGear(F, m, n, T, X, e); step = T[m] - T[m-1]; // compute value of lambda for this step lambda = Scalar(10) * sprevious / step; for(i = 0; i < n; i++) { axi = X[m * n + i]; if( axi <= zero ) axi = - axi; a = eabs[i] + erel * axi; if( e[i] > zero ) { if( m == 1 ) root = (a / e[i]) / ten; else { r = ( a / e[i] ) * step / (tf - ti); root = exp( log(r) / Scalar(m-1) ); } if( root <= lambda ) lambda = root; } } bool advance; if( m == M ) advance = one <= lambda || step <= one_plus * smin; else advance = one <= lambda || step <= one_plus * sini; if( advance ) { // accept the results of this time step CPPAD_ASSERT_UNKNOWN( m <= M ); if( m == M ) { // shift for next step for(k = 0; k < m; k++) { T[k] = T[k+1]; for(i = 0; i < n; i++) X[k*n + i] = X[(k+1)*n + i]; } } // update ef and maxabs for(i = 0; i < n; i++) { ef[i] = ef[i] + e[i]; axi = X[m * n + i]; if( axi <= zero ) axi = - axi; if( axi > maxabs[i] ) maxabs[i] = axi; } if( m != M ) m++; // all we need do in this case } // new step suggested by error criteria step = std::min(lambda , ten) * step / two; } for(i = 0; i < n; i++) xf[i] = X[(m-1) * n + i]; return xf; } } // End CppAD namespace # endif cppad-20160000.1/cppad/utility/omp_alloc.hpp0000644000175200017650000005043012656321766017707 0ustar coincoin-web// $Id: omp_alloc.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_OMP_ALLOC_HPP # define CPPAD_OMP_ALLOC_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # ifdef _OPENMP # include # endif namespace CppAD { // BEGIN_CPPAD_NAMESPACE class omp_alloc{ // ============================================================================ public: /* $begin omp_max_num_threads$$ $spell cppad.hpp inv CppAD num omp_alloc $$ $section Set and Get Maximum Number of Threads for omp_alloc Allocator$$ $head Deprecated 2011-08-31$$ Use the functions $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ and $cref/thread_alloc:num_threads/ta_num_threads/$$ instead. $head Syntax$$ $codei%# include %$$ $codei%omp_alloc::set_max_num_threads(%number%) %$$ $icode%number% = omp_alloc::get_max_num_threads() %$$ $head Purpose$$ By default there is only one thread and all execution is in sequential mode (not $cref/parallel/omp_in_parallel/$$). $head number$$ The argument and return value $icode number$$ has prototype $codei% size_t %number% %$$ and must be greater than zero. $head set_max_num_threads$$ Informs $cref omp_alloc$$ of the maximum number of OpenMP threads. $head get_max_num_threads$$ Returns the valued used in the previous call to $code set_max_num_threads$$. If there was no such previous call, the value one is returned (and only thread number zero can use $cref omp_alloc$$). $head Restrictions$$ The function $code set_max_num_threads$$ must be called before the program enters $cref/parallel/omp_in_parallel/$$ execution mode. In addition, this function cannot be called while in parallel mode. $end */ /*! Inform omp_alloc of the maximum number of OpenMP threads and enable parallel execution mode by initializing all statics in this file. \param number [in] maximum number of OpenMP threads. */ static void set_max_num_threads(size_t number) { thread_alloc::parallel_setup( number, omp_alloc::in_parallel, omp_alloc::get_thread_num ); thread_alloc::hold_memory(number > 1); } /*! Get the current maximum number of OpenMP threads that omp_alloc can use. \return maximum number of OpenMP threads. */ static size_t get_max_num_threads(void) { return thread_alloc::num_threads(); } /* ----------------------------------------------------------------------- $begin omp_in_parallel$$ $section Is The Current Execution in OpenMP Parallel Mode$$ $mindex in_parallel$$ $spell cppad.hpp omp_alloc bool $$ $head Deprecated 2011-08-31$$ Use the function $cref/thread_alloc::in_parallel/ta_in_parallel/$$ instead. $head Syntax$$ $codei%# include %$$ $icode%flag% = omp_alloc::in_parallel()%$$ $head Purpose$$ Some of the $cref omp_alloc$$ allocation routines have different specifications for parallel (not sequential) execution mode. This routine enables you to determine if the current execution mode is sequential or parallel. $head flag$$ The return value has prototype $codei% bool %flag% %$$ It is true if the current execution is in parallel mode (possibly multi-threaded) and false otherwise (sequential mode). $head Example$$ $cref omp_alloc.cpp$$ $end */ /// Are we in a parallel execution state; i.e., is it possible that /// other threads are currently executing. static bool in_parallel(void) { # ifdef _OPENMP return omp_in_parallel() != 0; # else return false; # endif } /* ----------------------------------------------------------------------- $begin omp_get_thread_num$$ $spell cppad.hpp CppAD num omp_alloc cppad.hpp $$ $section Get the Current OpenMP Thread Number$$ $mindex get_thread_num$$ $head Deprecated 2011-08-31$$ Use the function $cref/thread_alloc::thread_num/ta_thread_num/$$ instead. $head Syntax$$ $codei%# include %$$ $icode%thread% = omp_alloc::get_thread_num()%$$ $head Purpose$$ Some of the $cref omp_alloc$$ allocation routines have a thread number. This routine enables you to determine the current thread. $head thread$$ The return value $icode thread$$ has prototype $codei% size_t %thread% %$$ and is the currently executing thread number. If $code _OPENMP$$ is not defined, $icode thread$$ is zero. $head Example$$ $cref omp_alloc.cpp$$ $end */ /// Get current OpenMP thread number (zero if _OpenMP not defined). static size_t get_thread_num(void) { # ifdef _OPENMP size_t thread = static_cast( omp_get_thread_num() ); return thread; # else return 0; # endif } /* ----------------------------------------------------------------------- $begin omp_get_memory$$ $spell cppad.hpp num ptr omp_alloc $$ $section Get At Least A Specified Amount of Memory$$ $head Deprecated 2011-08-31$$ Use the function $cref/thread_alloc::get_memory/ta_get_memory/$$ instead. $head Syntax$$ $codei%# include %$$ $icode%v_ptr% = omp_alloc::get_memory(%min_bytes%, %cap_bytes%)%$$ $head Purpose$$ Use $cref omp_alloc$$ to obtain a minimum number of bytes of memory (for use by the $cref/current thread/omp_get_thread_num/$$). $head min_bytes$$ This argument has prototype $codei% size_t %min_bytes% %$$ It specifies the minimum number of bytes to allocate. $head cap_bytes$$ This argument has prototype $codei% size_t& %cap_bytes% %$$ It's input value does not matter. Upon return, it is the actual number of bytes (capacity) that have been allocated for use, $codei% %min_bytes% <= %cap_bytes% %$$ $head v_ptr$$ The return value $icode v_ptr$$ has prototype $codei% void* %v_ptr% %$$ It is the location where the $icode cap_bytes$$ of memory that have been allocated for use begins. $head Allocation Speed$$ This allocation should be faster if the following conditions hold: $list number$$ The memory allocated by a previous call to $code get_memory$$ is currently available for use. $lnext The current $icode min_bytes$$ is between the previous $icode min_bytes$$ and previous $icode cap_bytes$$. $lend $head Example$$ $cref omp_alloc.cpp$$ $end */ /*! Use omp_alloc to get a specified amount of memory. If the memory allocated by a previous call to \c get_memory is now avaialable, and \c min_bytes is between its previous value and the previous \c cap_bytes, this memory allocation will have optimal speed. Otherwise, the memory allocation is more complicated and may have to wait for other threads to complete an allocation. \param min_bytes [in] The minimum number of bytes of memory to be obtained for use. \param cap_bytes [out] The actual number of bytes of memory obtained for use. \return pointer to the beginning of the memory allocted for use. */ static void* get_memory(size_t min_bytes, size_t& cap_bytes) { return thread_alloc::get_memory(min_bytes, cap_bytes); } /* ----------------------------------------------------------------------- $begin omp_return_memory$$ $spell cppad.hpp ptr omp_alloc $$ $section Return Memory to omp_alloc$$ $mindex return_memory$$ $head Deprecated 2011-08-31$$ Use the function $cref/thread_alloc::return_memory/ta_return_memory/$$ instead. $head Syntax$$ $codei%# include %$$ $codei%omp_alloc::return_memory(%v_ptr%)%$$ $head Purpose$$ If $cref omp_max_num_threads$$ is one, the memory is returned to the system. Otherwise, the memory is retained by $cref omp_alloc$$ for quick future use by the thread that allocated to memory. $head v_ptr$$ This argument has prototype $codei% void* %v_ptr% %$$. It must be a pointer to memory that is currently in use; i.e. obtained by a previous call to $cref omp_get_memory$$ and not yet returned. $head Thread$$ Either the $cref/current thread/omp_get_thread_num/$$ must be the same as during the corresponding call to $cref omp_get_memory$$, or the current execution mode must be sequential (not $cref/parallel/omp_in_parallel/$$). $head NDEBUG$$ If $code NDEBUG$$ is defined, $icode v_ptr$$ is not checked (this is faster). Otherwise, a list of in use pointers is searched to make sure that $icode v_ptr$$ is in the list. $head Example$$ $cref omp_alloc.cpp$$ $end */ /*! Return memory that was obtained by \c get_memory. If max_num_threads(0) == 1, the memory is returned to the system. Otherwise, it is retained by \c omp_alloc and available for use by \c get_memory for this thread. \param v_ptr [in] Value of the pointer returned by \c get_memory and still in use. After this call, this pointer will available (and not in use). \par We must either be in sequential (not parallel) execution mode, or the current thread must be the same as for the corresponding call to \c get_memory. */ static void return_memory(void* v_ptr) { thread_alloc::return_memory(v_ptr); } /* ----------------------------------------------------------------------- $begin omp_free_available$$ $spell cppad.hpp omp_alloc $$ $section Free Memory Currently Available for Quick Use by a Thread$$ $mindex free_available$$ $head Deprecated 2011-08-31$$ Use the function $cref/thread_alloc::free_available/ta_free_available/$$ instead. $head Syntax$$ $codei%# include %$$ $codei%omp_alloc::free_available(%thread%)%$$ $head Purpose$$ Free memory, currently available for quick use by a specific thread, for general future use. $head thread$$ This argument has prototype $codei% size_t %thread% %$$ Either $cref omp_get_thread_num$$ must be the same as $icode thread$$, or the current execution mode must be sequential (not $cref/parallel/omp_in_parallel/$$). $head Example$$ $cref omp_alloc.cpp$$ $end */ /*! Return all the memory being held as available for a thread to the system. \param thread [in] this thread that will no longer have any available memory after this call. This must either be the thread currently executing, or we must be in sequential (not parallel) execution mode. */ static void free_available(size_t thread) { thread_alloc::free_available(thread); } /* ----------------------------------------------------------------------- $begin omp_inuse$$ $spell cppad.hpp num inuse omp_alloc $$ $section Amount of Memory a Thread is Currently Using$$ $mindex inuse$$ $head Deprecated 2011-08-31$$ $head Syntax$$ $codei%# include %$$ $icode%num_bytes% = omp_alloc::inuse(%thread%)%$$ Use the function $cref/thread_alloc::inuse/ta_inuse/$$ instead. $head Purpose$$ Memory being managed by $cref omp_alloc$$ has two states, currently in use by the specified thread, and quickly available for future use by the specified thread. This function informs the program how much memory is in use. $head thread$$ This argument has prototype $codei% size_t %thread% %$$ Either $cref omp_get_thread_num$$ must be the same as $icode thread$$, or the current execution mode must be sequential (not $cref/parallel/omp_in_parallel/$$). $head num_bytes$$ The return value has prototype $codei% size_t %num_bytes% %$$ It is the number of bytes currently in use by the specified thread. $head Example$$ $cref omp_alloc.cpp$$ $end */ /*! Determine the amount of memory that is currently inuse. \param thread [in] Thread for which we are determining the amount of memory (must be < CPPAD_MAX_NUM_THREADS). Durring parallel execution, this must be the thread that is currently executing. \return The amount of memory in bytes. */ static size_t inuse(size_t thread) { return thread_alloc::inuse(thread); } /* ----------------------------------------------------------------------- $begin omp_available$$ $spell cppad.hpp num omp_alloc $$ $section Amount of Memory Available for Quick Use by a Thread$$ $head Deprecated 2011-08-31$$ Use the function $cref/thread_alloc::available/ta_available/$$ instead. $head Syntax$$ $codei%# include %$$ $icode%num_bytes% = omp_alloc::available(%thread%)%$$ $head Purpose$$ Memory being managed by $cref omp_alloc$$ has two states, currently in use by the specified thread, and quickly available for future use by the specified thread. This function informs the program how much memory is available. $head thread$$ This argument has prototype $codei% size_t %thread% %$$ Either $cref omp_get_thread_num$$ must be the same as $icode thread$$, or the current execution mode must be sequential (not $cref/parallel/omp_in_parallel/$$). $head num_bytes$$ The return value has prototype $codei% size_t %num_bytes% %$$ It is the number of bytes currently available for use by the specified thread. $head Example$$ $cref omp_alloc.cpp$$ $end */ /*! Determine the amount of memory that is currently available for use. \copydetails inuse */ static size_t available(size_t thread) { return thread_alloc::available(thread); } /* ----------------------------------------------------------------------- $begin omp_create_array$$ $spell cppad.hpp omp_alloc sizeof $$ $section Allocate Memory and Create A Raw Array$$ $mindex create_array$$ $head Deprecated 2011-08-31$$ Use the function $cref/thread_alloc::create_array/ta_create_array/$$ instead. $head Syntax$$ $codei%# include %$$ $icode%array% = omp_alloc::create_array<%Type%>(%size_min%, %size_out%)%$$. $head Purpose$$ Create a new raw array using $cref omp_alloc$$ a fast memory allocator that works well in a multi-threading OpenMP environment. $head Type$$ The type of the elements of the array. $head size_min$$ This argument has prototype $codei% size_t %size_min% %$$ This is the minimum number of elements that there can be in the resulting $icode array$$. $head size_out$$ This argument has prototype $codei% size_t& %size_out% %$$ The input value of this argument does not matter. Upon return, it is the actual number of elements in $icode array$$ ($icode% size_min %<=% size_out%$$). $head array$$ The return value $icode array$$ has prototype $codei% %Type%* %array% %$$ It is array with $icode size_out$$ elements. The default constructor for $icode Type$$ is used to initialize the elements of $icode array$$. Note that $cref omp_delete_array$$ should be used to destroy the array when it is no longer needed. $head Delta$$ The amount of memory $cref omp_inuse$$ by the current thread, will increase $icode delta$$ where $codei% sizeof(%Type%) * (%size_out% + 1) > %delta% >= sizeof(%Type%) * %size_out% %$$ The $cref omp_available$$ memory will decrease by $icode delta$$, (and the allocation will be faster) if a previous allocation with $icode size_min$$ between its current value and $icode size_out$$ is available. $head Example$$ $cref omp_alloc.cpp$$ $end */ /*! Use omp_alloc to Create a Raw Array. \tparam Type The type of the elements of the array. \param size_min [in] The minimum number of elements in the array. \param size_out [out] The actual number of elements in the array. \return pointer to the first element of the array. The default constructor is used to initialize all the elements of the array. \par The \c extra_ field, in the \c omp_alloc node before the return value, is set to size_out. */ template static Type* create_array(size_t size_min, size_t& size_out) { return thread_alloc::create_array(size_min, size_out); } /* ----------------------------------------------------------------------- $begin omp_delete_array$$ $spell cppad.hpp omp_alloc sizeof $$ $section Return A Raw Array to The Available Memory for a Thread$$ $mindex delete_array$$ $head Deprecated 2011-08-31$$ Use the function $cref/thread_alloc::delete_array/ta_delete_array/$$ instead. $head Syntax$$ $codei%# include %$$ $codei%omp_alloc::delete_array(%array%)%$$. $head Purpose$$ Returns memory corresponding to a raw array (create by $cref omp_create_array$$) to the $cref omp_available$$ memory pool for the current thread. $head Type$$ The type of the elements of the array. $head array$$ The argument $icode array$$ has prototype $codei% %Type%* %array% %$$ It is a value returned by $cref omp_create_array$$ and not yet deleted. The $icode Type$$ destructor is called for each element in the array. $head Thread$$ The $cref/current thread/omp_get_thread_num/$$ must be the same as when $cref omp_create_array$$ returned the value $icode array$$. There is an exception to this rule: when the current execution mode is sequential (not $cref/parallel/omp_in_parallel/$$) the current thread number does not matter. $head Delta$$ The amount of memory $cref omp_inuse$$ will decrease by $icode delta$$, and the $cref omp_available$$ memory will increase by $icode delta$$, where $cref/delta/omp_create_array/Delta/$$ is the same as for the corresponding call to $code create_array$$. $head Example$$ $cref omp_alloc.cpp$$ $end */ /*! Return Memory Used for a Raw Array to the Available Pool. \tparam Type The type of the elements of the array. \param array [in] A value returned by \c create_array that has not yet been deleted. The \c Type destructor is used to destroy each of the elements of the array. \par Durring parallel execution, the current thread must be the same as during the corresponding call to \c create_array. */ template static void delete_array(Type* array) { thread_alloc::delete_array(array); } }; /* -------------------------------------------------------------------------- $begin omp_efficient$$ $spell cppad.hpp omp_alloc ptr num bool const $$ $section Check If A Memory Allocation is Efficient for Another Use$$ $head Removed$$ This function has been removed because speed tests seem to indicate it is just as fast, or faster, to free and then reallocate the memory. $head Syntax$$ $codei%# include %$$ $icode%flag% = omp_alloc::efficient(%v_ptr%, %num_bytes%)%$$ $head Purpose$$ Check if memory that is currently in use is an efficient allocation for a specified number of bytes. $head v_ptr$$ This argument has prototype $codei% const void* %v_ptr% %$$. It must be a pointer to memory that is currently in use; i.e. obtained by a previous call to $cref omp_get_memory$$ and not yet returned. $head num_bytes$$ This argument has prototype $codei% size_t %num_bytes% %$$ It specifies the number of bytes of the memory allocated by $icode v_ptr$$ that we want to use. $head flag$$ The return value has prototype $codei% bool %flag% %$$ It is true, a call to $code get_memory$$ with $cref/min_bytes/omp_get_memory/min_bytes/$$ equal to $icode num_bytes$$ would result in a value for $cref/cap_bytes/omp_get_memory/cap_bytes/$$ that is the same as when $code v_ptr$$ was returned by $code get_memory$$; i.e., $icode v_ptr$$ is an efficient memory block for $icode num_bytes$$ bytes of information. $head Thread$$ Either the $cref/current thread/omp_get_thread_num/$$ must be the same as during the corresponding call to $cref omp_get_memory$$, or the current execution mode must be sequential (not $cref/parallel/omp_in_parallel/$$). $head NDEBUG$$ If $code NDEBUG$$ is defined, $icode v_ptr$$ is not checked (this is faster). Otherwise, a list of in use pointers is searched to make sure that $icode v_ptr$$ is in the list. $end --------------------------------------------------------------------------- $begin old_max_num_threads$$ $spell cppad.hpp inv CppAD num omp_alloc $$ $section Set Maximum Number of Threads for omp_alloc Allocator$$ $mindex max_num_threads$$ $head Removed$$ This function has been removed from the CppAD API. Use the function $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ in its place. $head Syntax$$ $codei%# include %$$ $codei%omp_alloc::max_num_threads(%number%)%$$ $head Purpose$$ By default there is only one thread and all execution is in sequential mode (not $cref/parallel/omp_in_parallel/$$). $head number$$ The argument $icode number$$ has prototype $codei% size_t %number% %$$ It must be greater than zero and specifies the maximum number of OpenMP threads that will be active at one time. $head Restrictions$$ This function must be called before the program enters $cref/parallel/omp_in_parallel/$$ execution mode. $end ------------------------------------------------------------------------------- */ } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/utility/ode_gear.hpp0000644000175200017650000003057612656321766017520 0ustar coincoin-web// $Id: ode_gear.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_ODE_GEAR_HPP # define CPPAD_ODE_GEAR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin OdeGear$$ $spell cppad.hpp Jan bool const CppAD dep $$ $section An Arbitrary Order Gear Method$$ $mindex OdeGear Ode stiff differential equation$$ $head Syntax$$ $codei%# include %$$ $codei%OdeGear(%F%, %m%, %n%, %T%, %X%, %e%)%$$ $head Purpose$$ This routine applies $cref/Gear's Method/OdeGear/Gear's Method/$$ to solve an explicit set of ordinary differential equations. We are given $latex f : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. This routine solves the following initial value problem $latex \[ \begin{array}{rcl} x( t_{m-1} ) & = & x^0 \\ x^\prime (t) & = & f[t , x(t)] \end{array} \] $$ for the value of $latex x( t_m )$$. If your set of ordinary differential equations are not stiff an explicit method may be better (perhaps $cref Runge45$$.) $head Include$$ The file $code cppad/ode_gear.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head Fun$$ The class $icode Fun$$ and the object $icode F$$ satisfy the prototype $codei% %Fun% &%F% %$$ This must support the following set of calls $codei% %F%.Ode(%t%, %x%, %f%) %F%.Ode_dep(%t%, %x%, %f_x%) %$$ $subhead t$$ The argument $icode t$$ has prototype $codei% const %Scalar% &%t% %$$ (see description of $cref/Scalar/OdeGear/Scalar/$$ below). $subhead x$$ The argument $icode x$$ has prototype $codei% const %Vector% &%x% %$$ and has size $icode n$$ (see description of $cref/Vector/OdeGear/Vector/$$ below). $subhead f$$ The argument $icode f$$ to $icode%F%.Ode%$$ has prototype $codei% %Vector% &%f% %$$ On input and output, $icode f$$ is a vector of size $icode n$$ and the input values of the elements of $icode f$$ do not matter. On output, $icode f$$ is set equal to $latex f(t, x)$$ (see $icode f(t, x)$$ in $cref/Purpose/OdeGear/Purpose/$$). $subhead f_x$$ The argument $icode f_x$$ has prototype $codei% %Vector% &%f_x% %$$ On input and output, $icode f_x$$ is a vector of size $latex n * n$$ and the input values of the elements of $icode f_x$$ do not matter. On output, $latex \[ f\_x [i * n + j] = \partial_{x(j)} f_i ( t , x ) \] $$ $subhead Warning$$ The arguments $icode f$$, and $icode f_x$$ must have a call by reference in their prototypes; i.e., do not forget the $code &$$ in the prototype for $icode f$$ and $icode f_x$$. $head m$$ The argument $icode m$$ has prototype $codei% size_t %m% %$$ It specifies the order (highest power of $latex t$$) used to represent the function $latex x(t)$$ in the multi-step method. Upon return from $code OdeGear$$, the $th i$$ component of the polynomial is defined by $latex \[ p_i ( t_j ) = X[ j * n + i ] \] $$ for $latex j = 0 , \ldots , m$$ (where $latex 0 \leq i < n$$). The value of $latex m$$ must be greater than or equal one. $head n$$ The argument $icode n$$ has prototype $codei% size_t %n% %$$ It specifies the range space dimension of the vector valued function $latex x(t)$$. $head T$$ The argument $icode T$$ has prototype $codei% const %Vector% &%T% %$$ and size greater than or equal to $latex m+1$$. For $latex j = 0 , \ldots m$$, $latex T[j]$$ is the time corresponding to time corresponding to a previous point in the multi-step method. The value $latex T[m]$$ is the time of the next point in the multi-step method. The array $latex T$$ must be monotone increasing; i.e., $latex T[j] < T[j+1]$$. Above and below we often use the shorthand $latex t_j$$ for $latex T[j]$$. $head X$$ The argument $icode X$$ has the prototype $codei% %Vector% &%X% %$$ and size greater than or equal to $latex (m+1) * n$$. On input to $code OdeGear$$, for $latex j = 0 , \ldots , m-1$$, and $latex i = 0 , \ldots , n-1$$ $latex \[ X[ j * n + i ] = x_i ( t_j ) \] $$ Upon return from $code OdeGear$$, for $latex i = 0 , \ldots , n-1$$ $latex \[ X[ m * n + i ] \approx x_i ( t_m ) \] $$ $head e$$ The vector $icode e$$ is an approximate error bound for the result; i.e., $latex \[ e[i] \geq | X[ m * n + i ] - x_i ( t_m ) | \] $$ The order of this approximation is one less than the order of the solution; i.e., $latex \[ e = O ( h^m ) \] $$ where $latex h$$ is the maximum of $latex t_{j+1} - t_j$$. $head Scalar$$ The type $icode Scalar$$ must satisfy the conditions for a $cref NumericType$$ type. The routine $cref CheckNumericType$$ will generate an error message if this is not the case. In addition, the following operations must be defined for $icode Scalar$$ objects $icode a$$ and $icode b$$: $table $bold Operation$$ $cnext $bold Description$$ $rnext $icode%a% < %b%$$ $cnext less than operator (returns a $code bool$$ object) $tend $head Vector$$ The type $icode Vector$$ must be a $cref SimpleVector$$ class with $cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $head Example$$ $children% example/ode_gear.cpp %$$ The file $cref ode_gear.cpp$$ contains an example and test a test of using this routine. It returns true if it succeeds and false otherwise. $head Source Code$$ The source code for this routine is in the file $code cppad/ode_gear.hpp$$. $head Theory$$ For this discussion we use the shorthand $latex x_j$$ for the value $latex x ( t_j ) \in \B{R}^n$$ which is not to be confused with $latex x_i (t) \in \B{R}$$ in the notation above. The interpolating polynomial $latex p(t)$$ is given by $latex \[ p(t) = \sum_{j=0}^m x_j \frac{ \prod_{i \neq j} ( t - t_i ) }{ \prod_{i \neq j} ( t_j - t_i ) } \] $$ The derivative $latex p^\prime (t)$$ is given by $latex \[ p^\prime (t) = \sum_{j=0}^m x_j \frac{ \sum_{i \neq j} \prod_{k \neq i,j} ( t - t_k ) }{ \prod_{k \neq j} ( t_j - t_k ) } \] $$ Evaluating the derivative at the point $latex t_\ell$$ we have $latex \[ \begin{array}{rcl} p^\prime ( t_\ell ) & = & x_\ell \frac{ \sum_{i \neq \ell} \prod_{k \neq i,\ell} ( t_\ell - t_k ) }{ \prod_{k \neq \ell} ( t_\ell - t_k ) } + \sum_{j \neq \ell} x_j \frac{ \sum_{i \neq j} \prod_{k \neq i,j} ( t_\ell - t_k ) }{ \prod_{k \neq j} ( t_j - t_k ) } \\ & = & x_\ell \sum_{i \neq \ell} \frac{ 1 }{ t_\ell - t_i } + \sum_{j \neq \ell} x_j \frac{ \prod_{k \neq \ell,j} ( t_\ell - t_k ) }{ \prod_{k \neq j} ( t_j - t_k ) } \\ & = & x_\ell \sum_{k \neq \ell} ( t_\ell - t_k )^{-1} + \sum_{j \neq \ell} x_j ( t_j - t_\ell )^{-1} \prod_{k \neq \ell ,j} ( t_\ell - t_k ) / ( t_j - t_k ) \end{array} \] $$ We define the vector $latex \alpha \in \B{R}^{m+1}$$ by $latex \[ \alpha_j = \left\{ \begin{array}{ll} \sum_{k \neq m} ( t_m - t_k )^{-1} & {\rm if} \; j = m \\ ( t_j - t_m )^{-1} \prod_{k \neq m,j} ( t_m - t_k ) / ( t_j - t_k ) & {\rm otherwise} \end{array} \right. \] $$ It follows that $latex \[ p^\prime ( t_m ) = \alpha_0 x_0 + \cdots + \alpha_m x_m \] $$ Gear's method determines $latex x_m$$ by solving the following nonlinear equation $latex \[ f( t_m , x_m ) = \alpha_0 x_0 + \cdots + \alpha_m x_m \] $$ Newton's method for solving this equation determines iterates, which we denote by $latex x_m^k$$, by solving the following affine approximation of the equation above $latex \[ \begin{array}{rcl} f( t_m , x_m^{k-1} ) + \partial_x f( t_m , x_m^{k-1} ) ( x_m^k - x_m^{k-1} ) & = & \alpha_0 x_0^k + \alpha_1 x_1 + \cdots + \alpha_m x_m \\ \left[ \alpha_m I - \partial_x f( t_m , x_m^{k-1} ) \right] x_m & = & \left[ f( t_m , x_m^{k-1} ) - \partial_x f( t_m , x_m^{k-1} ) x_m^{k-1} - \alpha_0 x_0 - \cdots - \alpha_{m-1} x_{m-1} \right] \end{array} \] $$ In order to initialize Newton's method; i.e. choose $latex x_m^0$$ we define the vector $latex \beta \in \B{R}^{m+1}$$ by $latex \[ \beta_j = \left\{ \begin{array}{ll} \sum_{k \neq m-1} ( t_{m-1} - t_k )^{-1} & {\rm if} \; j = m-1 \\ ( t_j - t_{m-1} )^{-1} \prod_{k \neq m-1,j} ( t_{m-1} - t_k ) / ( t_j - t_k ) & {\rm otherwise} \end{array} \right. \] $$ It follows that $latex \[ p^\prime ( t_{m-1} ) = \beta_0 x_0 + \cdots + \beta_m x_m \] $$ We solve the following approximation of the equation above to determine $latex x_m^0$$: $latex \[ f( t_{m-1} , x_{m-1} ) = \beta_0 x_0 + \cdots + \beta_{m-1} x_{m-1} + \beta_m x_m^0 \] $$ $head Gear's Method$$ C. W. Gear, ``Simultaneous Numerical Solution of Differential-Algebraic Equations,'' IEEE Transactions on Circuit Theory, vol. 18, no. 1, pp. 89-95, Jan. 1971. $end -------------------------------------------------------------------------- */ # include # include # include # include # include # include # include namespace CppAD { // BEGIN CppAD namespace template void OdeGear( Fun &F , size_t m , size_t n , const Vector &T , Vector &X , Vector &e ) { // temporary indices size_t i, j, k; typedef typename Vector::value_type Scalar; // check numeric type specifications CheckNumericType(); // check simple vector class specifications CheckSimpleVector(); CPPAD_ASSERT_KNOWN( m >= 1, "OdeGear: m is less than one" ); CPPAD_ASSERT_KNOWN( n > 0, "OdeGear: n is equal to zero" ); CPPAD_ASSERT_KNOWN( size_t(T.size()) >= (m+1), "OdeGear: size of T is not greater than or equal (m+1)" ); CPPAD_ASSERT_KNOWN( size_t(X.size()) >= (m+1) * n, "OdeGear: size of X is not greater than or equal (m+1) * n" ); for(j = 0; j < m; j++) CPPAD_ASSERT_KNOWN( T[j] < T[j+1], "OdeGear: the array T is not monotone increasing" ); // some constants Scalar zero(0); Scalar one(1); // vectors required by method Vector alpha(m + 1); Vector beta(m + 1); Vector f(n); Vector f_x(n * n); Vector x_m0(n); Vector x_m(n); Vector b(n); Vector A(n * n); // compute alpha[m] alpha[m] = zero; for(k = 0; k < m; k++) alpha[m] += one / (T[m] - T[k]); // compute beta[m-1] beta[m-1] = one / (T[m-1] - T[m]); for(k = 0; k < m-1; k++) beta[m-1] += one / (T[m-1] - T[k]); // compute other components of alpha for(j = 0; j < m; j++) { // compute alpha[j] alpha[j] = one / (T[j] - T[m]); for(k = 0; k < m; k++) { if( k != j ) { alpha[j] *= (T[m] - T[k]); alpha[j] /= (T[j] - T[k]); } } } // compute other components of beta for(j = 0; j <= m; j++) { if( j != m-1 ) { // compute beta[j] beta[j] = one / (T[j] - T[m-1]); for(k = 0; k <= m; k++) { if( k != j && k != m-1 ) { beta[j] *= (T[m-1] - T[k]); beta[j] /= (T[j] - T[k]); } } } } // evaluate f(T[m-1], x_{m-1} ) for(i = 0; i < n; i++) x_m[i] = X[(m-1) * n + i]; F.Ode(T[m-1], x_m, f); // solve for x_m^0 for(i = 0; i < n; i++) { x_m[i] = f[i]; for(j = 0; j < m; j++) x_m[i] -= beta[j] * X[j * n + i]; x_m[i] /= beta[m]; } x_m0 = x_m; // evaluate partial w.r.t x of f(T[m], x_m^0) F.Ode_dep(T[m], x_m, f_x); // compute the matrix A = ( alpha[m] * I - f_x ) for(i = 0; i < n; i++) { for(j = 0; j < n; j++) A[i * n + j] = - f_x[i * n + j]; A[i * n + i] += alpha[m]; } // LU factor (and overwrite) the matrix A int sign; CppAD::vector ip(n) , jp(n); sign = LuFactor(ip, jp, A); CPPAD_ASSERT_KNOWN( sign != 0, "OdeGear: step size is to large" ); // Iterations of Newton's method for(k = 0; k < 3; k++) { // only evaluate f( T[m] , x_m ) keep f_x during iteration F.Ode(T[m], x_m, f); // b = f + f_x x_m - alpha[0] x_0 - ... - alpha[m-1] x_{m-1} for(i = 0; i < n; i++) { b[i] = f[i]; for(j = 0; j < n; j++) b[i] -= f_x[i * n + j] * x_m[j]; for(j = 0; j < m; j++) b[i] -= alpha[j] * X[ j * n + i ]; } LuInvert(ip, jp, A, b); x_m = b; } // return estimate for x( t[k] ) and the estimated error bound for(i = 0; i < n; i++) { X[m * n + i] = x_m[i]; e[i] = x_m[i] - x_m0[i]; if( e[i] < zero ) e[i] = - e[i]; } } } // End CppAD namespace # endif cppad-20160000.1/cppad/utility/lu_invert.hpp0000644000175200017650000001441612656321766017755 0ustar coincoin-web// $Id: lu_invert.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_LU_INVERT_HPP # define CPPAD_LU_INVERT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin LuInvert$$ $escape #$$ $spell cppad.hpp Lu Cpp jp ip const namespace typename etmp $$ $section Invert an LU Factored Equation$$ $mindex LuInvert linear$$ $pre $$ $head Syntax$$ $codei%# include %$$ $codei%LuInvert(%ip%, %jp%, %LU%, %X%)%$$ $head Description$$ Solves the matrix equation $icode%A% * %X% = %B%$$ using an LU factorization computed by $cref LuFactor$$. $head Include$$ The file $code cppad/lu_invert.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head Matrix Storage$$ All matrices are stored in row major order. To be specific, if $latex Y$$ is a vector that contains a $latex p$$ by $latex q$$ matrix, the size of $latex Y$$ must be equal to $latex p * q $$ and for $latex i = 0 , \ldots , p-1$$, $latex j = 0 , \ldots , q-1$$, $latex \[ Y_{i,j} = Y[ i * q + j ] \] $$ $head ip$$ The argument $icode ip$$ has prototype $codei% const %SizeVector% &%ip% %$$ (see description for $icode SizeVector$$ in $cref/LuFactor/LuFactor/SizeVector/$$ specifications). The size of $icode ip$$ is referred to as $icode n$$ in the specifications below. The elements of $icode ip$$ determine the order of the rows in the permuted matrix. $head jp$$ The argument $icode jp$$ has prototype $codei% const %SizeVector% &%jp% %$$ (see description for $icode SizeVector$$ in $cref/LuFactor/LuFactor/SizeVector/$$ specifications). The size of $icode jp$$ must be equal to $icode n$$. The elements of $icode jp$$ determine the order of the columns in the permuted matrix. $head LU$$ The argument $icode LU$$ has the prototype $codei% const %FloatVector% &%LU% %$$ and the size of $icode LU$$ must equal $latex n * n$$ (see description for $icode FloatVector$$ in $cref/LuFactor/LuFactor/FloatVector/$$ specifications). $subhead L$$ We define the lower triangular matrix $icode L$$ in terms of $icode LU$$. The matrix $icode L$$ is zero above the diagonal and the rest of the elements are defined by $codei% %L%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] %$$ for $latex i = 0 , \ldots , n-1$$ and $latex j = 0 , \ldots , i$$. $subhead U$$ We define the upper triangular matrix $icode U$$ in terms of $icode LU$$. The matrix $icode U$$ is zero below the diagonal, one on the diagonal, and the rest of the elements are defined by $codei% %U%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] %$$ for $latex i = 0 , \ldots , n-2$$ and $latex j = i+1 , \ldots , n-1$$. $subhead P$$ We define the permuted matrix $icode P$$ in terms of the matrix $icode L$$ and the matrix $icode U$$ by $icode%P% = %L% * %U%$$. $subhead A$$ The matrix $icode A$$, which defines the linear equations that we are solving, is given by $codei% %P%(%i%, %j%) = %A%[ %ip%[%i%] * %n% + %jp%[%j%] ] %$$ (Hence $icode LU$$ contains a permuted factorization of the matrix $icode A$$.) $head X$$ The argument $icode X$$ has prototype $codei% %FloatVector% &%X% %$$ (see description for $icode FloatVector$$ in $cref/LuFactor/LuFactor/FloatVector/$$ specifications). The matrix $icode X$$ must have the same number of rows as the matrix $icode A$$. The input value of $icode X$$ is the matrix $icode B$$ and the output value solves the matrix equation $icode%A% * %X% = %B%$$. $children% example/lu_invert.cpp% omh/lu_invert_hpp.omh %$$ $head Example$$ The file $cref lu_solve.hpp$$ is a good example usage of $code LuFactor$$ with $code LuInvert$$. The file $cref lu_invert.cpp$$ contains an example and test of using $code LuInvert$$ by itself. It returns true if it succeeds and false otherwise. $head Source$$ The file $cref lu_invert.hpp$$ contains the current source code that implements these specifications. $end -------------------------------------------------------------------------- */ // BEGIN C++ # include # include # include namespace CppAD { // BEGIN CppAD namespace // LuInvert template void LuInvert( const SizeVector &ip, const SizeVector &jp, const FloatVector &LU, FloatVector &B ) { size_t k; // column index in X size_t p; // index along diagonal in LU size_t i; // row index in LU and X typedef typename FloatVector::value_type Float; // check numeric type specifications CheckNumericType(); // check simple vector class specifications CheckSimpleVector(); CheckSimpleVector(); Float etmp; size_t n = ip.size(); CPPAD_ASSERT_KNOWN( size_t(jp.size()) == n, "Error in LuInvert: jp must have size equal to n * n" ); CPPAD_ASSERT_KNOWN( size_t(LU.size()) == n * n, "Error in LuInvert: Lu must have size equal to n * m" ); size_t m = size_t(B.size()) / n; CPPAD_ASSERT_KNOWN( size_t(B.size()) == n * m, "Error in LuSolve: B must have size equal to a multiple of n" ); // temporary storage for reordered solution FloatVector x(n); // loop over equations for(k = 0; k < m; k++) { // invert the equation c = L * b for(p = 0; p < n; p++) { // solve for c[p] etmp = B[ ip[p] * m + k ] / LU[ ip[p] * n + jp[p] ]; B[ ip[p] * m + k ] = etmp; // subtract off effect on other variables for(i = p+1; i < n; i++) B[ ip[i] * m + k ] -= etmp * LU[ ip[i] * n + jp[p] ]; } // invert the equation x = U * c p = n; while( p > 0 ) { --p; etmp = B[ ip[p] * m + k ]; x[ jp[p] ] = etmp; for(i = 0; i < p; i++ ) B[ ip[i] * m + k ] -= etmp * LU[ ip[i] * n + jp[p] ]; } // copy reordered solution into B for(i = 0; i < n; i++) B[i * m + k] = x[i]; } return; } } // END CppAD namespace // END C++ # endif cppad-20160000.1/cppad/utility/check_simple_vector.hpp0000644000175200017650000001150512656321766021752 0ustar coincoin-web// $Id: check_simple_vector.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_CHECK_SIMPLE_VECTOR_HPP # define CPPAD_CHECK_SIMPLE_VECTOR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin CheckSimpleVector$$ $spell alloc const cppad.hpp CppAD $$ $section Check Simple Vector Concept$$ $mindex CheckSimpleVector$$ $head Syntax$$ $codei%# include %$$ $codei%CheckSimpleVector<%Scalar%, %Vector%>()%$$ $pre $$ $codei%CheckSimpleVector<%Scalar%, %Vector%>(%x%, %y%)%$$ $head Purpose$$ Preforms compile and run time checks that the type specified by $icode Vector$$ satisfies all the requirements for a $cref SimpleVector$$ class with $cref/elements of type/SimpleVector/Elements of Specified Type/$$ $icode Scalar$$. If a requirement is not satisfied, a an error message makes it clear what condition is not satisfied. $head x, y$$ If the arguments $icode x$$ and $icode y$$ are present, they have prototype $codei% const %Scalar%& %x% const %Scalar%& %y% %$$ In addition, the check $codei% %x% == %x% %$$ will return the boolean value $code true$$, and $codei% %x% == %y% %$$ will return $code false$$. $head Restrictions$$ If the arguments $icode x$$ and $icode y$$ are not present, the following extra assumption is made by $code CheckSimpleVector$$: If $icode x$$ is a $icode Scalar$$ object $codei% %x% = 0 %y% = 1 %$$ assigns values to the objects $icode x$$ and $icode y$$. In addition, $icode%x% == %x%$$ would return the boolean value $code true$$ and $icode%x% == %y%$$ would return $code false$$. $head Include$$ The file $code cppad/check_simple_vector.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest if the CppAD include files. $head Parallel Mode$$ The routine $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ must be called before it can be used in $cref/parallel/ta_in_parallel/$$ mode. $head Example$$ $children% example/check_simple_vector.cpp %$$ The file $cref check_simple_vector.cpp$$ contains an example and test of this function where $icode S$$ is the same as $icode T$$. It returns true, if it succeeds an false otherwise. The comments in this example suggest a way to change the example so $icode S$$ is not the same as $icode T$$. $end --------------------------------------------------------------------------- */ # include # include # include # include namespace CppAD { # ifdef NDEBUG template inline void CheckSimpleVector(const Scalar& x, const Scalar& y) { } template inline void CheckSimpleVector(void) { } # else template struct ok_if_S_same_as_T { }; template struct ok_if_S_same_as_T { T value; }; template void CheckSimpleVector(const Scalar& x, const Scalar& y) { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL static size_t count; if( count > 0 ) return; count++; // value_type must be type of elements of Vector typedef typename Vector::value_type value_type; // check that elements of Vector have type Scalar struct ok_if_S_same_as_T x_copy; x_copy.value = x; // check default constructor Vector d; // size member function CPPAD_ASSERT_KNOWN( d.size() == 0, "default construtor result does not have size zero" ); // resize to same size as other vectors in test d.resize(1); // check sizing constructor Vector s(1); // check element assignment s[0] = y; CPPAD_ASSERT_KNOWN( s[0] == y, "element assignment failed" ); // check copy constructor s[0] = x_copy.value; const Vector c(s); s[0] = y; CPPAD_ASSERT_KNOWN( c[0] == x, "copy constructor is shallow" ); // vector assignment operator d[0] = x; s = d; s[0] = y; CPPAD_ASSERT_KNOWN( d[0] == x, "assignment operator is shallow" ); // element access, right side const // element assignment, left side not const d[0] = c[0]; CPPAD_ASSERT_KNOWN( d[0] == x, "element assignment from const failed" ); } template void CheckSimpleVector(void) { Scalar x; Scalar y; // use assignment and not constructor x = 0; y = 1; CheckSimpleVector(x, y); } # endif } // end namespace CppAD # endif cppad-20160000.1/cppad/utility/to_string.hpp0000644000175200017650000001113212656321766017746 0ustar coincoin-web// $Id$ # ifndef CPPAD_TO_STRING_HPP # define CPPAD_TO_STRING_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin to_string$$ $spell cppad.hpp long long std const ostringstream $$ $section Convert Certain Types to a String$$ $head Syntax$$ $codei%# include %$$ $icode%s% = to_string(%value%)%$$. $head See Also$$ $cref base_to_string$$, $cref ad_to_string$$ $head Purpose$$ This routine is similar to the C++11 routine $code std::to_string$$ with the following differences: $list number$$ It works with C++98. $lnext It has been extended to the fundamental floating point types. $lnext It has specifications for extending to an arbitrary type; see $cref base_to_string$$. $lnext If $code $$ is included, and it has been extended to a $icode Base$$ type, it automatically extends to the $cref/AD types above Base/glossary/AD Type Above Base/$$. $lend $head value$$ $subhead Integer$$ The argument $icode value$$ can have the following prototype $codei% const %Integer%& %value% %$$ where $icode Integer$$ is any of the fundamental integer types; e.g., $code short int$$ and $code unsigned long$$. Note that if C++11 is supported by this compilation, $code unsigned long long$$ is also a fundamental integer type. $subhead Float$$ The argument $icode value$$ can have the following prototype $codei% const %Float%& %value% %$$ where $icode Float$$ is any of the fundamental floating point types; i.e., $code float$$, $code double$$, and $code long double$$. $head s$$ The return value has prototype $codei% std::string %s% %$$ and contains a representation of the specified $icode value$$. $subhead Integer$$ If $icode value$$ is an $codei Integer$$, the representation is equivalent to $codei%os% << %value%$$ where $icode os$$ is an $code std::ostringstream$$. $subhead Float$$ If $icode value$$ is a $codei Float$$, enough digits are used in the representation so that the result is accurate to withing round off error. $children% example/to_string.cpp %$$ $head Example$$ The file $cref to_string.cpp$$ contains an example and test of this routine. It returns true if it succeeds and false otherwise. $end */ # include # include # include # include # include # define CPPAD_SPECIALIZE_TO_STRING_INTEGER(Type) \ template <> struct to_string_struct\ { std::string operator()(const Type& value) \ { std::stringstream os;\ os << value;\ return os.str();\ }\ }; # define CPPAD_SPECIALIZE_TO_STRING_FLOAT(Float) \ template <> struct to_string_struct\ { std::string operator()(const Float& value) \ { std::stringstream os;\ Float epsilon = std::numeric_limits::epsilon();\ size_t n_digits = 1 - int( std::log10(epsilon) );\ os << std::setprecision(n_digits);\ os << value;\ return os.str();\ }\ }; namespace CppAD { // Default implementation, // each type must define its own specilization. template struct to_string_struct { std::string operator()(const Type& value) { CPPAD_ASSERT_KNOWN( false, "to_string is not implemented for this type" ); // return empty string return std::string(""); } }; // specialization for the fundamental integer types CPPAD_SPECIALIZE_TO_STRING_INTEGER(signed short) CPPAD_SPECIALIZE_TO_STRING_INTEGER(unsigned short) // CPPAD_SPECIALIZE_TO_STRING_INTEGER(signed int) CPPAD_SPECIALIZE_TO_STRING_INTEGER(unsigned int) // CPPAD_SPECIALIZE_TO_STRING_INTEGER(signed long) CPPAD_SPECIALIZE_TO_STRING_INTEGER(unsigned long) // # if CPPAD_USE_CPLUSPLUS_2011 CPPAD_SPECIALIZE_TO_STRING_INTEGER(signed long long) CPPAD_SPECIALIZE_TO_STRING_INTEGER(unsigned long long) # endif // specialization for the fundamental floating point types CPPAD_SPECIALIZE_TO_STRING_FLOAT(float) CPPAD_SPECIALIZE_TO_STRING_FLOAT(double) CPPAD_SPECIALIZE_TO_STRING_FLOAT(long double) // link from function to function object in structure template std::string to_string(const Type& value) { to_string_struct to_str; return to_str(value); } } # undef CPPAD_SPECIALIZE_TO_STRING_FLOAT # undef CPPAD_SPECIALIZE_TO_STRING_INTEGER # endif cppad-20160000.1/cppad/utility/romberg_mul.hpp0000644000175200017650000001715112656321766020257 0ustar coincoin-web// $Id: romberg_mul.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_ROMBERG_MUL_HPP # define CPPAD_ROMBERG_MUL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin RombergMul$$ $spell cppad.hpp bool const Cpp RombergMulMul $$ $section Multi-dimensional Romberg Integration$$ $mindex integrate multi dimensional dimension$$ $head Syntax$$ $codei%# include %$$ $codei%RombergMul<%Fun%, %SizeVector%, %FloatVector%, %m%> %R%$$ $pre $$ $icode%r% = %R%(%F%, %a%, %b%, %n%, %p%, %e%)%$$ $head Description$$ Returns the Romberg integration estimate $latex r$$ for the multi-dimensional integral $latex \[ r = \int_{a[0]}^{b[0]} \cdots \int_{a[m-1]}^{b[m-1]} \; F(x) \; {\bf d} x_0 \cdots {\bf d} x_{m-1} \; + \; \sum_{i=0}^{m-1} O \left[ ( b[i] - a[i] ) / 2^{n[i]-1} \right]^{2(p[i]+1)} \] $$ $head Include$$ The file $code cppad/romberg_mul.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head m$$ The template parameter $icode m$$ must be convertible to a $code size_t$$ object with a value that can be determined at compile time; for example $code 2$$. It determines the dimension of the domain space for the integration. $head r$$ The return value $icode r$$ has prototype $codei% %Float% %r% %$$ It is the estimate computed by $code RombergMul$$ for the integral above (see description of $cref/Float/RombergMul/Float/$$ below). $head F$$ The object $icode F$$ has the prototype $codei% %Fun% &%F% %$$ It must support the operation $codei% %F%(%x%) %$$ The argument $icode x$$ to $icode F$$ has prototype $codei% const %Float% &%x% %$$ The return value of $icode F$$ is a $icode Float$$ object $head a$$ The argument $icode a$$ has prototype $codei% const %FloatVector% &%a% %$$ It specifies the lower limit for the integration (see description of $cref/FloatVector/RombergMul/FloatVector/$$ below). $head b$$ The argument $icode b$$ has prototype $codei% const %FloatVector% &%b% %$$ It specifies the upper limit for the integration. $head n$$ The argument $icode n$$ has prototype $codei% const %SizeVector% &%n% %$$ A total number of $latex 2^{n[i]-1} + 1$$ evaluations of $icode%F%(%x%)%$$ are used to estimate the integral with respect to $latex {\bf d} x_i$$. $head p$$ The argument $icode p$$ has prototype $codei% const %SizeVector% &%p% %$$ For $latex i = 0 , \ldots , m-1$$, $latex n[i]$$ determines the accuracy order in the approximation for the integral that is returned by $code RombergMul$$. The values in $icode p$$ must be less than or equal $icode n$$; i.e., $icode%p%[%i%] <= %n%[%i%]%$$. $head e$$ The argument $icode e$$ has prototype $codei% %Float% &%e% %$$ The input value of $icode e$$ does not matter and its output value is an approximation for the absolute error in the integral estimate. $head Float$$ The type $icode Float$$ is defined as the type of the elements of $cref/FloatVector/RombergMul/FloatVector/$$. The type $icode Float$$ must satisfy the conditions for a $cref NumericType$$ type. The routine $cref CheckNumericType$$ will generate an error message if this is not the case. In addition, if $icode x$$ and $icode y$$ are $icode Float$$ objects, $codei% %x% < %y% %$$ returns the $code bool$$ value true if $icode x$$ is less than $icode y$$ and false otherwise. $head FloatVector$$ The type $icode FloatVector$$ must be a $cref SimpleVector$$ class. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $children% example/romberg_mul.cpp %$$ $head Example$$ $comment% example/romberg_mul.cpp %$$ The file $cref Rombergmul.cpp$$ contains an example and test a test of using this routine. It returns true if it succeeds and false otherwise. $head Source Code$$ The source code for this routine is in the file $code cppad/romberg_mul.hpp$$. $end */ # include # include # include namespace CppAD { // BEGIN CppAD namespace template class SliceLast { typedef typename FloatVector::value_type Float; private: Fun *F; size_t last; FloatVector x; public: SliceLast( Fun *F_, size_t last_, const FloatVector &x_ ) : F(F_) , last(last_), x(last + 1) { size_t i; for(i = 0; i < last; i++) x[i] = x_[i]; } double operator()(const Float &xlast) { x[last] = xlast; return (*F)(x); } }; template class IntegrateLast { private: Fun *F; const size_t last; const FloatVector a; const FloatVector b; const SizeVector n; const SizeVector p; Float esum; size_t ecount; public: IntegrateLast( Fun *F_ , size_t last_ , const FloatVector &a_ , const FloatVector &b_ , const SizeVector &n_ , const SizeVector &p_ ) : F(F_) , last(last_), a(a_) , b(b_) , n(n_) , p(p_) { } Float operator()(const FloatVector &x) { Float r, e; SliceLast S(F, last, x); r = CppAD::RombergOne( S, a[last], b[last], n[last], p[last], e ); esum = esum + e; ecount++; return r; } void ClearEsum(void) { esum = 0.; } Float GetEsum(void) { return esum; } void ClearEcount(void) { ecount = 0; } size_t GetEcount(void) { return ecount; } }; template class RombergMul { typedef typename FloatVector::value_type Float; public: RombergMul(void) { } Float operator() ( Fun &F , const FloatVector &a , const FloatVector &b , const SizeVector &n , const SizeVector &p , Float &e ) { Float r; typedef IntegrateLast< Fun , SizeVector , FloatVector , Float > IntegrateOne; IntegrateOne Fm1(&F, m-1, a, b, n, p); RombergMul< IntegrateOne, SizeVector , FloatVector , m-1 > RombergMulM1; Fm1.ClearEsum(); Fm1.ClearEcount(); r = RombergMulM1(Fm1, a, b, n, p, e); size_t i, j; Float prod = 1; size_t pow2 = 1; for(i = 0; i < m-1; i++) { prod *= (b[i] - a[i]); for(j = 0; j < (n[i] - 1); j++) pow2 *= 2; } assert( Fm1.GetEcount() == (pow2+1) ); e = e + Fm1.GetEsum() * prod / Fm1.GetEcount(); return r; } }; template class RombergMul { typedef typename FloatVector::value_type Float; public: Float operator() ( Fun &F , const FloatVector &a , const FloatVector &b , const SizeVector &n , const SizeVector &p , Float &e ) { Float r; typedef IntegrateLast< Fun , SizeVector , FloatVector , Float > IntegrateOne; // check simple vector class specifications CheckSimpleVector(); // check numeric type specifications CheckNumericType(); IntegrateOne F0(&F, 0, a, b, n, p); F0.ClearEsum(); F0.ClearEcount(); r = F0(a); assert( F0.GetEcount() == 1 ); e = F0.GetEsum(); return r; } }; } // END CppAD namespace # endif cppad-20160000.1/cppad/utility/near_equal.hpp0000644000175200017650000001350212656321766020055 0ustar coincoin-web// $Id: near_equal.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_NEAR_EQUAL_HPP # define CPPAD_NEAR_EQUAL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin NearEqual$$ $spell cppad.hpp sqrt cout endl Microsoft std Cpp namespace const bool $$ $section Determine if Two Values Are Nearly Equal$$ $mindex NearEqual near absolute difference relative$$ $head Syntax$$ $codei%# include %$$ $icode%b% = NearEqual(%x%, %y%, %r%, %a%)%$$ $head Purpose$$ Returns true, if $icode x$$ and $icode y$$ are nearly equal, and false otherwise. $head x$$ The argument $icode x$$ has one of the following possible prototypes $codei% const %Type% &%x%, const std::complex<%Type%> &%x%, %$$ $head y$$ The argument $icode y$$ has one of the following possible prototypes $codei% const %Type% &%y%, const std::complex<%Type%> &%y%, %$$ $head r$$ The relative error criteria $icode r$$ has prototype $codei% const %Type% &%r% %$$ It must be greater than or equal to zero. The relative error condition is defined as: $latex \[ | x - y | \leq r ( |x| + |y| ) \] $$ $head a$$ The absolute error criteria $icode a$$ has prototype $codei% const %Type% &%a% %$$ It must be greater than or equal to zero. The absolute error condition is defined as: $latex \[ | x - y | \leq a \] $$ $head b$$ The return value $icode b$$ has prototype $codei% bool %b% %$$ If either $icode x$$ or $icode y$$ is infinite or not a number, the return value is false. Otherwise, if either the relative or absolute error condition (defined above) is satisfied, the return value is true. Otherwise, the return value is false. $head Type$$ The type $icode Type$$ must be a $cref NumericType$$. The routine $cref CheckNumericType$$ will generate an error message if this is not the case. In addition, the following operations must be defined objects $icode a$$ and $icode b$$ of type $icode Type$$: $table $bold Operation$$ $cnext $bold Description$$ $rnext $icode%a% <= %b%$$ $cnext less that or equal operator (returns a $code bool$$ object) $tend $head Include Files$$ The file $code cppad/near_equal.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head Example$$ $children% example/near_equal.cpp %$$ The file $cref near_equal.cpp$$ contains an example and test of $code NearEqual$$. It return true if it succeeds and false otherwise. $head Exercise$$ Create and run a program that contains the following code: $codep using std::complex; using std::cout; using std::endl; complex one(1., 0), i(0., 1); complex x = one / i; complex y = - i; double r = 1e-12; double a = 0; bool ok = CppAD::NearEqual(x, y, r, a); if( ok ) cout << "Ok" << endl; else cout << "Error" << endl; $$ $end */ # include # include # include # include namespace CppAD { // Begin CppAD namespace // determine if both x and y are finite values template bool near_equal_isfinite(const Type &x , const Type &y) { Type infinity = Type( std::numeric_limits::infinity() ); // handle bug where some compilers return true for nan == nan bool xNan = x != x; bool yNan = y != y; // infinite cases bool xInf = (x == infinity || x == - infinity); bool yInf = (x == infinity || x == - infinity); return ! (xNan | yNan | xInf | yInf); } template bool NearEqual(const Type &x, const Type &y, const Type &r, const Type &a) { CheckNumericType(); Type zero(0); CPPAD_ASSERT_KNOWN( zero <= r, "Error in NearEqual: relative error is less than zero" ); CPPAD_ASSERT_KNOWN( zero <= a, "Error in NearEqual: absolute error is less than zero" ); // check for special cases if( ! CppAD::near_equal_isfinite(x, y) ) return false; Type ax = x; if( ax <= zero ) ax = - ax; Type ay = y; if( ay <= zero ) ay = - ay; Type ad = x - y; if( ad <= zero ) ad = - ad; if( ad <= a ) return true; if( ad <= r * (ax + ay) ) return true; return false; } template bool NearEqual( const std::complex &x , const std::complex &y , const Type &r , const Type & a ) { CheckNumericType(); Type zero(0); CPPAD_ASSERT_KNOWN( zero <= r, "Error in NearEqual: relative error is less than zero" ); CPPAD_ASSERT_KNOWN( zero <= a, "Error in NearEqual: absolute error is less than zero" ); // check for special cases if( ! CppAD::near_equal_isfinite(x.real(), x.imag()) ) return false; if( ! CppAD::near_equal_isfinite(y.real(), y.imag()) ) return false; std::complex d = x - y; Type ad = std::abs(d); if( ad <= a ) return true; Type ax = std::abs(x); Type ay = std::abs(y); if( ad <= r * (ax + ay) ) return true; return false; } template bool NearEqual( const std::complex &x , const Type &y , const Type &r , const Type & a ) { return NearEqual(x, std::complex(y, Type(0)), r, a); } template bool NearEqual( const Type &x , const std::complex &y , const Type &r , const Type & a ) { return NearEqual(std::complex(x, Type(0)), y, r, a); } } // END CppAD namespace # endif cppad-20160000.1/cppad/utility/nan.hpp0000644000175200017650000001054112656321766016515 0ustar coincoin-web// $Id: nan.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_NAN_HPP # define CPPAD_NAN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin nan$$ $spell hasnan cppad hpp CppAD isnan bool const $$ $section Obtain Nan or Determine if a Value is Nan$$ $head Syntax$$ $codei%# include %$$ $icode%b% = isnan(%s%) %$$ $icode%b% = hasnan(%v%)%$$ $head Purpose$$ It obtain and check for the value not a number $code nan$$. The IEEE standard specifies that a floating point value $icode a$$ is $code nan$$ if and only if the following returns true $codei% %a% != %a% %$$ $head Include$$ The file $code cppad/nan.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $subhead Macros$$ Some C++ compilers use preprocessor symbols called $code nan$$ and $code isnan$$. These preprocessor symbols will no longer be defined after this file is included. $head isnan$$ This routine determines if a scalar value is $code nan$$. $subhead s$$ The argument $icode s$$ has prototype $codei% const %Scalar% %s% %$$ $subhead b$$ The return value $icode b$$ has prototype $codei% bool %b% %$$ It is true if the value $icode s$$ is $code nan$$. $head hasnan$$ This routine determines if a $cref SimpleVector$$ has an element that is $code nan$$. $subhead v$$ The argument $icode v$$ has prototype $codei% const %Vector% &%v% %$$ (see $cref/Vector/nan/Vector/$$ for the definition of $icode Vector$$). $subhead b$$ The return value $icode b$$ has prototype $codei% bool %b% %$$ It is true if the vector $icode v$$ has a $code nan$$. $head nan(zero)$$ $subhead Deprecated 2015-10-04$$ This routine has been deprecated, use CppAD numeric limits $cref/quiet_NaN/numeric_limits/quiet_NaN/$$ in its place. $subhead Syntax$$ $icode%s% = nan(%z%) %$$ $subhead z$$ The argument $icode z$$ has prototype $codei% const %Scalar% &%z% %$$ and its value is zero (see $cref/Scalar/nan/Scalar/$$ for the definition of $icode Scalar$$). $subhead s$$ The return value $icode s$$ has prototype $codei% %Scalar% %s% %$$ It is the value $code nan$$ for this floating point type. $head Scalar$$ The type $icode Scalar$$ must support the following operations; $table $bold Operation$$ $cnext $bold Description$$ $rnext $icode%a% / %b%$$ $cnext division operator (returns a $icode Scalar$$ object) $rnext $icode%a% == %b%$$ $cnext equality operator (returns a $code bool$$ object) $rnext $icode%a% != %b%$$ $cnext not equality operator (returns a $code bool$$ object) $tend Note that the division operator will be used with $icode a$$ and $icode b$$ equal to zero. For some types (e.g. $code int$$) this may generate an exception. No attempt is made to catch any such exception. $head Vector$$ The type $icode Vector$$ must be a $cref SimpleVector$$ class with elements of type $icode Scalar$$. $children% example/nan.cpp %$$ $head Example$$ The file $cref nan.cpp$$ contains an example and test of this routine. It returns true if it succeeds and false otherwise. $end */ # include # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL # include /* # define nan There must be a define for every CppAD undef */ # ifdef nan # undef nan # endif /* # define isnan There must be a define for every CppAD undef */ # ifdef isnan # undef isnan # endif namespace CppAD { // BEGIN CppAD namespace template inline bool isnan(const Scalar &s) { return (s != s); } template bool hasnan(const Vector &v) { bool found_nan; size_t i; i = v.size(); found_nan = false; // on MS Visual Studio 2012, CppAD required in front of isnan ? while(i--) found_nan |= CppAD::isnan(v[i]); return found_nan; } template inline Scalar nan(const Scalar &zero) { return zero / zero; } } // End CppAD namespace # endif cppad-20160000.1/cppad/utility/lu_factor.hpp0000644000175200017650000002663712656321766017734 0ustar coincoin-web// $Id: lu_factor.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_LU_FACTOR_HPP # define CPPAD_LU_FACTOR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin LuFactor$$ $escape #$$ $spell cppad.hpp Cpp Geq Lu bool const ip jp namespace std typename $$ $section LU Factorization of A Square Matrix$$ $mindex LuFactor linear equation solve$$ $pre $$ $head Syntax$$ $codei%# include %$$ $icode%sign% = LuFactor(%ip%, %jp%, %LU%)%$$ $head Description$$ Computes an LU factorization of the matrix $icode A$$ where $icode A$$ is a square matrix. $head Include$$ The file $code cppad/lu_factor.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head Matrix Storage$$ All matrices are stored in row major order. To be specific, if $latex Y$$ is a vector that contains a $latex p$$ by $latex q$$ matrix, the size of $latex Y$$ must be equal to $latex p * q $$ and for $latex i = 0 , \ldots , p-1$$, $latex j = 0 , \ldots , q-1$$, $latex \[ Y_{i,j} = Y[ i * q + j ] \] $$ $head sign$$ The return value $icode sign$$ has prototype $codei% int %sign% %$$ If $icode A$$ is invertible, $icode sign$$ is plus or minus one and is the sign of the permutation corresponding to the row ordering $icode ip$$ and column ordering $icode jp$$. If $icode A$$ is not invertible, $icode sign$$ is zero. $head ip$$ The argument $icode ip$$ has prototype $codei% %SizeVector% &%ip% %$$ (see description of $cref/SizeVector/LuFactor/SizeVector/$$ below). The size of $icode ip$$ is referred to as $icode n$$ in the specifications below. The input value of the elements of $icode ip$$ does not matter. The output value of the elements of $icode ip$$ determine the order of the rows in the permuted matrix. $head jp$$ The argument $icode jp$$ has prototype $codei% %SizeVector% &%jp% %$$ (see description of $cref/SizeVector/LuFactor/SizeVector/$$ below). The size of $icode jp$$ must be equal to $icode n$$. The input value of the elements of $icode jp$$ does not matter. The output value of the elements of $icode jp$$ determine the order of the columns in the permuted matrix. $head LU$$ The argument $icode LU$$ has the prototype $codei% %FloatVector% &%LU% %$$ and the size of $icode LU$$ must equal $latex n * n$$ (see description of $cref/FloatVector/LuFactor/FloatVector/$$ below). $subhead A$$ We define $icode A$$ as the matrix corresponding to the input value of $icode LU$$. $subhead P$$ We define the permuted matrix $icode P$$ in terms of $icode A$$ by $codei% %P%(%i%, %j%) = %A%[ %ip%[%i%] * %n% + %jp%[%j%] ] %$$ $subhead L$$ We define the lower triangular matrix $icode L$$ in terms of the output value of $icode LU$$. The matrix $icode L$$ is zero above the diagonal and the rest of the elements are defined by $codei% %L%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] %$$ for $latex i = 0 , \ldots , n-1$$ and $latex j = 0 , \ldots , i$$. $subhead U$$ We define the upper triangular matrix $icode U$$ in terms of the output value of $icode LU$$. The matrix $icode U$$ is zero below the diagonal, one on the diagonal, and the rest of the elements are defined by $codei% %U%(%i%, %j%) = %LU%[ %ip%[%i%] * %n% + %jp%[%j%] ] %$$ for $latex i = 0 , \ldots , n-2$$ and $latex j = i+1 , \ldots , n-1$$. $subhead Factor$$ If the return value $icode sign$$ is non-zero, $codei% %L% * %U% = %P% %$$ If the return value of $icode sign$$ is zero, the contents of $icode L$$ and $icode U$$ are not defined. $subhead Determinant$$ If the return value $icode sign$$ is zero, the determinant of $icode A$$ is zero. If $icode sign$$ is non-zero, using the output value of $icode LU$$ the determinant of the matrix $icode A$$ is equal to $codei% %sign% * %LU%[%ip%[0], %jp%[0]] * %...% * %LU%[%ip%[%n%-1], %jp%[%n%-1]] %$$ $head SizeVector$$ The type $icode SizeVector$$ must be a $cref SimpleVector$$ class with $cref/elements of type size_t/SimpleVector/Elements of Specified Type/$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $head FloatVector$$ The type $icode FloatVector$$ must be a $cref/simple vector class/SimpleVector/$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $head Float$$ This notation is used to denote the type corresponding to the elements of a $icode FloatVector$$. The type $icode Float$$ must satisfy the conditions for a $cref NumericType$$ type. The routine $cref CheckNumericType$$ will generate an error message if this is not the case. In addition, the following operations must be defined for any pair of $icode Float$$ objects $icode x$$ and $icode y$$: $table $bold Operation$$ $cnext $bold Description$$ $rnext $codei%log(%x%)%$$ $cnext returns the logarithm of $icode x$$ as a $icode Float$$ object $tend $head AbsGeq$$ Including the file $code lu_factor.hpp$$ defines the template function $codei% template bool AbsGeq<%Float%>(const %Float% &%x%, const %Float% &%y%) %$$ in the $code CppAD$$ namespace. This function returns true if the absolute value of $icode x$$ is greater than or equal the absolute value of $icode y$$. It is used by $code LuFactor$$ to choose the pivot elements. This template function definition uses the operator $code <=$$ to obtain the absolute value for $icode Float$$ objects. If this operator is not defined for your use of $icode Float$$, you will need to specialize this template so that it works for your use of $code LuFactor$$. $pre $$ Complex numbers do not have the operation $code <=$$ defined. The specializations $codei% bool AbsGeq< std::complex > (const std::complex &%x%, const std::complex &%y%) bool AbsGeq< std::complex > (const std::complex &%x%, const std::complex &%y%) %$$ are define by including $code lu_factor.hpp$$ These return true if the sum of the square of the real and imaginary parts of $icode x$$ is greater than or equal the sum of the square of the real and imaginary parts of $icode y$$. $children% example/lu_factor.cpp% omh/lu_factor_hpp.omh %$$ $head Example$$ The file $cref lu_factor.cpp$$ contains an example and test of using $code LuFactor$$ by itself. It returns true if it succeeds and false otherwise. $pre $$ The file $cref lu_solve.hpp$$ provides a useful example usage of $code LuFactor$$ with $code LuInvert$$. $head Source$$ The file $cref lu_factor.hpp$$ contains the current source code that implements these specifications. $end -------------------------------------------------------------------------- */ // BEGIN C++ # include # include # include # include # include namespace CppAD { // BEGIN CppAD namespace // AbsGeq template inline bool AbsGeq(const Float &x, const Float &y) { Float xabs = x; if( xabs <= Float(0) ) xabs = - xabs; Float yabs = y; if( yabs <= Float(0) ) yabs = - yabs; return xabs >= yabs; } inline bool AbsGeq( const std::complex &x, const std::complex &y) { double xsq = x.real() * x.real() + x.imag() * x.imag(); double ysq = y.real() * y.real() + y.imag() * y.imag(); return xsq >= ysq; } inline bool AbsGeq( const std::complex &x, const std::complex &y) { float xsq = x.real() * x.real() + x.imag() * x.imag(); float ysq = y.real() * y.real() + y.imag() * y.imag(); return xsq >= ysq; } // Lines that are different from code in cppad/local/lu_ratio.hpp end with // template // int LuFactor(SizeVector &ip, SizeVector &jp, FloatVector &LU) // { // type of the elements of LU // typedef typename FloatVector::value_type Float; // // check numeric type specifications CheckNumericType(); // check simple vector class specifications CheckSimpleVector(); CheckSimpleVector(); size_t i, j; // some temporary indices const Float zero( 0 ); // the value zero as a Float object size_t imax; // row index of maximum element size_t jmax; // column indx of maximum element Float emax; // maximum absolute value size_t p; // count pivots int sign; // sign of the permutation Float etmp; // temporary element Float pivot; // pivot element // ------------------------------------------------------- size_t n = ip.size(); CPPAD_ASSERT_KNOWN( size_t(jp.size()) == n, "Error in LuFactor: jp must have size equal to n" ); CPPAD_ASSERT_KNOWN( size_t(LU.size()) == n * n, "Error in LuFactor: LU must have size equal to n * m" ); // ------------------------------------------------------- // initialize row and column order in matrix not yet pivoted for(i = 0; i < n; i++) { ip[i] = i; jp[i] = i; } // initialize the sign of the permutation sign = 1; // --------------------------------------------------------- // Reduce the matrix P to L * U using n pivots for(p = 0; p < n; p++) { // determine row and column corresponding to element of // maximum absolute value in remaining part of P imax = jmax = n; emax = zero; for(i = p; i < n; i++) { for(j = p; j < n; j++) { CPPAD_ASSERT_UNKNOWN( (ip[i] < n) & (jp[j] < n) ); etmp = LU[ ip[i] * n + jp[j] ]; // check if maximum absolute value so far if( AbsGeq (etmp, emax) ) { imax = i; jmax = j; emax = etmp; } } } CPPAD_ASSERT_KNOWN( (imax < n) & (jmax < n) , "LuFactor can't determine an element with " "maximum absolute value.\n" "Perhaps original matrix contains not a number or infinity.\n" "Perhaps your specialization of AbsGeq is not correct." ); if( imax != p ) { // switch rows so max absolute element is in row p i = ip[p]; ip[p] = ip[imax]; ip[imax] = i; sign = -sign; } if( jmax != p ) { // switch columns so max absolute element is in column p j = jp[p]; jp[p] = jp[jmax]; jp[jmax] = j; sign = -sign; } // pivot using the max absolute element pivot = LU[ ip[p] * n + jp[p] ]; // check for determinant equal to zero if( pivot == zero ) { // abort the mission return 0; } // Reduce U by the elementary transformations that maps // LU( ip[p], jp[p] ) to one. Only need transform elements // above the diagonal in U and LU( ip[p] , jp[p] ) is // corresponding value below diagonal in L. for(j = p+1; j < n; j++) LU[ ip[p] * n + jp[j] ] /= pivot; // Reduce U by the elementary transformations that maps // LU( ip[i], jp[p] ) to zero. Only need transform elements // above the diagonal in U and LU( ip[i], jp[p] ) is // corresponding value below diagonal in L. for(i = p+1; i < n; i++ ) { etmp = LU[ ip[i] * n + jp[p] ]; for(j = p+1; j < n; j++) { LU[ ip[i] * n + jp[j] ] -= etmp * LU[ ip[p] * n + jp[j] ]; } } } return sign; } } // END CppAD namespace // END C++ # endif cppad-20160000.1/cppad/utility/index_sort.hpp0000644000175200017650000001056012656321766020120 0ustar coincoin-web// $Id: index_sort.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_INDEX_SORT_HPP # define CPPAD_INDEX_SORT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin index_sort$$ $spell cppad.hpp ind const $$ $section Returns Indices that Sort a Vector$$ $mindex index_sort$$ $head Syntax$$ $codei%# include %$$ $codei%index_sort(%keys%, %ind%)%$$ $head keys$$ The argument $icode keys$$ has prototype $codei% const %VectorKey%& %keys% %$$ where $icode VectorKey$$ is a $cref SimpleVector$$ class with elements that support the $code <$$ operation. $head ind$$ The argument $icode ind$$ has prototype $codei% %VectorSize%& %ind% %$$ where $icode VectorSize$$ is a $cref SimpleVector$$ class with elements of type $code size_t$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $subhead Input$$ The size of $icode ind$$ must be the same as the size of $icode keys$$ and the value of its input elements does not matter. $subhead Return$$ Upon return, $icode ind$$ is a permutation of the set of indices that yields increasing order for $icode keys$$. In other words, for all $icode%i% != %j%$$, $codei% %ind%[%i%] != %ind%[%j%] %$$ and for $icode%i% = 0 , %...% , %size%-2%$$, $codei% ( %keys%[ %ind%[%i%+1] ] < %keys%[ %ind%[%i%] ] ) == false %$$ $head Example$$ $children% example/index_sort.cpp %$$ The file $cref index_sort.cpp$$ contains an example and test of this routine. It return true if it succeeds and false otherwise. $end */ # include # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file index_sort.hpp File used to implement the CppAD index sort utility */ /*! Helper class used by index_sort */ template class index_sort_element { private: /// key used to determine position of this element Compare key_; /// index vlaue corresponding to this key size_t index_; public: /// operator requried by std::sort bool operator<(const index_sort_element& other) const { return key_ < other.key_; } /// set the key for this element void set_key(const Compare& value) { key_ = value; } /// set the index for this element void set_index(const size_t& index) { index_ = index; } /// get the key for this element Compare get_key(void) const { return key_; } /// get the index for this element size_t get_index(void) const { return index_; } }; /*! Compute the indices that sort a vector of keys \tparam VectorKey Simple vector type that deterimene the sorting order by \c < operator on its elements. \tparam VectorSize Simple vector type with elements of \c size_t that is used to return index values. \param keys [in] values that determine the sorting order. \param ind [out] must have the same size as \c keys. The input value of its elements does not matter. The output value of its elements satisfy \code ( keys[ ind[i] ] < keys[ ind[i+1] ] ) == false \endcode */ template void index_sort(const VectorKey& keys, VectorSize& ind) { typedef typename VectorKey::value_type Compare; CheckSimpleVector(); typedef index_sort_element element; CPPAD_ASSERT_KNOWN( size_t(keys.size()) == size_t(ind.size()), "index_sort: vector sizes do not match" ); size_t size_work = size_t(keys.size()); size_t size_out; element* work = thread_alloc::create_array(size_work, size_out); // copy initial order into work size_t i; for(i = 0; i < size_work; i++) { work[i].set_key( keys[i] ); work[i].set_index( i ); } // sort the work array std::sort(work, work+size_work); // copy the indices to the output vector for(i = 0; i < size_work; i++) ind[i] = work[i].get_index(); // we are done with this work array thread_alloc::delete_array(work); return; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/utility/ode_err_control.hpp0000644000175200017650000003705312656321766021127 0ustar coincoin-web// $Id: ode_err_control.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_ODE_ERR_CONTROL_HPP # define CPPAD_ODE_ERR_CONTROL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin OdeErrControl$$ $spell cppad.hpp nstep maxabs exp scur CppAD xf tf xi smin smax eabs erel ef ta tb xa xb const eb $$ $section An Error Controller for ODE Solvers$$ $mindex OdeErrControl differential equation$$ $head Syntax$$ $codei%# include %$$ $icode%xf% = OdeErrControl(%method%, %ti%, %tf%, %xi%, %smin%, %smax%, %scur%, %eabs%, %erel%, %ef% , %maxabs%, %nstep% )%$$ $head Description$$ Let $latex \B{R}$$ denote the real numbers and let $latex F : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ be a smooth function. We define $latex X : [ti , tf] \rightarrow \B{R}^n$$ by the following initial value problem: $latex \[ \begin{array}{rcl} X(ti) & = & xi \\ X'(t) & = & F[t , X(t)] \end{array} \] $$ The routine $code OdeErrControl$$ can be used to adjust the step size used an arbitrary integration methods in order to be as fast as possible and still with in a requested error bound. $head Include$$ The file $code cppad/ode_err_control.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. $head Notation$$ The template parameter types $cref/Scalar/OdeErrControl/Scalar/$$ and $cref/Vector/OdeErrControl/Vector/$$ are documented below. $head xf$$ The return value $icode xf$$ has the prototype $codei% %Vector% %xf% %$$ (see description of $cref/Vector/OdeErrControl/Vector/$$ below). and the size of $icode xf$$ is equal to $icode n$$. If $icode xf$$ contains not a number $cref nan$$, see the discussion of $cref/step/OdeErrControl/Method/Nan/$$. $head Method$$ The class $icode Method$$ and the object $icode method$$ satisfy the following syntax $codei% %Method% &%method% %$$ The object $icode method$$ must support $code step$$ and $code order$$ member functions defined below: $subhead step$$ The syntax $codei% %method%.step(%ta%, %tb%, %xa%, %xb%, %eb%) %$$ executes one step of the integration method. $codei% %ta% %$$ The argument $icode ta$$ has prototype $codei% const %Scalar% &%ta% %$$ It specifies the initial time for this step in the ODE integration. (see description of $cref/Scalar/OdeErrControl/Scalar/$$ below). $codei% %tb% %$$ The argument $icode tb$$ has prototype $codei% const %Scalar% &%tb% %$$ It specifies the final time for this step in the ODE integration. $codei% %xa% %$$ The argument $icode xa$$ has prototype $codei% const %Vector% &%xa% %$$ and size $icode n$$. It specifies the value of $latex X(ta)$$. (see description of $cref/Vector/OdeErrControl/Vector/$$ below). $codei% %xb% %$$ The argument value $icode xb$$ has prototype $codei% %Vector% &%xb% %$$ and size $icode n$$. The input value of its elements does not matter. On output, it contains the approximation for $latex X(tb)$$ that the method obtains. $codei% %eb% %$$ The argument value $icode eb$$ has prototype $codei% %Vector% &%eb% %$$ and size $icode n$$. The input value of its elements does not matter. On output, it contains an estimate for the error in the approximation $icode xb$$. It is assumed (locally) that the error bound in this approximation nearly equal to $latex K (tb - ta)^m$$ where $icode K$$ is a fixed constant and $icode m$$ is the corresponding argument to $code CodeControl$$. $subhead Nan$$ If any element of the vector $icode eb$$ or $icode xb$$ are not a number $code nan$$, the current step is considered to large. If this happens with the current step size equal to $icode smin$$, $code OdeErrControl$$ returns with $icode xf$$ and $icode ef$$ as vectors of $code nan$$. $subhead order$$ If $icode m$$ is $code size_t$$, the object $icode method$$ must also support the following syntax $codei% %m% = %method%.order() %$$ The return value $icode m$$ is the order of the error estimate; i.e., there is a constant K such that if $latex ti \leq ta \leq tb \leq tf$$, $latex \[ | eb(tb) | \leq K | tb - ta |^m \] $$ where $icode ta$$, $icode tb$$, and $icode eb$$ are as in $icode%method%.step(%ta%, %tb%, %xa%, %xb%, %eb%)%$$ $head ti$$ The argument $icode ti$$ has prototype $codei% const %Scalar% &%ti% %$$ It specifies the initial time for the integration of the differential equation. $head tf$$ The argument $icode tf$$ has prototype $codei% const %Scalar% &%tf% %$$ It specifies the final time for the integration of the differential equation. $head xi$$ The argument $icode xi$$ has prototype $codei% const %Vector% &%xi% %$$ and size $icode n$$. It specifies value of $latex X(ti)$$. $head smin$$ The argument $icode smin$$ has prototype $codei% const %Scalar% &%smin% %$$ The step size during a call to $icode method$$ is defined as the corresponding value of $latex tb - ta$$. If $latex tf - ti \leq smin$$, the integration will be done in one step of size $icode tf - ti$$. Otherwise, the minimum value of $icode tb - ta$$ will be $latex smin$$ except for the last two calls to $icode method$$ where it may be as small as $latex smin / 2$$. $head smax$$ The argument $icode smax$$ has prototype $codei% const %Scalar% &%smax% %$$ It specifies the maximum step size to use during the integration; i.e., the maximum value for $latex tb - ta$$ in a call to $icode method$$. The value of $icode smax$$ must be greater than or equal $icode smin$$. $head scur$$ The argument $icode scur$$ has prototype $codei% %Scalar% &%scur% %$$ The value of $icode scur$$ is the suggested next step size, based on error criteria, to try in the next call to $icode method$$. On input it corresponds to the first call to $icode method$$, in this call to $code OdeErrControl$$ (where $latex ta = ti$$). On output it corresponds to the next call to $icode method$$, in a subsequent call to $code OdeErrControl$$ (where $icode ta = tf$$). $head eabs$$ The argument $icode eabs$$ has prototype $codei% const %Vector% &%eabs% %$$ and size $icode n$$. Each of the elements of $icode eabs$$ must be greater than or equal zero. It specifies a bound for the absolute error in the return value $icode xf$$ as an approximation for $latex X(tf)$$. (see the $cref/error criteria discussion/OdeErrControl/Error Criteria Discussion/$$ below). $head erel$$ The argument $icode erel$$ has prototype $codei% const %Scalar% &%erel% %$$ and is greater than or equal zero. It specifies a bound for the relative error in the return value $icode xf$$ as an approximation for $latex X(tf)$$ (see the $cref/error criteria discussion/OdeErrControl/Error Criteria Discussion/$$ below). $head ef$$ The argument value $icode ef$$ has prototype $codei% %Vector% &%ef% %$$ and size $icode n$$. The input value of its elements does not matter. On output, it contains an estimated bound for the absolute error in the approximation $icode xf$$; i.e., $latex \[ ef_i > | X( tf )_i - xf_i | \] $$ If on output $icode ef$$ contains not a number $code nan$$, see the discussion of $cref/step/OdeErrControl/Method/Nan/$$. $head maxabs$$ The argument $icode maxabs$$ is optional in the call to $code OdeErrControl$$. If it is present, it has the prototype $codei% %Vector% &%maxabs% %$$ and size $icode n$$. The input value of its elements does not matter. On output, it contains an estimate for the maximum absolute value of $latex X(t)$$; i.e., $latex \[ maxabs[i] \approx \max \left\{ | X( t )_i | \; : \; t \in [ti, tf] \right\} \] $$ $head nstep$$ The argument $icode nstep$$ is optional in the call to $code OdeErrControl$$. If it is present, it has the prototype $codei% %size_t% &%nstep% %$$ Its input value does not matter and its output value is the number of calls to $icode%method%.step%$$ used by $code OdeErrControl$$. $head Error Criteria Discussion$$ The relative error criteria $icode erel$$ and absolute error criteria $icode eabs$$ are enforced during each step of the integration of the ordinary differential equations. In addition, they are inversely scaled by the step size so that the total error bound is less than the sum of the error bounds. To be specific, if $latex \tilde{X} (t)$$ is the approximate solution at time $latex t$$, $icode ta$$ is the initial step time, and $icode tb$$ is the final step time, $latex \[ \left| \tilde{X} (tb)_j - X (tb)_j \right| \leq \frac{tf - ti}{tb - ta} \left[ eabs[j] + erel \; | \tilde{X} (tb)_j | \right] \] $$ If $latex X(tb)_j$$ is near zero for some $latex tb \in [ti , tf]$$, and one uses an absolute error criteria $latex eabs[j]$$ of zero, the error criteria above will force $code OdeErrControl$$ to use step sizes equal to $cref/smin/OdeErrControl/smin/$$ for steps ending near $latex tb$$. In this case, the error relative to $icode maxabs$$ can be judged after $code OdeErrControl$$ returns. If $icode ef$$ is to large relative to $icode maxabs$$, $code OdeErrControl$$ can be called again with a smaller value of $icode smin$$. $head Scalar$$ The type $icode Scalar$$ must satisfy the conditions for a $cref NumericType$$ type. The routine $cref CheckNumericType$$ will generate an error message if this is not the case. In addition, the following operations must be defined for $icode Scalar$$ objects $icode a$$ and $icode b$$: $table $bold Operation$$ $cnext $bold Description$$ $rnext $icode%a% <= %b%$$ $cnext returns true (false) if $icode a$$ is less than or equal (greater than) $icode b$$. $rnext $icode%a% == %b%$$ $cnext returns true (false) if $icode a$$ is equal to $icode b$$. $rnext $codei%log(%a%)%$$ $cnext returns a $icode Scalar$$ equal to the logarithm of $icode a$$ $rnext $codei%exp(%a%)%$$ $cnext returns a $icode Scalar$$ equal to the exponential of $icode a$$ $tend $head Vector$$ The type $icode Vector$$ must be a $cref SimpleVector$$ class with $cref/elements of type Scalar/SimpleVector/Elements of Specified Type/$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $head Example$$ $children% example/ode_err_control.cpp% example/ode_err_maxabs.cpp %$$ The files $cref ode_err_control.cpp$$ and $cref ode_err_maxabs.cpp$$ contain examples and tests of using this routine. They return true if they succeed and false otherwise. $head Theory$$ Let $latex e(s)$$ be the error as a function of the step size $latex s$$ and suppose that there is a constant $latex K$$ such that $latex e(s) = K s^m$$. Let $latex a$$ be our error bound. Given the value of $latex e(s)$$, a step of size $latex \lambda s$$ would be ok provided that $latex \[ \begin{array}{rcl} a & \geq & e( \lambda s ) (tf - ti) / ( \lambda s ) \\ a & \geq & K \lambda^m s^m (tf - ti) / ( \lambda s ) \\ a & \geq & \lambda^{m-1} s^{m-1} (tf - ti) e(s) / s^m \\ a & \geq & \lambda^{m-1} (tf - ti) e(s) / s \\ \lambda^{m-1} & \leq & \frac{a}{e(s)} \frac{s}{tf - ti} \end{array} \] $$ Thus if the right hand side of the last inequality is greater than or equal to one, the step of size $latex s$$ is ok. $head Source Code$$ The source code for this routine is in the file $code cppad/ode_err_control.hpp$$. $end -------------------------------------------------------------------------- */ // link exp and log for float and double # include # include # include # include namespace CppAD { // Begin CppAD namespace template Vector OdeErrControl( Method &method, const Scalar &ti , const Scalar &tf , const Vector &xi , const Scalar &smin , const Scalar &smax , Scalar &scur , const Vector &eabs , const Scalar &erel , Vector &ef , Vector &maxabs, size_t &nstep ) { // check simple vector class specifications CheckSimpleVector(); size_t n = size_t(xi.size()); CPPAD_ASSERT_KNOWN( smin <= smax, "Error in OdeErrControl: smin > smax" ); CPPAD_ASSERT_KNOWN( size_t(eabs.size()) == n, "Error in OdeErrControl: size of eabs is not equal to n" ); CPPAD_ASSERT_KNOWN( size_t(maxabs.size()) == n, "Error in OdeErrControl: size of maxabs is not equal to n" ); size_t m = method.order(); CPPAD_ASSERT_KNOWN( m > 1, "Error in OdeErrControl: m is less than or equal one" ); bool ok; bool minimum_step; size_t i; Vector xa(n), xb(n), eb(n), nan_vec(n); // initialization Scalar zero(0); Scalar one(1); Scalar two(2); Scalar three(3); Scalar m1(m-1); Scalar ta = ti; for(i = 0; i < n; i++) { nan_vec[i] = nan(zero); ef[i] = zero; xa[i] = xi[i]; if( zero <= xi[i] ) maxabs[i] = xi[i]; else maxabs[i] = - xi[i]; } nstep = 0; Scalar tb, step, lambda, axbi, a, r, root; while( ! (ta == tf) ) { // start with value suggested by error criteria step = scur; // check maximum if( smax <= step ) step = smax; // check minimum minimum_step = step <= smin; if( minimum_step ) step = smin; // check if near the end if( tf <= ta + step * three / two ) tb = tf; else tb = ta + step; // try using this step size nstep++; method.step(ta, tb, xa, xb, eb); step = tb - ta; // check if this steps error estimate is ok ok = ! (hasnan(xb) || hasnan(eb)); if( (! ok) && minimum_step ) { ef = nan_vec; return nan_vec; } // compute value of lambda for this step lambda = Scalar(10) * scur / step; for(i = 0; i < n; i++) { if( zero <= xb[i] ) axbi = xb[i]; else axbi = - xb[i]; a = eabs[i] + erel * axbi; if( ! (eb[i] == zero) ) { r = ( a / eb[i] ) * step / (tf - ti); root = exp( log(r) / m1 ); if( root <= lambda ) lambda = root; } } if( ok && ( one <= lambda || step <= smin * three / two) ) { // this step is within error limits or // close to the minimum size ta = tb; for(i = 0; i < n; i++) { xa[i] = xb[i]; ef[i] = ef[i] + eb[i]; if( zero <= xb[i] ) axbi = xb[i]; else axbi = - xb[i]; if( axbi > maxabs[i] ) maxabs[i] = axbi; } } if( ! ok ) { // decrease step an see if method will work this time scur = step / two; } else if( ! (ta == tf) ) { // step suggested by the error criteria is not used // on the last step because it may be very small. scur = lambda * step / two; } } return xa; } template Vector OdeErrControl( Method &method, const Scalar &ti , const Scalar &tf , const Vector &xi , const Scalar &smin , const Scalar &smax , Scalar &scur , const Vector &eabs , const Scalar &erel , Vector &ef ) { Vector maxabs(xi.size()); size_t nstep; return OdeErrControl( method, ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep ); } template Vector OdeErrControl( Method &method, const Scalar &ti , const Scalar &tf , const Vector &xi , const Scalar &smin , const Scalar &smax , Scalar &scur , const Vector &eabs , const Scalar &erel , Vector &ef , Vector &maxabs) { size_t nstep; return OdeErrControl( method, ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep ); } } // End CppAD namespace # endif cppad-20160000.1/cppad/utility/pow_int.hpp0000644000175200017650000000626012656321766017423 0ustar coincoin-web// $Id: pow_int.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_POW_INT_HPP # define CPPAD_POW_INT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin pow_int$$ $spell cppad.hpp CppAD namespace const $$ $section The Integer Power Function$$ $mindex pow exponent$$ $head Syntax$$ $codei%# include %$$ $icode%z% = pow(%x%, %y%)%$$ $head See Also$$ $cref pow$$ $head Purpose$$ Determines the value of the power function $latex \[ {\rm pow} (x, y) = x^y \] $$ for integer exponents $icode n$$ using multiplication and possibly division to compute the value. The other CppAD $cref pow$$ function may use logarithms and exponentiation to compute derivatives of the same value (which will not work if $icode x$$ is less than or equal zero). $head Include$$ The file $code cppad/pow_int.h$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. Including this file defines this version of the $code pow$$ within the $code CppAD$$ namespace. $head x$$ The argument $icode x$$ has prototype $codei% const %Type%& %x% %$$ $head y$$ The argument $icode y$$ has prototype $codei% const int& %y% %$$ $head z$$ The result $icode z$$ has prototype $codei% %Type% %z% %$$ $head Type$$ The type $icode Type$$ must support the following operations where $icode a$$ and $icode b$$ are $icode Type$$ objects and $icode i$$ is an $code int$$: $table $bold Operation$$ $pre $$ $cnext $bold Description$$ $cnext $bold Result Type$$ $rnext $icode%Type% %a%(%i%)%$$ $cnext construction of a $icode Type$$ object from an $code int$$ $cnext $icode Type$$ $rnext $icode%a% * %b%$$ $cnext binary multiplication of $icode Type$$ objects $cnext $icode Type$$ $rnext $icode%a% / %b%$$ $cnext binary division of $icode Type$$ objects $cnext $icode Type$$ $tend $head Operation Sequence$$ The $icode Type$$ operation sequence used to calculate $icode z$$ is $cref/independent/glossary/Operation/Independent/$$ of $icode x$$. $head Example$$ $children% example/pow_int.cpp %$$ The file $cref pow_int.cpp$$ is an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- */ namespace CppAD { template inline Type pow (const Type& x, const int& n) { Type p(1); int n2 = n / 2; if( n == 0 ) return p; if( n < 0 ) return p / pow(x, -n); if( n == 1 ) return x; // p = (x^2)^(n/2) p = pow( x * x , n2 ); // n is even case if( n % 2 == 0 ) return p; // n is odd case return p * x; } } # endif cppad-20160000.1/cppad/utility/thread_alloc.hpp0000644000175200017650000012452412656321766020371 0ustar coincoin-web// $Id: thread_alloc.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_THREAD_ALLOC_HPP # define CPPAD_THREAD_ALLOC_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include # ifdef _MSC_VER // Supress warning that Microsoft compiler changed its behavior and is now // doing the correct thing at the statement: // new(array + i) Type(); # pragma warning(disable:4345) # endif # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file thread_alloc.hpp File used to define the CppAD multi-threading allocator class */ /*! \def CPPAD_MAX_NUM_CAPACITY Maximum number of different capacities the allocator will attempt. This must be larger than the log base two of numeric_limit::max(). */ # define CPPAD_MAX_NUM_CAPACITY 100 /*! \def CPPAD_MIN_DOUBLE_CAPACITY Minimum number of double values that will fit in an allocation. */ # define CPPAD_MIN_DOUBLE_CAPACITY 16 /*! \def CPPAD_TRACE_CAPACITY If NDEBUG is not defined, print all calls to \c get_memory and \c return_memory that correspond to this capacity and thread CPPAD_TRACE_THREAD. (Note that if CPPAD_TRACE_CAPACITY is zero, or any other value not in the list of capacities, no tracing will be done.) */ # define CPPAD_TRACE_CAPACITY 0 /*! \def CPPAD_TRACE_THREAD If NDEBUG is not defined, print all calls to \c get_memory and \c return_memory that correspond to this thead and capacity CPPAD_TRACE_CAPACITY. */ # define CPPAD_TRACE_THREAD 0 /* Note that Section 3.6.2 of ISO/IEC 14882:1998(E) states: "The storage for objects with static storage duration (3.7.1) shall be zero-initialized (8.5) before any other initialization takes place." */ /*! Capacity vector for memory allocation block sizes. Only one of these objects should be created and used as a static variable inside of the \c thread_alloc::capacity_info function. */ /*! Allocator class that works well with an multi-threading environment. */ class thread_alloc{ // ============================================================================ private: class capacity_t { public: /// number of capacity values actually used size_t number; /// the different capacity values size_t value[CPPAD_MAX_NUM_CAPACITY]; /// ctor capacity_t(void) { // Cannot figure out how to call thread_alloc::in_parallel here. // CPPAD_ASSERT_UNKNOWN( // ! thread_alloc::in_parallel() , "thread_alloc: " // "parallel mode and parallel_setup not yet called." // ); number = 0; size_t capacity = CPPAD_MIN_DOUBLE_CAPACITY * sizeof(double); while( capacity < std::numeric_limits::max() / 2 ) { CPPAD_ASSERT_UNKNOWN( number < CPPAD_MAX_NUM_CAPACITY ); value[number++] = capacity; // next capactiy is 3/2 times the current one capacity = 3 * ( (capacity + 1) / 2 ); } CPPAD_ASSERT_UNKNOWN( number > 0 ); } }; class block_t { public: /// extra information (currently used by create and delete array) size_t extra_; /// an index that uniquely idenfifies both thread and capacity size_t tc_index_; /// pointer to the next memory allocation with the same tc_index_ void* next_; // ----------------------------------------------------------------- /// make default constructor private. It is only used by constructor /// for `root arrays below. block_t(void) : extra_(0), tc_index_(0), next_(CPPAD_NULL) { } }; // --------------------------------------------------------------------- /// Vector of fixed capacity values for this allocator static const capacity_t* capacity_info(void) { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; static const capacity_t capacity; return &capacity; } // --------------------------------------------------------------------- /// Structure of information for each thread struct thread_alloc_info { /// count of available bytes for this thread size_t count_inuse_; /// count of inuse bytes for this thread size_t count_available_; /// root of available list for this thread and each capacity block_t root_available_[CPPAD_MAX_NUM_CAPACITY]; /// root of inuse list for this thread and each capacity /// If NDEBUG is true, this memory is not used, but it still /// helps separate this structure from one for the next thread. block_t root_inuse_[CPPAD_MAX_NUM_CAPACITY]; }; // --------------------------------------------------------------------- /*! Set and Get hold available memory flag. \param set [in] if true, the value returned by this return is changed. \param new_value [in] if \a set is true, this is the new value returned by this routine. Otherwise, \c new_value is ignored. \return the current setting for this routine (which is initially false). */ static bool set_get_hold_memory(bool set, bool new_value = false) { static bool value = false; if( set ) value = new_value; return value; } // --------------------------------------------------------------------- /*! Get pointer to the information for this thread. \param thread [in] Is the thread number for this information pointer. \param clear If \a clear is true, then the information pointer for this thread is deleted and the \c CPPAD_NULL pointer is returned. There must be no memory currently in either the inuse or avaialble lists when this routine is called. \return is the current informaiton pointer for this thread. If \a clear is false, and the current pointer is CPPAD_NULL, a new infromation record is allocated and its pointer returned. In this case, if \c info is the retured pointer, info->count_inuse == 0 and info->count_available == 0. In addition, for c = 0 , ... , CPPAD_MAX_NUM_CAPACITY-1 info->root_inuse_[c].next_ == CPPAD_NULL and info->root_available_[c].next_ == CPPAD_NULL. */ static thread_alloc_info* thread_info( size_t thread , bool clear = false ) { static thread_alloc_info* all_info[CPPAD_MAX_NUM_THREADS]; static thread_alloc_info zero_info; CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS ); thread_alloc_info* info = all_info[thread]; if( clear ) { if( info != CPPAD_NULL ) { # ifndef NDEBUG CPPAD_ASSERT_UNKNOWN( info->count_inuse_ == 0 && info->count_available_ == 0 ); for(size_t c = 0; c < CPPAD_MAX_NUM_CAPACITY; c++) { CPPAD_ASSERT_UNKNOWN( info->root_inuse_[c].next_ == CPPAD_NULL && info->root_available_[c].next_ == CPPAD_NULL ); } # endif if( thread != 0 ) ::operator delete( reinterpret_cast(info) ); info = CPPAD_NULL; all_info[thread] = info; } } else if( info == CPPAD_NULL ) { if( thread == 0 ) info = &zero_info; else { size_t size = sizeof(thread_alloc_info); void* v_ptr = ::operator new(size); info = reinterpret_cast(v_ptr); } all_info[thread] = info; // initialize the information record for(size_t c = 0; c < CPPAD_MAX_NUM_CAPACITY; c++) { info->root_inuse_[c].next_ = CPPAD_NULL; info->root_available_[c].next_ = CPPAD_NULL; } info->count_inuse_ = 0; info->count_available_ = 0; } return info; } // ----------------------------------------------------------------------- /*! Increase the number of bytes of memory that are currently in use; i.e., that been obtained with \c get_memory and not yet returned. \param inc [in] amount to increase memory in use. \param thread [in] Thread for which we are increasing the number of bytes in use (must be less than \c num_threads). Durring parallel execution, this must be the thread that is currently executing. */ static void inc_inuse(size_t inc, size_t thread) { CPPAD_ASSERT_UNKNOWN( thread < num_threads() ); CPPAD_ASSERT_UNKNOWN( thread == thread_num() || (! in_parallel()) ); thread_alloc_info* info = thread_info(thread); // do the addition size_t result = info->count_inuse_ + inc; CPPAD_ASSERT_UNKNOWN( result >= info->count_inuse_ ); info->count_inuse_ = result; } // ----------------------------------------------------------------------- /*! Increase the number of bytes of memory that are currently avaialble; i.e., have been obtained obtained from the system and are being held future use. \copydetails inc_inuse */ static void inc_available(size_t inc, size_t thread) { CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); CPPAD_ASSERT_UNKNOWN( thread == thread_num() || (! in_parallel()) ); thread_alloc_info* info = thread_info(thread); // do the addition size_t result = info->count_available_ + inc; CPPAD_ASSERT_UNKNOWN( result >= info->count_available_ ); info->count_available_ = result; } // ----------------------------------------------------------------------- /*! Decrease the number of bytes of memory that are currently in use; i.e., that been obtained with \c get_memory and not yet returned. \param dec [in] amount to decrease number of bytes in use. \param thread [in] Thread for which we are decreasing the number of bytes in use (must be less than \c num_threads). Durring parallel execution, this must be the thread that is currently executing. */ static void dec_inuse(size_t dec, size_t thread) { CPPAD_ASSERT_UNKNOWN( thread < num_threads() || (! in_parallel()) ); CPPAD_ASSERT_UNKNOWN( thread == thread_num() || (! in_parallel()) ); thread_alloc_info* info = thread_info(thread); // do the subtraction CPPAD_ASSERT_UNKNOWN( info->count_inuse_ >= dec ); info->count_inuse_ = info->count_inuse_ - dec; } // ----------------------------------------------------------------------- /*! Decrease the number of bytes of memory that are currently avaialble; i.e., have been obtained obtained from the system and are being held future use. \copydetails dec_inuse */ static void dec_available(size_t dec, size_t thread) { CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); CPPAD_ASSERT_UNKNOWN( thread == thread_num() || (! in_parallel()) ); thread_alloc_info* info = thread_info(thread); // do the subtraction CPPAD_ASSERT_UNKNOWN( info->count_available_ >= dec ); info->count_available_ = info->count_available_ - dec; } // ---------------------------------------------------------------------- /*! Set and get the number of threads that are sharing memory. \param number_new If \c number is zero, we are only retreiving the current maximum number of threads. Otherwise, we are setting and retreiving maximum number of threads. \return the number of threads that are sharing memory. If \c number_new is non-zero, the return value is equal to \c number_new. */ static size_t set_get_num_threads(size_t number_new) { static size_t number_user = 1; CPPAD_ASSERT_UNKNOWN( number_new <= CPPAD_MAX_NUM_THREADS ); CPPAD_ASSERT_UNKNOWN( ! in_parallel() || (number_new == 0) ); // case where we are changing the number of threads if( number_new != 0 ) number_user = number_new; return number_user; } /*! Set and call the routine that determine the current thread number. \return returns value for the most recent setting for \a thread_num_new. If \a set is true, or the most recent setting is \c CPPAD_NULL (its initial value), the return value is zero. Otherwise the routine corresponding to the most recent setting is called and its value returned by \c set_get_thread_num. \param thread_num_new [in] If \a set is false, \a thread_num_new it is not used. Otherwise, the current value of \c thread_num_new becomes the most recent setting for thread_num. \param set If \a set is true, then \a thread_num_new is becomes the most recent setting for this \c set_get_thread_num. */ static size_t set_get_thread_num( size_t (*thread_num_new)(void) , bool set = false ) { static size_t (*thread_num_user)(void) = CPPAD_NULL; if( set ) { thread_num_user = thread_num_new; return 0; } if( thread_num_user == CPPAD_NULL ) return 0; size_t thread = thread_num_user(); CPPAD_ASSERT_KNOWN( thread < set_get_num_threads(0) , "parallel_setup: thread_num() >= num_threads" ); return thread; } // ============================================================================ public: /* $begin ta_parallel_setup$$ $spell alloc num bool $$ $section Setup thread_alloc For Use in Multi-Threading Environment$$ $mindex parallel initialize$$ $head Syntax$$ $codei%thread_alloc::parallel_setup(%num_threads%, %in_parallel%, %thread_num%) %$$ $head Purpose$$ By default there is only one thread and all execution is in sequential mode, i.e., multiple threads are not sharing the same memory; i.e. not in parallel mode. $head Speed$$ It should be faster, even when $icode num_thread$$ is equal to one, for $code thread_alloc$$ to hold onto memory. This can be accomplished using the function call $codei% thread_alloc::hold_memory(true) %$$ see $cref/hold_memory/ta_hold_memory/$$. $head num_threads$$ This argument has prototype $codei% size_t %num_threads% %$$ and must be greater than zero. It specifies the number of threads that are sharing memory. The case $icode%num_threads% == 1%$$ is a special case that is used to terminate a multi-threading environment. $head in_parallel$$ This function has prototype $codei% bool %in_parallel%(void) %$$ It must return $code true$$ if there is more than one thread currently executing. Otherwise it can return false. $pre $$ In the special case where $icode%num_threads% == 1%$$, the routine $icode in_parallel$$ is not used. $head thread_num$$ This function has prototype $codei% size_t %thread_num%(void) %$$ It must return a thread number that uniquely identifies the currently executing thread. Furthermore $codei% 0 <= %thread_num%() < %num_threads% %$$. In the special case where $icode%num_threads% == 1%$$, the routine $icode thread_num$$ is not used. $pre $$ Note that this function is called by other routines so, as soon as a new thread is executing, one must be certain that $icode thread_num()$$ will work for that thread. $head Restrictions$$ The function $code parallel_setup$$ must be called before the program enters $cref/parallel/ta_in_parallel/$$ execution mode. In addition, this function cannot be called while in parallel mode. $head Example$$ The files $cref simple_ad_openmp.cpp$$, $cref simple_ad_bthread.cpp$$, and $cref simple_ad_pthread.cpp$$, contain examples and tests that use this function. $end */ /*! Set thread_alloc up for parallel mode usage. \param num_threads [in] Is the number of thread that may be executing at the same time. \param in_parallel [in] Is the routine that determines if we are in parallel mode or not. \param thread_num [in] Is the routine that determines the current thread number (between zero and num_threads minus one). */ static void parallel_setup( size_t num_threads , bool (*in_parallel)(void) , size_t (*thread_num)(void) ) { // Special case where we go back to single thread mode right away // (previous settings may no longer be valid) if( num_threads == 1 ) { bool set = true; set_get_num_threads(num_threads); // emphasize that this routine is outside thread_alloc class CppAD::set_get_in_parallel(CPPAD_NULL, set); set_get_thread_num(CPPAD_NULL, set); return; } CPPAD_ASSERT_KNOWN( num_threads <= CPPAD_MAX_NUM_THREADS , "parallel_setup: num_threads is too large" ); CPPAD_ASSERT_KNOWN( num_threads != 0 , "parallel_setup: num_threads == zero" ); CPPAD_ASSERT_KNOWN( in_parallel != CPPAD_NULL , "parallel_setup: num_threads != 1 and in_parallel == CPPAD_NULL" ); CPPAD_ASSERT_KNOWN( thread_num != CPPAD_NULL , "parallel_setup: num_threads != 1 and thread_num == CPPAD_NULL" ); // Make sure that constructors for all static variables in this file // are called in sequential mode. for(size_t thread = 0; thread < num_threads; thread++) thread_info(thread); capacity_info(); size_t cap_bytes; void* v_ptr = get_memory(0, cap_bytes); // free memory allocated by call to get_memory above return_memory(v_ptr); free_available( set_get_thread_num(CPPAD_NULL) ); // delay this so thread_num() call above is in previous mode // (current setings may not yet be valid) if( num_threads > 1 ) { bool set = true; set_get_num_threads(num_threads); // emphasize that this routine is outside thread_alloc class CppAD::set_get_in_parallel(in_parallel, set); set_get_thread_num(thread_num, set); } } /* $begin ta_num_threads$$ $spell inv CppAD num alloc $$ $section Get Number of Threads$$ $head Syntax$$ $icode%number% = thread_alloc::num_threads()%$$ $head Purpose$$ Determine the number of threads as set during $cref/parallel_setup/ta_parallel_setup/$$. $head number$$ The return value $icode number$$ has prototype $codei% size_t %number% %$$ and is equal to the value of $cref/num_threads/ta_parallel_setup/num_threads/$$ in the previous call to $icode parallel_setup$$. If there was no such previous call, the value one is returned. $head Example$$ The example and test $cref thread_alloc.cpp$$ uses this routine. $end */ /*! Get the current number of threads that thread_alloc can use. */ static size_t num_threads(void) { return set_get_num_threads(0); } /* ----------------------------------------------------------------------- $begin ta_in_parallel$$ $section Is The Current Execution in Parallel Mode$$ $mindex sequential$$ $spell thread_alloc bool $$ $head Syntax$$ $icode%flag% = thread_alloc::in_parallel()%$$ $head Purpose$$ Some of the $cref thread_alloc$$ allocation routines have different specifications for parallel (not sequential) execution mode. This routine enables you to determine if the current execution mode is sequential or parallel. $head flag$$ The return value has prototype $codei% bool %flag% %$$ It is true if the current execution is in parallel mode (possibly multi-threaded) and false otherwise (sequential mode). $head Example$$ $cref thread_alloc.cpp$$ $end */ /// Are we in a parallel execution state; i.e., is it possible that /// other threads are currently executing. static bool in_parallel(void) { // emphasize that this routine is outside thread_alloc class return CppAD::set_get_in_parallel(0); } /* ----------------------------------------------------------------------- $begin ta_thread_num$$ $spell CppAD num thread_alloc cppad.hpp $$ $section Get the Current Thread Number$$ $head Syntax$$ $icode%thread% = thread_alloc::thread_num()%$$ $head Purpose$$ Some of the $cref thread_alloc$$ allocation routines have a thread number. This routine enables you to determine the current thread. $head thread$$ The return value $icode thread$$ has prototype $codei% size_t %thread% %$$ and is the currently executing thread number. $head Example$$ $cref thread_alloc.cpp$$ $end */ /// Get current thread number static size_t thread_num(void) { return set_get_thread_num(CPPAD_NULL); } /* ----------------------------------------------------------------------- $begin ta_get_memory$$ $spell std num ptr thread_alloc $$ $section Get At Least A Specified Amount of Memory$$ $mindex allocate$$ $head Syntax$$ $icode%v_ptr% = thread_alloc::get_memory(%min_bytes%, %cap_bytes%)%$$ $head Purpose$$ Use $cref thread_alloc$$ to obtain a minimum number of bytes of memory (for use by the $cref/current thread/ta_thread_num/$$). $head min_bytes$$ This argument has prototype $codei% size_t %min_bytes% %$$ It specifies the minimum number of bytes to allocate. This value must be less than $codep std::numeric_limits::max() / 2 $$ $head cap_bytes$$ This argument has prototype $codei% size_t& %cap_bytes% %$$ It's input value does not matter. Upon return, it is the actual number of bytes (capacity) that have been allocated for use, $codei% %min_bytes% <= %cap_bytes% %$$ $head v_ptr$$ The return value $icode v_ptr$$ has prototype $codei% void* %v_ptr% %$$ It is the location where the $icode cap_bytes$$ of memory that have been allocated for use begins. $head Allocation Speed$$ This allocation should be faster if the following conditions hold: $list number$$ The memory allocated by a previous call to $code get_memory$$ is currently available for use. $lnext The current $icode min_bytes$$ is between the previous $icode min_bytes$$ and previous $icode cap_bytes$$. $lend $head Alignment$$ We call a memory allocation aligned if the address is a multiple of the number of bytes in a $code size_t$$ value. If the system $code new$$ allocator is aligned, then $icode v_ptr$$ pointer is also aligned. $head Example$$ $cref thread_alloc.cpp$$ $end */ /*! Use thread_alloc to get a specified amount of memory. If the memory allocated by a previous call to \c get_memory is now avaialable, and \c min_bytes is between its previous value and the previous \c cap_bytes, this memory allocation will have optimal speed. Otherwise, the memory allocation is more complicated and may have to wait for other threads to complete an allocation. \param min_bytes [in] The minimum number of bytes of memory to be obtained for use. \param cap_bytes [out] The actual number of bytes of memory obtained for use. \return pointer to the beginning of the memory allocated for use. */ static void* get_memory(size_t min_bytes, size_t& cap_bytes) { // see first_trace below CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; // check that number of requested bytes is not to large CPPAD_ASSERT_KNOWN( min_bytes < std::numeric_limits::max() / 2 , "get_memory(min_bytes, cap_bytes): min_bytes is too large" ); size_t num_cap = capacity_info()->number; using std::cout; using std::endl; // determine the capacity for this request size_t c_index = 0; const size_t* capacity_vec = capacity_info()->value; while( capacity_vec[c_index] < min_bytes ) { ++c_index; CPPAD_ASSERT_UNKNOWN(c_index < num_cap ); } cap_bytes = capacity_vec[c_index]; // determine the thread, capacity, and info for this thread size_t thread = thread_num(); size_t tc_index = thread * num_cap + c_index; thread_alloc_info* info = thread_info(thread); # ifndef NDEBUG // trace allocation static bool first_trace = true; if( cap_bytes == CPPAD_TRACE_CAPACITY && thread == CPPAD_TRACE_THREAD && first_trace ) { cout << endl; cout << "thread_alloc: Trace for Thread = " << thread; cout << " and capacity = " << cap_bytes << endl; if( first_trace ) first_trace = false; } // Root nodes for both lists. Note these are different for different // threads because tc_index is different for different threads. block_t* inuse_root = info->root_inuse_ + c_index; # endif block_t* available_root = info->root_available_ + c_index; // check if we already have a node we can use void* v_node = available_root->next_; block_t* node = reinterpret_cast(v_node); if( node != CPPAD_NULL ) { CPPAD_ASSERT_UNKNOWN( node->tc_index_ == tc_index ); // remove node from available list available_root->next_ = node->next_; // return value for get_memory void* v_ptr = reinterpret_cast(node + 1); # ifndef NDEBUG // add node to inuse list node->next_ = inuse_root->next_; inuse_root->next_ = v_node; // trace allocation if( cap_bytes == CPPAD_TRACE_CAPACITY && thread == CPPAD_TRACE_THREAD ) { cout << "get_memory: v_ptr = " << v_ptr << endl; } # endif // adjust counts inc_inuse(cap_bytes, thread); dec_available(cap_bytes, thread); // return pointer to memory, do not inclue thread_alloc information return v_ptr; } // Create a new node with thread_alloc information at front. // This uses the system allocator, which is thread safe, but slower, // because the thread might wait for a lock on the allocator. v_node = ::operator new(sizeof(block_t) + cap_bytes); node = reinterpret_cast(v_node); node->tc_index_ = tc_index; void* v_ptr = reinterpret_cast(node + 1); # ifndef NDEBUG // add node to inuse list node->next_ = inuse_root->next_; inuse_root->next_ = v_node; // trace allocation if( cap_bytes == CPPAD_TRACE_CAPACITY && thread == CPPAD_TRACE_THREAD ) { cout << "get_memory: v_ptr = " << v_ptr << endl; } # endif // adjust counts inc_inuse(cap_bytes, thread); return v_ptr; } /* ----------------------------------------------------------------------- $begin ta_return_memory$$ $spell num ptr thread_alloc $$ $section Return Memory to thread_alloc$$ $mindex return_memory available$$ $head Syntax$$ $codei%thread_alloc::return_memory(%v_ptr%)%$$ $head Purpose$$ If $cref/hold_memory/ta_hold_memory/$$ is false, the memory is returned to the system. Otherwise, the memory is retained by $cref thread_alloc$$ for quick future use by the thread that allocated to memory. $head v_ptr$$ This argument has prototype $codei% void* %v_ptr% %$$. It must be a pointer to memory that is currently in use; i.e. obtained by a previous call to $cref/get_memory/ta_get_memory/$$ and not yet returned. $head Thread$$ Either the $cref/current thread/ta_thread_num/$$ must be the same as during the corresponding call to $cref/get_memory/ta_get_memory/$$, or the current execution mode must be sequential (not $cref/parallel/ta_in_parallel/$$). $head NDEBUG$$ If $code NDEBUG$$ is defined, $icode v_ptr$$ is not checked (this is faster). Otherwise, a list of in use pointers is searched to make sure that $icode v_ptr$$ is in the list. $head Example$$ $cref thread_alloc.cpp$$ $end */ /*! Return memory that was obtained by \c get_memory. If num_threads() == 1, the memory is returned to the system. Otherwise, it is retained by \c thread_alloc and available for use by \c get_memory for this thread. \param v_ptr [in] Value of the pointer returned by \c get_memory and still in use. After this call, this pointer will available (and not in use). \par We must either be in sequential (not parallel) execution mode, or the current thread must be the same as for the corresponding call to \c get_memory. */ static void return_memory(void* v_ptr) { size_t num_cap = capacity_info()->number; block_t* node = reinterpret_cast(v_ptr) - 1; size_t tc_index = node->tc_index_; size_t thread = tc_index / num_cap; size_t c_index = tc_index % num_cap; size_t capacity = capacity_info()->value[c_index]; CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS ); CPPAD_ASSERT_KNOWN( thread == thread_num() || (! in_parallel()), "Attempt to return memory for a different thread " "while in parallel mode" ); thread_alloc_info* info = thread_info(thread); # ifndef NDEBUG // remove node from inuse list void* v_node = reinterpret_cast(node); block_t* inuse_root = info->root_inuse_ + c_index; block_t* previous = inuse_root; while( (previous->next_ != CPPAD_NULL) & (previous->next_ != v_node) ) previous = reinterpret_cast(previous->next_); // check that v_ptr is valid if( previous->next_ != v_node ) { using std::endl; std::ostringstream oss; oss << "return_memory: attempt to return memory not in use"; oss << endl; oss << "v_ptr = " << v_ptr << endl; oss << "thread = " << thread << endl; oss << "capacity = " << capacity << endl; oss << "See CPPAD_TRACE_THREAD & CPPAD_TRACE_CAPACITY in"; oss << endl << "%# include " << endl; // oss.str() returns a string object with a copy of the current // contents in the stream buffer. std::string msg_str = oss.str(); // msg_str.c_str() returns a pointer to the c-string // representation of the string object's value. const char* msg_char_star = msg_str.c_str(); CPPAD_ASSERT_KNOWN(false, msg_char_star ); } // trace option if( capacity==CPPAD_TRACE_CAPACITY && thread==CPPAD_TRACE_THREAD ) { std::cout << "return_memory: v_ptr = " << v_ptr << std::endl; } // remove v_ptr from inuse list previous->next_ = node->next_; # endif // capacity bytes are removed from the inuse pool dec_inuse(capacity, thread); // check for case where we just return the memory to the system if( ! set_get_hold_memory(false) ) { ::operator delete( reinterpret_cast(node) ); return; } // add this node to available list for this thread and capacity block_t* available_root = info->root_available_ + c_index; node->next_ = available_root->next_; available_root->next_ = reinterpret_cast(node); // capacity bytes are added to the available pool inc_available(capacity, thread); } /* ----------------------------------------------------------------------- $begin ta_free_available$$ $spell num thread_alloc $$ $section Free Memory Currently Available for Quick Use by a Thread$$ $mindex free_available$$ $spell inuse $$ $head Syntax$$ $codei%thread_alloc::free_available(%thread%)%$$ $head Purpose$$ Return to the system all the memory that is currently being $cref/held/ta_hold_memory/$$ for quick use by the specified thread. $subhead Extra Memory$$ In the case where $icode%thread% > 0%$$, some extra memory is used to track allocations by the specified thread. If $codei% thread_alloc::inuse(%thread%) == 0 %$$ the extra memory is also returned to the system. $head thread$$ This argument has prototype $codei% size_t %thread% %$$ Either $cref/thread_num/ta_thread_num/$$ must be the same as $icode thread$$, or the current execution mode must be sequential (not $cref/parallel/ta_in_parallel/$$). $head Example$$ $cref thread_alloc.cpp$$ $end */ /*! Return all the memory being held as available for a thread to the system. \param thread [in] this thread that will no longer have any available memory after this call. This must either be the thread currently executing, or we must be in sequential (not parallel) execution mode. */ static void free_available(size_t thread) { CPPAD_ASSERT_KNOWN( thread < CPPAD_MAX_NUM_THREADS, "Attempt to free memory for a thread >= CPPAD_MAX_NUM_THREADS" ); CPPAD_ASSERT_KNOWN( thread == thread_num() || (! in_parallel()), "Attempt to free memory for a different thread " "while in parallel mode" ); size_t num_cap = capacity_info()->number; if( num_cap == 0 ) return; const size_t* capacity_vec = capacity_info()->value; size_t c_index; thread_alloc_info* info = thread_info(thread); for(c_index = 0; c_index < num_cap; c_index++) { size_t capacity = capacity_vec[c_index]; block_t* available_root = info->root_available_ + c_index; void* v_ptr = available_root->next_; while( v_ptr != CPPAD_NULL ) { block_t* node = reinterpret_cast(v_ptr); void* next = node->next_; ::operator delete(v_ptr); v_ptr = next; dec_available(capacity, thread); } available_root->next_ = CPPAD_NULL; } CPPAD_ASSERT_UNKNOWN( available(thread) == 0 ); if( inuse(thread) == 0 ) { // clear the information for this thread thread_info(thread, true); } } /* ----------------------------------------------------------------------- $begin ta_hold_memory$$ $spell alloc num $$ $section Control When Thread Alloc Retains Memory For Future Use$$ $mindex hold$$ $head Syntax$$ $codei%thread_alloc::hold_memory(%value%)%$$ $head Purpose$$ It should be faster, even when $icode num_thread$$ is equal to one, for $code thread_alloc$$ to hold onto memory. Calling $icode hold_memory$$ with $icode value$$ equal to true, instructs $code thread_alloc$$ to hold onto memory, and put it in the $cref/available/ta_available/$$ pool, after each call to $cref/return_memory/ta_return_memory/$$. $head value$$ If $icode value$$ is true, $code thread_alloc$$ with hold onto memory for future quick use. If it is false, future calls to $cref/return_memory/ta_return_memory/$$ will return the corresponding memory to the system. By default (when $code hold_memory$$ has not been called) $code thread_alloc$$ does not hold onto memory. $head free_available$$ Memory that is being held by $code thread_alloc$$ can be returned to the system using $cref/free_available/ta_free_available/$$. $end */ /*! Change the thread_alloc hold memory setting. \param value [in] New value for the thread_alloc hold memory setting. */ static void hold_memory(bool value) { bool set = true; set_get_hold_memory(set, value); } /* ----------------------------------------------------------------------- $begin ta_inuse$$ $spell num inuse thread_alloc $$ $section Amount of Memory a Thread is Currently Using$$ $mindex inuse$$ $head Syntax$$ $icode%num_bytes% = thread_alloc::inuse(%thread%)%$$ $head Purpose$$ Memory being managed by $cref thread_alloc$$ has two states, currently in use by the specified thread, and quickly available for future use by the specified thread. This function informs the program how much memory is in use. $head thread$$ This argument has prototype $codei% size_t %thread% %$$ Either $cref/thread_num/ta_thread_num/$$ must be the same as $icode thread$$, or the current execution mode must be sequential (not $cref/parallel/ta_in_parallel/$$). $head num_bytes$$ The return value has prototype $codei% size_t %num_bytes% %$$ It is the number of bytes currently in use by the specified thread. $head Example$$ $cref thread_alloc.cpp$$ $end */ /*! Determine the amount of memory that is currently inuse. \param thread [in] Thread for which we are determining the amount of memory (must be < CPPAD_MAX_NUM_THREADS). Durring parallel execution, this must be the thread that is currently executing. \return The amount of memory in bytes. */ static size_t inuse(size_t thread) { CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); CPPAD_ASSERT_UNKNOWN( thread == thread_num() || (! in_parallel()) ); thread_alloc_info* info = thread_info(thread); return info->count_inuse_; } /* ----------------------------------------------------------------------- $begin ta_available$$ $spell num thread_alloc $$ $section Amount of Memory Available for Quick Use by a Thread$$ $head Syntax$$ $icode%num_bytes% = thread_alloc::available(%thread%)%$$ $head Purpose$$ Memory being managed by $cref thread_alloc$$ has two states, currently in use by the specified thread, and quickly available for future use by the specified thread. This function informs the program how much memory is available. $head thread$$ This argument has prototype $codei% size_t %thread% %$$ Either $cref/thread_num/ta_thread_num/$$ must be the same as $icode thread$$, or the current execution mode must be sequential (not $cref/parallel/ta_in_parallel/$$). $head num_bytes$$ The return value has prototype $codei% size_t %num_bytes% %$$ It is the number of bytes currently available for use by the specified thread. $head Example$$ $cref thread_alloc.cpp$$ $end */ /*! Determine the amount of memory that is currently available for use. \copydetails inuse */ static size_t available(size_t thread) { CPPAD_ASSERT_UNKNOWN( thread < CPPAD_MAX_NUM_THREADS); CPPAD_ASSERT_UNKNOWN( thread == thread_num() || (! in_parallel()) ); thread_alloc_info* info = thread_info(thread); return info->count_available_; } /* ----------------------------------------------------------------------- $begin ta_create_array$$ $spell inuse thread_alloc sizeof $$ $section Allocate An Array and Call Default Constructor for its Elements$$ $mindex create_array$$ $head Syntax$$ $icode%array% = thread_alloc::create_array<%Type%>(%size_min%, %size_out%)%$$. $head Purpose$$ Create a new raw array using $cref thread_alloc$$ memory allocator (works well in a multi-threading environment) and call default constructor for each element. $head Type$$ The type of the elements of the array. $head size_min$$ This argument has prototype $codei% size_t %size_min% %$$ This is the minimum number of elements that there can be in the resulting $icode array$$. $head size_out$$ This argument has prototype $codei% size_t& %size_out% %$$ The input value of this argument does not matter. Upon return, it is the actual number of elements in $icode array$$ ($icode% size_min %<=% size_out%$$). $head array$$ The return value $icode array$$ has prototype $codei% %Type%* %array% %$$ It is array with $icode size_out$$ elements. The default constructor for $icode Type$$ is used to initialize the elements of $icode array$$. Note that $cref/delete_array/ta_delete_array/$$ should be used to destroy the array when it is no longer needed. $head Delta$$ The amount of memory $cref/inuse/ta_inuse/$$ by the current thread, will increase $icode delta$$ where $codei% sizeof(%Type%) * (%size_out% + 1) > %delta% >= sizeof(%Type%) * %size_out% %$$ The $cref/available/ta_available/$$ memory will decrease by $icode delta$$, (and the allocation will be faster) if a previous allocation with $icode size_min$$ between its current value and $icode size_out$$ is available. $head Alignment$$ We call a memory allocation aligned if the address is a multiple of the number of bytes in a $code size_t$$ value. If the system $code new$$ allocator is aligned, then $icode array$$ pointer is also aligned. $head Example$$ $cref thread_alloc.cpp$$ $end */ /*! Use thread_alloc to allocate an array, then call default construtor for each element. \tparam Type The type of the elements of the array. \param size_min [in] The minimum number of elements in the array. \param size_out [out] The actual number of elements in the array. \return pointer to the first element of the array. The default constructor is used to initialize all the elements of the array. \par The \c extra_ field, in the \c thread_alloc node before the return value, is set to size_out. */ template static Type* create_array(size_t size_min, size_t& size_out) { // minimum number of bytes to allocate size_t min_bytes = size_min * sizeof(Type); // do the allocation size_t num_bytes; void* v_ptr = get_memory(min_bytes, num_bytes); // This is where the array starts Type* array = reinterpret_cast(v_ptr); // number of Type values in the allocation size_out = num_bytes / sizeof(Type); // store this number in the extra field block_t* node = reinterpret_cast(v_ptr) - 1; node->extra_ = size_out; // call default constructor for each element size_t i; for(i = 0; i < size_out; i++) new(array + i) Type(); return array; } /* ----------------------------------------------------------------------- $begin ta_delete_array$$ $spell inuse thread_alloc sizeof deallocate $$ $section Deallocate An Array and Call Destructor for its Elements$$ $mindex delete_array$$ $head Syntax$$ $codei%thread_alloc::delete_array(%array%)%$$. $head Purpose$$ Returns memory corresponding to an array created by (create by $cref/create_array/ta_create_array/$$) to the $cref/available/ta_available/$$ memory pool for the current thread. $head Type$$ The type of the elements of the array. $head array$$ The argument $icode array$$ has prototype $codei% %Type%* %array% %$$ It is a value returned by $cref/create_array/ta_create_array/$$ and not yet deleted. The $icode Type$$ destructor is called for each element in the array. $head Thread$$ The $cref/current thread/ta_thread_num/$$ must be the same as when $cref/create_array/ta_create_array/$$ returned the value $icode array$$. There is an exception to this rule: when the current execution mode is sequential (not $cref/parallel/ta_in_parallel/$$) the current thread number does not matter. $head Delta$$ The amount of memory $cref/inuse/ta_inuse/$$ will decrease by $icode delta$$, and the $cref/available/ta_available/$$ memory will increase by $icode delta$$, where $cref/delta/ta_create_array/Delta/$$ is the same as for the corresponding call to $code create_array$$. $head Example$$ $cref thread_alloc.cpp$$ $end */ /*! Return Memory Used for an Array to the Available Pool (include destructor call for each element). \tparam Type The type of the elements of the array. \param array [in] A value returned by \c create_array that has not yet been deleted. The \c Type destructor is used to destroy each of the elements of the array. \par Durring parallel execution, the current thread must be the same as during the corresponding call to \c create_array. */ template static void delete_array(Type* array) { // determine the number of values in the array block_t* node = reinterpret_cast(array) - 1; size_t size = node->extra_; // call destructor for each element size_t i; for(i = 0; i < size; i++) (array + i)->~Type(); // return the memory to the available pool for this thread thread_alloc::return_memory( reinterpret_cast(array) ); } /* ----------------------------------------------------------------------- $begin ta_free_all$$ $spell alloc bool inuse $$ $section Free All Memory That Was Allocated for Use by thread_alloc$$ $head Syntax$$ $icode%ok% = thread_alloc::free_all()%$$. $head Purpose$$ Returns all memory that was used by $code thread_alloc$$ to the system. $head ok$$ The return value $icode ok$$ has prototype $codei% bool %ok% %$$ Its value will be $code true$$ if all the memory can be freed. This requires that for all $icode thread$$ indices, there is no memory $cref/inuse/ta_inuse/$$; i.e., $codei% 0 == thread_alloc::inuse(%thread%) %$$ Otherwise, the return value will be false. $head Restrictions$$ This function cannot be called while in parallel mode. $head Example$$ $cref thread_alloc.cpp$$ $end */ /*! Return to the system all thread_alloc memory that is not currently inuse. \return If no \c thread_alloc memory is currently inuse, all memory is returned to the system and the return value is true. Otherwise the return value is false. */ static bool free_all(void) { CPPAD_ASSERT_KNOWN( ! in_parallel(), "free_all cannot be used while in parallel execution" ); bool ok = true; size_t thread = CPPAD_MAX_NUM_THREADS; while(thread--) { ok &= inuse(thread) == 0; free_available(thread); } return ok; } }; } // END_CPPAD_NAMESPACE // preprocessor symbols local to this file # undef CPPAD_MAX_NUM_CAPACITY # undef CPPAD_MIN_DOUBLE_CAPACITY # undef CPPAD_TRACE_CAPACITY # undef CPPAD_TRACE_THREAD # endif cppad-20160000.1/cppad/utility/poly.hpp0000644000175200017650000001130712656321766016725 0ustar coincoin-web// $Id: poly.hpp 3766 2015-12-08 23:12:56Z bradbell $ # ifndef CPPAD_POLY_HPP # define CPPAD_POLY_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Poly$$ $spell cppad.hpp CppAD namespace cstddef ifndef endif deg const std da $$ $section Evaluate a Polynomial or its Derivative$$ $mindex Poly template$$ $head Syntax$$ $codei%# include %$$ $icode%p% = Poly(%k%, %a%, %z%)%$$ $head Description$$ Computes the $th k$$ derivative of the polynomial $latex \[ P(z) = a_0 + a_1 z^1 + \cdots + a_d z^d \] $$ If $icode k$$ is equal to zero, the return value is $latex P(z)$$. $head Include$$ The file $code cppad/poly.hpp$$ is included by $code cppad/cppad.hpp$$ but it can also be included separately with out the rest of the $code CppAD$$ routines. Including this file defines $code Poly$$ within the $code CppAD$$ namespace. $head k$$ The argument $icode k$$ has prototype $codei% size_t %k% %$$ It specifies the order of the derivative to calculate. $head a$$ The argument $icode a$$ has prototype $codei% const %Vector% &%a% %$$ (see $cref/Vector/Poly/Vector/$$ below). It specifies the vector corresponding to the polynomial $latex P(z)$$. $head z$$ The argument $icode z$$ has prototype $codei% const %Type% &%z% %$$ (see $icode Type$$ below). It specifies the point at which to evaluate the polynomial $head p$$ The result $icode p$$ has prototype $codei% %Type% %p% %$$ (see $cref/Type/Poly/Type/$$ below) and it is equal to the $th k$$ derivative of $latex P(z)$$; i.e., $latex \[ p = \frac{k !}{0 !} a_k + \frac{(k+1) !}{1 !} a_{k+1} z^1 + \ldots + \frac{d !}{(d - k) !} a_d z^{d - k} \] $$ If $latex k > d$$, $icode%p% = %Type%(0)%$$. $head Type$$ The type $icode Type$$ is determined by the argument $icode z$$. It is assumed that multiplication and addition of $icode Type$$ objects are commutative. $subhead Operations$$ The following operations must be supported where $icode x$$ and $icode y$$ are objects of type $icode Type$$ and $icode i$$ is an $code int$$: $table $icode%x% = %i%$$ $cnext assignment $rnext $icode%x% = %y%$$ $cnext assignment $rnext $icode%x% *= %y%$$ $cnext multiplication computed assignment $rnext $icode%x% += %y%$$ $cnext addition computed assignment $tend $head Vector$$ The type $icode Vector$$ must be a $cref SimpleVector$$ class with $cref/elements of type/SimpleVector/Elements of Specified Type/$$ $icode Type$$. The routine $cref CheckSimpleVector$$ will generate an error message if this is not the case. $head Operation Sequence$$ The $icode Type$$ operation sequence used to calculate $icode p$$ is $cref/independent/glossary/Operation/Independent/$$ of $icode z$$ and the elements of $icode a$$ (it does depend on the size of the vector $icode a$$). $children% example/poly.cpp% omh/poly_hpp.omh %$$ $head Example$$ The file $cref poly.cpp$$ contains an example and test of this routine. It returns true if it succeeds and false otherwise. $head Source$$ The file $cref poly.hpp$$ contains the current source code that implements these specifications. $end ------------------------------------------------------------------------------ */ // BEGIN C++ # include // used to defined size_t # include namespace CppAD { // BEGIN CppAD namespace template Type Poly(size_t k, const Vector &a, const Type &z) { size_t i; size_t d = a.size() - 1; Type tmp; // check Vector is Simple Vector class with Type elements CheckSimpleVector(); // case where derivative order greater than degree of polynomial if( k > d ) { tmp = 0; return tmp; } // case where we are evaluating a derivative if( k > 0 ) { // initialize factor as (k-1) ! size_t factor = 1; for(i = 2; i < k; i++) factor *= i; // set b to coefficient vector corresponding to derivative Vector b(d - k + 1); for(i = k; i <= d; i++) { factor *= i; tmp = factor; b[i - k] = a[i] * tmp; factor /= (i - k + 1); } // value of derivative polynomial return Poly(0, b, z); } // case where we are evaluating the original polynomial Type sum = a[d]; i = d; while(i > 0) { sum *= z; sum += a[--i]; } return sum; } } // END CppAD namespace // END C++ # endif cppad-20160000.1/cppad/utility.hpp0000644000175200017650000000327712656321766015751 0ustar coincoin-web// $Id$ # ifndef CPPAD_UTILITY_HPP # define CPPAD_UTILITY_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # endif cppad-20160000.1/cppad/local/0002755000175200017650000000000012656321770014613 5ustar coincoin-webcppad-20160000.1/cppad/local/cond_exp.hpp0000644000175200017650000002254412656321766017135 0ustar coincoin-web// $Id: cond_exp.hpp 3768 2015-12-28 18:58:35Z bradbell $ # ifndef CPPAD_COND_EXP_HPP # define CPPAD_COND_EXP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin CondExp$$ $spell Atan2 CondExp Taylor std Cpp namespace inline const abs Rel bool Lt Le Eq Ge Gt $$ $section AD Conditional Expressions$$ $mindex assign$$ $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. There is one exception to this optimization; see $cref/optimizing nested conditional expressions /wish_list /Optimizing Nested Conditional Expressions /$$. $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/cond_exp.cpp %$$ The file $cref cond_exp.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $head Atan2$$ The following implementation of the AD $cref atan2$$ function is a more complex example of using conditional expressions: $code $verbatim%cppad/local/atan2.hpp%0%BEGIN CondExp%// END CondExp%$$ $$ $end ------------------------------------------------------------------------------- */ // BEGIN CppAD namespace namespace CppAD { template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION AD CondExpOp( enum CompareOp cop , const AD &left , const AD &right , const AD &if_true , const AD &if_false ) { AD returnValue; CPPAD_ASSERT_UNKNOWN( Parameter(returnValue) ); // check first case where do not need to tape if( IdenticalPar(left) & IdenticalPar(right) ) { switch( cop ) { case CompareLt: if( left.value_ < right.value_ ) returnValue = if_true; else returnValue = if_false; break; case CompareLe: if( left.value_ <= right.value_ ) returnValue = if_true; else returnValue = if_false; break; case CompareEq: if( left.value_ == right.value_ ) returnValue = if_true; else returnValue = if_false; break; case CompareGe: if( left.value_ >= right.value_ ) returnValue = if_true; else returnValue = if_false; break; case CompareGt: if( left.value_ > right.value_ ) returnValue = if_true; else returnValue = if_false; break; default: CPPAD_ASSERT_UNKNOWN(0); returnValue = if_true; } return returnValue; } // must use CondExp incase Base is an AD type and recording returnValue.value_ = CondExpOp(cop, left.value_, right.value_, if_true.value_, if_false.value_); ADTape *tape = CPPAD_NULL; if( Variable(left) ) tape = left.tape_this(); if( Variable(right) ) tape = right.tape_this(); if( Variable(if_true) ) tape = if_true.tape_this(); if( Variable(if_false) ) tape = if_false.tape_this(); // add this operation to the tape if( tape != CPPAD_NULL ) tape->RecordCondExp(cop, returnValue, left, right, if_true, if_false); return returnValue; } // --- RecordCondExp(cop, returnValue, left, right, if_true, if_false) ----- /// All these operations are done in \c Rec_, so we should move this /// routine to recorder. template void ADTape::RecordCondExp( enum CompareOp cop , AD &returnValue , const AD &left , const AD &right , const AD &if_true , const AD &if_false ) { size_t ind0, ind1, ind2, ind3, ind4, ind5; size_t returnValue_taddr; // taddr_ of this variable CPPAD_ASSERT_UNKNOWN( NumRes(CExpOp) == 1 ); returnValue_taddr = Rec_.PutOp(CExpOp); // ind[0] = cop ind0 = addr_t( cop ); // ind[1] = base 2 representaion of the value // [Var(left), Var(right), Var(if_true), Var(if_false)] ind1 = 0; // Make sure returnValue is in the list of variables and set its taddr if( Parameter(returnValue) ) returnValue.make_variable(id_, returnValue_taddr ); else returnValue.taddr_ = returnValue_taddr; // ind[2] = left address if( Parameter(left) ) ind2 = Rec_.PutPar(left.value_); else { ind1 += 1; ind2 = left.taddr_; } // ind[3] = right address if( Parameter(right) ) ind3 = Rec_.PutPar(right.value_); else { ind1 += 2; ind3 = right.taddr_; } // ind[4] = if_true address if( Parameter(if_true) ) ind4 = Rec_.PutPar(if_true.value_); else { ind1 += 4; ind4 = if_true.taddr_; } // ind[5] = if_false address if( Parameter(if_false) ) ind5 = Rec_.PutPar(if_false.value_); else { ind1 += 8; ind5 = if_false.taddr_; } CPPAD_ASSERT_UNKNOWN( NumArg(CExpOp) == 6 ); CPPAD_ASSERT_UNKNOWN( ind1 > 0 ); Rec_.PutArg(ind0, ind1, ind2, ind3, ind4, ind5); // check that returnValue is a dependent variable CPPAD_ASSERT_UNKNOWN( Variable(returnValue) ); } // ------------ 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 cppad-20160000.1/cppad/local/load_op.hpp0000644000175200017650000004641712656321766016760 0ustar coincoin-web// $Id: load_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_LOAD_OP_HPP # define CPPAD_LOAD_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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[ 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[ 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 inline void forward_load_op_0( player* play , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor , bool* isvar_by_ind , size_t* index_by_ind , addr_t* 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 \c sparse_pack, \c sparse_set, or \c 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 \a i_z in \a var_sparsity is the sparsity pattern correpsonding to z. \param arg \n \a arg[0] is the offset corresponding to this VecAD vector in the VecAD combined array. \param num_combined is the total number of elements in the VecAD combinded array. \param combined is the VecAD combined array. \n \n \a combined[ \a arg[0] - 1 ] is the index of the set corresponding to the vector v in \a vecad_sparsity. We use the notation i_v for this value; i.e., \verbatim i_v = combined[ \a arg[0] - 1 ] \endverbatim \param var_sparsity The set with index \a i_z in \a var_sparsity is the sparsity pattern for z. This is an output for forward mode operations, and an input for reverse mode operations. \param vecad_sparsity The set with index \a i_v is the sparsity pattern for the vector v. This is an input for forward mode operations. For reverse mode operations, the sparsity pattern for z is added to the sparsity pattern for v. \par Checked Assertions \li NumArg(op) == 3 \li NumRes(op) == 1 \li 0 < \a arg[0] \li \a arg[0] < \a num_combined \li i_v < \a vecad_sparsity.n_set() */ template inline void sparse_load_op( OpCode op , size_t i_z , 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 = LdpOp. \copydetails forward_load_op_0 */ template inline void forward_load_p_op_0( player* play , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor , bool* isvar_by_ind , size_t* index_by_ind , addr_t* 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() ); // Because the index is a parameter, this indexing error should have been // caught and reported to the user when the tape is recording. size_t i_vec = arg[1]; CPPAD_ASSERT_UNKNOWN( i_vec < index_by_ind[ arg[0] - 1 ] ); CPPAD_ASSERT_UNKNOWN( 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] ] = 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 forward_load_op_0 */ template inline void forward_load_v_op_0( player* play , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor , bool* isvar_by_ind , size_t* index_by_ind , addr_t* 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() ); size_t i_vec = Integer( taylor[ arg[1] * cap_order + 0 ] ); CPPAD_ASSERT_KNOWN( i_vec < index_by_ind[ arg[0] - 1 ] , "VecAD: index during zero order forward sweep is out of range" ); CPPAD_ASSERT_UNKNOWN( arg[0] + i_vec < play->num_vec_ind_rec() ); size_t i_v_x = index_by_ind[ arg[0] + i_vec ]; 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] ] = 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 inline void forward_load_op( const player* play , OpCode op , size_t p , size_t q , size_t r , size_t cap_order , size_t i_z , const addr_t* arg , const addr_t* var_by_load_op , Base* taylor ) { CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); 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); } } } } /*! 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< \a Base > and computations by this routine are done using type \a 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 \a 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 \a arg[2] is zero). \param partial If \a arg[2] is zero, y[x] is a parameter and no values need to be modified; i.e., \a partial is not used. Otherwise, y[x] is a variable and: \n \n \a partial [ \a i_z * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G with respect to the k-th order Taylor coefficient for z. \n \n If \a arg[2] is not zero, \a partial [ \a arg[2] * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative with respect to 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 inline void reverse_load_op( OpCode op , size_t d , size_t i_z , const addr_t* arg , size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial , const addr_t* 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 sparse_load_op */ template inline void forward_sparse_load_op( bool dependency , OpCode op , size_t i_z , 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) == 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, arg[1], var_sparsity); return; } /*! Reverse mode Jacobian sparsity operations for LdpOp and LdvOp \param dependency is this a dependency (or sparsity) calculation. \copydetails sparse_load_op */ template inline void reverse_sparse_jacobian_load_op( bool dependency , OpCode op , size_t i_z , const addr_t* arg , 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(arg[1], arg[1], i_z, var_sparsity); return; } /*! Reverse mode Hessian sparsity operations for LdpOp and LdvOp \copydetails sparse_load_op \param var_jacobian \a var_jacobian[i_z] is false (true) if the Jacobian of G with respect to z is always zero (many be non-zero). \param vecad_jacobian \a vecad_jacobian[i_v] is false (true) if the Jacobian with respect to x is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. */ template inline void reverse_sparse_hessian_load_op( OpCode op , size_t i_z , 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) == 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_NAMESPACE # endif cppad-20160000.1/cppad/local/erf.hpp0000644000175200017650000000515612656321766016112 0ustar coincoin-web// $Id: erf.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ERF_HPP # define CPPAD_ERF_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin 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/erf.cpp %$$ The file $cref erf.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- */ # include # if ! CPPAD_USE_CPLUSPLUS_2011 // BEGIN CppAD namespace namespace CppAD { template Type 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 inline AD erf(const AD &x) { return erf_template(x); } template inline AD erf(const VecAD_reference &x) { return erf_template( x.ADBase() ); } } // END CppAD namespace # endif // CPPAD_USE_CPLUSPLUS_2011 # endif // CPPAD_ERF_INCLUDED cppad-20160000.1/cppad/local/ad.hpp0000644000175200017650000002125512656321766015720 0ustar coincoin-web// $Id: ad.hpp 3760 2015-12-01 04:12:28Z bradbell $ # ifndef CPPAD_AD_HPP # define CPPAD_AD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ // 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 namespace CppAD { // BEGIN_CPPAD_NAMESPACE typedef enum { tape_manage_new, tape_manage_delete, tape_manage_clear } tape_manage_job; template class AD { // 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(VectorAD &x, size_t abort_op_index); // one argument functions 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); // 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 IdenticalPar (const AD &x); friend bool IdenticalZero (const AD &x); friend bool IdenticalOne (const AD &x); friend bool IdenticalEqualPar (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 ADTape; friend class ADFun; friend class atomic_base; 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 inline AD(void); // use default implicit copy constructor and assignment operator // inline AD(const AD &x); // inline AD& operator=(const AD &x); // implicit construction and assingment from base type inline AD(const Base &b); inline AD& operator=(const Base &b); // implicit contructor and assignment from VecAD::reference inline AD(const VecAD_reference &x); inline AD& operator=(const VecAD_reference &x); # if CPPAD_DEPRECATED // implicit construction from some other type (depricated) template inline AD(const T &t); # else // explicit construction from some other type (depricated) template inline explicit AD(const T &t); # endif // assignment from some other type template inline AD& operator=(const T &right); // base type corresponding to an AD object friend Base Value (const AD &x); // computed assignment operators inline AD& operator += (const AD &right); inline AD& operator -= (const AD &right); inline AD& operator *= (const AD &right); inline AD& operator /= (const AD &right); // unary operators inline AD operator +(void) const; inline AD operator -(void) const; // destructor ~AD(void) { } // interface so these functions need not be friends inline AD Abs(void) const; inline AD acos(void) const; inline AD asin(void) const; inline AD atan(void) const; inline AD cos(void) const; inline AD cosh(void) const; inline AD exp(void) const; inline AD fabs(void) const; inline AD log(void) const; inline AD sin(void) const; inline AD Sign(void) const; inline AD sinh(void) const; inline AD sqrt(void) const; inline AD tan(void) const; inline AD tanh(void) const; # if CPPAD_USE_CPLUSPLUS_2011 inline AD erf(void) const; inline AD asinh(void) const; inline AD acosh(void) const; inline AD atanh(void) const; inline AD expm1(void) const; inline AD log1p(void) const; # endif // ---------------------------------------------------------- // static public member functions // abort current AD recording static void abort_recording(void); // 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 inline bool UnaryBool( bool FunName(const Base &x), const AD &x ); static inline bool BinaryBool( bool FunName(const Base &x, const Base &y), const AD &x , const AD &y ); private: // value_ corresponding to this object Base value_; // Tape identifier corresponding to taddr tape_id_t tape_id_; // taddr_ in tape for this variable addr_t taddr_; // // Make this variable a parameter // void make_parameter(void) { CPPAD_ASSERT_UNKNOWN( Variable(*this) ); // currently a var tape_id_ = 0; } // // Make this parameter a new variable // void make_variable(size_t id, size_t taddr) { CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); // currently a par CPPAD_ASSERT_UNKNOWN( taddr > 0 ); // sure valid taddr taddr_ = taddr; tape_id_ = id; } // --------------------------------------------------------------- // tape linking functions // // not static inline ADTape* tape_this(void) const; // // static inline static tape_id_t** tape_id_handle(size_t thread); inline static tape_id_t* tape_id_ptr(size_t thread); inline static ADTape** tape_handle(size_t thread); static ADTape* tape_manage(tape_manage_job job); inline static ADTape* tape_ptr(void); inline static ADTape* tape_ptr(tape_id_t tape_id); }; // --------------------------------------------------------------------------- } // END_CPPAD_NAMESPACE // tape linking private functions # include // operations that expect the AD template class to be defined # endif cppad-20160000.1/cppad/local/convert.hpp0000644000175200017650000000235212656321766017011 0ustar coincoin-web// $Id: convert.hpp 3769 2015-12-29 16:13:16Z bradbell $ # ifndef CPPAD_CONVERT_HPP # define CPPAD_CONVERT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Convert$$ $spell $$ $section Conversion and I/O of AD Objects$$ $mindex convert from$$ $children% cppad/local/value.hpp% cppad/local/integer.hpp% cppad/local/ad_to_string.hpp% cppad/local/ad_io.hpp% cppad/local/print_for.hpp% cppad/local/var2par.hpp %$$ $table $rref Value$$ $rref Integer$$ $rref ad_output$$ $rref PrintFor$$ $rref Var2Par$$ $tend $end */ # include # include # include # include # include # include # endif cppad-20160000.1/cppad/local/parameter_op.hpp0000644000175200017650000000477612656321766020023 0ustar coincoin-web// $Id: parameter_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_PARAMETER_OP_HPP # define CPPAD_PARAMETER_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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< \a Base > and computations by this routine are done using type \a Base . \param i_z variable index corresponding to the result for this operation; i.e. the row index in \a taylor corresponding to the component of y that is a parameter. \param arg \a arg[0] \n index corresponding to the parameter value for this operator. \param num_par is the number of parameters in \a parameter. \param parameter \b Input: \a parameter[ \a 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: \a taylor [ \a i_z * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to z. \par Checked Assertions where op is the unary operator with one result: \li NumArg(op) == 1 \li NumRes(op) == 1 \li \a size_t(arg[0]) < num_par \li \a 0 < \a cap_order */ template inline 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_NAMESPACE # endif cppad-20160000.1/cppad/local/pow_op.hpp0000644000175200017650000004030712656321766016636 0ustar coincoin-web// $Id: pow_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_POW_OP_HPP # define CPPAD_POW_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 \a parameter is not used. \copydetails forward_pow_op */ template inline 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 ); // z_0 = log(x) forward_log_op(p, q, i_z, arg[0], cap_order, taylor); // z_1 = z_0 * y addr_t adr[2]; adr[0] = 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 + arg[0] * cap_order; Base* y = taylor + 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 forward_pow_op_dir */ template inline 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 ); // z_0 = log(x) forward_log_op_dir(q, r, i_z, arg[0], cap_order, taylor); // z_1 = y * z_0 addr_t adr[2]; adr[0] = 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 \a parameter is not used. \copydetails forward_pow_op_0 */ template inline 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 + arg[0] * cap_order; Base* y = taylor + 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 \a parameter is not used. \copydetails reverse_pow_op */ template inline 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 ); // 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] = 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, 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 forward_pow_op */ template inline 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); } // z_1 = z_0 * y addr_t adr[2]; // offset of z_i in taylor (as if it were a parameter); i.e., log(x) adr[0] = i_z * cap_order; // 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 + 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 forward_pow_op_dir */ template inline 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); // 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] = 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 forward_pow_op_0 */ template inline 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 + 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 reverse_pow_op */ template inline 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 ); // z_1 = z_0 * y addr_t adr[2]; adr[0] = i_z * cap_order; // offset of z_0[0] in taylor adr[1] = arg[1]; // index of y in taylor and partial // use taylor both for parameter and variable values reverse_mulpv_op( 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 forward_pow_op */ template inline 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 ); // z_0 = log(x) forward_log_op(p, q, i_z, arg[0], cap_order, taylor); // z_1 = y * z_0 addr_t adr[2]; adr[0] = arg[1]; adr[1] = 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 + 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 forward_pow_op_dir */ template inline 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 ); // z_0 = log(x) forward_log_op_dir(q, r, i_z, arg[0], cap_order, taylor); // z_1 = y * z_0 addr_t adr[2]; adr[0] = arg[1]; adr[1] = 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 forward_pow_op_0 */ template inline 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 + 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 reverse_pow_op */ template inline 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 ); // 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] = 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, arg[0], cap_order, taylor, nc_partial, partial ); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/vec_ad.hpp0000644000175200017650000004726712656321766016570 0ustar coincoin-web// $Id: vec_ad.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_VEC_AD_HPP # define CPPAD_VEC_AD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin VecAD$$ $spell cppad.hpp CondExpGt grep Ld vp Lu wc op Ldp Ldv Taylor VecAD const Cpp $$ $section AD Vectors that Record Index Operations$$ $mindex VecAD tape reference VecAD$$ $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/computed 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 and Variable/ParVar/$$ 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 Sparse$$) 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/ParVar/$$; 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 Example$$ $children% example/vec_ad.cpp %$$ The file $cref vec_ad.cpp$$ contains an example and test using $code VecAD$$ vectors. It returns true if it succeeds and false otherwise. $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 computed assignment is used. THis macro is used to print an error message if any of the computed assignments are used with the VecAD_reference class. The argument \c op is one of the following: += , -= , *= , /=. The argument \c name, is a string literal with the name of the computed assignment \c 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 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) { } // assignment operators inline void operator = (const VecAD_reference &right); void operator = (const AD &right); void operator = (const Base &right); void operator = (int right); // computed 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 { 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_) ) { ADTape* tape = AD::tape_ptr(vec_->tape_id_); CPPAD_ASSERT_UNKNOWN( tape != CPPAD_NULL ); CPPAD_ASSERT_UNKNOWN( vec_->offset_ > 0 ); size_t load_op_index = tape->Rec_.num_load_op_rec(); if( IdenticalPar(ind_) ) { CPPAD_ASSERT_UNKNOWN( NumRes(LdpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(LdpOp) == 3 ); // put operand addresses in tape tape->Rec_.PutArg( vec_->offset_, i, load_op_index ); // put operator in the tape, ind_ is a parameter result.taddr_ = tape->Rec_.PutLoadOp(LdpOp); // change result to variable for this load result.tape_id_ = tape->id_; } else { CPPAD_ASSERT_UNKNOWN( NumRes(LdvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(LdvOp) == 3 ); 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 // (value of third arugment does not matter) tape->Rec_.PutArg( vec_->offset_, ind_taddr, load_op_index ); // put operator in the tape, ind_ is a variable result.taddr_ = tape->Rec_.PutLoadOp(LdvOp); // change result to variable for this load result.tape_id_ = tape->id_; } } 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 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 pod_vector 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 lenght 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) { 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." ); 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( NumArg(StpvOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(StpvOp) == 0 ); // put operand addresses in tape tape->Rec_.PutArg(vec_->offset_, i, y.taddr_); // put operator in the tape, ind_ is parameter, y is variable tape->Rec_.PutOp(StpvOp); } else { CPPAD_ASSERT_UNKNOWN( NumArg(StvvOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(StvvOp) == 0 ); CPPAD_ASSERT_UNKNOWN( ind_.taddr_ > 0 ); // put operand addresses in tape tape->Rec_.PutArg(vec_->offset_, ind_.taddr_, y.taddr_); // put operator in the tape, ind_ is variable, y is variable tape->Rec_.PutOp(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; 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_.PutPar(y); // record the setting of this array element CPPAD_ASSERT_UNKNOWN( vec_->offset_ > 0 ); if( Parameter(ind_) ) { CPPAD_ASSERT_UNKNOWN( NumArg(StppOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(StppOp) == 0 ); // put operand addresses in tape tape->Rec_.PutArg(vec_->offset_, i, p); // put operator in the tape, ind_ is parameter, y is parameter tape->Rec_.PutOp(StppOp); } else { CPPAD_ASSERT_UNKNOWN( NumArg(StvpOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(StvpOp) == 0 ); CPPAD_ASSERT_UNKNOWN( ind_.taddr_ > 0 ); // put operand addresses in tape tape->Rec_.PutArg(vec_->offset_, ind_.taddr_, p); // put operator in the tape, ind_ is variable, y is parameter tape->Rec_.PutOp(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 inline 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 inline 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 cppad-20160000.1/cppad/local/reverse_sweep.hpp0000644000175200017650000005473212656321766020220 0ustar coincoin-web// $Id: reverse_sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_REVERSE_SWEEP_HPP # define CPPAD_REVERSE_SWEEP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file reverse_sweep.hpp Compute derivatives of arbitrary order Taylor coefficients. */ /* \def CPPAD_ATOMIC_CALL This avoids warnings when NDEBUG is defined and user_ok is not used. If \c NDEBUG is defined, this resolves to \code user_atom->reverse \endcode otherwise, it respolves to \code user_ok = user_atom->reverse \endcode This maco is undefined at the end of this file to facillitate is use with a different definition in other files. */ # ifdef NDEBUG # define CPPAD_ATOMIC_CALL user_atom->reverse # else # define CPPAD_ATOMIC_CALL user_ok = user_atom->reverse # endif /*! \def CPPAD_REVERSE_SWEEP_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_SWEEP_TRACE 0 /*! Compute derivative of arbitrary order forward mode Taylor coefficients. \tparam Base base type for the operator; i.e., this operation sequence was recorded using AD< \a Base > and computations by this routine are done using type \a 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 \a Taylor; i.e., play->num_var_rec(). \param play The information stored in \a 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$. \n \n The object \a play is effectly constant. There is an exception to this, while palying back the tape the object \a play holds information about the current location with in the tape and this changes during palyback. \param J Is the number of columns in the coefficient matrix \a Taylor. This must be greater than or equal \a d + 1. \param Taylor For i = 1 , ... , \a numvar, and for k = 0 , ... , \a d, \a Taylor [ i * J + k ] is the k-th order Taylor coefficient corresponding to 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$ = \a Taylor [ j * J + k ] for j = 1 , ... , \a n, and for k = 0 , ... , \a d. \param K Is the number of columns in the partial derivative matrix \a Partial. It must be greater than or equal \a d + 1. \param Partial \b Input: The last \f$ m \f$ rows of \a Partial are inputs. The matrix \f$ w \f$, used to define \f$ W(u) \f$, is specified by these rows. For i = 0 , ... , m - 1, for k = 0 , ... , d, Partial [ (numvar - m + i ) * K + k ] = w[i,k]. \n \n \b Temporary: For i = n+1 , ... , \a numvar - 1 and for k = 0 , ... , d, the value of \a 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, \a Partial [ j * K + k ] is the partial derivative of \f$ W( u ) \f$ with respect to \f$ u_j^{(k)} \f$. \param cskip_op 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). \param var_by_load_op is a vector with size play->num_load_op_rec(). Is 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 Assumptions The first operator on the tape is a BeginOp, and the next \a n operators are InvOp operations for the corresponding independent variables. */ template void ReverseSweep( size_t d, size_t n, size_t numvar, player* play, size_t J, const Base* Taylor, size_t K, Base* Partial, bool* cskip_op, const pod_vector& var_by_load_op ) { OpCode op; size_t i_op; size_t i_var; const addr_t* arg = CPPAD_NULL; // 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 UserOp. const size_t user_k = d; // highest order we are differentiating const size_t user_k1 = d+1; // number of orders for this calculation vector user_ix; // variable indices for argument vector vector user_tx; // argument vector Taylor coefficients vector user_ty; // result vector Taylor coefficients vector user_px; // partials w.r.t argument vector vector user_py; // partials w.r.t. result vector size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator size_t user_i = 0; // index in result vector size_t user_j = 0; // index in argument vector size_t user_m = 0; // size of result vector size_t user_n = 0; // size of arugment vector // atomic_base* user_atom = CPPAD_NULL; // user's atomic op calculator # ifndef NDEBUG bool user_ok = false; // atomic op return value # endif // // next expected operator in a UserOp sequence enum { user_start, user_arg, user_ret, user_end } user_state = user_end; // temporary indices size_t j, ell; // Initialize play->reverse_start(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( op == EndOp ); # if CPPAD_REVERSE_SWEEP_TRACE std::cout << std::endl; # endif bool more_operators = true; while(more_operators) { // next op play->reverse_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN((i_op > n) | (op == InvOp) | (op == BeginOp)); CPPAD_ASSERT_UNKNOWN((i_op <= n) | (op != InvOp) | (op != BeginOp)); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); // check if we are skipping this operation while( cskip_op[i_op] ) { if( op == CSumOp ) { // CSumOp has a variable number of arguments play->reverse_csum(op, arg, i_op, i_var); } CPPAD_ASSERT_UNKNOWN( op != CSkipOp ); // if( op == CSkipOp ) // { // CSkip has a variable number of arguments // play->reverse_cskip(op, arg, i_op, i_var); // } CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); play->reverse_next(op, arg, i_op, i_var); } // rest of informaiton depends on the case # if CPPAD_REVERSE_SWEEP_TRACE if( op == CSumOp ) { // CSumOp has a variable number of arguments play->reverse_csum(op, arg, i_op, i_var); } if( op == CSkipOp ) { // CSkip has a variable number of arguments play->reverse_cskip(op, arg, i_op, i_var); } 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, 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, arg[0], J, Taylor, K, Partial ); break; // -------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 case AcoshOp: // sqrt(x * x - 1), acosh(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); reverse_acosh_op( d, i_var, arg[0], J, Taylor, K, Partial ); break; # endif // -------------------------------------------------- case AddvvOp: reverse_addvv_op( d, i_var, arg, parameter, J, Taylor, K, Partial ); 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, 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, 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, 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, arg[0], J, Taylor, K, Partial ); break; # endif // ------------------------------------------------- case BeginOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); more_operators = false; break; // -------------------------------------------------- case CSkipOp: // CSkipOp has a variable number of arguments and // forward_next thinks it one has one argument. // we must inform reverse_next of this special case. # if ! CPPAD_REVERSE_SWEEP_TRACE play->reverse_cskip(op, arg, i_op, i_var); # endif break; // ------------------------------------------------- case CSumOp: // CSumOp has a variable number of arguments and // reverse_next thinks it one has one argument. // We must inform reverse_next of this special case. # if ! CPPAD_REVERSE_SWEEP_TRACE play->reverse_csum(op, arg, i_op, i_var); # endif reverse_csum_op( d, i_var, arg, K, Partial ); // end of a cummulative 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, arg[0], J, Taylor, K, Partial ); break; // -------------------------------------------------- case CoshOp: CPPAD_ASSERT_UNKNOWN( i_var < numvar ); reverse_cosh_op( d, i_var, 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; // -------------------------------------------------- # 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, arg[0], J, Taylor, K, Partial ); break; // -------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 case Expm1Op: reverse_expm1_op( d, i_var, arg[0], J, Taylor, K, Partial ); break; # endif // -------------------------------------------------- case InvOp: break; // -------------------------------------------------- case LdpOp: reverse_load_op( op, d, i_var, arg, J, Taylor, K, Partial, var_by_load_op.data() ); break; // ------------------------------------------------- case LdvOp: reverse_load_op( op, d, i_var, arg, J, Taylor, K, Partial, var_by_load_op.data() ); break; // -------------------------------------------------- case EqpvOp: case EqvvOp: case LtpvOp: case LtvpOp: case LtvvOp: case LepvOp: case LevpOp: case LevvOp: case NepvOp: case NevvOp: break; // ------------------------------------------------- case LogOp: reverse_log_op( d, i_var, arg[0], J, Taylor, K, Partial ); break; // -------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 case Log1pOp: reverse_log1p_op( d, i_var, 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, arg[0], J, Taylor, K, Partial ); break; // ------------------------------------------------- case SinOp: CPPAD_ASSERT_UNKNOWN( i_var < numvar ); reverse_sin_op( d, i_var, arg[0], J, Taylor, K, Partial ); break; // ------------------------------------------------- case SinhOp: CPPAD_ASSERT_UNKNOWN( i_var < numvar ); reverse_sinh_op( d, i_var, arg[0], J, Taylor, K, Partial ); break; // -------------------------------------------------- case SqrtOp: reverse_sqrt_op( d, i_var, 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, arg[0], J, Taylor, K, Partial ); break; // ------------------------------------------------- case TanhOp: CPPAD_ASSERT_UNKNOWN( i_var < numvar ); reverse_tanh_op( d, i_var, arg[0], J, Taylor, K, Partial ); break; // -------------------------------------------------- case UserOp: // start or end an atomic operation sequence CPPAD_ASSERT_UNKNOWN( NumRes( UserOp ) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg( UserOp ) == 4 ); if( user_state == user_end ) { user_index = arg[0]; user_id = arg[1]; user_n = arg[2]; user_m = arg[3]; user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif if(user_ix.size() != user_n) user_ix.resize(user_n); if(user_tx.size() != user_n * user_k1) { user_tx.resize(user_n * user_k1); user_px.resize(user_n * user_k1); } if(user_ty.size() != user_m * user_k1) { user_ty.resize(user_m * user_k1); user_py.resize(user_m * user_k1); } user_j = user_n; user_i = user_m; user_state = user_ret; } else { CPPAD_ASSERT_UNKNOWN( user_state == user_start ); CPPAD_ASSERT_UNKNOWN( user_index == size_t(arg[0]) ); CPPAD_ASSERT_UNKNOWN( user_id == size_t(arg[1]) ); CPPAD_ASSERT_UNKNOWN( user_n == size_t(arg[2]) ); CPPAD_ASSERT_UNKNOWN( user_m == size_t(arg[3]) ); // call users function for this operation user_atom->set_id(user_id); CPPAD_ATOMIC_CALL( user_k, user_tx, user_ty, user_px, user_py ); # ifndef NDEBUG if( ! user_ok ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base.reverse: returned false"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif for(j = 0; j < user_n; j++) if( user_ix[j] > 0 ) { for(ell = 0; ell < user_k1; ell++) Partial[user_ix[j] * K + ell] += user_px[j * user_k1 + ell]; } user_state = user_end; } break; case UsrapOp: // parameter argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( 0 < user_j && user_j <= user_n ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); --user_j; user_ix[user_j] = 0; user_tx[user_j * user_k1 + 0] = parameter[ arg[0]]; for(ell = 1; ell < user_k1; ell++) user_tx[user_j * user_k1 + ell] = Base(0.); if( user_j == 0 ) user_state = user_start; break; case UsravOp: // variable argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( 0 < user_j && user_j <= user_n ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= i_var ); CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); --user_j; user_ix[user_j] = arg[0]; for(ell = 0; ell < user_k1; ell++) user_tx[user_j*user_k1 + ell] = Taylor[ arg[0] * J + ell]; if( user_j == 0 ) user_state = user_start; break; case UsrrpOp: // parameter result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( 0 < user_i && user_i <= user_m ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); --user_i; for(ell = 0; ell < user_k1; ell++) { user_py[user_i * user_k1 + ell] = Base(0.); user_ty[user_i * user_k1 + ell] = Base(0.); } user_ty[user_i * user_k1 + 0] = parameter[ arg[0] ]; if( user_i == 0 ) user_state = user_arg; break; case UsrrvOp: // variable result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( 0 < user_i && user_i <= user_m ); --user_i; for(ell = 0; ell < user_k1; ell++) { user_py[user_i * user_k1 + ell] = Partial[i_var * K + ell]; user_ty[user_i * user_k1 + ell] = Taylor[i_var * J + ell]; } if( user_i == 0 ) user_state = user_arg; 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_SWEEP_TRACE std::cout << std::endl; # endif // values corresponding to BeginOp CPPAD_ASSERT_UNKNOWN( i_op == 0 ); CPPAD_ASSERT_UNKNOWN( i_var == 0 ); } } // END_CPPAD_NAMESPACE // preprocessor symbols that are local to this file # undef CPPAD_REVERSE_SWEEP_TRACE # undef CPPAD_ATOMIC_CALL # endif cppad-20160000.1/cppad/local/div.hpp0000644000175200017650000000563512656321766016122 0ustar coincoin-web// $Id: div.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DIV_HPP # define CPPAD_DIV_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // BEGIN CppAD 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 ADTape* tape = AD::tape_ptr(); if( tape == CPPAD_NULL ) return result; tape_id_t tape_id = tape->id_; // tape_id cannot match the default value for tape_id_; i.e., 0 CPPAD_ASSERT_UNKNOWN( tape_id > 0 ); bool var_left = left.tape_id_ == tape_id; bool var_right = right.tape_id_ == tape_id; if( var_left ) { if( var_right ) { // result = variable / variable CPPAD_ASSERT_KNOWN( left.tape_id_ == right.tape_id_, "Dividing AD objects that are" " variables on different tapes." ); CPPAD_ASSERT_UNKNOWN( NumRes(DivvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(DivvvOp) == 2 ); // put operand addresses in tape tape->Rec_.PutArg(left.taddr_, right.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(DivvvOp); // make result a variable result.tape_id_ = tape_id; } else if( IdenticalOne(right.value_) ) { // result = variable / 1 result.make_variable(left.tape_id_, left.taddr_); } else { // result = variable / parameter CPPAD_ASSERT_UNKNOWN( NumRes(DivvpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(DivvpOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(right.value_); tape->Rec_.PutArg(left.taddr_, p); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(DivvpOp); // make result a variable result.tape_id_ = tape_id; } } else if( var_right ) { if( IdenticalZero(left.value_) ) { // result = 0 / variable } else { // result = parameter / variable CPPAD_ASSERT_UNKNOWN( NumRes(DivpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(DivpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(left.value_); tape->Rec_.PutArg(p, right.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(DivpvOp); // make result a variable result.tape_id_ = tape_id; } } return result; } // convert other cases into the case above CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(/) } // END CppAD namespace # endif cppad-20160000.1/cppad/local/numeric_limits.hpp0000644000175200017650000001237212656321766020357 0ustar coincoin-web// $Id$ # ifndef CPPAD_NUMERIC_LIMITS_HPP # define CPPAD_NUMERIC_LIMITS_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------ $begin numeric_limits$$ $spell std eps CppAD namespace const $$ $section Numeric Limits For an AD and Base Types$$ $head Syntax$$ $icode%eps% = numeric_limits<%Float%>::epsilon() %$$ $icode%min% = numeric_limits<%Float%>::min() %$$ $icode%max% = numeric_limits<%Float%>::max() %$$ $icode%nan% = numeric_limits<%Float%>::quiet_NaN() %$$ $head CppAD::numeric_limits$$ These functions and have the prototype $codei% static %Float% CppAD::numeric_limits<%Float%>::%fun%(%void%) %$$ where $icode fun$$ is $code epsilon$$, $code min$$, $code max$$, and $code quiet_NaN$$. $head std::numeric_limits$$ CppAD does not use a specialization of $code std::numeric_limits$$ because this would be to restrictive. The C++ standard specifies that Non-fundamental standard types, such as $cref/std::complex/base_complex.hpp/$$ shall not have specializations of $code std::numeric_limits$$; see Section 18.2 of ISO/IEC 14882:1998(E). In addition, since C++11, a only literal types can have a specialization of $code std::numeric_limits$$. $head Float$$ These functions are defined for all $codei%AD<%Base%>%$$, and for all corresponding $icode Base$$ types; see $icode Base$$ type $cref base_limits$$. $head epsilon$$ The result $icode eps$$ is equal to machine epsilon and has prototype $codei% %Float% %eps% %$$ The file $cref num_limits.cpp$$ tests the value $icode eps$$ by checking that the following are true $codei% 1 != 1 + %eps% 1 == 1 + %eps% / 2 %$$ where all the values, and calculations, are done with the precision corresponding to $icode Float$$. $head min$$ The result $icode min$$ is equal to the minimum positive normalized value and has prototype $codei% %Float% %min% %$$ The file $cref num_limits.cpp$$ tests the value $icode min$$ by checking that the following are true $codei% abs( ((%min% / 100) * 100) / %min% - 1 ) > 3 * %eps% abs( ((%min% * 100) / 100) / %min% - 1 ) < 3 * %eps% %$$ where all the values, and calculations, are done with the precision corresponding to $icode Float$$. $head max$$ The result $icode max$$ is equal to the maximum finite value and has prototype $codei% %Float% %max% %$$ The file $cref num_limits.cpp$$ tests the value $icode max$$ by checking that the following are true $codei% abs( ((%max% * 100) / 100) / %max% - 1 ) > 3 * %eps% abs( ((%max% / 100) * 100) / %max% - 1 ) < 3 * %eps% %$$ where all the values, and calculations, are done with the precision corresponding to $icode Float$$. $head quiet_NaN$$ The result $icode nan$$ is not a number and has prototype $codei% %Float% %nan% %$$ The file $cref num_limits.cpp$$ tests the value $icode nan$$ by checking that the following is true $codei% %nan% != %nan% %$$ $head Example$$ $children% example/num_limits.cpp %$$ The file $cref num_limits.cpp$$ contains an example and test of these functions. $end ------------------------------------------------------------------------------ */ # include # include # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file numeric_limits.hpp File that defines CppAD numeric_limits for AD types */ /// Default value for all undefined numeric_limits types template class numeric_limits { public: /// machine epsilon static Float epsilon(void) { CPPAD_ASSERT_KNOWN( false, "numeric_limits::epsilon() is not specialized for this Float" ); return Float(0); } /// minimum positive normalized value static Float min(void) { CPPAD_ASSERT_KNOWN( false, "numeric_limits::min() is not specialized for this Float" ); return Float(0); } /// maximum finite value static Float max(void) { CPPAD_ASSERT_KNOWN( false, "numeric_limits::max() is not specialized for this Float" ); return Float(0); } /// not a number static Float quiet_NaN(void) { CPPAD_ASSERT_KNOWN( false, "numeric_limits::quiet_NaN() is not specialized for this Float" ); return Float(0); } }; /// Partial specialization that defines limits for for all AD types template class numeric_limits< AD > { public: /// machine epsilon static AD epsilon(void) { return AD( numeric_limits::epsilon() ); } /// minimum positive normalized value static AD min(void) { return AD( numeric_limits::min() ); } /// maximum finite value static AD max(void) { return AD( numeric_limits::max() ); } /// note a number static AD quiet_NaN(void) { return AD( numeric_limits::quiet_NaN() ); } }; } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/ordered.hpp0000644000175200017650000000552412656321766016761 0ustar coincoin-web// $Id: ordered.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ORDERED_HPP # define CPPAD_ORDERED_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include 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 \c 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 \c 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 \c 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 \c 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 \c x is greater than or equal absolute value of \c 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 cppad-20160000.1/cppad/local/zmul_op.hpp0000644000175200017650000003303012656321766017013 0ustar coincoin-web// $Id$ # ifndef CPPAD_ZMUL_OP_HPP # define CPPAD_ZMUL_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file mul_op.hpp Forward and reverse mode calculations for z = azmul(x, y). */ // --------------------------- Zmulvv ----------------------------------------- /*! Compute forward mode Taylor coefficients for result of op = ZmulvvOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where both x and y are variables and the argument \a parameter is not used. \copydetails forward_binary_op */ template inline void forward_zmulvv_op( size_t p , size_t q , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base* y = taylor + arg[1] * cap_order; Base* z = taylor + i_z * cap_order; size_t k; for(size_t d = p; d <= q; d++) { z[d] = Base(0); for(k = 0; k <= d; k++) z[d] += azmul(x[d-k], y[k]); } } /*! Multiple directions forward mode Taylor coefficients for op = ZmulvvOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where both x and y are variables and the argument \a parameter is not used. \copydetails forward_binary_op_dir */ template inline void forward_zmulvv_op_dir( size_t q , size_t r , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( 0 < q ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); // Taylor coefficients corresponding to arguments and result size_t num_taylor_per_var = (cap_order-1) * r + 1; Base* x = taylor + arg[0] * num_taylor_per_var; Base* y = taylor + arg[1] * num_taylor_per_var; Base* z = taylor + i_z * num_taylor_per_var; size_t k, ell, m; for(ell = 0; ell < r; ell++) { m = (q-1)*r + ell + 1; z[m] = azmul(x[0], y[m]) + azmul(x[m], y[0]); for(k = 1; k < q; k++) z[m] += azmul(x[(q-k-1)*r + ell + 1], y[(k-1)*r + ell + 1]); } } /*! Compute zero order forward mode Taylor coefficients for result of op = ZmulvvOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where both x and y are variables and the argument \a parameter is not used. \copydetails forward_binary_op_0 */ template inline void forward_zmulvv_op_0( size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvvOp) == 1 ); // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base* y = taylor + arg[1] * cap_order; Base* z = taylor + i_z * cap_order; z[0] = azmul(x[0], y[0]); } /*! Compute reverse mode partial derivatives for result of op = ZmulvvOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where both x and y are variables and the argument \a parameter is not used. \copydetails reverse_binary_op */ template inline void reverse_zmulvv_op( size_t d , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( d < cap_order ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // Arguments const Base* x = taylor + arg[0] * cap_order; const Base* y = taylor + arg[1] * cap_order; // Partial derivatives corresponding to arguments and result Base* px = partial + arg[0] * nc_partial; Base* py = partial + arg[1] * nc_partial; Base* pz = partial + i_z * nc_partial; // number of indices to access size_t j = d + 1; size_t k; while(j) { --j; for(k = 0; k <= j; k++) { px[j-k] += azmul(pz[j], y[k]); py[k] += azmul(pz[j], x[j-k]); } } } // --------------------------- Zmulpv ----------------------------------------- /*! Compute forward mode Taylor coefficients for result of op = ZmulpvOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where x is a parameter and y is a variable. \copydetails forward_binary_op */ template inline void forward_zmulpv_op( size_t p , size_t q , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); // Taylor coefficients corresponding to arguments and result Base* y = taylor + arg[1] * cap_order; Base* z = taylor + i_z * cap_order; // Paraemter value Base x = parameter[ arg[0] ]; for(size_t d = p; d <= q; d++) z[d] = azmul(x, y[d]); } /*! Multiple directions forward mode Taylor coefficients for op = ZmulpvOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where x is a parameter and y is a variable. \copydetails forward_binary_op_dir */ template inline void forward_zmulpv_op_dir( size_t q , size_t r , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( 0 < q ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); // Taylor coefficients corresponding to arguments and result size_t num_taylor_per_var = (cap_order-1) * r + 1; size_t m = (q-1) * r + 1; Base* y = taylor + arg[1] * num_taylor_per_var + m; Base* z = taylor + i_z * num_taylor_per_var + m; // Paraemter value Base x = parameter[ arg[0] ]; for(size_t ell = 0; ell < r; ell++) z[ell] = azmul(x, y[ell]); } /*! Compute zero order forward mode Taylor coefficient for result of op = ZmulpvOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where x is a parameter and y is a variable. \copydetails forward_binary_op_0 */ template inline void forward_zmulpv_op_0( size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 ); // Paraemter value Base x = parameter[ arg[0] ]; // Taylor coefficients corresponding to arguments and result Base* y = taylor + arg[1] * cap_order; Base* z = taylor + i_z * cap_order; z[0] = azmul(x, y[0]); } /*! Compute reverse mode partial derivative for result of op = ZmulpvOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where x is a parameter and y is a variable. \copydetails reverse_binary_op */ template inline void reverse_zmulpv_op( size_t d , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( d < cap_order ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // Arguments Base x = parameter[ arg[0] ]; // Partial derivatives corresponding to arguments and result Base* py = partial + arg[1] * nc_partial; Base* pz = partial + i_z * nc_partial; // number of indices to access size_t j = d + 1; while(j) { --j; py[j] += azmul(pz[j], x); } } // --------------------------- Zmulvp ----------------------------------------- /*! Compute forward mode Taylor coefficients for result of op = ZmulvpOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where x is a parameter and y is a variable. \copydetails forward_binary_op */ template inline void forward_zmulvp_op( size_t p , size_t q , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvpOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base* z = taylor + i_z * cap_order; // Paraemter value Base y = parameter[ arg[1] ]; for(size_t d = p; d <= q; d++) z[d] = azmul(x[d], y); } /*! Multiple directions forward mode Taylor coefficients for op = ZmulvpOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where x is a parameter and y is a variable. \copydetails forward_binary_op_dir */ template inline void forward_zmulvp_op_dir( size_t q , size_t r , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvpOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( 0 < q ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); // Taylor coefficients corresponding to arguments and result size_t num_taylor_per_var = (cap_order-1) * r + 1; size_t m = (q-1) * r + 1; Base* x = taylor + arg[0] * num_taylor_per_var + m; Base* z = taylor + i_z * num_taylor_per_var + m; // Paraemter value Base y = parameter[ arg[1] ]; for(size_t ell = 0; ell < r; ell++) z[ell] = azmul(x[ell], y); } /*! Compute zero order forward mode Taylor coefficient for result of op = ZmulvpOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where x is a parameter and y is a variable. \copydetails forward_binary_op_0 */ template inline void forward_zmulvp_op_0( size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvpOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvpOp) == 1 ); // Paraemter value Base y = parameter[ arg[1] ]; // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base* z = taylor + i_z * cap_order; z[0] = azmul(x[0], y); } /*! Compute reverse mode partial derivative for result of op = ZmulvpOp. The C++ source code corresponding to this operation is \verbatim z = azmul(x, y) \endverbatim In the documentation below, this operations is for the case where x is a parameter and y is a variable. \copydetails reverse_binary_op */ template inline void reverse_zmulvp_op( size_t d , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvpOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( d < cap_order ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // Arguments Base y = parameter[ arg[1] ]; // Partial derivatives corresponding to arguments and result Base* px = partial + arg[0] * nc_partial; Base* pz = partial + i_z * nc_partial; // number of indices to access size_t j = d + 1; while(j) { --j; px[j] += azmul(pz[j], y); } } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/add_op.hpp0000644000175200017650000002165112656321766016562 0ustar coincoin-web// $Id: add_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ADD_OP_HPP # define CPPAD_ADD_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 \a parameter is not used. \copydetails forward_binary_op */ template inline 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 + arg[0] * cap_order; Base* y = taylor + 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 \a parameter is not used. \copydetails forward_binary_op_dir */ template inline 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 + arg[0] * num_taylor_per_var; Base* y = taylor + arg[1] * num_taylor_per_var; Base* z = taylor + i_z * num_taylor_per_var; size_t 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 \a parameter is not used. \copydetails forward_binary_op_0 */ template inline 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 + arg[0] * cap_order; Base* y = taylor + 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 \a parameter is not used. \copydetails reverse_binary_op */ template inline 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 + arg[0] * nc_partial; Base* py = partial + arg[1] * nc_partial; Base* pz = partial + i_z * nc_partial; // number of indices to access size_t 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 forward_binary_op */ template inline 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 + 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 forward_binary_op_dir */ template inline 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 + 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 forward_binary_op_0 */ template inline 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 + 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 reverse_binary_op */ template inline 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 + 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_NAMESPACE # endif cppad-20160000.1/cppad/local/azmul.hpp0000644000175200017650000001304312656321766016460 0ustar coincoin-web// $Id$ # ifndef CPPAD_AZMUL_HPP # define CPPAD_AZMUL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin azmul$$ $spell azmul const namespace Vec $$ $section Absolute Zero Multiplication$$ $head Syntax$$ $icode%z% = azmul(%x%, %y%)%$$ $head Purpose$$ Evaluates multiplication with an absolute zero for any of the possible types listed below. The result is given by $latex \[ z = \left\{ \begin{array}{ll} 0 & {\rm if} \; x = 0 \\ x \cdot y & {\rm otherwise} \end{array} \right. \] $$ Note if $icode x$$ is zero and $icode y$$ is infinity, ieee multiplication would result in not a number whereas $icode z$$ would be zero. $head Base$$ If $icode Base$$ satisfies the $cref/base type requirements/base_require/$$ and arguments $icode x$$, $icode y$$ have prototypes $codei% const %Base%& %x% const %Base%& %y% %$$ then the result $icode z$$ has prototype $codei% %Base% %z% %$$ $head AD$$ If the arguments $icode x$$, $icode y$$ have prototype $codei% const AD<%Base%>& %x% const AD<%Base%>& %y% %$$ then the result $icode z$$ has prototype $codei% AD<%Base%> %z% %$$ $head VecAD$$ If the arguments $icode x$$, $icode y$$ have prototype $codei% const VecAD<%Base%>::reference& %x% const VecAD<%Base%>::reference& %y% %$$ then the result $icode z$$ has prototype $codei% AD<%Base%> %z% %$$ $head Example$$ $children% example/azmul.cpp %$$ The file $cref azmul.cpp$$ is an examples and tests of this function. It returns true if it succeeds and false otherwise. $end */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE // ========================================================================== // case where x and y are AD ------------------------------------------- template AD azmul(const AD& x, const AD& y) { // compute the Base part AD result; result.value_ = azmul(x.value_, y.value_); // check if there is a recording in progress ADTape* tape = AD::tape_ptr(); if( tape == CPPAD_NULL ) return result; tape_id_t tape_id = tape->id_; // tape_id cannot match the default value for tape_id_; i.e., 0 CPPAD_ASSERT_UNKNOWN( tape_id > 0 ); bool var_x = x.tape_id_ == tape_id; bool var_y = y.tape_id_ == tape_id; if( var_x ) { if( var_y ) { // result = azmul(variable, variable) CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvvOp) == 2 ); // put operand addresses in tape tape->Rec_.PutArg(x.taddr_, y.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(ZmulvvOp); // make result a variable result.tape_id_ = tape_id; } else if( IdenticalZero( y.value_ ) ) { // result = variable * 0 } else if( IdenticalOne( y.value_ ) ) { // result = variable * 1 result.make_variable(x.tape_id_, x.taddr_); } else { // result = zmul(variable, parameter) CPPAD_ASSERT_UNKNOWN( NumRes(ZmulvpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(ZmulvpOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(y.value_); tape->Rec_.PutArg(x.taddr_, p); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(ZmulvpOp); // make result a variable result.tape_id_ = tape_id; } } else if( var_y ) { if( IdenticalZero(x.value_) ) { // result = 0 * variable } else if( IdenticalOne( x.value_ ) ) { // result = 1 * variable result.make_variable(y.tape_id_, y.taddr_); } else { // result = zmul(parameter, variable) CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(x.value_); tape->Rec_.PutArg(p, y.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(ZmulpvOp); // make result a variable result.tape_id_ = tape_id; } } return result; } // ========================================================================= // Fold operations into case above // ------------------------------------------------------------------------- // Operations with VecAD_reference and AD only template AD azmul(const AD& x, const VecAD_reference& y) { return azmul(x, y.ADBase()); } template AD azmul(const VecAD_reference& x, const VecAD_reference& y) { return azmul(x.ADBase(), y.ADBase()); } template AD azmul(const VecAD_reference& x, const AD& y) { return azmul(x.ADBase(), y); } // ------------------------------------------------------------------------- // Operations with Base template AD azmul(const Base& x, const AD& y) { return azmul(AD(x), y); } template AD azmul(const Base& x, const VecAD_reference& y) { return azmul(AD(x), y.ADBase()); } template AD azmul(const AD& x, const Base& y) { return azmul(x, AD(y)); } template AD azmul(const VecAD_reference& x, const Base& y) { return azmul(x.ADBase(), AD(y)); } // ========================================================================== } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/for_one.hpp0000644000175200017650000001003312656321766016753 0ustar coincoin-web// $Id: for_one.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FOR_ONE_HPP # define CPPAD_FOR_ONE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ForOne$$ $spell dy typename Taylor const $$ $section First Order Partial Derivative: Driver Routine$$ $mindex easy$$ $head Syntax$$ $icode%dy% = %f%.ForOne(%x%, %j%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The syntax above sets $icode 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/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); dx[j] = Base(1); // dimension the return value Vector dy(m); // compute the return value dy = Forward(1, dx); return dy; } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/expm1_op.hpp0000644000175200017650000001147312656321766017065 0ustar coincoin-web// $Id$ # ifndef CPPAD_EXPM1_OP_HPP # define CPPAD_EXPM1_OP_HPP # if CPPAD_USE_CPLUSPLUS_2011 /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file expm1_op.hpp Forward and reverse mode calculations for z = expm1(x). */ /*! Forward mode Taylor coefficient for result of op = Expm1Op. The C++ source code corresponding to this operation is \verbatim z = expm1(x) \endverbatim \copydetails forward_unary1_op */ template inline void forward_expm1_op( size_t p , size_t q , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(Expm1Op) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(Expm1Op) == 1 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; size_t k; if( p == 0 ) { z[0] = expm1( x[0] ); p++; } for(size_t j = p; j <= q; j++) { z[j] = x[1] * z[j-1]; for(k = 2; k <= j; k++) z[j] += Base(k) * x[k] * z[j-k]; z[j] /= Base(j); z[j] += x[j]; } } /*! Multiple direction forward mode Taylor coefficient for op = Expm1Op. The C++ source code corresponding to this operation is \verbatim z = expm1(x) \endverbatim \copydetails forward_unary1_op_dir */ template inline void forward_expm1_op_dir( size_t q , size_t r , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(Expm1Op) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(Expm1Op) == 1 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( 0 < q ); // Taylor coefficients corresponding to argument and result size_t num_taylor_per_var = (cap_order-1) * r + 1; Base* x = taylor + i_x * num_taylor_per_var; Base* z = taylor + i_z * num_taylor_per_var; size_t m = (q-1)*r + 1; for(size_t ell = 0; ell < r; ell++) { z[m+ell] = Base(q) * x[m+ell] * z[0]; for(size_t k = 1; k < q; k++) z[m+ell] += Base(k) * x[(k-1)*r+ell+1] * z[(q-k-1)*r+ell+1]; z[m+ell] /= Base(q); z[m+ell] += x[m+ell]; } } /*! Zero order forward mode Taylor coefficient for result of op = Expm1Op. The C++ source code corresponding to this operation is \verbatim z = expm1(x) \endverbatim \copydetails forward_unary1_op_0 */ template inline void forward_expm1_op_0( size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(Expm1Op) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(Expm1Op) == 1 ); CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; z[0] = expm1( x[0] ); } /*! Reverse mode partial derivatives for result of op = Expm1Op. The C++ source code corresponding to this operation is \verbatim z = expm1(x) \endverbatim \copydetails reverse_unary1_op */ template inline void reverse_expm1_op( size_t d , size_t i_z , size_t i_x , size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(Expm1Op) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(Expm1Op) == 1 ); CPPAD_ASSERT_UNKNOWN( d < cap_order ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // Taylor coefficients and partials corresponding to argument const Base* x = taylor + i_x * cap_order; Base* px = partial + i_x * nc_partial; // Taylor coefficients and partials corresponding to result const Base* z = taylor + i_z * cap_order; Base* pz = partial + i_z * nc_partial; // If pz is zero, make sure this operation has no effect // (zero times infinity or nan would be non-zero). bool skip(true); for(size_t i_d = 0; i_d <= d; i_d++) skip &= IdenticalZero(pz[i_d]); if( skip ) return; // loop through orders in reverse size_t j, k; j = d; while(j) { px[j] += pz[j]; // scale partial w.r.t z[j] pz[j] /= Base(j); for(k = 1; k <= j; k++) { px[k] += Base(k) * azmul(pz[j], z[j-k]); pz[j-k] += Base(k) * azmul(pz[j], x[k]); } --j; } px[0] += pz[0] + azmul(pz[0], z[0]); } } // END_CPPAD_NAMESPACE # endif # endif cppad-20160000.1/cppad/local/prototype_op.hpp0000644000175200017650000012414612656321767020103 0ustar coincoin-web// $Id: prototype_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_PROTOTYPE_OP_HPP # define CPPAD_PROTOTYPE_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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< \a Base > and computations by this routine are done using type \a 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 \a taylor corresponding to z. \param i_x variable index corresponding to the argument for this operator; i.e. the row index in \a taylor corresponding to x. \param cap_order maximum number of orders that will fit in the \c 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 inline 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< \a Base > and computations by this routine are done using type \a Base. \param q order of the Taylor coefficients that we are computing. \param r number of directions for Taylor coefficients that we are computing. \param i_z variable index corresponding to the last (primary) result for this operation; i.e. the row index in \a taylor corresponding to z. The auxillary result is called y has index \a i_z - 1. \param i_x variable index corresponding to the argument for this operator; i.e. the row index in \a taylor corresponding to x. \param cap_order maximum number of orders that will fit in the \c 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 inline 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< \a Base > and computations by this routine are done using type \a Base . \param i_z variable index corresponding to the result for this operation; i.e. the row index in \a taylor corresponding to z. \param i_x variable index corresponding to the argument for this operator; i.e. the row index in \a taylor corresponding to x. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor \b Input: \a taylor [ \a i_x * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to x. \n \b Output: \a taylor [ \a i_z * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to z. \par Checked Assertions \li NumArg(op) == 1 \li NumRes(op) == 1 \li \a i_x < \a i_z \li \a 0 < \a cap_order */ template inline void forward_unary1_op_0( size_t i_z , size_t i_x , size_t cap_order , 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< \a Base > and computations by this routine are done using type \a 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 \a taylor to z. \param i_x variable index corresponding to the argument for this operation; i.e. the row index in \a taylor corresponding to x. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor \a taylor [ \a i_x * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to x. \n \a taylor [ \a i_z * \a cap_order + k ] for k = 0 , ... , \a 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: \a partial [ \a i_x * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G( z , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Input: \a partial [ \a i_z * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G( z , x , w , u , ... ) with respect to the k-th order Taylor coefficient for z. \n \b Output: \a partial [ \a i_x * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of H( x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Output: \a partial [ \a i_z * \a nc_partial + k ] for k = 0 , ... , \a d may be used as work space; i.e., may change in an unspecified manner. \par Checked Assumptions \li NumArg(op) == 1 \li NumRes(op) == 1 \li \a i_x < \a i_z \li \a d < \a cap_order \li \a d < \a nc_partial */ template inline 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< \a Base > and computations by this routine are done using type \a 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 \a taylor corresponding to z. The auxillary result is called y has index \a i_z - 1. \param i_x variable index corresponding to the argument for this operator; i.e. the row index in \a taylor corresponding to x. \param cap_order maximum number of orders that will fit in the \c 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 inline 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< \a Base > and computations by this routine are done using type \a Base. \param q order of the Taylor coefficients that we are computing. \param r number of directions for Taylor coefficients that we are computing. \param i_z variable index corresponding to the last (primary) result for this operation; i.e. the row index in \a taylor corresponding to z. The auxillary result is called y has index \a i_z - 1. \param i_x variable index corresponding to the argument for this operator; i.e. the row index in \a taylor corresponding to x. \param cap_order maximum number of orders that will fit in the \c 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 inline 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< \a Base > and computations by this routine are done using type \a Base . \param i_z variable index corresponding to the last (primary) result for this operation; i.e. the row index in \a taylor corresponding to z. The auxillary result is called y and has index \a i_z - 1. \param i_x variable index corresponding to the argument for this operator; i.e. the row index in \a taylor corresponding to x. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor \b Input: \a taylor [ \a i_x * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to x. \n \b Output: \a taylor [ \a i_z * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to z. \n \b Output: \a taylor [ ( \a i_z - 1 ) * \a cap_order + j ] is the j-th order Taylor coefficient corresponding to the autillary result y. \par Checked Assertions \li NumArg(op) == 1 \li NumRes(op) == 2 \li \a i_x + 1 < \a i_z \li \a j < \a cap_order */ template inline void forward_unary2_op_0( size_t i_z , size_t i_x , size_t cap_order , 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< \a Base > and computations by this routine are done using type \a 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 \a taylor to z. The auxillary result is called y and has index \a i_z - 1. \param i_x variable index corresponding to the argument for this operation; i.e. the row index in \a taylor corresponding to x. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor \a taylor [ \a i_x * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to x. \n \a taylor [ \a i_z * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to z. \n \a taylor [ ( \a i_z - 1) * \a cap_order + k ] for k = 0 , ... , \a 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: \a partial [ \a i_x * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Input: \a partial [ \a i_z * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for z. \n \b Input: \a partial [ ( \a i_z - 1) * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G( z , x , w , u , ... ) with respect to the k-th order Taylor coefficient for the auxillary variable y. \n \b Output: \a partial [ \a i_x * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of H( x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Output: \a partial [ \a ( i_z - j ) * \a nc_partial + k ] for j = 0 , 1 , and for k = 0 , ... , \a d may be used as work space; i.e., may change in an unspecified manner. \par Checked Assumptions \li NumArg(op) == 1 \li NumRes(op) == 2 \li \a i_x + 1 < \a i_z \li \a d < \a cap_order \li \a d < \a nc_partial */ template inline 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< \a Base > and computations by this routine are done using type \a 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 \a taylor corresponding to z. \param arg \a arg[0] index corresponding to the left operand for this operator; i.e. the index corresponding to x. \n \a 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, \a parameter [ \a arg[0] ] is the value corresponding to x. \n If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor \b Input: If x is a variable, taylor [ arg[0] * cap_order + k ], for k = 0 , ... , q, is the k-th order Taylor coefficient corresponding to x. \n \b Input: If y is a variable, taylor [ arg[1] * cap_order + k ], 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 inline 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< \a Base > and computations by this routine are done using type \a 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 \a taylor corresponding to z. \param arg \a arg[0] index corresponding to the left operand for this operator; i.e. the index corresponding to x. \n \a 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, \a parameter [ \a arg[0] ] is the value corresponding to x. \n If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \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 inline 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< \a Base > and computations by this routine are done using type \a Base. \param i_z variable index corresponding to the result for this operation; i.e. the row index in \a taylor corresponding to z. \param arg \a arg[0] index corresponding to the left operand for this operator; i.e. the index corresponding to x. \n \a 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, \a parameter [ \a arg[0] ] is the value corresponding to x. \n If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor \b Input: If x is a variable, \a taylor [ \a arg[0] * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to x. \n \b Input: If y is a variable, \a taylor [ \a arg[1] * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to y. \n \b Output: \a taylor [ \a i_z * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to z. \par Checked Assertions \li NumArg(op) == 2 \li NumRes(op) == 1 */ template inline 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< \a Base > and computations by this routine are done using type \a 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 \a taylor corresponding to z. \param arg \a arg[0] index corresponding to the left operand for this operator; i.e. the index corresponding to x. \n \a 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, \a parameter [ \a arg[0] ] is the value corresponding to x. \n If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor \a taylor [ \a i_z * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to z. \n If x is a variable, \a taylor [ \a arg[0] * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to x. \n If y is a variable, \a taylor [ \a arg[1] * \a cap_order + k ] for k = 0 , ... , \a 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: \a partial [ \a i_z * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for z. \n \b Input: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Input: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G( z , x , w , u , ... ) with respect to the k-th order Taylor coefficient for the auxillary variable y. \n \b Output: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of H( y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Output: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of H( y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for y. \n \b Output: \a partial [ \a i_z * \a nc_partial + k ] for k = 0 , ... , \a d may be used as work space; i.e., may change in an unspecified manner. \par Checked Assumptions \li NumArg(op) == 2 \li NumRes(op) == 1 \li \a If x is a variable, arg[0] < \a i_z \li \a If y is a variable, arg[1] < \a i_z \li \a d < \a cap_order \li \a d < \a nc_partial */ template inline 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< \a Base > and computations by this routine are done using type \a 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 \a taylor corresponding to z. Note that there are three results for this operation, below they are referred to as z_0, z_1, z_2 and correspond to \verbatim 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 \a arg[0] index corresponding to the left operand for this operator; i.e. the index corresponding to x. \n \a 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, \a parameter [ \a arg[0] ] is the value corresponding to x. \n If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor \b Input: If x is a variable, taylor [ arg[0] * cap_order + k ] for k = 0 , ... , q, is the k-th order Taylor coefficient corresponding to x. \n \b Input: If y is a variable, taylor [ arg[1] * cap_order + k ] 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 inline 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< \a Base > and computations by this routine are done using type \a 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 \a taylor corresponding to z. Note that there are three results for this operation, below they are referred to as z_0, z_1, z_2 and correspond to \verbatim 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 \a arg[0] index corresponding to the left operand for this operator; i.e. the index corresponding to x. \n \a 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, \a parameter [ \a arg[0] ] is the value corresponding to x. \n If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \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 inline 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< \a Base > and computations by this routine are done using type \a Base. \param i_z variable index corresponding to the last (primary) result for this operation; i.e. the row index in \a taylor corresponding to z. 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 \a arg[0] index corresponding to the left operand for this operator; i.e. the index corresponding to x. \n \a 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, \a parameter [ \a arg[0] ] is the value corresponding to x. \n If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor \b Input: If x is a variable, \a taylor [ \a arg[0] * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to x. \n \b Input: If y is a variable, \a taylor [ \a arg[1] * \a cap_order + 0 ] is the k-th order Taylor coefficient corresponding to y. \n \b Output: \a taylor [ \a (i_z - 2 + j) * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to z_j. \par Checked Assertions \li NumArg(op) == 2 \li NumRes(op) == 3 \li If x is a variable, \a arg[0] < \a i_z - 2 \li If y is a variable, \a arg[1] < \a i_z - 2 */ template inline 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< \a Base > and computations by this routine are done using type \a 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 \a taylor corresponding to z. Note that there are three results for this operation, below they are referred to as z_0, z_1, z_2 and correspond to \verbatim 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 \a arg[0] index corresponding to the left operand for this operator; i.e. the index corresponding to x. \n \a 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, \a parameter [ \a arg[0] ] is the value corresponding to x. \n If y is a parameter, \a parameter [ \a arg[1] ] is the value corresponding to y. \param cap_order maximum number of orders that will fit in the \c taylor array. \param taylor \a taylor [ \a (i_z - 2 + j) * \a cap_order + k ] for j = 0, 1, 2 and k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to z_j. \n If x is a variable, \a taylor [ \a arg[0] * \a cap_order + k ] for k = 0 , ... , \a d is the k-th order Taylor coefficient corresponding to x. \n If y is a variable, \a taylor [ \a arg[1] * \a cap_order + k ] for k = 0 , ... , \a 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: \a partial [ \a (i_z - 2 + j) * \a nc_partial + k ] for j = 0, 1, 2, and k = 0 , ... , \a d is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for z_j. \n \b Input: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Input: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of G( z , x , w , u , ... ) with respect to the k-th order Taylor coefficient for the auxillary variable y. \n \b Output: If x is a variable, \a partial [ \a arg[0] * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of H( y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for x. \n \b Output: If y is a variable, \a partial [ \a arg[1] * \a nc_partial + k ] for k = 0 , ... , \a d is the partial derivative of H( y , x , w , u , ... ) with respect to the k-th order Taylor coefficient for y. \n \b Output: \a partial [ \a ( i_z - j ) * \a nc_partial + k ] for j = 0 , 1 , 2 and for k = 0 , ... , \a d 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 \a If x is a variable, arg[0] < \a i_z - 2 \li \a If y is a variable, arg[1] < \a i_z - 2 \li \a d < \a cap_order \li \a d < \a nc_partial */ template inline 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z variable index corresponding to the result for this operation; i.e. the row index in sparsity corresponding to z. \param i_x variable index corresponding to the argument for this operator; i.e. the row index in sparsity corresponding to x. \param rev_jacobian \a rev_jacobian[i_z] is all false (true) if the Jacobian of G with respect to z must be zero (may be non-zero). \n \n \a rev_jacobian[i_x] is all false (true) if the Jacobian with respect to x must be zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. \param for_jac_sparsity The set with index \a i_x in for_jac_sparsity is the forward mode Jacobian sparsity pattern for the variable x. \param rev_hes_sparsity The set with index \a i_z in in \a 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 \a i_x in \a 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 \a i_x < \a i_z */ template inline 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z variable index corresponding to the result for this operation; i.e. the row index in sparsity corresponding to z. \param arg \a arg[0] variable index corresponding to the left operand for this operator; i.e. the set with index \a arg[0] in \a 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 \a jac_reverse[i_z] is false (true) if the Jacobian of G with respect to z is always zero (may be non-zero). \n \n \a jac_reverse[ \a arg[0] ] is false (true) if the Jacobian with respect to x is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. \n \n \a jac_reverse[ \a arg[1] ] is false (true) if the Jacobian with respect to y is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. \param for_jac_sparsity The set with index \a arg[0] in \a for_jac_sparsity for the is the forward Jacobian sparsity pattern for x. \n \n The set with index \a arg[1] in \a for_jac_sparsity is the forward sparsity pattern for y. \param rev_hes_sparsity The set wiht index \a i_x in \a rev_hes_sparsity is the Hessian sparsity pattern for the function G where one of the partial derivatives is with respect to z. \n \n The set with index \a arg[0] in \a rev_hes_sparsity is the Hessian sparsity pattern where one of the partial derivatives is with respect to x. On input, it corresponds to the function G, and on output it correspondst to H. \n \n The set with index \a arg[1] in \a rev_hes_sparsity is the Hessian sparsity pattern where one of the partial derivatives is with respect to y. On input, it corresponds to the function G, and on output it correspondst to H. \par Checked Assertions: \li \a arg[0] < \a i_z \li \a arg[1] < \a i_z */ template inline 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_NAMESPACE # endif cppad-20160000.1/cppad/local/forward2sweep.hpp0000644000175200017650000005547712656321767020144 0ustar coincoin-web// $Id: forward2sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FORWARD2SWEEP_HPP # define CPPAD_FORWARD2SWEEP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file forward2sweep.hpp Compute one Taylor coefficient for each direction requested. */ /* \def CPPAD_ATOMIC_CALL This avoids warnings when NDEBUG is defined and user_ok is not used. If NDEBUG is defined, this resolves to \code user_atom->forward \endcode otherwise, it respolves to \code user_ok = user_atom->forward \endcode This macro is undefined at the end of this file to facillitate its use with a different definition in other files. */ # ifdef NDEBUG # define CPPAD_ATOMIC_CALL user_atom->forward # else # define CPPAD_ATOMIC_CALL user_ok = user_atom->forward # endif /*! \def CPPAD_FORWARD2SWEEP_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_FORWARD2SWEEP_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. \n \n The object play is effectly constant. The exception to this is that while palying back the tape the object play holds information about the current location with in the tape and this changes during palyback. \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). */ template void forward2sweep( const size_t q, const size_t r, const size_t n, const size_t numvar, player* play, const size_t J, Base* taylor, const bool* cskip_op, const pod_vector& var_by_load_op ) { CPPAD_ASSERT_UNKNOWN( q > 0 ); CPPAD_ASSERT_UNKNOWN( J >= q + 1 ); CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar ); // used to avoid compiler errors until all operators are implemented size_t p = q; // op code for current instruction OpCode op; // index for current instruction size_t i_op; // next variables size_t i_var; // operation argument indices const addr_t* arg = CPPAD_NULL; // work space used by UserOp. vector user_vx; // empty vecotor vector user_vy; // empty vecotor vector user_tx_one; // argument vector Taylor coefficients vector user_tx_all; vector user_ty_one; // result vector Taylor coefficients vector user_ty_all; size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator size_t user_i = 0; // index in result vector size_t user_j = 0; // index in argument vector size_t user_m = 0; // size of result vector size_t user_n = 0; // size of arugment vector // atomic_base* user_atom = CPPAD_NULL; // user's atomic op calculator # ifndef NDEBUG bool user_ok = false; // atomic op return value # endif // // next expected operator in a UserOp sequence enum { user_start, user_arg, user_ret, user_end, user_trace } user_state = user_start; // 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 user calculation // (not needed for order zero) const size_t user_q1 = q+1; // variable indices for results vector // (done differently for order zero). vector user_iy; // skip the BeginOp at the beginning of the recording play->forward_start(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( op == BeginOp ); # if CPPAD_FORWARD2SWEEP_TRACE std::cout << std::endl; CppAD::vector Z_vec(q+1); # endif bool more_operators = true; while(more_operators) { // this op play->forward_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) ); CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) ); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); CPPAD_ASSERT_ARG_BEFORE_RESULT(op, arg, i_var); // check if we are skipping this operation while( cskip_op[i_op] ) { if( op == CSumOp ) { // CSumOp has a variable number of arguments play->forward_csum(op, arg, i_op, i_var); } CPPAD_ASSERT_UNKNOWN( op != CSkipOp ); // if( op == CSkipOp ) // { // CSkip has a variable number of arguments // play->forward_cskip(op, arg, i_op, i_var); // } play->forward_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); } // action depends on the operator switch( op ) { case AbsOp: forward_abs_op_dir(q, r, i_var, 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, 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, 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, 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, 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, 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, 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, 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, arg[0], J, taylor); break; // ------------------------------------------------- case CSkipOp: // CSkipOp has a variable number of arguments and // forward_next thinks it has no arguments. // we must inform forward_next of this special case. play->forward_cskip(op, arg, i_op, i_var); break; // ------------------------------------------------- case CSumOp: // CSumOp has a variable number of arguments and // forward_next thinks it has no arguments. // we must inform forward_next of this special case. forward_csum_op_dir( q, r, i_var, arg, num_par, parameter, J, taylor ); play->forward_csum(op, arg, i_op, i_var); 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; // ------------------------------------------------- case ExpOp: forward_exp_op_dir(q, r, i_var, arg[0], J, taylor); break; // ------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 case Expm1Op: forward_expm1_op_dir(q, r, i_var, arg[0], J, taylor); break; # endif // ------------------------------------------------- case InvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); break; // ------------------------------------------------- case LdpOp: case LdvOp: forward_load_op( play, op, p, q, r, J, i_var, arg, var_by_load_op.data(), taylor ); break; // --------------------------------------------------- case EqpvOp: case EqvvOp: case LtpvOp: case LtvpOp: case LtvvOp: case LepvOp: case LevpOp: case LevvOp: case NepvOp: case NevvOp: CPPAD_ASSERT_UNKNOWN(q > 0 ); break; // ------------------------------------------------- case LogOp: forward_log_op_dir(q, r, i_var, arg[0], J, taylor); break; // --------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 case Log1pOp: forward_log1p_op_dir(q, r, i_var, arg[0], J, taylor); break; # endif // --------------------------------------------------- case MulpvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); 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); 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, 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, 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, arg[0], J, taylor); break; // ------------------------------------------------- case SqrtOp: forward_sqrt_op_dir(q, r, i_var, 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, 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, arg[0], J, taylor); break; // ------------------------------------------------- case UserOp: // start or end an atomic operation sequence CPPAD_ASSERT_UNKNOWN( NumRes( UserOp ) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg( UserOp ) == 4 ); if( user_state == user_start ) { user_index = arg[0]; user_id = arg[1]; user_n = arg[2]; user_m = arg[3]; user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif if(user_tx_one.size() != user_n * user_q1) user_tx_one.resize(user_n * user_q1); if( user_tx_all.size() != user_n * (q * r + 1) ) user_tx_all.resize(user_n * (q * r + 1)); // if(user_ty_one.size() != user_m * user_q1) user_ty_one.resize(user_m * user_q1); if( user_ty_all.size() != user_m * (q * r + 1) ) user_ty_all.resize(user_m * (q * r + 1)); // if(user_iy.size() != user_m) user_iy.resize(user_m); user_j = 0; user_i = 0; user_state = user_arg; } else { CPPAD_ASSERT_UNKNOWN( user_state == user_end ); CPPAD_ASSERT_UNKNOWN( user_index == size_t(arg[0]) ); CPPAD_ASSERT_UNKNOWN( user_id == size_t(arg[1]) ); CPPAD_ASSERT_UNKNOWN( user_n == size_t(arg[2]) ); CPPAD_ASSERT_UNKNOWN( user_m == size_t(arg[3]) ); // call users function for this operation user_atom->set_id(user_id); for(ell = 0; ell < r; ell++) { // set user_tx for(j = 0; j < user_n; j++) { size_t j_all = j * (q * r + 1); size_t j_one = j * user_q1; user_tx_one[j_one+0] = user_tx_all[j_all+0]; for(k = 1; k < user_q1; k++) { size_t k_all = j_all + (k-1)*r+1+ell; size_t k_one = j_one + k; user_tx_one[k_one] = user_tx_all[k_all]; } } // set user_ty for(i = 0; i < user_m; i++) { size_t i_all = i * (q * r + 1); size_t i_one = i * user_q1; user_ty_one[i_one+0] = user_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; user_ty_one[k_one] = user_ty_all[k_all]; } } CPPAD_ATOMIC_CALL( q, q, user_vx, user_vy, user_tx_one, user_ty_one ); # ifndef NDEBUG if( ! user_ok ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base.forward: returned false"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif for(i = 0; i < user_m; i++) { if( user_iy[i] > 0 ) { size_t i_taylor = user_iy[i]*((J-1)*r+1); size_t q_taylor = i_taylor + (q-1)*r+1+ell; size_t q_one = i * user_q1 + q; taylor[q_taylor] = user_ty_one[q_one]; } } } # if CPPAD_FORWARD2SWEEP_TRACE user_state = user_trace; # else user_state = user_start; # endif } break; case UsrapOp: // parameter argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( user_j < user_n ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); user_tx_all[user_j*(q*r+1) + 0] = parameter[ arg[0]]; for(ell = 0; ell < r; ell++) for(k = 1; k < user_q1; k++) user_tx_all[user_j*(q*r+1) + (k-1)*r+1+ell] = Base(0); ++user_j; if( user_j == user_n ) user_state = user_ret; break; case UsravOp: // variable argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( user_j < user_n ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= i_var ); user_tx_all[user_j*(q*r+1)+0] = taylor[arg[0]*((J-1)*r+1)+0]; for(ell = 0; ell < r; ell++) { for(k = 1; k < user_q1; k++) { user_tx_all[user_j*(q*r+1) + (k-1)*r+1+ell] = taylor[arg[0]*((J-1)*r+1) + (k-1)*r+1+ell]; } } ++user_j; if( user_j == user_n ) user_state = user_ret; break; case UsrrpOp: // parameter result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( user_i < user_m ); user_iy[user_i] = 0; user_ty_all[user_i*(q*r+1) + 0] = parameter[ arg[0]]; for(ell = 0; ell < r; ell++) for(k = 1; k < user_q1; k++) user_ty_all[user_i*(q*r+1) + (k-1)*r+1+ell] = Base(0); user_i++; if( user_i == user_m ) user_state = user_end; break; case UsrrvOp: // variable result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( user_i < user_m ); user_iy[user_i] = i_var; user_ty_all[user_i*(q*r+1)+0] = taylor[i_var*((J-1)*r+1)+0]; for(ell = 0; ell < r; ell++) { for(k = 1; k < user_q1; k++) { user_ty_all[user_i*(q*r+1) + (k-1)*r+1+ell] = taylor[i_var*((J-1)*r+1) + (k-1)*r+1+ell]; } } user_i++; if( user_i == user_m ) user_state = user_end; 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_FORWARD2SWEEP_TRACE if( user_state == user_trace ) { user_state = user_start; CPPAD_ASSERT_UNKNOWN( op == UserOp ); CPPAD_ASSERT_UNKNOWN( NumArg(UsrrvOp) == 0 ); for(i = 0; i < user_m; i++) if( user_iy[i] > 0 ) { size_t i_tmp = (i_op + i) - user_m; printOp( std::cout, play, i_tmp, user_iy[i], UsrrvOp, CPPAD_NULL ); Base* Z_tmp = taylor + user_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; } } const addr_t* arg_tmp = arg; if( op == CSumOp ) arg_tmp = arg - arg[-1] - 4; if( op == CSkipOp ) arg_tmp = arg - arg[-1] - 7; if( op != UsrrvOp ) { printOp( std::cout, play, i_op, i_var, op, arg_tmp ); Base* Z_tmp = CPPAD_NULL; if( op == UsravOp ) Z_tmp = taylor + 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( user_state == user_start ); CPPAD_ASSERT_UNKNOWN( i_var + 1 == play->num_var_rec() ); return; } // preprocessor symbols that are local to this file # undef CPPAD_FORWARD2SWEEP_TRACE # undef CPPAD_ATOMIC_CALL } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/atomic_base.hpp0000644000175200017650000012545212656321767017607 0ustar coincoin-web// $Id: atomic_base.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ATOMIC_BASE_HPP # define CPPAD_ATOMIC_BASE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file atomic_base.hpp Base class for atomic user 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 class_object 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 afun, declared here to avoid memory /// allocation/deallocation for each call to afun vector afun_vx_[CPPAD_MAX_NUM_THREADS]; vector afun_vy_[CPPAD_MAX_NUM_THREADS]; vector afun_tx_[CPPAD_MAX_NUM_THREADS]; vector afun_ty_[CPPAD_MAX_NUM_THREADS]; // ----------------------------------------------------- // static member functions // /// List of all the object in this class static std::vector& class_object(void) { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; static std::vector list_; return list_; } /// List of names for each object in this class static std::vector& class_name(void) { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; static std::vector list_; return list_; } // ===================================================================== public: // ----------------------------------------------------- // member functions not in user API // /// current sparsity setting option_enum sparsity(void) const { return sparsity_; } /// Name corresponding to a base_atomic object const std::string& afun_name(void) const { return class_name()[index_]; } /* $begin atomic_ctor$$ $spell enum sq std afun arg CppAD bool ctor const matrix_mul.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 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). $head Examples$$ $subhead Define Constructor$$ The following are links to user atomic function constructor definitions: $cref%get_started.cpp%atomic_get_started.cpp%Constructor%$$, $cref%norm_sq.cpp%atomic_norm_sq.cpp%Constructor%$$, $cref%reciprocal.cpp%atomic_reciprocal.cpp%Constructor%$$, $cref%tangent.cpp%atomic_tangent.cpp%Constructor%$$, $cref%matrix_mul.hpp%atomic_matrix_mul.hpp%Constructor%$$. $subhead Use Constructor$$ The following are links to user atomic function constructor uses: $cref%get_started.cpp%atomic_get_started.cpp%Use Atomic Function%Constructor%$$, $cref%norm_sq.cpp%atomic_norm_sq.cpp%Use Atomic Function%Constructor%$$, $cref%reciprocal.cpp%atomic_reciprocal.cpp%Use Atomic Function%Constructor%$$, $cref%tangent.cpp%atomic_tangent.cpp%Use Atomic Function%Constructor%$$, $cref%mat_mul.cpp%atomic_mat_mul.cpp%Use Atomic Function%Constructor%$$. $end */ /*! Base class for atomic_user functions. \tparam Base This class is used for defining an AD atomic operation y = f(x). */ /// make sure user does not invoke the default constructor 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. */ atomic_base( const std::string& name, option_enum sparsity = bool_sparsity_enum ) : index_( class_object().size() ) , sparsity_( sparsity ) { CPPAD_ASSERT_KNOWN( ! thread_alloc::in_parallel() , "atomic_base: constructor cannot be called in parallel mode." ); class_object().push_back(this); class_name().push_back(name); CPPAD_ASSERT_UNKNOWN( class_object().size() == class_name().size() ); } /// 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) { CPPAD_ASSERT_UNKNOWN( class_object().size() > index_ ); // change object pointer to null, but leave name for error reporting class_object()[index_] = CPPAD_NULL; } /// atomic_base function object corresponding to a certain index static atomic_base* class_object(size_t index) { CPPAD_ASSERT_UNKNOWN( class_object().size() > index ); return class_object()[index]; } /// atomic_base function name corresponding to a certain index static const std::string& class_name(size_t index) { CPPAD_ASSERT_UNKNOWN( class_name().size() > index ); return class_name()[index]; } /* $begin atomic_option$$ $spell sq enum afun bool CppAD std typedef $$ $section Set Atomic Function Options$$ $head Syntax$$ $icode%afun%.option(%option_value%)%$$ These settings do not apply to individual $icode afun$$ calls, but rather all subsequent uses of the corresponding atomic operation in an $cref ADFun$$ object. $head atomic_sparsity$$ Note that, if you use $cref optimize$$, these sparsity patterns are used to determine the $cref/dependency/dependency.cpp/$$ relationship between argument and result variables. $subhead pack_sparsity_enum$$ If $icode option_value$$ is $codei%atomic_base<%Base%>::pack_sparsity_enum%$$, then the type used by $icode afun$$ for $cref/sparsity patterns/glossary/Sparsity Pattern/$$, (after the option is set) will be $codei% typedef CppAD::vectorBool %atomic_sparsity% %$$ If $icode r$$ is a sparsity pattern for a matrix $latex R \in B^{p \times q}$$: $icode%r%.size() == %p% * %q%$$. $subhead bool_sparsity_enum$$ 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^{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^{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 */ void 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; } /* ----------------------------------------------------------------------------- $begin atomic_afun$$ $spell sq mul afun const CppAD $$ $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_ctor/atomic_base/Base/$$. $head afun$$ is a $cref/atomic_user/atomic_ctor/atomic_user/$$ object and this $icode afun$$ function call is implemented by the $cref/atomic_base/atomic_ctor/atomic_base/$$ class. $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^n$$ at which an $codei%AD<%Base%>%$$ version of $latex y = f(x)$$ is to be evaluated; see $cref/Base/atomic_ctor/atomic_base/Base/$$. $head ay$$ 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)$$. $head Examples$$ The following files contain example uses of the AD version of atomic functions during recording: $cref%get_started.cpp%atomic_get_started.cpp%Use Atomic Function%Recording%$$, $cref%norm_sq.cpp%atomic_norm_sq.cpp%Use Atomic Function%Recording%$$, $cref%reciprocal.cpp%atomic_reciprocal.cpp%Use Atomic Function%Recording%$$, $cref%tangent.cpp%atomic_tangent.cpp%Use Atomic Function%Recording%$$, $cref%matrix_mul.cpp%atomic_mat_mul.cpp%Use Atomic Function%Recording%$$. $end ----------------------------------------------------------------------------- */ /*! Implement the user call to afun(ax, ay) and old_atomic 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 old_atomic derived class (not other derived classes). This is an extra parameter to the virtual callbacks for old_atomic; see the set_id 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 void operator()( const ADVector& ax , ADVector& ay , size_t id = 0 ) { 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(); vector & tx = afun_tx_[thread]; vector & ty = afun_ty_[thread]; vector & vx = afun_vx_[thread]; vector & vy = afun_vy_[thread]; // 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; ADTape* tape = CPPAD_NULL; for(j = 0; j < n; j++) { tx[j] = ax[j].value_; vx[j] = Variable( 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_id(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 eleemnts 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( NumRes(UserOp) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg(UserOp) == 4 ); tape->Rec_.PutArg(index_, id, n, m); tape->Rec_.PutOp(UserOp); // Now put n operators, one for each element of argument vector CPPAD_ASSERT_UNKNOWN( NumRes(UsravOp) == 0 ); CPPAD_ASSERT_UNKNOWN( NumRes(UsrapOp) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg(UsravOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(UsrapOp) == 1 ); for(j = 0; j < n; j++) { if( vx[j] ) { // information for an argument that is a variable tape->Rec_.PutArg(ax[j].taddr_); tape->Rec_.PutOp(UsravOp); } else { // information for an argument that is parameter addr_t par = tape->Rec_.PutPar(ax[j].value_); tape->Rec_.PutArg(par); tape->Rec_.PutOp(UsrapOp); } } // Now put m operators, one for each element of result vector CPPAD_ASSERT_UNKNOWN( NumArg(UsrrpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(UsrrpOp) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg(UsrrvOp) == 0 ); CPPAD_ASSERT_UNKNOWN( NumRes(UsrrvOp) == 1 ); for(i = 0; i < m; i++) { if( vy[i] ) { ay[i].taddr_ = tape->Rec_.PutOp(UsrrvOp); ay[i].tape_id_ = tape_id; } else { addr_t par = tape->Rec_.PutPar(ay[i].value_); tape->Rec_.PutArg(par); tape->Rec_.PutOp(UsrrpOp); } } // Put a duplicate UserOp at end of UserOp sequence tape->Rec_.PutArg(index_, id, n, m); tape->Rec_.PutOp(UserOp); } return; } /* ----------------------------------------------------------------------------- $begin atomic_forward$$ $spell sq mul.hpp hes afun vx vy ty Taylor const CppAD bool $$ $section Atomic Forward Mode$$ $mindex callback virtual$$ $head Syntax$$ $icode%ok% = %afun%.forward(%p%, %q%, %vx%, %vy%, %tx%, %ty%)%$$ $head Purpose$$ This virtual function is used by $cref atomic_afun$$ to evaluate function values. It is also used buy $cref/forward/Forward/$$ to compute function vales and derivatives. $head Implementation$$ This virtual function must be defined by the $cref/atomic_user/atomic_ctor/atomic_user/$$ class. It can just return $icode%ok% == false%$$ (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_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_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_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/$$ in the corresponding call to $codei% %afun%(%ax%, %ay%, %id%) %$$ 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 (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%$$. 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 ty$$ The argument $icode ty$$ has prototype $codei% CppAD::vector<%Base%>& %ty% %$$ and $icode%tx%.size() == (%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) & = & 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 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 \] $$ $head Examples$$ $subhead Define forward$$ The following files contain example atomic $code forward$$ functions: $cref%get_started.cpp%atomic_get_started.cpp%forward%$$, $cref%norm_sq.cpp%atomic_norm_sq.cpp%forward%$$, $cref%reciprocal.cpp%atomic_reciprocal.cpp%forward%$$, $cref%tangent.cpp%atomic_tangent.cpp%forward%$$, $cref%matrix_mul.hpp%atomic_matrix_mul.hpp%forward%$$. $subhead Use forward$$ The following are links to user atomic function forward uses: $cref%get_started.cpp%atomic_get_started.cpp%Use Atomic Function%forward%$$, $cref%norm_sq.cpp%atomic_norm_sq.cpp%Use Atomic Function%forward%$$, $cref%reciprocal.cpp%atomic_reciprocal.cpp%Use Atomic Function%forward%$$, $cref%tangent.cpp%atomic_tangent.cpp%Use Atomic Function%forward%$$, $cref%mat_mul.cpp%atomic_mat_mul.cpp%Use Atomic Function%forward%$$. $end ----------------------------------------------------------------------------- */ /*! Link from atomic_base to forward mode \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 \c x are variables \param vy [out] if size not zero, which components of \c y are variables \param tx [in] Taylor coefficients corresponding to \c x for this calculation. \param ty [out] Taylor coefficient corresponding to \c y for this calculation See the forward mode in user's documentation for base_atomic */ virtual bool forward( size_t p , size_t q , const vector& vx , vector& vy , const vector& tx , vector& ty ) { return false; } /* ----------------------------------------------------------------------------- $begin atomic_reverse$$ $spell sq mul.hpp afun ty px py Taylor const CppAD $$ $section Atomic Reverse Mode$$ $spell bool $$ $head Syntax$$ $icode%ok% = %afun%.reverse(%q%, %tx%, %ty%, %px%, %py%)%$$ $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_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 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 F, G, H$$ We use the notation $latex \{ x_j^k \} \in B^{n \times (q+1)}$$ for $latex \[ \{ x_j^k \W{:} j = 0 , \ldots , n-1, k = 0 , \ldots , q \} \]$$ We use the notation $latex \{ y_i^k \} \in B^{m \times (q+1)}$$ for $latex \[ \{ y_i^k \W{:} i = 0 , \ldots , m-1, k = 0 , \ldots , q \} \]$$ We define the function $latex F : B^{n \times (q+1)} \rightarrow B^{m \times (q+1)}$$ by $latex \[ y_i^k = F_i^k [ \{ x_j^k \} ] \] $$ We use $latex G : B^{m \times (q+1)} \rightarrow B$$ to denote an arbitrary scalar valued function of $latex \{ y_i^k \}$$. We use $latex H : B^{n \times (q+1)} \rightarrow B$$ 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 \] $$ $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 \} ) ( \partial \{ y_i^k \} / \partial x_j^\ell ) \\ & = & \sum_{i=0}^{m-1} \sum_{k=0}^q ( \partial G / \partial y_i^k ) ( \partial y_i^k / \partial x_j^\ell ) \\ & = & \sum_{i=0}^{m-1} \sum_{k=\ell}^q py[ i * (q + 1 ) + k ] ( \partial F_i^k / \partial x_j^\ell ) \end{array} \] $$ Note that we have used the fact that for $latex k < \ell$$, $latex \partial F_i^k / \partial x_j^\ell = 0$$. $head ok$$ The return value $icode ok$$ has prototype $codei% bool %ok% %$$ If it is $code true$$, the corresponding evaluation succeeded, otherwise it failed. $head Examples$$ $subhead Define reverse$$ The following files contain example atomic $code reverse$$ functions: $cref%norm_sq.cpp%atomic_norm_sq.cpp%reverse%$$, $cref%reciprocal.cpp%atomic_reciprocal.cpp%reverse%$$, $cref%tangent.cpp%atomic_tangent.cpp%reverse%$$, $cref%matrix_mul.hpp%atomic_matrix_mul.hpp%reverse%$$. $subhead Use reverse$$ The following are links to user atomic function constructor uses: $cref%norm_sq.cpp%atomic_norm_sq.cpp%Use Atomic Function%reverse%$$, $cref%reciprocal.cpp%atomic_reciprocal.cpp%Use Atomic Function%reverse%$$, $cref%tangent.cpp%atomic_tangent.cpp%Use Atomic Function%reverse%$$, $cref%mat_mul.cpp%atomic_mat_mul.cpp%Use Atomic Function%reverse%$$. $end ----------------------------------------------------------------------------- */ /*! 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 \c x for this calculation. \param ty [in] Taylor coefficient corresponding to \c y for this calculation \param px [out] Partials w.r.t. the \c x Taylor coefficients. \param py [in] Partials w.r.t. the \c y Taylor coefficients. See atomic_reverse mode use documentation */ virtual bool reverse( size_t q , const vector& tx , const vector& ty , vector& px , const vector& py ) { return false; } /* -------------------------------------- --------------------------------------- $begin atomic_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%)%$$ $head Purpose$$ This function is used by $cref ForSparseJac$$ to compute Jacobian sparsity patterns. For a fixed matrix $latex R \in B^{n \times q}$$, the Jacobian of $latex f( x + R * u)$$ with respect to $latex u \in B^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$$, this virtual function must be defined by the $cref/atomic_user/atomic_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^{n \times q}$$ and the Jacobian $latex S(x) \in B^{m \times q}$$. $subhead r$$ This argument has prototype $codei% const %atomic_sparsity%& %r% %$$ and is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for $latex R \in B^{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_option/atomic_sparsity/$$ pattern for $latex S(x) \in B^{m \times q}$$. $head ok$$ The return value $icode ok$$ has prototype $codei% bool %ok% %$$ If it is $code true$$, the corresponding evaluation succeeded, otherwise it failed. $head Examples$$ $subhead Define for_sparse_jac$$ The following files contain example atomic $code for_sparse_jac$$ functions: $cref%norm_sq.cpp%atomic_norm_sq.cpp%for_sparse_jac%$$, $cref%reciprocal.cpp%atomic_reciprocal.cpp%for_sparse_jac%$$, $cref%tangent.cpp%atomic_tangent.cpp%for_sparse_jac%$$, $cref%matrix_mul.hpp%atomic_matrix_mul.hpp%for_sparse_jac%$$. $subhead Use for_sparse_jac$$ The following are links to user atomic function constructor uses: $cref%norm_sq.cpp% atomic_norm_sq.cpp%Use Atomic Function%for_sparse_jac%$$, $cref%reciprocal.cpp% atomic_reciprocal.cpp%Use Atomic Function%for_sparse_jac%$$, $cref%tangent.cpp%atomic_tangent.cpp%Use Atomic Function%for_sparse_jac%$$, $cref%mat_mul.cpp%atomic_mat_mul.cpp%Use Atomic Function%for_sparse_jac%$$. $end ----------------------------------------------------------------------------- */ /*! Link from forward Jacobian sparsity 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 */ virtual bool for_sparse_jac( size_t q , const vector< std::set >& r , vector< std::set >& s ) { return false; } virtual bool for_sparse_jac( size_t q , const vector& r , vector& s ) { return false; } virtual bool for_sparse_jac( size_t q , const vectorBool& r , vectorBool& s ) { return false; } /* -------------------------------------- --------------------------------------- $begin atomic_rev_sparse_jac$$ $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%)%$$ $head Purpose$$ This function is used by $cref RevSparseJac$$ to compute Jacobian sparsity patterns. For a fixed matrix $latex R \in B^{q \times m}$$, the Jacobian of $latex R * f( x )$$ with respect to $latex x \in B^q$$ 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$$, this virtual function must be defined by the $cref/atomic_user/atomic_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^{q \times m}$$ and the Jacobian $latex S(x) \in B^{q \times n}$$. $subhead rt$$ This argument has prototype $codei% const %atomic_sparsity%& %rt% %$$ and is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for $latex R^\R{T} \in B^{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_option/atomic_sparsity/$$ pattern for $latex S(x)^\R{T} \in B^{n \times q}$$. $head ok$$ The return value $icode ok$$ has prototype $codei% bool %ok% %$$ If it is $code true$$, the corresponding evaluation succeeded, otherwise it failed. $head Examples$$ $subhead Define rev_sparse_jac$$ The following files contain example atomic $code rev_sparse_jac$$ functions: $cref%norm_sq.cpp%atomic_norm_sq.cpp%rev_sparse_jac%$$, $cref%reciprocal.cpp%atomic_reciprocal.cpp%rev_sparse_jac%$$, $cref%tangent.cpp%atomic_tangent.cpp%rev_sparse_jac%$$, $cref%matrix_mul.hpp%atomic_matrix_mul.hpp%rev_sparse_jac%$$. $subhead Use rev_sparse_jac$$ The following are links to user atomic function constructor uses: $cref%norm_sq.cpp% atomic_norm_sq.cpp%Use Atomic Function%rev_sparse_jac%$$, $cref%reciprocal.cpp% atomic_reciprocal.cpp%Use Atomic Function%rev_sparse_jac%$$, $cref%tangent.cpp%atomic_tangent.cpp%Use Atomic Function%rev_sparse_jac%$$, $cref%mat_mul.cpp%atomic_mat_mul.cpp%Use Atomic Function%rev_sparse_jac%$$. $end ----------------------------------------------------------------------------- */ /*! Link from reverse Jacobian sparsity 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 */ virtual bool rev_sparse_jac( size_t q , const vector< std::set >& rt , vector< std::set >& st ) { return false; } virtual bool rev_sparse_jac( size_t q , const vector& rt , vector& st ) { return false; } virtual bool rev_sparse_jac( size_t q , const vectorBool& rt , vectorBool& st ) { return false; } /* -------------------------------------- --------------------------------------- $begin atomic_rev_sparse_hes$$ $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%)%$$ $head Purpose$$ This function is used by $cref RevSparseHes$$ to compute Hessian sparsity patterns. There is an unspecified scalar valued function $latex g : B^m \rightarrow B$$. Given a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for $latex R \in B^{n \times q}$$, and information about the function $latex z = g(y)$$, this routine computes the sparsity pattern for $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_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/$$ in the corresponding call to $codei% %afun%(%ax%, %ay%, %id%) %$$ $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)} (y) \in B^{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^{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^{n \times q}$$, $latex U(x) \in B^{m \times q}$$, and $latex V(x) \in B^{n \times q}$$. $subhead r$$ This argument has prototype $codei% const %atomic_sparsity%& %r% %$$ and is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for $latex R \in B^{n \times q}$$. $head u$$ This argument has prototype $codei% const %atomic_sparsity%& %u% %$$ and is a $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ pattern for $latex U(x) \in B^{m \times q}$$ which is defined by $latex \[ \begin{array}{rcl} U(x) & = & \partial_u \{ \partial_y g[ y + f^{(1)} (x) R u ] \}_{u=0} \\ & = & \partial_u \{ g^{(1)} [ y + f^{(1)} (x) R u ] \}_{u=0} \\ & = & g^{(2)} (y) 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_option/atomic_sparsity/$$ pattern for $latex V(x) \in B^{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)} ( y ) f^{(1)} (x) R + \sum_{i=1}^m g_i^{(1)} (y) \; 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} \] $$ $head Examples$$ $subhead Define rev_sparse_hes$$ The following files contain example atomic $code rev_sparse_hes$$ functions: $cref%norm_sq.cpp%atomic_norm_sq.cpp%rev_sparse_hes%$$, $cref%reciprocal.cpp%atomic_reciprocal.cpp%rev_sparse_hes%$$, $cref%tangent.cpp%atomic_tangent.cpp%rev_sparse_hes%$$, $cref%matrix_mul.hpp%atomic_matrix_mul.hpp%rev_sparse_hes%$$. $subhead Use rev_sparse_hes$$ The following are links to user atomic function constructor uses: $cref%norm_sq.cpp% atomic_norm_sq.cpp%Use Atomic Function%rev_sparse_hes%$$, $cref%reciprocal.cpp% atomic_reciprocal.cpp%Use Atomic Function%rev_sparse_hes%$$, $cref%tangent.cpp%atomic_tangent.cpp%Use Atomic Function%rev_sparse_hes%$$, $cref%mat_mul.cpp%atomic_mat_mul.cpp%Use Atomic Function%rev_sparse_hes%$$. $end ----------------------------------------------------------------------------- */ /*! Link from reverse Hessian sparsity sweep to base_atomic \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. */ 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 ) { return false; } virtual bool rev_sparse_hes( const vector& vx , const vector& s , vector& t , size_t q , const vector& r , const vector& u , vector& v ) { return false; } virtual bool rev_sparse_hes( const vector& vx , const vector& s , vector& t , size_t q , const vectorBool& r , const vectorBool& u , vectorBool& v ) { return false; } /* ------------------------------------------------------------------------------ $begin atomic_base_clear$$ $spell sq alloc $$ $section Free Static Variables$$ $mindex clear$$ $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 ------------------------------------------------------------------------------ */ /*! Free all thread_alloc static memory held by atomic_base (avoids reallocations). (This does not include class_object() which is an std::vector.) */ /// Free vector memory used by this class (work space) static void clear(void) { CPPAD_ASSERT_KNOWN( ! thread_alloc::in_parallel() , "cannot use atomic_base clear during parallel execution" ); size_t i = class_object().size(); while(i--) { size_t thread = CPPAD_MAX_NUM_THREADS; while(thread--) { atomic_base* op = class_object()[i]; if( op != CPPAD_NULL ) { op->afun_vx_[thread].clear(); op->afun_vy_[thread].clear(); op->afun_tx_[thread].clear(); op->afun_ty_[thread].clear(); } } } return; } // ------------------------------------------------------------------------- /*! Set value of id (used by deprecated old_atomic class) This function is called just before calling any of the virtual funcitons and has the corresponding id of the corresponding virtual call. */ virtual void set_id(size_t id) { } // --------------------------------------------------------------------------- }; } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/par_var.hpp0000644000175200017650000000603212656321767016763 0ustar coincoin-web// $Id: par_var.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_PAR_VAR_HPP # define CPPAD_PAR_VAR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- $begin ParVar$$ $spell VecAD const bool $$ $section Is an AD Object a Parameter or Variable$$ $head Syntax$$ $icode%b% = Parameter(%x%)%$$ $pre $$ $icode%b% = Variable(%x%)%$$ $head Purpose$$ Determine if $icode x$$ is a $cref/parameter/glossary/Parameter/$$ or $cref/variable/glossary/Variable/$$. $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% %$$ The return value for $code Parameter$$ ($code Variable$$) is true if and only if $icode x$$ is a parameter (variable). Note that 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/par_var.cpp %$$ The file $cref par_var.cpp$$ contains an example and test of these functions. It returns true if it succeeds and false otherwise. $end ----------------------------------------------------------------------------- */ namespace CppAD { // Parameter template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool Parameter(const AD &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); } template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION 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 CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool Variable(const AD &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); } template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION 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 cppad-20160000.1/cppad/local/rev_sparse_jac.hpp0000644000175200017650000004736212656321767020332 0ustar coincoin-web// $Id: rev_sparse_jac.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_REV_SPARSE_JAC_HPP # define CPPAD_REV_SPARSE_JAC_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin RevSparseJac$$ $spell optimizer nz CondExpRel std VecAD var Jacobian Jac const Bool Dep proportional $$ $section Jacobian Sparsity Pattern: Reverse Mode$$ $mindex RevSparseJac sparse$$ $head Syntax$$ $icode%s% = %f%.RevSparseJac(%q%, %r%) %$$ $icode%s% = %f%.RevSparseJac(%q%, %r%, %transpose%, %dependency%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. For a fixed matrix $latex R \in B^{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$$ the sparsity pattern is valid for all values of the independent variables in $latex x \in B^n$$ (even if it has $cref CondExp$$ or $cref VecAD$$ operations). $head q$$ The argument $icode q$$ has prototype $codei% size_t %q% %$$ It specifies the number of rows in $latex R \in B^{q \times m}$$ and the Jacobian $latex S(x) \in B^{q \times n}$$. $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 %VectorSet%& %r% %$$ see $cref/VectorSet/RevSparseJac/VectorSet/$$ 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^{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^{m \times q}$$. $head s$$ The return value $icode s$$ has prototype $codei% %VectorSet% %s% %$$ see $cref/VectorSet/RevSparseJac/VectorSet/$$ 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 VectorSet$$ The type $icode VectorSet$$ 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/rev_sparse_jac.cpp %$$ The file $cref rev_sparse_jac.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. $end ----------------------------------------------------------------------------- */ # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file rev_sparse_jac.hpp Reverse mode Jacobian sparsity patterns. */ // ========================================================================= // RevSparseJacBool /*! Calculate Jacobian vector of bools sparsity patterns using reverse mode. The C++ source code corresponding to this operation is \verbatim s = f.RevSparseJac(q, r) \endverbatim \tparam Base is the base type for this recording. \tparam VectorSet is a simple vector class with elements of type \c bool. \param transpose are the sparsity patterns transposed. \param dependency Are the derivatives with respect to left and right of the expression below considered to be non-zero: \code CondExpRel(left, right, if_true, if_false) \endcode This is used by the optimizer to obtain the correct dependency relations. \param q is the number of rows in the matrix \f$ R \f$. \param r is a sparsity pattern for the matrix \f$ R \f$. \param s the input value of \a s must be a vector with size p*n where \c n is the number of independent variables corresponding to the operation sequence stored in \a play. The input value of the components of \c s does not matter. On output, \a s is the sparsity pattern for the matrix \f[ S(x) = R * F^{(1)} (x) \f] where \f$ F \f$ is the function corresponding to the operation sequence and \a x is any argument value. \param total_num_var is the total number of variable in this recording. \param dep_taddr maps dependendent variable index to the corresponding variable in the tape. \param ind_taddr maps independent variable index to the corresponding variable in the tape. \param play is the recording that defines the function we are computing the sparsity pattern for. */ template void RevSparseJacBool( bool transpose , bool dependency , size_t q , const VectorSet& r , VectorSet& s , size_t total_num_var , CppAD::vector& dep_taddr , CppAD::vector& ind_taddr , CppAD::player& play ) { // temporary indices size_t i, j; // check VectorSet is Simple Vector class with bool elements CheckSimpleVector(); // range and domain dimensions for F size_t m = dep_taddr.size(); size_t n = ind_taddr.size(); 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 sparse_pack var_sparsity; var_sparsity.resize(total_num_var, q); // The sparsity pattern corresponding to the dependent variables for(i = 0; i < m; i++) { CPPAD_ASSERT_UNKNOWN( dep_taddr[i] < total_num_var ); if( transpose ) { for(j = 0; j < q; j++) if( r[ i * q + j ] ) var_sparsity.add_element( dep_taddr[i], j ); } else { for(j = 0; j < q; j++) if( r[ j * m + i ] ) var_sparsity.add_element( dep_taddr[i], j ); } } // evaluate the sparsity patterns RevJacSweep( dependency, n, total_num_var, &play, var_sparsity ); // return values corresponding to dependent variables CPPAD_ASSERT_UNKNOWN( size_t(s.size()) == q * n ); for(j = 0; j < n; j++) { CPPAD_ASSERT_UNKNOWN( ind_taddr[j] == (j+1) ); // ind_taddr[j] is operator taddr for j-th independent variable CPPAD_ASSERT_UNKNOWN( play.GetOp( ind_taddr[j] ) == InvOp ); // extract the result from var_sparsity if( transpose ) { for(i = 0; i < q; i++) s[ j * q + i ] = false; } else { for(i = 0; i < q; i++) s[ i * n + j ] = false; } CPPAD_ASSERT_UNKNOWN( var_sparsity.end() == q ); var_sparsity.begin(j+1); i = var_sparsity.next_element(); while( i < q ) { if( transpose ) s[ j * q + i ] = true; else s[ i * n + j ] = true; i = var_sparsity.next_element(); } } } // ========================================================================= // RevSparseJacSet /*! Calculate Jacobian vector of sets sparsity patterns using reverse mode. The C++ source code corresponding to this operation is \verbatim s = f.RevSparseJac(q, r) \endverbatim \tparam Base see \c RevSparseJacBool. \tparam VectorSet is a simple vector class with elements of type \c std::set. \param transpose see \c RevSparseJacBool. \param dependency see \c RevSparseJacBool. \param q see \c RevSparseJacBool. \param r see \c RevSparseJacBool. \param s see \c RevSparseJacBool. \param total_num_var see \c RevSparseJacBool. \param dep_taddr see \c RevSparseJacBool. \param ind_taddr see \c RevSparseJacBool. \param play see \c RevSparseJacBool. */ template void RevSparseJacSet( bool transpose , bool dependency , size_t q , const VectorSet& r , VectorSet& s , size_t total_num_var , CppAD::vector& dep_taddr , CppAD::vector& ind_taddr , CppAD::player& play ) { // temporary indices size_t i, j; std::set::const_iterator itr; // check VectorSet is Simple Vector class with sets for elements CheckSimpleVector, VectorSet>( one_element_std_set(), 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 CPPAD_INTERNAL_SPARSE_SET var_sparsity; var_sparsity.resize(total_num_var, q); // The sparsity pattern corresponding to the dependent variables if( transpose ) { for(i = 0; i < m; i++) { itr = r[i].begin(); while(itr != r[i].end()) { j = *itr++; 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] < total_num_var ); var_sparsity.add_element( dep_taddr[i], j ); } } } else { for(i = 0; i < q; i++) { itr = r[i].begin(); while(itr != r[i].end()) { j = *itr++; 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] < total_num_var ); var_sparsity.add_element( dep_taddr[j], i ); } } } // evaluate the sparsity patterns RevJacSweep( dependency, n, total_num_var, &play, var_sparsity ); // 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(j = 0; j < n; j++) { CPPAD_ASSERT_UNKNOWN( ind_taddr[j] == (j+1) ); // ind_taddr[j] is operator taddr for j-th independent variable CPPAD_ASSERT_UNKNOWN( play.GetOp( ind_taddr[j] ) == InvOp ); CPPAD_ASSERT_UNKNOWN( var_sparsity.end() == q ); var_sparsity.begin(j+1); i = var_sparsity.next_element(); while( i < q ) { if( transpose ) s[j].insert(i); else s[i].insert(j); i = var_sparsity.next_element(); } } } // ========================================================================= // RevSparseJacCase /*! Private helper function for \c RevSparseJac(q, r, transpose). All of the description in the public member function \c RevSparseJac(q, r, transpose) apply. \param set_type is a \c bool value. This argument is used to dispatch to the proper source code depending on the value of \c VectorSet::value_type. \param transpose See \c RevSparseJac(q, r, transpose, dependency) \param dependency See \c RevSparseJac(q, r, transpose, dependency) \param q See \c RevSparseJac(q, r, transpose, dependency) \param r See \c 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 VectorSet& r , VectorSet& s ) { size_t n = Domain(); // dimension of the result vector s.resize( q * n ); // store results in s RevSparseJacBool( transpose , dependency , q , r , s , num_var_tape_ , dep_taddr_ , ind_taddr_ , play_ ); } /*! Private helper function for \c RevSparseJac(q, r, transpose). All of the description in the public member function \c RevSparseJac(q, r, transpose) apply. \param set_type is a \c std::set object. This argument is used to dispatch to the proper source code depending on the value of \c VectorSet::value_type. \param transpose See \c RevSparseJac(q, r, transpose, dependency) \param dependency See \c RevSparseJac(q, r, transpose, dependency) \param q See \c RevSparseJac(q, r, transpose, dependency) \param r See \c 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 VectorSet& r , VectorSet& s ) { // dimension of the result vector if( transpose ) s.resize( Domain() ); else s.resize( q ); // store results in r RevSparseJacSet( transpose , dependency , q , r , s , num_var_tape_ , dep_taddr_ , ind_taddr_ , play_ ); } // ========================================================================= // RevSparseJac /*! User API for Jacobian sparsity patterns using reverse mode. The C++ source code corresponding to this operation is \verbatim s = f.RevSparseJac(q, r, transpose, dependency) \endverbatim \tparam Base is the base type for this recording. \tparam VectorSet is a simple vector with elements of type \c bool. or \c 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 \c 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 \a x is any argument value. If \c VectorSet::value_type is \c bool, the return value has size \f$ q * n \f$ ( \f$ n * q \f$). If \c VectorSet::value_type is \c 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 VectorSet ADFun::RevSparseJac( size_t q , const VectorSet& r , bool transpose , bool dependency ) { VectorSet s; typedef typename VectorSet::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 , CPPAD_INTERNAL_SPARSE_SET& r , bool transpose , bool dependency , CPPAD_INTERNAL_SPARSE_SET& s ) { size_t n = Domain(); size_t m = Range(); # ifndef NDEBUG if( transpose ) { CPPAD_ASSERT_UNKNOWN( r.n_set() == m ); CPPAD_ASSERT_UNKNOWN( r.end() == q ); } else { CPPAD_ASSERT_UNKNOWN( r.n_set() == q ); CPPAD_ASSERT_UNKNOWN( r.end() == m ); } for(size_t i = 0; i < m; i++) CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); # endif // holds reverse Jacobian sparsity pattern for all variables CPPAD_INTERNAL_SPARSE_SET var_sparsity; var_sparsity.resize(num_var_tape_, q); // set sparsity pattern for dependent variables if( transpose ) { for(size_t i = 0; i < m; i++) { r.begin(i); size_t j = r.next_element(); while( j < q ) { var_sparsity.add_element( dep_taddr_[i], j ); j = r.next_element(); } } } else { for(size_t j = 0; j < q; j++) { r.begin(j); size_t i = r.next_element(); while( i < m ) { var_sparsity.add_element( dep_taddr_[i], j ); i = r.next_element(); } } } // evaluate the sparsity pattern for all variables RevJacSweep( dependency, n, num_var_tape_, &play_, var_sparsity ); // dimension the return value if( transpose ) s.resize(n, m); else s.resize(m, n); // return values corresponding to independent variables for(size_t j = 0; j < n; j++) { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] == (j+1) ); // ind_taddr_[j] is operator taddr for j-th independent variable CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[j] ) == InvOp ); // extract the result from var_sparsity CPPAD_ASSERT_UNKNOWN( var_sparsity.end() == q ); var_sparsity.begin(j+1); size_t i = var_sparsity.next_element(); while( i < q ) { if( transpose ) s.add_element(j, i); else s.add_element(i, j); i = var_sparsity.next_element(); } } } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/bool_valued.hpp0000644000175200017650000000233212656321767017623 0ustar coincoin-web// $Id: bool_valued.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_BOOL_VALUED_HPP # define CPPAD_BOOL_VALUED_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin BoolValued$$ $spell Bool $$ $section Bool Valued Operations and Functions with AD Arguments$$ $children% cppad/local/compare.hpp% cppad/local/near_equal_ext.hpp% cppad/local/bool_fun.hpp% cppad/local/par_var.hpp% cppad/local/equal_op_seq.hpp %$$ $table $rref Compare$$ $rref NearEqualExt$$ $rref BoolFun$$ $rref ParVar$$ $rref EqualOpSeq$$ $tend $end */ # include # include # include # include # include # endif cppad-20160000.1/cppad/local/ad_binary.hpp0000644000175200017650000000663012656321767017265 0ustar coincoin-web// $Id: ad_binary.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_AD_BINARY_HPP # define CPPAD_AD_BINARY_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin ad_binary$$ $spell Op VecAD const $$ $section AD Binary Arithmetic Operators$$ $mindex + add plus - subtract minus * multiply times / divide$$ $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/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/add.cpp% example/sub.cpp% example/mul.cpp% example/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 cppad-20160000.1/cppad/local/acosh.hpp0000644000175200017650000000452412656321767016432 0ustar coincoin-web// $Id$ # ifndef CPPAD_ACOSH_HPP # define CPPAD_ACOSH_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin acosh$$ $spell acosh const Vec std cmath CppAD $$ $section The Inverse Hyperbolic Cosine Function: acosh$$ $head Syntax$$ $icode%y% = acosh(%x%)%$$ $head Description$$ The inverse hyperbolic cosine function is defined by $icode%x% == cosh(%y%)%$$. $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head CPPAD_USE_CPLUSPLUS_2011$$ $subhead true$$ If this preprocessor symbol is true ($code 1$$), and $icode x$$ is an AD type, this is an $cref/atomic operation/glossary/Operation/Atomic/$$. $subhead false$$ If this preprocessor symbol is false ($code 0$$), CppAD uses the representation $latex \[ \R{acosh} (x) = \log \left( x + \sqrt{ x^2 - 1 } \right) \] $$ to compute this function. $head Example$$ $children% example/acosh.cpp %$$ The file $cref acosh.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- */ # include # if ! CPPAD_USE_CPLUSPLUS_2011 // BEGIN CppAD namespace namespace CppAD { template Type acosh_template(const Type &x) { return CppAD::log( x + CppAD::sqrt( x * x - Type(1) ) ); } inline float acosh(const float &x) { return acosh_template(x); } inline double acosh(const double &x) { return acosh_template(x); } template inline AD acosh(const AD &x) { return acosh_template(x); } template inline AD acosh(const VecAD_reference &x) { return acosh_template( x.ADBase() ); } } // END CppAD namespace # endif // CPPAD_USE_CPLUSPLUS_2011 # endif // CPPAD_ACOSH_INCLUDED cppad-20160000.1/cppad/local/tanh_op.hpp0000644000175200017650000001340212656321767016760 0ustar coincoin-web// $Id: tanh_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_TANH_OP_HPP # define CPPAD_TANH_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary2_op */ template inline 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(j); z[j] = x[j]; for(k = 1; k <= j; k++) z[j] -= Base(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 forward_unary2_op_dir */ template inline 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(q) * ( x[m+ell] - x[m+ell] * y[0] ); for(k = 1; k < q; k++) z[m+ell] -= Base(k) * x[(k-1)*r+1+ell] * y[(q-k-1)*r+1+ell]; z[m+ell] /= Base(q); // y[m+ell] = Base(2) * 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 forward_unary2_op_0 */ template inline 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 reverse_unary2_op */ template inline 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(j); for(k = 1; k <= j; k++) { px[k] -= azmul(pz[j], y[j-k]) * Base(k); py[j-k] -= azmul(pz[j], x[k]) * Base(k); } for(k = 0; k < j; k++) pz[k] += azmul(py[j-1], z[j-k-1]) * base_two; --j; } px[0] += azmul(pz[0], Base(1) - y[0]); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/print_op.hpp0000644000175200017650000000731712656321767017172 0ustar coincoin-web// $Id: print_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_PRINT_OP_HPP # define CPPAD_PRINT_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! 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< \a Base > and computations by this routine are done using type \a Base . \param s_out the results are printed on this output stream. \param arg \a arg[0] & 1 \n If this is zero, \a pos is a parameter. Otherwise it is a variable. \n \a arg[0] & 2 \n If this is zero, \a var is a parameter. Otherwise it is a variable. \n \n \a arg[1] \n If \a pos is a parameter, parameter[arg[1]] is its value. Othwise taylor[ arg[1] * cap_order + 0 ] is the zero order Taylor coefficient for \a pos. \n \n \a arg[2] \n index of the text to be printed before \a var if \a pos is not a positive value. \n \n \a arg[3] \n If \a var is a parameter, parameter[arg[3]] is its value. Othwise taylor[ arg[3] * cap_order + 0 ] is the zero order Taylor coefficient for \a var. \n \n \a arg[4] \n index of the text to be printed after \a var if \a 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 \a 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 \a pos is a parameter, arg[1] < num_par \li if \a var is a parameter, arg[3] < num_par */ template inline 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[ 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[ 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_NAMESPACE # endif cppad-20160000.1/cppad/local/ad_tape.hpp0000644000175200017650000001507112656321767016731 0ustar coincoin-web// $Id: ad_tape.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_AD_TAPE_HPP # define CPPAD_AD_TAPE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include namespace CppAD { // BEGIN_CPPAD_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 discrete; friend class VecAD; friend class VecAD_reference; // functions ----------------------------------------------------------- // PrintFor friend void PrintFor ( const AD& flag , const char* before , const AD& var , const char* after ); // CondExpOp friend AD CondExpOp ( enum CompareOp cop , const AD &left , const AD &right , const AD &trueCase , const AD &falseCase ); // pow friend AD pow (const AD &x, const AD &y); // azmul friend AD azmul (const AD &x, const AD &y); // Parameter friend bool Parameter (const AD &u); // Variable friend bool Variable (const AD &u); // operators ----------------------------------------------------------- // 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); // ====================================================================== // -------------------------------------------------------------------------- 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. recorder Rec_; // ---------------------------------------------------------------------- // private functions // // add a parameter to the tape size_t RecordParOp(const Base &x); // 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& data ); public: // default constructor and destructor // public function only used by CppAD::Independent template void Independent(VectorADBase &u); template void Independent(VectorADBase &u, size_t abort_op_index); }; // --------------------------------------------------------------------------- // Private functions // /*! Place a parameter in the tape. On rare occations it is necessary to place a parameter in the tape; e.g., when it is one of the dependent variabes. \param z value of the parameter that we are placing in the tape. \return variable index (for this recording) correpsonding to the parameter. \par 2DO All these operates are preformed in \c Rec_, so we should move this routine from ADTape to recorder. */ template size_t ADTape::RecordParOp(const Base &z) { size_t z_taddr; size_t ind; CPPAD_ASSERT_UNKNOWN( NumRes(ParOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(ParOp) == 1 ); z_taddr = Rec_.PutOp(ParOp); ind = Rec_.PutPar(z); 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 \c length indices following for this vector. The values for these vector indices are the corresponding parameter indices in the tape for the initial value of the corresponding vec_ad element. \par 2DO All these operates are preformed in \c Rec_, so we should move this routine from ADTape to recorder. */ template size_t ADTape::AddVec(size_t length, const pod_vector& data) { CPPAD_ASSERT_UNKNOWN( length > 0 ); size_t i; size_t value_index; // store the length in VecInd size_t start = Rec_.PutVecInd(length); // store indices of the values in VecInd for(i = 0; i < length; i++) { value_index = Rec_.PutPar( data[i] ); Rec_.PutVecInd( value_index ); } // return the taddr of the length (where the vector starts) return start; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/sparse_list.hpp0000644000175200017650000003716112656321767017670 0ustar coincoin-web// $Id: sparse_list.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_LIST_HPP # define CPPAD_SPARSE_LIST_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file sparse_list.hpp Vector of sets of positive integers stored as singly linked lists. */ /*! Vector of sets of positive integers, each set stored as a singly linked list. */ class sparse_list { public: /// type used for each set in the vector of sets /// (note that next is index in data_ for next element in this set). struct pair_size_t { size_t value; size_t next; }; private: // ----------------------------------------------------------------- /// Number of sets that we are representing /// (set by constructor and resize). size_t n_set_; /// Possible elements in each set are 0, 1, ..., end_ - 1; size_t end_; /// The data for all the elements in all the sets CppAD::pod_vector data_; /// next element pair_size_t next_pair_; /// number of elements in data_ that are no longer being used. size_t data_not_used_; /// temporary data vector used for garbage collection CppAD::pod_vector data_tmp_; // ----------------------------------------------------------------- /*! Private member function that counts number of elements in a set. \param index is the index of the set we are counting. \par Checked Assertions \li index < n_set_ */ size_t number_elements(size_t index) const { CPPAD_ASSERT_UNKNOWN(index < n_set_ ); size_t count = 0; size_t i = index; size_t value = data_[i].value; while( value < end_ ) { count++; i = data_[i].next; value = data_[i].value; } return count; } // ----------------------------------------------------------------- /// Private member functions that does garbage collection. void collect_garbage(void) { CPPAD_ASSERT_UNKNOWN( 2 * data_not_used_ > data_.size() ); // CPPAD_ASSERT_UNKNOWN( number_elements() + n_set_ + data_not_used_ == data_.size() ); // copy the sets to a temporary data vector data_tmp_.erase(); data_tmp_.extend(n_set_); for(size_t i = 0; i < n_set_; i++) { size_t next = i; size_t next_tmp = i; // size_t value = data_[next].value; while( value < end_ ) { data_tmp_[next_tmp].value = value; // data_tmp_[next_tmp].next = data_tmp_.extend(1); // does not seem to work ? size_t index_tmp = data_tmp_.extend(1); data_tmp_[next_tmp].next = index_tmp; // next = data_[next].next; next_tmp = data_tmp_[next_tmp].next; // value = data_[next].value; } data_tmp_[next_tmp].value = end_; } CPPAD_ASSERT_UNKNOWN( data_tmp_.size() + data_not_used_ == data_.size() ); // swap the tmp and old data vectors data_.swap(data_tmp_); // all of the elements are used in this new version of data_ data_not_used_ = 0; } public: // ----------------------------------------------------------------- /*! Default constructor (no sets) */ sparse_list(void) : n_set_(0) , end_(0) , data_not_used_(0) { next_pair_.value = end_; } // ----------------------------------------------------------------- /*! Using copy constructor is a programing (not user) error \param v vector that we are attempting to make a copy of. */ sparse_list(const sparse_list& v) { // Error: // Probably a sparse_list argument has been passed by value CPPAD_ASSERT_UNKNOWN(false); } // ----------------------------------------------------------------- /*! Destructor */ ~sparse_list(void) { } // ----------------------------------------------------------------- /*! Change number of sets, end marker, and initialize all sets as empty If \c n_set_in is zero, any memory currently allocated for this object is freed. Otherwise, new memory may be allocated for the sets (if needed). \param n_set_in is the number of sets in this vector of sets. \param end_in is the maximum element plus one (the minimum element is 0). */ void resize(size_t n_set_in, size_t end_in) { n_set_ = n_set_in; end_ = end_in; next_pair_.value = end_in; data_not_used_ = 0; if( n_set_in == 0 ) { // free all memory connected with this object data_.free(); return; } // now start a new vector with empty sets data_.erase(); data_.extend(n_set_); for(size_t i = 0; i < n_set_; i++) data_[i].value = end_; } // ----------------------------------------------------------------- /*! Add one element to a set. \param index is the index for this set in the vector of sets. \param element is the element we are adding to the set. \par Checked Assertions \li index < n_set_ \li element < end_ */ void add_element(size_t index, size_t element) { CPPAD_ASSERT_UNKNOWN( index < n_set_ ); CPPAD_ASSERT_UNKNOWN( element < end_ ); size_t value = data_[index].value; // case of inserting at beginning if( element < value ) { size_t insert = data_.extend(1); data_[insert] = data_[index]; data_[index].value = element; data_[index].next = insert; return; } // search list for place to insert size_t previous = index; size_t current = data_[previous].next; value = data_[current].value; while( value < element ) { previous = current; current = data_[previous].next; value = data_[current].value; } if( element != value ) { CPPAD_ASSERT_UNKNOWN( element < value ); size_t insert = data_.extend(1); // data_[insert].next = data_[previous].next; data_[previous].next = insert; data_[insert].value = element; } } // ----------------------------------------------------------------- /*! Is an element in a set. \param index is the index for this set in the vector of sets. \param element is the element we are checking to see if it is in set. \par Checked Assertions \li index < n_set_ \li element < end_ */ bool is_element(size_t index, size_t element) { CPPAD_ASSERT_UNKNOWN( index < n_set_ ); CPPAD_ASSERT_UNKNOWN( element < end_ ); size_t i = index; size_t value = data_[i].value; while( value < element ) { i = data_[i].next; value = data_[i].value; } return element == value; } // ----------------------------------------------------------------- /*! Begin retrieving elements from one of the sets. \param index is the index for the set that is going to be retrieved. The elements of the set are retrieved in increasing order. \par Checked Assertions \li index < n_set_ */ void begin(size_t index) { // initialize element to search for in this set CPPAD_ASSERT_UNKNOWN( index < n_set_ ); next_pair_ = data_[index]; return; } // ----------------------------------------------------------------- /*! Get the next element from the current retrieval set. \return is the next element in the set with index specified by the previous call to \c begin. If no such element exists, \c this->end() is returned. \par Assumption There is no call to \c add_element or \c binary_union since the previvious \c begin */ size_t next_element(void) { size_t element = next_pair_.value; if( element != end_ ) next_pair_ = data_[next_pair_.next]; return 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 elements lost. \par Checked Assertions \li target < n_set_ */ void clear(size_t target) { CPPAD_ASSERT_UNKNOWN( target < n_set_ ); // number of elements that will be deleted by this operation size_t number_delete = number_elements(target); // delete the elements from the set data_[target].value = end_; // adjust data_not_used_ data_not_used_ += number_delete; if( 2 * data_not_used_ > data_.size() ) collect_garbage(); } // ----------------------------------------------------------------- /*! Assign one set equal to another set. \param this_target is the index (in this \c sparse_list object) of the set being assinged. \param other_source is the index (in the other \c sparse_list object) of the that we are using as the value to assign to the target set. \param other is the other \c sparse_list object (which may be the same as this \c sparse_list object). \par data_not_used_ increments this value by number of elements lost. \par Checked Assertions \li this_target < n_set_ \li other_index < other.n_set_ */ void assignment( size_t this_target , size_t other_source , const sparse_list& other ) { CPPAD_ASSERT_UNKNOWN( this_target < n_set_ ); CPPAD_ASSERT_UNKNOWN( other_source < other.n_set_ ); CPPAD_ASSERT_UNKNOWN( end_ == other.end() ); // check if we are assigning a set to itself if( (this == &other) & (this_target == other_source) ) return; // number of elements that will be deleted by this operation size_t number_delete = number_elements(this_target); size_t this_index = this_target; size_t other_index = other_source; size_t value = other.data_[other_index].value; while( value != end_ ) { size_t next = data_.extend(1); data_[this_index].value = value; data_[this_index].next = next; this_index = next; other_index = other.data_[other_index].next; value = other.data_[other_index].value; } data_[this_index].value = end_; // adjust data_not_used_ data_not_used_ += number_delete; if( 2 * data_not_used_ > data_.size() ) collect_garbage(); } // ----------------------------------------------------------------- /*! Assign a set equal to the union of two other sets. \param this_target is the index (in this \c sparse_list object) of the set being assinged. \param this_left is the index (in this \c sparse_list object) of the left operand for the union operation. It is OK for \a this_target and \a this_left to be the same value. \param other_right is the index (in the other \c sparse_list object) of the right operand for the union operation. It is OK for \a this_target and \a other_right to be the same value. \param other is the other \c sparse_list object (which may be the same as this \c sparse_list object). \par Checked Assertions \li this_target < n_set_ \li this_left < n_set_ \li other_right < other.n_set_ */ void binary_union( size_t this_target , size_t this_left , size_t other_right , const sparse_list& other ) { CPPAD_ASSERT_UNKNOWN( this_target < n_set_ ); CPPAD_ASSERT_UNKNOWN( this_left < n_set_ ); CPPAD_ASSERT_UNKNOWN( other_right < other.n_set_ ); CPPAD_ASSERT_UNKNOWN( end_ == other.end() ); // determine if we will delete the original version of the target size_t number_delete = 0; bool delete_target = this_target == this_left; delete_target |= (this == &other) & (this_target == other_right); if( delete_target ) { // number of elements that will be deleted by this operation number_delete = number_elements(this_target); } // value and next for left and right sets size_t left_value = data_[this_left].value; size_t left_next = data_[this_left].next; size_t right_value = other.data_[other_right].value; size_t right_next = other.data_[other_right].next; // merge left and right sets to form new target set size_t current = this_target; while( (left_value < end_) | (right_value < end_) ) { if( left_value == right_value ) { right_value = other.data_[right_next].value; right_next = other.data_[right_next].next; } size_t next = data_.extend(1); data_[current].next = next; if( left_value < right_value ) { data_[current].value = left_value; left_value = data_[left_next].value; left_next = data_[left_next].next; } else { data_[current].value = right_value; right_value = other.data_[right_next].value; right_next = other.data_[right_next].next; } current = next; } data_[current].value = end_; // adjust data_not_used_ data_not_used_ += number_delete; if( 2 * data_not_used_ > data_.size() ) collect_garbage(); } // ----------------------------------------------------------------- /*! Sum over all sets of the number of elements /return The the total number of elements */ size_t number_elements(void) const { size_t i, count; count = 0; for(i = 0; i < n_set_; i++) count += number_elements(i); return count; } // ----------------------------------------------------------------- /*! Fetch n_set for vector of sets object. \return Number of from sets for this vector of sets object */ size_t n_set(void) const { return n_set_; } // ----------------------------------------------------------------- /*! Fetch end for this vector of sets object. \return is the maximum element value plus one (the minimum element value is 0). */ size_t end(void) const { return end_; } }; // Tell pod_vector class that each pair_size_t is plain old data and hence // the corresponding constructor need not be called. template <> inline bool is_pod(void) { return true; } /*! Copy a user vector of sets sparsity pattern to an internal sparse_list object. \tparam VectorSet is a simple vector with elements of type \c std::list. \param internal The input value of sparisty does not matter. Upon return it contains the same sparsity pattern as \c user (or the transposed sparsity pattern). \param user sparsity pattern that we are placing \c internal. \param n_row number of rows in the sparsity pattern in \c user (range dimension). \param n_col number of columns in the sparsity pattern in \c user (domain dimension). \param transpose if true, the sparsity pattern in \c internal is the transpose of the one in \c user. Otherwise it is the same sparsity pattern. */ template void sparsity_user2internal( sparse_list& internal , const VectorSet& user , size_t n_row , size_t n_col , bool transpose ) { CPPAD_ASSERT_KNOWN( size_t( user.size() ) == n_row, "Size of this vector of sets sparsity pattern is not equal\n" "the range dimension for the corresponding function." ); size_t i, j; std::set::const_iterator itr; // transposed pattern case if( transpose ) { internal.resize(n_col, n_row); for(i = 0; i < n_row; i++) { itr = user[i].begin(); while(itr != user[i].end()) { j = *itr++; CPPAD_ASSERT_KNOWN( j < n_col, "An element in this vector of sets sparsity pattern " "is greater than or equal\n" "the domain dimension for the corresponding function." ); internal.add_element(j, i); } } return; } // same pattern case internal.resize(n_row, n_col); for(i = 0; i < n_row; i++) { itr = user[i].begin(); while(itr != user[i].end()) { j = *itr++; CPPAD_ASSERT_UNKNOWN( j < n_col ); internal.add_element(i, j); } } return; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/parallel_ad.hpp0000644000175200017650000000710512656321767017573 0ustar coincoin-web// $Id: parallel_ad.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_PARALLEL_AD_HPP # define CPPAD_PARALLEL_AD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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(); NumArg(BeginOp); NumRes(BeginOp); one_element_std_set(); two_element_std_set(); // the sparse_pack class has member functions with static data sparse_pack sp; sp.resize(1, 1); // so can call add_element sp.add_element(0, 0); // has static data sp.begin(0); // so can call next_element sp.next_element(); // has static data sp.clear(0); // has static data sp.is_element(0, 0); // has static data // statics that depend on the value of Base AD::tape_id_handle(0); AD::tape_handle(0); AD::tape_manage(tape_manage_clear); discrete::List(); CheckSimpleVector< Base, CppAD::vector >(); CheckSimpleVector< AD, CppAD::vector< AD > >(); } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/sub.hpp0000644000175200017650000000527112656321767016126 0ustar coincoin-web// $Id: sub.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SUB_HPP # define CPPAD_SUB_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // BEGIN CppAD 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 ADTape* tape = AD::tape_ptr(); if( tape == CPPAD_NULL ) return result; tape_id_t tape_id = tape->id_; // tape_id cannot match the default value for tape_id_; i.e., 0 CPPAD_ASSERT_UNKNOWN( tape_id > 0 ); bool var_left = left.tape_id_ == tape_id; bool var_right = right.tape_id_ == tape_id; if( var_left ) { if( var_right ) { // result = variable - variable CPPAD_ASSERT_UNKNOWN( NumRes(SubvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(SubvvOp) == 2 ); // put operand addresses in tape tape->Rec_.PutArg(left.taddr_, right.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(SubvvOp); // make result a variable result.tape_id_ = tape_id; } else if( IdenticalZero(right.value_) ) { // result = variable - 0 result.make_variable(left.tape_id_, left.taddr_); } else { // result = variable - parameter CPPAD_ASSERT_UNKNOWN( NumRes(SubvpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(SubvpOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(right.value_); tape->Rec_.PutArg(left.taddr_, p); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(SubvpOp); // make result a variable result.tape_id_ = tape_id; } } else if( var_right ) { // result = parameter - variable CPPAD_ASSERT_UNKNOWN( NumRes(SubpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(SubpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(left.value_); tape->Rec_.PutArg(p, right.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(SubpvOp); // make result a variable result.tape_id_ = tape_id; } return result; } // convert other cases into the case above CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(-) } // END CppAD namespace # endif cppad-20160000.1/cppad/local/identical.hpp0000644000175200017650000000634712656321767017276 0ustar coincoin-web// $Id: identical.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_IDENTICAL_HPP # define CPPAD_IDENTICAL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include 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 \c 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 \c x is identically a parameter. */ template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool IdenticalPar(const AD &x) { return Parameter(x) && IdenticalPar(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 \c x is equals zero and is identically a parameter \ref IdenticalPar. */ template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool IdenticalZero(const AD &x) { return Parameter(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 \c x is equals one and is identically a parameter \ref IdenticalPar. */ template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool IdenticalOne(const AD &x) { return Parameter(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 IdenticalPar. */ template CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool IdenticalEqualPar (const AD &x, const AD &y) { bool parameter; parameter = ( Parameter(x) & Parameter(y) ); return parameter && IdenticalEqualPar(x.value_, y.value_); } // ========================================================================== } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/test_vector.hpp0000644000175200017650000001005712656321767017674 0ustar coincoin-web// $Id: test_vector.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_TEST_VECTOR_HPP # define CPPAD_TEST_VECTOR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin test_vector$$ $spell ifdef undef Microsofts CppADvector hpp std endif ublas Dir valarray stdvector $$ $section Choosing The Vector Testing Template Class$$ $mindex CPPAD_TEST_VECTOR test$$ $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$$: $codep */ // 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 $codep */ // 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/auto_tools/Configure/$$ command line, $code CPPAD_EIGENVECTOR$$ is true. This vector type cannot be supported by $code CPPAD_TEST_VECTOR$$ (use $cref/CPPAD_TESTVECTOR/testvector/$$ for this support) so $code CppAD::vector$$ is used in this case $codep */ // 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/auto_tools/Configure/$$ command line during CppAD installation, $code CPPAD_STDVECTOR$$ is true and $code CPPAD_TEST_VECTOR$$ is defined by the following source code $codep */ // 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 $codep */ // 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: $codep */ # define CppADvector CPPAD_TEST_VECTOR /* $$ $end ------------------------------------------------------------------------ */ # endif cppad-20160000.1/cppad/local/asinh.hpp0000644000175200017650000000452112656321767016434 0ustar coincoin-web// $Id$ # ifndef CPPAD_ASINH_HPP # define CPPAD_ASINH_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin asinh$$ $spell asinh const Vec std cmath CppAD $$ $section The Inverse Hyperbolic Sine Function: asinh$$ $head Syntax$$ $icode%y% = asinh(%x%)%$$ $head Description$$ The inverse hyperbolic sine function is defined by $icode%x% == sinh(%y%)%$$. $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head CPPAD_USE_CPLUSPLUS_2011$$ $subhead true$$ If this preprocessor symbol is true ($code 1$$), and $icode x$$ is an AD type, this is an $cref/atomic operation/glossary/Operation/Atomic/$$. $subhead false$$ If this preprocessor symbol is false ($code 0$$), CppAD uses the representation $latex \[ \R{asinh} (x) = \log \left( x + \sqrt{ 1 + x^2 } \right) \] $$ to compute this function. $head Example$$ $children% example/asinh.cpp %$$ The file $cref asinh.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- */ # include # if ! CPPAD_USE_CPLUSPLUS_2011 // BEGIN CppAD namespace namespace CppAD { template Type asinh_template(const Type &x) { return CppAD::log( x + CppAD::sqrt( Type(1) + x * x ) ); } inline float asinh(const float &x) { return asinh_template(x); } inline double asinh(const double &x) { return asinh_template(x); } template inline AD asinh(const AD &x) { return asinh_template(x); } template inline AD asinh(const VecAD_reference &x) { return asinh_template( x.ADBase() ); } } // END CppAD namespace # endif // CPPAD_USE_CPLUSPLUS_2011 # endif // CPPAD_ASINH_INCLUDED cppad-20160000.1/cppad/local/sparse.hpp0000644000175200017650000000201612656321767016624 0ustar coincoin-web// $Id: sparse.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_HPP # define CPPAD_SPARSE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Sparse$$ $spell $$ $section Calculating Sparsity Patterns$$ $childtable% cppad/local/for_sparse_jac.hpp% cppad/local/rev_sparse_jac.hpp% example/dependency.cpp% cppad/local/rev_sparse_hes.hpp% example/bool_sparsity.cpp %$$ $end */ # include # include # include # endif cppad-20160000.1/cppad/local/unary_plus.hpp0000644000175200017650000000403212656321767017530 0ustar coincoin-web// $Id: unary_plus.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_UNARY_PLUS_HPP # define CPPAD_UNARY_PLUS_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin UnaryPlus$$ $spell Vec const inline $$ $section AD Unary Plus Operator$$ $mindex +$$ $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/unary_plus.cpp %$$ The file $cref unary_plus.cpp$$ contains an example and test of this operation. $end ------------------------------------------------------------------------------- */ // BEGIN CppAD namespace namespace CppAD { template inline AD AD::operator + (void) const { AD result(*this); return result; } template inline AD operator + (const VecAD_reference &right) { return right.ADBase(); } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/fun_construct.hpp0000644000175200017650000003301012656321767020221 0ustar coincoin-web// $Id: fun_construct.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FUN_CONSTRUCT_HPP # define CPPAD_FUN_CONSTRUCT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin FunConstruct$$ $spell alloc num Jac bool taylor var ADvector const Jacobian $$ $spell $$ $section Construct an ADFun Object and Stop Recording$$ $mindex tape$$ $head Syntax$$ $codei%ADFun<%Base%> %f%, %g% %$$ $codei%ADFun<%Base%> %f%(%x%, %y%) %$$ $icode%g% = %f% %$$ $head Purpose$$ The $codei%AD<%Base%>%$$ object $icode f$$ can store an AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$. It can then be used to calculate derivatives of the corresponding $cref/AD function/glossary/AD Function/$$ $latex \[ F : B^n \rightarrow B^m \] $$ where $latex B$$ is the space corresponding to objects of type $icode Base$$. $head x$$ If the argument $icode x$$ is present, it has prototype $codei% const %VectorAD% &%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 %VectorAD% &%y% %$$ The sequence of operations that map $icode x$$ to $icode y$$ are stored in the ADFun object $icode f$$. $head VectorAD$$ The type $icode VectorAD$$ 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%> %f% %$$ creates an $codei%AD<%Base%>%$$ object with no corresponding operation sequence; i.e., $codei% %f%.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 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. It returns true if it succeeds and false otherwise. $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/fun_assign.cpp %$$ $subhead Assignment Operator$$ The file $cref fun_assign.cpp$$ contains an example and test of the $codei%ADFun<%Base%>%$$ assignment operator. It returns true if it succeeds and false otherwise. $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 \c AD. */ template ADFun::ADFun(void) : has_been_optimized_(false), check_for_nan_(true) , compare_change_count_(1), compare_change_number_(0), compare_change_op_index_(0), num_var_tape_(0) { } /*! ADFun assignment operator The C++ syntax for this operation is \verbatim g = f \endverbatim where \c g and \c f are ADFun ADFun objects. A copy of the the operation sequence currently stored in \c f is placed in this ADFun object (called \c 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 \c AD. \param f ADFun object containing the operation sequence to be copied. */ template void ADFun::operator=(const ADFun& f) { size_t m = f.Range(); size_t n = f.Domain(); size_t i; // go through member variables in ad_fun.hpp order // // size_t objects has_been_optimized_ = f.has_been_optimized_; check_for_nan_ = f.check_for_nan_; compare_change_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_; // // CppAD::vector objects ind_taddr_.resize(n); ind_taddr_ = f.ind_taddr_; dep_taddr_.resize(m); dep_taddr_ = f.dep_taddr_; dep_parameter_.resize(m); dep_parameter_ = f.dep_parameter_; // // pod_vector objects taylor_ = f.taylor_; cskip_op_ = f.cskip_op_; load_op_ = f.load_op_; // // player play_ = f.play_; // // sparse_pack for_jac_sparse_pack_.resize(0, 0); size_t n_set = f.for_jac_sparse_pack_.n_set(); size_t end = f.for_jac_sparse_pack_.end(); if( n_set > 0 ) { CPPAD_ASSERT_UNKNOWN( n_set == num_var_tape_ ); CPPAD_ASSERT_UNKNOWN( f.for_jac_sparse_set_.n_set() == 0 ); for_jac_sparse_pack_.resize(n_set, end); for(i = 0; i < num_var_tape_ ; i++) { for_jac_sparse_pack_.assignment( i , i , f.for_jac_sparse_pack_ ); } } // // sparse_set for_jac_sparse_set_.resize(0, 0); n_set = f.for_jac_sparse_set_.n_set(); end = f.for_jac_sparse_set_.end(); if( n_set > 0 ) { CPPAD_ASSERT_UNKNOWN( n_set == num_var_tape_ ); CPPAD_ASSERT_UNKNOWN( f.for_jac_sparse_pack_.n_set() == 0 ); for_jac_sparse_set_.resize(n_set, end); for(i = 0; i < num_var_tape_; i++) { for_jac_sparse_set_.assignment( i , i , f.for_jac_sparse_set_ ); } } } /*! 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 \c Independent(x), and that ends with this operation, is stored in this \c ADFun object \c f. \tparam Base is the base for the recording that will be stored in the object \c f; i.e., the operations were recorded using the type \c AD. \tparam VectorAD is a simple vector class with elements of typea \c AD. \param x is the independent variable vector for this ADFun object. The domain dimension of this object will be the size of \a x. \param y is the dependent variable vector for this ADFun object. The range dimension of this object will be the size of \a 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 \a y. Thus, the zero order Taylor coefficients corresponding to the value of the \a x vector are stored in this ADFun object. */ template template ADFun::ADFun(const VectorAD &x, const VectorAD &y) { 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." ); 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() ); forward0sweep(std::cout, false, n, num_var_tape_, &play_, cap_order_taylor_, taylor_.data(), cskip_op_.data(), load_op_, compare_change_count_, compare_change_number_, compare_change_op_index_ ); 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 cppad-20160000.1/cppad/local/atan2.hpp0000644000175200017650000000655212656321767016345 0ustar coincoin-web// $Id: atan2.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ATAN2_HPP # define CPPAD_ATAN2_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin atan2$$ $spell Vec CppAD namespace std atan const $$ $section AD Two Argument Inverse Tangent Function$$ $mindex tan atan2$$ $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/atan2.cpp %$$ The file $cref atan2.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $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 = abs(x); AD ay = abs(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 inline AD atan2 (const VecAD_reference &y, const AD &x) { return atan2( y.ADBase() , x ); } template inline AD atan2 (const AD &y, const VecAD_reference &x) { return atan2( y , x.ADBase() ); } template inline AD atan2 (const VecAD_reference &y, const VecAD_reference &x) { return atan2( y.ADBase() , x.ADBase() ); } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/near_equal_ext.hpp0000644000175200017650000001174212656321767020331 0ustar coincoin-web// $Id: near_equal_ext.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_NEAR_EQUAL_EXT_HPP # define CPPAD_NEAR_EQUAL_EXT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin NearEqualExt$$ $spell cout endl Microsoft std Cpp namespace const bool $$ $section Compare AD and Base Objects for Nearly Equal$$ $mindex NearEqual with$$ $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/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 cppad-20160000.1/cppad/local/recorder.hpp0000644000175200017650000004135112656321767017141 0ustar coincoin-web// $Id: recorder.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_RECORDER_HPP # define CPPAD_RECORDER_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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< \a Base > operation sequence recording; i.e., it records operations of type AD< \a Base >. */ template class recorder { friend class player; private: /// operator index at which to abort recording with an error /// (do not abort when zero) size_t abort_op_index_; /// offset for this thread in the static hash table const size_t thread_offset_; /// Number of variables in the recording. size_t num_var_rec_; /// Number vecad load operations (LdpOp or LdvOp) currently in recording. size_t num_load_op_rec_; /// The operators in the recording. pod_vector op_rec_; /// The VecAD indices in the recording. pod_vector vecad_ind_rec_; /// The argument indices in the recording pod_vector op_arg_rec_; /// The parameters in the recording. /// Note that Base may not be plain old data, so use false in consructor. pod_vector par_rec_; /// Character strings ('\\0' terminated) in the recording. pod_vector text_rec_; // ---------------------- Public Functions ----------------------------------- public: /// Default constructor recorder(void) : thread_offset_( thread_alloc::thread_num() * CPPAD_HASH_TABLE_SIZE ) , num_var_rec_(0) , num_load_op_rec_(0) , op_rec_( std::numeric_limits::max() ) , vecad_ind_rec_( std::numeric_limits::max() ) , op_arg_rec_( std::numeric_limits::max() ) , par_rec_( std::numeric_limits::max() ) , text_rec_( std::numeric_limits::max() ) { abort_op_index_ = 0; } /// Set the abort index void set_abort_op_index(size_t abort_op_index) { abort_op_index_ = abort_op_index; } /// Get the abort index size_t get_abort_op_index(void) { return abort_op_index_; } /// Destructor ~recorder(void) { } /*! Frees all information in recording. Frees the operation sequence store in this recording (the operation sequence is empty after this operation). The buffers used to store the current recording are returned to the system (so as to conserve on memory). */ void free(void) { num_var_rec_ = 0; num_load_op_rec_ = 0; op_rec_.free(); vecad_ind_rec_.free(); op_arg_rec_.free(); par_rec_.free(); text_rec_.free(); } /// Put next operator in the operation sequence. inline size_t PutOp(OpCode op); /// Put a vecad load operator in the operation sequence (special case) inline size_t PutLoadOp(OpCode op); /// Add a value to the end of the current vector of VecAD indices. inline size_t PutVecInd(size_t vec_ind); /// Find or add a parameter to the current vector of parameters. inline size_t PutPar(const Base &par); /// Put one operation argument index in the recording inline void PutArg(addr_t arg0); /// Put two operation argument index in the recording inline void PutArg(addr_t arg0, addr_t arg1); /// Put three operation argument index in the recording inline void PutArg(addr_t arg0, addr_t arg1, addr_t arg2); /// Put four operation argument index in the recording inline void PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3); /// Put five operation argument index in the recording inline void PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3, addr_t arg4); /// Put six operation argument index in the recording inline void PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3, addr_t arg4, addr_t arg5); // Reserve space for a specified number of arguments inline size_t ReserveArg(size_t n_arg); // Replace an argument value void ReplaceArg(size_t i_arg, size_t value); /// Put a character string in the text for this recording. inline size_t PutTxt(const char *text); /// 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_rec_.size(); } /// Approximate amount of memory used by the recording size_t Memory(void) const { return op_rec_.capacity() * sizeof(CPPAD_OP_CODE_TYPE) + vecad_ind_rec_.capacity() * sizeof(size_t) + op_arg_rec_.capacity() * sizeof(addr_t) + par_rec_.capacity() * sizeof(Base) + text_rec_.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 and after each call to Erase. */ template inline size_t recorder::PutOp(OpCode op) { size_t i = op_rec_.extend(1); CPPAD_ASSERT_KNOWN( (abort_op_index_ == 0) || (abort_op_index_ != i), "Operator index equals abort_op_index in Independent" ); op_rec_[i] = static_cast(op); CPPAD_ASSERT_UNKNOWN( op_rec_.size() == i + 1 ); CPPAD_ASSERT_UNKNOWN( (op != LdpOp) & (op != LdvOp) ); // first operator should be a BeginOp and NumRes( BeginOp ) > 0 num_var_rec_ += NumRes(op); CPPAD_ASSERT_UNKNOWN( num_var_rec_ > 0 ); return 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 and after each call to Erase. \par num_load_op_rec() The return value for num_load_op_rec() increases by one after each call to this function (and starts at zero after the default constructor or Erase). */ template inline size_t recorder::PutLoadOp(OpCode op) { size_t i = op_rec_.extend(1); CPPAD_ASSERT_KNOWN( (abort_op_index_ == 0) || (abort_op_index_ != i), "This is the abort operator index specified by " "Independent(x, abort_op_index)." ); op_rec_[i] = static_cast(op); CPPAD_ASSERT_UNKNOWN( op_rec_.size() == i + 1 ); CPPAD_ASSERT_UNKNOWN( (op == LdpOp) | (op == LdvOp) ); // 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_++; return 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 and after each call to Erase. It increments by one for each call to PutVecInd.. */ template inline size_t recorder::PutVecInd(size_t vec_ind) { size_t i = vecad_ind_rec_.extend(1); vecad_ind_rec_[i] = vec_ind; CPPAD_ASSERT_UNKNOWN( vecad_ind_rec_.size() == i + 1 ); return i; } /*! Find or add a parameter to the current vector of 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 size_t recorder::PutPar(const Base &par) { static size_t hash_table[CPPAD_HASH_TABLE_SIZE * CPPAD_MAX_NUM_THREADS]; size_t i; size_t code; CPPAD_ASSERT_UNKNOWN( thread_offset_ / CPPAD_HASH_TABLE_SIZE == thread_alloc::thread_num() ); // get hash code for this value code = static_cast( hash_code(par) ); CPPAD_ASSERT_UNKNOWN( code < CPPAD_HASH_TABLE_SIZE ); // If we have a match, return the parameter index i = hash_table[code + thread_offset_]; if( i < par_rec_.size() && IdenticalEqualPar(par_rec_[i], par) ) return i; // place a new value in the table i = par_rec_.extend(1); par_rec_[i] = par; CPPAD_ASSERT_UNKNOWN( par_rec_.size() == i + 1 ); // make the hash code point to this new value hash_table[code + thread_offset_] = i; // return the parameter index return i; } // -------------------------- 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. \a arg0 comes before \a 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 and each call to Erase. It increases by the number of indices placed by each call to PutArg. */ 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 inline void recorder::PutArg(addr_t arg0) { size_t i = op_arg_rec_.extend(1); op_arg_rec_[i] = static_cast( arg0 ); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.size() == i + 1 ); } /*! 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 inline void recorder::PutArg(addr_t arg0, addr_t arg1) { size_t i = op_arg_rec_.extend(2); op_arg_rec_[i++] = static_cast( arg0 ); op_arg_rec_[i] = static_cast( arg1 ); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.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 inline void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2) { size_t i = op_arg_rec_.extend(3); op_arg_rec_[i++] = static_cast( arg0 ); op_arg_rec_[i++] = static_cast( arg1 ); op_arg_rec_[i] = static_cast( arg2 ); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.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 inline void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3) { size_t i = op_arg_rec_.extend(4); op_arg_rec_[i++] = static_cast( arg0 ); op_arg_rec_[i++] = static_cast( arg1 ); op_arg_rec_[i++] = static_cast( arg2 ); op_arg_rec_[i] = static_cast( arg3 ); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.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 inline void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3, addr_t arg4) { size_t i = op_arg_rec_.extend(5); op_arg_rec_[i++] = static_cast( arg0 ); op_arg_rec_[i++] = static_cast( arg1 ); op_arg_rec_[i++] = static_cast( arg2 ); op_arg_rec_[i++] = static_cast( arg3 ); op_arg_rec_[i] = static_cast( arg4 ); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.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 inline void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3, addr_t arg4, addr_t arg5) { size_t i = op_arg_rec_.extend(6); op_arg_rec_[i++] = static_cast( arg0 ); op_arg_rec_[i++] = static_cast( arg1 ); op_arg_rec_[i++] = static_cast( arg2 ); op_arg_rec_[i++] = static_cast( arg3 ); op_arg_rec_[i++] = static_cast( arg4 ); op_arg_rec_[i] = static_cast( arg5 ); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.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 inline size_t recorder::ReserveArg(size_t n_arg) { size_t i = op_arg_rec_.extend(n_arg); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.size() == i + n_arg ); return i; } /*! \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 inline void recorder::ReplaceArg(size_t i_arg, size_t value) { op_arg_rec_[i_arg] = static_cast( 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 inline size_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_rec_.extend(n); size_t j; for(j = 0; j < n; j++) text_rec_[i + j] = text[j]; CPPAD_ASSERT_UNKNOWN( text_rec_.size() == i + n ); return i; } // ------------------------------------------------------------------------- } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/integer.hpp0000644000175200017650000000540512656321767016771 0ustar coincoin-web// $Id: integer.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_INTEGER_HPP # define CPPAD_INTEGER_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------ $begin 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/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 cppad-20160000.1/cppad/local/expm1.hpp0000644000175200017650000000447112656321767016370 0ustar coincoin-web// $Id$ # ifndef CPPAD_EXPM1_HPP # define CPPAD_EXPM1_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin expm1$$ $spell exp expm1 const Vec std cmath CppAD $$ $section The Exponential Function Minus One: expm1$$ $head Syntax$$ $icode%y% = expm1(%x%)%$$ $head Description$$ Returns the value of the exponential function minus one which is defined by $icode%y% == exp(%x%) - 1%$$. $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head CPPAD_USE_CPLUSPLUS_2011$$ $subhead true$$ If this preprocessor symbol is true ($code 1$$), and $icode x$$ is an AD type, this is an $cref/atomic operation/glossary/Operation/Atomic/$$. $subhead false$$ If this preprocessor symbol is false ($code 0$$), CppAD uses the representation $latex \[ \R{expm1} (x) = \exp(x) - 1 \] $$ to compute this function. $head Example$$ $children% example/expm1.cpp %$$ The file $cref expm1.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- */ # include # if ! CPPAD_USE_CPLUSPLUS_2011 // BEGIN CppAD namespace namespace CppAD { template Type expm1_template(const Type &x) { return CppAD::exp(x) - Type(1); } inline float expm1(const float &x) { return expm1_template(x); } inline double expm1(const double &x) { return expm1_template(x); } template inline AD expm1(const AD &x) { return expm1_template(x); } template inline AD expm1(const VecAD_reference &x) { return expm1_template( x.ADBase() ); } } // END CppAD namespace # endif // CPPAD_USE_CPLUSPLUS_2011 # endif // CPPAD_EXPM1_INCLUDED cppad-20160000.1/cppad/local/div_eq.hpp0000644000175200017650000000513012656321767016576 0ustar coincoin-web// $Id: div_eq.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DIV_EQ_HPP # define CPPAD_DIV_EQ_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // BEGIN CppAD 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 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 ); bool var_left = tape_id_ == tape_id; bool var_right = right.tape_id_ == tape_id; if( var_left ) { if( var_right ) { // this = variable / variable CPPAD_ASSERT_UNKNOWN( NumRes(DivvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(DivvvOp) == 2 ); // put operand addresses in tape tape->Rec_.PutArg(taddr_, right.taddr_); // put operator in the tape taddr_ = tape->Rec_.PutOp(DivvvOp); // make this a variable CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); } else if( IdenticalOne( right.value_ ) ) { // this = variable * 1 } else { // this = variable / parameter CPPAD_ASSERT_UNKNOWN( NumRes(DivvpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(DivvpOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(right.value_); tape->Rec_.PutArg(taddr_, p); // put operator in the tape taddr_ = tape->Rec_.PutOp(DivvpOp); // make this a variable CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); } } else if( var_right ) { if( IdenticalZero(left) ) { // this = 0 / variable } else { // this = parameter / variable CPPAD_ASSERT_UNKNOWN( NumRes(DivpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(DivpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(left); tape->Rec_.PutArg(p, right.taddr_); // put operator in the tape taddr_ = tape->Rec_.PutOp(DivpvOp); // make this a variable tape_id_ = tape_id; } } return *this; } CPPAD_FOLD_ASSIGNMENT_OPERATOR(/=) } // END CppAD namespace # endif cppad-20160000.1/cppad/local/rev_one.hpp0000644000175200017650000000776212656321767017001 0ustar coincoin-web// $Id: rev_one.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_REV_ONE_HPP # define CPPAD_REV_ONE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin RevOne$$ $spell dw Taylor const $$ $section First Order Derivative: Driver Routine$$ $mindex derivative easy$$ $head Syntax$$ $icode%dw% = %f%.RevOne(%x%, %i%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The syntax above sets $icode 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/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); // dimension the return value Vector dw(n); // compute the return value dw = Reverse(1, w); return dw; } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/undef.hpp0000644000175200017650000000757412656321767016446 0ustar coincoin-web// $Id: undef.hpp 3768 2015-12-28 18:58:35Z bradbell $ # ifndef CPPAD_UNDEF_HPP # define CPPAD_UNDEF_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- 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 needed by cppad_ipopt # undef CPPAD_ASSERT_UNKNOWN needed 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_BOOL_BINARY in user api # undef CPPAD_BOOL_UNARY in user api # undef CPPAD_DISCRETE_FUNCTION in user api # undef CPPAD_EIGENVECTOR in user api # undef CPPAD_INTERNAL_SPARSE_SET in user api # undef CPPAD_MAX_NUM_THREADS in user api # undef CPPAD_NUMERIC_LIMITS in user api # undef CPPAD_NULL in user api # undef CPPAD_PACKAGE_STRING in user api # undef CPPAD_STANDARD_MATH_UNARY in user api # undef CPPAD_TAPE_ADDR_TYPE in user api # undef CPPAD_TAPE_ID_TYPE in user api # undef CPPAD_TESTVECTOR in user api # undef CPPAD_TO_STRING in user api # undef CPPAD_USE_CPLUSPLUS_2011 in user api # undef CPPAD_TRACK_COUNT in deprecated api # undef CPPAD_TRACK_DEL_VEC in deprecated api # 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_ASSERT_ARG_BEFORE_RESULT # undef CPPAD_AZMUL # undef CPPAD_BOOSTVECTOR # 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_FOR_JAC_SWEEP_TRACE # undef CPPAD_HAS_COLPACK # undef CPPAD_HAS_GETTIMEOFDAY # undef CPPAD_HAS_MKSTEMP # undef CPPAD_HAS_TMPNAM_S # undef CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION # undef CPPAD_LIB_EXPORT # undef CPPAD_MAX_NUM_CAPACITY # undef CPPAD_MIN_DOUBLE_CAPACITY # undef CPPAD_OP_CODE_TYPE # undef CPPAD_REVERSE_SWEEP_TRACE # undef CPPAD_REV_HES_SWEEP_TRACE # undef CPPAD_REV_JAC_SWEEP_TRACE # undef CPPAD_SIZE_T_NOT_UNSIGNED_INT # 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 # endif cppad-20160000.1/cppad/local/bender_quad.hpp0000644000175200017650000002306212656321767017604 0ustar coincoin-web// $Id: bender_quad.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_BENDER_QUAD_HPP # define CPPAD_BENDER_QUAD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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$$ $mindex BenderQuad$$ $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/bender_quad.cpp %$$ The file $cref bender_quad.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. $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); // 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); dg = Gtilde.Forward(1, dx); gx[j] = dg[0]; // restore the dx vector to zero dx[j] = Base(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 cppad-20160000.1/cppad/local/sign_op.hpp0000644000175200017650000000736112656321767016775 0ustar coincoin-web// $Id: sign_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SIGN_OP_HPP # define CPPAD_SIGN_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary1_op */ template inline 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 forward_unary1_op_dir */ template inline 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 forward_unary1_op_0 */ template inline 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 reverse_unary1_op */ template inline 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_NAMESPACE # endif cppad-20160000.1/cppad/local/cskip_op.hpp0000644000175200017650000001234412656321767017143 0ustar coincoin-web// $Id: cskip_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_CSKIP_OP_HPP # define CPPAD_CSKIP_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 \a arg[0] is static cast to size_t from the enum type \verbatim enum CompareOp { CompareLt, CompareLe, CompareEq, CompareGe, CompareGt, CompareNe } \endverbatim for this operation. Note that arg[0] cannot be equal to CompareNe. \n \n \a arg[1] & 1 \n If this is zero, left is an AD parameter. Otherwise it is an AD variable. \n \n \a arg[1] & 2 \n If this is zero, right is an AD parameter. Otherwise it is an AD variable. \n \a arg[2] is the index corresponding to left in comparision. \n \a arg[3] is the index corresponding to right in comparision. \n \a arg[4] is the number of operations to skip if the comparision result is true. \n \a arg[5] is the number of operations to skip if the comparision result is false. \n arg[5+i] for i = 1 , ... , arg[4] are the operations to skip if the comparision result is true 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 [ arg[2] * cap_order + 0 ] is the zeroth order Taylor coefficient corresponding to left. If right is an AD variable, taylor [ arg[3] * cap_order + 0 ] is the zeroth order Taylor coefficient corresponding to right. \param cskip_op [in,out] 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 inline 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 varialbe arg[2] <= i_z, it has already been computed, // but it will be skipped for higher orders. left = taylor[ arg[2] * cap_order + 0 ]; } else { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); left = parameter[ arg[2] ]; } if( arg[1] & 2 ) { // If varialbe arg[3] <= i_z, it has already been computed, // but it will be skipped for higher orders. right = taylor[ arg[3] * cap_order + 0 ]; } else { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); right = parameter[ arg[3] ]; } bool ok_to_skip = IdenticalPar(left) & IdenticalPar(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(size_t i = 0; i < size_t(arg[4]); i++) cskip_op[ arg[6+i] ] = true; } else { for(size_t i = 0; i < size_t(arg[5]); i++) cskip_op[ arg[6+arg[4]+i] ] = true; } return; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/ad_io.hpp0000644000175200017650000001256512656321767016414 0ustar coincoin-web// $Id: ad_io.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_AD_IO_HPP # define CPPAD_AD_IO_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ad_input$$ $spell VecAD std istream const $$ $section AD Output Stream Operator$$ $mindex >> input write$$ $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/ad_input.cpp %$$ The file $cref ad_input.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------ $begin ad_output$$ $spell VecAD std ostream const $$ $section AD Output Stream Operator$$ $mindex <<$$ $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/ad_output.cpp %$$ The file $cref ad_output.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. $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 cppad-20160000.1/cppad/local/rev_hes_sweep.hpp0000644000175200017650000006632012656321767020175 0ustar coincoin-web// $Id: rev_hes_sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_REV_HES_SWEEP_HPP # define CPPAD_REV_HES_SWEEP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file rev_hes_sweep.hpp Compute Reverse mode Hessian sparsity patterns. */ /*! \def CPPAD_REV_HES_SWEEP_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_SWEEP_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 base type for the operator; i.e., this operation sequence was recorded using AD< \a Base > and computations by this routine are done using type \a Base. \tparam Vector_set is the type used for vectors of sets. It can be either \c sparse_pack, \c sparse_set, or \c sparse_list. \param n is the number of independent variables on the tape. \param numvar is the total number of variables on the tape; i.e., \a play->num_var_rec(). This is also the number of rows in the entire sparsity pattern \a rev_hes_sparse. \param play The information stored in \a 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. The object \a play is effectly constant. It is not declared const because while playing back the tape the object \a play holds information about the currentl location with in the tape and this changes during playback. \param for_jac_sparse For i = 0 , ... , \a numvar - 1, (for all the variables on the tape), the forward Jacobian sparsity pattern for the variable with index i corresponds to the set with index i in \a for_jac_sparse. \param RevJac \b Input: For i = 0, ... , \a numvar - 1 the if the variable with index i on the tape is an dependent variable and included in the Hessian, \a RevJac[ i ] is equal to true, otherwise it is equal to false. \n \n \b Output: The values in \a 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 \a rev_hes_sparse. \n \n \b Input: For i = 0 , ... , \a numvar - 1 the reverse Hessian sparsity pattern for the variable with index i is empty. \n \n \b Output: For j = 1 , ... , \a n, the reverse Hessian sparsity pattern for the independent dependent variable with index (j-1) is given by the set with index j in \a rev_hes_sparse. The values in the rest of \a rev_hes_sparse are not specified; i.e., they are used for temporary work space. */ template void RevHesSweep( size_t n, size_t numvar, player *play, Vector_set& for_jac_sparse, // should be const bool* RevJac, Vector_set& rev_hes_sparse ) { OpCode op; size_t i_op; size_t i_var; const addr_t* arg = CPPAD_NULL; // 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; vecad_sparse.resize(num_vecad_vec, limit); pod_vector vecad_ind; pod_vector vecad_jac; if( num_vecad_vec > 0 ) { size_t length; 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 UserOp. vector user_ix; // variable indices for argument vector x typedef std::set size_set; size_set::iterator set_itr; // iterator for a standard set size_set::iterator set_end; // end of iterator sequence vector< size_set > set_r; // forward Jacobian sparsity for x vector< size_set > set_u; // reverse Hessian sparsity for y vector< size_set > set_v; // reverse Hessian sparsity for x // vector bool_r; // bool forward Jacobian sparsity for x vector bool_u; // bool reverse Hessian sparsity for y vector bool_v; // bool reverse Hessian sparsity for x // vectorBool pack_r; // pack forward Jacobian sparsity for x vectorBool pack_u; // pack reverse Hessian sparsity for y vectorBool pack_v; // pack reverse Hessian sparsity for x // vector user_vx; // which components of x are variables vector user_s; // reverse Jacobian sparsity for y vector user_t; // reverse Jacobian sparsity for x const size_t user_q = limit; // maximum element plus one size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator size_t user_i = 0; // index in result vector size_t user_j = 0; // index in argument vector size_t user_m = 0; // size of result vector size_t user_n = 0; // size of arugment vector // atomic_base* user_atom = CPPAD_NULL; // user's atomic op calculator bool user_pack = false; // sparsity pattern type is pack bool user_bool = false; // sparsity pattern type is bool bool user_set = false; // sparsity pattern type is set # ifndef NDEBUG bool user_ok = false; // atomic op return value # endif // next expected operator in a UserOp sequence enum { user_start, user_arg, user_ret, user_end } user_state = user_end; // Initialize play->reverse_start(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( op == EndOp ); # if CPPAD_REV_HES_SWEEP_TRACE std::cout << std::endl; CppAD::vectorBool zf_value(limit); CppAD::vectorBool zh_value(limit); # endif bool more_operators = true; while(more_operators) { // next op play->reverse_next(op, arg, i_op, i_var); # ifndef NDEBUG if( i_op <= n ) { CPPAD_ASSERT_UNKNOWN((op == InvOp) | (op == BeginOp)); } else CPPAD_ASSERT_UNKNOWN((op != InvOp) & (op != BeginOp)); # endif // 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, 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, 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, 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, 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, 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, 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, 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, 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: // CSkipOp has a variable number of arguments and // reverse_next thinks it one has one argument. // We must inform reverse_next of this special case. play->reverse_cskip(op, arg, i_op, i_var); break; // ------------------------------------------------- case CSumOp: // CSumOp has a variable number of arguments and // reverse_next thinks it one has one argument. // We must inform reverse_next of this special case. play->reverse_csum(op, arg, i_op, i_var); 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, 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, 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, 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, arg[0], RevJac, for_jac_sparse, rev_hes_sparse ); 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_hessian_nonlinear_unary_op( i_var, 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, 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, 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 EqpvOp: case EqvvOp: case LtpvOp: case LtvpOp: case LtvvOp: case LepvOp: case LevpOp: case LevvOp: case NepvOp: case NevvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 0); break; // ------------------------------------------------- case LogOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1) reverse_sparse_hessian_nonlinear_unary_op( i_var, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, arg[0], RevJac, for_jac_sparse, rev_hes_sparse ); break; // ------------------------------------------------- case UserOp: // start or end an atomic operation sequence CPPAD_ASSERT_UNKNOWN( NumRes( UserOp ) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg( UserOp ) == 4 ); if( user_state == user_end ) { user_index = arg[0]; user_id = arg[1]; user_n = arg[2]; user_m = arg[3]; user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif user_pack = user_atom->sparsity() == atomic_base::pack_sparsity_enum; user_bool = user_atom->sparsity() == atomic_base::bool_sparsity_enum; user_set = user_atom->sparsity() == atomic_base::set_sparsity_enum; CPPAD_ASSERT_UNKNOWN( user_pack || user_bool || user_set ); user_ix.resize(user_n); user_vx.resize(user_n); user_s.resize(user_m); user_t.resize(user_n); // simpler to initialize all sparsity patterns as empty for(i = 0; i < user_m; i++) user_s[i] = false; for(i = 0; i < user_n; i++) user_t[i] = false; if( user_pack ) { pack_r.resize(user_n * user_q); pack_u.resize(user_m * user_q); pack_v.resize(user_n * user_q); // simpler to initialize all patterns as empty for(i = 0; i < user_m; i++) { for(j = 0; j < user_q; j++) pack_u[ i * user_q + j] = false; } for(i = 0; i < user_n; i++) { for(j = 0; j < user_q; j++) { pack_r[ i * user_q + j] = false; pack_v[ i * user_q + j] = false; } } } if( user_bool ) { bool_r.resize(user_n * user_q); bool_u.resize(user_m * user_q); bool_v.resize(user_n * user_q); // simpler to initialize all patterns as empty for(i = 0; i < user_m; i++) { for(j = 0; j < user_q; j++) bool_u[ i * user_q + j] = false; } for(i = 0; i < user_n; i++) { for(j = 0; j < user_q; j++) { bool_r[ i * user_q + j] = false; bool_v[ i * user_q + j] = false; } } } if( user_set ) { set_r.resize(user_n); set_u.resize(user_m); set_v.resize(user_n); for(i = 0; i < user_m; i++) set_u[i].clear(); for(i = 0; i < user_n; i++) { set_r[i].clear(); set_v[i].clear(); } } user_j = user_n; user_i = user_m; user_state = user_ret; } else { CPPAD_ASSERT_UNKNOWN( user_state == user_start ); CPPAD_ASSERT_UNKNOWN( user_index == size_t(arg[0]) ); CPPAD_ASSERT_UNKNOWN( user_id == size_t(arg[1]) ); CPPAD_ASSERT_UNKNOWN( user_n == size_t(arg[2]) ); CPPAD_ASSERT_UNKNOWN( user_m == size_t(arg[3]) ); user_state = user_end; // call users function for this operation user_atom->set_id(user_id); # ifdef NDEBUG if( user_pack ) user_atom->rev_sparse_hes(user_vx, user_s, user_t, user_q, pack_r, pack_u, pack_v ); if( user_bool ) user_atom->rev_sparse_hes(user_vx, user_s, user_t, user_q, bool_r, bool_u, bool_v ); if( user_set ) user_atom->rev_sparse_hes(user_vx, user_s, user_t, user_q, set_r, set_u, set_v ); # else if( user_pack ) user_ok = user_atom->rev_sparse_hes(user_vx, user_s, user_t, user_q, pack_r, pack_u, pack_v ); if( user_bool ) user_ok = user_atom->rev_sparse_hes(user_vx, user_s, user_t, user_q, bool_r, bool_u, bool_v ); if( user_set ) user_ok = user_atom->rev_sparse_hes(user_vx, user_s, user_t, user_q, set_r, set_u, set_v ); if( ! user_ok ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base.rev_sparse_hes: returned false\n"; if( user_pack ) msg += "sparsity = pack_sparsity_enum"; if( user_bool ) msg += "sparsity = bool_sparsity_enum"; if( user_set ) msg += "sparsity = set_sparsity_enum"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif for(i = 0; i < user_n; i++) if( user_ix[i] > 0 ) { size_t i_x = user_ix[i]; if( user_t[i] ) RevJac[i_x] = true; if( user_pack ) { for(j = 0; j < user_q; j++) if( pack_v[ i * user_q + j ] ) rev_hes_sparse.add_element(i_x, j); } if( user_bool ) { for(j = 0; j < user_q; j++) if( bool_v[ i * user_q + j ] ) rev_hes_sparse.add_element(i_x, j); } if( user_set ) { set_itr = set_v[i].begin(); set_end = set_v[i].end(); while( set_itr != set_end ) rev_hes_sparse.add_element(i_x, *set_itr++); } } } break; case UsrapOp: // parameter argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( 0 < user_j && user_j <= user_n ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); --user_j; user_ix[user_j] = 0; user_vx[user_j] = false; if( user_j == 0 ) user_state = user_start; break; case UsravOp: // variable argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( 0 < user_j && user_j <= user_n ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= i_var ); CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); --user_j; user_ix[user_j] = arg[0]; user_vx[user_j] = true; for_jac_sparse.begin(arg[0]); i = for_jac_sparse.next_element(); while( i < user_q ) { if( user_pack ) pack_r[ user_j * user_q + i ] = true; if( user_bool ) bool_r[ user_j * user_q + i ] = true; if( user_set ) set_r[user_j].insert(i); i = for_jac_sparse.next_element(); } if( user_j == 0 ) user_state = user_start; break; case UsrrpOp: // parameter result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( 0 < user_i && user_i <= user_m ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); --user_i; if( user_i == 0 ) user_state = user_arg; break; case UsrrvOp: // variable result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( 0 < user_i && user_i <= user_m ); --user_i; if( RevJac[i_var] ) { user_s[user_i] = true; } rev_hes_sparse.begin(i_var); j = rev_hes_sparse.next_element(); while( j < user_q ) { if( user_pack ) pack_u[user_i * user_q + j] = true; if( user_bool ) bool_u[user_i * user_q + j] = true; if( user_set ) set_u[user_i].insert(j); j = rev_hes_sparse.next_element(); } if( user_i == 0 ) user_state = user_arg; break; // ------------------------------------------------- case ZmulpvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1) reverse_sparse_hessian_linear_unary_op( i_var, arg[1], RevJac, for_jac_sparse, rev_hes_sparse ); break; // ------------------------------------------------- case ZmulvpOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1) reverse_sparse_hessian_linear_unary_op( i_var, arg[0], RevJac, for_jac_sparse, rev_hes_sparse ); break; // ------------------------------------------------- case ZmulvvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1) reverse_sparse_hessian_mul_op( i_var, arg, RevJac, for_jac_sparse, rev_hes_sparse ); break; // ------------------------------------------------- default: CPPAD_ASSERT_UNKNOWN(0); } # if CPPAD_REV_HES_SWEEP_TRACE for(j = 0; j < limit; j++) { zf_value[j] = false; zh_value[j] = false; } for_jac_sparse.begin(i_var);; j = for_jac_sparse.next_element();; while( j < limit ) { zf_value[j] = true; j = for_jac_sparse.next_element(); } rev_hes_sparse.begin(i_var);; j = rev_hes_sparse.next_element();; while( j < limit ) { zh_value[j] = true; j = rev_hes_sparse.next_element(); } printOp( std::cout, play, i_op, 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( i_op == 0 ); CPPAD_ASSERT_UNKNOWN( i_var == 0 ); return; } } // END_CPPAD_NAMESPACE // preprocessor symbols that are local to this file # undef CPPAD_REV_HES_SWEEP_TRACE # endif cppad-20160000.1/cppad/local/reverse.hpp0000644000175200017650000001340312656321767017004 0ustar coincoin-web// $Id: reverse.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_REVERSE_HPP # define CPPAD_REVERSE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file reverse.hpp Compute derivatives using reverse mode. */ /*! Use reverse mode to compute derivative of forward mode Taylor coefficients. The function \f$ X : {\rm R} \times {\rm R}^{n \times q} \rightarrow {\rm R} \f$ is defined by \f[ X(t , u) = \sum_{k=0}^{q-1} u^{(k)} t^k \f] The function \f$ Y : {\rm R} \times {\rm R}^{n \times q} \rightarrow {\rm R} \f$ is defined by \f[ Y(t , u) = F[ X(t, u) ] \f] The function \f$ W : {\rm R}^{n \times q} \rightarrow {\rm R} \f$ is defined by \f[ W(u) = \sum_{k=0}^{q-1} ( w^{(k)} )^{\rm T} \frac{1}{k !} \frac{ \partial^k } { t^k } Y(0, u) \f] \tparam Base base type for the operator; i.e., this operation sequence was recorded using AD< \a Base > and computations by this routine are done using type \a Base. \tparam VectorBase is a Simple Vector class with elements of type \a 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 \a 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 \a w has size \c 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 VectorBase ADFun::Reverse(size_t q, const VectorBase &w) { // 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(); pod_vector Partial; Partial.extend(num_var_tape_ * q); // update maximum memory requirement // memoryMax = std::max( memoryMax, // Memory() + num_var_tape_ * q * sizeof(Base) // ); // check VectorBase 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 for the corresponding ADFun." ); CPPAD_ASSERT_KNOWN( q > 0, "The first argument to Reverse must be greater than zero." ); CPPAD_ASSERT_KNOWN( num_order_taylor_ >= q, "Less that q taylor_ coefficients are currently stored" " in this ADFun object." ); // special case where multiple forward directions have been computed, // but we are only using the one direction zero order results if( (q == 1) & (num_direction_taylor_ > 1) ) { 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 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() ); ReverseSweep( q - 1, n, num_var_tape_, &play_, cap_order_taylor_, taylor_.data(), q, Partial.data(), cskip_op_.data(), load_op_ ); // return the derivative values VectorBase 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] ) == 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 cppad-20160000.1/cppad/local/base_float.hpp0000644000175200017650000001245612656321767017437 0ustar coincoin-web// $Id: base_float.hpp 3769 2015-12-29 16:13:16Z bradbell $ # ifndef CPPAD_BASE_FLOAT_HPP # define CPPAD_BASE_FLOAT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include /* $begin base_float.hpp$$ $spell 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 $codep */ 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 $codep */ 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 $codep */ 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 $codep */ 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); } } /* $$ $head Integer$$ $codep */ namespace CppAD { inline int Integer(const float& x) { return static_cast(x); } } /* $$ $head azmul$$ $codep */ namespace CppAD { CPPAD_AZMUL( float ) } /* $$ $head Ordered$$ The $code float$$ type supports ordered comparisons $codep */ 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 define the unary standard math functions required to use $code AD$$: (in the CppAD namespace) $codep */ namespace CppAD { CPPAD_STANDARD_MATH_UNARY(float, acos) CPPAD_STANDARD_MATH_UNARY(float, asin) CPPAD_STANDARD_MATH_UNARY(float, atan) CPPAD_STANDARD_MATH_UNARY(float, cos) CPPAD_STANDARD_MATH_UNARY(float, cosh) CPPAD_STANDARD_MATH_UNARY(float, exp) CPPAD_STANDARD_MATH_UNARY(float, fabs) CPPAD_STANDARD_MATH_UNARY(float, log) CPPAD_STANDARD_MATH_UNARY(float, log10) CPPAD_STANDARD_MATH_UNARY(float, sin) CPPAD_STANDARD_MATH_UNARY(float, sinh) CPPAD_STANDARD_MATH_UNARY(float, sqrt) CPPAD_STANDARD_MATH_UNARY(float, tan) CPPAD_STANDARD_MATH_UNARY(float, tanh) # if CPPAD_USE_CPLUSPLUS_2011 CPPAD_STANDARD_MATH_UNARY(float, erf) CPPAD_STANDARD_MATH_UNARY(float, asinh) CPPAD_STANDARD_MATH_UNARY(float, acosh) CPPAD_STANDARD_MATH_UNARY(float, atanh) CPPAD_STANDARD_MATH_UNARY(float, expm1) CPPAD_STANDARD_MATH_UNARY(float, log1p) # endif } /* $$ The absolute value function is special because its $code std$$ name is $code fabs$$ $codep */ 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$$: $codep */ 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$$: $codep */ namespace CppAD { inline float pow(const float& x, const float& y) { return std::pow(x, y); } } /*$$ $head numeric_limits$$ The following defines the CppAD $cref numeric_limits$$ for the type $code float$$: $codep */ namespace CppAD { CPPAD_NUMERIC_LIMITS(float, float) } /*$$ $head to_string$$ There is no need to define $code to_string$$ for $code float$$ because it is defined by including $code cppad/utility/to_string.hpp$$; see $cref to_string$$. See $cref/base_complex.hpp/base_complex.hpp/to_string/$$ for an example where it is necessary to define $code to_string$$ for a $icode Base$$ type. $end */ # endif cppad-20160000.1/cppad/local/for_two.hpp0000644000175200017650000001454412656321767017017 0ustar coincoin-web// $Id: for_two.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FOR_TWO_HPP # define CPPAD_FOR_TWO_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ForTwo$$ $spell ddy typename Taylor const $$ $section Forward Mode Second Partial Derivative Driver$$ $mindex order easy$$ $head Syntax$$ $icode%ddy% = %f%.ForTwo(%x%, %j%, %k%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The syntax above sets $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 %VectorBase% &%x% %$$ (see $cref/VectorBase/ForTwo/VectorBase/$$ 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 %VectorSize_t% &%j% %$$ (see $cref/VectorSize_t/ForTwo/VectorSize_t/$$ below) We use $icode p$$ to denote the size of the vector $icode j$$. All of the indices in $icode j$$ 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 %VectorSize_t% &%k% %$$ (see $cref/VectorSize_t/ForTwo/VectorSize_t/$$ below) and its size must be equal to $icode p$$, the size of the vector $icode j$$. All of the indices in $icode k$$ 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% %VectorBase% %ddy% %$$ (see $cref/VectorBase/ForTwo/VectorBase/$$ below) and its size is $latex m * p$$. It contains the requested partial derivatives; to be specific, for $latex i = 0 , \ldots , m - 1 $$ and $latex \ell = 0 , \ldots , p - 1$$ $latex \[ ddy [ i * p + \ell ] = \DD{ F_i }{ x_{j[ \ell ]} }{ x_{k[ \ell ]} } (x) \] $$ $head VectorBase$$ The type $icode VectorBase$$ 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 VectorSize_t$$ The type $icode VectorSize_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/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 VectorBase ADFun::ForTwo( const VectorBase &x, const VectorSize_t &j, const VectorSize_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 VectorBase is Simple Vector class with Base type elements CheckSimpleVector(); // check VectorSize_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 VectorBase ddy(m * p); // allocate memory to hold all possible diagonal Taylor coefficients // (for large sparse cases, this is not efficient) VectorBase 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 VectorBase dx(n); for(j1 = 0; j1 < n; j1++) dx[j1] = Base(0); // result vector in range space VectorBase 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); Forward(1, dx); dx[j1] = Base(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) * D[i * n + j1]; } else { // cross term in j1 and k1 directions dx[j1] = Base(1); dx[k1] = Base(1); Forward(1, dx); dx[j1] = Base(0); dx[k1] = Base(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 cppad-20160000.1/cppad/local/std_math_98.hpp0000644000175200017650000003364112656321767017462 0ustar coincoin-web// $Id$ # ifndef CPPAD_STD_MATH_98_HPP # define CPPAD_STD_MATH_98_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin acos$$ $spell acos $$ $section Inverse Sine Function: acos$$ $head Syntax$$ $icode%y% = acos(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{acos}^{(1)} (x) & = & - (1 - x * x)^{-1/2} \end{array} \] $$ $head Example$$ $children% example/acos.cpp %$$ The file $cref acos.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin asin$$ $spell asin $$ $section Inverse Sine Function: asin$$ $head Syntax$$ $icode%y% = asin(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{asin}^{(1)} (x) & = & (1 - x * x)^{-1/2} \end{array} \] $$ $head Example$$ $children% example/asin.cpp %$$ The file $cref asin.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin atan$$ $spell atan $$ $section Inverse Tangent Function: atan$$ $head Syntax$$ $icode%y% = atan(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{atan}^{(1)} (x) & = & \frac{1}{1 + x^2} \end{array} \] $$ $head Example$$ $children% example/atan.cpp %$$ The file $cref atan.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin cos$$ $spell cos $$ $section The Cosine Function: cos$$ $head Syntax$$ $icode%y% = cos(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{cos}^{(1)} (x) & = & - \sin(x) \end{array} \] $$ $head Example$$ $children% example/cos.cpp %$$ The file $cref cos.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin cosh$$ $spell cosh $$ $section The Hyperbolic Cosine Function: cosh$$ $head Syntax$$ $icode%y% = cosh(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{cosh}^{(1)} (x) & = & \sinh(x) \end{array} \] $$ $head Example$$ $children% example/cosh.cpp %$$ The file $cref cosh.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin exp$$ $spell exp $$ $section The Exponential Function: exp$$ $head Syntax$$ $icode%y% = exp(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{exp}^{(1)} (x) & = & \exp(x) \end{array} \] $$ $head Example$$ $children% example/exp.cpp %$$ The file $cref exp.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin log$$ $spell $$ $section The Exponential Function: log$$ $head Syntax$$ $icode%y% = log(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{log}^{(1)} (x) & = & \frac{1}{x} \end{array} \] $$ $head Example$$ $children% example/log.cpp %$$ The file $cref log.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin log10$$ $spell CppAD $$ $section The Base 10 Logarithm Function: log10$$ $head Syntax$$ $icode%y% = log10(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Method$$ CppAD uses the representation $latex \[ \begin{array}{lcr} {\rm log10} (x) & = & \log(x) / \log(10) \end{array} \] $$ $head Example$$ $children% example/log10.cpp %$$ The file $cref log10.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin sin$$ $spell sin $$ $section The Sine Function: sin$$ $head Syntax$$ $icode%y% = sin(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{sin}^{(1)} (x) & = & \cos(x) \end{array} \] $$ $head Example$$ $children% example/sin.cpp %$$ The file $cref sin.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin sinh$$ $spell sinh $$ $section The Hyperbolic Sine Function: sinh$$ $head Syntax$$ $icode%y% = sinh(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{sinh}^{(1)} (x) & = & \cosh(x) \end{array} \] $$ $head Example$$ $children% example/sinh.cpp %$$ The file $cref sinh.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin sqrt$$ $spell sqrt $$ $section The Square Root Function: sqrt$$ $head Syntax$$ $icode%y% = sqrt(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{sqrt}^{(1)} (x) & = & \frac{1}{2 \R{sqrt} (x) } \end{array} \] $$ $head Example$$ $children% example/sqrt.cpp %$$ The file $cref sqrt.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin tan$$ $spell tan $$ $section The Tangent Function: tan$$ $head Syntax$$ $icode%y% = tan(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{tan}^{(1)} (x) & = & 1 + \tan (x)^2 \end{array} \] $$ $head Example$$ $children% example/tan.cpp %$$ The file $cref tan.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- $begin tanh$$ $spell tanh $$ $section The Hyperbolic Tangent Function: tanh$$ $head Syntax$$ $icode%y% = tanh(%x%)%$$ $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head Atomic$$ This is an $cref/atomic operation/glossary/Operation/Atomic/$$. $head Derivative$$ $latex \[ \begin{array}{lcr} \R{tanh}^{(1)} (x) & = & 1 - \tanh (x)^2 \end{array} \] $$ $head Example$$ $children% example/tanh.cpp %$$ The file $cref tanh.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- */ /*! \file std_math_98.hpp Define AD standard math functions (using their Base versions) */ /*! \def CPPAD_STANDARD_MATH_UNARY_AD(Name, Op) Defines function Name with argument type AD and tape operation Op The macro defines the function x.Name() where x has type AD. It then uses this funciton to define Name(x) where x has type AD or VecAD_reference. If x is a variable, the tape unary operator Op is used to record the operation and the result is identified as correspoding to this operation; i.e., Name(x).taddr_ idendifies the operation and Name(x).tape_id_ identifies the tape. This macro is used to define AD versions of acos, asin, atan, cos, cosh, exp, fabs, log, sin, sinh, sqrt, tan, tanh. */ # define CPPAD_STANDARD_MATH_UNARY_AD(Name, Op) \ template \ inline AD Name(const AD &x) \ { return x.Name(); } \ template \ inline AD AD::Name (void) const \ { \ AD result; \ result.value_ = CppAD::Name(value_); \ CPPAD_ASSERT_UNKNOWN( Parameter(result) ); \ \ if( Variable(*this) ) \ { CPPAD_ASSERT_UNKNOWN( NumArg(Op) == 1 ); \ ADTape *tape = tape_this(); \ tape->Rec_.PutArg(taddr_); \ result.taddr_ = tape->Rec_.PutOp(Op); \ result.tape_id_ = tape->id_; \ } \ return result; \ } \ template \ inline AD Name(const VecAD_reference &x) \ { return Name( x.ADBase() ); } // BEGIN CppAD namespace namespace CppAD { CPPAD_STANDARD_MATH_UNARY_AD(acos, AcosOp) CPPAD_STANDARD_MATH_UNARY_AD(asin, AsinOp) CPPAD_STANDARD_MATH_UNARY_AD(atan, AtanOp) CPPAD_STANDARD_MATH_UNARY_AD(cos, CosOp) CPPAD_STANDARD_MATH_UNARY_AD(cosh, CoshOp) CPPAD_STANDARD_MATH_UNARY_AD(exp, ExpOp) CPPAD_STANDARD_MATH_UNARY_AD(fabs, AbsOp) CPPAD_STANDARD_MATH_UNARY_AD(log, LogOp) CPPAD_STANDARD_MATH_UNARY_AD(sin, SinOp) CPPAD_STANDARD_MATH_UNARY_AD(sinh, SinhOp) CPPAD_STANDARD_MATH_UNARY_AD(sqrt, SqrtOp) CPPAD_STANDARD_MATH_UNARY_AD(tan, TanOp) CPPAD_STANDARD_MATH_UNARY_AD(tanh, TanhOp) # if CPPAD_USE_CPLUSPLUS_2011 CPPAD_STANDARD_MATH_UNARY_AD(asinh, AsinhOp) CPPAD_STANDARD_MATH_UNARY_AD(acosh, AcoshOp) CPPAD_STANDARD_MATH_UNARY_AD(atanh, AtanhOp) CPPAD_STANDARD_MATH_UNARY_AD(expm1, Expm1Op) CPPAD_STANDARD_MATH_UNARY_AD(log1p, Log1pOp) # endif # if CPPAD_USE_CPLUSPLUS_2011 // Error function is a special case template inline AD erf(const AD &x) { return x.erf(); } template inline AD AD::erf (void) const { AD result; result.value_ = CppAD::erf(value_); CPPAD_ASSERT_UNKNOWN( Parameter(result) ); if( Variable(*this) ) { CPPAD_ASSERT_UNKNOWN( NumArg(ErfOp) == 3 ); ADTape *tape = tape_this(); // arg[0] = argument to erf function tape->Rec_.PutArg(taddr_); // arg[1] = zero addr_t p = tape->Rec_.PutPar( Base(0) ); tape->Rec_.PutArg(p); // arg[2] = 2 / sqrt(pi) p = tape->Rec_.PutPar(Base( 1.0 / std::sqrt( std::atan(1.0) ) )); tape->Rec_.PutArg(p); // result.taddr_ = tape->Rec_.PutOp(ErfOp); result.tape_id_ = tape->id_; } return result; } template inline AD erf(const VecAD_reference &x) { return erf( x.ADBase() ); } # endif /*! Compute the log of base 10 of x where has type AD \tparam Base is the base type (different from base for log) for this AD type, see base_require. \param x is the argument for the log10 function. \result if the result is y, then \f$ x = 10^y \f$. */ template inline AD log10(const AD &x) { return CppAD::log(x) / CppAD::log( Base(10) ); } template inline AD log10(const VecAD_reference &x) { return CppAD::log(x.ADBase()) / CppAD::log( Base(10) ); } } # undef CPPAD_STANDARD_MATH_UNARY_AD # endif cppad-20160000.1/cppad/local/cos_op.hpp0000644000175200017650000001440312656321767016614 0ustar coincoin-web// $Id: cos_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_COS_OP_HPP # define CPPAD_COS_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary2_op */ template inline 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); c[j] = Base(0); for(k = 1; k <= j; k++) { s[j] += Base(k) * x[k] * c[j-k]; c[j] -= Base(k) * x[k] * s[j-k]; } s[j] /= Base(j); c[j] /= Base(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 forward_unary2_op_dir */ template inline 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(q) * x[m + ell] * c[0]; c[m+ell] = - Base(q) * x[m + ell] * s[0]; for(size_t k = 1; k < q; k++) { s[m+ell] += Base(k) * x[(k-1)*r+1+ell] * c[(q-k-1)*r+1+ell]; c[m+ell] -= Base(k) * x[(k-1)*r+1+ell] * s[(q-k-1)*r+1+ell]; } s[m+ell] /= Base(q); c[m+ell] /= Base(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 forward_unary2_op_0 */ template inline 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 reverse_unary2_op */ template inline 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(j); pc[j] /= Base(j); for(k = 1; k <= j; k++) { px[k] += Base(k) * azmul(ps[j], c[j-k]); px[k] -= Base(k) * azmul(pc[j], s[j-k]); ps[j-k] -= Base(k) * azmul(pc[j], x[k]); pc[j-k] += Base(k) * azmul(ps[j], x[k]); } --j; } px[0] += azmul(ps[0], c[0]); px[0] -= azmul(pc[0], s[0]); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/drivers.hpp0000644000175200017650000000246012656321767017010 0ustar coincoin-web// $Id: drivers.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DRIVERS_HPP # define CPPAD_DRIVERS_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Drivers$$ $spell $$ $section First and Second Derivatives: Easy Drivers$$ $mindex forward reverse$$ $childtable% cppad/local/jacobian.hpp% cppad/local/for_one.hpp% cppad/local/rev_one.hpp% cppad/local/hessian.hpp% cppad/local/for_two.hpp% cppad/local/rev_two.hpp% cppad/local/sparse_jacobian.hpp% cppad/local/sparse_hessian.hpp %$$ $end */ # include # include # include # include # include # include # include # include # endif cppad-20160000.1/cppad/local/log1p.hpp0000644000175200017650000000442612656321767016360 0ustar coincoin-web// $Id$ # ifndef CPPAD_LOG1P_HPP # define CPPAD_LOG1P_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin log1p$$ $spell CppAD $$ $section The Logarithm of One Plus Argument: log1p$$ $head Syntax$$ $icode%y% = log1p(%x%)%$$ $head Description$$ Returns the value of the logarithm of one plus argument which is defined by $icode%y% == log(1 + %x%)%$$. $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head CPPAD_USE_CPLUSPLUS_2011$$ $subhead true$$ If this preprocessor symbol is true ($code 1$$), and $icode x$$ is an AD type, this is an $cref/atomic operation/glossary/Operation/Atomic/$$. $subhead false$$ If this preprocessor symbol is false ($code 0$$), CppAD uses the representation $latex \[ \R{log1p} (x) = \log(1 + x) \] $$ to compute this function. $head Example$$ $children% example/log1p.cpp %$$ The file $cref log1p.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- */ # include # if ! CPPAD_USE_CPLUSPLUS_2011 // BEGIN CppAD namespace namespace CppAD { template Type log1p_template(const Type &x) { return CppAD::log(Type(1) + x); } inline float log1p(const float &x) { return log1p_template(x); } inline double log1p(const double &x) { return log1p_template(x); } template inline AD log1p(const AD &x) { return log1p_template(x); } template inline AD log1p(const VecAD_reference &x) { return log1p_template( x.ADBase() ); } } // END CppAD namespace # endif // CPPAD_USE_CPLUSPLUS_2011 # endif // CPPAD_LOG1P_INCLUDED cppad-20160000.1/cppad/local/declare_ad.hpp0000644000175200017650000001361312656321767017377 0ustar coincoin-web// $Id: declare_ad.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DECLARE_AD_HPP # define CPPAD_DECLARE_AD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # if CPPAD_USE_CPLUSPLUS_2011 # include # endif 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_jacobian_work; class sparse_hessian_work; template class AD; template class ADFun; template class ADTape; template class atomic_base; template class discrete; template class player; template class recorder; template class VecAD; template class VecAD_reference; // functions with one VecAD argument template bool Parameter (const VecAD &u); template bool Variable (const VecAD &u); // functions with one AD argument template int Integer (const AD &u); template bool Parameter (const AD &u); template bool Variable (const AD &u); template bool IdenticalZero (const AD &u); template bool IdenticalOne (const AD &u); template bool IdenticalPar (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); // 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 ); // IdenticalEqualPar template bool IdenticalEqualPar (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 cppad-20160000.1/cppad/local/asin_op.hpp0000644000175200017650000001523612656321767016767 0ustar coincoin-web// $Id: asin_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ASIN_OP_HPP # define CPPAD_ASIN_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary2_op */ template inline 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) - x[0] * x[0]; b[0] = sqrt( uj ); p++; } for(size_t j = p; j <= q; j++) { uj = Base(0); for(k = 0; k <= j; k++) uj -= x[k] * x[j-k]; b[j] = Base(0); z[j] = Base(0); for(k = 1; k < j; k++) { b[j] -= Base(k) * b[k] * b[j-k]; z[j] -= Base(k) * z[k] * b[j-k]; } b[j] /= Base(j); z[j] /= Base(j); // b[j] += uj / Base(2); z[j] += x[j]; // b[j] /= b[0]; z[j] /= b[0]; } } /*! Multiple directions forward mode Taylor coefficient for op = 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 forward_unary2_op_dir */ template inline 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); z[m+ell] = Base(0); for(k = 1; k < q; k++) { b[m+ell] += Base(k) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; z[m+ell] += Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; } b[m+ell] = ( uq / Base(2) - b[m+ell] / Base(q) ) / b[0]; z[m+ell] = ( x[m+ell] - z[m+ell] / Base(q) ) / b[0]; } } /*! Compute zero order forward mode Taylor coefficient for result of op = 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 forward_unary2_op_0 */ template inline 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) - 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 reverse_unary2_op */ template inline 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) / b[0]; // number of indices to access size_t j = d; size_t k; while(j) { // scale partials w.r.t b[j] by 1 / b[0] pb[j] = azmul(pb[j], inv_b0); // scale partials w.r.t z[j] by 1 / b[0] pz[j] = azmul(pz[j], inv_b0); // update partials w.r.t b^0 pb[0] -= azmul(pz[j], z[j]) + azmul(pb[j], b[j]); // update partial w.r.t. x^0 px[0] -= azmul(pb[j], x[j]); // update partial w.r.t. x^j px[j] += pz[j] - azmul(pb[j], x[0]); // further scale partial w.r.t. z[j] by 1 / j pz[j] /= Base(j); for(k = 1; k < j; k++) { // update partials w.r.t b^(j-k) pb[j-k] -= Base(k) * azmul(pz[j], z[k]) + azmul(pb[j], b[k]); // update partials w.r.t. x^k px[k] -= azmul(pb[j], x[j-k]); // update partials w.r.t. z^k pz[k] -= Base(k) * azmul(pz[j], b[j-k]); } --j; } // j == 0 case px[0] += azmul(pz[0] - azmul(pb[0], x[0]), inv_b0); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/discrete.hpp0000644000175200017650000001773012656321767017142 0ustar coincoin-web// $Id: discrete.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DISCRETE_HPP # define CPPAD_DISCRETE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Discrete$$ $spell retaping namespace std Eq Cpp const inline Geq $$ $section Discrete AD Functions$$ $mindex CPPAD_DISCRETE_FUNCTION$$ $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/tape_index.cpp% example/interp_onetape.cpp% example/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 \c ax and \c 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 \c Base class. \par This constructor can ont be used in parallel mode because it changes the static object \c 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 \c ay above. */ AD ad(const AD &ax) const { AD ay; ay.value_ = f_(ax.value_); if( Variable(ax) ) { ADTape *tape = ax.tape_this(); CPPAD_ASSERT_UNKNOWN( NumRes(DisOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(DisOp) == 2 ); // put operand addresses in the tape tape->Rec_.PutArg(index_, ax.taddr_); // put operator in the tape ay.taddr_ = tape->Rec_.PutOp(DisOp); // make result a variable ay.tape_id_ = tape->id_; CPPAD_ASSERT_UNKNOWN( Variable(ay) ); } 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 cppad-20160000.1/cppad/local/log_op.hpp0000644000175200017650000001135612656321767016615 0ustar coincoin-web// $Id: log_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_LOG_OP_HPP # define CPPAD_LOG_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary1_op */ template inline 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(k) * z[k] * x[j-k]; z[j] /= Base(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 forward_unary1_op_dir */ template inline 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(q) * x[m+ell]; for(size_t k = 1; k < q; k++) z[m+ell] -= Base(k) * z[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; z[m+ell] /= (Base(q) * 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 forward_unary1_op_0 */ template inline 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 reverse_unary1_op */ template inline 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) / 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(j); for(k = 1; k < j; k++) { pz[k] -= Base(k) * azmul(pz[j], x[j-k]); px[j-k] -= Base(k) * azmul(pz[j], z[k]); } --j; } px[0] += azmul(pz[0], inv_x0); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/add.hpp0000644000175200017650000000560112656321767016062 0ustar coincoin-web// $Id: add.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ADD_HPP # define CPPAD_ADD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // BEGIN CppAD 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 ADTape* tape = AD::tape_ptr(); if( tape == CPPAD_NULL ) return result; tape_id_t tape_id = tape->id_; // tape_id cannot match the default value for tape_id_; i.e., 0 CPPAD_ASSERT_UNKNOWN( tape_id > 0 ); bool var_left = left.tape_id_ == tape_id; bool var_right = right.tape_id_ == tape_id; if( var_left ) { if( var_right ) { // result = variable + variable CPPAD_ASSERT_UNKNOWN( NumRes(AddvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(AddvvOp) == 2 ); // put operand addresses in tape tape->Rec_.PutArg(left.taddr_, right.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(AddvvOp); // make result a variable result.tape_id_ = tape_id; } else if( IdenticalZero(right.value_) ) { // result = variable + 0 result.make_variable(left.tape_id_, left.taddr_); } else { // result = variable + parameter // = parameter + variable CPPAD_ASSERT_UNKNOWN( NumRes(AddpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(AddpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(right.value_); tape->Rec_.PutArg(p, left.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(AddpvOp); // make result a variable result.tape_id_ = tape_id; } } else if( var_right ) { if( IdenticalZero(left.value_) ) { // result = 0 + variable result.make_variable(right.tape_id_, right.taddr_); } else { // result = parameter + variable CPPAD_ASSERT_UNKNOWN( NumRes(AddpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(AddpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(left.value_); tape->Rec_.PutArg(p, right.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(AddpvOp); // make result a variable result.tape_id_ = tape_id; } } return result; } // convert other cases into the case above CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(+) } // END CppAD namespace # endif cppad-20160000.1/cppad/local/std_set.hpp0000644000175200017650000000266512656321767017006 0ustar coincoin-web// $Id: std_set.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_STD_SET_HPP # define CPPAD_STD_SET_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL # include namespace CppAD { // BEGIN_CPPAD_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_NAMESPACE # endif cppad-20160000.1/cppad/local/ad_valued.hpp0000644000175200017650000000266412656321767017264 0ustar coincoin-web// $Id: ad_valued.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_AD_VALUED_HPP # define CPPAD_AD_VALUED_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ADValued$$ $spell $$ $section AD Valued Operations and Functions$$ $comment atomic.omh includes atomic_base.omh which atomic_base.hpp$$ $childtable% cppad/local/arithmetic.hpp% cppad/local/standard_math.hpp% cppad/local/cond_exp.hpp% cppad/local/discrete.hpp% cppad/local/numeric_limits.hpp% omh/atomic.omh %$$ $end */ // include MathOther.h after CondExp.h because some MathOther.h routines use // CondExp.h and CondExp.h is not sufficently declared in Declare.h # include # include # include # include # include # include # include # include # endif cppad-20160000.1/cppad/local/define.hpp0000644000175200017650000004234612656321767016573 0ustar coincoin-web// $Id: define.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DEFINE_HPP # define CPPAD_DEFINE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /*! \file define.hpp Define processor symbols and macros that are used by CppAD. */ // ---------------------------------------------------------------------------- /*! \def CPPAD_OP_CODE_TYPE Is the type used to store enum OpCode values. If not the same as OpCode, then sizeof(CPPAD_OP_CODE_TYPE) <= sizeof( enum OpCode ) to conserve memory. This type must support \c std::numeric_limits, the \c <= operator, and conversion to \c size_t. Make sure that the type chosen returns true for is_pod in pod_vector.hpp. */ # define CPPAD_OP_CODE_TYPE unsigned char // ---------------------------------------------------------------------------- /*! \def CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION A version of the inline command that works with MC compiler. Microsoft Visual C++ version 9.0 generates a warning if a template function is declared as a friend (this was not a problem for version 7.0). 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 \ inline AD& operator Op \ (AD &left, double right) \ { return left Op AD(right); } \ \ template \ inline 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 \ inline 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 \ inline AD operator Op \ (const AD &left, const VecAD_reference &right) \ { return left Op right.ADBase(); } \ \ template \ inline AD operator Op \ (const VecAD_reference &left, const VecAD_reference &right)\ { return left.ADBase() Op right.ADBase(); } \ \ template \ inline AD operator Op \ (const VecAD_reference &left, const AD &right) \ { return left.ADBase() Op right; } \ /* ----------------------------------------------------------------*/ \ /* Operations Base */ \ \ template \ inline AD operator Op \ (const Base &left, const AD &right) \ { return AD(left) Op right; } \ \ template \ inline AD operator Op \ (const Base &left, const VecAD_reference &right) \ { return AD(left) Op right.ADBase(); } \ \ template \ inline AD operator Op \ (const AD &left, const Base &right) \ { return left Op AD(right); } \ \ template \ inline AD operator Op \ (const VecAD_reference &left, const Base &right) \ { return left.ADBase() Op AD(right); } \ \ /* ----------------------------------------------------------------*/ \ /* Operations double */ \ \ template \ inline AD operator Op \ (const double &left, const AD &right) \ { return AD(left) Op right; } \ \ template \ inline AD operator Op \ (const double &left, const VecAD_reference &right) \ { return AD(left) Op right.ADBase(); } \ \ template \ inline AD operator Op \ (const AD &left, const double &right) \ { return left Op AD(right); } \ \ template \ inline 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 \ inline bool operator Op \ (const AD &left, const VecAD_reference &right) \ { return left Op right.ADBase(); } \ \ template \ inline bool operator Op \ (const VecAD_reference &left, const VecAD_reference &right)\ { return left.ADBase() Op right.ADBase(); } \ \ template \ inline bool operator Op \ (const VecAD_reference &left, const AD &right) \ { return left.ADBase() Op right; } \ /* ----------------------------------------------------------------*/ \ /* Operations Base */ \ \ template \ inline bool operator Op \ (const Base &left, const AD &right) \ { return AD(left) Op right; } \ \ template \ inline bool operator Op \ (const Base &left, const VecAD_reference &right) \ { return AD(left) Op right.ADBase(); } \ \ template \ inline bool operator Op \ (const AD &left, const Base &right) \ { return left Op AD(right); } \ \ template \ inline bool operator Op \ (const VecAD_reference &left, const Base &right) \ { return left.ADBase() Op AD(right); } \ \ /* ----------------------------------------------------------------*/ \ /* Operations double */ \ \ template \ inline bool operator Op \ (const double &left, const AD &right) \ { return AD(left) Op right; } \ \ template \ inline bool operator Op \ (const double &left, const VecAD_reference &right) \ { return AD(left) Op right.ADBase(); } \ \ template \ inline bool operator Op \ (const AD &left, const double &right) \ { return left Op AD(right); } \ \ template \ inline 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 cppad-20160000.1/cppad/local/compare.hpp0000644000175200017650000002460212656321767016762 0ustar coincoin-web// $Id: compare.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_COMPARE_HPP # define CPPAD_COMPARE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin Compare$$ $spell cos Op bool const $$ $section AD Binary Comparison Operators$$ $mindex compare < <= > >= == !=$$ $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/compare.cpp %$$ The file $cref compare.cpp$$ contains an example and test of these operations. It returns true if it succeeds and false otherwise. $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_); bool var_left = Variable(left); bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; if( var_left ) { tape = left.tape_this(); if( var_right ) { if( result ) { tape->Rec_.PutOp(LtvvOp); tape->Rec_.PutArg(left.taddr_, right.taddr_); } else { tape->Rec_.PutOp(LevvOp); tape->Rec_.PutArg(right.taddr_, left.taddr_); } } else { addr_t arg1 = tape->Rec_.PutPar(right.value_); if( result ) { tape->Rec_.PutOp(LtvpOp); tape->Rec_.PutArg(left.taddr_, arg1); } else { tape->Rec_.PutOp(LepvOp); tape->Rec_.PutArg(arg1, left.taddr_); } } } else if ( var_right ) { tape = right.tape_this(); addr_t arg0 = tape->Rec_.PutPar(left.value_); if( result ) { tape->Rec_.PutOp(LtpvOp); tape->Rec_.PutArg(arg0, right.taddr_); } else { tape->Rec_.PutOp(LevpOp); tape->Rec_.PutArg(right.taddr_, arg0); } } return result; } // 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_); bool var_left = Variable(left); bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; if( var_left ) { tape = left.tape_this(); if( var_right ) { if( result ) { tape->Rec_.PutOp(LevvOp); tape->Rec_.PutArg(left.taddr_, right.taddr_); } else { tape->Rec_.PutOp(LtvvOp); tape->Rec_.PutArg(right.taddr_, left.taddr_); } } else { addr_t arg1 = tape->Rec_.PutPar(right.value_); if( result ) { tape->Rec_.PutOp(LevpOp); tape->Rec_.PutArg(left.taddr_, arg1); } else { tape->Rec_.PutOp(LtpvOp); tape->Rec_.PutArg(arg1, left.taddr_); } } } else if ( var_right ) { tape = right.tape_this(); addr_t arg0 = tape->Rec_.PutPar(left.value_); if( result ) { tape->Rec_.PutOp(LepvOp); tape->Rec_.PutArg(arg0, right.taddr_); } else { tape->Rec_.PutOp(LtvpOp); tape->Rec_.PutArg(right.taddr_, arg0); } } return result; } // 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_); bool var_left = Variable(left); bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; if( var_left ) { tape = left.tape_this(); if( var_right ) { if( result ) { tape->Rec_.PutOp(LtvvOp); tape->Rec_.PutArg(right.taddr_, left.taddr_); } else { tape->Rec_.PutOp(LevvOp); tape->Rec_.PutArg(left.taddr_, right.taddr_); } } else { addr_t arg1 = tape->Rec_.PutPar(right.value_); if( result ) { tape->Rec_.PutOp(LtpvOp); tape->Rec_.PutArg(arg1, left.taddr_); } else { tape->Rec_.PutOp(LevpOp); tape->Rec_.PutArg(left.taddr_, arg1); } } } else if ( var_right ) { tape = right.tape_this(); addr_t arg0 = tape->Rec_.PutPar(left.value_); if( result ) { tape->Rec_.PutOp(LtvpOp); tape->Rec_.PutArg(right.taddr_, arg0); } else { tape->Rec_.PutOp(LepvOp); tape->Rec_.PutArg(arg0, right.taddr_); } } return result; } // 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_); bool var_left = Variable(left); bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; if( var_left ) { tape = left.tape_this(); if( var_right ) { if( result ) { tape->Rec_.PutOp(LevvOp); tape->Rec_.PutArg(right.taddr_, left.taddr_); } else { tape->Rec_.PutOp(LtvvOp); tape->Rec_.PutArg(left.taddr_, right.taddr_); } } else { addr_t arg1 = tape->Rec_.PutPar(right.value_); if( result ) { tape->Rec_.PutOp(LepvOp); tape->Rec_.PutArg(arg1, left.taddr_); } else { tape->Rec_.PutOp(LtvpOp); tape->Rec_.PutArg(left.taddr_, arg1); } } } else if ( var_right ) { tape = right.tape_this(); addr_t arg0 = tape->Rec_.PutPar(left.value_); if( result ) { tape->Rec_.PutOp(LevpOp); tape->Rec_.PutArg(right.taddr_, arg0); } else { tape->Rec_.PutOp(LtpvOp); tape->Rec_.PutArg(arg0, right.taddr_); } } return result; } // 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_); bool var_left = Variable(left); bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; if( var_left ) { tape = left.tape_this(); if( var_right ) { tape->Rec_.PutArg(left.taddr_, right.taddr_); if( result ) tape->Rec_.PutOp(EqvvOp); else tape->Rec_.PutOp(NevvOp); } else { addr_t arg1 = tape->Rec_.PutPar(right.value_); tape->Rec_.PutArg(arg1, left.taddr_); if( result ) tape->Rec_.PutOp(EqpvOp); else tape->Rec_.PutOp(NepvOp); } } else if ( var_right ) { tape = right.tape_this(); addr_t arg0 = tape->Rec_.PutPar(left.value_); tape->Rec_.PutArg(arg0, right.taddr_); if( result ) tape->Rec_.PutOp(EqpvOp); else tape->Rec_.PutOp(NepvOp); } return result; } // 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_); bool var_left = Variable(left); bool var_right = Variable(right); ADTape *tape = CPPAD_NULL; if( var_left ) { tape = left.tape_this(); if( var_right ) { tape->Rec_.PutArg(left.taddr_, right.taddr_); if( result ) tape->Rec_.PutOp(NevvOp); else tape->Rec_.PutOp(EqvvOp); } else { addr_t arg1 = tape->Rec_.PutPar(right.value_); tape->Rec_.PutArg(arg1, left.taddr_); if( result ) tape->Rec_.PutOp(NepvOp); else tape->Rec_.PutOp(EqpvOp); } } else if ( var_right ) { tape = right.tape_this(); addr_t arg0 = tape->Rec_.PutPar(left.value_); tape->Rec_.PutArg(arg0, right.taddr_); if( result ) tape->Rec_.PutOp(NepvOp); else tape->Rec_.PutOp(EqpvOp); } return result; } // convert other cases into the case above CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(!=) } // END CppAD namespace # endif cppad-20160000.1/cppad/local/base_limits.hpp0000644000175200017650000000403512656321767017625 0ustar coincoin-web// $Id$ # ifndef CPPAD_BASE_LIMITS_HPP # define CPPAD_BASE_LIMITS_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin base_limits$$ $spell std namespace CppAD $$ $section Base Type Requirements for Numeric Limits$$ $head CppAD::numeric_limits$$ A specialization for $cref/CppAD::numeric_limits/numeric_limits/$$ must be defined in order to use the type $codei%AD<%Base%>%$$. CppAD does not use a specialization of $codei%std::numeric_limits<%Base%>%$$. Since C++11, using a specialization of $codei%std::numeric_limits<%Base%>%$$ would require that $icode Base$$ be a literal type. $head CPPAD_NUMERIC_LIMITS$$ In most cases, this macro can be used to define the specialization where the numeric limits for the type $icode Base$$ are the same as the standard numeric limits for the type $icode Other$$. For most $icode Base$$ types, there is a choice of $icode Other$$, for which the following preprocessor macro invocation suffices: $codei% namespace CppAD { CPPAD_NUMERIC_LIMITS(%Other%, %Base%) } %$$ where the macro is defined by $codep */ # define CPPAD_NUMERIC_LIMITS(Other, Base) \ template <> class numeric_limits\ {\ public:\ static Base min(void) \ { return static_cast( std::numeric_limits::min() ); }\ static Base max(void) \ { return static_cast( std::numeric_limits::max() ); }\ static Base epsilon(void) \ { return static_cast( std::numeric_limits::epsilon() ); }\ static Base quiet_NaN(void) \ { return static_cast( std::numeric_limits::quiet_NaN() ); }\ }; /* $$ $end */ # endif cppad-20160000.1/cppad/local/sqrt_op.hpp0000644000175200017650000001120112656321767017012 0ustar coincoin-web// $Id: sqrt_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SQRT_OP_HPP # define CPPAD_SQRT_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary1_op */ template inline 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); for(k = 1; k < j; k++) z[j] -= Base(k) * z[k] * z[j-k]; z[j] /= Base(j); z[j] += x[j] / Base(2); 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 forward_unary1_op_dir */ template inline 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); for(size_t k = 1; k < q; k++) z[m+ell] -= Base(k) * z[(k-1)*r+1+ell] * z[(q-k-1)*r+1+ell]; z[m+ell] /= Base(q); z[m+ell] += x[m+ell] / Base(2); 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 forward_unary1_op_0 */ template inline 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 reverse_unary1_op */ template inline 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) / 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); for(k = 1; k < j; k++) pz[k] -= azmul(pz[j], z[j-k]); --j; } px[0] += azmul(pz[0], inv_z0) / Base(2); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/set_get_in_parallel.hpp0000644000175200017650000000416612656321767021333 0ustar coincoin-web// $Id$ # ifndef CPPAD_SET_GET_IN_PARALLEL_HPP # define CPPAD_SET_GET_IN_PARALLEL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file set_get_in_parallel.hpp File used to set and get user in_parallel routine. */ /*! Set and call the routine that determine if we are in parallel execution mode. \return value retuned by most recent setting for in_parallel_new. If set is true, or the most recent setting is CPPAD_NULL (its initial value), the return value is false. Otherwise the function corresponding to the most recent setting is called and its value returned by set_get_in_parallel. \param in_parallel_new [in] If set is false, in_parallel_new it is not used. Otherwise, the current value of in_parallel_new becomes the most recent setting for in_parallel_user. \param set If set is true, then parallel_new is becomes the most recent setting for this set_get_in_parallel. In this case, it is assumed that we are currently in sequential execution mode. */ static bool set_get_in_parallel( bool (*in_parallel_new)(void) , bool set = false ) { static bool (*in_parallel_user)(void) = CPPAD_NULL; if( set ) { in_parallel_user = in_parallel_new; // Doing a raw assert in this case because set_get_in_parallel is used // by ErrorHandler and hence cannot use ErrorHandler. // CPPAD_ASSERT_UNKNOWN( in_parallel_user() == false ) assert(in_parallel_user == CPPAD_NULL || in_parallel_user() == false); return false; } // if( in_parallel_user == CPPAD_NULL ) return false; // return in_parallel_user(); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/abs.hpp0000644000175200017650000000552712656321767016106 0ustar coincoin-web// $Id: abs.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ABS_HPP # define CPPAD_ABS_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin 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/abs.cpp %$$ The file $cref abs.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- */ // BEGIN CppAD namespace namespace CppAD { template AD AD::Abs (void) const { AD result; result.value_ = abs(value_); CPPAD_ASSERT_UNKNOWN( Parameter(result) ); if( Variable(*this) ) { // add this operation to the tape CPPAD_ASSERT_UNKNOWN( NumRes(AbsOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(AbsOp) == 1 ); ADTape *tape = tape_this(); // corresponding operand address tape->Rec_.PutArg(taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(AbsOp); // make result a variable result.tape_id_ = tape->id_; } return result; } template inline AD abs(const AD &x) { return x.Abs(); } template inline AD abs(const VecAD_reference &x) { return abs( x.ADBase() ); } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/sin_op.hpp0000644000175200017650000001440512656321767016623 0ustar coincoin-web// $Id: sin_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SIN_OP_HPP # define CPPAD_SIN_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary2_op */ template inline 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); c[j] = Base(0); for(k = 1; k <= j; k++) { s[j] += Base(k) * x[k] * c[j-k]; c[j] -= Base(k) * x[k] * s[j-k]; } s[j] /= Base(j); c[j] /= Base(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 forward_unary2_op_dir */ template inline 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(q) * x[m + ell] * c[0]; c[m+ell] = - Base(q) * x[m + ell] * s[0]; for(size_t k = 1; k < q; k++) { s[m+ell] += Base(k) * x[(k-1)*r+1+ell] * c[(q-k-1)*r+1+ell]; c[m+ell] -= Base(k) * x[(k-1)*r+1+ell] * s[(q-k-1)*r+1+ell]; } s[m+ell] /= Base(q); c[m+ell] /= Base(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 forward_unary2_op_0 */ template inline 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 reverse_unary2_op */ template inline 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(j); pc[j] /= Base(j); for(k = 1; k <= j; k++) { px[k] += Base(k) * azmul(ps[j], c[j-k]); px[k] -= Base(k) * azmul(pc[j], s[j-k]); ps[j-k] -= Base(k) * azmul(pc[j], x[k]); pc[j-k] += Base(k) * azmul(ps[j], x[k]); } --j; } px[0] += azmul(ps[0], c[0]); px[0] -= azmul(pc[0], s[0]); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/sinh_op.hpp0000644000175200017650000001443412656321767016775 0ustar coincoin-web// $Id: sinh_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SINH_OP_HPP # define CPPAD_SINH_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary2_op */ template inline 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); c[j] = Base(0); for(k = 1; k <= j; k++) { s[j] += Base(k) * x[k] * c[j-k]; c[j] += Base(k) * x[k] * s[j-k]; } s[j] /= Base(j); c[j] /= Base(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 forward_unary2_op_dir */ template inline 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(q) * x[m + ell] * c[0]; c[m+ell] = Base(q) * x[m + ell] * s[0]; for(size_t k = 1; k < q; k++) { s[m+ell] += Base(k) * x[(k-1)*r+1+ell] * c[(q-k-1)*r+1+ell]; c[m+ell] += Base(k) * x[(k-1)*r+1+ell] * s[(q-k-1)*r+1+ell]; } s[m+ell] /= Base(q); c[m+ell] /= Base(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 forward_unary2_op_0 */ template inline 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 reverse_unary2_op */ template inline 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(j); pc[j] /= Base(j); for(k = 1; k <= j; k++) { px[k] += Base(k) * azmul(ps[j], c[j-k]); px[k] += Base(k) * azmul(pc[j], s[j-k]); ps[j-k] += Base(k) * azmul(pc[j], x[k]); pc[j-k] += Base(k) * azmul(ps[j], x[k]); } --j; } px[0] += azmul(ps[0], c[0]); px[0] += azmul(pc[0], s[0]); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/dependent.hpp0000644000175200017650000002203012656321767017273 0ustar coincoin-web// $Id: dependent.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DEPENDENT_HPP # define CPPAD_DEPENDENT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Dependent$$ $spell alloc num taylor_ ADvector const $$ $spell $$ $section Stop Recording and Store Operation Sequence$$ $mindex ADFun tape Dependent$$ $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^n \rightarrow B^m \] $$ where $latex B$$ is the space corresponding to objects of type $icode Base$$. The value $latex n$$ is the dimension of the $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. It returns true if it succeeds and false otherwise. $end ---------------------------------------------------------------------------- */ // BEGIN CppAD namespace namespace CppAD { /*! \file dependent.hpp Different versions of Dependent function. */ /*! Determine the \c 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) { 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 \c 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." ); 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(ADTape *tape, const ADvector &y) { size_t m = y.size(); size_t n = tape->size_independent_; size_t i, j; size_t y_taddr; // 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( NumRes(ParOp) == 1 ); dep_parameter_.resize(m); dep_taddr_.resize(m); for(i = 0; i < m; i++) { dep_parameter_[i] = CppAD::Parameter(y[i]); if( dep_parameter_[i] ) { // make a tape copy of dependent variables that are parameters, y_taddr = tape->RecordParOp( y[i].value_ ); } else y_taddr = y[i].taddr_; CPPAD_ASSERT_UNKNOWN( y_taddr > 0 ); dep_taddr_[i] = y_taddr; } // put an EndOp at the end of the tape tape->Rec_.PutOp(EndOp); // some size_t values in ad_fun.hpp has_been_optimized_ = false; compare_change_count_ = 1; compare_change_number_ = 0; compare_change_op_index_ = 0; num_order_taylor_ = 0; num_direction_taylor_ = 0; cap_order_taylor_ = 0; // num_var_tape_ // Now that all the variables are in the tape, we can set this value. num_var_tape_ = tape->Rec_.num_var_rec(); // taylor_ taylor_.erase(); // cskip_op_ cskip_op_.erase(); cskip_op_.extend( tape->Rec_.num_op_rec() ); // load_op_ load_op_.erase(); load_op_.extend( 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 tape. play_.get(tape->Rec_); // 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(j = 0; j < n; j++) { CPPAD_ASSERT_UNKNOWN( play_.GetOp(j+1) == 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); // --------------------------------------------------------------------- // End set ad_fun.hpp private member data // --------------------------------------------------------------------- // now we can delete the tape AD::tape_manage(tape_manage_delete); // 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 cppad-20160000.1/cppad/local/atanh_op.hpp0000644000175200017650000001374112656321767017127 0ustar coincoin-web// $Id$ # ifndef CPPAD_ATANH_OP_HPP # define CPPAD_ATANH_OP_HPP # if CPPAD_USE_CPLUSPLUS_2011 /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file atanh_op.hpp Forward and reverse mode calculations for z = atanh(x). */ /*! Forward mode Taylor coefficient for result of op = AtanhOp. The C++ source code corresponding to this operation is \verbatim z = atanh(x) \endverbatim The auxillary result is \verbatim y = 1 - x * x \endverbatim The value of y, and its derivatives, are computed along with the value and derivatives of z. \copydetails forward_unary2_op */ template inline void forward_atanh_op( size_t p , size_t q , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AtanhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AtanhOp) == 2 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; Base* b = z - cap_order; // called y in documentation size_t k; if( p == 0 ) { z[0] = atanh( x[0] ); b[0] = Base(1) - x[0] * x[0]; p++; } for(size_t j = p; j <= q; j++) { b[j] = - Base(2) * x[0] * x[j]; z[j] = Base(0); for(k = 1; k < j; k++) { b[j] -= x[k] * x[j-k]; z[j] -= Base(k) * z[k] * b[j-k]; } z[j] /= Base(j); z[j] += x[j]; z[j] /= b[0]; } } /*! Multiple direction Taylor coefficient for op = AtanhOp. The C++ source code corresponding to this operation is \verbatim z = atanh(x) \endverbatim The auxillary result is \verbatim y = 1 - x * x \endverbatim The value of y, and its derivatives, are computed along with the value and derivatives of z. \copydetails forward_unary2_op_dir */ template inline void forward_atanh_op_dir( size_t q , size_t r , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AtanhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AtanhOp) == 2 ); CPPAD_ASSERT_UNKNOWN( 0 < q ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); // Taylor coefficients corresponding to argument and result size_t num_taylor_per_var = (cap_order-1) * r + 1; Base* x = taylor + i_x * num_taylor_per_var; Base* z = taylor + i_z * num_taylor_per_var; Base* b = z - num_taylor_per_var; // called y in documentation size_t m = (q-1) * r + 1; for(size_t ell = 0; ell < r; ell++) { b[m+ell] = - Base(2) * x[m+ell] * x[0]; z[m+ell] = Base(q) * x[m+ell]; for(size_t k = 1; k < q; k++) { b[m+ell] -= x[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; z[m+ell] -= Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; } z[m+ell] /= ( Base(q) * b[0] ); } } /*! Zero order forward mode Taylor coefficient for result of op = AtanhOp. The C++ source code corresponding to this operation is \verbatim z = atanh(x) \endverbatim The auxillary result is \verbatim y = 1 - x * x \endverbatim The value of y is computed along with the value of z. \copydetails forward_unary2_op_0 */ template inline void forward_atanh_op_0( size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AtanhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AtanhOp) == 2 ); CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; Base* b = z - cap_order; // called y in documentation z[0] = atanh( x[0] ); b[0] = Base(1) - x[0] * x[0]; } /*! Reverse mode partial derivatives for result of op = AtanhOp. The C++ source code corresponding to this operation is \verbatim z = atanh(x) \endverbatim The auxillary result is \verbatim y = 1 - x * x \endverbatim The value of y is computed along with the value of z. \copydetails reverse_unary2_op */ template inline void reverse_atanh_op( size_t d , size_t i_z , size_t i_x , size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AtanhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AtanhOp) == 2 ); CPPAD_ASSERT_UNKNOWN( d < cap_order ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // Taylor coefficients and partials corresponding to argument const Base* x = taylor + i_x * cap_order; Base* px = partial + i_x * nc_partial; // Taylor coefficients and partials corresponding to first result const Base* z = taylor + i_z * cap_order; Base* pz = partial + i_z * nc_partial; // Taylor coefficients and partials corresponding to auxillary result const Base* b = z - cap_order; // called y in documentation Base* pb = pz - nc_partial; Base inv_b0 = Base(1) / b[0]; // number of indices to access size_t j = d; size_t k; while(j) { // scale partials w.r.t z[j] and b[j] pz[j] = azmul(pz[j], inv_b0); pb[j] *= Base(2); pb[0] -= azmul(pz[j], z[j]); px[j] += pz[j] - azmul(pb[j], x[0]); px[0] -= azmul(pb[j], x[j]); // more scaling of partials w.r.t z[j] pz[j] /= Base(j); for(k = 1; k < j; k++) { pb[j-k] -= Base(k) * azmul(pz[j], z[k]); pz[k] -= Base(k) * azmul(pz[j], b[j-k]); px[k] -= azmul(pb[j], x[j-k]); } --j; } px[0] += azmul(pz[0], inv_b0) - Base(2) * azmul(pb[0], x[0]); } } // END_CPPAD_NAMESPACE # endif # endif cppad-20160000.1/cppad/local/testvector.hpp0000644000175200017650000000621612656321767017537 0ustar coincoin-web// $Id: testvector.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_TESTVECTOR_HPP # define CPPAD_TESTVECTOR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin testvector$$ $spell CppAD cmake testvector cppad Eigen ifdef hpp std endif ublas $$ $section Using The CppAD Test Vector Template Class$$ $mindex CPPAD_TESTVECTOR$$ $head Syntax$$ $codei%CPPAD_TESTVECTOR(%Scalar%) %$$ $head Introduction$$ Many of the CppAD $cref/examples/example/$$ and tests use the $code CPPAD_TESTVECTOR$$ template class to pass information to CppAD. This is not a true template class because it's syntax uses $codei%(%Scalar%)%$$ instead of $codei%<%Scalar%>%$$. This enables us to use $codei% Eigen::Matrix<%Scalar%, Eigen::Dynamic, 1> %$$ as one of the possible cases for this 'template class'. $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: $codep */ # 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: $codep */ # 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: $codep */ # 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 Eigen Vectors$$ 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: $codep */ # if CPPAD_EIGENVECTOR # include # 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. $end ------------------------------------------------------------------------ */ # endif cppad-20160000.1/cppad/local/tape_link.hpp0000644000175200017650000002360712656321767017306 0ustar coincoin-web// $Id: tape_link.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_TAPE_LINK_HPP # define CPPAD_TAPE_LINK_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include // 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 ADTape Objects. The routines that connect the AD class to the corresponding tapes (one for each thread). */ /*! Handle 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 handle to the tape identifier for this thread and AD class. */ template inline tape_id_t** AD::tape_id_handle(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; } /*! 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; i.e., \code thread == thread_alloc::thread_num() \endcode If this condition is not satisfied, and \c NDEBUG is not defined, a CPPAD_ASSERT_UNKNOWN is generated. \return is a pointer to the tape identifier for this thread and AD class. \par Restrictions This routine should only be called if there was a tape created for the specified thread (it may no longer be recording). */ template inline tape_id_t* AD::tape_id_ptr(size_t thread) { CPPAD_ASSERT_UNKNOWN( *tape_id_handle(thread) != CPPAD_NULL ) return *tape_id_handle(thread); } /*! 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 == thread_alloc::thread_num() \endcode If this condition is not satisfied, and \c NDEBUG is not defined, a CPPAD_ASSERT_UNKNOWN is generated. \return is a handle for the AD class and the specified thread. */ template inline ADTape** AD::tape_handle(size_t thread) { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; static ADTape* tape_table[CPPAD_MAX_NUM_THREADS]; CPPAD_ASSERT_UNKNOWN( 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 \c CPPAD_NULL, there is no tape currently recording AD operations for this thread. */ template inline 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 \c CPPAD_NULL). \par Restrictions This routine should only be called if there is a tape recording operaitons for the specified thread. */ template inline 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. - \c tape_manage_new : Creates and a new tape. It is assumed that there is no tape recording AD operations for this thread when \c tape_manage is called. It the input value of *tape_id_handle(thread) is \c CPPAD_NULL, it will be changed to a non-zero pointer and the corresponding value of *tape_id_ptr(thread) will be set to thread + CPPAD_MAX_NUM_THREADS. - \c tape_manage_delete : It is assumed that there is a tape recording AD operations for this thread when \c tape_manage is called. The value of *tape_id_ptr(thread) will be advanced by \c CPPAD_MAX_NUM_THREADS. \return - job == tape_manage_new: a pointer to the new tape is returned. - job == tape_manage_delete: the value \c CPPAD_NULL is returned. */ template ADTape* AD::tape_manage(tape_manage_job job) { // this routine has static variables so first call cannot be in parallel CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL // The tape for the master thread static ADTape tape_zero; // Pointer to the tape for each thread static ADTape* tape_table[CPPAD_MAX_NUM_THREADS]; // The id current being used for each of the tapes static tape_id_t tape_id_save[CPPAD_MAX_NUM_THREADS]; // Thread corresponding to this call size_t thread = thread_alloc::thread_num(); // tape_manage_clear if( job == tape_manage_clear ) { // This operation cannot be done in parallel CPPAD_ASSERT_UNKNOWN(thread == 0 && (! thread_alloc::in_parallel())); for(thread = 0; thread < CPPAD_MAX_NUM_THREADS; thread++) { // if this thread has a tape if( tape_table[thread] != CPPAD_NULL ) { // id corresponding to this thread tape_id_save[thread] = tape_table[thread]->id_; *tape_id_handle(thread) = &tape_id_save[thread]; // delete all but the master thread if( thread != 0 ) delete( tape_table[thread] ); // set the tape pointer to null tape_table[thread] = CPPAD_NULL; } } return CPPAD_NULL; } // id and tape fpor this thread tape_id_t** tape_id = tape_id_handle(thread); ADTape** tape = tape_handle(thread); // check if there is no tape currently attached to this thread if( tape_table[thread] == CPPAD_NULL ) { // allocate separate memroy to avoid false sharing if( thread == 0 ) { // mastert tape is a static in this routine tape_table[thread] = &tape_zero; } else { // other tapes are allocated tape_table[thread] = new ADTape(); } // current id and pointer to this tape tape_table[thread]->id_ = tape_id_save[thread]; *tape_id = &tape_table[thread]->id_; // if id is zero, initialize it so that // thread == tape id % CPPAD_MAX_NUM_THREADS if( **tape_id == 0 ) **tape_id = thread + CPPAD_MAX_NUM_THREADS; } // make sure tape_id_handle(thread) is pointing to the proper place CPPAD_ASSERT_UNKNOWN( *tape_id == &tape_table[thread]->id_ ); // make sure tape_id value is valid for this thread CPPAD_ASSERT_UNKNOWN( size_t( **tape_id % CPPAD_MAX_NUM_THREADS ) == thread ); switch(job) { case tape_manage_new: // tape for this thread must be null at the start CPPAD_ASSERT_UNKNOWN( *tape == CPPAD_NULL ); *tape = tape_table[thread]; break; case tape_manage_delete: CPPAD_ASSERT_UNKNOWN( *tape == tape_table[thread] ); CPPAD_ASSERT_KNOWN( std::numeric_limits::max() - CPPAD_MAX_NUM_THREADS > **tape_id, "To many different tapes given the type used for " "CPPAD_TAPE_ID_TYPE" ); // advance tape identfier so all AD variables become parameters **tape_id += CPPAD_MAX_NUM_THREADS; // free memory corresponding to recording in the old tape tape_table[thread]->Rec_.free(); // inform rest of CppAD that no tape recording for this thread *tape = CPPAD_NULL; break; case tape_manage_clear: CPPAD_ASSERT_UNKNOWN(false); } return *tape; } /*! 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 \c CPPAD_NULL; i.e., there must be a tape currently recording AD operations for this thread. */ template inline ADTape *AD::tape_this(void) const { size_t thread = size_t( tape_id_ % CPPAD_MAX_NUM_THREADS ); CPPAD_ASSERT_UNKNOWN( tape_id_ == *tape_id_ptr(thread) ); CPPAD_ASSERT_UNKNOWN( *tape_handle(thread) != CPPAD_NULL ); return *tape_handle(thread); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/exp_op.hpp0000644000175200017650000001131612656321767016624 0ustar coincoin-web// $Id: exp_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_EXP_OP_HPP # define CPPAD_EXP_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary1_op */ template inline 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(k) * x[k] * z[j-k]; z[j] /= Base(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 forward_unary1_op_dir */ template inline 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(q) * x[m+ell] * z[0]; for(size_t k = 1; k < q; k++) z[m+ell] += Base(k) * x[(k-1)*r+ell+1] * z[(q-k-1)*r+ell+1]; z[m+ell] /= Base(q); } } /*! 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 forward_unary1_op_0 */ template inline 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 reverse_unary1_op */ template inline 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(j); for(k = 1; k <= j; k++) { px[k] += Base(k) * azmul(pz[j], z[j-k]); pz[j-k] += Base(k) * azmul(pz[j], x[k]); } --j; } px[0] += azmul(pz[0], z[0]); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/forward.hpp0000644000175200017650000003015112656321767016774 0ustar coincoin-web// $Id: forward.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FORWARD_HPP # define CPPAD_FORWARD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ // documened after Forward but included here so easy to see # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 VectorBase 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 VectorBase ADFun::Forward( size_t q , const VectorBase& xq , std::ostream& s ) { // 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_; // 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] ) == 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 ) { forward0sweep(s, true, n, num_var_tape_, &play_, C, taylor_.data(), cskip_op_.data(), load_op_, compare_change_count_, compare_change_number_, compare_change_op_index_ ); } else { forward1sweep(s, true, p, q, n, num_var_tape_, &play_, C, taylor_.data(), cskip_op_.data(), load_op_, compare_change_count_, compare_change_number_, compare_change_op_index_ ); } // return Taylor coefficients for dependent variables VectorBase 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 VectorBase 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, \c r must be the same as in the previous call to Forward where \c 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 \c 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 \c 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 VectorBase ADFun::Forward( size_t q , size_t r , const VectorBase& xq ) { // 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] ) == 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() ); forward2sweep( q, r, n, num_var_tape_, &play_, c, taylor_.data(), cskip_op_.data(), load_op_ ); // return Taylor coefficients for dependent variables VectorBase 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 cppad-20160000.1/cppad/local/rev_sparse_hes.hpp0000644000175200017650000005405312656321767020347 0ustar coincoin-web// $Id: rev_sparse_hes.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_REV_SPARSE_HES_HPP # define CPPAD_REV_SPARSE_HES_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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$$ the sparsity pattern is valid for all values of the independent variables in $latex x \in \B{R}^n$$ (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/VectorSet/RevSparseHes/VectorSet/$$ must be the same as the type of the elements of $icode r$$. $head s$$ The argument $icode s$$ has prototype $codei% const %VectorSet%& %s% %$$ (see $cref/VectorSet/RevSparseHes/VectorSet/$$ 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% %VectorSet%& %h% %$$ (see $cref/VectorSet/RevSparseHes/VectorSet/$$ 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 VectorSet$$ The type $icode VectorSet$$ 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/VectorSet/RevSparseHes/VectorSet/$$ 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/rev_sparse_hes.cpp %example/sparsity_sub.cpp %$$ The file $cref rev_sparse_hes.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. The file $cref/sparsity_sub.cpp/sparsity_sub.cpp/RevSparseHes/$$ contains an example and test of using $code RevSparseHes$$ to compute the sparsity pattern for a subset of the Hessian. $end ----------------------------------------------------------------------------- */ # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file rev_sparse_hes.hpp Reverse mode Hessian sparsity patterns. */ // =========================================================================== // RevSparseHesBool /*! Calculate Hessian sparsity patterns using reverse mode. The C++ source code corresponding to this operation is \verbatim h = f.RevSparseHes(q, s) \endverbatim \tparam Base is the base type for this recording. \tparam VectorSet is a simple vector with elements of type \c bool. \param transpose is true (false) if \c 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 \a x is any argument value. \param q is the value of \a q in the by the previous call of the form \verbatim f.ForSparseJac(q, r) \endverbatim The value \c r in this call is a sparsity pattern for the matrix \f$ R \f$. \param s is a vector with size \c m that specifies the sparsity pattern for the vector \f$ S \f$, where \c m is the number of dependent variables corresponding to the operation sequence stored in \a play. \param h the input value of \a h must be a vector with size \c q*n. The input value of its elements does not matter. On output, \a h is the sparsity pattern for the matrix \f$ H(x) \f$ or \f$ H(x)^T \f$ depending on \c transpose. \param num_var is the total number of variables in this recording. \param dep_taddr maps dependendent variable index to the corresponding variable in the tape. \param ind_taddr maps independent variable index to the corresponding variable in the tape. \param play is the recording that defines the function we are computing the sparsity pattern for. \param for_jac_sparsity is a vector of sets containing the the forward Jacobian sparsity pattern corresponding to $latex R$$ for all of the variables on the tape. */ template void RevSparseHesBool( bool transpose , size_t q , const VectorSet& s , VectorSet& h , size_t num_var , CppAD::vector& dep_taddr , CppAD::vector& ind_taddr , CppAD::player& play , sparse_pack& for_jac_sparsity ) { // temporary indices size_t i, j; // check Vector is Simple VectorSet class with bool elements CheckSimpleVector(); // range and domain dimensions for F size_t m = dep_taddr.size(); size_t n = ind_taddr.size(); CPPAD_ASSERT_KNOWN( q == for_jac_sparsity.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. pod_vector RevJac; RevJac.extend(num_var); for(i = 0; i < num_var; i++) RevJac[i] = false; for(i = 0; i < m; i++) { CPPAD_ASSERT_UNKNOWN( dep_taddr[i] < num_var ); RevJac[ dep_taddr[i] ] = s[i]; } // vector of sets that will hold reverse Hessain values sparse_pack rev_hes_sparsity; rev_hes_sparsity.resize(num_var, q); // compute the Hessian sparsity patterns RevHesSweep( n, num_var, &play, for_jac_sparsity, RevJac.data(), rev_hes_sparsity ); // 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 ); // ind_taddr[j] is operator taddr for j-th independent variable CPPAD_ASSERT_UNKNOWN( ind_taddr[j] == j + 1 ); CPPAD_ASSERT_UNKNOWN( play.GetOp( ind_taddr[j] ) == InvOp ); // extract the result from rev_hes_sparsity CPPAD_ASSERT_UNKNOWN( rev_hes_sparsity.end() == q ); rev_hes_sparsity.begin(j + 1); i = rev_hes_sparsity.next_element(); while( i < q ) { if( transpose ) h[ j * q + i ] = true; else h[ i * n + j ] = true; i = rev_hes_sparsity.next_element(); } } return; } // =========================================================================== // RevSparseHesSet /*! Calculate Hessian sparsity patterns using reverse mode. The C++ source code corresponding to this operation is \verbatim h = f.RevSparseHes(q, s) \endverbatim \tparam Base is the base type for this recording. \tparam VectorSet is a simple vector with elements of type \c std::set. \param transpose is true (false) if \c 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 \a x is any argument value. \param q is the value of \a q in the by the previous call of the form \verbatim f.ForSparseJac(q, r) \endverbatim The value \c r in this call is a sparsity pattern for the matrix \f$ R \f$. \param s is a vector with size \c m that specifies the sparsity pattern for the vector \f$ S \f$, where \c m is the number of dependent variables corresponding to the operation sequence stored in \a play. \param h If \c transpose, the input value of \a h must be a vector with size \a q. Otherwise, its input value must have size \c n; On input, each element of \a h must be an empty set. On output, \a h is the sparsity pattern for the matrix \f$ H(x) \f$ or \f$ H(x)^T \f$ depending on \c transpose. \param num_var is the total number of variables in this recording. \param dep_taddr maps dependendent variable index to the corresponding variable in the tape. \param ind_taddr maps independent variable index to the corresponding variable in the tape. \param play is the recording that defines the function we are computing the sparsity pattern for. \param for_jac_sparsity is a vector of sets containing the the forward Jacobian sparsity pattern corresponding to $latex R$$ for all of the variables on the tape. */ template void RevSparseHesSet( bool transpose , size_t q , const VectorSet& s , VectorSet& h , size_t num_var , CppAD::vector& dep_taddr , CppAD::vector& ind_taddr , CppAD::player& play , CPPAD_INTERNAL_SPARSE_SET& for_jac_sparsity ) { // temporary indices size_t i, j; std::set::const_iterator itr; // check VectorSet is Simple Vector class with sets for elements CheckSimpleVector, VectorSet>( one_element_std_set(), two_element_std_set() ); // range and domain dimensions for F # ifndef NDEBUG size_t m = dep_taddr.size(); # endif size_t n = ind_taddr.size(); CPPAD_ASSERT_KNOWN( q == for_jac_sparsity.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. pod_vector RevJac; RevJac.extend(num_var); for(i = 0; i < num_var; i++) RevJac[i] = false; itr = s[0].begin(); while( itr != s[0].end() ) { i = *itr++; 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 ); RevJac[ dep_taddr[i] ] = true; } // vector of sets that will hold reverse Hessain values CPPAD_INTERNAL_SPARSE_SET rev_hes_sparsity; rev_hes_sparsity.resize(num_var, q); // compute the Hessian sparsity patterns RevHesSweep( n, num_var, &play, for_jac_sparsity, RevJac.data(), rev_hes_sparsity ); // 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 ); CPPAD_ASSERT_UNKNOWN( ind_taddr[j] == j + 1 ); CPPAD_ASSERT_UNKNOWN( play.GetOp( ind_taddr[j] ) == InvOp ); // extract the result from rev_hes_sparsity // and add corresponding elements to result sets in h CPPAD_ASSERT_UNKNOWN( rev_hes_sparsity.end() == q ); rev_hes_sparsity.begin(j+1); i = rev_hes_sparsity.next_element(); while( i < q ) { if( transpose ) h[j].insert(i); else h[i].insert(j); i = rev_hes_sparsity.next_element(); } } return; } // =========================================================================== // 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 VectorSet is a simple vector with elements of type \c bool or \c std::set. \param transpose is true (false) if \c 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 \a x is any argument value. \param q is the value of \a q in the by the previous call of the form \verbatim f.ForSparseJac(q, r, packed) \endverbatim The value \c r in this call is a sparsity pattern for the matrix \f$ R \f$. The type of the element of \c r for the previous call to \c ForSparseJac must be the same as the type of the elements of \c s. \param s is a vector with size \c m that specifies the sparsity pattern for the vector \f$ S \f$, where \c m is the number of dependent variables corresponding to the operation sequence stored in \a play. \return If \c transpose is false (true), the return vector is a sparsity pattern for \f$ H(x) \f$ (\f$ H(x)^T \f$). \f[ H(x) = R^T ( S * F)^{(2)} (x) \f] where \f$ F \f$ is the function corresponding to the operation sequence and \a x is any argument value. */ template template VectorSet ADFun::RevSparseHes( size_t q, const VectorSet& s, bool transpose ) { VectorSet h; typedef typename VectorSet::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; } // =========================================================================== // RevSparseHesCase /*! Private helper function for RevSparseHes(q, s). All of the description in the public member function RevSparseHes(q, s) applies. \param set_type is a \c bool value. This argument is used to dispatch to the proper source code depending on the vlaue of \c VectorSet::value_type. \param transpose See \c RevSparseHes(q, s). \param q See \c RevSparseHes(q, s). \param s See \c RevSparseHes(q, s). \param h is the return value for the corresponging call to \c RevSparseJac(q, s). */ template template void ADFun::RevSparseHesCase( bool set_type , bool transpose , size_t q , const VectorSet& s , VectorSet& h ) { size_t n = Domain(); 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_ ); // use sparse_pack for the calculation CppAD::RevSparseHesBool( transpose , q , s , h , num_var_tape_ , dep_taddr_ , ind_taddr_ , play_ , for_jac_sparse_pack_ ); } /*! Private helper function for RevSparseHes(q, s). All of the description in the public member function RevSparseHes(q, s) applies. \param set_type is a \c std::set value. This argument is used to dispatch to the proper source code depending on the vlaue of \c VectorSet::value_type. \param transpose See \c RevSparseHes(q, s). \param q See \c RevSparseHes(q, s). \param s See \c RevSparseHes(q, s). \param h is the return value for the corresponging call to \c RevSparseJac(q, s). */ template template void ADFun::RevSparseHesCase( const std::set& set_type , bool transpose , size_t q , const VectorSet& s , VectorSet& h ) { size_t n = Domain(); 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_ ); // use sparse_pack for the calculation CppAD::RevSparseHesSet( transpose , q , s , h , num_var_tape_ , dep_taddr_ , ind_taddr_ , play_ , for_jac_sparse_set_ ); } // =========================================================================== // RevSparseHesCheckpoint /*! Hessian sparsity patterns calculation used by checkpoint functions. \tparam Base is the base type for this recording. \param transpose is true (false) h is equal to \f$ H(x) \f$ (\f$ H(x)^T \f$) where \f[ H(x) = R^T (S * F)^{(2)} (x) \f] where \f$ F \f$ is the function corresponding to the operation sequence and \f$ x \f$ is any argument value. \param q is the value of q in the by the previous call of the form \verbatim f.ForSparseJac(q, r) \endverbatim The value r in this call is a sparsity pattern for the matrix \f$ R \f$. \param s is a vector with size m that specifies the sparsity pattern for the vector \f$ S \f$, where m is the number of dependent variables corresponding to the operation sequence stored in play_. \param h The input size and elements of h do not matter. On output, h is the sparsity pattern for the matrix \f$ H(x) \f$ or \f$ H(x)^T \f$ depending on transpose. \par Assumptions The forward jacobian sparsity pattern must be currently stored in this ADFUN object. */ template void ADFun::RevSparseHesCheckpoint( size_t q , vector& s , bool transpose , CPPAD_INTERNAL_SPARSE_SET& h ) { size_t n = Domain(); size_t m = Range(); // checkpoint functions should get this right CPPAD_ASSERT_UNKNOWN( for_jac_sparse_pack_.n_set() == 0 ); CPPAD_ASSERT_UNKNOWN( for_jac_sparse_set_.n_set() == num_var_tape_ ); CPPAD_ASSERT_UNKNOWN( for_jac_sparse_set_.end() == q ); CPPAD_ASSERT_UNKNOWN( s.size() == m ); // Array that holds the reverse Jacobiain dependcy flags. // Initialize as true for dependent variables, flase for others. pod_vector RevJac; RevJac.extend(num_var_tape_); for(size_t i = 0; i < num_var_tape_; i++) RevJac[i] = false; for(size_t i = 0; i < m; i++) { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ) RevJac[ dep_taddr_[i] ] = s[i]; } // holds reverse Hessian sparsity pattern for all variables CPPAD_INTERNAL_SPARSE_SET rev_hes_sparsity; rev_hes_sparsity.resize(num_var_tape_, q); // compute Hessian sparsity pattern for all variables RevHesSweep( n, num_var_tape_, &play_, for_jac_sparse_set_, RevJac.data(), rev_hes_sparsity ); // dimension the return value if( transpose ) h.resize(n, q); else h.resize(q, n); // j is index corresponding to reverse mode partial for(size_t j = 0; j < n; j++) { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] < num_var_tape_ ); // ind_taddr_[j] is operator taddr for j-th independent variable CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] == j + 1 ); CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[j] ) == InvOp ); // extract the result from rev_hes_sparsity CPPAD_ASSERT_UNKNOWN( rev_hes_sparsity.end() == q ); rev_hes_sparsity.begin(j + 1); size_t i = rev_hes_sparsity.next_element(); while( i < q ) { if( transpose ) h.add_element(j, i); else h.add_element(i, j); i = rev_hes_sparsity.next_element(); } } } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/jacobian.hpp0000644000175200017650000001323312656321767017100 0ustar coincoin-web// $Id: jacobian.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_JACOBIAN_HPP # define CPPAD_JACOBIAN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Jacobian$$ $spell jac typename Taylor Jacobian DetLu const $$ $section Jacobian: Driver Routine$$ $mindex Jacobian first derivative$$ $head Syntax$$ $icode%jac% = %f%.Jacobian(%x%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The syntax above sets $icode 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/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); // loop through the different coordinate directions for(j = 0; j < n; j++) { // set u to the j-th coordinate direction u[j] = Base(1); // 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); // 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); // 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); } else { // set v to the i-th coordinate direction v[i] = Base(1); // compute the derivative of this component of f u = f.Reverse(1, v); // reset v to vector of all zeros v[i] = Base(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 ); if( workForward <= workReverse ) JacobianFor(*this, x, jac); else JacobianRev(*this, x, jac); return jac; } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/sparse_unary_op.hpp0000644000175200017650000001257712656321767020555 0ustar coincoin-web// $Id: sparse_unary_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_UNARY_OP_HPP # define CPPAD_SPARSE_UNARY_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 \c sparse_pack, \c sparse_set or \c sparse_list. \param i_z variable index corresponding to the result for this operation; i.e., z. \param i_x variable index corresponding to the argument for this operator; i.e., x. \param sparsity \b Input: The set with index \a arg[0] in \a sparsity is the sparsity bit pattern for x. This identifies which of the independent variables the variable x depends on. \n \n \b Output: The set with index \a i_z in \a sparsity is the sparsity bit pattern for z. This identifies which of the independent variables the variable z depends on. \n \par Checked Assertions: \li \a i_x < \a i_z */ template inline 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z variable index corresponding to the result for this operation; i.e. the row index in sparsity corresponding to z. \param i_x variable index corresponding to the argument for this operator; i.e. the row index in sparsity corresponding to x. \param sparsity \b Input: The set with index \a i_z in \a sparsity is the sparsity bit pattern for G with respect to the variable z. \n \b Input: The set with index \a i_x in \a sparsity is the sparsity bit pattern for G with respect to the variable x. \n \b Output: The set with index \a i_x in \a sparsity is the sparsity bit pattern for H with respect to the variable x. \par Checked Assertions: \li \a i_x < \a i_z */ template inline 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 reverse_sparse_hessian_unary_op */ template inline void reverse_sparse_hessian_linear_unary_op( size_t i_z , size_t i_x , bool* rev_jacobian , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) { // check assumptions CPPAD_ASSERT_UNKNOWN( i_x < i_z ); rev_hes_sparsity.binary_union(i_x, i_x, i_z, rev_hes_sparsity); rev_jacobian[i_x] |= rev_jacobian[i_z]; 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 reverse_sparse_hessian_unary_op */ template inline void reverse_sparse_hessian_nonlinear_unary_op( size_t i_z , size_t i_x , bool* rev_jacobian , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) { // check assumptions CPPAD_ASSERT_UNKNOWN( i_x < i_z ); rev_hes_sparsity.binary_union(i_x, i_x, i_z, rev_hes_sparsity); if( rev_jacobian[i_z] ) rev_hes_sparsity.binary_union(i_x, i_x, i_x, for_jac_sparsity); rev_jacobian[i_x] |= rev_jacobian[i_z]; return; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/sparse_hessian.hpp0000644000175200017650000005624012656321767020346 0ustar coincoin-web// $Id: sparse_hessian.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_HESSIAN_HPP # define CPPAD_SPARSE_HESSIAN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sparse_hessian$$ $spell jacobian recomputed CppAD valarray std Bool hes const Taylor cppad cmake colpack $$ $section Sparse Hessian: Easy Driver$$ $mindex SparseHessian$$ $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 %VectorBase%& %x% %$$ (see $cref/VectorBase/sparse_hessian/VectorBase/$$ 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 %VectorBase%& %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 %VectorSet%& %p% %$$ (see $cref/VectorSet/sparse_hessian/VectorSet/$$ 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)$$. $pre $$ If this sparsity pattern does not change between calls to $codei SparseHessian$$, it should be faster to calculate $icode p$$ once and pass this argument to $codei SparseHessian$$. Furthermore, if you specify $icode work$$ in the calling sequence, it is not necessary to keep the sparsity pattern; see the heading $cref/p/sparse_hessian/work/p/$$ under the $icode work$$ description. $pre $$ In addition, if you specify $icode p$$, CppAD will use the same type of sparsity representation (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 %VectorSize%& %row% const %VectorSize%& %col% %$$ (see $cref/VectorSize/sparse_hessian/VectorSize/$$ 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% %VectorBase% %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.star" %$$ This method requires that $cref colpack_prefix$$ was specified on the $cref/cmake command/cmake/CMake Command/$$ line. It also takes advantage of the fact that the Hessian matrix is symmetric. $subhead p$$ If $icode work$$ is present, and it is not the first call after its construction or a clear, the sparsity pattern $icode p$$ is not used. This enables one to free the sparsity pattern and still compute corresponding sparse Hessians. $head n_sweep$$ The return value $icode n_sweep$$ has prototype $codei% size_t %n_sweep% %$$ It is the number of first order forward sweeps 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 VectorBase$$ The type $icode VectorBase$$ 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 VectorSet$$ The type $icode VectorSet$$ 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 VectorSet$$ 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 VectorSize$$ The type $icode VectorSize$$ 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_hessian.cpp% example/sub_sparse_hes.cpp% example/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 routines $cref sub_sparse_hes.cpp$$ and $cref sparse_sub_hes.cpp$$ are examples and tests that compute a sparse Hessian for a subset of the variables. They return $code true$$, if they succeed and $code false$$ otherwise. $end ----------------------------------------------------------------------------- */ # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \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 VectorSize is \c sparse_pack, \c sparse_set or \c 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 \c SparseHessianCompute. If the sparsity pattern, \c row vector, or \c col vectors are not the same between calls to \c SparseHessianCompute, \c work.clear() must be called to reinitialize \c 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 VectorBase& x , const VectorBase& w , VectorSet& sparsity , const VectorSize& user_row , const VectorSize& user_col , VectorBase& hes , sparse_hessian_work& work ) { using CppAD::vectorBool; size_t i, k, ell; CppAD::vector& row(work.row); CppAD::vector& col(work.col); CppAD::vector& color(work.color); CppAD::vector& order(work.order); size_t n = Domain(); // some values const Base zero(0); const Base one(1); // check VectorBase is Simple Vector class with Base type elements CheckSimpleVector(); // number of components of Hessian that are required size_t K = hes.size(); CPPAD_ASSERT_UNKNOWN( size_t( user_row.size() ) == K ); CPPAD_ASSERT_UNKNOWN( size_t( user_col.size() ) == K ); CPPAD_ASSERT_UNKNOWN( size_t(x.size()) == n ); CPPAD_ASSERT_UNKNOWN( color.size() == 0 || color.size() == n ); CPPAD_ASSERT_UNKNOWN( row.size() == 0 || row.size() == K ); CPPAD_ASSERT_UNKNOWN( col.size() == 0 || col.size() == K ); // 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" ) color_general_cppad(sparsity, row, col, color); else if( work.color_method == "cppad.symmetric" ) color_symmetric_cppad(sparsity, row, col, color); else if( work.color_method == "colpack.star" ) { # if CPPAD_HAS_COLPACK color_symmetric_colpack(sparsity, row, col, color); # else CPPAD_ASSERT_KNOWN( false, "SparseHessian: work.color_method = colpack.star" "and colpack_prefix missing from cmake command line." ); # endif } else { CPPAD_ASSERT_KNOWN( false, "SparseHessian: work.color_method is not valid." ); } // put sorting indices in color order VectorSize key(K); 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) VectorBase u(n); // location for return values from reverse (columns of the Hessian) VectorBase ddw(2 * n); // initialize the return value for(k = 0; k < K; k++) hes[k] = zero; // loop over colors k = 0; for(ell = 0; ell < n_color; ell++) { 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 VectorSize is a simple vector class with elements of type \c 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 \c SparseHessianCompute. If the sparsity pattern, \c row vector, or \c col vectors are not the same between calls to \c SparseHessian, \c work.clear() must be called to reinitialize \c 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 VectorBase& x , const VectorBase& w , const VectorSet& p , const VectorSize& row , const VectorSize& col , VectorBase& 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 VectorSet::value_type Set_type; typedef typename internal_sparsity::pattern_type Pattern_type; Pattern_type s; if( work.color.size() == 0 ) { bool transpose = false; sparsity_user2internal(s, p, n, n, transpose); } 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 \a 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 \c n * n containing the Hessian of at the point specified by \a x (where \c n is the domain dimension for this ADFun object). */ template template VectorBase ADFun::SparseHessian( const VectorBase& x, const VectorBase& w, const VectorSet& p ) { size_t i, j, k; size_t n = Domain(); VectorBase hes(n * n); CPPAD_ASSERT_KNOWN( size_t(x.size()) == n, "SparseHessian: size of x not equal domain size for f." ); typedef typename VectorSet::value_type Set_type; typedef typename 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; sparsity_user2internal(s, p, n, n, transpose); k = 0; for(i = 0; i < n; i++) { s.begin(i); j = s.next_element(); while( j != s.end() ) { row.push_back(i); col.push_back(j); k++; j = s.next_element(); } } size_t K = k; VectorBase 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 \a 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 \c n * n containing the Hessian of at the point specified by \a x (where \c n is the domain dimension for this ADFun object). */ template template VectorBase ADFun::SparseHessian(const VectorBase &x, const VectorBase &w) { size_t i, j, k; typedef CppAD::vectorBool VectorBool; size_t m = Range(); size_t n = Domain(); // 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; } ForSparseJac(n, r); // VectorBool s(m); for(i = 0; i < m; i++) s[i] = w[i] != 0; VectorBool p = RevSparseHes(n, s); // compute sparse Hessian return SparseHessian(x, w, p); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/var2par.hpp0000644000175200017650000000372312656321767016712 0ustar coincoin-web// $Id: var2par.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_VAR2PAR_HPP # define CPPAD_VAR2PAR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------ $begin Var2Par$$ $spell var const $$ $section Convert an AD Variable to a Parameter$$ $mindex Var2Par from value_ obtain during taping$$ $head Syntax$$ $icode%y% = Var2Par(%x%)%$$ $head See Also$$ $cref value$$ $head Purpose$$ Returns a $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 or 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/var2par.cpp %$$ The file $cref var2par.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. $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 cppad-20160000.1/cppad/local/print_for.hpp0000644000175200017650000001354712656321767017344 0ustar coincoin-web// $Id: print_for.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_PRINT_FOR_HPP # define CPPAD_PRINT_FOR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin PrintFor$$ $spell pos var VecAD std cout const $$ $section Printing AD Values During Forward Mode$$ $mindex print text output debug$$ $head Syntax$$ $icode%f%.Forward(0, %x%) %$$ $codei%PrintFor(%before%, %var%) %$$ $codei%PrintFor(%pos%, %before%, %var%, %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 var$$ The argument $icode var$$ has one of the following prototypes $codei% const AD<%Base%>& %var% const VecAD<%Base%>::reference& %var% %$$ The value of $icode var$$, that corresponds to $icode x$$, is written to $code std::cout$$ during the execution of $codei% %f%.Forward(0, %x%) %$$ Note that $icode var$$ may be a $cref/variable/glossary/Variable/$$ or $cref/parameter/glossary/Parameter/$$. (A parameters value does not depend on the value of the independent variable vector $icode x$$.) $head after$$ The argument $icode after$$ has prototype $codei% const char* %after% %$$ This text is written to $code std::cout$$ after $icode var$$. $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% print_for/print_for.cpp% example/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(PriOp, 5, 0); // check for case where we are not recording operations 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" ); size_t ind0, ind1, ind2, ind3, ind4; // ind[0] = base 2 representation of the value [Var(pos), Var(var)] ind0 = 0; // ind[1] = address for pos if( Parameter(pos) ) ind1 = tape->Rec_.PutPar(pos.value_); else { ind0 += 1; ind1 = pos.taddr_; } // ind[2] = address of before ind2 = tape->Rec_.PutTxt(before); // ind[3] = address for var if( Parameter(var) ) ind3 = tape->Rec_.PutPar(var.value_); else { ind0 += 2; ind3 = var.taddr_; } // ind[4] = address of after ind4 = tape->Rec_.PutTxt(after); // put the operator in the tape tape->Rec_.PutArg(ind0, ind1, ind2, ind3, ind4); tape->Rec_.PutOp(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 cppad-20160000.1/cppad/local/op_code.hpp0000644000175200017650000006506012656321767016747 0ustar coincoin-web// $Id: op_code.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_OP_CODE_HPP # define CPPAD_OP_CODE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include # include # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file op_code.hpp Defines the OpCode enum type and functions related to it. */ /*! Type used to distinguish different AD< \a 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< \a 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, // abs(variable) AcosOp, // acos(variable) AcoshOp, // acosh(variable) AddpvOp, // parameter + variable AddvvOp, // variable + variable AsinOp, // asin(variable) AsinhOp, // asinh(variable) AtanOp, // atan(variable) AtanhOp, // atanh(variable) BeginOp, // used to mark the beginning of the tape CExpOp, // CondExpRel(left, right, trueCase, falseCase) // arg[0] = the Rel operator: Lt, Le, Eq, Ge, Gt, or Ne // 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] = number of addition variables in summation // arg[1] = number of subtraction variables in summation // arg[2] = index of parameter that initializes summation // arg[3] -> arg[2+arg[0]] = index for positive variables // arg[3+arg[0]] -> arg[2+arg[0]+arg[1]] = index for minus variables // arg[3+arg[0]+arg[1]] = arg[0] + arg[1] DisOp, // discrete::eval(index, variable) DivpvOp, // parameter / variable DivvpOp, // variable / parameter DivvvOp, // variable / variable EndOp, // used to mark the end of the tape EqpvOp, // parameter == variable EqvvOp, // variable == variable ErfOp, // erf(variable) ExpOp, // exp(variable) Expm1Op, // expm1(variable) InvOp, // independent variable LdpOp, // z[parameter] LdvOp, // z[variable] LepvOp, // parameter <= variable LevpOp, // variable <= parameter LevvOp, // variable <= variable LogOp, // log(variable) Log1pOp, // log1p(variable) LtpvOp, // parameter < variable LtvpOp, // variable < parameter LtvvOp, // variable < variable MulpvOp, // parameter * variable MulvvOp, // variable * variable NepvOp, // parameter != variable NevvOp, // variable != variable ParOp, // parameter PowpvOp, // pow(parameter, variable) PowvpOp, // pow(variable, parameter) PowvvOp, // pow(variable, variable) PriOp, // PrintFor(text, parameter or variable, parameter or variable) SignOp, // sign(variable) SinOp, // sin(variable) SinhOp, // sinh(variable) SqrtOp, // sqrt(variable) StppOp, // z[parameter] = parameter StpvOp, // z[parameter] = variable StvpOp, // z[variable] = parameter StvvOp, // z[variable] = variable SubpvOp, // parameter - variable SubvpOp, // variable - parameter SubvvOp, // variable - variable TanOp, // tan(variable) TanhOp, // tan(variable) // user atomic operation codes UserOp, // start of a user atomic operaiton // arg[0] = index of the operation if atomic_base class // arg[1] = extra information passed trough by deprecated old atomic class // arg[2] = number of arguments to this atomic function // arg[3] = number of results for this atomic function UsrapOp, // this user atomic argument is a parameter UsravOp, // this user atomic argument is a variable UsrrpOp, // this user atomic result is a parameter UsrrvOp, // this user atomic result is a variable ZmulpvOp, // azmul(parameter, variable) ZmulvpOp, // azmul(variabe, parameter) ZmulvvOp, // azmul(variable, variable) NumberOp // number of operator codes (not an operator) }; // Note that bin/check_op_code.sh assumes the pattern '^\tNumberOp$' occurs // at the end of this list and only at the end of this list. /*! 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 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, // EqpvOp 2, // EqvvOp 3, // ErfOp 1, // ExpOp 1, // Expm1Op 0, // InvOp 3, // LdpOp 3, // LdvOp 2, // LepvOp 2, // LevpOp 2, // LevvOp 1, // LogOp 1, // Log1pOp 2, // LtpvOp 2, // LtvpOp 2, // LtvvOp 2, // MulpvOp 2, // MulvvOp 2, // NepvOp 2, // NevvOp 1, // ParOp 2, // PowpvOp 2, // PowvpOp 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 4, // UserOp 1, // UsrapOp 1, // UsravOp 1, // UsrrpOp 0, // UsrrvOp 2, // ZmulpvOp 2, // ZmulvpOp 2, // ZmulvvOp 0 // NumberOp not used }; # ifndef NDEBUG // only do these checks once to save time static bool first = true; if( first ) { CPPAD_ASSERT_UNKNOWN( size_t(NumberOp) + 1 == sizeof(NumArgTable) / sizeof(NumArgTable[0]) ); CPPAD_ASSERT_UNKNOWN( size_t(NumberOp) <= std::numeric_limits::max() ); first = false; } // 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 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, // EqpvOp 0, // EqvvOp 5, // ErfOp 1, // ExpOp 1, // Expm1Op 1, // InvOp 1, // LdpOp 1, // LdvOp 0, // LepvOp 0, // LevpOp 0, // LevvOp 1, // LogOp 1, // Log1pOp 0, // LtpvOp 0, // LtvpOp 0, // LtvvOp 1, // MulpvOp 1, // MulvvOp 0, // NepvOp 0, // NevvOp 1, // ParOp 3, // PowpvOp 3, // PowvpOp 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 0, // UserOp 0, // UsrapOp 0, // UsravOp 0, // UsrrpOp 1, // UsrrvOp 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" , "Asin" , "Asinh" , "Atan" , "Atanh" , "Begin" , "CExp" , "Cos" , "Cosh" , "CSkip" , "CSum" , "Dis" , "Divpv" , "Divvp" , "Divvv" , "End" , "Eqpv" , "Eqvv" , "Erf" , "Exp" , "Expm1" , "Inv" , "Ldp" , "Ldv" , "Lepv" , "Levp" , "Levv" , "Log" , "Log1p" , "Ltpv" , "Ltvp" , "Ltvv" , "Mulpv" , "Mulvv" , "Nepv" , "Nevv" , "Par" , "Powpv" , "Powvp" , "Powvv" , "Pri" , "Sign" , "Sin" , "Sinh" , "Sqrt" , "Stpp" , "Stpv" , "Stvp" , "Stvv" , "Subpv" , "Subvp" , "Subvv" , "Tan" , "Tanh" , "User" , "Usrap" , "Usrav" , "Usrrp" , "Usrrv" , "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(width) << value; str = buffer.str(); // length of the string size_t len = str.size(); if( len > width ) { size_t i; for(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< \a 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 ind is the vector of argument indices for this operation (must have NumArg(op) elements). */ template void printOp( std::ostream& os , const player* play , size_t i_op , size_t i_var , OpCode op , const addr_t* ind ) { size_t i; 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[ ind[0] ], 3); } else printOpField(os, "", OpName(op), 8); // print other fields size_t ncol = 5; switch( op ) { case CSkipOp: /* ind[0] = the Rel operator: Lt, Le, Eq, Ge, Gt, or Ne ind[1] & 1 = is left a variable ind[1] & 2 = is right a variable ind[2] = index correspoding to left ind[3] = index correspoding to right ind[4] = number of operations to skip if CExpOp comparision is true ind[5] = number of operations to skip if CExpOp comparision is false ind[6] -> ind[5+ind[4]] = skip operations if true ind[6+ind[4]] -> ind[5+ind[4]+ind[5]] = skip operations if false ind[6+ind[4]+ind[5]] = ind[4] + ind[5] */ CPPAD_ASSERT_UNKNOWN( ind[6+ind[4]+ind[5]] == ind[4]+ind[5] ); CPPAD_ASSERT_UNKNOWN(ind[1] != 0); if( ind[1] & 1 ) printOpField(os, " vl=", ind[2], ncol); else printOpField(os, " pl=", play->GetPar(ind[2]), ncol); if( ind[1] & 2 ) printOpField(os, " vr=", ind[3], ncol); else printOpField(os, " pr=", play->GetPar(ind[3]), ncol); if( size_t(ind[4]) < 3 ) { for(i = 0; i < size_t(ind[4]); i++) printOpField(os, " ot=", ind[6+i], ncol); } else { printOpField(os, "\n\tot=", ind[6+0], ncol); for(i = 1; i < size_t(ind[4]); i++) printOpField(os, " ot=", ind[6+i], ncol); } if( size_t(ind[5]) < 3 ) { for(i = 0; i < size_t(ind[5]); i++) printOpField(os, " of=", ind[6+ind[4]+i], ncol); } else { printOpField(os, "\n\tof=", ind[6+ind[4]+0], ncol); { for(i = 1; i < size_t(ind[5]); i++) printOpField(os, " of=", ind[6+ind[4]+i], ncol); } } break; case CSumOp: /* ind[0] = number of addition variables in summation ind[1] = number of subtraction variables in summation ind[2] = index of parameter that initializes summation ind[3], ... , ind[2+ind[0]] = index for positive variables ind[3+ind[0]], ..., ind[2+ind[0]+ind[1]] = negative variables ind[3+ind[0]+ind[1]] == ind[0] + ind[1] */ CPPAD_ASSERT_UNKNOWN( ind[3+ind[0]+ind[1]] == ind[0]+ind[1] ); printOpField(os, " pr=", play->GetPar(ind[2]), ncol); for(i = 0; i < size_t(ind[0]); i++) printOpField(os, " +v=", ind[3+i], ncol); for(i = 0; i < size_t(ind[1]); i++) printOpField(os, " -v=", ind[3+ind[0]+i], ncol); break; case LdpOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); printOpField(os, "off=", ind[0], ncol); printOpField(os, "idx=", ind[1], ncol); break; case LdvOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); printOpField(os, "off=", ind[0], ncol); printOpField(os, " v=", ind[1], ncol); break; case StppOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); printOpField(os, "off=", ind[0], ncol); printOpField(os, "idx=", ind[1], ncol); printOpField(os, " pr=", play->GetPar(ind[2]), ncol); break; case StpvOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); printOpField(os, "off=", ind[0], ncol); printOpField(os, "idx=", ind[1], ncol); printOpField(os, " vr=", ind[2], ncol); break; case StvpOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); printOpField(os, "off=", ind[0], ncol); printOpField(os, " vl=", ind[1], ncol); printOpField(os, " pr=", play->GetPar(ind[2]), ncol); break; case StvvOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); printOpField(os, "off=", ind[0], ncol); printOpField(os, " vl=", ind[1], ncol); printOpField(os, " vr=", ind[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=", ind[0], ncol); printOpField(os, " vr=", ind[1], ncol); break; case AddpvOp: case EqpvOp: case DivpvOp: case LepvOp: case LtpvOp: case NepvOp: case SubpvOp: case MulpvOp: case PowpvOp: case ZmulpvOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); printOpField(os, " pl=", play->GetPar(ind[0]), ncol); printOpField(os, " vr=", ind[1], ncol); break; case DivvpOp: case LevpOp: case LtvpOp: case PowvpOp: case SubvpOp: case ZmulvpOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); printOpField(os, " vl=", ind[0], ncol); printOpField(os, " pr=", play->GetPar(ind[1]), ncol); 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 UsravOp: case TanOp: case TanhOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); printOpField(os, " v=", ind[0], ncol); break; case ErfOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); // ind[1] points to the parameter 0 // ind[2] points to the parameter 2 / sqrt(pi) printOpField(os, " v=", ind[0], ncol); break; case ParOp: case UsrapOp: case UsrrpOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); printOpField(os, " p=", play->GetPar(ind[0]), ncol); break; case UserOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 4 ); { std::string name = atomic_base::class_name(ind[0]); printOpField(os, " f=", name.c_str(), ncol); printOpField(os, " i=", ind[1], ncol); printOpField(os, " n=", ind[2], ncol); printOpField(os, " m=", ind[3], ncol); } break; case PriOp: CPPAD_ASSERT_NARG_NRES(op, 5, 0); if( ind[0] & 1 ) printOpField(os, " v=", ind[1], ncol); else printOpField(os, " p=", play->GetPar(ind[1]), ncol); os << "before=\"" << play->GetTxt(ind[2]) << "\""; if( ind[0] & 2 ) printOpField(os, " v=", ind[3], ncol); else printOpField(os, " p=", play->GetPar(ind[3]), ncol); os << "after=\"" << play->GetTxt(ind[4]) << "\""; break; case BeginOp: // argument not used (created by independent) CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); break; case EndOp: case InvOp: case UsrrvOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 0 ); break; case DisOp: CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); { const char* name = discrete::name(ind[0]); printOpField(os, " f=", name, ncol); printOpField(os, " x=", ind[1], ncol); } break; case CExpOp: CPPAD_ASSERT_UNKNOWN(ind[1] != 0); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 6 ); if( ind[1] & 1 ) printOpField(os, " vl=", ind[2], ncol); else printOpField(os, " pl=", play->GetPar(ind[2]), ncol); if( ind[1] & 2 ) printOpField(os, " vr=", ind[3], ncol); else printOpField(os, " pr=", play->GetPar(ind[3]), ncol); if( ind[1] & 4 ) printOpField(os, " vt=", ind[4], ncol); else printOpField(os, " pt=", play->GetPar(ind[4]), ncol); if( ind[1] & 8 ) printOpField(os, " vf=", ind[5], ncol); else printOpField(os, " pf=", play->GetPar(ind[5]), ncol); break; default: CPPAD_ASSERT_UNKNOWN(0); } } /*! Prints the result values correspnding to an operator. \tparam Base Is the base type for these AD< \a 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]; } /*! If NDEBUG is not defined, assert that arguments come before result. \param op Operator for which we are checking order. All the operators are checked except for those of the form UserOp or Usr..Op. \param result is the variable index for the result. \param arg is a vector of lenght NumArg(op) pointing to the arguments for this operation. */ inline void assert_arg_before_result( OpCode op, const addr_t* arg, size_t result ) { switch( op ) { // These cases are not included below case UserOp: case UsrapOp: case UsravOp: case UsrrpOp: case UsrrvOp: break; // ------------------------------------------------------------------ // 0 arguments case CSkipOp: case CSumOp: case EndOp: case InvOp: break; // ------------------------------------------------------------------ // 1 argument, but is not used case BeginOp: break; // 1 argument , 1 result case AbsOp: case ExpOp: case Expm1Op: case LogOp: case Log1pOp: case ParOp: case SignOp: case SqrtOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < result ); break; // 1 argument, 2 results case AcosOp: case AcoshOp: case AsinOp: case AsinhOp: case AtanOp: case AtanhOp: case CosOp: case CoshOp: case SinOp: case SinhOp: case TanOp: case TanhOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) + 1 < result ); break; // 1 argument, 5 results case ErfOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) + 4 < result ); break; // ------------------------------------------------------------------ // 2 arguments, no results case LepvOp: case LtpvOp: case EqpvOp: case NepvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) <= result ); break; // case LevpOp: case LtvpOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= result ); break; // case LevvOp: case LtvvOp: case EqvvOp: case NevvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= result ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) <= result ); break; // 2 arguments (both variables), 1 results case AddvvOp: case DivvvOp: case MulvvOp: case SubvvOp: case ZmulvvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < result ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < result ); break; // 2 arguments (first variables), 1 results case DivvpOp: case SubvpOp: case ZmulvpOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < result ); break; // 2 arguments (second variables), 1 results case AddpvOp: case DisOp: case DivpvOp: case MulpvOp: case SubpvOp: case ZmulpvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < result ); break; // 2 arguments (both variables), 3 results case PowvvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) + 2 < result ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) + 2 < result ); break; // 2 arguments (first variable), 3 results case PowvpOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) + 2 < result ); break; // 2 arguments (second variable), 3 results case PowpvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) + 2 < result ); break; // ------------------------------------------------------------------ // 3 arguments, none variables case LdpOp: case StppOp: break; // 3 arguments, second variable, 1 result case LdvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < result ); break; // 3 arguments, third variable, no result case StpvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) <= result ); break; // 3 arguments, second variable, no result case StvpOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) <= result ); break; // 3 arguments, second and third variable, no result case StvvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) <= result ); CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) <= result ); break; // ------------------------------------------------------------------ // 5 arguments, no result case PriOp: if( arg[0] & 1 ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) <= result ); } if( arg[0] & 2 ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) <= result ); } break; // ------------------------------------------------------------------ // 6 arguments, 1 result case CExpOp: if( arg[1] & 1 ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < result ); } if( arg[1] & 2 ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < result ); } if( arg[1] & 4 ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[4]) < result ); } if( arg[1] & 8 ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[5]) < result ); } break; // ------------------------------------------------------------------ default: CPPAD_ASSERT_UNKNOWN(false); break; } return; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/sub_eq.hpp0000644000175200017650000000501012656321767016602 0ustar coincoin-web// $Id: sub_eq.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SUB_EQ_HPP # define CPPAD_SUB_EQ_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // BEGIN CppAD 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 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 ); bool var_left = tape_id_ == tape_id; bool var_right = right.tape_id_ == tape_id; if( var_left ) { if( var_right ) { // this = variable - variable CPPAD_ASSERT_UNKNOWN( NumRes(SubvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(SubvvOp) == 2 ); // put operand addresses in tape tape->Rec_.PutArg(taddr_, right.taddr_); // put operator in the tape taddr_ = tape->Rec_.PutOp(SubvvOp); // make this a variable CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); } else if( IdenticalZero( right.value_ ) ) { // this = variable - 0 } else { // this = variable - parameter CPPAD_ASSERT_UNKNOWN( NumRes(SubvpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(SubvpOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(right.value_); tape->Rec_.PutArg(taddr_, p); // put operator in the tape taddr_ = tape->Rec_.PutOp(SubvpOp); // make this a variable CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); } } else if( var_right ) { // this = parameter - variable CPPAD_ASSERT_UNKNOWN( NumRes(SubpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(SubpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(left); tape->Rec_.PutArg(p, right.taddr_); // put operator in the tape taddr_ = tape->Rec_.PutOp(SubpvOp); // make this a variable tape_id_ = tape_id; } return *this; } CPPAD_FOLD_ASSIGNMENT_OPERATOR(-=) } // END CppAD namespace # endif cppad-20160000.1/cppad/local/abs_op.hpp0000644000175200017650000001007612656321767016577 0ustar coincoin-web// $Id: abs_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ABS_OP_HPP # define CPPAD_ABS_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file abs_op.hpp Forward and reverse mode calculations for z = abs(x). */ /*! Compute forward mode Taylor coefficient for result of op = AbsOp. The C++ source code corresponding to this operation is \verbatim z = abs(x) \endverbatim \copydetails forward_unary1_op */ template inline 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 = abs(x) \endverbatim \copydetails forward_unary1_op_dir */ template inline 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 = abs(x) \endverbatim \copydetails forward_unary1_op_0 */ template inline 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] = abs(x0); } /*! Compute reverse mode partial derivatives for result of op = AbsOp. The C++ source code corresponding to this operation is \verbatim z = abs(x) \endverbatim \copydetails reverse_unary1_op */ template inline 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 becasue sign is either +1, -1, or zero for(j = 0; j <= d; j++) px[j] += sign(x[0]) * pz[j]; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/epsilon.hpp0000644000175200017650000000300212656321767016774 0ustar coincoin-web// $Id: epsilon.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_EPSILON_HPP # define CPPAD_EPSILON_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------ $begin 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 cppad-20160000.1/cppad/local/csum_op.hpp0000644000175200017650000004255112656321767017004 0ustar coincoin-web// $Id: csum_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_CSUM_OP_HPP # define CPPAD_CSUM_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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(1) + ... + x(m) - y(1) - ... - y(n). \endverbatim \tparam Base base type for the operator; i.e., this operation was recorded using AD< \a Base > and computations by this routine are done using type \a 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 \a taylor corresponding to z. \param arg \a arg[0] is the number of addition variables in this cummulative summation; i.e., m. \n \a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n parameter[ arg[2] ] is the parameter value \c s in this cummunative summation. \n arg[2+i] for i = 1 , ... , m is the variable index of x(i). \n arg[2+arg[0]+i] for i = 1 , ... , n is the variable index of y(i). \param num_par is the number of parameters in \a 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[2+i] * cap_order + k ] for i = 1 , ... , m and k = 0 , ... , q is the k-th order Taylor coefficient corresponding to x(i) \n \b Input: taylor [ arg[2+m+i] * cap_order + k ] for i = 1 , ... , n 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 \a k-th order Taylor coefficient corresponding to z. */ template inline 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); size_t i, j, k; // 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[2]) < num_par ); CPPAD_ASSERT_UNKNOWN( arg[0] + arg[1] == arg[ arg[0] + arg[1] + 3 ] ); // Taylor coefficients corresponding to result Base* z = taylor + i_z * cap_order; for(k = p; k <= q; k++) z[k] = zero; if( p == 0 ) z[p] = parameter[ arg[2] ]; Base* x; i = arg[0]; j = 2; while(i--) { CPPAD_ASSERT_UNKNOWN( size_t(arg[j+1]) < i_z ); x = taylor + arg[++j] * cap_order; for(k = p; k <= q; k++) z[k] += x[k]; } i = arg[1]; while(i--) { CPPAD_ASSERT_UNKNOWN( size_t(arg[j+1]) < i_z ); x = taylor + arg[++j] * cap_order; for(k = p; k <= q; k++) z[k] -= x[k]; } } /*! Multiple direction forward mode Taylor coefficients for op = CsumOp. This operation is \verbatim z = s + x(1) + ... + x(m) - y(1) - ... - y(n). \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 \a 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 \a taylor corresponding to z. \param arg \a arg[0] is the number of addition variables in this cummulative summation; i.e., m. \n \a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n parameter[ arg[2] ] is the parameter value \c s in this cummunative summation. \n arg[2+i] for i = 1 , ... , m is the variable index of x(i). \n arg[2+arg[0]+i] for i = 1 , ... , n is the variable index of y(i). \param num_par is the number of parameters in \a 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[2+i]*((cap_order-1)*r + 1) + 0 ] for i = 1 , ... , m is the 0-th order Taylor coefficient corresponding to x(i) and taylor [ arg[2+i]*((cap_order-1)*r + 1) + (q-1)*r + ell + 1 ] for i = 1 , ... , m, ell = 0 , ... , r-1 is the q-th order Taylor coefficient corresponding to x(i) and direction ell. \n \b Input: taylor [ arg[2+m+i]*((cap_order-1)*r + 1) + 0 ] for i = 1 , ... , n is the 0-th order Taylor coefficient corresponding to y(i) and taylor [ arg[2+m+i]*((cap_order-1)*r + 1) + (q-1)*r + ell + 1 ] for i = 1 , ... , n, ell = 0 , ... , r-1 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 \a q-th order Taylor coefficient corresponding to z for direction ell = 0 , ... , r-1. */ template inline 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); size_t i, j, ell; // 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[2]) < num_par ); CPPAD_ASSERT_UNKNOWN( arg[0] + arg[1] == arg[ arg[0] + arg[1] + 3 ] ); // Taylor coefficients corresponding to result size_t num_taylor_per_var = (cap_order-1) * r + 1; size_t m = (q-1)*r + 1; Base* z = taylor + i_z * num_taylor_per_var + m; for(ell = 0; ell < r; ell++) z[ell] = zero; Base* x; i = arg[0]; j = 2; while(i--) { CPPAD_ASSERT_UNKNOWN( size_t(arg[j+1]) < i_z ); x = taylor + arg[++j] * num_taylor_per_var + m; for(ell = 0; ell < r; ell++) z[ell] += x[ell]; } i = arg[1]; while(i--) { CPPAD_ASSERT_UNKNOWN( size_t(arg[j+1]) < i_z ); x = taylor + arg[++j] * num_taylor_per_var + m; for(ell = 0; ell < r; ell++) z[ell] -= x[ell]; } } /*! Compute reverse mode Taylor coefficients for result of op = CsumOp. This operation is \verbatim z = q + x(1) + ... + x(m) - y(1) - ... - y(n). 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< \a Base > and computations by this routine are done using type \a 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 \a taylor corresponding to z. \param arg \a arg[0] is the number of addition variables in this cummulative summation; i.e., m. \n \a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n parameter[ arg[2] ] is the parameter value \c q in this cummunative summation. \n arg[2+i] for i = 1 , ... , m is the value x(i). \n arg[2+arg[0]+i] for i = 1 , ... , n is the value y(i). \param nc_partial number of colums in the matrix containing all the partial derivatives. \param partial \b Input: partial [ arg[2+i] * nc_partial + k ] for i = 1 , ... , m and k = 0 , ... , d is the partial derivative of G(z, y, x, w, ...) with respect to the k-th order Taylor coefficient corresponding to x(i) \n \b Input: partial [ arg[2+m+i] * nc_partial + k ] for i = 1 , ... , n and k = 0 , ... , d is the partial derivative of G(z, y, x, w, ...) with respect to the k-th order Taylor coefficient corresponding to y(i) \n \b Input: partial [ i_z * nc_partial + k ] for i = 1 , ... , n and k = 0 , ... , d is the partial derivative of G(z, y, x, w, ...) with respect to the k-th order Taylor coefficient corresponding to \c z. \n \b Output: partial [ arg[2+i] * nc_partial + k ] for i = 1 , ... , m and k = 0 , ... , d is the partial derivative of H(y, x, w, ...) with respect to the k-th order Taylor coefficient corresponding to x(i) \n \b Output: partial [ arg[2+m+i] * nc_partial + k ] for i = 1 , ... , n 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 inline 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 i, j, k; size_t d1 = d + 1; i = arg[0]; j = 2; while(i--) { CPPAD_ASSERT_UNKNOWN( size_t(arg[j+1]) < i_z ); px = partial + arg[++j] * nc_partial; k = d1; while(k--) px[k] += pz[k]; } i = arg[1]; while(i--) { CPPAD_ASSERT_UNKNOWN( size_t(arg[j+1]) < i_z ); px = partial + arg[++j] * nc_partial; k = d1; while(k--) px[k] -= pz[k]; } } /*! Forward mode Jacobian sparsity pattern for CSumOp operator. This operation is \verbatim z = q + x(1) + ... + x(m) - y(1) - ... - y(n). \endverbatim \tparam Vector_set is the type used for vectors of sets. It can be either \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z variable index corresponding to the result for this operation; i.e. the index in \a sparsity corresponding to z. \param arg \a arg[0] is the number of addition variables in this cummulative summation; i.e., m + n. \n \a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n parameter[ arg[2] ] is the parameter value \c q in this cummunative summation. \n arg[2+i] for i = 1 , ... , m is the value x(i). \n arg[2+arg[1]+i] for i = 1 , ... , n is the value y(i). \param sparsity \b Input: For i = 1 , ... , m, the set with index \a arg[2+i] in \a sparsity is the sparsity bit pattern for x(i). This identifies which of the independent variables the variable x(i) depends on. \n \b Input: For i = 1 , ... , n, the set with index \a arg[2+arg[0]+i] in \a sparsity is the sparsity bit pattern for x(i). This identifies which of the independent variables the variable y(i) depends on. \n \b Output: The set with index \a i_z in \a sparsity is the sparsity bit pattern for z. This identifies which of the independent variables the variable z depends on. */ template inline void forward_sparse_jacobian_csum_op( size_t i_z , const addr_t* arg , Vector_set& sparsity ) { sparsity.clear(i_z); size_t i, j; i = arg[0] + arg[1]; j = 2; while(i--) { CPPAD_ASSERT_UNKNOWN( size_t(arg[j+1]) < i_z ); sparsity.binary_union( i_z , // index in sparsity for result i_z , // index in sparsity for left operand arg[++j] , // 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(1) + ... + x(m) - y(1) - ... - y(n). 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z variable index corresponding to the result for this operation; i.e. the index in \a sparsity corresponding to z. \param arg \a arg[0] is the number of addition variables in this cummulative summation; i.e., m + n. \n \a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n parameter[ arg[2] ] is the parameter value \c q in this cummunative summation. \n arg[2+i] for i = 1 , ... , m is the value x(i). \n arg[2+arg[1]+i] for i = 1 , ... , n is the value y(i). \param sparsity For i = 1 , ... , m, the set with index \a arg[2+i] in \a sparsity is the sparsity bit pattern for x(i). This identifies which of the dependent variables depend on x(i). On input, the sparsity patter corresponds to \c G, and on ouput it corresponds to \c H. \n For i = 1 , ... , m, the set with index \a arg[2+arg[0]+i] in \a sparsity is the sparsity bit pattern for y(i). This identifies which of the dependent variables depend on y(i). On input, the sparsity patter corresponds to \c G, and on ouput it corresponds to \c H. \n \b Input: The set with index \a i_z in \a sparsity is the sparsity bit pattern for z. On input it corresponds to \c G and on output it is undefined. */ template inline void reverse_sparse_jacobian_csum_op( size_t i_z , const addr_t* arg , Vector_set& sparsity ) { size_t i, j; i = arg[0] + arg[1]; j = 2; while(i--) { ++j; CPPAD_ASSERT_UNKNOWN( size_t(arg[j]) < i_z ); sparsity.binary_union( arg[j] , // index in sparsity for result arg[j] , // 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(1) + ... + x(m) - y(1) - ... - y(n). 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z variable index corresponding to the result for this operation; i.e. the index in \a sparsity corresponding to z. \param arg \a arg[0] is the number of addition variables in this cummulative summation; i.e., m + n. \n \a arg[1] is the number of subtraction variables in this cummulative summation; i.e., \c m. \n parameter[ arg[2] ] is the parameter value \c q in this cummunative summation. \n arg[2+i] for i = 1 , ... , m is the value x(i). \n arg[2+arg[0]+i] for i = 1 , ... , n is the value y(i). \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 = 1 , ... , m rev_jacobian[ arg[2+i] ] is all false (true) if the Jacobian with respect to x(i) is zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. \n \n For i = 1 , ... , n rev_jacobian[ arg[2+arg[0]+i] ] is all false (true) if the Jacobian with respect to y(i) is zero (may be non-zero). 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 \a i_z in in \a 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 = 1 , ... , m The set with index arg[2+i] in \a 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 = 1 , ... , n The set with index arg[2+arg[0]+i] in \a 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 inline void reverse_sparse_hessian_csum_op( size_t i_z , const addr_t* arg , bool* rev_jacobian , Vector_set& rev_hes_sparsity ) { size_t i, j; i = arg[0] + arg[1]; j = 2; while(i--) { ++j; CPPAD_ASSERT_UNKNOWN( size_t(arg[j]) < i_z ); rev_hes_sparsity.binary_union( arg[j] , // index in sparsity for result arg[j] , // index in sparsity for left operand i_z , // index for right operand rev_hes_sparsity // sparsity vector for right operand ); rev_jacobian[arg[j]] |= rev_jacobian[i_z]; } } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/ad_to_string.hpp0000644000175200017650000000346612656321767020015 0ustar coincoin-web// $Id$ # ifndef CPPAD_AD_TO_STRING_HPP # define CPPAD_AD_TO_STRING_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ad_to_string$$ $spell const std $$ $section Convert An AD or Base Type to String$$ $head Syntax$$ $icode%s% = to_string(%value%)%$$. $head See Also$$ $cref to_string$$, $cref base_to_string$$ $head value$$ The argument $icode value$$ has prototype $codei% const AD<%Base%>& %value% const %Base%& %value% %$$ where $icode Base$$ is a type that supports the $cref base_to_string$$ type requirement. $head s$$ The return value has prototype $codei% std::string %s% %$$ and contains a representation of the specified $icode value$$. If $icode value$$ is an AD type, the result has the same precision as for the $icode Base$$ type. $head Example$$ The file $cref to_string.cpp$$ includes an example and test of $code to_string$$ with AD types. It returns true if it succeeds and false otherwise. $end */ # include # include namespace CppAD { // Template definition is in cppad/utility/to_string.hpp. // Partial specialzation for AD types template struct to_string_struct< CppAD::AD > { std::string operator()(const CppAD::AD& value) { to_string_struct ts; return ts( Value( Var2Par( value ) ) ); } }; } # endif cppad-20160000.1/cppad/local/lu_ratio.hpp0000644000175200017650000002464212656321767017156 0ustar coincoin-web// $Id: lu_ratio.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_LU_RATIO_HPP # define CPPAD_LU_RATIO_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin LuRatio$$ $spell cppad.hpp xk Cpp Lu bool const ip jp std ADvector $$ $section LU Factorization of A Square Matrix and Stability Calculation$$ $mindex LuRatio linear equation solve$$ $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/lu_ratio.cpp %$$ The file $cref lu_ratio.cpp$$ contains an example and test of using $code LuRatio$$. It returns true if it succeeds and false otherwise. $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 = abs(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 cppad-20160000.1/cppad/local/value.hpp0000644000175200017650000000430012656321767016441 0ustar coincoin-web// $Id: value.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_VALUE_HPP # define CPPAD_VALUE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Value$$ $spell const $$ $section Convert From an AD Type to its Base Type$$ $mindex Value$$ $head Syntax$$ $icode%b% = Value(%x%)%$$ $head See Also$$ $cref var2par$$ $head Purpose$$ Converts from an AD type to the corresponding $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$$ If the argument $icode x$$ is a $cref/variable/glossary/Variable/$$ its dependency information would not be included in the $code Value$$ result (see above). For this reason, the argument $icode x$$ must be a $cref/parameter/glossary/Parameter/$$; i.e., it cannot depend on the current $cref/independent variables/glossary/Tape/Independent Variable/$$. $head Example$$ $children% example/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( Parameter(x) , "Value: argument is a variable (not a parameter)" ); result = x.value_; return result; } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/op.hpp0000644000175200017650000000412312656321767015746 0ustar coincoin-web// $Id: op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_OP_HPP # define CPPAD_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ // 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 cppad-20160000.1/cppad/local/mul_eq.hpp0000644000175200017650000000550312656321767016615 0ustar coincoin-web// $Id: mul_eq.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_MUL_EQ_HPP # define CPPAD_MUL_EQ_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // BEGIN CppAD 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 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 ); bool var_left = tape_id_ == tape_id; bool var_right = right.tape_id_ == tape_id; if( var_left ) { if( var_right ) { // this = variable * variable CPPAD_ASSERT_UNKNOWN( NumRes(MulvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(MulvvOp) == 2 ); // put operand addresses in tape tape->Rec_.PutArg(taddr_, right.taddr_); // put operator in the tape taddr_ = tape->Rec_.PutOp(MulvvOp); // make this a variable CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); } else if( IdenticalOne( right.value_ ) ) { // this = variable * 1 } else if( IdenticalZero( right.value_ ) ) { // this = variable * 0 make_parameter(); } else { // this = variable * parameter // = parameter * variable CPPAD_ASSERT_UNKNOWN( NumRes(MulpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(MulpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(right.value_); tape->Rec_.PutArg(p, taddr_); // put operator in the tape taddr_ = tape->Rec_.PutOp(MulpvOp); // make this a variable CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); } } else if( var_right ) { if( IdenticalZero(left) ) { // this = 0 * right } else if( IdenticalOne(left) ) { // this = 1 * right make_variable(right.tape_id_, right.taddr_); } else { // this = parameter * variable CPPAD_ASSERT_UNKNOWN( NumRes(MulpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(MulpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(left); tape->Rec_.PutArg(p, right.taddr_); // put operator in the tape taddr_ = tape->Rec_.PutOp(MulpvOp); // make this a variable tape_id_ = tape_id; } } return *this; } CPPAD_FOLD_ASSIGNMENT_OPERATOR(*=) } // END CppAD namespace # endif cppad-20160000.1/cppad/local/add_eq.hpp0000644000175200017650000000520512656321767016547 0ustar coincoin-web// $Id: add_eq.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ADD_EQ_HPP # define CPPAD_ADD_EQ_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // BEGIN CppAD 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 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 ); bool var_left = tape_id_ == tape_id; bool var_right = right.tape_id_ == tape_id; if( var_left ) { if( var_right ) { // this = variable + variable CPPAD_ASSERT_UNKNOWN( NumRes(AddvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(AddvvOp) == 2 ); // put operand addresses in tape tape->Rec_.PutArg(taddr_, right.taddr_); // put operator in the tape taddr_ = tape->Rec_.PutOp(AddvvOp); // make this a variable CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); } else if( ! IdenticalZero( right.value_ ) ) { // this = variable + parameter // = parameter + variable CPPAD_ASSERT_UNKNOWN( NumRes(AddpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(AddpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(right.value_); tape->Rec_.PutArg(p, taddr_); // put operator in the tape taddr_ = tape->Rec_.PutOp(AddpvOp); // make this a variable CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); } } else if( var_right ) { if( IdenticalZero(left) ) { // this = 0 + right make_variable(right.tape_id_, right.taddr_); } else { // this = parameter + variable CPPAD_ASSERT_UNKNOWN( NumRes(AddpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(AddpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(left); tape->Rec_.PutArg(p, right.taddr_); // put operator in the tape taddr_ = tape->Rec_.PutOp(AddpvOp); // make this a variable tape_id_ = tape_id; } } return *this; } CPPAD_FOLD_ASSIGNMENT_OPERATOR(+=) } // END CppAD namespace # endif cppad-20160000.1/cppad/local/compute_assign.hpp0000644000175200017650000000667312656321767020364 0ustar coincoin-web// $Id: compute_assign.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_COMPUTE_ASSIGN_HPP # define CPPAD_COMPUTE_ASSIGN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin compute_assign$$ $spell Op VecAD const $$ $section AD Computed Assignment Operators$$ $mindex + add plus - subtract minus * multiply times / divide multiple$$ $head Syntax$$ $icode%x% %Op% %y%$$ $head Purpose$$ Performs computed 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/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/add_eq.cpp% example/sub_eq.cpp% example/mul_eq.cpp% example/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 cppad-20160000.1/cppad/local/acos_op.hpp0000644000175200017650000001524112656321767016756 0ustar coincoin-web// $Id: acos_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ACOS_OP_HPP # define CPPAD_ACOS_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary2_op */ template inline 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) - x[0] * x[0]; b[0] = sqrt( uj ); p++; } for(size_t j = p; j <= q; j++) { uj = Base(0); for(k = 0; k <= j; k++) uj -= x[k] * x[j-k]; b[j] = Base(0); z[j] = Base(0); for(k = 1; k < j; k++) { b[j] -= Base(k) * b[k] * b[j-k]; z[j] -= Base(k) * z[k] * b[j-k]; } b[j] /= Base(j); z[j] /= Base(j); // b[j] += uj / Base(2); z[j] -= x[j]; // b[j] /= b[0]; z[j] /= b[0]; } } /*! Multiple directions forward mode Taylor coefficient for op = 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 forward_unary2_op_dir */ template inline 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); z[m+ell] = Base(0); for(k = 1; k < q; k++) { b[m+ell] += Base(k) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; z[m+ell] += Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; } b[m+ell] = ( uq / Base(2) - b[m+ell] / Base(q) ) / b[0]; z[m+ell] = -( x[m+ell] + z[m+ell] / Base(q) ) / b[0]; } } /*! Compute zero order forward mode Taylor coefficient for result of op = 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 forward_unary2_op_0 */ template inline 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) - 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 reverse_unary2_op */ template inline 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) / b[0]; // number of indices to access size_t j = d; size_t k; while(j) { // scale partials w.r.t b[j] by 1 / b[0] pb[j] = azmul(pb[j], inv_b0); // scale partials w.r.t z[j] by 1 / b[0] pz[j] = azmul(pz[j], inv_b0); // update partials w.r.t b^0 pb[0] -= azmul(pz[j], z[j]) + azmul(pb[j], b[j]); // update partial w.r.t. x^0 px[0] -= azmul(pb[j], x[j]); // update partial w.r.t. x^j px[j] -= pz[j] + azmul(pb[j], x[0]); // further scale partial w.r.t. z[j] by 1 / j pz[j] /= Base(j); for(k = 1; k < j; k++) { // update partials w.r.t b^(j-k) pb[j-k] -= Base(k) * azmul(pz[j], z[k]) + azmul(pb[j], b[k]); // update partials w.r.t. x^k px[k] -= azmul(pb[j], x[j-k]); // update partials w.r.t. z^k pz[k] -= Base(k) * azmul(pz[j], b[j-k]); } --j; } // j == 0 case px[0] -= azmul( pz[0] + azmul(pb[0], x[0]), inv_b0); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/hash_code.hpp0000644000175200017650000001520612656321767017251 0ustar coincoin-web// $Id: hash_code.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_HASH_CODE_HPP # define CPPAD_HASH_CODE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file hash_code.hpp CppAD hashing utility. */ /*! \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 /*! 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. \return is a hash code that is between zero and CPPAD_HASH_TABLE_SIZE - 1. \par Checked Assertions \li \c std::numeric_limits::max() >= CPPAD_HASH_TABLE_SIZE \li \c sizeof(value) is even \li \c sizeof(unsigned short) == 2 */ template unsigned short 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; # unsigned short code = v[i]; # while(i--) code += v[i]; return code % CPPAD_HASH_TABLE_SIZE; } /*! 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 \c 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 \a npar containing the parameters for this operation sequence; i.e., given a parameter index of \c i, the corresponding parameter value is \a par[i]. \return is a hash code that is between zero and CPPAD_HASH_TABLE_SIZE - 1. \par Checked Assertions \c op must be one of the operators specified above. In addition, \li \c std::numeric_limits::max() >= CPPAD_HASH_TABLE_SIZE \li \c sizeof(size_t) is even \li \c sizeof(Base) is even \li \c sizeof(unsigned short) == 2 \li \c size_t(op) < size_t(NumberOp) <= CPPAD_HASH_TABLE_SIZE \li if the j-th argument for this operation is a parameter, arg[j] < npar. */ template unsigned short 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; // number of shorts per Base value size_t short_base = sizeof(Base) / 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 ); v = reinterpret_cast(par + arg[0]); i = short_base; while(i--) code += v[i]; 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]; v = reinterpret_cast(par + arg[1]); i = short_base; while(i--) code += v[i]; 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_NAMESPACE # endif cppad-20160000.1/cppad/local/atan_op.hpp0000644000175200017650000001371612656321767016761 0ustar coincoin-web// $Id: atan_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ATAN_OP_HPP # define CPPAD_ATAN_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary2_op */ template inline 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) + x[0] * x[0]; p++; } for(size_t j = p; j <= q; j++) { b[j] = Base(2) * x[0] * x[j]; z[j] = Base(0); for(k = 1; k < j; k++) { b[j] += x[k] * x[j-k]; z[j] -= Base(k) * z[k] * b[j-k]; } z[j] /= Base(j); z[j] += x[j]; z[j] /= b[0]; } } /*! Multiple direction Taylor coefficient for op = 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 forward_unary2_op_dir */ template inline 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) * x[m+ell] * x[0]; z[m+ell] = Base(q) * x[m+ell]; for(size_t k = 1; k < q; k++) { b[m+ell] += x[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; z[m+ell] -= Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; } z[m+ell] /= ( Base(q) * b[0] ); } } /*! Zero order forward mode Taylor coefficient for result of op = 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 forward_unary2_op_0 */ template inline 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) + 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 reverse_unary2_op */ template inline 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) / b[0]; // number of indices to access size_t j = d; size_t k; while(j) { // scale partials w.r.t z[j] and b[j] pz[j] = azmul(pz[j], inv_b0); pb[j] *= Base(2); pb[0] -= azmul(pz[j], z[j]); px[j] += pz[j] + azmul(pb[j], x[0]); px[0] += azmul(pb[j], x[j]); // more scaling of partials w.r.t z[j] pz[j] /= Base(j); for(k = 1; k < j; k++) { pb[j-k] -= Base(k) * azmul(pz[j], z[k]); pz[k] -= Base(k) * azmul(pz[j], b[j-k]); px[k] += azmul(pb[j], x[j-k]); } --j; } px[0] += azmul(pz[0], inv_b0) + Base(2) * azmul(pb[0], x[0]); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/cppad_colpack.hpp0000644000175200017650000000671012656321767020117 0ustar coincoin-web// $Id: cppad_colpack.hpp 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. -------------------------------------------------------------------------- */ # ifndef CPPAD_CPPAD_COLPACK_HPP # define CPPAD_CPPAD_COLPACK_HPP # if CPPAD_HAS_COLPACK namespace CppAD { // BEGIN_CPPAD_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 \c m, adolc_pattern[i][0] is the number of non-zeros in row \c i. For j = 1 , ... , adolc_sparsity[i], adolc_pattern[i][j] is the column index (base zero) for the non-zeros in row \c i. \param color [out] is a vector with size \c 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 \c 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 \c 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 \c n, adolc_pattern[i][0] is the number of non-zeros in row \c i. For j = 1 , ... , adolc_sparsity[i], adolc_pattern[i][j] is the column index (base zero) for the non-zeros in row \c 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_NAMESPACE # endif # endif cppad-20160000.1/cppad/local/fun_check.hpp0000644000175200017650000001330112656321767017253 0ustar coincoin-web// $Id: fun_check.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FUN_CHECK_HPP # define CPPAD_FUN_CHECK_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. We use $latex G : B^n \rightarrow B^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/fun_check.cpp %$$ The file $cref fun_check.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $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 cppad-20160000.1/cppad/local/zdouble.hpp0000644000175200017650000003756712656321767017016 0ustar coincoin-web// $Id$ # ifndef CPPAD_ZDOUBLE_HPP # define CPPAD_ZDOUBLE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin zdouble$$ $spell zdouble op bool inf CppAD $$ $section zdouble: An AD Base Type With Absolute Zero$$ $head Deprecated 2015-09-26$$ Use the function $cref azmul$$ instead. $head Absolute Zero$$ The $code zdouble$$ class acts like the $code double$$ type with the added property that zero times any value is zero. This includes zero time $cref nan$$ and zero times infinity. In addition, zero divided by any value and any value times zero are also zero. $head Syntax$$ $subhead Constructor and Assignment$$ $codei% zdouble z %$$ $codei% zdouble z(x) %$$ $icode% z1% %op% %x% %$$ where $icode x$$ is a $code double$$ or $code zdouble$$ object and $icode op$$ is $code =$$, $code +=$$, $code -=$$, $code *=$$ or $code /=-$$. $subhead Comparison Operators$$ $icode% b% = %z% %op% %x% %$$ $icode% b% = %x% %op% %z% %$$ where $icode b$$ is a $code bool$$ object, $icode z$$ is a $code zdouble$$ object, $icode x$$ is a $code double$$ or $code zdouble$$ object, and $icode op$$ is $code ==$$, $code !=$$, $code <=$$, $code >=$$, $code <$$ or $code >$$. $subhead Arithmetic Operators$$ $icode% z2% = %z1% %op% %x% %$$ $icode% z2% = %x% %op% %z1% %$$ where $icode z1$$, $icode z2$$ are $code zdouble$$ objects, $icode x$$ is a $code double$$ or $code zdouble$$ object, and $icode op$$ is $code +$$, $code -$$, $code *$$ or $code /$$. $subhead Standard Math$$ $icode% z2% = %fun%(%z1%) %$$ $icode% z3% = pow(%z1%, %z2%) %$$ where $icode z1$$, $icode z2$$, $icode z3$$ are $code zdouble$$ objects and $icode fun$$ is a $cref unary_standard_math$$ function. $subhead Nan$$ There is a specialization of $cref nan$$ so that $icode% z2% = nan(%z1%) %$$ returns 'not a number' when $icode z1$$ has type $code zdouble$$. Note that this template function needs to be specialized because $codei zdouble(0.0) == zdouble(0.0) / zdouble(0.0) $$ $head Motivation$$ $subhead General$$ Often during computing (and more so in parallel computing) alternative values for an expression are computed and one of the alternatives is chosen using some boolean variable. This is often represented by $codei% %result% = %flag% * %value_if_true% + (1 - %flag%) * %value_if_false% %$$ where $icode flag$$ is one for true and zero for false. This representation does not work for $code double$$ when the value being multiplied by zero is $code +inf$$, $code -inf$$, or $code nan$$. $subhead CppAD$$ In CppAD one can use $cref/conditional expressions/CondExp/$$ to achieve the representation $codei% %result% = %flag% * %value_if_true% + (1 - %flag%) * %value_if_false% %$$ This works fine except when there are $cref/multiple levels of AD/mul_level/$$; e.g., when using $codei%AD< AD >%$$. In this case the corresponding AD function objects have type $cref/ADFun< AD >/FunConstruct/$$. When these AD function objects compute derivatives using $cref reverse$$ mode, the conditional expressions are represented use zeros to multiply the expression that is not used. Using $codei%AD< AD >%$$ instead of $code AD< AD >$$ makes this representation work and fixes the problem. $head Base Type Requirements$$ The type $code zdouble$$ satisfies all of the CppAD $cref/base type requirements/base_require/$$. $children% test_more/zdouble.cpp %$$ $head Example$$ The file $cref zdouble.cpp$$ contains an example and test of this class. It returns true if it succeeds and false otherwise. $end */ # include # include /*! \file zdouble.hpp Define a class like double but with an absolute zero. */ /*! \def CPPAD_ZDOUBLE_NORMAL_ASSIGN_OPERATOR(op) Define a computed assignment member operator that functions the same as corresponding double operator. */ # define CPPAD_ZDOUBLE_NORMAL_ASSIGN_OPERATOR(op) \ zdouble& operator op (const zdouble& z) \ { dbl_ op z.dbl_; \ return *this; \ } \ zdouble& operator op (const double& x) \ { dbl_ op x; \ return *this; \ } /*! \def CPPAD_ZDOUBLE_UNARY_OPERATOR(op) Define a unary computed assignment member operator. */ # define CPPAD_ZDOUBLE_UNARY_OPERATOR(op) \ zdouble operator op (void) const \ { return zdouble( op dbl_ ); } /*! # define CPPAD_ZDOUBLE_NORMAL_BINARY_OPERATOR(op) Define a binary arithmetic member operator that functions the same as corresponding double operator. */ # define CPPAD_ZDOUBLE_NORMAL_BINARY_OPERATOR(op) \ zdouble operator op (const zdouble& z) const \ { return zdouble( dbl_ op z.dbl_ ); } \ zdouble operator op (const double& x) const \ { return zdouble( dbl_ op x ); } /*! \def CPPAD_ZDOUBLE_COMPARE_OPERATOR(op) Define a comparison member operator. */ # define CPPAD_ZDOUBLE_COMPARE_OPERATOR(op) \ bool operator op (const zdouble& z) const \ { return dbl_ op z.dbl_; } \ bool operator op (const double& x) const \ { return dbl_ op x; } /*! \def CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(op) Define a binary arithmetic operator that is not a member because the double operand is on the left. */ # define CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(op) \ inline zdouble operator op(const double& x, const zdouble& z) \ { return zdouble(x) op z; } /*! \def CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(op, op_switch) Define a comparison operator that is not a member because the double operand is on the left. Convert it to the case where the double operand is on the right by by using op_switch instead of op. */ # define CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(op, op_switch) \ inline bool operator op(const double& x, const zdouble& z) \ { return z op_switch x; } /*! \def CPPAD_ZDOUBLE_STD_MATH_FRIEND(fun) Declare that a standard math function is a friend. */ # define CPPAD_ZDOUBLE_STD_MATH_FRIEND(fun) \ friend zdouble fun(const zdouble& z); /*! \def CPPAD_ZDOUBLE_STD_MATH(fun) Define a standard math function. */ # define CPPAD_ZDOUBLE_STD_MATH(fun) \ inline zdouble fun(const zdouble& z ) \ { return zdouble( std::fun(z.dbl_) ); } namespace CppAD { // CPPAD_BEGIN_NAMESPACDE /*! Class that is like double, except that it has an absolute zero. */ class zdouble { /*! For zdouble objects z1, z2, and std::ostream os, declare the following friends: \code os << z1 Integer(z1) abs(z1) pow(z1, z2) abs_geq(z1, z2) fun(z1) \endcode where fun is any of the standard math unary functions. */ friend std::ostream& operator << (std::ostream &os, const zdouble& z); friend int Integer(const zdouble& z); friend zdouble abs(const zdouble& x); friend zdouble pow(const zdouble& x, const zdouble& y); friend bool abs_geq(const zdouble& x, const zdouble& y); // CPPAD_ZDOUBLE_STD_MATH_FRIEND(acos) CPPAD_ZDOUBLE_STD_MATH_FRIEND(asin) CPPAD_ZDOUBLE_STD_MATH_FRIEND(atan) CPPAD_ZDOUBLE_STD_MATH_FRIEND(cos) CPPAD_ZDOUBLE_STD_MATH_FRIEND(cosh) CPPAD_ZDOUBLE_STD_MATH_FRIEND(exp) CPPAD_ZDOUBLE_STD_MATH_FRIEND(fabs) CPPAD_ZDOUBLE_STD_MATH_FRIEND(log) CPPAD_ZDOUBLE_STD_MATH_FRIEND(log10) CPPAD_ZDOUBLE_STD_MATH_FRIEND(sin) CPPAD_ZDOUBLE_STD_MATH_FRIEND(sinh) CPPAD_ZDOUBLE_STD_MATH_FRIEND(sqrt) CPPAD_ZDOUBLE_STD_MATH_FRIEND(tan) CPPAD_ZDOUBLE_STD_MATH_FRIEND(tanh) // # if CPPAD_USE_CPLUSPLUS_2011 CPPAD_ZDOUBLE_STD_MATH_FRIEND(erf) CPPAD_ZDOUBLE_STD_MATH_FRIEND(asinh) CPPAD_ZDOUBLE_STD_MATH_FRIEND(acosh) CPPAD_ZDOUBLE_STD_MATH_FRIEND(atanh) CPPAD_ZDOUBLE_STD_MATH_FRIEND(expm1) CPPAD_ZDOUBLE_STD_MATH_FRIEND(log1p) // # endif private: /// The value for this object double dbl_; public: /// Default constructor zdouble(void) : dbl_() { } /// Copy constructor zdouble(const zdouble& z) : dbl_(z.dbl_) { } /// Constructor from double zdouble(const double& dbl) : dbl_(dbl) { } // /// Destructor ~zdouble(void) { } // /// Assignment from zdouble zdouble& operator=(const zdouble& z) { dbl_ = z.dbl_; return *this; } /// Assignment from double zdouble& operator=(const double& dbl) { dbl_ = dbl; return *this; } // /// Normal computed assignment CPPAD_ZDOUBLE_NORMAL_ASSIGN_OPERATOR(+=) /// Normal computed assignment CPPAD_ZDOUBLE_NORMAL_ASSIGN_OPERATOR(-=) /// Normal unary operator CPPAD_ZDOUBLE_UNARY_OPERATOR(+) /// Normal unary operator CPPAD_ZDOUBLE_UNARY_OPERATOR(-) /// Normal compare operator CPPAD_ZDOUBLE_COMPARE_OPERATOR(==) /// Normal compare operator CPPAD_ZDOUBLE_COMPARE_OPERATOR(!=) /// Normal compare operator CPPAD_ZDOUBLE_COMPARE_OPERATOR(<=) /// Normal compare operator CPPAD_ZDOUBLE_COMPARE_OPERATOR(>=) /// Normal compare operator CPPAD_ZDOUBLE_COMPARE_OPERATOR(<) /// Normal compare operator CPPAD_ZDOUBLE_COMPARE_OPERATOR(>) // /// Normal binary arithmetic operator CPPAD_ZDOUBLE_NORMAL_BINARY_OPERATOR(+) /// Normal binary arithmetic operator CPPAD_ZDOUBLE_NORMAL_BINARY_OPERATOR(-) // /// Binary arithmetic * with absolute zero zdouble operator * (const zdouble& z) const { bool zero = (dbl_ == 0.0) || (z.dbl_ == 0.0); return zdouble( zero ? 0.0 : (dbl_ * z.dbl_) ); } /// Binary arithmetic * with absolute zero zdouble operator * (const double& x) const { bool zero = (dbl_ == 0.0) || (x == 0.0); return zdouble( zero ? 0.0 : (dbl_ * x) ); } /// Binary arithmetic / with absolute zero zdouble operator / (const zdouble& z) const { bool zero = (dbl_ == 0.0); return zdouble( zero ? 0.0 : (dbl_ / z.dbl_) ); } /// Binary arithmetic / with absolute zero zdouble operator / (const double& x) const { bool zero = (dbl_ == 0.0); return zdouble( zero ? 0.0 : (dbl_ / x) ); } // /// Compute assignmnet *= with absolute zero zdouble& operator *= (const zdouble& z) { bool zero = (dbl_ == 0.0) || (z.dbl_ == 0.0); zero ? (dbl_ = 0.0) : (dbl_ *= z.dbl_); return *this; } /// Compute assignmnet *= with absolute zero zdouble& operator *= (const double& x) { bool zero = (dbl_ == 0.0) || (x == 0.0); zero ? (dbl_ = 0.0) : (dbl_ *= x); return *this; } // /// Compute assignmnet /= with absolute zero zdouble& operator /= (const zdouble& z) { bool zero = (dbl_ == 0.0); zero ? (dbl_ = 0.0) : (dbl_ /= z.dbl_); return *this; } /// Compute assignmnet /= with absolute zero zdouble& operator /= (const double& x) { bool zero = (dbl_ == 0.0); zero ? (dbl_ = 0.0) : (dbl_ /= x); return *this; } }; // BEGIN nan /// Must specialize CppAD::nan because zdouble 0/0 is not nan. template <> inline zdouble nan(const zdouble& zero) { return zdouble( std::numeric_limits::quiet_NaN() ); } // END nan // /// Normal non-member compare operator CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(==, ==) /// Normal non-member compare operator CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(!=, !=) /// Normal non-member compare operator CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(<=, >=) /// Normal non-member compare operator CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(>=, <=) /// Normal non-member compare operator CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(<, >) /// Normal non-member compare operator CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR(>, <) // /// Normal binary arithmetic operator CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(+) /// Normal binary arithmetic operator CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(-) /// Binary arithmetic operator with absolute zero CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(*) /// Binary arithmetic operator with absolute zero CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR(/) // ------------------------------------------------------------------------- // Base type requirements // ------------------------------------------------------------------------- /// Base type requirement: CondExpOp inline zdouble CondExpOp( enum CompareOp cop , const zdouble& left , const zdouble& right , const zdouble& exp_if_true , const zdouble& exp_if_false ) { return CondExpTemplate(cop, left, right, exp_if_true, exp_if_false); } /// Base type requirement: CondExpRel CPPAD_COND_EXP_REL(zdouble) /// Base type requirement: EqualOpSeq inline bool EqualOpSeq(const zdouble& x, const zdouble& y) { return x == y; } /// Base type requirement: Identical inline bool IdenticalPar(const zdouble& x) { return true; } inline bool IdenticalZero(const zdouble& x) { return (x == 0.0); } inline bool IdenticalOne(const zdouble& x) { return (x == 1.); } inline bool IdenticalEqualPar(const zdouble& x, const zdouble& y) { return (x == y); } /// Base type requirement: output operator inline std::ostream& operator << (std::ostream &os, const zdouble& z) { os << z.dbl_; return os; } /// Base type requirement: Integer inline int Integer(const zdouble& x) { return static_cast(x.dbl_); } /// Base type requirement: azmul inline zdouble azmul(const zdouble& x, const zdouble& y) { return x * y; } /// Base type requirement: Ordered inline bool GreaterThanZero(const zdouble& x) { return x > 0.0; } inline bool GreaterThanOrZero(const zdouble& x) { return x >= 0.0; } inline bool LessThanZero(const zdouble& x) { return x < 0.0; } inline bool LessThanOrZero(const zdouble& x) { return x <= 0.0; } inline bool abs_geq(const zdouble& x, const zdouble& y) { return std::fabs(x.dbl_) >= std::fabs(y.dbl_); } /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(acos) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(asin) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(atan) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(cos) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(cosh) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(exp) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(fabs) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(log) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(log10) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(sin) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(sinh) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(sqrt) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(tan) /// Normal standard math function CPPAD_ZDOUBLE_STD_MATH(tanh) // # if CPPAD_USE_CPLUSPLUS_2011 /// C++2011 standard math function CPPAD_ZDOUBLE_STD_MATH(erf) /// C++2011 standard math function CPPAD_ZDOUBLE_STD_MATH(asinh) /// C++2011 standard math function CPPAD_ZDOUBLE_STD_MATH(acosh) /// C++2011 standard math function CPPAD_ZDOUBLE_STD_MATH(atanh) /// C++2011 standard math function CPPAD_ZDOUBLE_STD_MATH(expm1) /// C++2011 standard math function CPPAD_ZDOUBLE_STD_MATH(log1p) # endif /// Base type requirement: abs inline zdouble abs(const zdouble& x) { return std::fabs(x.dbl_); } /// Base type requirement: sign inline zdouble sign(const zdouble& x) { if( x > 0.0 ) return zdouble(1.); if( x == 0.0 ) return zdouble(0.0); return zdouble(-1.); } /// Base type requirement: pow inline zdouble pow(const zdouble& x, const zdouble& y) { return std::pow(x.dbl_, y.dbl_); } /// Base type requirement: limits template <> class numeric_limits { public: // machine epsilon static zdouble epsilon(void) { return std::numeric_limits::epsilon(); } // minimum positive normalized value static zdouble min(void) { return std::numeric_limits::min(); } // maximum finite value static zdouble max(void) { return std::numeric_limits::max(); } }; } // CPPAD_END_NAMESPACE /// undef all macros defined in this file # undef CPPAD_ZDOUBLE_NORMAL_ASSIGN_OPERATOR # undef CPPAD_ZDOUBLE_UNARY_OPERATOR # undef CPPAD_ZDOUBLE_NORMAL_BINARY_OPERATOR # undef CPPAD_ZDOUBLE_COMPARE_OPERATOR # undef CPPAD_ZDOUBLE_OTHER_BINARY_OPERATOR # undef CPPAD_ZDOUBLE_OTHER_COMPARE_OPERATOR # undef CPPAD_ZDOUBLE_STD_MATH_FRIEND # undef CPPAD_ZDOUBLE_STD_MATH # endif cppad-20160000.1/cppad/local/tan_op.hpp0000644000175200017650000001336212656321767016615 0ustar coincoin-web// $Id: tan_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_TAN_OP_HPP # define CPPAD_TAN_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary2_op */ template inline 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(j); z[j] = x[j]; for(k = 1; k <= j; k++) z[j] += Base(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 forward_unary2_op_dir */ template inline 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(q) * ( x[m+ell] + x[m+ell] * y[0]); for(k = 1; k < q; k++) z[m+ell] += Base(k) * x[(k-1)*r+1+ell] * y[(q-k-1)*r+1+ell]; z[m+ell] /= Base(q); // y[m+ell] = Base(2) * 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 forward_unary2_op_0 */ template inline 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 reverse_unary2_op */ template inline 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(j); for(k = 1; k <= j; k++) { px[k] += azmul(pz[j], y[j-k]) * Base(k); py[j-k] += azmul(pz[j], x[k]) * Base(k); } for(k = 0; k < j; k++) pz[k] += azmul(py[j-1], z[j-k-1]) * base_two; --j; } px[0] += azmul(pz[0], Base(1) + y[0]); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/sub_op.hpp0000644000175200017650000003170212656321767016622 0ustar coincoin-web// $Id: sub_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SUB_OP_HPP # define CPPAD_SUB_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 \a parameter is not used. \copydetails forward_binary_op */ template inline 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 + arg[0] * cap_order; Base* y = taylor + 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 \a parameter is not used. \copydetails forward_binary_op_dir */ template inline 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 + arg[0] * num_taylor_per_var + m; Base* y = taylor + 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 \a parameter is not used. \copydetails forward_binary_op_0 */ template inline 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 + arg[0] * cap_order; Base* y = taylor + 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 \a parameter is not used. \copydetails reverse_binary_op */ template inline 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 + arg[0] * nc_partial; Base* py = partial + arg[1] * nc_partial; Base* pz = partial + i_z * nc_partial; // number of indices to access size_t 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 forward_binary_op */ template inline 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 + 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 forward_binary_op_dir */ template inline 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 + 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 forward_binary_op_0 */ template inline 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 + 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 reverse_binary_op */ template inline 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 + 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 forward_binary_op */ template inline 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 + 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 forward_binary_op_dir */ template inline 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 + 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 forward_binary_op_0 */ template inline 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 + 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 reverse_binary_op */ template inline 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 + 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_NAMESPACE # endif cppad-20160000.1/cppad/local/ad_assign.hpp0000644000175200017650000000617212656321767017266 0ustar coincoin-web// $Id: ad_assign.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_AD_ASSIGN_HPP # define CPPAD_AD_ASSIGN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------ $begin ad_assign$$ $spell Vec const $$ $section AD Assignment Operator$$ $mindex assign Base VecAD$$ $head Syntax$$ $icode%y% = %x%$$ $head Purpose$$ Assigns the value in $icode x$$ to the object $icode y$$. In either case, $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/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 inline AD& AD::operator=(const AD &right) { value_ = right.value_; tape_id_ = right.tape_id_; taddr_ = right.taddr_; 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 inline AD& AD::operator=(const Base &b) { value_ = b; tape_id_ = 0; // check that this is a parameter CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); return *this; } /*! Assignment to an ADVec element drops the vector information. \tparam Base Base type for this AD object. */ template inline AD& AD::operator=(const VecAD_reference &x) { return *this = x.ADBase(); } /*! 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 inline AD& AD::operator=(const T &t) { return *this = Base(t); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/div_op.hpp0000644000175200017650000003551612656321767016622 0ustar coincoin-web// $Id: div_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DIV_OP_HPP # define CPPAD_DIV_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 \a parameter is not used. \copydetails forward_binary_op */ template inline 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 + arg[0] * cap_order; Base* y = taylor + 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 \a parameter is not used. \copydetails forward_binary_op_dir */ template inline 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 + arg[0] * num_taylor_per_var; Base* y = taylor + 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 \a parameter is not used. \copydetails forward_binary_op_0 */ template inline 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 + arg[0] * cap_order; Base* y = taylor + 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 \a parameter is not used. \copydetails reverse_binary_op */ template inline 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 + arg[1] * cap_order; const Base* z = taylor + i_z * cap_order; // Partial derivatives corresponding to arguments and result Base* px = partial + arg[0] * nc_partial; Base* py = partial + arg[1] * nc_partial; Base* pz = partial + i_z * nc_partial; // Using CondExp, it can make sense to divide by zero // so do not make it an error. Base inv_y0 = Base(1) / y[0]; size_t k; // number of indices to access 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 forward_binary_op */ template inline 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 + 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); 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 forward_binary_op_dir */ template inline 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 + 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 forward_binary_op_0 */ template inline 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 + 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 reverse_binary_op */ template inline 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 + arg[1] * cap_order; const Base* z = taylor + i_z * cap_order; // Partial derivatives corresponding to arguments and result Base* py = partial + 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) / 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 forward_binary_op */ template inline 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 + 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 forward_binary_op_dir */ template inline 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 + 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 forward_binary_op_0 */ template inline 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 + 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 reverse_binary_op */ template inline 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 + 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) / y; // number of indices to access size_t j = d + 1; while(j) { --j; px[j] += azmul(pz[j], inv_y); } } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/hessian.hpp0000644000175200017650000001215612656321767016767 0ustar coincoin-web// $Id: hessian.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_HESSIAN_HPP # define CPPAD_HESSIAN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Hessian$$ $spell hes typename Taylor HesLuDet const $$ $section Hessian: Easy Driver$$ $mindex second derivative$$ $head Syntax$$ $icode%hes% = %f%.Hessian(%x%, %w%) %$$ $icode%hes% = %f%.Hessian(%x%, %l%) %$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The syntax above sets $icode hes$$ to the Hessian The syntax above sets $icode h$$ to the Hessian $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/hessian.cpp% example/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); w[l] = Base(1); 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); // 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); Forward(1, u); u[j] = Base(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 cppad-20160000.1/cppad/local/num_skip.hpp0000644000175200017650000000536312656321767017164 0ustar coincoin-web// $Id: num_skip.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_NUM_SKIP_HPP # define CPPAD_NUM_SKIP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin number_skip$$ $spell optimizer var taylor_ $$ $section Number of Variables that Can be Skipped$$ $mindex number_skip$$ $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/$$. This leads to the fact that some terms only need to be evaluated depending on the value of the comparison in the conditional expression. The $cref optimize$$ option is capable of detecting some of these 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/number_skip.cpp %$$ $head Example$$ The file $cref number_skip.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ----------------------------------------------------------------------------- */ // BEGIN CppAD namespace namespace CppAD { // This routine is not const becasue 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 OpCode op; size_t i_op; size_t i_var; const addr_t* arg; // number of variables skipped size_t n_skip = 0; // start playback play_.forward_start(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN(op == BeginOp) while(op != EndOp) { // next op play_.forward_next(op, arg, i_op, i_var); if( op == CSumOp) play_.forward_csum(op, arg, i_op, i_var); else if (op == CSkipOp) play_.forward_cskip(op, arg, i_op, i_var); // if( cskip_op_[i_op] ) n_skip += NumRes(op); } return n_skip; } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/user_ad.hpp0000644000175200017650000000400712656321767016753 0ustar coincoin-web// $Id: user_ad.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_USER_AD_HPP # define CPPAD_USER_AD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- $begin AD$$ $spell std bool cos Cpp $$ $section AD Objects$$ $mindex require$$ $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% cppad/local/ad_ctor.hpp% cppad/local/ad_assign.hpp% cppad/local/convert.hpp% cppad/local/ad_valued.hpp% cppad/local/bool_valued.hpp% cppad/local/vec_ad.hpp% cppad/base_require.hpp %$$ $end --------------------------------------------------------------------------- */ # include # include # include # include # include # include # include # endif cppad-20160000.1/cppad/local/sparse_pattern.hpp0000644000175200017650000000332712656321770020361 0ustar coincoin-web// $Id: sparse_pattern.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_PATTERN_HPP # define CPPAD_SPARSE_PATTERN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ // necessary definitions # include # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file sparse_pattern.hpp Determine internal spasity pattern from correpsonding element type. */ /*! 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 \c bool elements. */ template <> struct internal_sparsity { typedef sparse_pack pattern_type; }; /*! Specilization for std::set elements. */ template <> struct internal_sparsity< std::set > { typedef CPPAD_INTERNAL_SPARSE_SET pattern_type; }; } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/base_std_math.hpp0000644000175200017650000001216612656321770020125 0ustar coincoin-web// $Id: base_std_math.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_BASE_STD_MATH_HPP # define CPPAD_BASE_STD_MATH_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin base_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 \c x and return value \c y have type \c 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 cppad-20160000.1/cppad/local/sparse_pack.hpp0000644000175200017650000002710412656321770017621 0ustar coincoin-web// $Id: sparse_pack.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_PACK_HPP # define CPPAD_SPARSE_PACK_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file sparse_pack.hpp Vector of sets of positive integers stored as a packed array of bools. */ /*! Vector of sets of postivie integers, each set stored as a packed boolean array. */ class sparse_pack { 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 static const size_t n_bit_ = std::numeric_limits::digits; /// 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 \c Pack values necessary to represent \c end_ bits. /// (set by constructor and resize). size_t n_pack_; /// Data for all the sets. pod_vector data_; /// index for which we were retrieving next_element /// (use n_set_ if no such index exists). size_t next_index_; /// Next element to start search at /// (use end_ for no such element exists; i.e., past end of the set). size_t next_element_; public: // ----------------------------------------------------------------- /*! Default constructor (no sets) */ sparse_pack(void) : n_set_(0) , end_(0) , n_pack_(0) , next_index_(0) , next_element_(0) { } // ----------------------------------------------------------------- /*! Make use of copy constructor an error \param v vector that we are attempting to make a copy of. */ sparse_pack(const sparse_pack& v) { // Error: // Probably a sparse_pack argument has been passed by value CPPAD_ASSERT_UNKNOWN(0); } // ----------------------------------------------------------------- /*! Destructor */ ~sparse_pack(void) { } // ----------------------------------------------------------------- /*! Change number of sets, set end, and initialize all sets as empty If \c n_set_in is zero, any memory currently allocated for this object is freed. Otherwise, new memory may be allocated for the sets (if needed). \param n_set_in is the number of sets in this vector of sets. \param end_in is the maximum element plus one (the minimum element is 0). */ void resize(size_t n_set_in, size_t end_in) { n_set_ = n_set_in; end_ = end_in; if( n_set_ == 0 ) { data_.free(); return; } // now start a new vector with empty sets Pack zero(0); data_.erase(); n_pack_ = ( 1 + (end_ - 1) / n_bit_ ); size_t i = n_set_ * n_pack_; if( i > 0 ) { data_.extend(i); while(i--) data_[i] = zero; } // values that signify past end of list next_index_ = n_set_; next_element_ = end_; } // ----------------------------------------------------------------- /*! Add one element to a set. \param index is the index for this set in the vector of sets. \param element is the element we are adding to the set. \par Checked Assertions \li index < n_set_ \li element < end_ */ void add_element(size_t index, size_t element) { static Pack one(1); CPPAD_ASSERT_UNKNOWN( index < 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_[ index * n_pack_ + j] |= mask; } // ----------------------------------------------------------------- /*! Is an element of a set. \param index 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. \par Checked Assertions \li index < n_set_ \li element < end_ */ bool is_element(size_t index, size_t element) { static Pack one(1); static Pack zero(0); CPPAD_ASSERT_UNKNOWN( index < 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_[ index * n_pack_ + j] & mask) != zero; } // ----------------------------------------------------------------- /*! Begin retrieving elements from one of the sets. \param index is the index for the set that is going to be retrieved. The elements of the set are retrieved in increasing order. \par Checked Assertions \li index < n_set_ */ void begin(size_t index) { // initialize element to search for in this set CPPAD_ASSERT_UNKNOWN( index < n_set_ ); next_index_ = index; next_element_ = 0; } /*! Get the next element from the current retrieval set. \return is the next element in the set with index specified by the previous call to \c begin. If no such element exists, \c this->end() is returned. */ size_t next_element(void) { static Pack one(1); CPPAD_ASSERT_UNKNOWN( next_index_ < n_set_ ); CPPAD_ASSERT_UNKNOWN( next_element_ <= end_ ); if( next_element_ == end_ ) return end_; // initialize packed data index size_t j = next_element_ / n_bit_; // initialize bit index size_t k = next_element_ - j * n_bit_; // start search at this packed value Pack check = data_[ next_index_ * n_pack_ + j ]; while( true ) { // increment next element before checking this one next_element_++; // check if this element is in the set if( check & (one << k) ) return next_element_ - 1; // check if no more elements in the set if( next_element_ == end_ ) return end_; // increment bit index in Pack value so corresponds to // next element k++; CPPAD_ASSERT_UNKNOWN( k <= n_bit_ ); if( k == n_bit_ ) { // get next packed value k = 0; j++; CPPAD_ASSERT_UNKNOWN( j < n_pack_ ); check = data_[ next_index_ * n_pack_ + j ]; } } // should never get here CPPAD_ASSERT_UNKNOWN(false); return end_; } // ----------------------------------------------------------------- /*! 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 \c sparse_pack object) of the set being assinged. \param other_value is the index (in the other \c sparse_pack object) of the that we are using as the value to assign to the target set. \param other is the other \c sparse_pack object (which may be the same as this \c 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 \c sparse_pack object) of the set being assinged. \param this_left is the index (in this \c sparse_pack object) of the left operand for the union operation. It is OK for \a this_target and \a this_left to be the same value. \param other_right is the index (in the other \c sparse_pack object) of the right operand for the union operation. It is OK for \a this_target and \a other_right to be the same value. \param other is the other \c sparse_pack object (which may be the same as this \c 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++] ); } // ----------------------------------------------------------------- /*! Amount of memory used by this vector of sets \return The amount of memory in units of type unsigned char memory. */ size_t memory(void) const { return n_set_ * n_pack_ * sizeof(Pack); } // ----------------------------------------------------------------- /*! Fetch n_set for vector of sets object. \return Number of from sets for this vector of sets object */ size_t n_set(void) const { return n_set_; } // ----------------------------------------------------------------- /*! Fetch end for this vector of sets object. \return is the maximum element value plus one (the minimum element value is 0). */ size_t end(void) const { return end_; } }; /*! Copy a user vector of bools sparsity pattern to an internal sparse_pack object. \tparam VectorBool is a simple vector with elements of type bool. \param internal The input value of sparisty does not matter. Upon return it contains the same sparsity pattern as \c user (or the transposed sparsity pattern). \param user sparsity pattern that we are placing \c internal. \param n_row number of rows in the sparsity pattern in \c user (rand dimension). \param n_col number of columns in the sparsity pattern in \c user (domain dimension). \param transpose if true, the sparsity pattern in \c internal is the transpose of the one in \c user. Otherwise it is the same sparsity pattern. */ template void sparsity_user2internal( sparse_pack& internal , const VectorBool& user , size_t n_row , size_t n_col , bool transpose ) { size_t i, j; CPPAD_ASSERT_KNOWN( size_t( user.size() ) == n_row * n_col, "Size of this vector of bools sparsity pattern is not equal\n" "product of domain and range dimensions for corresponding function." ); // transposed pattern case if( transpose ) { internal.resize(n_col, n_row); for(j = 0; j < n_col; j++) { for(i = 0; i < n_row; i++) { if( user[ i * n_col + j ] ) internal.add_element(j, i); } } return; } // same pattern case internal.resize(n_row, n_col); for(i = 0; i < n_row; i++) { for(j = 0; j < n_col; j++) { if( user[ i * n_col + j ] ) internal.add_element(i, j); } } return; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/rev_two.hpp0000644000175200017650000001410112656321770017004 0ustar coincoin-web// $Id: rev_two.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_REV_TWO_HPP # define CPPAD_REV_TWO_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin RevTwo$$ $spell ddw typename Taylor const $$ $section Reverse Mode Second Partial Derivative Driver$$ $mindex order easy$$ $head Syntax$$ $icode%ddw% = %f%.RevTwo(%x%, %i%, %j%)%$$ $head Purpose$$ We use $latex F : B^n \rightarrow B^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The syntax above sets $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 %VectorBase% &%x% %$$ (see $cref/VectorBase/RevTwo/VectorBase/$$ 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 %VectorSize_t% &%i% %$$ (see $cref/VectorSize_t/RevTwo/VectorSize_t/$$ below) We use $icode p$$ to denote the size of the vector $icode i$$. All of the indices in $icode i$$ 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 %VectorSize_t% &%j% %$$ (see $cref/VectorSize_t/RevTwo/VectorSize_t/$$ below) and its size must be equal to $icode p$$, the size of the vector $icode i$$. All of the indices in $icode j$$ 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% %VectorBase% %ddw% %$$ (see $cref/VectorBase/RevTwo/VectorBase/$$ below) and its size is $latex n * p$$. It contains the requested partial derivatives; to be specific, for $latex k = 0 , \ldots , n - 1 $$ and $latex \ell = 0 , \ldots , p - 1$$ $latex \[ ddw [ k * p + \ell ] = \DD{ F_{i[ \ell ]} }{ x_{j[ \ell ]} }{ x_k } (x) \] $$ $head VectorBase$$ The type $icode VectorBase$$ 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 VectorSize_t$$ The type $icode VectorSize_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/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 VectorBase ADFun::RevTwo( const VectorBase &x, const VectorSize_t &i, const VectorSize_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 VectorBase is Simple Vector class with Base elements CheckSimpleVector(); // check VectorSize_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 VectorBase ddw(n * p); // direction vector in argument space VectorBase dx(n); for(j1 = 0; j1 < n; j1++) dx[j1] = Base(0); // direction vector in range space VectorBase w(m); for(i1 = 0; i1 < m; i1++) w[i1] = Base(0); // place to hold the results of a reverse calculation VectorBase 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); Forward(1, dx); dx[j1] = Base(0); } // execute a reverse in this component direction i1 = i[l]; w[i1] = Base(1); r = Reverse(2, w); w[i1] = Base(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 cppad-20160000.1/cppad/local/atanh.hpp0000644000175200017650000000453412656321770016423 0ustar coincoin-web// $Id$ # ifndef CPPAD_ATANH_HPP # define CPPAD_ATANH_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin atanh$$ $spell atanh const Vec std cmath CppAD tanh $$ $section The Inverse Hyperbolic Tangent Function: atanh$$ $head Syntax$$ $icode%y% = atanh(%x%)%$$ $head Description$$ The inverse hyperbolic tangent function is defined by $icode%x% == tanh(%y%)%$$. $head x, y$$ See the $cref/possible types/unary_standard_math/Possible Types/$$ for a unary standard math function. $head CPPAD_USE_CPLUSPLUS_2011$$ $subhead true$$ If this preprocessor symbol is true ($code 1$$), and $icode x$$ is an AD type, this is an $cref/atomic operation/glossary/Operation/Atomic/$$. $subhead false$$ If this preprocessor symbol is false ($code 0$$), CppAD uses the representation $latex \[ \R{atanh} (x) = \frac{1}{2} \log \left( \frac{1 + x}{1 - x} \right) \] $$ to compute this function. $head Example$$ $children% example/atanh.cpp %$$ The file $cref atanh.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- */ # include # if ! CPPAD_USE_CPLUSPLUS_2011 // BEGIN CppAD namespace namespace CppAD { template Type atanh_template(const Type &x) { return CppAD::log( (1 + x) / (1 - x) ) / 2.0; } inline float atanh(const float &x) { return atanh_template(x); } inline double atanh(const double &x) { return atanh_template(x); } template inline AD atanh(const AD &x) { return atanh_template(x); } template inline AD atanh(const VecAD_reference &x) { return atanh_template( x.ADBase() ); } } // END CppAD namespace # endif // CPPAD_USE_CPLUSPLUS_2011 # endif // CPPAD_ATANH_INCLUDED cppad-20160000.1/cppad/local/fun_eval.hpp0000644000175200017650000000172312656321770017124 0ustar coincoin-web// $Id: fun_eval.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FUN_EVAL_HPP # define CPPAD_FUN_EVAL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin FunEval$$ $spell $$ $section Evaluate ADFun Functions, Derivatives, and Sparsity Patterns$$ $childtable% omh/forward/forward.omh% omh/reverse/reverse.omh% cppad/local/sparse.hpp %$$ $end */ # include # include # include # endif cppad-20160000.1/cppad/local/erf_op.hpp0000644000175200017650000002670112656321770016602 0ustar coincoin-web// $Id$ # ifndef CPPAD_ERF_OP_HPP # define CPPAD_ERF_OP_HPP # if CPPAD_USE_CPLUSPLUS_2011 /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include namespace CppAD { // BEGIN_CPPAD_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 \par CPPAD_HAS_ERROF_FUNCTION This macro is either zero or one and forward_erf_op is only defined when it is one. \tparam Base base type for the operator; i.e., this operation was recorded using AD< \a Base > and computations by this routine are done using type \a Base. \param 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 \a taylor corresponding to z. The auxillary result is called y has index \a i_z - 1. \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 \c taylor array. \param taylor \b Input: taylor [ 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 */ template inline 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 ); // 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] = 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] = 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 + 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 ) { // zero order Taylor coefficient for z_4 z_4[0] = erf(x[0]); p++; } for(size_t j = p; j <= q; j++) { Base base_j = static_cast(j); z_4[j] = static_cast(0); for(size_t k = 1; k <= j; k++) z_4[j] += (Base(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 \par CPPAD_HAS_ERROF_FUNCTION This macro is either zero or one and forward_erf_op is only defined when it is one. \tparam Base base type for the operator; i.e., this operation was recorded using AD< \a Base > and computations by this routine are done using type \a Base. \param i_z variable index corresponding to the last (primary) result for this operation; i.e. the row index in \a taylor corresponding to z. The auxillary result is called y has index \a i_z - 1. \param 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 \c taylor array. \param taylor \b Input: taylor [ 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 */ template inline 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 ); // 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] = 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] = 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 + arg[0] * cap_order; Base* z_4 = taylor + (i_z + 4) * cap_order; z_4[0] = erf(x[0]); } /*! Compute reverse mode partial derivatives for result of op = ErfOp. The C++ source code corresponding to this operation is \verbatim z = erf(x) \endverbatim \par CPPAD_HAS_ERROF_FUNCTION This macro is either zero or one and reverse_tan_op is only defined when it is one. \tparam Base base type for the operator; i.e., this operation was recorded using AD< \a Base > and computations by this routine are done using type \a Base. \param 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 \a taylor corresponding to z. The auxillary result is called y has index \a i_z - 1. \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 \c taylor array. \param taylor \b Input: taylor [ 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 [ 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 [ 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 inline 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 ); // 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 + arg[0] * cap_order; Base* px = partial + 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(j); for(size_t k = 1; k <= j; k++) { px[k] += azmul(pz_4[j], z_3[j-k]) * Base(k); pz_3[j-k] += azmul(pz_4[j], x[k]) * Base(k); } j--; } px[0] += azmul(pz_4[0], z_3[0]); // z_3 = (2 / sqrt(pi)) * exp( - x * x ) addr[0] = arg[2]; // 2 / sqrt(pi) addr[1] = 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] = 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_NAMESPACE # endif // CPPAD_USE_CPLUSPLUS_2011 # endif // CPPAD_ERF_OP_INCLUDED cppad-20160000.1/cppad/local/mul_op.hpp0000644000175200017650000002252012656321770016616 0ustar coincoin-web// $Id: mul_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_MUL_OP_HPP # define CPPAD_MUL_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file mul_op.hpp Forward and reverse mode calculations for z = 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 \a parameter is not used. \copydetails forward_binary_op */ template inline 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 + arg[0] * cap_order; Base* y = taylor + arg[1] * cap_order; Base* z = taylor + i_z * cap_order; size_t k; for(size_t d = p; d <= q; d++) { z[d] = Base(0); for(k = 0; k <= d; k++) z[d] += 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 \a parameter is not used. \copydetails forward_binary_op_dir */ template inline 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 + arg[0] * num_taylor_per_var; Base* y = taylor + arg[1] * num_taylor_per_var; Base* z = taylor + i_z * num_taylor_per_var; size_t k, ell, m; for(ell = 0; ell < r; ell++) { m = (q-1)*r + ell + 1; z[m] = 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 \a parameter is not used. \copydetails forward_binary_op_0 */ template inline 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 + arg[0] * cap_order; Base* y = taylor + 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 \a parameter is not used. \copydetails reverse_binary_op */ template inline 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 + arg[0] * cap_order; const Base* y = taylor + arg[1] * cap_order; // Partial derivatives corresponding to arguments and result Base* px = partial + arg[0] * nc_partial; Base* py = partial + arg[1] * nc_partial; Base* pz = partial + i_z * nc_partial; // number of indices to access size_t j = d + 1; size_t k; while(j) { --j; for(k = 0; k <= j; k++) { px[j-k] += azmul(pz[j], y[k]); py[k] += azmul(pz[j], x[j-k]); } } } // --------------------------- 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 forward_binary_op */ template inline 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 + 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 forward_binary_op_dir */ template inline 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 + 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 forward_binary_op_0 */ template inline 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 + 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 reverse_binary_op */ template inline 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 + 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_NAMESPACE # endif cppad-20160000.1/cppad/local/abort_recording.hpp0000644000175200017650000000322312656321770020465 0ustar coincoin-web// $Id: abort_recording.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ABORT_RECORDING_HPP # define CPPAD_ABORT_RECORDING_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin abort_recording$$ $spell $$ $section Abort Recording of an Operation Sequence$$ $mindex tape$$ $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/abort_recording.cpp %$$ $head Example$$ The file $cref abort_recording.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. $end ---------------------------------------------------------------------------- */ namespace CppAD { template void AD::abort_recording(void) { ADTape* tape = AD::tape_ptr(); if( tape != CPPAD_NULL ) AD::tape_manage(tape_manage_delete); } } # endif cppad-20160000.1/cppad/local/player.hpp0000644000175200017650000005325012656321770016623 0ustar coincoin-web// $Id: player.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_PLAYER_HPP # define CPPAD_PLAYER_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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< \a Base > operations when recorded. Operations during playback are done using the type \a Base . */ template class player { // -------------- Variables that define the recording ----------------------- private: /// 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_rec_; /// The VecAD indices in the recording. pod_vector vecad_ind_rec_; /// The operation argument indices in the recording pod_vector op_arg_rec_; /// The parameters in the recording. /// Note that Base may not be plain old data, so use false in consructor. pod_vector par_rec_; /// Character strings ('\\0' terminated) in the recording. pod_vector text_rec_; // --------------- Functions used to create and maniplate a recording ------- public: /// Default constructor player(void) : num_var_rec_(0) , num_load_op_rec_(0) , op_rec_( std::numeric_limits::max() ) , vecad_ind_rec_( std::numeric_limits::max() ) , op_arg_rec_( std::numeric_limits::max() ) , par_rec_( std::numeric_limits::max() ) , text_rec_( std::numeric_limits::max() ) { } /// Destructor ~player(void) { } // =============================================================== /*! Moving an operation sequence from a recorder to a 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 \c pod_vector member variables in \c this have been swapped with \c rec . */ void get(recorder& rec) { size_t i; // just set size_t values num_var_rec_ = rec.num_var_rec_; num_load_op_rec_ = rec.num_load_op_rec_; // op_rec_ op_rec_.swap(rec.op_rec_); // vec_ind_rec_ vecad_ind_rec_.swap(rec.vecad_ind_rec_); // op_arg_rec_ op_arg_rec_.swap(rec.op_arg_rec_); // par_rec_ par_rec_.swap(rec.par_rec_); // text_rec_ text_rec_.swap(rec.text_rec_); // set the number of VecAD vectors num_vecad_vec_rec_ = 0; for(i = 0; i < vecad_ind_rec_.size(); i += vecad_ind_rec_[i] + 1) num_vecad_vec_rec_++; // vecad_ind_rec_ contains size of each VecAD followed by // the parameter indices used to iniialize it. CPPAD_ASSERT_UNKNOWN( i == vecad_ind_rec_.size() ); } // =============================================================== /*! Copying an operation sequence from one player to another \param play the object that contains the operatoion sequence to copy. */ void operator=(const player& play) { num_var_rec_ = play.num_var_rec_; num_load_op_rec_ = play.num_load_op_rec_; op_rec_ = play.op_rec_; num_vecad_vec_rec_ = play.num_vecad_vec_rec_; vecad_ind_rec_ = play.vecad_ind_rec_; op_arg_rec_ = play.op_arg_rec_; par_rec_ = play.par_rec_; text_rec_ = play.text_rec_; } // =============================================================== /// Erase all information in an operation sequence player. void Erase(void) { num_var_rec_ = 0; num_load_op_rec_ = 0; num_vecad_vec_rec_ = 0; op_rec_.erase(); vecad_ind_rec_.erase(); op_arg_rec_.erase(); par_rec_.erase(); text_rec_.erase(); } public: /*! \brief Old method of fetching 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_rec_[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 vecad_ind_rec_[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 par_rec_[i]; } /*! \brief Fetch entire parameter vector from the recording. \return the entire parameter vector. */ const Base* GetPar(void) const { return par_rec_.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_rec_.size() ); return text_rec_.data() + i; } /// 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_rec_.size(); } /// Fetch number of VecAD indices in the recording. size_t num_vec_ind_rec(void) const { return vecad_ind_rec_.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 op_arg_rec_.size(); } /// Fetch number of parameters in the recording. size_t num_par_rec(void) const { return par_rec_.size(); } /// Fetch number of characters (representing strings) in the recording. size_t num_text_rec(void) const { return text_rec_.size(); } /// Fetch a rough measure of amount of memory used to store recording /// (just lengths, not capacities). size_t Memory(void) const { return op_rec_.size() * sizeof(OpCode) + op_arg_rec_.size() * sizeof(addr_t) + par_rec_.size() * sizeof(Base) + text_rec_.size() * sizeof(char) + vecad_ind_rec_.size() * sizeof(addr_t) ; } // ------------- Variables used for new methog of playing back a recording --- private: /// Current operator OpCode op_; /// Index in recording corresponding to current operator size_t op_index_; /// Current offset of the argument indices in op_arg_rec_ const addr_t* op_arg_; /// Index for primary (last) variable corresponding to current operator size_t var_index_; // ----------- Functions used in new method for palying back a recording --- public: /*! Start a play back of the recording during a forward sweep. Use repeated calls to forward_next to play back one operator at a time. \param op [out] The input value of \c op does not matter. Its output value is the first operator in the recording; i.e., BeginOp. \param op_arg [out] The input value of \c op_arg does not matter. Its output value is the beginning of the vector of argument indices for the first operation; i.e., 0 \param op_index [out] The input value of \c op_index does not matter. Its output value is the index of the next first operator in the recording; i.e., 0. \param var_index [out] The input value of \c var_index does not matter. Its output value is the index of the primary (last) result corresponding to the the first operator (which must be a BeginOp); i.e., 0. */ void forward_start( OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index) { op = op_ = OpCode( op_rec_[0] ); op_arg = op_arg_ = op_arg_rec_.data(); op_index = op_index_ = 0; var_index = var_index_ = 0; CPPAD_ASSERT_UNKNOWN( op_ == BeginOp ); CPPAD_ASSERT_NARG_NRES(op_, 1, 1); return; } /*! Fetch the next operator during a forward sweep. Use forward_start to initialize to the first operator; i.e., the BeginOp at the beginning of the recording. We use the notation forward_routine to denote the set forward_start, forward_next, forward_csum, forward_cskip. \param op [in,out] The input value of \c op must be its output value from the previous call to a forward_routine. Its output value is the next operator in the recording. For speed, \c forward_next does not check for the special cases where op == CSumOp or op == CSkipOp. In these cases, the other return values from \c forward_next must be corrected by a call to \c forward_csum or \c forward_cskip respectively. \param op_arg [in,out] The input value of \c op_arg must be its output value form the previous call to a forward routine. Its output value is the beginning of the vector of argument indices for this operation. \param op_index [in,out] The input value of \c op_index must be its output value form the previous call to a forward routine. Its output value is the index of the next operator in the recording. Thus the ouput value following the previous call to forward_start is one. In addition, the output value increases by one with each call to forward_next. \param var_index [in,out] The input value of \c var_index must be its output value form the previous call to a forward routine. Its output value is the index of the primary (last) result corresponding to the operator op. */ void forward_next( OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index) { using CppAD::NumRes; using CppAD::NumArg; CPPAD_ASSERT_UNKNOWN( op_ == op ); CPPAD_ASSERT_UNKNOWN( op_arg == op_arg_ ); CPPAD_ASSERT_UNKNOWN( op_index == op_index_ ); CPPAD_ASSERT_UNKNOWN( var_index == var_index_ ); // index for the next operator op_index = ++op_index_; // first argument for next operator op_arg = op_arg_ += NumArg(op_); // next operator op = op_ = OpCode( op_rec_[ op_index_ ] ); // index for last result for next operator var_index = var_index_ += NumRes(op); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.data() <= op_arg_ ); CPPAD_ASSERT_UNKNOWN( op_arg_ + NumArg(op) <= op_arg_rec_.data() + op_arg_rec_.size() ); CPPAD_ASSERT_UNKNOWN( var_index_ < num_var_rec_ ); } /*! Correct \c forward_next return values when op == CSumOp. \param op [in] The input value of op must be the return value from the previous call to \c forward_next and must be \c CSumOp. It is not modified. \param op_arg [in,out] The input value of \c op_arg must be the return value from the previous call to \c forward_next. Its output value is the beginning of the vector of argument indices for the next operation. \param op_index [in] The input value of \c op_index does must be the return value from the previous call to \c forward_next. Its is not modified. \param var_index [in,out] The input value of \c var_index must be the return value from the previous call to \c forward_next. It is not modified. */ void forward_csum( OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index) { using CppAD::NumRes; using CppAD::NumArg; CPPAD_ASSERT_UNKNOWN( op_ == op ); CPPAD_ASSERT_UNKNOWN( op_arg == op_arg_ ); CPPAD_ASSERT_UNKNOWN( op_index == op_index_ ); CPPAD_ASSERT_UNKNOWN( var_index == var_index_ ); CPPAD_ASSERT_UNKNOWN( op == CSumOp ); CPPAD_ASSERT_UNKNOWN( NumArg(CSumOp) == 0 ); CPPAD_ASSERT_UNKNOWN( op_arg[0] + op_arg[1] == op_arg[ 3 + op_arg[0] + op_arg[1] ] ); /* The only thing that really needs fixing is op_arg_. Actual number of arugments for this operator is op_arg[0] + op_arg[1] + 4. We must change op_arg_ so that when you add NumArg(CSumOp) you get first argument for next operator in sequence. */ op_arg = op_arg_ += op_arg[0] + op_arg[1] + 4; CPPAD_ASSERT_UNKNOWN( op_arg_rec_.data() <= op_arg_ ); CPPAD_ASSERT_UNKNOWN( op_arg_ + NumArg(op) <= op_arg_rec_.data() + op_arg_rec_.size() ); CPPAD_ASSERT_UNKNOWN( var_index_ < num_var_rec_ ); } /*! Correct \c forward_next return values when op == CSkipOp. \param op [in] The input value of op must be the return value from the previous call to \c forward_next and must be \c CSkipOp. It is not modified. \param op_arg [in,out] The input value of \c op_arg must be the return value from the previous call to \c forward_next. Its output value is the beginning of the vector of argument indices for the next operation. \param op_index [in] The input value of \c op_index does must be the return value from the previous call to \c forward_next. Its is not modified. \param var_index [in,out] The input value of \c var_index must be the return value from the previous call to \c forward_next. It is not modified. */ void forward_cskip( OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index) { using CppAD::NumRes; using CppAD::NumArg; CPPAD_ASSERT_UNKNOWN( op_ == op ); CPPAD_ASSERT_UNKNOWN( op_arg == op_arg_ ); CPPAD_ASSERT_UNKNOWN( op_index == op_index_ ); CPPAD_ASSERT_UNKNOWN( var_index == var_index_ ); CPPAD_ASSERT_UNKNOWN( op == CSkipOp ); CPPAD_ASSERT_UNKNOWN( NumArg(CSkipOp) == 0 ); CPPAD_ASSERT_UNKNOWN( op_arg[4] + op_arg[5] == op_arg[ 6 + op_arg[4] + op_arg[5] ] ); /* The only thing that really needs fixing is op_arg_. Actual number of arugments for this operator is 7 + op_arg[4] + op_arg[5] We must change op_arg_ so that when you add NumArg(CSkipOp) you get first argument for next operator in sequence. */ op_arg = op_arg_ += 7 + op_arg[4] + op_arg[5]; CPPAD_ASSERT_UNKNOWN( op_arg_rec_.data() <= op_arg_ ); CPPAD_ASSERT_UNKNOWN( op_arg_ + NumArg(op) <= op_arg_rec_.data() + op_arg_rec_.size() ); CPPAD_ASSERT_UNKNOWN( var_index_ < num_var_rec_ ); } /*! Start a play back of the recording during a reverse sweep. Use repeated calls to reverse_next to play back one operator at a time. \param op [out] The input value of \c op does not matter. Its output value is the last operator in the recording; i.e., EndOp. \param op_arg [out] The input value of \c op_arg does not matter. Its output value is the beginning of the vector of argument indices for the last operation; (there are no arguments for the last operation so \a op_arg is invalid). \param op_index [out[ The input value of \c op_index does not matter. Its output value is the index of the last operator in the recording. \param var_index [out] The input value of \c var_index does not matter. Its output value is the index of the primary (last) result corresponding to the the last operator (which must be a EndOp). (there are no results for the last operation so \a var_index is invalid). */ void reverse_start( OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index) { op_arg = op_arg_ = op_arg_rec_.data() + op_arg_rec_.size(); op_index = op_index_ = op_rec_.size() - 1; var_index = var_index_ = num_var_rec_ - 1; op = op_ = OpCode( op_rec_[ op_index_ ] ); CPPAD_ASSERT_UNKNOWN( op_ == EndOp ); CPPAD_ASSERT_NARG_NRES(op, 0, 0); return; } /*! Fetch the next operator during a reverse sweep. Use reverse_start to initialize to reverse play back. The first call to reverse_next (after reverse_start) will give the last operator in the recording. We use the notation reverse_routine to denote the set reverse_start, reverse_next, reverse_csum, reverse_cskip. \param op [in,out] The input value of \c op must be its output value from the previous call to a reverse_routine. Its output value is the next operator in the recording (in reverse order). The last operator sets op equal to EndOp. \param op_arg [in,out] The input value of \c op_arg must be its output value from the previous call to a reverse_routine. Its output value is the beginning of the vector of argument indices for this operation. The last operator sets op_arg equal to the beginning of the argument indices for the entire recording. For speed, \c reverse_next does not check for the special cases op == CSumOp or op == CSkipOp. In these cases, the other return values from \c reverse_next must be corrected by a call to \c reverse_csum or \c reverse_cskip respectively. \param op_index [in,out] The input value of \c op_index must be its output value from the previous call to a reverse_routine. Its output value is the index of this operator in the recording. Thus the output value following the previous call to reverse_start is equal to the number of variables in the recording minus one. In addition, the output value decreases by one with each call to reverse_next. The last operator sets op_index equal to 0. \param var_index [in,out] The input value of \c var_index must be its output value from the previous call to a reverse_routine. Its output value is the index of the primary (last) result corresponding to the operator op. The last operator sets var_index equal to 0 (corresponding to BeginOp at beginning of operation sequence). */ void reverse_next( OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index) { using CppAD::NumRes; using CppAD::NumArg; CPPAD_ASSERT_UNKNOWN( op_ == op ); CPPAD_ASSERT_UNKNOWN( op_arg == op_arg_ ); CPPAD_ASSERT_UNKNOWN( op_index == op_index_ ); CPPAD_ASSERT_UNKNOWN( var_index == var_index_ ); // index of the last result for the next operator CPPAD_ASSERT_UNKNOWN( var_index_ >= NumRes(op_) ); var_index = var_index_ -= NumRes(op_); // next operator CPPAD_ASSERT_UNKNOWN( op_index_ > 0 ); op_index = --op_index_; // index op = op_ = OpCode( op_rec_[ op_index_ ] ); // value // first argument for next operator op_arg = op_arg_ -= NumArg(op); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.data() <= op_arg_ ); CPPAD_ASSERT_UNKNOWN( op_arg_ + NumArg(op) <= op_arg_rec_.data() + op_arg_rec_.size() ); } /*! Correct \c reverse_next return values when op == CSumOp. \param op [in] The input value of \c op must be the return value from the previous call to \c reverse_next and must be \c CSumOp. It is not modified. \param op_arg [in,out] The input value of \c op_arg must be the return value from the previous call to \c reverse_next. Its output value is the beginning of the vector of argument indices for this operation. \param op_index [in] The input value of \c op_index must be the return value from the previous call to \c reverse_next. It is not modified. \param var_index [in] The input value of \c var_index must be the return value from the previous call to \c reverse_next. It is not modified. */ void reverse_csum( OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index) { using CppAD::NumRes; using CppAD::NumArg; CPPAD_ASSERT_UNKNOWN( op_ == op ); CPPAD_ASSERT_UNKNOWN( op_arg == op_arg_ ); CPPAD_ASSERT_UNKNOWN( op_index == op_index_ ); CPPAD_ASSERT_UNKNOWN( var_index == var_index_ ); CPPAD_ASSERT_UNKNOWN( op == CSumOp ); CPPAD_ASSERT_UNKNOWN( NumArg(CSumOp) == 0 ); /* The variables that need fixing are op_arg_ and op_arg. Currently, op_arg points to the last argument for the previous operator. */ // last argument for this csum operation --op_arg; // first argument for this csum operation op_arg = op_arg_ -= (op_arg[0] + 4); // now op_arg points to the first argument for this csum operator CPPAD_ASSERT_UNKNOWN( op_arg[0] + op_arg[1] == op_arg[ 3 + op_arg[0] + op_arg[1] ] ); CPPAD_ASSERT_UNKNOWN( op_index_ < op_rec_.size() ); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.data() <= op_arg_ ); CPPAD_ASSERT_UNKNOWN( var_index_ < num_var_rec_ ); } /*! Correct \c reverse_next return values when op == CSkipOp. \param op [int] The input value of \c op must be the return value from the previous call to \c reverse_next and must be \c CSkipOp. It is not modified. \param op_arg [in,out] The input value of \c op_arg must be the return value from the previous call to \c reverse_next. Its output value is the beginning of the vector of argument indices for this operation. \param op_index [in] The input value of \c op_index must be the return value from the previous call to \c reverse_next. It is not modified. \param var_index [in] The input value of \c var_index must be the return value from the previous call to \c reverse_next. It is not modified. */ void reverse_cskip( OpCode& op, const addr_t*& op_arg, size_t& op_index, size_t& var_index) { using CppAD::NumRes; using CppAD::NumArg; CPPAD_ASSERT_UNKNOWN( op_ == op ); CPPAD_ASSERT_UNKNOWN( op_arg == op_arg_ ); CPPAD_ASSERT_UNKNOWN( op_index == op_index_ ); CPPAD_ASSERT_UNKNOWN( var_index == var_index_ ); CPPAD_ASSERT_UNKNOWN( op == CSkipOp ); CPPAD_ASSERT_UNKNOWN( NumArg(CSkipOp) == 0 ); /* The variables that need fixing are op_arg_ and op_arg. Currently, op_arg points to the last arugment for the previous operator. */ // last argument for this cskip operation --op_arg; // first argument for this cskip operation op_arg = op_arg_ -= (op_arg[0] + 7); CPPAD_ASSERT_UNKNOWN( op_arg[4] + op_arg[5] == op_arg[ 6 + op_arg[4] + op_arg[5] ] ); CPPAD_ASSERT_UNKNOWN( op_index_ < op_rec_.size() ); CPPAD_ASSERT_UNKNOWN( op_arg_rec_.data() <= op_arg_ ); CPPAD_ASSERT_UNKNOWN( var_index_ < num_var_rec_ ); } }; } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/opt_val_hes.hpp0000644000175200017650000003346612656321770017641 0ustar coincoin-web// $Id: opt_val_hes.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_OPT_VAL_HES_HPP # define CPPAD_OPT_VAL_HES_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin opt_val_hes$$ $spell hes sy Jacobian hes signdet jac Bradley const CppAD $$ $section Jacobian and Hessian of Optimal Values$$ $mindex opt_val_hes$$ $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/opt_val_hes.cpp %$$ The file $cref opt_val_hes.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. $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 \c BaseVector must be a SimpleVector class. We use \c Base to refer to the type of the elements of \c BaseVector; i.e., BaseVector::value_type. \param x is a vector with size \c n. It specifies the point at which we evaluating the Jacobian \f$ V^{(1)} (x) \f$ (and possibly the Hessian \f$ V^{(2)} (x) \f$). \param y is a vector with size \c m. It must be equal to \f$ Y(x) \f$; i.e., it must solve the implicit equation \f[ 0 = \partial_y F ( x , y) \f] \param fun The argument \c fun is an object of type \c Fun wich must support the member functions listed below. CppAD will may be recording operations of the type \c AD when these member functions are called. These member functions must not stop such a recording; e.g., they must not call \c AD::abort_recording. \par Fun::ad_vector The type Fun::ad_vector must be a SimpleVector class with elements of type \c AD; i.e. Fun::ad_vector::value_type is equal to \c AD. \par fun.ell the type \c Fun must support the syntax \verbatim ell = fun.ell() \endverbatim where \c ell is a \c size_t value that is set to \f$ \ell \f$; i.e., the number of terms in the summation. \par fun.s The type \c Fun must support the syntax \verbatim s_k = fun.s(k, x, y) \endverbatim The argument \c k has prototype size_t k. The argument \c x has prototype const Fun::ad_vector& x and its size must be equal to \c n. The argument \c y has prototype const Fun::ad_vector& y and its size must be equal to \c m. The return value \c s_k has prototype \c AD s_k and its value must be given by \f$ s_k = S_k ( x , y ) \f$. \par fun.sy The type \c Fun must support the syntax \verbatim sy_k = fun.sy(k, x, y) \endverbatim The argument \c k has prototype size_t k. The argument \c x has prototype const Fun::ad_vector& x and its size must be equal to \c n. The argument \c y has prototype const Fun::ad_vector& y and its size must be equal to \c m. The return value \c sy_k has prototype Fun::ad_vector& sy_k, its size is \c 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 \c 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 \c x is the first argument to \c 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 \c 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 cppad-20160000.1/cppad/local/ad_fun.hpp0000644000175200017650000004543012656321770016564 0ustar coincoin-web// $Id: ad_fun.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_AD_FUN_HPP # define CPPAD_AD_FUN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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% cppad/local/independent.hpp% cppad/local/fun_construct.hpp% cppad/local/dependent.hpp% cppad/local/abort_recording.hpp% omh/seq_property.omh% cppad/local/fun_eval.hpp% cppad/local/drivers.hpp% cppad/local/fun_check.hpp% cppad/local/optimize.hpp% cppad/local/check_for_nan.hpp %$$ $end */ 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 \c Base operations. */ template class ADFun { // ------------------------------------------------------------ // Private member variables private: /// Has this ADFun object been optmized bool has_been_optimized_; /// Check for nan's and report message to user (default value is true). bool check_for_nan_; /// 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 CppAD::vector ind_taddr_; /// tape address and parameter flag for the dependent variables CppAD::vector dep_taddr_; /// which dependent variables are actually parameters CppAD::vector dep_parameter_; /// results of the forward mode calculations pod_vector taylor_; /// which operations can be conditionally skipped /// Set during forward pass of order zero pod_vector cskip_op_; /// Variable on the tape corresponding to each vecad load operation /// (if zero, the operation corresponds to a parameter). pod_vector load_op_; /// the operation sequence corresponding to this object player play_; /// Packed results of the forward mode Jacobian sparsity calculations. /// for_jac_sparse_pack_.n_set() != 0 implies other sparsity results /// are empty 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. CPPAD_INTERNAL_SPARSE_SET for_jac_sparse_set_; // ------------------------------------------------------------ // Private member functions /// change the operation sequence corresponding to this object template void Dependent(ADTape *tape, const ADvector &y); // ------------------------------------------------------------ // vector of bool version of ForSparseJac // (see doxygen in for_sparse_jac.hpp) template void ForSparseJacCase( bool set_type , bool transpose , bool dependency, size_t q , const VectorSet& r , VectorSet& s ); // vector of std::set version of ForSparseJac // (see doxygen in for_sparse_jac.hpp) template void ForSparseJacCase( const std::set& set_type , bool transpose , bool dependency, size_t q , const VectorSet& r , VectorSet& s ); // ------------------------------------------------------------ // vector of bool version of RevSparseJac // (see doxygen in rev_sparse_jac.hpp) template void RevSparseJacCase( bool set_type , bool transpose , bool dependency, size_t p , const VectorSet& s , VectorSet& r ); // vector of std::set version of RevSparseJac // (see doxygen in rev_sparse_jac.hpp) template void RevSparseJacCase( const std::set& set_type , bool transpose , bool dependency, size_t p , const VectorSet& s , VectorSet& r ); // ------------------------------------------------------------ // vector of bool version of RevSparseHes // (see doxygen in rev_sparse_hes.hpp) template void RevSparseHesCase( bool set_type , bool transpose , size_t q , const VectorSet& s , VectorSet& h ); // vector of std::set version of RevSparseHes // (see doxygen in rev_sparse_hes.hpp) template void RevSparseHesCase( const std::set& set_type , bool transpose , size_t q , const VectorSet& s , VectorSet& h ); // ------------------------------------------------------------ // Forward mode version of SparseJacobian // (see doxygen in sparse_jacobian.hpp) template size_t SparseJacobianFor( const VectorBase& x , VectorSet& p_transpose , const VectorSize& row , const VectorSize& col , VectorBase& jac , sparse_jacobian_work& work ); // Reverse mode version of SparseJacobian // (see doxygen in sparse_jacobian.hpp) template size_t SparseJacobianRev( const VectorBase& x , VectorSet& p , const VectorSize& row , const VectorSize& col , VectorBase& jac , sparse_jacobian_work& work ); // ------------------------------------------------------------ // combined sparse_set, sparse_list and sparse_pack version of // SparseHessian (see doxygen in sparse_hessian.hpp) template size_t SparseHessianCompute( const VectorBase& x , const VectorBase& w , VectorSet& sparsity , const VectorSize& row , const VectorSize& col , VectorBase& hes , sparse_hessian_work& work ); // ------------------------------------------------------------ public: /// copy constructor ADFun(const ADFun& g) : num_var_tape_(0) { 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." ); } /// default constructor ADFun(void); // assignment operator // (see doxygen in fun_construct.hpp) void operator=(const ADFun& f); /// sequence constructor template ADFun(const ADvector &x, const ADvector &y); /// destructor ~ADFun(void) { } /// set value of check_for_nan_ void check_for_nan(bool value) { check_for_nan_ = value; } bool check_for_nan(void) const { return check_for_nan_; } /// assign a new operation sequence template void Dependent(const ADvector &x, const ADvector &y); /// forward mode user API, one order multiple directions. template VectorBase Forward(size_t q, size_t r, const VectorBase& x); /// forward mode user API, multiple directions one order. template VectorBase Forward(size_t q, const VectorBase& x, std::ostream& s = std::cout ); /// reverse mode sweep template VectorBase Reverse(size_t p, const VectorBase &v); // forward mode Jacobian sparsity // (see doxygen documentation in for_sparse_jac.hpp) template VectorSet ForSparseJac( size_t q, const VectorSet &r, bool transpose = false, bool dependency = false ); // reverse mode Jacobian sparsity // (see doxygen documentation in rev_sparse_jac.hpp) template VectorSet RevSparseJac( size_t q, const VectorSet &s, bool transpose = false, bool dependency = false ); // reverse mode Hessian sparsity // (see doxygen documentation in rev_sparse_hes.hpp) template VectorSet RevSparseHes( size_t q, const VectorSet &s, bool transpose = false ); // internal set sparsity version of RevSparseHes // (used by checkpoint functions only) void RevSparseHesCheckpoint( size_t q , vector& s , bool transpose , CPPAD_INTERNAL_SPARSE_SET& h ); // internal set sparsity version of RevSparseJac // (used by checkpoint functions only) void RevSparseJacCheckpoint( size_t q , CPPAD_INTERNAL_SPARSE_SET& r , bool transpose , bool dependency , CPPAD_INTERNAL_SPARSE_SET& s ); // internal set sparsity version of RevSparseJac // (used by checkpoint functions only) void ForSparseJacCheckpoint( size_t q , CPPAD_INTERNAL_SPARSE_SET& r , bool transpose , bool dependency , CPPAD_INTERNAL_SPARSE_SET& s ); /// amount of memory used for 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); } /// total number of elements used for Jacobian sparsity pattern size_t size_forward_set(void) const { return for_jac_sparse_set_.number_elements(); } /// 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_.Memory(); } /// number of parameters in the operation sequence size_t size_par(void) const { return play_.num_par_rec(); } /// 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 VectorBase Jacobian(const VectorBase &x); /// calculate Hessian for one component of f template VectorBase Hessian(const VectorBase &x, const VectorBase &w); template VectorBase Hessian(const VectorBase &x, size_t i); /// forward mode calculation of partial w.r.t one domain component template VectorBase ForOne( const VectorBase &x , size_t j ); /// reverse mode calculation of derivative of one range component template VectorBase RevOne( const VectorBase &x , size_t i ); /// forward mode calculation of a subset of second order partials template VectorBase ForTwo( const VectorBase &x , const VectorSize_t &J , const VectorSize_t &K ); /// reverse mode calculation of a subset of second order partials template VectorBase RevTwo( const VectorBase &x , const VectorSize_t &I , const VectorSize_t &J ); /// calculate sparse Jacobians template VectorBase SparseJacobian( const VectorBase &x ); template VectorBase SparseJacobian( const VectorBase &x , const VectorSet &p ); template size_t SparseJacobianForward( const VectorBase& x , const VectorSet& p , const VectorSize& r , const VectorSize& c , VectorBase& jac , sparse_jacobian_work& work ); template size_t SparseJacobianReverse( const VectorBase& x , const VectorSet& p , const VectorSize& r , const VectorSize& c , VectorBase& jac , sparse_jacobian_work& work ); /// calculate sparse Hessians template VectorBase SparseHessian( const VectorBase& x , const VectorBase& w ); template VectorBase SparseHessian( const VectorBase& x , const VectorBase& w , const VectorBool& p ); template size_t SparseHessian( const VectorBase& x , const VectorBase& w , const VectorSet& p , const VectorSize& r , const VectorSize& c , VectorBase& hes , sparse_hessian_work& work ); // Optimize the tape // (see doxygen documentation in optimize.hpp) void optimize(const std::string& options = ""); // ------------------- 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() + 3 * sizeof(size_t) * for_jac_sparse_set_.number_elements(); size_t total = num_var_tape_ * pervar + play_.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 // user interfaces # include # include # include # include # include # include # include # include # include # include # endif cppad-20160000.1/cppad/local/cosh_op.hpp0000644000175200017650000001443412656321770016762 0ustar coincoin-web// $Id: cosh_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_COSH_OP_HPP # define CPPAD_COSH_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 forward_unary2_op */ template inline 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); c[j] = Base(0); for(k = 1; k <= j; k++) { s[j] += Base(k) * x[k] * c[j-k]; c[j] += Base(k) * x[k] * s[j-k]; } s[j] /= Base(j); c[j] /= Base(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 forward_unary2_op_dir */ template inline 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(q) * x[m + ell] * c[0]; c[m+ell] = Base(q) * x[m + ell] * s[0]; for(size_t k = 1; k < q; k++) { s[m+ell] += Base(k) * x[(k-1)*r+1+ell] * c[(q-k-1)*r+1+ell]; c[m+ell] += Base(k) * x[(k-1)*r+1+ell] * s[(q-k-1)*r+1+ell]; } s[m+ell] /= Base(q); c[m+ell] /= Base(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 forward_unary2_op_0 */ template inline 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 reverse_unary2_op */ template inline 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(j); pc[j] /= Base(j); for(k = 1; k <= j; k++) { px[k] += Base(k) * azmul(ps[j], c[j-k]); px[k] += Base(k) * azmul(pc[j], s[j-k]); ps[j-k] += Base(k) * azmul(pc[j], x[k]); pc[j-k] += Base(k) * azmul(ps[j], x[k]); } --j; } px[0] += azmul(ps[0], c[0]); px[0] += azmul(pc[0], s[0]); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/store_op.hpp0000644000175200017650000003427612656321770017170 0ustar coincoin-web// $Id: store_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_STORE_OP_HPP # define CPPAD_STORE_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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[ 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 inline 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param op is the code corresponding to this operator; i.e., StpvOp, StvpOp, or StvvOp. \param arg \n \a arg[0] is the offset corresponding to this VecAD vector in the combined array. \n \n \a arg[2] \n The set with index \a arg[2] in \a var_sparsity is the sparsity pattern corresponding to y. (Note that \a arg[2] > 0 because y is a variable.) \param num_combined is the total number of elements in the VecAD address array. \param combined \a combined [ arg[0] - 1 ] is the index of the set in \a vecad_sparsity corresponding to the sparsity pattern for the vector v. We use the notation i_v below which is defined by \verbatim i_v = combined[ \a arg[0] - 1 ] \endverbatim \param var_sparsity The set with index \a arg[2] in \a var_sparsity is the sparsity pattern for y. This is an input for forward mode operations. For reverse mode operations: The sparsity pattern for v is added to the spartisy pattern for y. \param vecad_sparsity The set with index \a i_v in \a vecad_sparsity is the sparsity pattern for v. This is an input for reverse mode operations. For forward mode operations, the sparsity pattern for y is added to the sparsity pattern for the vector v. \par Checked Assertions \li NumArg(op) == 3 \li NumRes(op) == 0 \li 0 < \a arg[0] \li \a arg[0] < \a num_combined \li \a arg[2] < \a var_sparsity.n_set() \li i_v < \a vecad_sparsity.n_set() */ template inline 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 forward_store_op_0 */ template inline 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 ) { size_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( 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 ] = arg[2]; } /*! Zero order forward mode implementation of op = StpvOp. \copydetails forward_store_op_0 */ template inline 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 ) { size_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( 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 ] = arg[2]; } /*! Zero order forward mode implementation of op = StvpOp. \copydetails forward_store_op_0 */ template inline 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 ) { size_t i_vec = Integer( taylor[ arg[1] * cap_order + 0 ] ); CPPAD_ASSERT_KNOWN( i_vec < index_by_ind[ arg[0] - 1 ] , "VecAD: index during zero order forward sweep is out of range" ); CPPAD_ASSERT_UNKNOWN( 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 ] = arg[2]; } /*! Zero order forward mode implementation of op = StvvOp. \copydetails forward_store_op_0 */ template inline 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 ) { size_t i_vec = Integer( taylor[ arg[1] * cap_order + 0 ] ); CPPAD_ASSERT_KNOWN( i_vec < index_by_ind[ arg[0] - 1 ] , "VecAD: index during zero order forward sweep is out of range" ); CPPAD_ASSERT_UNKNOWN( 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 ] = 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 sparse_store_op */ template inline 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, arg[1], var_sparsity); if( (op == StpvOp) | (op == StvvOp ) ) vecad_sparsity.binary_union(i_v, i_v, arg[2], var_sparsity); return; } /*! Reverse mode sparsity operations for StpvOp, 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 sparse_store_op */ template inline 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(arg[1], arg[1], i_v, vecad_sparsity); if( (op == StpvOp) | (op == StvvOp) ) var_sparsity.binary_union(arg[2], arg[2], i_v, vecad_sparsity); return; } /*! 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 sparse_store_op \param var_jacobian \a var_jacobian[ \a arg[2] ] is false (true) if the Jacobian of G with respect to y is always zero (may be non-zero). \param vecad_jacobian \a vecad_jacobian[i_v] is false (true) if the Jacobian with respect to x is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. */ template inline 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(arg[2], arg[2], i_v, vecad_sparsity); var_jacobian[ arg[2] ] |= vecad_jacobian[i_v]; return; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/independent.hpp0000644000175200017650000001273612656321770017630 0ustar coincoin-web// $Id: independent.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_INDEPENDENT_HPP # define CPPAD_INDEPENDENT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- $begin 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%) %$$ $head Purpose$$ Start 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; see below. $head Start Recording$$ An operation sequence recording is started by the commands $codei% Independent(%x%) Independent(%x%, %abort_op_index%) %$$ $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% %VectorAD% &%x% %$$ (see $icode VectorAD$$ 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$$ It specifies the operator index at which the execution is be aborted by calling the CppAD $cref/error handler/ErrorHandler/$$. When this error handler leads to an assert, the user can inspect the call stack to see the source code corresponding to this operator index; see $cref/purpose/compare_change/op_index/Purpose/$$. No abort will occur if $icode abort_op_index$$ is zero, of if $cref/NDEBUG/Faq/Speed/NDEBUG/$$ is defined. $head VectorAD$$ The type $icode VectorAD$$ must be a $cref SimpleVector$$ class with $cref/elements of type/SimpleVector/Elements of Specified Type/$$ $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/independent.cpp %$$ The file $cref independent.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. $end ----------------------------------------------------------------------------- */ // BEGIN CppAD namespace namespace CppAD { // --------------------------------------------------------------------------- template template void ADTape::Independent(VectorAD &x, size_t abort_op_index) { // check VectorAD is Simple Vector class with AD elements CheckSimpleVector< AD, VectorAD>(); // 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 ); // set the abort index before doing anything else Rec_.set_abort_op_index(abort_op_index); // mark the beginning of the tape and skip the first variable index // (zero) because parameters use taddr zero CPPAD_ASSERT_NARG_NRES(BeginOp, 1, 1); Rec_.PutOp(BeginOp); Rec_.PutArg(0); // place each of the independent variables in the tape CPPAD_ASSERT_NARG_NRES(InvOp, 0, 1); size_t j; for(j = 0; j < n; j++) { // tape address for this independent variable x[j].taddr_ = Rec_.PutOp(InvOp); x[j].tape_id_ = id_; 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; } template inline void Independent(VectorAD &x, size_t abort_op_index) { typedef typename VectorAD::value_type ADBase; typedef typename ADBase::value_type Base; CPPAD_ASSERT_KNOWN( 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." ); ADTape* tape = ADBase::tape_manage(tape_manage_new); tape->Independent(x, abort_op_index); } template inline void Independent(VectorAD &x) { size_t abort_op_index = 0; Independent(x, abort_op_index); } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/comp_op.hpp0000644000175200017650000001770312656321770016766 0ustar coincoin-web// $Id: comp_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_COMP_OP_HPP # define CPPAD_COMP_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 taylor[ arg[1] * cap_order + 0 ] is the zero order Taylor coefficient for the right operand. \param parameter vector of parameter values. \param cap_order number of Taylor coefficients allocated for each variable \param taylor vector of taylor coefficients. */ template inline void forward_lepv_op_0( size_t& count , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(LepvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(LepvOp) == 0 ); // Taylor coefficients corresponding to arguments and result Base x = parameter[ arg[0] ]; Base* y = taylor + arg[1] * cap_order; count += GreaterThanZero(x - y[0]); } /*! Zero order forward mode comparison check that left <= right \param count It the condition is not true, ths counter is incremented by one. \param arg taylor[ arg[0] * cap_order + 0 ] is the zero order Taylor coefficient for the left operand and parameter[ arg[1] ] is the right operand \param parameter vector of parameter values. \param cap_order number of Taylor coefficients allocated for each variable \param taylor vector of taylor coefficients. */ template inline void forward_levp_op_0( size_t& count , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(LevpOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(LevpOp) == 0 ); // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base y = parameter[ arg[1] ]; count += GreaterThanZero(x[0] - y); } /*! Zero order forward mode comparison check that left <= right \param count It the condition is not true, ths counter is incremented by one. \param arg taylor[ arg[0] * cap_order + 0 ] is the zero order Taylor coefficient for the left operand and taylor[ arg[1] * cap_order + 0 ] is the zero order Taylor coefficient for the right operand. \param parameter vector of parameter values. \param cap_order number of Taylor coefficients allocated for each variable \param taylor vector of taylor coefficients. */ template inline void forward_levv_op_0( size_t& count , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(LevvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(LevvOp) == 0 ); // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base* y = taylor + arg[1] * cap_order; count += GreaterThanZero(x[0] - y[0]); } // ------------------------------- < ------------------------------------- /*! Zero order forward mode comparison check that left < right \copydetails forward_lepv_op_0 */ template inline void forward_ltpv_op_0( size_t& count , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(LtpvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(LtpvOp) == 0 ); // Taylor coefficients corresponding to arguments and result Base x = parameter[ arg[0] ]; Base* y = taylor + arg[1] * cap_order; count += GreaterThanOrZero(x - y[0]); } /*! Zero order forward mode comparison check that left < right \copydetails forward_levp_op_0 */ template inline void forward_ltvp_op_0( size_t& count , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(LtvpOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(LtvpOp) == 0 ); // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base y = parameter[ arg[1] ]; count += GreaterThanOrZero(x[0] - y); } /*! Zero order forward mode comparison check that left < right \copydetails forward_levv_op_0 */ template inline void forward_ltvv_op_0( size_t& count , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(LtvvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(LtvvOp) == 0 ); // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base* y = taylor + arg[1] * cap_order; count += GreaterThanOrZero(x[0] - y[0]); } // ------------------------------ == ------------------------------------- /*! Zero order forward mode comparison check that left == right \copydetails forward_lepv_op_0 */ template inline void forward_eqpv_op_0( size_t& count , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(EqpvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(EqpvOp) == 0 ); // Taylor coefficients corresponding to arguments and result Base x = parameter[ arg[0] ]; Base* y = taylor + arg[1] * cap_order; count += (x != y[0]); } /*! Zero order forward mode comparison check that left == right \copydetails forward_levv_op_0 */ template inline void forward_eqvv_op_0( size_t& count , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(EqvvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(EqvvOp) == 0 ); // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base* y = taylor + arg[1] * cap_order; count += (x[0] != y[0]); } // -------------------------------- != ----------------------------------- /*! Zero order forward mode comparison check that left != right \copydetails forward_lepv_op_0 */ template inline void forward_nepv_op_0( size_t& count , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(NepvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(NepvOp) == 0 ); // Taylor coefficients corresponding to arguments and result Base x = parameter[ arg[0] ]; Base* y = taylor + arg[1] * cap_order; count += (x == y[0]); } /*! Zero order forward mode comparison check that left != right \copydetails forward_levv_op_0 */ template inline void forward_nevv_op_0( size_t& count , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(NevvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(NevvOp) == 0 ); // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base* y = taylor + arg[1] * cap_order; count += (x[0] == y[0]); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/base_to_string.hpp0000644000175200017650000000364612656321770020335 0ustar coincoin-web// $Id$ # ifndef CPPAD_BASE_TO_STRING_HPP # define CPPAD_BASE_TO_STRING_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin base_to_string$$ $spell std namespace CppAD struct const stringstream setprecision str $$ $section Extending to_string To Another Floating Point Type$$ $head Base Requirement$$ If the function $cref to_string$$ is used by an $cref/AD type above Base/glossary/AD Type Above Base/$$, A specialization for the template structure $code CppAD::to_string_struct$$ must be defined. $head CPPAD_TO_STRING$$ For most $icode Base$$ types, the following can be used to define the specialization: $codei% namespace CppAD { CPPAD_TO_STRING(%Base%) } %$$ Note that the $code CPPAD_TO_STRING$$ macro assumes that the $cref base_limits$$ and $cref base_std_math$$ have already been defined for this type. This macro is defined as follows: $codep */ # define CPPAD_TO_STRING(Base) \ template <> struct to_string_struct\ { std::string operator()(const Base& value) \ { std::stringstream os;\ Base epsilon = CppAD::numeric_limits::epsilon();\ Base log10 = CppAD::log( epsilon ) / CppAD::log(Base(10.));\ size_t n_digits = 1 - Integer( log10 );\ os << std::setprecision(n_digits);\ os << value;\ return os.str();\ }\ }; /* $$ $end ------------------------------------------------------------------------------ */ // make sure to_string has been included # include # endif cppad-20160000.1/cppad/local/unary_minus.hpp0000644000175200017650000000447012656321770017700 0ustar coincoin-web// $Id: unary_minus.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_UNARY_MINUS_HPP # define CPPAD_UNARY_MINUS_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin UnaryMinus$$ $spell Vec const inline $$ $section AD Unary Minus Operator$$ $mindex -$$ $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/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 inline AD AD::operator - (void) const { // should make a more efficient version by adding unary minus to // Operator.h (some day) AD result(0); result -= *this; return result; } template inline AD operator - (const VecAD_reference &right) { return - right.ADBase(); } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/cppad_assert.hpp0000644000175200017650000001464312656321770020002 0ustar coincoin-web// $Id: cppad_assert.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_CPPAD_ASSERT_HPP # define CPPAD_CPPAD_ASSERT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /*! \file 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$$ $mindex assert macro CPPAD_ASSERT_KNOWN CPPAD_ASSERT_UNKNOWN$$ $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 \a exp is true, if not print \a msg and terminate execution. The C++ expression \a exp is expected to be true. If it is false, the CppAD use has made an error that is described by \a msg. If the preprocessor symbol \a NDEBUG is not defined, and \a 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 \a 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 \a exp is true, if not terminate execution. The C++ expression \a 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 \a NDEBUG is not defined, and \a 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 \a op has the specified number of of arguments and results. If \a NDEBUG is not defined and either the number of arguments or the number of results are not as expected, execution is terminated and the source code line number is reported. */ # define CPPAD_ASSERT_NARG_NRES(op, n_arg, n_res) \ CPPAD_ASSERT_UNKNOWN( NumArg(op) == n_arg ) \ CPPAD_ASSERT_UNKNOWN( NumRes(op) == n_res ) /*! \def CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL Check that the first call to a routine is not during parallel execution mode. If \c NDEBUG is defined, this macro has no effect (not even the definition of (\c assert_first_call). Otherwise, the variable \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 /*! \def CPPAD_ASSERT_ARG_BEFORE_RESULT Check that operator arguments come before result. If \c NDEBUG is defined, this macro has no effect, otherwise it calls the function assert_arg_before_result. */ # ifdef NDEBUG # define CPPAD_ASSERT_ARG_BEFORE_RESULT(op, arg, result) # else # define CPPAD_ASSERT_ARG_BEFORE_RESULT(op, arg, result) \ assert_arg_before_result(op, arg, result) # endif # endif cppad-20160000.1/cppad/local/ad_ctor.hpp0000644000175200017650000000727612656321770016751 0ustar coincoin-web// $Id: ad_ctor.hpp 3760 2015-12-01 04:12:28Z bradbell $ # ifndef CPPAD_AD_CTOR_HPP # define CPPAD_AD_CTOR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------ $begin ad_ctor$$ $spell cppad ctor initializes Vec const $$ $section AD Constructors $$ $mindex convert Base VecAD$$ $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%)%$$. $subhead Deprecated 2013-12-31$$ If you set $cref/cppad_deprecated/cmake/cppad_deprecated/$$ to be $code YES$$ during the install procedure, you will get an implicit constructor with prototype $codei% const %Type%& %x% %$$ for any type that has an explicit constructor of the form $icode%Base%(%x%)%$$. $head y$$ The target $icode y$$ has prototype $codei% AD<%Base%> %y% %$$ $head Example$$ $children% example/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 inline AD::AD(const AD &x) { value_ = x.value_; tape_id_ = x.tape_id_; taddr_ = x.taddr_; return; } \endcode */ /*! Default Constructor. \tparam Base Base type for this AD object. */ template inline AD::AD(void) : value_() , tape_id_(0) , taddr_(0) { } /*! 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. */ template inline AD::AD(const Base &b) : value_(b) , tape_id_(0) , taddr_(0) { // check that this is a parameter CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); } /*! Constructor from an ADVec element drops the vector information. \tparam Base Base type for this AD object. */ template inline 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 inline AD::AD(const T &t) : value_(Base(t)) , tape_id_(0) , taddr_(0) { } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/for_jac_sweep.hpp0000644000175200017650000005777012656321770020150 0ustar coincoin-web// $Id: for_jac_sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FOR_JAC_SWEEP_HPP # define CPPAD_FOR_JAC_SWEEP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file for_jac_sweep.hpp Compute Forward mode Jacobian sparsity patterns. */ /*! \def CPPAD_FOR_JAC_SWEEP_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_SWEEP_TRACE 0 /* \def CPPAD_ATOMIC_CALL This avoids warnings when NDEBUG is defined and user_ok is not used. If \c NDEBUG is defined, this resolves to \code user_atom->for_sparse_jac \endcode otherwise, it respolves to \code user_ok = user_atom->for_sparse_jac \endcode This maco is undefined at the end of this file to facillitate is use with a different definition in other files. */ # ifdef NDEBUG # define CPPAD_ATOMIC_CALL user_atom->for_sparse_jac # else # define CPPAD_ATOMIC_CALL user_ok = user_atom->for_sparse_jac # endif /*! Given the sparsity pattern for the independent variables, ForJacSweep computes the sparsity pattern for all the other variables. \tparam Base base type for the operator; i.e., this operation sequence was recorded using AD< \a Base > and computations by this routine are done using type \a Base. \tparam Vector_set is the type used for vectors of sets. It can be either \c sparse_pack, \c sparse_set, or \c sparse_list. \param 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., \a play->num_var_rec(). \param play The information stored in \a 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. The object \a play is effectly constant. It is not declared const because while playing back the tape the object \a play holds information about the currentl location with in the tape and this changes during playback. \param var_sparsity \b Input: For j = 1 , ... , \a n, the sparsity pattern for the independent variable with index (j-1) corresponds to the set with index j in \a var_sparsity. \n \n \b Output: For i = \a n + 1 , ... , \a numvar - 1, the sparsity pattern for the variable with index i on the tape corresponds to the set with index i in \a var_sparsity. \par Checked Assertions: \li numvar == var_sparsity.n_set() \li numvar == play->num_var_rec() */ template void ForJacSweep( bool dependency , size_t n , size_t numvar , player* play , Vector_set& var_sparsity ) { OpCode op; size_t i_op; size_t i_var; const addr_t* arg = CPPAD_NULL; 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 cummulative 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; vecad_sparsity.resize(num_vecad_vec, limit); pod_vector vecad_ind; if( num_vecad_vec > 0 ) { size_t length; 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 UserOp. // typedef std::set size_set; size_set::iterator set_itr; // iterator for a standard set size_set::iterator set_end; // end of iterator sequence vector< size_set > set_r; // set sparsity pattern for the argument x vector< size_set > set_s; // set sparisty pattern for the result y // vector bool_r; // bool sparsity pattern for the argument x vector bool_s; // bool sparisty pattern for the result y // vectorBool pack_r; // pack sparsity pattern for the argument x vectorBool pack_s; // pack sparisty pattern for the result y // const size_t user_q = limit; // maximum element plus one size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator size_t user_i = 0; // index in result vector size_t user_j = 0; // index in argument vector size_t user_m = 0; // size of result vector size_t user_n = 0; // size of arugment vector // atomic_base* user_atom = CPPAD_NULL; // user's atomic op calculator bool user_pack = false; // sparsity pattern type is pack bool user_bool = false; // sparsity pattern type is bool bool user_set = false; // sparsity pattern type is set # ifndef NDEBUG bool user_ok = false; // atomic op return value # endif // // next expected operator in a UserOp sequence enum { user_start, user_arg, user_ret, user_end } user_state = user_start; // -------------------------------------------------------------- # if CPPAD_FOR_JAC_SWEEP_TRACE std::cout << std::endl; CppAD::vectorBool z_value(limit); # endif // skip the BeginOp at the beginning of the recording play->forward_start(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( op == BeginOp ); bool more_operators = true; while(more_operators) { // this op play->forward_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) ); CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) ); CPPAD_ASSERT_ARG_BEFORE_RESULT(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, 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, 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, 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, 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, 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, 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, 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, arg[0], var_sparsity ); break; # endif // ------------------------------------------------- case CSkipOp: // CSipOp has a variable number of arguments and // forward_next thinks it has no arguments. // we must inform forward_next of this special case. play->forward_cskip(op, arg, i_op, i_var); break; // ------------------------------------------------- case CSumOp: // CSumOp has a variable number of arguments and // forward_next thinks it has no arguments. // we must inform forward_next of this special case. forward_sparse_jacobian_csum_op( i_var, arg, var_sparsity ); play->forward_csum(op, arg, i_op, i_var); 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, 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, 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, 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, arg[1], var_sparsity ); break; // ------------------------------------------------- case DivvpOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); forward_sparse_jacobian_unary_op( i_var, 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, arg[0], var_sparsity ); break; // ------------------------------------------------- case ExpOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); forward_sparse_jacobian_unary_op( i_var, 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, 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 EqpvOp: case EqvvOp: case LtpvOp: case LtvpOp: case LtvvOp: case LepvOp: case LevpOp: case LevvOp: case NepvOp: case NevvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 0); break; // ------------------------------------------------- case LogOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); forward_sparse_jacobian_unary_op( i_var, 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, arg[0], var_sparsity ); break; # endif // ------------------------------------------------- case MulpvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); forward_sparse_jacobian_unary_op( i_var, 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, arg[0], var_sparsity ); break; // ------------------------------------------------- case PowpvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 3); forward_sparse_jacobian_unary_op( i_var, 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, 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, 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, arg[0], var_sparsity ); break; // ------------------------------------------------- case SqrtOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); forward_sparse_jacobian_unary_op( i_var, 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, arg[1], var_sparsity ); break; // ------------------------------------------------- case SubvpOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); forward_sparse_jacobian_unary_op( i_var, 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, 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, arg[0], var_sparsity ); break; // ------------------------------------------------- case UserOp: // start or end an atomic operation sequence CPPAD_ASSERT_UNKNOWN( NumRes( UserOp ) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg( UserOp ) == 4 ); if( user_state == user_start ) { user_index = arg[0]; user_id = arg[1]; user_n = arg[2]; user_m = arg[3]; user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif user_pack = user_atom->sparsity() == atomic_base::pack_sparsity_enum; user_bool = user_atom->sparsity() == atomic_base::bool_sparsity_enum; user_set = user_atom->sparsity() == atomic_base::set_sparsity_enum; CPPAD_ASSERT_UNKNOWN( user_pack || user_bool || user_set ); if( user_pack ) { if( pack_r.size() != user_n * user_q ) pack_r.resize( user_n * user_q ); if( pack_s.size() != user_m * user_q ) pack_s.resize( user_m * user_q ); for(i = 0; i < user_n; i++) for(j = 0; j < user_q; j++) pack_r[ i * user_q + j] = false; } if( user_bool ) { if( bool_r.size() != user_n * user_q ) bool_r.resize( user_n * user_q ); if( bool_s.size() != user_m * user_q ) bool_s.resize( user_m * user_q ); for(i = 0; i < user_n; i++) for(j = 0; j < user_q; j++) bool_r[ i * user_q + j] = false; } if( user_set) { if(set_r.size() != user_n ) set_r.resize(user_n); if(set_s.size() != user_m ) set_s.resize(user_m); for(i = 0; i < user_n; i++) set_r[i].clear(); } user_j = 0; user_i = 0; user_state = user_arg; } else { CPPAD_ASSERT_UNKNOWN( user_state == user_end ); CPPAD_ASSERT_UNKNOWN( user_index == size_t(arg[0]) ); CPPAD_ASSERT_UNKNOWN( user_id == size_t(arg[1]) ); CPPAD_ASSERT_UNKNOWN( user_n == size_t(arg[2]) ); CPPAD_ASSERT_UNKNOWN( user_m == size_t(arg[3]) ); # ifndef NDEBUG if( ! user_ok ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base.for_sparse_jac: returned false\n"; if( user_pack ) msg += "sparsity = pack_sparsity_enum"; if( user_bool ) msg += "sparsity = bool_sparsity_enum"; if( user_set ) msg += "sparsity = set_sparsity_enum"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif user_state = user_start; } break; case UsrapOp: // parameter argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( user_j < user_n ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); // set row user_j to empty sparsity pattern ++user_j; if( user_j == user_n ) { // call users function for this operation user_atom->set_id(user_id); if( user_pack ) CPPAD_ATOMIC_CALL( user_q, pack_r, pack_s); if( user_bool ) CPPAD_ATOMIC_CALL( user_q, bool_r, bool_s); if( user_set ) CPPAD_ATOMIC_CALL( user_q, set_r, set_s); user_state = user_ret; } break; case UsravOp: // variable argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( user_j < user_n ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= i_var ); // set row user_j to sparsity pattern for variable arg[0] var_sparsity.begin(arg[0]); i = var_sparsity.next_element(); while( i < user_q ) { if( user_pack ) pack_r[user_j * user_q + i] = true; if( user_bool ) bool_r[user_j * user_q + i] = true; if( user_set ) set_r[user_j].insert(i); i = var_sparsity.next_element(); } ++user_j; if( user_j == user_n ) { // call users function for this operation user_atom->set_id(user_id); if( user_pack ) CPPAD_ATOMIC_CALL( user_q, pack_r, pack_s); if( user_bool ) CPPAD_ATOMIC_CALL( user_q, bool_r, bool_s); if( user_set ) CPPAD_ATOMIC_CALL( user_q, set_r, set_s); user_state = user_ret; } break; case UsrrpOp: // parameter result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( user_i < user_m ); user_i++; if( user_i == user_m ) user_state = user_end; break; case UsrrvOp: // variable result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( user_i < user_m ); // It might be faster if we add set union to var_sparsity // where one of the sets is not in var_sparsity if( user_pack ) { for(j = 0; j < user_q; j++) if( pack_s[ user_i * user_q + j ] ) var_sparsity.add_element(i_var, j); } if( user_bool ) { for(j = 0; j < user_q; j++) if( bool_s[ user_i * user_q + j ] ) var_sparsity.add_element(i_var, j); } if( user_set ) { set_itr = set_s[user_i].begin(); set_end = set_s[user_i].end(); while( set_itr != set_end ) var_sparsity.add_element(i_var, *set_itr++); } user_i++; if( user_i == user_m ) user_state = user_end; break; // ------------------------------------------------- case ZmulpvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); forward_sparse_jacobian_unary_op( i_var, arg[1], var_sparsity ); break; // ------------------------------------------------- case ZmulvpOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); forward_sparse_jacobian_unary_op( i_var, arg[0], var_sparsity ); break; // ------------------------------------------------- case ZmulvvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); forward_sparse_jacobian_binary_op( i_var, arg, var_sparsity ); break; // ------------------------------------------------- default: CPPAD_ASSERT_UNKNOWN(0); } # if CPPAD_FOR_JAC_SWEEP_TRACE const addr_t* arg_tmp = arg; if( op == CSumOp ) arg_tmp = arg - arg[-1] - 4; if( op == CSkipOp ) arg_tmp = arg - arg[-1] - 7; // // value for this variable for(j = 0; j < limit; j++) z_value[j] = false; var_sparsity.begin(i_var); j = var_sparsity.next_element(); while( j < limit ) { z_value[j] = true; j = var_sparsity.next_element(); } printOp( std::cout, play, i_op, i_var, op, arg_tmp ); if( NumRes(op) > 0 ) printOpResult( std::cout, 1, &z_value, 0, (CppAD::vectorBool *) CPPAD_NULL ); std::cout << std::endl; } std::cout << std::endl; # else } # endif CPPAD_ASSERT_UNKNOWN( i_var + 1 == play->num_var_rec() ); return; } } // END_CPPAD_NAMESPACE // preprocessor symbols that are local to this file # undef CPPAD_FOR_JAC_SWEEP_TRACE # undef CPPAD_ATOMIC_CALL # endif cppad-20160000.1/cppad/local/equal_op_seq.hpp0000644000175200017650000000572212656321770020005 0ustar coincoin-web// $Id: equal_op_seq.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_EQUAL_OP_SEQ_HPP # define CPPAD_EQUAL_OP_SEQ_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------ $begin EqualOpSeq$$ $spell Op const bool $$ $section Check if Two Value are Identically Equal$$ $mindex EqualOpSeq operation sequence$$ $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/equal_op_seq.cpp %$$ The file $cref equal_op_seq.cpp$$ contains an example and test of $code EqualOpSeq$$. It returns true if it succeeds and false otherwise. $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 cppad-20160000.1/cppad/local/mul.hpp0000644000175200017650000000573312656321770016127 0ustar coincoin-web// $Id: mul.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_MUL_HPP # define CPPAD_MUL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // BEGIN CppAD 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 ADTape* tape = AD::tape_ptr(); if( tape == CPPAD_NULL ) return result; tape_id_t tape_id = tape->id_; // tape_id cannot match the default value for tape_id_; i.e., 0 CPPAD_ASSERT_UNKNOWN( tape_id > 0 ); bool var_left = left.tape_id_ == tape_id; bool var_right = right.tape_id_ == tape_id; if( var_left ) { if( var_right ) { // result = variable * variable CPPAD_ASSERT_UNKNOWN( NumRes(MulvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(MulvvOp) == 2 ); // put operand addresses in tape tape->Rec_.PutArg(left.taddr_, right.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(MulvvOp); // make result a variable result.tape_id_ = tape_id; } else if( IdenticalZero(right.value_) ) { // result = variable * 0 } else if( IdenticalOne(right.value_) ) { // result = variable * 1 result.make_variable(left.tape_id_, left.taddr_); } else { // result = variable * parameter CPPAD_ASSERT_UNKNOWN( NumRes(MulpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(MulpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(right.value_); tape->Rec_.PutArg(p, left.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(MulpvOp); // make result a variable result.tape_id_ = tape_id; } } else if( var_right ) { if( IdenticalZero(left.value_) ) { // result = 0 * variable } else if( IdenticalOne(left.value_) ) { // result = 1 * variable result.make_variable(right.tape_id_, right.taddr_); } else { // result = parameter * variable CPPAD_ASSERT_UNKNOWN( NumRes(MulpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(MulpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(left.value_); tape->Rec_.PutArg(p, right.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(MulpvOp); // make result a variable result.tape_id_ = tape_id; } } return result; } // convert other cases into the case above CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(*) } // END CppAD namespace # endif cppad-20160000.1/cppad/local/log1p_op.hpp0000644000175200017650000001151412656321770017044 0ustar coincoin-web// $Id$ # ifndef CPPAD_LOG1P_OP_HPP # define CPPAD_LOG1P_OP_HPP # if CPPAD_USE_CPLUSPLUS_2011 /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file log1p_op.hpp Forward and reverse mode calculations for z = log1p(x). */ /*! Compute forward mode Taylor coefficient for result of op = Log1pOp. The C++ source code corresponding to this operation is \verbatim z = log1p(x) \endverbatim \copydetails forward_unary1_op */ template inline void forward_log1p_op( size_t p , size_t q , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { size_t k; // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(Log1pOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(Log1pOp) == 1 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; if( p == 0 ) { z[0] = log1p( x[0] ); p++; if( q == 0 ) return; } if ( p == 1 ) { z[1] = x[1] / (Base(1) + x[0]); p++; } for(size_t j = p; j <= q; j++) { z[j] = -z[1] * x[j-1]; for(k = 2; k < j; k++) z[j] -= Base(k) * z[k] * x[j-k]; z[j] /= Base(j); z[j] += x[j]; z[j] /= (Base(1) + x[0]); } } /*! Muiltiple directions Taylor coefficient for op = Log1pOp. The C++ source code corresponding to this operation is \verbatim z = log1p(x) \endverbatim \copydetails forward_unary1_op_dir */ template inline void forward_log1p_op_dir( size_t q , size_t r , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(Log1pOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(Log1pOp) == 1 ); CPPAD_ASSERT_UNKNOWN( 0 < q ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); // Taylor coefficients corresponding to argument and result size_t num_taylor_per_var = (cap_order-1) * r + 1; Base* x = taylor + i_x * num_taylor_per_var; Base* z = taylor + i_z * num_taylor_per_var; size_t m = (q-1) * r + 1; for(size_t ell = 0; ell < r; ell++) { z[m+ell] = Base(q) * x[m+ell]; for(size_t k = 1; k < q; k++) z[m+ell] -= Base(k) * z[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; z[m+ell] /= (Base(q) + Base(q) * x[0]); } } /*! Compute zero order forward mode Taylor coefficient for result of op = Log1pOp. The C++ source code corresponding to this operation is \verbatim z = log1p(x) \endverbatim \copydetails forward_unary1_op_0 */ template inline void forward_log1p_op_0( size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(Log1pOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(Log1pOp) == 1 ); CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; z[0] = log1p( x[0] ); } /*! Compute reverse mode partial derivatives for result of op = Log1pOp. The C++ source code corresponding to this operation is \verbatim z = log1p(x) \endverbatim \copydetails reverse_unary1_op */ template inline void reverse_log1p_op( size_t d , size_t i_z , size_t i_x , size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) { size_t j, k; // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(Log1pOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(Log1pOp) == 1 ); CPPAD_ASSERT_UNKNOWN( d < cap_order ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // Taylor coefficients and partials corresponding to argument const Base* x = taylor + i_x * cap_order; Base* px = partial + i_x * nc_partial; // Taylor coefficients and partials corresponding to result const Base* z = taylor + i_z * cap_order; Base* pz = partial + i_z * nc_partial; Base inv_1px0 = Base(1) / (Base(1) + x[0]); j = d; while(j) { // scale partial w.r.t z[j] pz[j] = azmul(pz[j] , inv_1px0); px[0] -= azmul(pz[j], z[j]); px[j] += pz[j]; // further scale partial w.r.t. z[j] pz[j] /= Base(j); for(k = 1; k < j; k++) { pz[k] -= Base(k) * azmul(pz[j], x[j-k]); px[j-k] -= Base(k) * azmul(pz[j], z[k]); } --j; } px[0] += azmul(pz[0], inv_1px0); } } // END_CPPAD_NAMESPACE # endif # endif cppad-20160000.1/cppad/local/standard_math.hpp0000644000175200017650000000673312656321770020144 0ustar coincoin-web// $Id$ # ifndef CPPAD_STANDARD_MATH_HPP # define CPPAD_STANDARD_MATH_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin unary_standard_math$$ $spell const VecAD fabs $$ $section The Unary Standard Math Functions$$ $head Syntax$$ $icode%y% = %fun%(%x%)%$$ $head Purpose$$ Evaluates the standard math function $icode fun$$. $head Possible Types$$ $subhead Base$$ If $icode Base$$ satisfies the $cref/base type requirements/base_require/$$ and argument $icode x$$ has prototype $codei% const %Base%& %x% %$$ then the result $icode y$$ has prototype $codei% %Base% %y% %$$ $subhead AD$$ If the argument $icode x$$ has prototype $codei% const AD<%Base%>& %x% %$$ then the result $icode y$$ has prototype $codei% AD<%Base%> %y% %$$ $subhead VecAD$$ If the argument $icode x$$ has prototype $codei% const VecAD<%Base%>::reference& %x% %$$ then the result $icode y$$ has prototype $codei% AD<%Base%> %y% %$$ $children%cppad/local/std_math_98.hpp %cppad/local/abs.hpp %cppad/local/acosh.hpp %cppad/local/asinh.hpp %cppad/local/atanh.hpp %cppad/local/erf.hpp %cppad/local/expm1.hpp %cppad/local/log1p.hpp %cppad/local/sign.hpp %$$ $head fun$$ The possible values for $icode fun$$ are $table $icode fun$$ $pre $$ $cnext Description $rnext $cref abs$$ $cnext $title abs$$ $rnext $cref acos$$ $cnext $title acos$$ $rnext $cref acosh$$ $cnext $title acosh$$ $rnext $cref asin$$ $cnext $title asin$$ $rnext $cref asinh$$ $cnext $title asinh$$ $rnext $cref atan$$ $cnext $title atan$$ $rnext $cref atanh$$ $cnext $title atanh$$ $rnext $cref cos$$ $cnext $title cos$$ $rnext $cref cosh$$ $cnext $title cosh$$ $rnext $cref erf$$ $cnext $title erf$$ $rnext $cref exp$$ $cnext $title exp$$ $rnext $cref expm1$$ $cnext $title expm1$$ $rnext $cref/fabs/abs/$$ $cnext $title abs$$ $rnext $cref log10$$ $cnext $title log10$$ $rnext $cref log1p$$ $cnext $title log1p$$ $rnext $cref log$$ $cnext $title log$$ $rnext $cref sign$$ $cnext $title sign$$ $rnext $cref sin$$ $cnext $title sin$$ $rnext $cref sinh$$ $cnext $title sinh$$ $rnext $cref sqrt$$ $cnext $title sqrt$$ $rnext $cref tan$$ $cnext $title tan$$ $rnext $cref tanh$$ $cnext $title tanh$$ $tend $end */ # include # include # include # include # include # include # include # include # include /* $begin binary_math$$ $section The Binary Math Functions$$ $childtable%cppad/local/atan2.hpp %cppad/local/pow.hpp %cppad/local/azmul.hpp %$$ $end */ # include # include # endif cppad-20160000.1/cppad/local/for_sparse_jac.hpp0000644000175200017650000006043612656321770020313 0ustar coincoin-web// $Id: for_sparse_jac.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FOR_SPARSE_JAC_HPP # define CPPAD_FOR_SPARSE_JAC_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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^n \rightarrow B^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/VectorSet/ForSparseJac/VectorSet/$$ 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 s$$ to the total number of elements in all the sets corresponding to the sparsity pattern stored in the function object $icode f$$. 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 (unless the entire sparsity pattern is false). This sparsity pattern is stored for use by $cref RevSparseHes$$ and when it is not longer needed, it can be deleted (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$$ the sparsity pattern is valid for all values of the independent variables in $latex x \in B^n$$ (even if it has $cref CondExp$$ or $cref VecAD$$ operations). $head q$$ The argument $icode q$$ has prototype $codei% size_t %q% %$$ It specifies the number of columns in $latex R \in B^{n \times q}$$ and the Jacobian $latex S(x) \in B^{m \times q}$$. $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 %VectorSet%& %r% %$$ see $cref/VectorSet/ForSparseJac/VectorSet/$$ 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^{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^{q \times n}$$. $head s$$ The return value $icode s$$ has prototype $codei% %VectorSet% %s% %$$ see $cref/VectorSet/ForSparseJac/VectorSet/$$ 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^{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^{q \times m}$$. $head VectorSet$$ The type $icode VectorSet$$ 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/for_sparse_jac.cpp %$$ The file $cref for_sparse_jac.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. The file $cref/sparsity_sub.cpp/sparsity_sub.cpp/ForSparseJac/$$ contains an example and test of using $code ForSparseJac$$ to compute the sparsity pattern for a subset of the Jacobian. $end ----------------------------------------------------------------------------- */ # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file for_sparse_jac.hpp Forward mode Jacobian sparsity patterns. */ // --------------------------------------------------------------------------- /*! Calculate Jacobian vector of bools sparsity patterns using forward mode. The C++ source code corresponding to this operation is \verbatim s = f.ForSparseJac(q, r) \endverbatim \tparam Base is the base type for this recording. \tparam VectorSet is a simple vector class with elements of type \c bool. \param transpose are the sparsity patterns transposed. \param dependency Are the derivatives with respect to left and right of the expression below considered to be non-zero: \code CondExpRel(left, right, if_true, if_false) \endcode This is used by the optimizer to obtain the correct dependency relations. \param q is the number of columns in the matrix \f$ R \f$. \param r is a sparsity pattern for the matrix \f$ R \f$. \param s The input value of \a s must be a vector with size \c m*q where \c m is the number of dependent variables corresponding to the operation sequence stored in \a play. The input value of the components of \c s does not matter. On output, \a s is the sparsity pattern for the matrix \f[ S(x) = F^{(1)} (x) * R \f] where \f$ F \f$ is the function corresponding to the operation sequence and \a x is any argument value. \param total_num_var is the total number of variable in this recording. \param dep_taddr maps dependendent variable index to the corresponding variable in the tape. \param ind_taddr maps independent variable index to the corresponding variable in the tape. \param play is the recording that defines the function we are computing the sparsity pattern for. \param for_jac_sparsity the input value of \a for_jac_sparsity does not matter. On output, \a for_jac_sparsity.n_set() == \a total_num_var and \a for_jac_sparsity.end() == \a q. It contains the forward sparsity pattern for all of the variables on the tape (given the sparsity pattern for the independent variables is \f$ R \f$). */ template void ForSparseJacBool( bool transpose , bool dependency , size_t q , const VectorSet& r , VectorSet& s , size_t total_num_var , CppAD::vector& dep_taddr , CppAD::vector& ind_taddr , CppAD::player& play , sparse_pack& for_jac_sparsity ) { // temporary indices size_t i, j; // range and domain dimensions for F size_t m = dep_taddr.size(); size_t n = ind_taddr.size(); 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_sparsity.resize(total_num_var, q); // set values corresponding to independent variables for(i = 0; i < n; i++) { CPPAD_ASSERT_UNKNOWN( ind_taddr[i] < total_num_var ); // ind_taddr[i] is operator taddr for i-th independent variable CPPAD_ASSERT_UNKNOWN( play.GetOp( ind_taddr[i] ) == InvOp ); // set bits that are true if( transpose ) { for(j = 0; j < q; j++) if( r[ j * n + i ] ) for_jac_sparsity.add_element( ind_taddr[i], j); } else { for(j = 0; j < q; j++) if( r[ i * q + j ] ) for_jac_sparsity.add_element( ind_taddr[i], j); } } // evaluate the sparsity patterns ForJacSweep( dependency, n, total_num_var, &play, for_jac_sparsity ); // return values corresponding to dependent variables CPPAD_ASSERT_UNKNOWN( size_t(s.size()) == m * q ); for(i = 0; i < m; i++) { CPPAD_ASSERT_UNKNOWN( dep_taddr[i] < total_num_var ); // extract the result from for_jac_sparsity if( transpose ) { for(j = 0; j < q; j++) s[ j * m + i ] = false; } else { for(j = 0; j < q; j++) s[ i * q + j ] = false; } CPPAD_ASSERT_UNKNOWN( for_jac_sparsity.end() == q ); for_jac_sparsity.begin( dep_taddr[i] ); j = for_jac_sparsity.next_element(); while( j < q ) { if( transpose ) s[j * m + i] = true; else s[i * q + j] = true; j = for_jac_sparsity.next_element(); } } } /*! Calculate Jacobian vector of sets sparsity patterns using forward mode. The C++ source code corresponding to this operation is \verbatim s = f.ForSparseJac(q, r) \endverbatim \tparam Base see \c SparseJacBool. \tparam VectorSet is a simple vector class with elements of type \c std::set. \param transpose see \c SparseJacBool. \param dependency see \c SparseJacBool. \param q see \c SparseJacBool. \param r see \c SparseJacBool. \param s see \c SparseJacBool. \param total_num_var see \c SparseJacBool. \param dep_taddr see \c SparseJacBool. \param ind_taddr see \c SparseJacBool. \param play see \c SparseJacBool. \param for_jac_sparsity see \c SparseJacBool. */ template void ForSparseJacSet( bool transpose , bool dependency , size_t q , const VectorSet& r , VectorSet& s , size_t total_num_var , CppAD::vector& dep_taddr , CppAD::vector& ind_taddr , CppAD::player& play , CPPAD_INTERNAL_SPARSE_SET& for_jac_sparsity ) { // temporary indices size_t i, j; std::set::const_iterator itr; // range and domain dimensions for F size_t m = dep_taddr.size(); size_t n = ind_taddr.size(); CPPAD_ASSERT_KNOWN( q > 0, "RevSparseJac: q is not greater than zero" ); CPPAD_ASSERT_KNOWN( size_t(r.size()) == n || transpose, "RevSparseJac: size of r is not equal to n and transpose is false." ); CPPAD_ASSERT_KNOWN( size_t(r.size()) == q || ! transpose, "RevSparseJac: size of r is not equal to q and transpose is true." ); // allocate memory for the requested sparsity calculation for_jac_sparsity.resize(total_num_var, q); // set values corresponding to independent variables if( transpose ) { for(i = 0; i < q; i++) { // add the elements that are present itr = r[i].begin(); while( itr != r[i].end() ) { j = *itr++; 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] < total_num_var ); // operator for j-th independent variable CPPAD_ASSERT_UNKNOWN( play.GetOp( ind_taddr[j] ) == InvOp ); for_jac_sparsity.add_element( ind_taddr[j], i); } } } else { for(i = 0; i < n; i++) { CPPAD_ASSERT_UNKNOWN( ind_taddr[i] < total_num_var ); // ind_taddr[i] is operator taddr for i-th independent variable CPPAD_ASSERT_UNKNOWN( play.GetOp( ind_taddr[i] ) == InvOp ); // add the elements that are present itr = r[i].begin(); while( itr != r[i].end() ) { j = *itr++; CPPAD_ASSERT_KNOWN( j < q, "ForSparseJac: an element of the set r[i] " "has value greater than or equal q." ); for_jac_sparsity.add_element( ind_taddr[i], j); } } } // evaluate the sparsity patterns ForJacSweep( dependency, n, total_num_var, &play, for_jac_sparsity ); // 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(i = 0; i < m; i++) { CPPAD_ASSERT_UNKNOWN( dep_taddr[i] < total_num_var ); // extract results from for_jac_sparsity // and add corresponding elements to sets in s CPPAD_ASSERT_UNKNOWN( for_jac_sparsity.end() == q ); for_jac_sparsity.begin( dep_taddr[i] ); j = for_jac_sparsity.next_element(); while( j < q ) { if( transpose ) s[j].insert(i); else s[i].insert(j); j = for_jac_sparsity.next_element(); } } } // --------------------------------------------------------------------------- /*! Private helper function for ForSparseJac(q, r). All of the description in the public member function ForSparseJac(q, r) applies. \param set_type is a \c bool value. This argument is used to dispatch to the proper source code depending on the value of \c VectorSet::value_type. \param transpose See \c ForSparseJac(q, r, transpose, dependency). \param dependency See \c ForSparseJac(q, r, transpose, dependency). \param q See \c ForSparseJac(q, r, transpose, dependency). \param r See \c ForSparseJac(q, r, transpose, dependency). \param s is the return value for the corresponding call to \c ForSparseJac(q, r). */ template template void ADFun::ForSparseJacCase( bool set_type , bool transpose , bool dependency , size_t q , const VectorSet& r , VectorSet& s ) { size_t m = Range(); // check VectorSet is Simple Vector class with bool elements CheckSimpleVector(); // dimension size of result vector s.resize( m * q ); // store results in s and for_jac_sparse_pack_ ForSparseJacBool( transpose , dependency , q , r , s , num_var_tape_ , dep_taddr_ , ind_taddr_ , play_ , for_jac_sparse_pack_ ); } /*! Private helper function for \c ForSparseJac(q, r). All of the description in the public member function \c ForSparseJac(q, r) applies. \param set_type is a \c std::set object. This argument is used to dispatch to the proper source code depending on the value of \c VectorSet::value_type. \param transpose See \c ForSparseJac(q, r, transpose, dependency). \param dependency See \c ForSparseJac(q, r, transpose, dependency). \param q See \c ForSparseJac(q, r, transpose, dependency). \param r See \c ForSparseJac(q, r, transpose, dependency). \param s is the return value for the corresponding call to \c ForSparseJac(q, r). */ template template void ADFun::ForSparseJacCase( const std::set& set_type , bool transpose , bool dependency , size_t q , const VectorSet& r , VectorSet& s ) { size_t m = Range(); // check VectorSet is Simple Vector class with sets for elements CheckSimpleVector, VectorSet>( one_element_std_set(), two_element_std_set() ); // dimension size of result vector if( transpose ) s.resize(q); else s.resize( m ); // store results in r and for_jac_sparse_pack_ CppAD::ForSparseJacSet( transpose , dependency , q , r , s , num_var_tape_ , dep_taddr_ , ind_taddr_ , play_ , for_jac_sparse_set_ ); } // --------------------------------------------------------------------------- /*! 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 VectorSet is a simple vector with elements of type \c bool or \c 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 \c 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 \a x is any argument value. If \c VectorSet::value_type is \c bool, the return value has size \f$ m * q \f$ (\f$ q * m \f$). where \c m is the number of dependent variables corresponding to the operation sequence stored in \c f. If \c VectorSet::value_type is \c std::set, the return value has size \f$ m \f$ ( \f$ q \f$ ) and with all its elements between zero and \f$ q - 1 \f$ ( \f$ m - 1 \f$). \par Side Effects If \c VectorSet::value_type is \c bool, the forward sparsity pattern for all of the variables on the tape is stored in \c for_jac_sparse_pack__. In this case \verbatim for_jac_sparse_pack_.n_set() == num_var_tape_ for_jac_sparse_pack_.end() == q for_jac_sparse_set_.n_set() == 0 for_jac_sparse_set_.end() == 0 \endverbatim \n \n If \c VectorSet::value_type is \c std::set, the forward sparsity pattern for all of the variables on the tape is stored in \c for_jac_sparse_set__. In this case \verbatim for_jac_sparse_set_.n_set() == num_var_tape_ for_jac_sparse_set_.end() == q for_jac_sparse_pack_.n_set() == 0 for_jac_sparse_pack_.end() == 0 \endverbatim */ template template VectorSet ADFun::ForSparseJac( size_t q , const VectorSet& r , bool transpose , bool dependency ) { VectorSet s; typedef typename VectorSet::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 \c VectorSet::value_type is \c bool, the forward sparsity pattern for all of the variables on the tape is stored in \c for_jac_sparse_pack__. In this case \verbatim for_jac_sparse_pack_.n_set() == num_var_tape_ for_jac_sparse_pack_.end() == q for_jac_sparse_set_.n_set() == 0 for_jac_sparse_set_.end() == 0 \endverbatim \n \n If \c VectorSet::value_type is \c std::set, the forward sparsity pattern for all of the variables on the tape is stored in \c for_jac_sparse_set__. In this case \verbatim for_jac_sparse_set_.n_set() == num_var_tape_ for_jac_sparse_set_.end() == q for_jac_sparse_pack_.n_set() == 0 for_jac_sparse_pack_.end() == 0 \endverbatim */ template void ADFun::ForSparseJacCheckpoint( size_t q , CPPAD_INTERNAL_SPARSE_SET& r , bool transpose , bool dependency , CPPAD_INTERNAL_SPARSE_SET& s ) { size_t n = Domain(); size_t m = Range(); # ifndef NDEBUG if( transpose ) { CPPAD_ASSERT_UNKNOWN( r.n_set() == q ); CPPAD_ASSERT_UNKNOWN( r.end() == n ); } else { CPPAD_ASSERT_UNKNOWN( r.n_set() == n ); CPPAD_ASSERT_UNKNOWN( r.end() == q ); } for(size_t j = 0; j < n; j++) { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] == (j+1) ); CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[j] ) == InvOp ); } # endif // free all memory currently in sparsity patterns for_jac_sparse_pack_.resize(0, 0); for_jac_sparse_set_.resize(0, 0); // allocate new sparsity pattern for_jac_sparse_set_.resize(num_var_tape_, q); // set sparsity pattern for dependent variables if( transpose ) { for(size_t i = 0; i < q; i++) { r.begin(i); size_t j = r.next_element(); while( j < n ) { for_jac_sparse_set_.add_element( ind_taddr_[j], i ); j = r.next_element(); } } } else { for(size_t j = 0; j < n; j++) { r.begin(j); size_t i = r.next_element(); while( i < q ) { for_jac_sparse_set_.add_element( ind_taddr_[j], i ); i = r.next_element(); } } } // evaluate the sparsity pattern for all variables ForJacSweep( dependency, n, num_var_tape_, &play_, for_jac_sparse_set_ ); // dimension the return value if( transpose ) s.resize(q, m); else s.resize(m, q); // return values corresponding to dependent variables for(size_t i = 0; i < m; i++) { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); // extract the result from for_jac_sparse_set_ CPPAD_ASSERT_UNKNOWN( for_jac_sparse_set_.end() == q ); for_jac_sparse_set_.begin( dep_taddr_[i] ); size_t j = for_jac_sparse_set_.next_element(); while( j < q ) { if( transpose ) s.add_element(j, i); else s.add_element(i, j); j = for_jac_sparse_set_.next_element(); } } } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/asinh_op.hpp0000644000175200017650000001525112656321770017126 0ustar coincoin-web// $Id$ # ifndef CPPAD_ASINH_OP_HPP # define CPPAD_ASINH_OP_HPP # if CPPAD_USE_CPLUSPLUS_2011 /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file asinh_op.hpp Forward and reverse mode calculations for z = asinh(x). */ /*! Compute forward mode Taylor coefficient for result of op = AsinhOp. The C++ source code corresponding to this operation is \verbatim z = asinh(x) \endverbatim The auxillary result is \verbatim y = sqrt(1 + x * x) \endverbatim The value of y, and its derivatives, are computed along with the value and derivatives of z. \copydetails forward_unary2_op */ template inline void forward_asinh_op( size_t p , size_t q , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AsinhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AsinhOp) == 2 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; Base* b = z - cap_order; // called y in documentation size_t k; Base uj; if( p == 0 ) { z[0] = asinh( x[0] ); uj = Base(1) + x[0] * x[0]; b[0] = sqrt( uj ); p++; } for(size_t j = p; j <= q; j++) { uj = Base(0); for(k = 0; k <= j; k++) uj += x[k] * x[j-k]; b[j] = Base(0); z[j] = Base(0); for(k = 1; k < j; k++) { b[j] -= Base(k) * b[k] * b[j-k]; z[j] -= Base(k) * z[k] * b[j-k]; } b[j] /= Base(j); z[j] /= Base(j); // b[j] += uj / Base(2); z[j] += x[j]; // b[j] /= b[0]; z[j] /= b[0]; } } /*! Multiple directions forward mode Taylor coefficient for op = AsinhOp. The C++ source code corresponding to this operation is \verbatim z = asinh(x) \endverbatim The auxillary result is \verbatim y = sqrt(1 + x * x) \endverbatim The value of y, and its derivatives, are computed along with the value and derivatives of z. \copydetails forward_unary2_op_dir */ template inline void forward_asinh_op_dir( size_t q , size_t r , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AcosOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AcosOp) == 2 ); CPPAD_ASSERT_UNKNOWN( 0 < q ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); // Taylor coefficients corresponding to argument and result size_t num_taylor_per_var = (cap_order-1) * r + 1; Base* x = taylor + i_x * num_taylor_per_var; Base* z = taylor + i_z * num_taylor_per_var; Base* b = z - num_taylor_per_var; // called y in documentation size_t k, ell; size_t m = (q-1) * r + 1; for(ell = 0; ell < r; ell ++) { Base uq = 2.0 * x[m + ell] * x[0]; for(k = 1; k < q; k++) uq += x[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; b[m+ell] = Base(0); z[m+ell] = Base(0); for(k = 1; k < q; k++) { b[m+ell] += Base(k) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; z[m+ell] += Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; } b[m+ell] = ( uq / Base(2) - b[m+ell] / Base(q) ) / b[0]; z[m+ell] = ( x[m+ell] - z[m+ell] / Base(q) ) / b[0]; } } /*! Compute zero order forward mode Taylor coefficient for result of op = AsinhOp. The C++ source code corresponding to this operation is \verbatim z = asinh(x) \endverbatim The auxillary result is \verbatim y = sqrt( 1 + x * x ) \endverbatim The value of y is computed along with the value of z. \copydetails forward_unary2_op_0 */ template inline void forward_asinh_op_0( size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AsinhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AsinhOp) == 2 ); CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; Base* b = z - cap_order; // called y in documentation z[0] = asinh( x[0] ); b[0] = sqrt( Base(1) + x[0] * x[0] ); } /*! Compute reverse mode partial derivatives for result of op = AsinhOp. The C++ source code corresponding to this operation is \verbatim z = asinh(x) \endverbatim The auxillary result is \verbatim y = sqrt( 1 + x * x ) \endverbatim The value of y is computed along with the value of z. \copydetails reverse_unary2_op */ template inline void reverse_asinh_op( size_t d , size_t i_z , size_t i_x , size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AsinhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AsinhOp) == 2 ); CPPAD_ASSERT_UNKNOWN( d < cap_order ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // Taylor coefficients and partials corresponding to argument const Base* x = taylor + i_x * cap_order; Base* px = partial + i_x * nc_partial; // Taylor coefficients and partials corresponding to first result const Base* z = taylor + i_z * cap_order; Base* pz = partial + i_z * nc_partial; // Taylor coefficients and partials corresponding to auxillary result const Base* b = z - cap_order; // called y in documentation Base* pb = pz - nc_partial; Base inv_b0 = Base(1) / b[0]; // number of indices to access size_t j = d; size_t k; while(j) { // scale partials w.r.t b[j] by 1 / b[0] pb[j] = azmul(pb[j], inv_b0); // scale partials w.r.t z[j] by 1 / b[0] pz[j] = azmul(pz[j], inv_b0); // update partials w.r.t b^0 pb[0] -= azmul(pz[j], z[j]) + azmul(pb[j], b[j]); // update partial w.r.t. x^0 px[0] += azmul(pb[j], x[j]); // update partial w.r.t. x^j px[j] += pz[j] + azmul(pb[j], x[0]); // further scale partial w.r.t. z[j] by 1 / j pz[j] /= Base(j); for(k = 1; k < j; k++) { // update partials w.r.t b^(j-k) pb[j-k] -= Base(k) * azmul(pz[j], z[k]) + azmul(pb[j], b[k]); // update partials w.r.t. x^k px[k] += azmul(pb[j], x[j-k]); // update partials w.r.t. z^k pz[k] -= Base(k) * azmul(pz[j], b[j-k]); } --j; } // j == 0 case px[0] += azmul(pz[0] + azmul(pb[0], x[0]), inv_b0); } } // END_CPPAD_NAMESPACE # endif # endif cppad-20160000.1/cppad/local/optimize.hpp0000644000175200017650000026223612656321770017175 0ustar coincoin-web// $Id: optimize.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_OPTIMIZE_HPP # define CPPAD_OPTIMIZE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin optimize$$ $spell enum jac bool Taylor var CppAD cppad std CondExpEq $$ $section Optimize an ADFun Object Tape$$ $mindex sequence operations speed memory NDEBUG$$ $head Syntax$$ $icode%f%.optimize()%$$ $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 Improvements$$ You can see the reduction in number of variables in the operation sequence by calling the function $cref/f.size_var()/seq_property/size_var/$$ before and after the optimization procedure. Given that the optimization procedure takes time, it may be faster to skip this optimize procedure and just compute derivatives using the original operation sequence. $subhead Testing$$ You can run the CppAD $cref/speed/speed_main/$$ tests and see the corresponding changes in number of variables and execution time; see $cref cmake_check$$. $head Efficiency$$ The $code optimize$$ member function may greatly reduce the number of variables in the operation sequence; see $cref/size_var/seq_property/size_var/$$. If a $cref/zero order forward/forward_zero/$$ calculation is done during the construction of $icode f$$, it will require more memory and time than required after the optimization procedure. In addition, it will need to be redone. For this reason, it is more efficient to use $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 Atomic Functions$$ There are some subtitle issue with optimized $cref atomic$$ functions $latex v = g(u)$$: $subhead rev_sparse_jac$$ The $cref atomic_rev_sparse_jac$$ function is be used to determine which components of $icode u$$ affect the dependent variables of $icode f$$. For each atomic operation, the current $cref/atomic_sparsity/atomic_option/atomic_sparsity/$$ setting is used to determine if $code pack_sparsity_enum$$, $code bool_sparsity_enum$$, or $code set_sparsity_enum$$ is used to determine dependency relations between argument and result variables. $subhead nan$$ If $icode%u%[%i%]%$$ does not affect the value of 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()%$$. $head Example$$ $children% example/optimize.cpp %$$ The file $cref optimize.cpp$$ contains an example and test of this operation. It returns true if it succeeds and false otherwise. $end ----------------------------------------------------------------------------- */ # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE namespace optimize { // BEGIN_CPPAD_OPTIMIZE_NAMESPACE /*! \file optimize.hpp Routines for optimizing a tape */ /*! State for this variable set during reverse sweep. */ enum enum_connect_type { /// There is no operation that connects this variable to the /// independent variables. not_connected , /// There is one or more operations that connects this variable to the /// independent variables. yes_connected , /// There is only one parrent that connects this variable to the /// independent variables and the parent is a summation operation; i.e., /// AddvvOp, AddpvOp, SubpvOp, SubvpOp, or SubvvOp. sum_connected , /// Satisfies the sum_connected assumptions above and in addition /// this variable is the result of summation operator. csum_connected , /// This node is only connected in the case where the comparision is /// true for the conditional expression with index \c connect_index. cexp_connected }; /*! Class used to hold information about one conditional expression. */ class class_cexp_pair { public: /// packs both the compare and index information /// compare = pack_ % 2 /// index = pack_ / 2 size_t pack_; /// If this is true (false) this connection is only for the case where /// the comparision in the conditional expression is true (false) bool compare(void) const { return pack_ % 2 != 0; } /// This is the index of the conditional expression (in cksip_info) /// for this connection size_t index(void) const { return pack_ / 2; } /// constructor class_cexp_pair(const bool& compare_arg, const size_t& index_arg) : pack_(size_t(compare_arg) + 2 * index_arg ) { CPPAD_ASSERT_UNKNOWN( compare_arg == compare() ); CPPAD_ASSERT_UNKNOWN( index_arg == index() ); } /// assignment operator void operator=(const class_cexp_pair& right) { pack_ = right.pack_; } /// not equal operator bool operator!=(const class_cexp_pair& right) { return pack_ != right.pack_; } /// Less than operator /// (required for intersection of two sets of class_cexp_pair elements). bool operator<(const class_cexp_pair& right) const { return pack_ < right.pack_; } }; /*! A container that is like std::set except that it does not allocate empty sets and only has a few operations. */ class class_set_cexp_pair { private: // This set is empty if and only if ptr_ == CPPAD_NULL; std::set* ptr_; void new_ptr(void) { CPPAD_ASSERT_UNKNOWN( ptr_ == CPPAD_NULL ); ptr_ = new std::set; CPPAD_ASSERT_UNKNOWN( ptr_ != CPPAD_NULL ); // std::cout << "new ptr_ = " << ptr_ << std::endl; } void delete_ptr(void) { if( ptr_ != CPPAD_NULL ) { // std::cout << "delete ptr_ = " << ptr_ << std::endl; delete ptr_; } ptr_ = CPPAD_NULL; } public: /// constructor class_set_cexp_pair(void) { ptr_ = CPPAD_NULL; } /// destructor ~class_set_cexp_pair(void) { delete_ptr(); } void print(void) { if( ptr_ == CPPAD_NULL ) { std::cout << "{ }"; return; } CPPAD_ASSERT_UNKNOWN( ! empty() ); const char* sep = "{ "; std::set::const_iterator itr; for(itr = ptr_->begin(); itr != ptr_->end(); itr++) { std::cout << sep; std::cout << "(" << itr->compare() << "," << itr->index() << ")"; sep = ", "; } std::cout << "}"; } /// assignment operator void operator=(const class_set_cexp_pair& other) { // make this a copy of the other set if( other.ptr_ == CPPAD_NULL ) { if( ptr_ == CPPAD_NULL ) return; delete_ptr(); return; } CPPAD_ASSERT_UNKNOWN( ! other.empty() ); if( ptr_ == CPPAD_NULL ) new_ptr(); *ptr_ = *other.ptr_; } /// insert an element in this set void insert(const class_cexp_pair& element) { if( ptr_ == CPPAD_NULL ) new_ptr(); ptr_->insert(element); CPPAD_ASSERT_UNKNOWN( ! empty() ); } /// is this set empty bool empty(void) const { if( ptr_ == CPPAD_NULL ) return true; CPPAD_ASSERT_UNKNOWN( ! ptr_->empty() ); return false; } /// remove the elements in this set void clear(void) { if( ptr_ == CPPAD_NULL ) return; CPPAD_ASSERT_UNKNOWN( ! empty() ); delete_ptr(); } // returns begin pointer for the set std::set::const_iterator begin(void) { CPPAD_ASSERT_UNKNOWN( ! empty() ); return ptr_->begin(); } // returns end pointer for the set std::set::const_iterator end(void) { CPPAD_ASSERT_UNKNOWN( ! empty() ); return ptr_->end(); } /*! Make this set the intersection of itself with another set. \param other the other set */ void intersection(const class_set_cexp_pair& other ) { // empty result case if( ptr_ == CPPAD_NULL ) return; // empty result case if( other.ptr_ == CPPAD_NULL ) { delete_ptr(); return; } // put result here class_set_cexp_pair result; CPPAD_ASSERT_UNKNOWN( result.ptr_ == CPPAD_NULL ); result.new_ptr(); CPPAD_ASSERT_UNKNOWN( result.ptr_ != CPPAD_NULL ); // do the intersection std::set_intersection( ptr_->begin() , ptr_->end() , other.ptr_->begin() , other.ptr_->end() , std::inserter(*result.ptr_, result.ptr_->begin()) ); if( result.ptr_->empty() ) result.delete_ptr(); // swap this and the result std::swap(ptr_, result.ptr_); return; } }; /*! Structure used by \c optimize to hold information about one variable. in the old operation seqeunce. */ struct struct_old_variable { /// Operator for which this variable is the result, \c NumRes(op) > 0. /// Set by the reverse sweep at beginning of optimization. OpCode op; /// Pointer to first argument (child) for this operator. /// Set by the reverse sweep at beginning of optimization. const addr_t* arg; /// How is this variable connected to the independent variables enum_connect_type connect_type; /// New operation sequence corresponding to this old varable. /// Set during forward sweep to the index in the new tape addr_t new_var; /// New operator index for this varable. /// Set during forward sweep to the index in the new tape size_t new_op; /// Did this variable match another variable in the operation sequence bool match; }; struct struct_size_pair { size_t i_op; // an operator index size_t i_var; // a variable index }; /*! Structures used by \c record_csum to hold information about one variable. */ struct struct_csum_variable { /// Operator for which this variable is the result, \c NumRes(op) > 0. OpCode op; /// Pointer to first argument (child) for this operator. /// Set by the reverse sweep at beginning of optimization. const addr_t* arg; /// Is this variable added to the summation /// (if not it is subtracted) bool add; }; /*! Structure used to pass work space from \c optimize to \c record_csum (so that stacks do not start from zero size every time). */ struct struct_csum_stacks { /// stack of operations in the cummulative summation std::stack op_stack; /// stack of variables to be added std::stack add_stack; /// stack of variables to be subtracted std::stack sub_stack; }; /*! CExpOp information that is copied to corresponding CSkipOp */ struct struct_cskip_info { /// comparision operator 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 size_t flag; /// index for left comparison operand size_t left; /// index for right comparison operand size_t right; /// maximum variable index between left and right size_t max_left_right; /// set of variables to skip on true CppAD::vector skip_var_true; /// set of variables to skip on false CppAD::vector skip_var_false; /// set of operations to skip on true CppAD::vector skip_op_true; /// set of operations to skip on false CppAD::vector skip_op_false; /// size of skip_op_true size_t n_op_true; /// size of skip_op_false size_t n_op_false; /// index in the argument recording of first argument for this CSkipOp size_t i_arg; }; /*! Connection information for a user atomic function */ struct struct_user_info { /// type of connection for this atomic function enum_connect_type connect_type; /// If this is an conditional connection, this is the information /// of the correpsonding CondExpOp operators class_set_cexp_pair cexp_set; /// If this is a conditional connection, this is the operator /// index of the beginning of the atomic call sequence; i.e., /// the first UserOp. size_t op_begin; /// If this is a conditional connection, this is one more than the /// operator index of the ending of the atomic call sequence; i.e., /// the second UserOp. size_t op_end; }; /*! Shared documentation for optimization helper functions (not called). \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. Note that the index for this vector must be greater than or equal zero and less than tape.size(). \li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. \li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current is the index in the old operation sequence for the variable corresponding to the result for the current operator. Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. \param npar is the number of parameters corresponding to this operation sequence. \param par is a vector of length \a npar containing the parameters for this operation sequence; i.e., given a parameter index \c i, the corresponding parameter value is par[i]. */ template void prototype( const CppAD::vector& tape , size_t current , size_t npar , const Base* par ) { CPPAD_ASSERT_UNKNOWN(false); } /*! Check a unary operator for a complete match with a previous operator. A complete match means that the result of the previous operator can be used inplace of the result for current operator. \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. Note that the index for this vector must be greater than or equal zero and less than tape.size(). \li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. \li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current is the index in the old operation sequence for the variable corresponding to the result for the current operator. Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. \param npar is the number of parameters corresponding to this operation sequence. \param par is a vector of length \a npar containing the parameters for this operation sequence; i.e., given a parameter index \c i, the corresponding parameter value is par[i]. \param hash_table_var is a vector with size CPPAD_HASH_TABLE_SIZE that maps a hash code to the corresponding variable index in the old operation sequence. All the values in this table must be less than \a current. \param code The input value of code does not matter. The output value of code is the hash code corresponding to this operation in the new operation sequence. \return If the return value is zero, no match was found. If the return value is greater than zero, it is the old operation sequence index of a variable, that comes before current and can be used to replace the current variable. \par Restrictions: NumArg( tape[current].op ) == 1 */ template addr_t unary_match( const CppAD::vector& tape , size_t current , size_t npar , const Base* par , const CppAD::vector& hash_table_var , unsigned short& code ) { const addr_t* arg = tape[current].arg; OpCode op = tape[current].op; addr_t new_arg[1]; // ErfOp has three arguments, but the second and third are always the // parameters 0 and 2 / sqrt(pi) respectively. CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 || op == ErfOp); CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < current ); new_arg[0] = tape[arg[0]].new_var; CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < current ); code = hash_code( op , new_arg , npar , par ); size_t i_var = hash_table_var[code]; CPPAD_ASSERT_UNKNOWN( i_var < current ); if( op == tape[i_var].op ) { size_t k = tape[i_var].arg[0]; CPPAD_ASSERT_UNKNOWN( k < i_var ); if (new_arg[0] == tape[k].new_var ) return i_var; } return 0; } /*! Check a binary operator for a complete match with a previous operator, \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. Note that the index for this vector must be greater than or equal zero and less than tape.size(). \li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. \li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current is the index in the old operation sequence for the variable corresponding to the result for the current operator. Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. \param npar is the number of parameters corresponding to this operation sequence. \param par is a vector of length \a npar containing the parameters for this operation sequence; i.e., given a parameter index \c i, the corresponding parameter value is par[i]. \param hash_table_var is a vector with size CPPAD_HASH_TABLE_SIZE that maps a hash code to the corresponding variable index in the old operation sequence. All the values in this table must be less than \a current. \param code The input value of code does not matter. The output value of code is the hash code corresponding to this operation in the new operation sequence. \return If the return value is zero, no match was found. If the return value is greater than zero, it is the index of a new variable that can be used to replace the old variable. \par Restrictions: The binary operator must be an addition, subtraction, multiplication, division or power operator. NumArg( tape[current].op ) == 1. */ template inline addr_t binary_match( const CppAD::vector& tape , size_t current , size_t npar , const Base* par , const CppAD::vector& hash_table_var , unsigned short& code ) { OpCode op = tape[current].op; const addr_t* arg = tape[current].arg; addr_t new_arg[2]; bool parameter[2]; // initialize return value addr_t match_var = 0; CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); switch(op) { // index op variable case DisOp: // parameter not defined for this case CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < current ); new_arg[0] = arg[0]; new_arg[1] = tape[arg[1]].new_var; break; // parameter op variable ---------------------------------- case AddpvOp: case MulpvOp: case DivpvOp: case PowpvOp: case SubpvOp: case ZmulpvOp: // arg[0] parameter[0] = true; new_arg[0] = arg[0]; CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < npar ); // arg[1] parameter[1] = false; new_arg[1] = tape[arg[1]].new_var; CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < current ); break; // variable op parameter ----------------------------------- case DivvpOp: case PowvpOp: case SubvpOp: case ZmulvpOp: // arg[0] parameter[0] = false; new_arg[0] = tape[arg[0]].new_var; CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < current ); // arg[1] parameter[1] = true; new_arg[1] = arg[1]; CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < npar ); break; // variable op variable ----------------------------------- case AddvvOp: case MulvvOp: case DivvvOp: case PowvvOp: case SubvvOp: case ZmulvvOp: // arg[0] parameter[0] = false; new_arg[0] = tape[arg[0]].new_var; CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < current ); // arg[1] parameter[1] = false; new_arg[1] = tape[arg[1]].new_var; CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < current ); break; // must be one of the cases above default: CPPAD_ASSERT_UNKNOWN(false); } code = hash_code( op , new_arg , npar , par ); size_t i_var = hash_table_var[code]; CPPAD_ASSERT_UNKNOWN( i_var < current ); if( op == tape[i_var].op ) { bool match = true; if( op == DisOp ) { match &= new_arg[0] == tape[i_var].arg[0]; size_t k = tape[i_var].arg[1]; match &= new_arg[1] == tape[k].new_var; } else { for(size_t j = 0; j < 2; j++) { size_t k = tape[i_var].arg[j]; if( parameter[j] ) { CPPAD_ASSERT_UNKNOWN( k < npar ); match &= IdenticalEqualPar( par[ arg[j] ], par[k] ); } else { CPPAD_ASSERT_UNKNOWN( k < i_var ); match &= (new_arg[j] == tape[k].new_var); } } } if( match ) match_var = i_var; } if( (match_var > 0) | ( (op != AddvvOp) & (op != MulvvOp ) ) ) return match_var; // check for match with argument order switched ---------------------- CPPAD_ASSERT_UNKNOWN( op == AddvvOp || op == MulvvOp ); std::swap(new_arg[0], new_arg[1]); unsigned short code_switch = hash_code( op , new_arg , npar , par ); i_var = hash_table_var[code_switch]; CPPAD_ASSERT_UNKNOWN( i_var < current ); if( op == tape[i_var].op ) { bool match = true; size_t j; for(j = 0; j < 2; j++) { size_t k = tape[i_var].arg[j]; CPPAD_ASSERT_UNKNOWN( k < i_var ); match &= (new_arg[j] == tape[k].new_var); } if( match ) match_var = i_var; } return match_var; } /*! Record an operation of the form (parameter op variable). \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. Note that the index for this vector must be greater than or equal zero and less than tape.size(). \li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. \li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current is the index in the old operation sequence for the variable corresponding to the result for the current operator. Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. \param npar is the number of parameters corresponding to this operation sequence. \param par is a vector of length \a npar containing the parameters for this operation sequence; i.e., given a parameter index \c i, the corresponding parameter value is par[i]. \param rec is the object that will record the operations. \param op is the operator that we are recording which must be one of the following: AddpvOp, DivpvOp, MulpvOp, PowpvOp, SubpvOp, ZmulpvOp. \param arg is the vector of arguments for this operator. \return the result is the operaiton and variable index corresponding to the current operation in the new operation sequence. */ template struct_size_pair record_pv( const CppAD::vector& tape , size_t current , size_t npar , const Base* par , recorder* rec , OpCode op , const addr_t* arg ) { # ifndef NDEBUG switch(op) { case AddpvOp: case DivpvOp: case MulpvOp: case PowpvOp: case SubpvOp: case ZmulpvOp: break; default: CPPAD_ASSERT_UNKNOWN(false); } # endif CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < npar ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < current ); addr_t new_arg[2]; new_arg[0] = rec->PutPar( par[arg[0]] ); new_arg[1] = tape[ arg[1] ].new_var; rec->PutArg( new_arg[0], new_arg[1] ); struct_size_pair ret; ret.i_op = rec->num_op_rec(); ret.i_var = rec->PutOp(op); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < ret.i_var ); return ret; } /*! Record an operation of the form (variable op parameter). \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. Note that the index for this vector must be greater than or equal zero and less than tape.size(). \li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. \li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current is the index in the old operation sequence for the variable corresponding to the result for the current operator. Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. \param npar is the number of parameters corresponding to this operation sequence. \param par is a vector of length \a npar containing the parameters for this operation sequence; i.e., given a parameter index \c i, the corresponding parameter value is par[i]. \param rec is the object that will record the operations. \param op is the operator that we are recording which must be one of the following: DivvpOp, PowvpOp, SubvpOp, ZmulvpOp. \param arg is the vector of arguments for this operator. \return the result operation and variable index corresponding to the current operation in the new operation sequence. */ template struct_size_pair record_vp( const CppAD::vector& tape , size_t current , size_t npar , const Base* par , recorder* rec , OpCode op , const addr_t* arg ) { # ifndef NDEBUG switch(op) { case DivvpOp: case PowvpOp: case SubvpOp: case ZmulvpOp: break; default: CPPAD_ASSERT_UNKNOWN(false); } # endif CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < current ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < npar ); addr_t new_arg[2]; new_arg[0] = tape[ arg[0] ].new_var; new_arg[1] = rec->PutPar( 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 = rec->PutOp(op); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < ret.i_var ); return ret; } /*! Record an operation of the form (variable op variable). \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. Note that the index for this vector must be greater than or equal zero and less than tape.size(). \li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. \li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current is the index in the old operation sequence for the variable corresponding to the result for the current operator. Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. \param npar is the number of parameters corresponding to this operation sequence. \param par is a vector of length \a npar containing the parameters for this operation sequence; i.e., given a parameter index \c i, the corresponding parameter value is par[i]. \param rec is the object that will record the operations. \param op is the operator that we are recording which must be one of the following: AddvvOp, DivvvOp, MulvvOp, PowvvOp, SubvvOp, ZmulvvOp. \param arg is the vector of arguments for this operator. \return the result is the operation and variable index corresponding to the current operation in the new operation sequence. */ template struct_size_pair record_vv( const CppAD::vector& tape , size_t current , size_t npar , const Base* par , recorder* rec , OpCode op , const addr_t* arg ) { # 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( size_t(arg[0]) < current ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < current ); addr_t new_arg[2]; new_arg[0] = tape[ arg[0] ].new_var; new_arg[1] = tape[ arg[1] ].new_var; rec->PutArg( new_arg[0], new_arg[1] ); struct_size_pair ret; ret.i_op = rec->num_op_rec(); ret.i_var = rec->PutOp(op); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < ret.i_var ); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[1]) < ret.i_var ); return ret; } // ========================================================================== /*! Recording a cummulative cummulative summation starting at its highest parrent. \param tape is a vector that maps a variable index, in the old operation sequence, to an struct_old_variable information record. Note that the index for this vector must be greater than or equal zero and less than tape.size(). \li tape[i].op is the operator in the old operation sequence corresponding to the old variable index \c i. Assertion: NumRes(tape[i].op) > 0. \li tape[i].arg for j < NumArg( tape[i].op ), tape[i].arg[j] is the j-th the argument, in the old operation sequence, corresponding to the old variable index \c i. Assertion: tape[i].arg[j] < i. \li tape[i].new_var Suppose i <= current, j < NumArg( tape[i].op ), and k = tape[i].arg[j], and \c j corresponds to a variable for operator tape[i].op. It follows that tape[k].new_var has alread been set to the variable in the new operation sequence corresponding to the old variable index \c k. This means that the \c new_var value has been set for all the possible arguments that come before \a current. \param current is the index in the old operation sequence for the variable corresponding to the result for the current operator. Assertions: current < tape.size(), NumRes( tape[current].op ) > 0. \param npar is the number of parameters corresponding to this operation sequence. \param par is a vector of length \a npar containing the parameters for this operation sequence; i.e., given a parameter index \c i, the corresponding parameter value is par[i]. \param rec is the object that will record the operations. \param work Is used for computation. On input and output, work.op_stack.empty(), work.add_stack.empty(), and work.sub_stack.empty(), are all true true. These stacks are passed in so that elements can be allocated once and then the elements can be reused with calls to \c record_csum. \par Exception tape[i].new_var is not yet defined for any node \c i that is \c csum_connected to the \a current node (or that is \c sum_connected to a node that is \c csum_connected). For example; suppose that index \c j corresponds to a variable in the current operator, i = tape[current].arg[j], and tape[arg[j]].connect_type == csum_connected. It then follows that tape[i].new_var == tape.size(). \par Restriction: \li tape[current].op must be one of AddpvOp, AddvvOp, SubpvOp, SubvpOp, SubvvOp. \li tape[current].connect_type must be \c yes_connected. \li tape[j].connect_type == csum_connected for some index j that is a variable operand for the current operation. */ template struct_size_pair record_csum( const CppAD::vector& tape , size_t current , size_t npar , const Base* par , recorder* rec , struct_csum_stacks& work ) { CPPAD_ASSERT_UNKNOWN( work.op_stack.empty() ); CPPAD_ASSERT_UNKNOWN( work.add_stack.empty() ); CPPAD_ASSERT_UNKNOWN( work.sub_stack.empty() ); CPPAD_ASSERT_UNKNOWN( tape[current].connect_type == yes_connected ); size_t i; OpCode op; const addr_t* arg; bool add; struct struct_csum_variable var; var.op = tape[current].op; var.arg = tape[current].arg; var.add = true; work.op_stack.push( var ); Base sum_par(0); # ifndef NDEBUG bool ok = false; if( var.op == SubvpOp ) ok = tape[ tape[current].arg[0] ].connect_type == csum_connected; if( var.op == AddpvOp || var.op == SubpvOp ) ok = tape[ tape[current].arg[1] ].connect_type == csum_connected; if( var.op == AddvvOp || var.op == SubvvOp ) { ok = tape[ tape[current].arg[0] ].connect_type == csum_connected; ok |= tape[ tape[current].arg[1] ].connect_type == csum_connected; } CPPAD_ASSERT_UNKNOWN( ok ); # endif while( ! work.op_stack.empty() ) { var = work.op_stack.top(); work.op_stack.pop(); op = var.op; arg = var.arg; add = var.add; // process first argument to this operator switch(op) { case AddpvOp: case SubpvOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < npar ); if( add ) sum_par += par[arg[0]]; else sum_par -= par[arg[0]]; break; case AddvvOp: case SubvpOp: case SubvvOp: if( tape[arg[0]].connect_type == csum_connected ) { CPPAD_ASSERT_UNKNOWN( size_t(tape[arg[0]].new_var) == tape.size() ); var.op = tape[arg[0]].op; var.arg = tape[arg[0]].arg; var.add = add; work.op_stack.push( var ); } else if( add ) work.add_stack.push(arg[0]); else work.sub_stack.push(arg[0]); break; default: CPPAD_ASSERT_UNKNOWN(false); } // process second argument to this operator switch(op) { case SubvpOp: CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < npar ); if( add ) sum_par -= par[arg[1]]; else sum_par += par[arg[1]]; break; case SubvvOp: case SubpvOp: add = ! add; case AddvvOp: case AddpvOp: if( tape[arg[1]].connect_type == csum_connected ) { CPPAD_ASSERT_UNKNOWN( size_t(tape[arg[1]].new_var) == tape.size() ); var.op = tape[arg[1]].op; var.arg = tape[arg[1]].arg; var.add = add; work.op_stack.push( var ); } else if( add ) work.add_stack.push(arg[1]); else work.sub_stack.push(arg[1]); break; default: CPPAD_ASSERT_UNKNOWN(false); } } // number of variables in this cummulative sum operator size_t n_add = work.add_stack.size(); size_t n_sub = work.sub_stack.size(); size_t old_arg, new_arg; rec->PutArg(n_add); // arg[0] rec->PutArg(n_sub); // arg[1] new_arg = rec->PutPar( sum_par ); rec->PutArg(new_arg); // arg[2] for(i = 0; i < n_add; i++) { CPPAD_ASSERT_UNKNOWN( ! work.add_stack.empty() ); old_arg = work.add_stack.top(); new_arg = tape[old_arg].new_var; CPPAD_ASSERT_UNKNOWN( new_arg < tape.size() ); rec->PutArg(new_arg); // arg[3+i] work.add_stack.pop(); } for(i = 0; i < n_sub; i++) { CPPAD_ASSERT_UNKNOWN( ! work.sub_stack.empty() ); old_arg = work.sub_stack.top(); new_arg = tape[old_arg].new_var; CPPAD_ASSERT_UNKNOWN( new_arg < tape.size() ); rec->PutArg(new_arg); // arg[3 + arg[0] + i] work.sub_stack.pop(); } rec->PutArg(n_add + n_sub); // arg[3 + arg[0] + arg[1]] struct_size_pair ret; ret.i_op = rec->num_op_rec(); ret.i_var = rec->PutOp(CSumOp); CPPAD_ASSERT_UNKNOWN( new_arg < ret.i_var ); return ret; } // ========================================================================== /*! Convert a player object to an optimized recorder object \tparam Base base type for the operator; i.e., this operation was recorded using AD< \a Base > and computations by this routine are done using type \a Base. \param options The possible values for this string are: "", "no_conditional_skip". If it is "no_conditional_skip", then no conditional skip operations will be generated. \param n is the number of independent variables on the tape. \param dep_taddr On input this vector contains the indices for each of the dependent variable values in the operation sequence corresponding to \a play. Upon return it contains the indices for the same variables but in the operation sequence corresponding to \a rec. \param play This is the operation sequence that we are optimizing. It is essentially const, except for play back state which changes while it plays back the operation seqeunce. \param rec The input contents of this recording does not matter. Upon return, it contains an optimized verison of the operation sequence corresponding to \a play. */ template void optimize_run( const std::string& options , size_t n , CppAD::vector& dep_taddr , player* play , recorder* rec ) { // nan with type Base Base base_nan = Base( std::numeric_limits::quiet_NaN() ); // temporary indices size_t i, j, k; // check options bool conditional_skip = options.find("no_conditional_skip", 0) == std::string::npos; // temporary variables OpCode op; // current operator const addr_t* arg; // operator arguments size_t i_var; // index of first result for current operator // range and domain dimensions for F size_t m = dep_taddr.size(); // number of variables in the player const size_t num_var = play->num_var_rec(); # ifndef NDEBUG // number of parameters in the player const size_t num_par = play->num_par_rec(); # endif // number of VecAD indices size_t num_vecad_ind = play->num_vec_ind_rec(); // number of VecAD vectors size_t num_vecad_vec = play->num_vecad_vec_rec(); // ------------------------------------------------------------- // data structure that maps variable index in original operation // sequence to corresponding operator information CppAD::vector tape(num_var); // if tape[i].connect_type == exp_connected, cexp_set[i] is the // corresponding information for the conditional connection. CppAD::vector cexp_vec_set; if( conditional_skip ) cexp_vec_set.resize(num_var); // ------------------------------------------------------------- // Determine how each variable is connected to the dependent variables // initialize all variables has having no connections for(i = 0; i < num_var; i++) tape[i].connect_type = not_connected; for(j = 0; j < m; j++) { // mark dependent variables as having one or more connections tape[ dep_taddr[j] ].connect_type = yes_connected; } // vecad_connect contains a value for each VecAD object. // vecad maps a VecAD index (which corresponds to the beginning of the // VecAD object) to the vecad_connect falg for the VecAD object. CppAD::vector vecad_connect(num_vecad_vec); CppAD::vector vecad(num_vecad_ind); j = 0; for(i = 0; i < num_vecad_vec; i++) { vecad_connect[i] = not_connected; // length of this VecAD size_t length = play->GetVecInd(j); // set to proper index for this VecAD vecad[j] = i; for(k = 1; k <= length; k++) vecad[j+k] = num_vecad_vec; // invalid index // start of next VecAD j += length + 1; } CPPAD_ASSERT_UNKNOWN( j == num_vecad_ind ); // work space used by UserOp. typedef std::set size_set; // vector user_r_set; // set sparsity pattern for result vector user_s_set; // set sparisty pattern for argument // vector user_r_bool; // bool sparsity pattern for result vector user_s_bool; // bool sparisty pattern for argument // vectorBool user_r_pack; // pack sparsity pattern for result vectorBool user_s_pack; // pack sparisty pattern for argument // size_t user_q = 0; // column dimension for sparsity patterns size_t user_index = 0; // indentifier for this user_atomic operation size_t user_id = 0; // user identifier for this call to operator size_t user_i = 0; // index in result vector size_t user_j = 0; // index in argument vector size_t user_m = 0; // size of result vector size_t user_n = 0; // size of arugment vector // atomic_base* user_atom = CPPAD_NULL; // current user atomic function bool user_pack = false; // sparsity pattern type is pack bool user_bool = false; // sparsity pattern type is bool bool user_set = false; // sparsity pattern type is set // next expected operator in a UserOp sequence enum { user_start, user_arg, user_ret, user_end } user_state; // During reverse mode, compute type of connection for each call to // a user atomic function. CppAD::vector user_info; size_t user_curr = 0; /// During reverse mode, information for each CSkip operation CppAD::vector cskip_info; // Initialize a reverse mode sweep through the operation sequence size_t i_op; play->reverse_start(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( op == EndOp ); size_t mask; user_state = user_end; while(op != BeginOp) { // next op play->reverse_next(op, arg, i_op, i_var); // Store the operator corresponding to each variable if( NumRes(op) > 0 ) { tape[i_var].op = op; tape[i_var].arg = arg; } # ifndef NDEBUG if( i_op <= n ) { CPPAD_ASSERT_UNKNOWN((op == InvOp) | (op == BeginOp)); } else CPPAD_ASSERT_UNKNOWN((op != InvOp) & (op != BeginOp)); # endif enum_connect_type connect_type = tape[i_var].connect_type; class_set_cexp_pair* cexp_set = CPPAD_NULL; if( conditional_skip ) cexp_set = &cexp_vec_set[i_var]; switch( op ) { // One variable corresponding to arg[0] case AbsOp: case AcosOp: case AcoshOp: case AsinOp: case AsinhOp: case AtanOp: case AtanhOp: case CosOp: case CoshOp: case DivvpOp: case ErfOp: case ExpOp: case Expm1Op: case LogOp: case Log1pOp: case PowvpOp: case SignOp: case SinOp: case SinhOp: case SqrtOp: case TanOp: case TanhOp: case ZmulvpOp: switch( connect_type ) { case not_connected: break; case yes_connected: case sum_connected: case csum_connected: tape[arg[0]].connect_type = yes_connected; break; case cexp_connected: CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[0]].connect_type == not_connected ) { tape[arg[0]].connect_type = cexp_connected; cexp_vec_set[arg[0]] = *cexp_set; } else if( tape[arg[0]].connect_type == cexp_connected ) { cexp_vec_set[arg[0]].intersection(*cexp_set); if( cexp_vec_set[arg[0]].empty() ) tape[arg[0]].connect_type = yes_connected; } else tape[arg[0]].connect_type = yes_connected; break; default: CPPAD_ASSERT_UNKNOWN(false); } break; // -------------------------------------------- // One variable corresponding to arg[1] case DisOp: case DivpvOp: case MulpvOp: case PowpvOp: case ZmulpvOp: switch( connect_type ) { case not_connected: break; case yes_connected: case sum_connected: case csum_connected: tape[arg[1]].connect_type = yes_connected; break; case cexp_connected: CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[1]].connect_type == not_connected ) { tape[arg[1]].connect_type = cexp_connected; cexp_vec_set[arg[1]] = *cexp_set; } else if( tape[arg[1]].connect_type == cexp_connected ) { cexp_vec_set[arg[1]].intersection(*cexp_set); if( cexp_vec_set[arg[1]].empty() ) tape[arg[1]].connect_type = yes_connected; } else tape[arg[1]].connect_type = yes_connected; break; default: CPPAD_ASSERT_UNKNOWN(false); } break; // -------------------------------------------- // Special case for SubvpOp case SubvpOp: switch( connect_type ) { case not_connected: break; case yes_connected: case sum_connected: case csum_connected: if( tape[arg[0]].connect_type == not_connected ) tape[arg[0]].connect_type = sum_connected; else tape[arg[0]].connect_type = yes_connected; break; case cexp_connected: CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[0]].connect_type == not_connected ) { tape[arg[0]].connect_type = cexp_connected; cexp_vec_set[arg[0]] = *cexp_set; } else if( tape[arg[0]].connect_type == cexp_connected ) { cexp_vec_set[arg[0]].intersection(*cexp_set); if( cexp_vec_set[arg[0]].empty() ) tape[arg[0]].connect_type = yes_connected; } else tape[arg[0]].connect_type = yes_connected; break; default: CPPAD_ASSERT_UNKNOWN(false); } if( connect_type == sum_connected ) { // convert sum to csum connection for this variable tape[i_var].connect_type = connect_type = csum_connected; } break; // -------------------------------------------- // Special case for AddpvOp and SubpvOp case AddpvOp: case SubpvOp: switch( connect_type ) { case not_connected: break; case yes_connected: case sum_connected: case csum_connected: if( tape[arg[1]].connect_type == not_connected ) tape[arg[1]].connect_type = sum_connected; else tape[arg[1]].connect_type = yes_connected; break; case cexp_connected: CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[1]].connect_type == not_connected ) { tape[arg[1]].connect_type = cexp_connected; cexp_vec_set[arg[1]] = *cexp_set; } else if( tape[arg[1]].connect_type == cexp_connected ) { cexp_vec_set[arg[1]].intersection(*cexp_set); if( cexp_vec_set[arg[1]].empty() ) tape[arg[1]].connect_type = yes_connected; } else tape[arg[1]].connect_type = yes_connected; break; default: CPPAD_ASSERT_UNKNOWN(false); } if( connect_type == sum_connected ) { // convert sum to csum connection for this variable tape[i_var].connect_type = connect_type = csum_connected; } break; // -------------------------------------------- // Special case for AddvvOp and SubvvOp case AddvvOp: case SubvvOp: for(i = 0; i < 2; i++) switch( connect_type ) { case not_connected: break; case yes_connected: case sum_connected: case csum_connected: if( tape[arg[i]].connect_type == not_connected ) tape[arg[i]].connect_type = sum_connected; else tape[arg[i]].connect_type = yes_connected; break; case cexp_connected: CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[i]].connect_type == not_connected ) { tape[arg[i]].connect_type = cexp_connected; cexp_vec_set[arg[i]] = *cexp_set; } else if( tape[arg[i]].connect_type == cexp_connected ) { cexp_vec_set[arg[i]].intersection(*cexp_set); if( cexp_vec_set[arg[i]].empty() ) tape[arg[i]].connect_type = yes_connected; } else tape[arg[i]].connect_type = yes_connected; break; default: CPPAD_ASSERT_UNKNOWN(false); } if( connect_type == sum_connected ) { // convert sum to csum connection for this variable tape[i_var].connect_type = connect_type = csum_connected; } break; // -------------------------------------------- // Other binary operators // where operands are arg[0], arg[1] case DivvvOp: case MulvvOp: case PowvvOp: case ZmulvvOp: for(i = 0; i < 2; i++) switch( connect_type ) { case not_connected: break; case yes_connected: case sum_connected: case csum_connected: tape[arg[i]].connect_type = yes_connected; break; case cexp_connected: CPPAD_ASSERT_UNKNOWN( conditional_skip ) if( tape[arg[i]].connect_type == not_connected ) { tape[arg[i]].connect_type = cexp_connected; cexp_vec_set[arg[i]] = *cexp_set; } else if( tape[arg[i]].connect_type == cexp_connected ) { cexp_vec_set[arg[i]].intersection(*cexp_set); if( cexp_vec_set[arg[i]].empty() ) tape[arg[i]].connect_type = yes_connected; } else tape[arg[i]].connect_type = yes_connected; break; default: CPPAD_ASSERT_UNKNOWN(false); } break; // -------------------------------------------- // Conditional expression operators case CExpOp: CPPAD_ASSERT_UNKNOWN( NumArg(CExpOp) == 6 ); if( connect_type != not_connected ) { struct_cskip_info info; info.cop = CompareOp( arg[0] ); info.flag = arg[1]; info.left = arg[2]; info.right = arg[3]; info.n_op_true = 0; info.n_op_false = 0; info.i_arg = 0; // case where no CSkipOp for this CExpOp // size_t index = 0; if( arg[1] & 1 ) { index = std::max(index, info.left); tape[info.left].connect_type = yes_connected; } if( arg[1] & 2 ) { index = std::max(index, info.right); tape[info.right].connect_type = yes_connected; } CPPAD_ASSERT_UNKNOWN( index > 0 ); info.max_left_right = index; // index = cskip_info.size(); cskip_info.push_back(info); // if( arg[1] & 4 ) { if( conditional_skip && tape[arg[4]].connect_type == not_connected ) { tape[arg[4]].connect_type = cexp_connected; cexp_vec_set[arg[4]] = *cexp_set; cexp_vec_set[arg[4]].insert( class_cexp_pair(true, index) ); } else { // if arg[4] is cexp_connected, it could be // connected for both the true and false case // 2DO: if previously cexp_connected // and the true/false sense is the same, should // keep this conditional connnection. if(conditional_skip) cexp_vec_set[arg[4]].clear(); tape[arg[4]].connect_type = yes_connected; } } if( arg[1] & 8 ) { if( conditional_skip && tape[arg[5]].connect_type == not_connected ) { tape[arg[5]].connect_type = cexp_connected; cexp_vec_set[arg[5]] = *cexp_set; cexp_vec_set[arg[5]].insert( class_cexp_pair(false, index) ); } else { if(conditional_skip) cexp_vec_set[arg[5]].clear(); tape[arg[5]].connect_type = yes_connected; } } } break; // -------------------------------------------- // Operations where there is nothing to do case EndOp: case ParOp: case PriOp: break; // -------------------------------------------- // Operators that never get removed case BeginOp: case InvOp: tape[i_var].connect_type = yes_connected; break; // Compare operators never get removed ----------------- case LepvOp: case LtpvOp: case EqpvOp: case NepvOp: tape[arg[1]].connect_type = yes_connected; break; case LevpOp: case LtvpOp: tape[arg[0]].connect_type = yes_connected; break; case LevvOp: case LtvvOp: case EqvvOp: case NevvOp: tape[arg[0]].connect_type = yes_connected; tape[arg[1]].connect_type = yes_connected; break; // Load using a parameter index ---------------------- case LdpOp: if( tape[i_var].connect_type != not_connected ) { i = vecad[ arg[0] - 1 ]; vecad_connect[i] = yes_connected; } break; // -------------------------------------------- // Load using a variable index case LdvOp: if( tape[i_var].connect_type != not_connected ) { i = vecad[ arg[0] - 1 ]; vecad_connect[i] = yes_connected; tape[arg[1]].connect_type = yes_connected; } break; // -------------------------------------------- // Store a variable using a parameter index case StpvOp: i = vecad[ arg[0] - 1 ]; if( vecad_connect[i] != not_connected ) tape[arg[2]].connect_type = yes_connected; break; // -------------------------------------------- // Store a variable using a variable index case StvvOp: i = vecad[ arg[0] - 1 ]; if( vecad_connect[i] ) { tape[arg[1]].connect_type = yes_connected; tape[arg[2]].connect_type = yes_connected; } break; // ============================================================ case UserOp: // start or end atomic operation sequence CPPAD_ASSERT_UNKNOWN( NumRes( UserOp ) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg( UserOp ) == 4 ); if( user_state == user_end ) { user_index = arg[0]; user_id = arg[1]; user_n = arg[2]; user_m = arg[3]; user_q = 1; user_atom = atomic_base::class_object(user_index); if( user_atom == CPPAD_NULL ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } user_pack = user_atom->sparsity() == atomic_base::pack_sparsity_enum; user_bool = user_atom->sparsity() == atomic_base::bool_sparsity_enum; user_set = user_atom->sparsity() == atomic_base::set_sparsity_enum; CPPAD_ASSERT_UNKNOWN( user_pack || user_bool || user_set ); user_set = user_atom->sparsity() == atomic_base::set_sparsity_enum; // // Note user_q is 1, but use it for clarity of code if( user_pack ) { if( user_r_pack.size() != user_m * user_q ) user_r_pack.resize( user_m * user_q ); if( user_s_pack.size() != user_n * user_q ) user_s_pack.resize( user_n * user_q ); for(i = 0; i < user_m; i++) for(j = 0; j < user_q; j++) user_r_pack[ i * user_q + j] = false; } if( user_bool ) { if( user_r_bool.size() != user_m * user_q ) user_r_bool.resize( user_m * user_q ); if( user_s_bool.size() != user_n * user_q ) user_s_bool.resize( user_n * user_q ); for(i = 0; i < user_m; i++) for(j = 0; j < user_q; j++) user_r_bool[ i * user_q + j] = false; } if( user_set ) { if(user_s_set.size() != user_n ) user_s_set.resize(user_n); if(user_r_set.size() != user_m ) user_r_set.resize(user_m); for(i = 0; i < user_m; i++) user_r_set[i].clear(); } // user_j = user_n; user_i = user_m; user_state = user_ret; // struct_user_info info; info.connect_type = not_connected; info.op_end = i_op + 1; user_info.push_back(info); } else { CPPAD_ASSERT_UNKNOWN( user_state == user_start ); CPPAD_ASSERT_UNKNOWN( user_index == size_t(arg[0]) ); CPPAD_ASSERT_UNKNOWN( user_id == size_t(arg[1]) ); CPPAD_ASSERT_UNKNOWN( user_n == size_t(arg[2]) ); CPPAD_ASSERT_UNKNOWN( user_m == size_t(arg[3]) ); user_state = user_end; // CPPAD_ASSERT_UNKNOWN( user_curr + 1 == user_info.size() ); user_info[user_curr].op_begin = i_op; user_curr = user_info.size(); } break; case UsrapOp: // parameter argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( 0 < user_j && user_j <= user_n ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); --user_j; if( user_j == 0 ) user_state = user_start; break; case UsravOp: // variable argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( 0 < user_j && user_j <= user_n ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= i_var ); CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); --user_j; if( user_set ) { if( ! user_s_set[user_j].empty() ) tape[arg[0]].connect_type = user_info[user_curr].connect_type; } if( user_bool ) { if( user_s_bool[user_j] ) tape[arg[0]].connect_type = user_info[user_curr].connect_type; } if( user_pack ) { if( user_s_pack[user_j] ) tape[arg[0]].connect_type = user_info[user_curr].connect_type; } if( user_j == 0 ) user_state = user_start; break; case UsrrvOp: // variable result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( 0 < user_i && user_i <= user_m ); --user_i; switch( connect_type ) { case not_connected: break; case yes_connected: case sum_connected: case csum_connected: user_info[user_curr].connect_type = yes_connected; if( user_set ) user_r_set[user_i].insert(0); if( user_bool ) user_r_bool[user_i] = true; if( user_pack ) user_r_pack[user_i] = true; break; case cexp_connected: CPPAD_ASSERT_UNKNOWN( conditional_skip ); if( user_info[user_curr].connect_type == not_connected ) { user_info[user_curr].connect_type = connect_type; user_info[user_curr].cexp_set = *cexp_set; } else if(user_info[user_curr].connect_type==cexp_connected) { user_info[user_curr].cexp_set.intersection(*cexp_set); if( user_info[user_curr].cexp_set.empty() ) user_info[user_curr].connect_type = yes_connected; } else user_info[user_curr].connect_type = yes_connected; if( user_set ) user_r_set[user_i].insert(0); if( user_bool ) user_r_bool[user_i] = true; if( user_pack ) user_r_pack[user_i] = true; break; default: CPPAD_ASSERT_UNKNOWN(false); } // drop into op = UsrrpOp code to handle case where user_i == 0 // for both UsrrvOp and UsrrpOp together. case UsrrpOp: if( op == UsrrpOp ) { // parameter result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( 0 < user_i && user_i <= user_m ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); --user_i; } if( user_i == 0 ) { // call users function for this operation user_atom->set_id(user_id); bool flag = false; if( user_set ) { flag = user_atom-> rev_sparse_jac(user_q, user_r_set, user_s_set); } if( user_bool ) { flag = user_atom-> rev_sparse_jac(user_q, user_r_bool, user_s_bool); } if( user_pack ) { flag = user_atom-> rev_sparse_jac(user_q, user_r_pack, user_s_pack); } if( ! flag ) { std::string s = "Optimizing an ADFun object" " that contains the atomic function\n\t"; s += user_atom->afun_name(); s += "\nCurrent atomic_sparsity is set to"; // if( user_set ) s += "set_sparsity_enum.\n"; if( user_bool ) s += "bool_sparsity_enum.\n"; if( user_pack ) s += "pack_sparsity_enum.\n"; // s += "This version of rev_sparse_jac returned false"; CPPAD_ASSERT_KNOWN(false, s.c_str() ); } user_state = user_arg; } break; // ============================================================ // all cases should be handled above default: CPPAD_ASSERT_UNKNOWN(0); } } // values corresponding to BeginOp CPPAD_ASSERT_UNKNOWN( i_op == 0 && i_var == 0 && op == BeginOp ); tape[i_var].op = op; tape[i_var].connect_type = yes_connected; // ------------------------------------------------------------- // Determine which variables can be conditionally skipped for(i = 0; i < num_var; i++) { if( tape[i].connect_type == cexp_connected && ! cexp_vec_set[i].empty() ) { std::set::const_iterator itr = cexp_vec_set[i].begin(); while( itr != cexp_vec_set[i].end() ) { j = itr->index(); if( itr->compare() == true ) cskip_info[j].skip_var_false.push_back(i); else cskip_info[j].skip_var_true.push_back(i); itr++; } } } // Determine size of skip information in user_info for(i = 0; i < user_info.size(); i++) { if( user_info[i].connect_type == cexp_connected && ! user_info[i].cexp_set.empty() ) { std::set::const_iterator itr = user_info[i].cexp_set.begin(); while( itr != user_info[i].cexp_set.end() ) { j = itr->index(); if( itr->compare() == true ) cskip_info[j].n_op_false = user_info[i].op_end - user_info[i].op_begin; else cskip_info[j].n_op_true = user_info[i].op_end - user_info[i].op_begin; itr++; } } } // Sort the conditional skip information by the maximum of the // index for the left and right comparision operands CppAD::vector cskip_info_order( cskip_info.size() ); { CppAD::vector keys( cskip_info.size() ); for(i = 0; i < cskip_info.size(); i++) keys[i] = std::max( cskip_info[i].left, cskip_info[i].right ); CppAD::index_sort(keys, cskip_info_order); } // index in sorted order size_t cskip_order_next = 0; // index in order during reverse sweep size_t cskip_info_index = cskip_info.size(); // Initilaize table mapping hash code to variable index in tape // as pointing to the BeginOp at the beginning of the tape CppAD::vector hash_table_var(CPPAD_HASH_TABLE_SIZE); for(i = 0; i < CPPAD_HASH_TABLE_SIZE; i++) hash_table_var[i] = 0; CPPAD_ASSERT_UNKNOWN( tape[0].op == BeginOp ); // initialize mapping from old variable index to new // operator and variable index for(i = 0; i < num_var; i++) { tape[i].new_op = 0; // invalid index (except for BeginOp) tape[i].new_var = num_var; // invalid index } // Erase all information in the old recording rec->free(); // initialize mapping from old VecAD index to new VecAD index CppAD::vector new_vecad_ind(num_vecad_ind); for(i = 0; i < num_vecad_ind; i++) new_vecad_ind[i] = num_vecad_ind; // invalid index j = 0; // index into the old set of indices for(i = 0; i < num_vecad_vec; i++) { // length of this VecAD size_t length = play->GetVecInd(j); if( vecad_connect[i] != not_connected ) { // Put this VecAD vector in new recording CPPAD_ASSERT_UNKNOWN(length < num_vecad_ind); new_vecad_ind[j] = rec->PutVecInd(length); for(k = 1; k <= length; k++) new_vecad_ind[j+k] = rec->PutVecInd( rec->PutPar( play->GetPar( play->GetVecInd(j+k) ) ) ); } // start of next VecAD j += length + 1; } CPPAD_ASSERT_UNKNOWN( j == num_vecad_ind ); // start playing the operations in the forward direction play->forward_start(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( user_curr == user_info.size() ); // playing forward skips BeginOp at the beginning, but not EndOp at // the end. Put BeginOp at beginning of recording CPPAD_ASSERT_UNKNOWN( op == BeginOp ); CPPAD_ASSERT_NARG_NRES(BeginOp, 1, 1); tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = rec->PutOp(BeginOp); rec->PutArg(0); // 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; user_state = user_start; while(op != EndOp) { // next op play->forward_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) ); CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) ); // determine if we should insert a conditional skip here bool skip = cskip_order_next < cskip_info.size(); skip &= op != BeginOp; skip &= op != InvOp; skip &= user_state == user_start; if( skip ) { j = cskip_info_order[cskip_order_next]; if( NumRes(op) > 0 ) skip &= cskip_info[j].max_left_right < i_var; else skip &= cskip_info[j].max_left_right <= i_var; } if( skip ) { cskip_order_next++; struct_cskip_info info = cskip_info[j]; size_t n_true = info.skip_var_true.size() + info.n_op_true; size_t n_false = info.skip_var_false.size() + info.n_op_false; skip &= n_true > 0 || n_false > 0; if( skip ) { CPPAD_ASSERT_UNKNOWN( NumRes(CSkipOp) == 0 ); size_t n_arg = 7 + n_true + n_false; // reserve space for the arguments to this operator but // delay setting them until we have all the new addresses cskip_info[j].i_arg = rec->ReserveArg(n_arg); CPPAD_ASSERT_UNKNOWN( cskip_info[j].i_arg > 0 ); rec->PutOp(CSkipOp); } } // determine if we should keep this operation in the new // operation sequence bool keep; switch( op ) { // see wish_list/Optimize/CompareChange entry. case EqpvOp: case EqvvOp: case LepvOp: case LevpOp: case LevvOp: case LtpvOp: case LtvpOp: case LtvvOp: case NepvOp: case NevvOp: keep = true; break; case PriOp: keep = false; break; case InvOp: case EndOp: keep = true; break; case StppOp: case StvpOp: case StpvOp: case StvvOp: CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 ); i = vecad[ arg[0] - 1 ]; keep = vecad_connect[i] != not_connected; break; case AddpvOp: case AddvvOp: case SubpvOp: case SubvpOp: case SubvvOp: keep = tape[i_var].connect_type != not_connected; keep &= tape[i_var].connect_type != csum_connected; break; case UserOp: case UsrapOp: case UsravOp: case UsrrpOp: case UsrrvOp: keep = true; break; default: keep = tape[i_var].connect_type != not_connected; break; } unsigned short code = 0; bool replace_hash = false; addr_t match_var; tape[i_var].match = false; if( keep ) switch( op ) { // Unary operator where operand is arg[0] case AbsOp: case AcosOp: case AcoshOp: case AsinOp: case AsinhOp: case AtanOp: case AtanhOp: case CosOp: case CoshOp: case ErfOp: case ExpOp: case Expm1Op: case LogOp: case Log1pOp: case SignOp: case SinOp: case SinhOp: case SqrtOp: case TanOp: case TanhOp: match_var = unary_match( tape , // inputs i_var , play->num_par_rec() , play->GetPar() , hash_table_var , code // outputs ); if( match_var > 0 ) { tape[i_var].match = true; tape[match_var].match = true; tape[i_var].new_var = tape[match_var].new_var; } else { replace_hash = true; new_arg[0] = tape[ arg[0] ].new_var; rec->PutArg( new_arg[0] ); tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = i = rec->PutOp(op); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < i ); if( op == ErfOp ) { // Error function is a special case // second argument is always the parameter 0 // third argument is always the parameter 2 / sqrt(pi) CPPAD_ASSERT_UNKNOWN( NumArg(ErfOp) == 3 ); rec->PutArg( rec->PutPar( Base(0) ) ); rec->PutArg( rec->PutPar( Base( 1.0 / std::sqrt( std::atan(1.0) ) ) ) ); } } break; // --------------------------------------------------- // Binary operators where // left is a variable and right is a parameter case SubvpOp: if( tape[arg[0]].connect_type == csum_connected ) { // convert to a sequence of summation operators size_pair = record_csum( tape , // inputs i_var , play->num_par_rec() , play->GetPar() , rec , csum_work ); tape[i_var].new_op = size_pair.i_op; tape[i_var].new_var = size_pair.i_var; // abort rest of this case break; } case DivvpOp: case PowvpOp: case ZmulvpOp: match_var = binary_match( tape , // inputs i_var , play->num_par_rec() , play->GetPar() , hash_table_var , code // outputs ); if( match_var > 0 ) { tape[i_var].match = true; tape[match_var].match = true; tape[i_var].new_var = tape[match_var].new_var; } else { size_pair = record_vp( tape , // inputs i_var , play->num_par_rec() , play->GetPar() , rec , op , arg ); tape[i_var].new_op = size_pair.i_op; tape[i_var].new_var = size_pair.i_var; replace_hash = true; } break; // --------------------------------------------------- // Binary operators where // left is an index and right is a variable case DisOp: match_var = binary_match( tape , // inputs i_var , play->num_par_rec() , play->GetPar() , hash_table_var , code // outputs ); if( match_var > 0 ) { tape[i_var].match = true; tape[match_var].match = true; tape[i_var].new_var = tape[match_var].new_var; } else { new_arg[0] = arg[0]; new_arg[1] = tape[ arg[1] ].new_var; rec->PutArg( new_arg[0], new_arg[1] ); tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = rec->PutOp(op); CPPAD_ASSERT_UNKNOWN( new_arg[1] < tape[i_var].new_var ); replace_hash = true; } break; // --------------------------------------------------- // Binary operators where // left is a parameter and right is a variable case SubpvOp: case AddpvOp: if( tape[arg[1]].connect_type == csum_connected ) { // convert to a sequence of summation operators size_pair = record_csum( tape , // inputs i_var , play->num_par_rec() , play->GetPar() , rec , csum_work ); tape[i_var].new_op = size_pair.i_op; tape[i_var].new_var = size_pair.i_var; // abort rest of this case break; } case DivpvOp: case MulpvOp: case PowpvOp: case ZmulpvOp: match_var = binary_match( tape , // inputs i_var , play->num_par_rec() , play->GetPar() , hash_table_var , code // outputs ); if( match_var > 0 ) { tape[i_var].match = true; tape[match_var].match = true; tape[i_var].new_var = tape[match_var].new_var; } else { size_pair = record_pv( tape , // inputs i_var , play->num_par_rec() , play->GetPar() , rec , op , arg ); tape[i_var].new_op = size_pair.i_op; tape[i_var].new_var = size_pair.i_var; replace_hash = true; } break; // --------------------------------------------------- // Binary operator where // both operators are variables case AddvvOp: case SubvvOp: if( (tape[arg[0]].connect_type == csum_connected) | (tape[arg[1]].connect_type == csum_connected) ) { // convert to a sequence of summation operators size_pair = record_csum( tape , // inputs i_var , play->num_par_rec() , play->GetPar() , rec , csum_work ); tape[i_var].new_op = size_pair.i_op; tape[i_var].new_var = size_pair.i_var; // abort rest of this case break; } case DivvvOp: case MulvvOp: case PowvvOp: case ZmulvvOp: match_var = binary_match( tape , // inputs i_var , play->num_par_rec() , play->GetPar() , hash_table_var , code // outputs ); if( match_var > 0 ) { tape[i_var].match = true; tape[match_var].match = true; tape[i_var].new_var = tape[match_var].new_var; } else { size_pair = record_vv( tape , // inputs i_var , play->num_par_rec() , play->GetPar() , rec , op , arg ); tape[i_var].new_op = size_pair.i_op; tape[i_var].new_var = size_pair.i_var; replace_hash = true; } 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(i = 2; i < 6; i++) { if( arg[1] & mask ) { new_arg[i] = tape[arg[i]].new_var; CPPAD_ASSERT_UNKNOWN( size_t(new_arg[i]) < num_var ); } else new_arg[i] = rec->PutPar( play->GetPar( 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] ); tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = rec->PutOp(op); // // The new addresses for left and right are used during // fill in the arguments for the CSkip operations. This does not // affect max_left_right which is used during this sweep. CPPAD_ASSERT_UNKNOWN( cskip_info_index > 0 ); cskip_info_index--; cskip_info[ cskip_info_index ].left = new_arg[2]; cskip_info[ cskip_info_index ].right = new_arg[3]; break; // --------------------------------------------------- // Operations with no arguments and no results case EndOp: CPPAD_ASSERT_NARG_NRES(op, 0, 0); rec->PutOp(op); break; // --------------------------------------------------- // Operations with two arguments and no results case LepvOp: case LtpvOp: case EqpvOp: case NepvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 0); new_arg[0] = rec->PutPar( play->GetPar(arg[0]) ); new_arg[1] = tape[arg[1]].new_var; rec->PutArg(new_arg[0], new_arg[1]); rec->PutOp(op); break; // case LevpOp: case LtvpOp: CPPAD_ASSERT_NARG_NRES(op, 2, 0); new_arg[0] = tape[arg[0]].new_var; new_arg[1] = rec->PutPar( play->GetPar(arg[1]) ); rec->PutArg(new_arg[0], new_arg[1]); rec->PutOp(op); break; // case LevvOp: case LtvvOp: case EqvvOp: case NevvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 0); new_arg[0] = tape[arg[0]].new_var; new_arg[1] = tape[arg[1]].new_var; rec->PutArg(new_arg[0], new_arg[1]); rec->PutOp(op); break; // --------------------------------------------------- // Operations with no arguments and one result case InvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = rec->PutOp(op); break; // --------------------------------------------------- // Operations with one argument that is a parameter case ParOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); new_arg[0] = rec->PutPar( play->GetPar(arg[0] ) ); rec->PutArg( new_arg[0] ); tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = rec->PutOp(op); break; // --------------------------------------------------- // Load using a parameter index case LdpOp: CPPAD_ASSERT_NARG_NRES(op, 3, 1); new_arg[0] = new_vecad_ind[ arg[0] ]; new_arg[1] = arg[1]; new_arg[2] = rec->num_load_op_rec(); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < num_vecad_ind ); rec->PutArg( new_arg[0], new_arg[1], new_arg[2] ); tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = rec->PutLoadOp(op); break; // --------------------------------------------------- // Load using a variable index case LdvOp: CPPAD_ASSERT_NARG_NRES(op, 3, 1); new_arg[0] = new_vecad_ind[ arg[0] ]; new_arg[1] = tape[arg[1]].new_var; new_arg[2] = rec->num_load_op_rec(); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < num_vecad_ind ); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[1]) < num_var ); rec->PutArg( new_arg[0], new_arg[1], new_arg[2] ); tape[i_var].new_var = rec->num_op_rec(); tape[i_var].new_var = rec->PutLoadOp(op); break; // --------------------------------------------------- // Store a parameter using a parameter index case StppOp: CPPAD_ASSERT_NARG_NRES(op, 3, 0); new_arg[0] = new_vecad_ind[ arg[0] ]; new_arg[1] = rec->PutPar( play->GetPar(arg[1]) ); new_arg[2] = rec->PutPar( play->GetPar(arg[2]) ); CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < num_vecad_ind ); rec->PutArg( new_arg[0], new_arg[1], new_arg[2] ); rec->PutOp(op); break; // --------------------------------------------------- // Store a parameter using a variable index case StvpOp: CPPAD_ASSERT_NARG_NRES(op, 3, 0); new_arg[0] = new_vecad_ind[ arg[0] ]; new_arg[1] = tape[arg[1]].new_var; new_arg[2] = rec->PutPar( play->GetPar(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] ); rec->PutOp(op); break; // --------------------------------------------------- // Store a variable using a parameter index case StpvOp: CPPAD_ASSERT_NARG_NRES(op, 3, 0); new_arg[0] = new_vecad_ind[ arg[0] ]; new_arg[1] = rec->PutPar( play->GetPar(arg[1]) ); new_arg[2] = tape[arg[2]].new_var; 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] ); rec->PutOp(op); break; // --------------------------------------------------- // Store a variable using a variable index case StvvOp: CPPAD_ASSERT_NARG_NRES(op, 3, 0); new_arg[0] = new_vecad_ind[ arg[0] ]; new_arg[1] = tape[arg[1]].new_var; new_arg[2] = tape[arg[2]].new_var; 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] ); rec->PutOp(op); break; // ----------------------------------------------------------- case UserOp: CPPAD_ASSERT_NARG_NRES(op, 4, 0); if( user_state == user_start ) { user_state = user_arg; CPPAD_ASSERT_UNKNOWN( user_curr > 0 ); user_curr--; user_info[user_curr].op_begin = rec->num_op_rec(); } else { user_state = user_start; user_info[user_curr].op_end = rec->num_op_rec() + 1; } // user_index, user_id, user_n, user_m if( user_info[user_curr].connect_type != not_connected ) { rec->PutArg(arg[0], arg[1], arg[2], arg[3]); rec->PutOp(UserOp); } break; case UsrapOp: CPPAD_ASSERT_NARG_NRES(op, 1, 0); if( user_info[user_curr].connect_type != not_connected ) { new_arg[0] = rec->PutPar( play->GetPar(arg[0]) ); rec->PutArg(new_arg[0]); rec->PutOp(UsrapOp); } break; case UsravOp: CPPAD_ASSERT_NARG_NRES(op, 1, 0); if( user_info[user_curr].connect_type != not_connected ) { new_arg[0] = tape[arg[0]].new_var; if( size_t(new_arg[0]) < num_var ) { rec->PutArg(new_arg[0]); rec->PutOp(UsravOp); } else { // This argument does not affect the result and // has been optimized out so use nan in its place. new_arg[0] = rec->PutPar( base_nan ); rec->PutArg(new_arg[0]); rec->PutOp(UsrapOp); } } break; case UsrrpOp: CPPAD_ASSERT_NARG_NRES(op, 1, 0); if( user_info[user_curr].connect_type != not_connected ) { new_arg[0] = rec->PutPar( play->GetPar(arg[0]) ); rec->PutArg(new_arg[0]); rec->PutOp(UsrrpOp); } break; case UsrrvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); if( user_info[user_curr].connect_type != not_connected ) { tape[i_var].new_op = rec->num_op_rec(); tape[i_var].new_var = rec->PutOp(UsrrvOp); } break; // --------------------------------------------------- // all cases should be handled above default: CPPAD_ASSERT_UNKNOWN(false); } if( replace_hash ) { // The old variable index i_var corresponds to the // new variable index tape[i_var].new_var. In addition // this is the most recent variable that has this code. hash_table_var[code] = i_var; } } // modify the dependent variable vector to new indices for(i = 0; i < dep_taddr.size(); i++ ) { CPPAD_ASSERT_UNKNOWN( size_t(tape[dep_taddr[i]].new_var) < num_var ); dep_taddr[i] = tape[ dep_taddr[i] ].new_var; } # ifndef NDEBUG size_t num_new_op = rec->num_op_rec(); for(i_var = 0; i_var < tape.size(); i_var++) CPPAD_ASSERT_UNKNOWN( tape[i_var].new_op < num_new_op ); # endif // Move skip information from user_info to cskip_info for(i = 0; i < user_info.size(); i++) { if( user_info[i].connect_type == cexp_connected && ! user_info[i].cexp_set.empty() ) { std::set::const_iterator itr = user_info[i].cexp_set.begin(); while( itr != user_info[i].cexp_set.end() ) { j = itr->index(); k = user_info[i].op_begin; while(k < user_info[i].op_end) { if( itr->compare() == true ) cskip_info[j].skip_op_false.push_back(k++); else cskip_info[j].skip_op_true.push_back(k++); } itr++; } } } // fill in the arguments for the CSkip operations CPPAD_ASSERT_UNKNOWN( cskip_order_next == cskip_info.size() ); for(i = 0; i < cskip_info.size(); i++) { struct_cskip_info info = cskip_info[i]; if( info.i_arg > 0 ) { CPPAD_ASSERT_UNKNOWN( info.n_op_true==info.skip_op_true.size() ); CPPAD_ASSERT_UNKNOWN(info.n_op_false==info.skip_op_false.size()); size_t n_true = info.skip_var_true.size() + info.skip_op_true.size(); size_t n_false = info.skip_var_false.size() + info.skip_op_false.size(); size_t i_arg = info.i_arg; rec->ReplaceArg(i_arg++, info.cop ); rec->ReplaceArg(i_arg++, info.flag ); rec->ReplaceArg(i_arg++, info.left ); rec->ReplaceArg(i_arg++, info.right ); rec->ReplaceArg(i_arg++, n_true ); rec->ReplaceArg(i_arg++, n_false ); for(j = 0; j < info.skip_var_true.size(); j++) { i_var = info.skip_var_true[j]; if( tape[i_var].match ) { // The operation for this argument has been removed, // so use an operator index that never comes up. rec->ReplaceArg(i_arg++, rec->num_op_rec()); } else { CPPAD_ASSERT_UNKNOWN( tape[i_var].new_op > 0 ); rec->ReplaceArg(i_arg++, tape[i_var].new_op ); } } for(j = 0; j < info.skip_op_true.size(); j++) { i_op = info.skip_op_true[j]; rec->ReplaceArg(i_arg++, i_op); } for(j = 0; j < info.skip_var_false.size(); j++) { i_var = info.skip_var_false[j]; if( tape[i_var].match ) { // The operation for this argument has been removed, // so use an operator index that never comes up. rec->ReplaceArg(i_arg++, rec->num_op_rec()); } else { CPPAD_ASSERT_UNKNOWN( tape[i_var].new_op > 0 ); rec->ReplaceArg(i_arg++, tape[i_var].new_op ); } } for(j = 0; j < info.skip_op_false.size(); j++) { i_op = info.skip_op_false[j]; rec->ReplaceArg(i_arg++, i_op); } rec->ReplaceArg(i_arg++, n_true + n_false); # ifndef NDEBUG size_t n_arg = 7 + n_true + n_false; CPPAD_ASSERT_UNKNOWN( info.i_arg + n_arg == i_arg ); # endif } } } } // END_CPPAD_OPTIMIZE_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< \a Base > and computations by this routine are done using type \a Base. \param options The default value for this option is the empty string. The only other possible value is "no_conditional_skip". If this option is present, no conditional skip operators will be generated. */ template void ADFun::optimize(const std::string& options) { // place to store the optimized version of the recording 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) == 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 CppAD::optimize::optimize_run(options, n, dep_taddr_, &play_, &rec); // number of variables in the recording num_var_tape_ = rec.num_var_rec(); // now replace the recording play_.get(rec); // set flag so this function knows it has been optimized has_been_optimized_ = true; // free memory allocated for sparse Jacobian calculation // (the results are no longer valid) for_jac_sparse_pack_.resize(0, 0); for_jac_sparse_set_.resize(0,0); // free old Taylor coefficient memory taylor_.free(); 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_.erase(); cskip_op_.extend( play_.num_op_rec() ); # ifndef NDEBUG if( check_zero_order ) { // zero order forward calculation using new operation sequence check = Forward(0, x); // check results Base eps = 10. * CppAD::numeric_limits::epsilon(); for(i = 0; i < m; i++) CPPAD_ASSERT_KNOWN( abs_geq( eps * max_taylor , check[i] - y[i] ) , "Error during check of f.optimize()." ); // Erase memory that this calculation was done so NDEBUG gives // same final state for this object (from users perspective) num_order_taylor_ = 0; } # endif } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/cond_op.hpp0000644000175200017650000007620212656321770016752 0ustar coincoin-web// $Id: cond_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_COND_OP_HPP # define CPPAD_COND_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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< \a Base > and computations by this routine are done using type \a Base. \param i_z is the AD variable index corresponding to the variable z. \param arg \n \a arg[0] is static cast to size_t from the enum type \verbatim enum CompareOp { CompareLt, CompareLe, CompareEq, CompareGe, CompareGt, CompareNe } \endverbatim for this operation. Note that arg[0] cannot be equal to CompareNe. \n \n \a arg[1] & 1 \n If this is zero, y_0 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 2 \n If this is zero, y_1 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 4 \n If this is zero, y_2 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 8 \n If this is zero, y_3 is a parameter. Otherwise it is a variable. \n \n \a 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 \a parameter. \param parameter For j = 0, 1, 2, 3, if y_j is a parameter, \a 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 inline 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z is the AD variable index corresponding to the variable z. \param arg \n \a arg[0] is static cast to size_t from the enum type \verbatim enum CompareOp { CompareLt, CompareLe, CompareEq, CompareGe, CompareGt, CompareNe } \endverbatim for this operation. Note that arg[0] cannot be equal to CompareNe. \n \n \a arg[1] & 1 \n If this is zero, y_0 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 2 \n If this is zero, y_1 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 4 \n If this is zero, y_2 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 8 \n If this is zero, y_3 is a parameter. Otherwise it is a variable. \n \n \a 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 \a 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 inline 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< \a Base > and computations by this routine are done using type \a Base. \param i_z is the AD variable index corresponding to the variable z. \param arg \n \a arg[0] is static cast to size_t from the enum type \verbatim enum CompareOp { CompareLt, CompareLe, CompareEq, CompareGe, CompareGt, CompareNe } \endverbatim for this operation. Note that arg[0] cannot be equal to CompareNe. \n \n \a arg[1] & 1 \n If this is zero, y_0 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 2 \n If this is zero, y_1 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 4 \n If this is zero, y_2 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 8 \n If this is zero, y_3 is a parameter. Otherwise it is a variable. \n \n \a 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 \a parameter. \param parameter For j = 0, 1, 2, 3, if y_j is a parameter, \a 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 inline 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[ 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[ 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[ 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[ 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[ arg[4] * cap_order + d]; } else y_2 = zero; if( arg[1] & 8 ) { y_3 = taylor[ 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< \a Base > and computations by this routine are done using type \a Base. \param i_z is the AD variable index corresponding to the variable z. \param arg \n \a arg[0] is static cast to size_t from the enum type \verbatim enum CompareOp { CompareLt, CompareLe, CompareEq, CompareGe, CompareGt, CompareNe } \endverbatim for this operation. Note that arg[0] cannot be equal to CompareNe. \n \n \a arg[1] & 1 \n If this is zero, y_0 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 2 \n If this is zero, y_1 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 4 \n If this is zero, y_2 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 8 \n If this is zero, y_3 is a parameter. Otherwise it is a variable. \n \n \a 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 \a parameter. \param parameter For j = 0, 1, 2, 3, if y_j is a parameter, \a 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 inline 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[ 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[ 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[ arg[4] * num_taylor_per_var + m + ell]; } else y_2 = zero; if( arg[1] & 8 ) { y_3 = taylor[ 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< \a Base > and computations by this routine are done using type \a Base. \param i_z is the AD variable index corresponding to the variable z. \param arg \n \a arg[0] is static cast to size_t from the enum type \verbatim enum CompareOp { CompareLt, CompareLe, CompareEq, CompareGe, CompareGt, CompareNe } \endverbatim for this operation. Note that arg[0] cannot be equal to CompareNe. \n \n \a arg[1] & 1 \n If this is zero, y_0 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 2 \n If this is zero, y_1 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 4 \n If this is zero, y_2 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 8 \n If this is zero, y_3 is a parameter. Otherwise it is a variable. \n \n \a 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 \a parameter. \param parameter For j = 0, 1, 2, 3, if y_j is a parameter, \a 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 \a taylor [ \a arg[2+j] * cap_order + 0 ] is the zero order Taylor coefficient corresponding to y_j. \n \b Output: \a taylor [ \a i_z * \a cap_order + 0 ] is the zero order Taylor coefficient corresponding to z. */ template inline 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[ 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[ 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[ 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[ 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< \a Base > and computations by this routine are done using type \a Base. \param i_z is the AD variable index corresponding to the variable z. \param arg \n \a arg[0] is static cast to size_t from the enum type \verbatim enum CompareOp { CompareLt, CompareLe, CompareEq, CompareGe, CompareGt, CompareNe } \endverbatim for this operation. Note that arg[0] cannot be equal to CompareNe. \n \n \a arg[1] & 1 \n If this is zero, y_0 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 2 \n If this is zero, y_1 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 4 \n If this is zero, y_2 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 8 \n If this is zero, y_3 is a parameter. Otherwise it is a variable. \n \n \a 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 \a parameter. \param parameter For j = 0, 1, 2, 3, if y_j is a parameter, \a 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 , ... , \a d, if y_j is a variable then \a taylor [ \a arg[2+j] * cap_order + k ] is the k-th order Taylor coefficient corresponding to y_j. \n \a taylor [ \a i_z * \a cap_order + k ] for k = 0 , ... , \a 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 , ... , \a d, if y_j is a variable then \a partial [ \a 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: \a partial [ \a i_z * \a cap_order + k ] for k = 0 , ... , \a d is the partial derivative of G( z , y , x , w , u , ... ) with respect to the k-th order Taylor coefficient corresponding to z. \n \b Output: For j = 0, 1, 2, 3 and k = 0 , ... , \a d, if y_j is a variable then \a partial [ \a 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 inline 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[ 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[ 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 + 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 + 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z is the AD variable index corresponding to the variable z. \param arg \n \a arg[0] is static cast to size_t from the enum type \verbatim enum CompareOp { CompareLt, CompareLe, CompareEq, CompareGe, CompareGt, CompareNe } \endverbatim for this operation. Note that arg[0] cannot be equal to CompareNe. \n \n \a arg[1] & 1 \n If this is zero, y_0 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 2 \n If this is zero, y_1 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 4 \n If this is zero, y_2 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 8 \n If this is zero, y_3 is a parameter. Otherwise it is a variable. \n \n \a 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 \a 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 inline 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 size_t k = 1; for( size_t j = 0; j < 4; j++) { if( ! ( arg[1] & k ) ) CPPAD_ASSERT_UNKNOWN( size_t(arg[2+j]) < num_par ); k *= 2; } # endif sparsity.clear(i_z); if( dependency ) { if( arg[1] & 1 ) sparsity.binary_union(i_z, i_z, arg[2], sparsity); if( arg[1] & 2 ) sparsity.binary_union(i_z, i_z, arg[3], sparsity); } if( arg[1] & 4 ) sparsity.binary_union(i_z, i_z, arg[4], sparsity); if( arg[1] & 8 ) sparsity.binary_union(i_z, i_z, arg[5], sparsity); return; } /*! 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z is the AD variable index corresponding to the variable z. \param arg \n \a arg[0] is static cast to size_t from the enum type \verbatim enum CompareOp { CompareLt, CompareLe, CompareEq, CompareGe, CompareGt, CompareNe } \endverbatim for this operation. Note that arg[0] cannot be equal to CompareNe. \n \n \a arg[1] & 1 \n If this is zero, y_0 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 2 \n If this is zero, y_1 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 4 \n If this is zero, y_2 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 8 \n If this is zero, y_3 is a parameter. Otherwise it is a variable. \n \n \a 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 \a 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 inline 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 size_t k = 1; for( size_t j = 0; j < 4; j++) { if( ! ( arg[1] & k ) ) CPPAD_ASSERT_UNKNOWN( size_t(arg[2+j]) < num_par ); k *= 2; } # endif if( dependency ) { if( arg[1] & 1 ) sparsity.binary_union(arg[2], arg[2], i_z, sparsity); if( arg[1] & 2 ) sparsity.binary_union(arg[3], arg[3], i_z, sparsity); } // -------------------------------------------------------------------- if( arg[1] & 4 ) sparsity.binary_union(arg[4], arg[4], i_z, sparsity); if( arg[1] & 8 ) sparsity.binary_union(arg[5], arg[5], i_z, sparsity); return; } /*! 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z is the AD variable index corresponding to the variable z. \param arg \n \a arg[0] is static cast to size_t from the enum type \verbatim enum CompareOp { CompareLt, CompareLe, CompareEq, CompareGe, CompareGt, CompareNe } \endverbatim for this operation. Note that arg[0] cannot be equal to CompareNe. \n \n \a arg[1] & 1 \n If this is zero, y_0 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 2 \n If this is zero, y_1 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 4 \n If this is zero, y_2 is a parameter. Otherwise it is a variable. \n \n \a arg[1] & 8 \n If this is zero, y_3 is a parameter. Otherwise it is a variable. \n \n \a 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 \a 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 \a jac_reverse[i_z] is false (true) if the Jacobian of G with respect to z is always zero (may be non-zero). \n \n \a jac_reverse[ arg[4] ] If y_2 is a variable, \a jac_reverse[ arg[4] ] is false (true) if the Jacobian with respect to y_2 is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. \n \n \a jac_reverse[ arg[5] ] If y_3 is a variable, \a jac_reverse[ arg[5] ] is false (true) if the Jacobian with respect to y_3 is always zero (may be non-zero). On input, it corresponds to the function G, and on output it corresponds to the function H. \param hes_sparsity The set with index \a i_z in \a hes_sparsity is the Hessian sparsity pattern for the function G where one of the partials is with respect to z. \n \n If y_2 is a variable, the set with index \a arg[4] in \a hes_sparsity is the Hessian sparsity pattern where one of the partials is with respect to y_2. On input, this pattern corresponds to the function G. On output, this pattern corresponds to the function H. \n \n If y_3 is a variable, the set with index \a arg[5] in \a hes_sparsity is the Hessian sparsity pattern 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 inline 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 size_t k = 1; for( size_t j = 0; j < 4; j++) { if( ! ( arg[1] & k ) ) CPPAD_ASSERT_UNKNOWN( size_t(arg[2+j]) < num_par ); k *= 2; } # endif if( arg[1] & 4 ) { hes_sparsity.binary_union(arg[4], arg[4], i_z, hes_sparsity); jac_reverse[ arg[4] ] |= jac_reverse[i_z]; } if( arg[1] & 8 ) { hes_sparsity.binary_union(arg[5], arg[5], i_z, hes_sparsity); jac_reverse[ arg[5] ] |= jac_reverse[i_z]; } return; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/acosh_op.hpp0000644000175200017650000001525512656321770017125 0ustar coincoin-web// $Id$ # ifndef CPPAD_ACOSH_OP_HPP # define CPPAD_ACOSH_OP_HPP # if CPPAD_USE_CPLUSPLUS_2011 /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file acosh_op.hpp Forward and reverse mode calculations for z = acosh(x). */ /*! Compute forward mode Taylor coefficient for result of op = AcoshOp. The C++ source code corresponding to this operation is \verbatim z = acosh(x) \endverbatim The auxillary result is \verbatim y = sqrt(x * x - 1) \endverbatim The value of y, and its derivatives, are computed along with the value and derivatives of z. \copydetails forward_unary2_op */ template inline void forward_acosh_op( size_t p , size_t q , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AcoshOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AcoshOp) == 2 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; Base* b = z - cap_order; // called y in documentation size_t k; Base uj; if( p == 0 ) { z[0] = acosh( x[0] ); uj = x[0] * x[0] - Base(1); b[0] = sqrt( uj ); p++; } for(size_t j = p; j <= q; j++) { uj = Base(0); for(k = 0; k <= j; k++) uj += x[k] * x[j-k]; b[j] = Base(0); z[j] = Base(0); for(k = 1; k < j; k++) { b[j] -= Base(k) * b[k] * b[j-k]; z[j] -= Base(k) * z[k] * b[j-k]; } b[j] /= Base(j); z[j] /= Base(j); // b[j] += uj / Base(2); z[j] += x[j]; // b[j] /= b[0]; z[j] /= b[0]; } } /*! Multiple directions forward mode Taylor coefficient for op = AcoshOp. The C++ source code corresponding to this operation is \verbatim z = acosh(x) \endverbatim The auxillary result is \verbatim y = sqrt(x * x - 1) \endverbatim The value of y, and its derivatives, are computed along with the value and derivatives of z. \copydetails forward_unary2_op_dir */ template inline void forward_acosh_op_dir( size_t q , size_t r , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AcoshOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AcoshOp) == 2 ); CPPAD_ASSERT_UNKNOWN( 0 < q ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); // Taylor coefficients corresponding to argument and result size_t num_taylor_per_var = (cap_order-1) * r + 1; Base* x = taylor + i_x * num_taylor_per_var; Base* z = taylor + i_z * num_taylor_per_var; Base* b = z - num_taylor_per_var; // called y in documentation size_t k, ell; size_t m = (q-1) * r + 1; for(ell = 0; ell < r; ell ++) { Base uq = 2.0 * x[m + ell] * x[0]; for(k = 1; k < q; k++) uq += x[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; b[m+ell] = Base(0); z[m+ell] = Base(0); for(k = 1; k < q; k++) { b[m+ell] += Base(k) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; z[m+ell] += Base(k) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; } b[m+ell] = ( uq / Base(2) - b[m+ell] / Base(q) ) / b[0]; z[m+ell] = ( x[m+ell] - z[m+ell] / Base(q) ) / b[0]; } } /*! Compute zero order forward mode Taylor coefficient for result of op = AcoshOp. The C++ source code corresponding to this operation is \verbatim z = acosh(x) \endverbatim The auxillary result is \verbatim y = sqrt( x * x - 1 ) \endverbatim The value of y is computed along with the value of z. \copydetails forward_unary2_op_0 */ template inline void forward_acosh_op_0( size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AcoshOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AcoshOp) == 2 ); CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; Base* b = z - cap_order; // called y in documentation z[0] = acosh( x[0] ); b[0] = sqrt( x[0] * x[0] - Base(1) ); } /*! Compute reverse mode partial derivatives for result of op = AcoshOp. The C++ source code corresponding to this operation is \verbatim z = acosh(x) \endverbatim The auxillary result is \verbatim y = sqrt( x * x - 1 ) \endverbatim The value of y is computed along with the value of z. \copydetails reverse_unary2_op */ template inline void reverse_acosh_op( size_t d , size_t i_z , size_t i_x , size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AcoshOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AcoshOp) == 2 ); CPPAD_ASSERT_UNKNOWN( d < cap_order ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // Taylor coefficients and partials corresponding to argument const Base* x = taylor + i_x * cap_order; Base* px = partial + i_x * nc_partial; // Taylor coefficients and partials corresponding to first result const Base* z = taylor + i_z * cap_order; Base* pz = partial + i_z * nc_partial; // Taylor coefficients and partials corresponding to auxillary result const Base* b = z - cap_order; // called y in documentation Base* pb = pz - nc_partial; Base inv_b0 = Base(1) / b[0]; // number of indices to access size_t j = d; size_t k; while(j) { // scale partials w.r.t b[j] by 1 / b[0] pb[j] = azmul(pb[j], inv_b0); // scale partials w.r.t z[j] by 1 / b[0] pz[j] = azmul(pz[j], inv_b0); // update partials w.r.t b^0 pb[0] -= azmul(pz[j], z[j]) + azmul(pb[j], b[j]); // update partial w.r.t. x^0 px[0] += azmul(pb[j], x[j]); // update partial w.r.t. x^j px[j] += pz[j] + azmul(pb[j], x[0]); // further scale partial w.r.t. z[j] by 1 / j pz[j] /= Base(j); for(k = 1; k < j; k++) { // update partials w.r.t b^(j-k) pb[j-k] -= Base(k) * azmul(pz[j], z[k]) + azmul(pb[j], b[k]); // update partials w.r.t. x^k px[k] += azmul(pb[j], x[j-k]); // update partials w.r.t. z^k pz[k] -= Base(k) * azmul(pz[j], b[j-k]); } --j; } // j == 0 case px[0] += azmul(pz[0] + azmul(pb[0], x[0]), inv_b0); } } // END_CPPAD_NAMESPACE # endif # endif cppad-20160000.1/cppad/local/color_symmetric.hpp0000644000175200017650000002316412656321770020542 0ustar coincoin-web// $Id: color_symmetric.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_COLOR_SYMMETRIC_HPP # define CPPAD_COLOR_SYMMETRIC_HPP # include /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /*! \file color_symmetric.hpp Coloring algorithm for a symmetric sparse matrix. */ // -------------------------------------------------------------------------- /*! CppAD algorithm for determining which rows of a symmetric sparse matrix can be computed together. \tparam VectorSize is a simple vector class with elements of type size_t. \tparam VectorSet is an unspecified type with the exception that it must support the operations under pattern and the following operations where p is a VectorSet object: \n VectorSet p Constructs a new vector of sets object. \n p.resize(ns, ne) resizes \c p to ns sets with elements between zero and \c ne. All of the sets are initially empty. \n p.add_element(s, e) add element \c e to set with index \c s. \param pattern [in] Is a representation of the sparsity pattern for the matrix. Note that color_symmetric does not change the values in pattern, but it is not const because its iterator facility modifies some of its internal data. \n m = pattern.n_set() \n sets m to the number of rows (and columns) in the sparse matrix. All of the row indices are less than this value. \n n = pattern.end() \n sets n to the number of columns in the sparse matrix (which must be equal to the number of rows). All of the column indices are less than this value. \n pattern.begin(i) instructs the iterator facility to start iterating over columns in the i-th row of the sparsity pattern. \n j = pattern.next_element() Sets j to the next possibly non-zero column in the row specified by the previous call to pattern.begin. If there are no more such columns, the value pattern.end() is returned. \param row [in/out] is a vector specifying which row indices to compute. \param col [in/out] is a vector, with the same size as row, that specifies which column indices to compute. \n \n Input: For each valid index \c k, the index pair (row[k], col[k]) must be present in the sparsity pattern. It may be that some entries in the sparsity pattern do not need to be computed; i.e, do not appear in the set of (row[k], col[k]) entries. \n \n Output: On output, some of row and column indices may have been swapped \code std::swap( row[k], col[k] ) \endcode So the the the color for row[k] can be used to compute entry (row[k], col[k]). \param color [out] is a vector with size m. The input value of its elements does not matter. Upon return, it is a coloring for the rows of the sparse matrix. Note that if color[i] == m, then ther is no index k for which row[k] == i (for the return value of row). \n \n Fix any (i, j) in the sparsity pattern. Suppose that there is a row index i1 with i1 != i, color[i1] == color[i] and (i1, j) is in the sparsity pattern. If follows that for all j1 with j1 != j and color[j1] == color[j], (j1, i ) is not in the sparsity pattern. \n \n This routine tries to minimize, with respect to the choice of colors, the maximum, with respect to k, of color[ row[k] ]. */ template void color_symmetric_cppad( VectorSet& pattern , CppAD::vector& row , CppAD::vector& col , CppAD::vector& color ) { size_t o1, o2, i1, i2, j1, j2, k1, c1, c2; size_t K = row.size(); size_t m = pattern.n_set(); CPPAD_ASSERT_UNKNOWN( m == pattern.end() ); CPPAD_ASSERT_UNKNOWN( color.size() == m ); CPPAD_ASSERT_UNKNOWN( col.size() == K ); // row, column pairs that appear in ( row[k], col[k] ) CppAD::vector< std::set > pair_needed(m); std::set::iterator itr1, itr2; for(k1 = 0; k1 < K; k1++) { CPPAD_ASSERT_UNKNOWN( pattern.is_element(row[k1], col[k1]) ); pair_needed[ row[k1] ].insert( col[k1] ); pair_needed[ col[k1] ].insert( row[k1] ); } // order the rows decending by number of pairs needed CppAD::vector key(m), order2row(m); for(i1 = 0; i1 < m; i1++) { CPPAD_ASSERT_UNKNOWN( pair_needed[i1].size() <= m ); key[i1] = m - pair_needed[i1].size(); } CppAD::index_sort(key, order2row); // mapping from order index to row index CppAD::vector row2order(m); for(o1 = 0; o1 < m; o1++) row2order[ order2row[o1] ] = o1; // initial coloring color.resize(m); c1 = 0; for(o1 = 0; o1 < m; o1++) { i1 = order2row[o1]; if( pair_needed[i1].empty() ) color[i1] = m; else color[i1] = c1++; } // which colors are forbidden for this row CppAD::vector forbidden(m); // must start with row zero so that we remove results computed for it for(o1 = 0; o1 < m; o1++) // for each row that appears (in order) if( color[ order2row[o1] ] < m ) { i1 = order2row[o1]; c1 = color[i1]; // initial all colors as ok for this row // (value of forbidden for c > c1 does not matter) for(c2 = 0; c2 <= c1; c2++) forbidden[c2] = false; // ----------------------------------------------------- // Forbid grouping with rows that would destroy results that are // needed for this row. itr1 = pair_needed[i1].begin(); while( itr1 != pair_needed[i1].end() ) { // entry (i1, j1) is needed for this row j1 = *itr1; // Forbid rows i2 != i1 that have non-zero sparsity at (i2, j1). // Note that this is the same as non-zero sparsity at (j1, i2) pattern.begin(j1); i2 = pattern.next_element(); while( i2 != pattern.end() ) { c2 = color[i2]; if( c2 < c1 ) forbidden[c2] = true; i2 = pattern.next_element(); } itr1++; } // ----------------------------------------------------- // Forbid grouping with rows that this row would destroy results for for(o2 = 0; o2 < o1; o2++) { i2 = order2row[o2]; c2 = color[i2]; itr2 = pair_needed[i2].begin(); while( itr2 != pair_needed[i2].end() ) { j2 = *itr2; // row i2 needs pair (i2, j2). // Forbid grouping with i1 if (i1, j2) has non-zero sparsity if( pattern.is_element(i1, j2) ) forbidden[c2] = true; itr2++; } } // pick the color with smallest index c2 = 0; while( forbidden[c2] ) { c2++; CPPAD_ASSERT_UNKNOWN( c2 <= c1 ); } color[i1] = c2; // no longer need results that are computed by this row itr1 = pair_needed[i1].begin(); while( itr1 != pair_needed[i1].end() ) { j1 = *itr1; if( row2order[j1] > o1 ) { itr2 = pair_needed[j1].find(i1); if( itr2 != pair_needed[j1].end() ) { pair_needed[j1].erase(itr2); if( pair_needed[j1].empty() ) color[j1] = m; } } itr1++; } } // determine which sparsity entries need to be reflected for(k1 = 0; k1 < row.size(); k1++) { i1 = row[k1]; j1 = col[k1]; itr1 = pair_needed[i1].find(j1); if( itr1 == pair_needed[i1].end() ) { row[k1] = j1; col[k1] = i1; # ifndef NDEBUG itr1 = pair_needed[j1].find(i1); CPPAD_ASSERT_UNKNOWN( itr1 != pair_needed[j1].end() ); # endif } } return; } // -------------------------------------------------------------------------- /*! Colpack algorithm for determining which rows of a symmetric sparse matrix can be computed together. \copydetails color_symmetric_cppad */ template void color_symmetric_colpack( VectorSet& pattern , CppAD::vector& row , CppAD::vector& col , CppAD::vector& color ) { # if ! CPPAD_HAS_COLPACK CPPAD_ASSERT_UNKNOWN(false); return; # else size_t i, j, k; size_t m = pattern.n_set(); CPPAD_ASSERT_UNKNOWN( m == pattern.end() ); CPPAD_ASSERT_UNKNOWN( row.size() == col.size() ); // Determine number of non-zero entries in each row CppAD::vector n_nonzero(m); size_t n_nonzero_total = 0; for(i = 0; i < m; i++) { n_nonzero[i] = 0; pattern.begin(i); j = pattern.next_element(); while( j != pattern.end() ) { n_nonzero[i]++; j = pattern.next_element(); } n_nonzero_total += n_nonzero[i]; } // Allocate memory and fill in Adolc sparsity pattern CppAD::vector adolc_pattern(m); CppAD::vector adolc_memory(m + n_nonzero_total); size_t i_memory = 0; for(i = 0; i < m; i++) { adolc_pattern[i] = adolc_memory.data() + i_memory; adolc_pattern[i][0] = n_nonzero[i]; pattern.begin(i); j = pattern.next_element(); k = 1; while(j != pattern.end() ) { adolc_pattern[i][k++] = j; j = pattern.next_element(); } CPPAD_ASSERT_UNKNOWN( k == 1 + n_nonzero[i] ); i_memory += k; } CPPAD_ASSERT_UNKNOWN( i_memory == m + n_nonzero_total ); // Must use an external routine for this part of the calculation because // ColPack/ColPackHeaders.h has as 'using namespace std' at global level. cppad_colpack_symmetric(color, m, adolc_pattern); // determine which sparsity entries need to be reflected size_t i1, i2, j1, j2, k1, k2; for(k1 = 0; k1 < row.size(); k1++) { i1 = row[k1]; j1 = col[k1]; bool reflect = false; for(i2 = 0; i2 < m; i2++) if( (i1 != i2) & (color[i1]==color[i2]) ) { for(k2 = 1; k2 <= adolc_pattern[i2][0]; k2++) { j2 = adolc_pattern[i2][k2]; reflect |= (j1 == j2); } } if( reflect ) { row[k1] = j1; col[k1] = i1; } } return; # endif // CPPAD_HAS_COLPACK } # endif cppad-20160000.1/cppad/local/color_general.hpp0000644000175200017650000002126012656321770020136 0ustar coincoin-web// $Id: color_general.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_COLOR_GENERAL_HPP # define CPPAD_COLOR_GENERAL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include namespace CppAD { // BEGIN_CPPAD_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 VectorSize is a simple vector class with elements of type size_t. \tparam VectorSet is an unspecified type with the exception that it must support the operations under pattern and the following operations where p is a VectorSet object: \n VectorSet p Constructs a new vector of sets object. \n p.resize(ns, ne) resizes \c p to \c ns sets with elements between zero \c ne. All of the \c ns sets are initially empty. \n p.add_element(s, e) add element \c e to set with index \c s. \param pattern [in] Is a representation of the sparsity pattern for the matrix. Note that color_general does not change the values in pattern, but it is not const because its iterator facility modifies some of its internal data. \n m = pattern.n_set() \n sets \c m to the number of rows in the sparse matrix. All of the row indices are less than this value. \n n = pattern.end() \n sets \c n to the number of columns in the sparse matrix. All of the column indices are less than this value. \n pattern.begin(i) instructs the iterator facility to start iterating over columns in the i-th row of the sparsity pattern. \n j = pattern.next_element() Sets j to the next possibly non-zero column in the row specified by the previous call to pattern.begin. If there are no more such columns, the value pattern.end() is returned. \param row [in] 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( VectorSet& pattern , const VectorSize& row , const VectorSize& col , CppAD::vector& color ) { size_t i, j, k, ell, r; 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(i = 0; i < m; i++) row_appear[i] = false; // rows and columns that appear VectorSet c2r_appear, r2c_appear; c2r_appear.resize(n, m); r2c_appear.resize(m, n); for(k = 0; k < K; k++) { CPPAD_ASSERT_UNKNOWN( pattern.is_element(row[k], col[k]) ); row_appear[ row[k] ] = true; c2r_appear.add_element(col[k], row[k]); r2c_appear.add_element(row[k], col[k]); } // for each column, which rows are non-zero and do not appear VectorSet not_appear; not_appear.resize(n, m); for(i = 0; i < m; i++) { pattern.begin(i); j = pattern.next_element(); while( j != pattern.end() ) { if( ! c2r_appear.is_element(j , i) ) not_appear.add_element(j, i); j = pattern.next_element(); } } // initial coloring color.resize(m); ell = 0; for(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(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 pattern.begin(i); j = pattern.next_element(); while( j != pattern.end() ) { // for each row that appears with this column c2r_appear.begin(j); r = c2r_appear.next_element(); while( r != c2r_appear.end() ) { // if this is not the same row, forbid its color if( (r < i) & (color[r] < m) ) forbidden[ color[r] ] = true; r = c2r_appear.next_element(); } j = pattern.next_element(); } // ----------------------------------------------------- // Forbid colors that destroy results needed for this row. // // for each column that appears with this row r2c_appear.begin(i); j = r2c_appear.next_element(); while( j != r2c_appear.end() ) { // For each row that is non-zero for this column // (the appear rows have already been checked above). not_appear.begin(j); r = not_appear.next_element(); while( r != not_appear.end() ) { // if this is not the same row, forbid its color if( (r < i) & (color[r] < m) ) forbidden[ color[r] ] = true; r = not_appear.next_element(); } j = r2c_appear.next_element(); } // 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( VectorSet& pattern , const VectorSize& row , const VectorSize& col , CppAD::vector& color ) { size_t i, j, k; 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(i = 0; i < m; i++) { n_nonzero[i] = 0; pattern.begin(i); j = pattern.next_element(); while( j != pattern.end() ) { n_nonzero[i]++; j = pattern.next_element(); } n_nonzero_total += n_nonzero[i]; } // Allocate memory and fill in Adolc sparsity pattern CppAD::vector adolc_pattern(m); CppAD::vector adolc_memory(m + n_nonzero_total); size_t i_memory = 0; for(i = 0; i < m; i++) { adolc_pattern[i] = adolc_memory.data() + i_memory; adolc_pattern[i][0] = n_nonzero[i]; pattern.begin(i); j = pattern.next_element(); k = 1; while(j != pattern.end() ) { adolc_pattern[i][k++] = j; j = pattern.next_element(); } CPPAD_ASSERT_UNKNOWN( k == 1 + n_nonzero[i] ); i_memory += k; } CPPAD_ASSERT_UNKNOWN( i_memory == m + n_nonzero_total ); // Must use an external routine for this part of the calculation because // ColPack/ColPackHeaders.h has as 'using namespace std' at global level. cppad_colpack_general(color, m, n, adolc_pattern); return; } # endif // CPPAD_HAS_COLPACK } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/checkpoint.hpp0000644000175200017650000007407312656321770017464 0ustar coincoin-web// $Id: checkpoint.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_CHECKPOINT_HPP # define CPPAD_CHECKPOINT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file checkpoint.hpp defining checkpoint functions. */ /* $begin checkpoint$$ $spell sv var cppad.hpp CppAD checkpoint checkpointing algo atom_fun const enum bool $$ $section Checkpointing Functions$$ $head Syntax$$ $codei%checkpoint<%Base%> %atom_fun%(%name%, %algo%, %ax%, %ay%, %sparsity%) %sv% = %atom_fun%.size_var() %atom_fun%.option(%option_value%) %algo%(%ax%, %ay%) %atom_fun%(%ax%, %ay%) checkpoint<%Base%>::clear()%$$ $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^n \rightarrow B^m$$. The $cref/operation sequence/glossary/Operation/Sequence/$$ representing $latex f(x)$$ cannot depend on the value of $latex x$$. $subhead Faster Recording$$ It may also reduce the time to make a recording the same function for different values of the independent variable. Note that the operation sequence for a recording that uses $latex f(x)$$ may depend on its independent variables. $head Method$$ The $code checkpoint$$ class is derived from $code atomic_base$$ and makes this easy. It implements all the $code atomic_base$$ $cref/virtual functions/atomic_base/Virtual Functions/$$ and hence its source code $code cppad/local/checkpoint.hpp$$ provides an example implementation of $cref atomic_base$$. The difference is that $code checkpoint.hpp$$ uses AD 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_base/atomic_ctor/atomic_base/$$ and hence some of its error message will refer to $code atomic_base$$. $lend $head Base$$ The type $icode Base$$ specifies the base type for AD operations. $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^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_ctor/atomic_base/sparsity/$$ in the $code atomic_base$$ constructor and must be either $codei%atomic_base<%Base%>::pack_sparsity_enum%$$, $codei%atomic_base<%Base%>::bool_sparsity_enum%$$, or $codei%atomic_base<%Base%>::set_sparsity_enum%$$. This argument is optional and its default value is unspecified. $head size_var$$ This $code size_var$$ member function return value has prototype $codei% size_t %sv% %$$ It is the $cref/size_var/seq_property/size_var/$$ for the $codei%ADFun<%Base%>%$$ object is used to store the operation sequence corresponding to $icode algo$$. $head option$$ The $code option$$ syntax can be used to set the type of sparsity pattern used by $icode atom_fun$$. This is an $codei%atomic_base<%Base%>%$$ function and its documentation can be found at $cref atomic_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 clear$$ The $code 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 $cref/available/ta_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 $icode Base$$. $subhead Restriction$$ The $code clear$$ routine cannot be called while in $cref/parallel/ta_in_parallel/$$ execution mode. $children% example/atomic/checkpoint.cpp %$$ $head Example$$ The file $cref checkpoint.cpp$$ contains an example and test of these operations. It returns true if it succeeds and false if it fails. $end */ template class checkpoint : public atomic_base { // --------------------------------------------------------------------------- private: /// same as option_enum in base class typedef typename atomic_base::option_enum option_enum; // /// AD function corresponding to this checkpoint object ADFun f_; // /// sparsity for entire Jacobian f(x)^{(1)} does not change so can cache it CPPAD_INTERNAL_SPARSE_SET jac_sparse_set_; vectorBool jac_sparse_bool_; // /// sparsity for sum_i f_i(x)^{(2)} does not change so can cache it CPPAD_INTERNAL_SPARSE_SET hes_sparse_set_; vectorBool hes_sparse_bool_; // ------------------------------------------------------------------------ option_enum sparsity(void) { return static_cast< atomic_base* >(this)->sparsity(); } // ------------------------------------------------------------------------ /// set jac_sparse_set_ void set_jac_sparse_set(void) { CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == 0 ); bool transpose = false; bool dependency = true; size_t n = f_.Domain(); size_t m = f_.Range(); // Use the choice for forward / reverse that results in smaller // size for the sparsity pattern of all variables in the tape. if( n <= m ) { CPPAD_INTERNAL_SPARSE_SET identity; identity.resize(n, n); for(size_t j = 0; j < n; j++) identity.add_element(j, j); f_.ForSparseJacCheckpoint( n, identity, transpose, dependency, jac_sparse_set_ ); f_.size_forward_set(0); } else { CPPAD_INTERNAL_SPARSE_SET identity; identity.resize(m, m); for(size_t i = 0; i < m; i++) identity.add_element(i, i); f_.RevSparseJacCheckpoint( m, identity, transpose, dependency, jac_sparse_set_ ); } CPPAD_ASSERT_UNKNOWN( f_.size_forward_set() == 0 ); CPPAD_ASSERT_UNKNOWN( f_.size_forward_bool() == 0 ); } /// set jac_sparse_bool_ void set_jac_sparse_bool(void) { CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == 0 ); bool transpose = false; bool dependency = true; size_t n = f_.Domain(); size_t m = f_.Range(); // Use the choice for forward / reverse that results in smaller // size for the sparsity pattern of all variables in the tape. if( n <= m ) { vectorBool identity(n * n); for(size_t j = 0; j < n; j++) { for(size_t i = 0; i < n; i++) identity[ i * n + j ] = (i == j); } jac_sparse_bool_ = f_.ForSparseJac( n, identity, transpose, dependency ); f_.size_forward_bool(0); } else { vectorBool identity(m * m); for(size_t j = 0; j < m; j++) { for(size_t i = 0; i < m; i++) identity[ i * m + j ] = (i == j); } jac_sparse_bool_ = f_.RevSparseJac( m, identity, transpose, dependency ); } CPPAD_ASSERT_UNKNOWN( f_.size_forward_bool() == 0 ); CPPAD_ASSERT_UNKNOWN( f_.size_forward_set() == 0 ); } // ------------------------------------------------------------------------ /// set hes_sparse_set_ void set_hes_sparse_set(void) { CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.n_set() == 0 ); size_t n = f_.Domain(); size_t m = f_.Range(); // // set version of sparsity for vector of all ones vector all_one(m); for(size_t i = 0; i < m; i++) all_one[i] = true; // set version of sparsity for n by n idendity matrix CPPAD_INTERNAL_SPARSE_SET identity; identity.resize(n, n); for(size_t j = 0; j < n; j++) identity.add_element(j, j); // compute sparsity pattern for H(x) = sum_i f_i(x)^{(2)} bool transpose = false; bool dependency = false; f_.ForSparseJacCheckpoint( n, identity, transpose, dependency, jac_sparse_set_ ); f_.RevSparseHesCheckpoint( n, all_one, transpose, hes_sparse_set_ ); CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.n_set() == n ); CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.end() == n ); // // drop the forward sparsity results from f_ f_.size_forward_set(0); } /// set hes_sparse_bool_ void set_hes_sparse_bool(void) { CPPAD_ASSERT_UNKNOWN( hes_sparse_bool_.size() == 0 ); size_t n = f_.Domain(); size_t m = f_.Range(); // // set version of sparsity for vector of all ones vectorBool all_one(m); for(size_t i = 0; i < m; i++) all_one[i] = true; // set version of sparsity for n by n idendity matrix vectorBool identity(n * n); for(size_t j = 0; j < n; j++) { for(size_t i = 0; i < n; i++) identity[ i * n + j ] = (i == j); } // compute sparsity pattern for H(x) = sum_i f_i(x)^{(2)} bool transpose = false; bool dependency = false; f_.ForSparseJac(n, identity, transpose, dependency); hes_sparse_bool_ = f_.RevSparseHes(n, all_one, transpose); CPPAD_ASSERT_UNKNOWN( hes_sparse_bool_.size() == n * n ); // // drop the forward sparsity results from f_ f_.size_forward_bool(0); CPPAD_ASSERT_UNKNOWN( f_.size_forward_bool() == 0 ); CPPAD_ASSERT_UNKNOWN( f_.size_forward_set() == 0 ); } // ------------------------------------------------------------------------ /*! Link from user_atomic to forward sparse Jacobian pack and bool \copydetails atomic_base::for_sparse_jac */ template bool for_sparse_jac( size_t q , const sparsity_type& r , sparsity_type& s ) { // during user sparsity calculations size_t m = f_.Range(); size_t n = f_.Domain(); if( jac_sparse_bool_.size() == 0 ) set_jac_sparse_bool(); if( jac_sparse_set_.n_set() != 0 ) jac_sparse_set_.resize(0, 0); CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == m * n ); CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == 0 ); CPPAD_ASSERT_UNKNOWN( r.size() == n * q ); CPPAD_ASSERT_UNKNOWN( s.size() == m * q ); // bool ok = true; for(size_t i = 0; i < m; i++) { for(size_t k = 0; k < q; k++) s[i * q + k] = false; } // sparsity for s = jac_sparse_bool_ * r for(size_t i = 0; i < m; i++) { // compute row i of the return pattern for(size_t j = 0; j < n; j++) { if( jac_sparse_bool_[ i * n + j] ) { for(size_t k = 0; k < q; k++) // s[i * q + k] |= r[j * q + k ]; s[i * q + k] = bool(s[i * q + k]) | bool(r[j * q + k]); } } } return ok; } // ------------------------------------------------------------------------ /*! Link from user_atomic to reverse sparse Jacobian pack and bool \copydetails atomic_base::rev_sparse_jac */ template bool rev_sparse_jac( size_t q , const sparsity_type& rt , sparsity_type& st ) { // during user sparsity calculations size_t m = f_.Range(); size_t n = f_.Domain(); if( jac_sparse_bool_.size() == 0 ) set_jac_sparse_bool(); if( jac_sparse_set_.n_set() != 0 ) jac_sparse_set_.resize(0, 0); CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == m * n ); CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == 0 ); CPPAD_ASSERT_UNKNOWN( rt.size() == m * q ); CPPAD_ASSERT_UNKNOWN( st.size() == n * q ); bool ok = true; // for(size_t j = 0; j < n; j++) { for(size_t k = 0; k < q; k++) st[j * q + k] = false; } // // sparsity for s = r * jac_sparse_bool_ // s^T = jac_sparse_bool_^T * r^T for(size_t i = 0; i < m; i++) { // i is the row index in r^T for(size_t k = 0; k < q; k++) { // k is column index in r^T if( rt[i * q + k] ) { // i is column index in jac_sparse_bool_^T for(size_t j = 0; j < n; j++) { if( jac_sparse_bool_[i * n + j] ) st[j * q + k ] = true; } } } } return ok; } /*! Link from user_atomic to reverse sparse Hessian bools \copydetails atomic_base::rev_sparse_hes */ template bool rev_sparse_hes( const vector& vx , const vector& s , vector& t , size_t q , const sparsity_type& r , const sparsity_type& u , sparsity_type& v ) { size_t n = f_.Domain(); size_t m = f_.Range(); CPPAD_ASSERT_UNKNOWN( vx.size() == n ); CPPAD_ASSERT_UNKNOWN( s.size() == m ); CPPAD_ASSERT_UNKNOWN( t.size() == n ); CPPAD_ASSERT_UNKNOWN( r.size() == n * q ); CPPAD_ASSERT_UNKNOWN( u.size() == m * q ); CPPAD_ASSERT_UNKNOWN( v.size() == n * q ); // bool ok = true; // make sure hes_sparse_bool_ has been set if( hes_sparse_bool_.size() == 0 ) set_hes_sparse_bool(); if( hes_sparse_set_.n_set() != 0 ) hes_sparse_set_.resize(0, 0); CPPAD_ASSERT_UNKNOWN( hes_sparse_bool_.size() == n * n ); CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.n_set() == 0 ); // compute sparsity pattern for T(x) = S(x) * f'(x) t = f_.RevSparseJac(1, s); # ifndef NDEBUG for(size_t j = 0; j < n; j++) CPPAD_ASSERT_UNKNOWN( vx[j] || ! t[j] ) # endif // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R // U(x) = g''(y) * f'(x) * R // S(x) = g'(y) // compute sparsity pattern for A(x) = f'(x)^T * U(x) bool transpose = true; sparsity_type a(n * q); a = f_.RevSparseJac(q, u, transpose); // Need sparsity pattern for H(x) = (S(x) * f(x))''(x) * R, // but use less efficient sparsity for f(x)''(x) * R so that // hes_sparse_set_ can be used every time this is needed. for(size_t i = 0; i < n; i++) { for(size_t k = 0; k < q; k++) v[i * q + k] = false; for(size_t j = 0; j < n; j++) { if( hes_sparse_bool_[i * n + j] ) { for(size_t k = 0; k < q; k++) // v[i * q + k] |= r[ j * q + k ]; v[i * q + k] = bool(v[i*q + k]) | bool(r[j*q + k]); } } } // compute sparsity pattern for V(x) = A(x) + H(x) for(size_t i = 0; i < n; i++) { for(size_t k = 0; k < q; k++) // v[ i * q + k ] |= a[ i * q + k]; v[ i * q + k ] = bool(v[ i * q + k]) | bool(a[ i * q + k]); } return ok; } public: // ------------------------------------------------------------------------ /*! Constructor of a checkpoint object \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. */ template checkpoint( const char* name , Algo& algo , const ADVector& ax , ADVector& ay , option_enum sparsity = atomic_base::pack_sparsity_enum ) : atomic_base(name, sparsity) { CheckSimpleVector< CppAD::AD , ADVector>(); // make a copy of ax because Independent modifies AD information ADVector x_tmp(ax); // delcare x_tmp as the independent variables Independent(x_tmp); // record mapping from x_tmp to ay algo(x_tmp, ay); // create function f_ : x -> y f_.Dependent(ay); // suppress checking for nan in f_ results // (see optimize documentation for atomic functions) f_.check_for_nan(false); // now optimize (we expect to use this function many times). f_.optimize(); // now disable checking of comparison opertaions // 2DO: add a debugging mode that checks for changes and aborts f_.compare_change_count(0); } // ------------------------------------------------------------------------ /*! Implement the user call to atom_fun.size_var(). */ size_t size_var(void) { return f_.size_var(); } // ------------------------------------------------------------------------ /*! Implement the user call to 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 ) { size_t n = f_.Domain(); size_t m = f_.Range(); // CPPAD_ASSERT_UNKNOWN( f_.size_var() > 0 ); CPPAD_ASSERT_UNKNOWN( tx.size() % (q+1) == 0 ); CPPAD_ASSERT_UNKNOWN( ty.size() % (q+1) == 0 ); CPPAD_ASSERT_UNKNOWN( n == tx.size() / (q+1) ); CPPAD_ASSERT_UNKNOWN( m == ty.size() / (q+1) ); bool ok = true; // if( vx.size() == 0 ) { // during user forward mode if( jac_sparse_set_.n_set() != 0 ) jac_sparse_set_.resize(0,0); if( jac_sparse_bool_.size() != 0 ) jac_sparse_bool_.clear(); // if( hes_sparse_set_.n_set() != 0 ) hes_sparse_set_.resize(0,0); if( hes_sparse_bool_.size() != 0 ) hes_sparse_bool_.clear(); } if( vx.size() > 0 ) { // need Jacobian sparsity pattern to determine variable relation // during user recording using checkpoint functions if( sparsity() == atomic_base::set_sparsity_enum ) { if( jac_sparse_set_.n_set() == 0 ) set_jac_sparse_set(); CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == m ); CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.end() == n ); // for(size_t i = 0; i < m; i++) { vy[i] = false; jac_sparse_set_.begin(i); size_t j = jac_sparse_set_.next_element(); while(j < n ) { // y[i] depends on the value of x[j] // cast avoid Microsoft warning (should not be needed) vy[i] |= static_cast( vx[j] ); j = jac_sparse_set_.next_element(); } } } else { if( jac_sparse_set_.n_set() != 0 ) jac_sparse_set_.resize(0, 0); if( jac_sparse_bool_.size() == 0 ) set_jac_sparse_bool(); CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == 0 ); CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == m * n ); // for(size_t i = 0; i < m; i++) { vy[i] = false; for(size_t j = 0; j < n; j++) { if( jac_sparse_bool_[ i * n + j ] ) { // y[i] depends on the value of x[j] // cast avoid Microsoft warning vy[i] |= static_cast( vx[j] ); } } } } } ty = 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; f_.capacity_order(c, r); return ok; } // ------------------------------------------------------------------------ /*! Link from user_atomic to reverse mode \copydetails atomic_base::reverse */ virtual bool reverse( size_t q , const vector& tx , const vector& ty , vector& px , const vector& py ) { size_t n = f_.Domain(); size_t m = f_.Range(); CPPAD_ASSERT_UNKNOWN( n == tx.size() / (q+1) ); CPPAD_ASSERT_UNKNOWN( m == ty.size() / (q+1) ); CPPAD_ASSERT_UNKNOWN( f_.size_var() > 0 ); CPPAD_ASSERT_UNKNOWN( tx.size() % (q+1) == 0 ); CPPAD_ASSERT_UNKNOWN( ty.size() % (q+1) == 0 ); bool ok = true; // put proper forward mode coefficients in f_ # ifdef NDEBUG f_.Forward(q, tx); # else CPPAD_ASSERT_UNKNOWN( px.size() == n * (q+1) ); CPPAD_ASSERT_UNKNOWN( py.size() == m * (q+1) ); size_t i, j, k; // vector check_ty = 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 = 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; f_.capacity_order(c, r); return ok; } // ------------------------------------------------------------------------ /*! 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 ) { return for_sparse_jac< vectorBool >(q, r, s); } /*! Link from user_atomic to forward sparse Jacobian bool \copydetails atomic_base::for_sparse_jac */ virtual bool for_sparse_jac( size_t q , const vector& r , vector& s ) { return for_sparse_jac< vector >(q, r, s); } /*! Link from user_atomic to forward sparse Jacobian sets \copydetails atomic_base::for_sparse_jac */ virtual bool for_sparse_jac( size_t q , const vector< std::set >& r , vector< std::set >& s ) { // during user sparsity calculations size_t m = f_.Range(); size_t n = f_.Domain(); if( jac_sparse_bool_.size() != 0 ) jac_sparse_bool_.clear(); if( jac_sparse_set_.n_set() == 0 ) set_jac_sparse_set(); CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == 0 ); CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == m ); CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.end() == n ); CPPAD_ASSERT_UNKNOWN( r.size() == n ); CPPAD_ASSERT_UNKNOWN( s.size() == m ); bool ok = true; 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 jac_sparse_set_.begin(i); size_t j = jac_sparse_set_.next_element(); while(j < n ) { std::set::const_iterator itr_j; const std::set& r_j( r[j] ); for(itr_j = r_j.begin(); itr_j != r_j.end(); itr_j++) { size_t k = *itr_j; CPPAD_ASSERT_UNKNOWN( k < q ); s[i].insert(k); } j = jac_sparse_set_.next_element(); } } return ok; } // ------------------------------------------------------------------------ /*! Link from user_atomic to reverse sparse Jacobian pack \copydetails atomic_base::rev_sparse_jac */ virtual bool rev_sparse_jac( size_t q , const vectorBool& rt , vectorBool& st ) { return rev_sparse_jac< vectorBool >(q, rt, st); } /*! 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 ) { return rev_sparse_jac< vector >(q, rt, st); } /*! 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 ) { // during user sparsity calculations size_t m = f_.Range(); size_t n = f_.Domain(); if( jac_sparse_bool_.size() != 0 ) jac_sparse_bool_.clear(); if( jac_sparse_set_.n_set() == 0 ) set_jac_sparse_set(); CPPAD_ASSERT_UNKNOWN( jac_sparse_bool_.size() == 0 ); CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.n_set() == m ); CPPAD_ASSERT_UNKNOWN( jac_sparse_set_.end() == n ); CPPAD_ASSERT_UNKNOWN( rt.size() == m ); CPPAD_ASSERT_UNKNOWN( st.size() == n ); // bool ok = true; // for(size_t j = 0; j < n; j++) st[j].clear(); // // sparsity for s = r * jac_sparse_set_ // s^T = jac_sparse_set_^T * r^T for(size_t i = 0; i < m; i++) { // i is the row index in r^T std::set::const_iterator itr_i; const std::set& r_i( rt[i] ); for(itr_i = r_i.begin(); itr_i != r_i.end(); itr_i++) { // k is the column index in r^T size_t k = *itr_i; CPPAD_ASSERT_UNKNOWN( k < q ); // // i is column index in jac_sparse_set^T jac_sparse_set_.begin(i); size_t j = jac_sparse_set_.next_element(); while( j < n ) { // j is row index in jac_sparse_set^T st[j].insert(k); j = jac_sparse_set_.next_element(); } } } return ok; } // ------------------------------------------------------------------------ /*! 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 ) { return rev_sparse_hes< vectorBool >(vx, s, t, q, r, u, v); } /*! 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 ) { return rev_sparse_hes< vector >(vx, s, t, q, r, u, v); } /*! Link from user_atomic to reverse sparse Hessian sets \copydetails atomic_base::rev_sparse_hes */ virtual bool rev_sparse_hes( const vector& vx , const vector& s , vector& t , size_t q , const vector< std::set >& r , const vector< std::set >& u , vector< std::set >& v ) { size_t n = f_.Domain(); size_t m = f_.Range(); CPPAD_ASSERT_UNKNOWN( vx.size() == n ); CPPAD_ASSERT_UNKNOWN( s.size() == m ); CPPAD_ASSERT_UNKNOWN( t.size() == n ); CPPAD_ASSERT_UNKNOWN( r.size() == n ); CPPAD_ASSERT_UNKNOWN( u.size() == m ); CPPAD_ASSERT_UNKNOWN( v.size() == n ); // bool ok = true; // make sure hes_sparse_set_ has been set if( hes_sparse_bool_.size() != 0 ) hes_sparse_bool_.clear(); if( hes_sparse_set_.n_set() == 0 ) set_hes_sparse_set(); CPPAD_ASSERT_UNKNOWN( hes_sparse_bool_.size() == 0 ); CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.n_set() == n ); CPPAD_ASSERT_UNKNOWN( hes_sparse_set_.end() == n ); // compute sparsity pattern for T(x) = S(x) * f'(x) t = f_.RevSparseJac(1, s); # ifndef NDEBUG for(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 = 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(); hes_sparse_set_.begin(i); size_t j = hes_sparse_set_.next_element(); while( j < n ) { std::set::const_iterator itr_j; const std::set& r_j( r[j] ); for(itr_j = r_j.begin(); itr_j != r_j.end(); itr_j++) { size_t k = *itr_j; v[i].insert(k); } j = hes_sparse_set_.next_element(); } } // compute sparsity pattern for V(x) = A(x) + H(x) 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 cppad-20160000.1/cppad/local/arithmetic.hpp0000644000175200017650000000233312656321770017454 0ustar coincoin-web// $Id: arithmetic.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ARITHMETIC_HPP # define CPPAD_ARITHMETIC_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- $begin Arithmetic$$ $spell Op const $$ $section AD Arithmetic Operators and Computed Assignments$$ $childtable% cppad/local/unary_plus.hpp% cppad/local/unary_minus.hpp% cppad/local/ad_binary.hpp% cppad/local/compute_assign.hpp %$$ $end ------------------------------------------------------------------------------- */ # include # include # include # include # endif cppad-20160000.1/cppad/local/sparse_binary_op.hpp0000644000175200017650000002147412656321770020671 0ustar coincoin-web// $Id: sparse_binary_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_BINARY_OP_HPP # define CPPAD_SPARSE_BINARY_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z variable index corresponding to the result for this operation; i.e., z. \param arg \a 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 \a arg[0] in \a sparsity is the sparsity bit pattern for x. This identifies which of the independent variables the variable x depends on. \n \n \b Input: The set with index \a arg[1] in \a sparsity is the sparsity bit pattern for y. This identifies which of the independent variables the variable y depends on. \n \n \b Output: The set with index \a i_z in \a sparsity is the sparsity bit pattern for z. This identifies which of the independent variables the variable z depends on. \par Checked Assertions: \li \a arg[0] < \a i_z \li \a arg[1] < \a i_z */ template inline 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, arg[0], 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 \c sparse_pack, \c sparse_set, or \c sparse_list. \param i_z variable index corresponding to the result for this operation; i.e., z. \param arg \a 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 \a i_z in \a sparsity is the sparsity pattern for z corresponding ot the function G. \n \n The set with index \a arg[0] in \a sparsity is the sparsity pattern for x. On input, it corresponds to the function G, and on output it corresponds to H. \n \n The set with index \a arg[1] in \a sparsity 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 \a arg[0] < \a i_z \li \a arg[1] < \a i_z */ template inline void reverse_sparse_jacobian_binary_op( size_t i_z , const addr_t* arg , Vector_set& sparsity ) { // check assumptions CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); sparsity.binary_union(arg[0], arg[0], i_z, sparsity); sparsity.binary_union(arg[1], 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 reverse_sparse_hessian_binary_op */ template inline void reverse_sparse_hessian_addsub_op( size_t i_z , const addr_t* arg , bool* jac_reverse , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) { // check assumptions CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); rev_hes_sparsity.binary_union(arg[0], arg[0], i_z, rev_hes_sparsity); rev_hes_sparsity.binary_union(arg[1], arg[1], i_z, rev_hes_sparsity); jac_reverse[arg[0]] |= jac_reverse[i_z]; jac_reverse[arg[1]] |= jac_reverse[i_z]; 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 reverse_sparse_hessian_binary_op */ template inline void reverse_sparse_hessian_mul_op( size_t i_z , const addr_t* arg , bool* jac_reverse , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) { // check assumptions CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); rev_hes_sparsity.binary_union(arg[0], arg[0], i_z, rev_hes_sparsity); rev_hes_sparsity.binary_union(arg[1], arg[1], i_z, rev_hes_sparsity); if( jac_reverse[i_z] ) { rev_hes_sparsity.binary_union( arg[0], arg[0], arg[1], for_jac_sparsity); rev_hes_sparsity.binary_union( arg[1], arg[1], arg[0], for_jac_sparsity); } jac_reverse[arg[0]] |= jac_reverse[i_z]; jac_reverse[arg[1]] |= jac_reverse[i_z]; return; } /*! Reverse mode Hessian sparsity pattern for division operator. The C++ source code corresponding to a unary operation has the form \verbatim z = x / y \endverbatim where x and y are variables. \copydetails reverse_sparse_hessian_binary_op */ template inline void reverse_sparse_hessian_div_op( size_t i_z , const addr_t* arg , bool* jac_reverse , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) { // check assumptions CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); rev_hes_sparsity.binary_union(arg[0], arg[0], i_z, rev_hes_sparsity); rev_hes_sparsity.binary_union(arg[1], arg[1], i_z, rev_hes_sparsity); if( jac_reverse[i_z] ) { rev_hes_sparsity.binary_union( arg[0], arg[0], arg[1], for_jac_sparsity); rev_hes_sparsity.binary_union( arg[1], arg[1], arg[0], for_jac_sparsity); rev_hes_sparsity.binary_union( arg[1], arg[1], arg[1], for_jac_sparsity); } jac_reverse[arg[0]] |= jac_reverse[i_z]; jac_reverse[arg[1]] |= jac_reverse[i_z]; return; } /*! Reverse mode Hessian sparsity pattern for power function. 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 reverse_sparse_hessian_binary_op */ template inline void reverse_sparse_hessian_pow_op( size_t i_z , const addr_t* arg , bool* jac_reverse , Vector_set& for_jac_sparsity , Vector_set& rev_hes_sparsity ) { // check assumptions CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); rev_hes_sparsity.binary_union(arg[0], arg[0], i_z, rev_hes_sparsity); rev_hes_sparsity.binary_union(arg[1], arg[1], i_z, rev_hes_sparsity); if( jac_reverse[i_z] ) { rev_hes_sparsity.binary_union( arg[0], arg[0], arg[0], for_jac_sparsity); rev_hes_sparsity.binary_union( arg[0], arg[0], arg[1], for_jac_sparsity); rev_hes_sparsity.binary_union( arg[1], arg[1], arg[0], for_jac_sparsity); rev_hes_sparsity.binary_union( arg[1], arg[1], 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]] |= jac_reverse[i_z]; jac_reverse[arg[1]] |= jac_reverse[i_z]; return; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/discrete_op.hpp0000644000175200017650000000664612656321770017636 0ustar coincoin-web// $Id: discrete_op.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_DISCRETE_OP_HPP # define CPPAD_DISCRETE_OP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file 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< \a Base > and computations by this routine are done using type \a 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 \a taylor corresponding to z. \param arg \a arg[0] \n is the index, in the order of the discrete functions defined by the user, for this discrete function. \n \n \a arg[1] variable index corresponding to the argument for this operator; i.e. the row index in \a 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 inline 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 + arg[1] * num_taylor_per_var; Base* z = taylor + i_z * num_taylor_per_var; if( p == 0 ) { z[0] = discrete::eval(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); } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/base_complex.hpp0000644000175200017650000003010112656321770017756 0ustar coincoin-web// $Id: base_complex.hpp 3768 2015-12-28 18:58:35Z bradbell $ # ifndef CPPAD_BASE_COMPLEX_HPP # define CPPAD_BASE_COMPLEX_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include // 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/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. It returns true if it succeeds and false otherwise. $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/$$ $codep */ # 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 $codep */ 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 $codep */ 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. $codep */ 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. $codep */ namespace CppAD { inline bool IdenticalPar(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 IdenticalEqualPar( const std::complex &x, const std::complex &y) { return (x == y); } } /* $$ $head Ordered$$ Complex types do not support comparison operators, $codep */ # 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: $codep */ namespace CppAD { inline int Integer(const std::complex &x) { return static_cast( x.real() ); } } /* $$ $head azmul$$ $codep */ 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. $codep */ 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 >$$. $codep */ 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 >$$. $codep */ # 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(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 >$$: $codep */ 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$$: $codep */ namespace CppAD { CPPAD_NUMERIC_LIMITS(double, std::complex) } /*$$ $head to_string$$ The following defines the function CppAD $cref to_string$$ for the type $code std::complex$$: $codep */ namespace CppAD { CPPAD_TO_STRING(std::complex) } /* $$ $end */ # 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 IdenticalPar(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 IdenticalEqualPar( 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 cppad-20160000.1/cppad/local/pod_vector.hpp0000644000175200017650000002311712656321770017472 0ustar coincoin-web// $Id: pod_vector.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_POD_VECTOR_HPP # define CPPAD_POD_VECTOR_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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 CPPAD_CSTDINT_HAS_8_TO_64 # include # endif # include # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file pod_vector.hpp File used to define pod_vector class */ /* A list of which Types pod_vector consideres to be plain old data */ /// default value is false template inline bool is_pod(void) { return false; } /// system pod types so far: template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } # if CPPAD_CSTDINT_HAS_8_TO_64 template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } // template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } # else // CPPAD_CSTDINT_HAS_8_TO_64 template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } // template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } template <> inline bool is_pod(void) { return true; } # if CPPAD_SIZE_T_NOT_UNSIGNED_INT template <> inline bool is_pod(void) { return true; } # endif # endif // CPPAD_CSTDINT_HAS_8_TO_64 /// CppAD pod types so far: template <> inline bool is_pod(void) { return true; } // --------------------------------------------------------------------------- /*! A vector class with Type element that does not use element constructors or destructors when Type is Plain Old Data (pod). */ template class pod_vector { private: /// maximum number of elements that should ever be in this vector size_t max_length_; /// number of elements currently in this vector size_t length_; /// maximum number of Type elements current allocation can hold size_t capacity_; /// 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(const pod_vector& ) { CPPAD_ASSERT_UNKNOWN(false); } public: /// Constructors set capacity, length, and data to zero. /// /// \param max_length /// value for maximum number of elements in this vector. inline pod_vector( size_t max_length = std::numeric_limits::max() ) : max_length_(max_length), length_(0), capacity_(0), data_(CPPAD_NULL) { } // ---------------------------------------------------------------------- /// Destructor: returns allocated memory to \c thread_alloc; /// see \c extend. If this is not plain old data, /// the destructor for each element is called. ~pod_vector(void) { if( capacity_ > 0 ) { void* v_ptr = reinterpret_cast( data_ ); if( ! is_pod() ) { // call destructor for each element size_t i; for(i = 0; i < capacity_; i++) (data_ + i)->~Type(); } thread_alloc::return_memory(v_ptr); } } // ---------------------------------------------------------------------- /// current number of elements in this vector. inline size_t size(void) const { return length_; } /// current capacity (amount of allocated storage) for this vector. inline size_t capacity(void) const { return capacity_; } /// current data pointer, no longer valid after any of the following: /// extend, erase, operator=, and ~pod_vector. /// Take extreem care when using this function. inline Type* data(void) { return data_; } /// const version of \c data pointer inline const Type* data(void) const { return data_; } // ---------------------------------------------------------------------- /*! Increase the number of elements the end of this vector. \param n is the number of elements to add to end of this vector. \return is the number of elements in the vector before \c extend was extended. - If \c Type is plain old data, new elements are not initialized; i.e., their constructor is not called. Otherwise, the constructor is called for each new element. - This is the only routine that allocates memory for \c pod_vector. and it uses thread_alloc for this allocation, hence this determines which thread corresponds to this vector (when in parallel mode). - If the resulting length of the vector would be more than \c max_length_, and \c NDEBUG is not defined, a CPPAD_ASSERT is generated. */ inline size_t extend(size_t n) { size_t old_length = length_; length_ += n; CPPAD_ASSERT_KNOWN( length_ <= max_length_ , "pod_vector.hpp: attempt to create to large a vector.\n" "If Type is CPPAD_TYPE_ADDR_TYPE, tape is too long for Type." ); // check if we can use current memory if( capacity_ >= length_ ) 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); CPPAD_ASSERT_UNKNOWN( length_ <= capacity_ ); size_t i; if( ! is_pod() ) { // call constructor for each new element for(i = 0; i < capacity_; i++) new(data_ + i) Type(); } // copy old data to new data for(i = 0; i < old_length; i++) data_[i] = old_data[i]; // return old memory to available pool if( old_capacity > 0 ) { v_ptr = reinterpret_cast( old_data ); if( ! is_pod() ) { for(i = 0; i < old_capacity; i++) (old_data + i)->~Type(); } thread_alloc::return_memory(v_ptr); } // return value for extend(n) is the old length return old_length; } // ---------------------------------------------------------------------- /// 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]; } // ---------------------------------------------------------------------- /// 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]; } // ---------------------------------------------------------------------- /*! Remove all the elements from this vector but leave the capacity and data pointer as is. */ void erase(void) { length_ = 0; return; } // ---------------------------------------------------------------------- /*! Remove all the elements from this vector and delete its memory. */ void free(void) { if( capacity_ > 0 ) { void* v_ptr = reinterpret_cast( data_ ); if( ! is_pod() ) { // call destructor for each element size_t i; for(i = 0; i < capacity_; i++) (data_ + i)->~Type(); } thread_alloc::return_memory(v_ptr); } data_ = CPPAD_NULL; capacity_ = 0; length_ = 0; } /// vector assignment operator /// If the resulting length of the vector would be more than /// \c max_length_, and \c NDEBUG is not defined, /// a CPPAD_ASSERT is generated. void operator=( /// right hand size of the assingment operation const pod_vector& x ) { size_t i; if( x.length_ <= capacity_ ) { // use existing allocation for this vector length_ = x.length_; CPPAD_ASSERT_KNOWN( length_ <= max_length_ , "pod_vector.hpp: attempt to create to large a vector.\n" "If Type is CPPAD_TYPE_ADDR_TYPE, tape long for Type." ); } else { // free old memory and get new memory of sufficient length if( capacity_ > 0 ) { void* v_ptr = reinterpret_cast( data_ ); if( ! is_pod() ) { // call destructor for each element for(i = 0; i < capacity_; i++) (data_ + i)->~Type(); } thread_alloc::return_memory(v_ptr); } length_ = capacity_ = 0; extend( x.length_ ); } CPPAD_ASSERT_UNKNOWN( length_ == x.length_ ); for(i = 0; i < length_; i++) { data_[i] = x.data_[i]; } } /*! Swap all properties of this vector with another. \param other is the other vector that we are swapping this vector with. */ void swap(pod_vector& other) { std::swap(capacity_, other.capacity_); std::swap(length_, other.length_); std::swap(data_, other.data_); } }; } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/sparse_jacobian.hpp0000644000175200017650000007517012656321770020457 0ustar coincoin-web// $Id: sparse_jacobian.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_JACOBIAN_HPP # define CPPAD_SPARSE_JACOBIAN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ // 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: Easy Driver$$ $mindex SparseJacobian$$ $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 %VectorBase%& %x% %$$ (see $cref/VectorBase/sparse_jacobian/VectorBase/$$ 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 %VectorSet%& %p% %$$ (see $cref/VectorSet/sparse_jacobian/VectorSet/$$ 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 %VectorSize%& %row% const %VectorSize%& %col% %$$ (see $cref/VectorSize/sparse_jacobian/VectorSize/$$ 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% %VectorBase%& %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 $codep% 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 VectorBase$$ The type $icode VectorBase$$ 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 VectorSet$$ The type $icode VectorSet$$ 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 VectorSet$$ 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 VectorSize$$ The type $icode VectorSize$$ 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_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 VectorBase is a simple vector class with elements of type \a Base. \tparam VectorSet is either \c sparse_pack, \c sparse_set or \c sparse_list. \tparam VectorSize is a simple vector class with elements of type \c 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 \c 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 \c p_transpose, but is not \c 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 \c row. \param jac [out] is the vector of Jacobian values. We use \c K to denote the size of \c 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 \c SparseJacobainFor. If the sparsity pattern, \c row vector, or \c col vectors are not the same between calls to \c SparseJacobianFor, \c work.clear() must be called to reinitialize \c 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 VectorBase& x , VectorSet& p_transpose , const VectorSize& row , const VectorSize& col , VectorBase& 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 VectorBase 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" ) color_general_cppad(p_transpose, col, row, color); else if( work.color_method == "colpack" ) { # if CPPAD_HAS_COLPACK 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 VectorSize 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 VectorBase 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); VectorBase 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 VectorBase is a simple vector class with elements of type \a Base. \tparam VectorSet is either \c sparse_pack, \c sparse_set or \c sparse_list. \tparam VectorSize is a simple vector class with elements of type \c 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 \c 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 \c p, but is not \c 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 \c row. \param jac [out] is the vector of Jacobian values. It must have the same size as \c row. The return value jac[k] is the partial of the row[k] range component of the function with respect the the col[k] domain component of its argument. \param work work.color_method is an input. The rest of This structure contains information that is computed by \c SparseJacobainRev. If the sparsity pattern, \c row vector, or \c col vectors are not the same between calls to \c SparseJacobianRev, \c work.clear() must be called to reinitialize \c 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 VectorBase& x , VectorSet& p , const VectorSize& row , const VectorSize& col , VectorBase& 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 VectorBase 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" ) color_general_cppad(p, row, col, color); else if( work.color_method == "colpack" ) { # if CPPAD_HAS_COLPACK 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 VectorSize 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 VectorBase w(m); // location for return values from Reverse VectorBase 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 VectorBase is a simple vector class with elements of type \a Base. \tparam VectorSet is a simple vector class with elements of type \c bool or \c std::set. \tparam VectorSize is a simple vector class with elements of type \c 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 \c row. \param jac [out] is the vector of Jacobian values. It must have the same size as \c row. The return value jac[k] is the partial of the row[k] range component of the function with respect the the col[k] domain component of its argument. \param work [in,out] this structure contains information that depends on the function object, sparsity pattern, \c row vector, and \c col vector. If they are not the same between calls to \c SparseJacobianForward, \c 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 VectorBase& x , const VectorSet& p , const VectorSize& row , const VectorSize& col , VectorBase& 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 VectorSet::value_type Set_type; typedef typename internal_sparsity::pattern_type Pattern_type; Pattern_type s_transpose; if( work.color.size() == 0 ) { bool transpose = true; sparsity_user2internal(s_transpose, p, m, n, transpose); } 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 VectorBase is a simple vector class with elements of type \a Base. \tparam VectorSet is a simple vector class with elements of type \c bool or \c std::set. \tparam VectorSize is a simple vector class with elements of type \c 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 \c row. \param jac [out] is the vector of Jacobian values. It must have the same size as \c row. The return value jac[k] is the partial of the row[k] range component of the function with respect the the col[k] domain component of its argument. \param work [in,out] this structure contains information that depends on the function object, sparsity pattern, \c row vector, and \c col vector. If they are not the same between calls to \c SparseJacobianReverse, \c 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 VectorBase& x , const VectorSet& p , const VectorSize& row , const VectorSize& col , VectorBase& 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 VectorSet::value_type Set_type; typedef typename internal_sparsity::pattern_type Pattern_type; Pattern_type s; if( work.color.size() == 0 ) { bool transpose = false; sparsity_user2internal(s, p, m, n, transpose); } 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 VectorBase is a simple vector class with elements of type \a Base. \tparam VectorSet is a simple vector class with elements of type \c bool or \c 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 \c m * n containing the Jacobian at the specified point (in row major order). */ template template VectorBase ADFun::SparseJacobian( const VectorBase& x, const VectorSet& p ) { size_t i, j, k; size_t m = Range(); size_t n = Domain(); VectorBase jac(m * n); CPPAD_ASSERT_KNOWN( size_t(x.size()) == n, "SparseJacobian: size of x not equal domain size for f." ); CheckSimpleVector(); typedef typename VectorSet::value_type Set_type; typedef typename 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; sparsity_user2internal(s_transpose, p, m, n, transpose); k = 0; for(j = 0; j < n; j++) { s_transpose.begin(j); i = s_transpose.next_element(); while( i != s_transpose.end() ) { row.push_back(i); col.push_back(j); k++; i = s_transpose.next_element(); } } size_t K = k; VectorBase J(K); // now we have folded this into the following case SparseJacobianFor(x, s_transpose, row, col, J, work); // 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; sparsity_user2internal(s, p, m, n, transpose); k = 0; for(i = 0; i < m; i++) { s.begin(i); j = s.next_element(); while( j != s.end() ) { row.push_back(i); col.push_back(j); k++; j = s.next_element(); } } size_t K = k; VectorBase 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 VectorBase is a simple vector class with elements of the \a Base. \param x [in] is a vector specifing the point at which to compute the Jacobian. \return Will be a vector of size \c m * n containing the Jacobian at the specified point (in row major order). */ template template VectorBase ADFun::SparseJacobian( const VectorBase& x ) { typedef CppAD::vectorBool VectorBool; size_t m = Range(); size_t n = Domain(); // sparsity pattern for Jacobian VectorBool p(m * n); if( n <= m ) { size_t j, k; // use forward mode 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; } p = ForSparseJac(n, r); } else { size_t i, k; // use reverse mode VectorBool 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 cppad-20160000.1/cppad/local/forward0sweep.hpp0000644000175200017650000006265512656321770020130 0ustar coincoin-web// $Id: forward0sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FORWARD0SWEEP_HPP # define CPPAD_FORWARD0SWEEP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file forward0sweep.hpp Compute zero order forward mode Taylor coefficients. */ /* \def CPPAD_ATOMIC_CALL This avoids warnings when NDEBUG is defined and user_ok is not used. If NDEBUG is defined, this resolves to \code user_atom->forward \endcode otherwise, it respolves to \code user_ok = user_atom->forward \endcode This maco is undefined at the end of this file to facillitate is use with a different definition in other files. */ # ifdef NDEBUG # define CPPAD_ATOMIC_CALL user_atom->forward # else # define CPPAD_ATOMIC_CALL user_ok = user_atom->forward # endif /*! \def CPPAD_FORWARD0SWEEP_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_FORWARD0SWEEP is zero). */ # define CPPAD_FORWARD0SWEEP_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. \n \n The object play is effectly constant. The exception to this is that while palying back the tape the object play holds information about the current location with in the tape and this changes during palyback. \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. */ template void forward0sweep( std::ostream& s_out, bool print, size_t n, size_t numvar, player* play, 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 ) { 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; /* */ // op code for current instruction OpCode op; // index for current instruction size_t i_op; // next variables size_t i_var; // operation argument indices const addr_t* arg = CPPAD_NULL; // 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; } // work space used by UserOp. vector user_vx; // empty vecotor vector user_vy; // empty vecotor vector user_tx; // argument vector Taylor coefficients vector user_ty; // result vector Taylor coefficients size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator size_t user_i = 0; // index in result vector size_t user_j = 0; // index in argument vector size_t user_m = 0; // size of result vector size_t user_n = 0; // size of arugment vector // atomic_base* user_atom = CPPAD_NULL; // user's atomic op calculator # ifndef NDEBUG bool user_ok = false; // atomic op return value # endif // // next expected operator in a UserOp sequence enum { user_start, user_arg, user_ret, user_end, user_trace } user_state = user_start; // 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_FORWARD0SWEEP_TRACE // variable indices for results vector // (done differently for order zero). vector user_iy; # endif // skip the BeginOp at the beginning of the recording play->forward_start(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( op == BeginOp ); # if CPPAD_FORWARD0SWEEP_TRACE std::cout << std::endl; # endif bool more_operators = true; while(more_operators) { // this op play->forward_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) ); CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) ); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); CPPAD_ASSERT_ARG_BEFORE_RESULT(op, arg, i_var); // check if we are skipping this operation while( cskip_op[i_op] ) { if( op == CSumOp ) { // CSumOp has a variable number of arguments play->forward_csum(op, arg, i_op, i_var); } CPPAD_ASSERT_UNKNOWN( op != CSkipOp ); // if( op == CSkipOp ) // { // CSkip has a variable number of arguments // play->forward_cskip(op, arg, i_op, i_var); // } play->forward_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); } // action to take depends on the case switch( op ) { case AbsOp: forward_abs_op_0(i_var, 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, 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, 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, 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, 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, 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, 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, arg[0], J, taylor); break; // --------------------------------------------------- case CoshOp: // sinh(x), cosh(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); forward_cosh_op_0(i_var, arg[0], J, taylor); break; // ------------------------------------------------- case CSkipOp: // CSkipOp has a variable number of arguments and // forward_next thinks it has no arguments. // we must inform forward_next of this special case. forward_cskip_op_0( i_var, arg, num_par, parameter, J, taylor, cskip_op ); play->forward_cskip(op, arg, i_op, i_var); break; // ------------------------------------------------- case CSumOp: // CSumOp has a variable number of arguments and // forward_next thinks it has no arguments. // we must inform forward_next of this special case. forward_csum_op( 0, 0, i_var, arg, num_par, parameter, J, taylor ); play->forward_csum(op, arg, i_op, i_var); 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 EqpvOp: if( compare_change_count ) { forward_eqpv_op_0( compare_change_number, arg, parameter, J, taylor ); { if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } } break; // ------------------------------------------------- case EqvvOp: if( compare_change_count ) { forward_eqvv_op_0( compare_change_number, arg, parameter, J, taylor ); { if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } } break; // ------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 case ErfOp: forward_erf_op_0(i_var, arg, parameter, J, taylor); break; # endif // ------------------------------------------------- case ExpOp: forward_exp_op_0(i_var, arg[0], J, taylor); break; // ------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 case Expm1Op: forward_expm1_op_0(i_var, arg[0], J, taylor); break; # endif // ------------------------------------------------- case InvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); break; // --------------------------------------------------- case LdpOp: forward_load_p_op_0( play, i_var, arg, parameter, J, 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 LepvOp: if( compare_change_count ) { forward_lepv_op_0( compare_change_number, arg, parameter, J, taylor ); { if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } } break; // ------------------------------------------------- case LevpOp: if( compare_change_count ) { forward_levp_op_0( compare_change_number, arg, parameter, J, taylor ); { if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } } break; // ------------------------------------------------- case LevvOp: if( compare_change_count ) { forward_levv_op_0( compare_change_number, arg, parameter, J, taylor ); { if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } } break; // ------------------------------------------------- case LogOp: forward_log_op_0(i_var, arg[0], J, taylor); break; // ------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 case Log1pOp: forward_log1p_op_0(i_var, arg[0], J, taylor); break; # endif // ------------------------------------------------- case LtpvOp: if( compare_change_count ) { forward_ltpv_op_0( compare_change_number, arg, parameter, J, taylor ); { if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } } break; // ------------------------------------------------- case LtvpOp: if( compare_change_count ) { forward_ltvp_op_0( compare_change_number, arg, parameter, J, taylor ); { if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } } break; // ------------------------------------------------- case LtvvOp: if( compare_change_count ) { forward_ltvv_op_0( compare_change_number, arg, parameter, J, taylor ); { if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } } break; // ------------------------------------------------- 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 NepvOp: if( compare_change_count ) { forward_nepv_op_0( compare_change_number, arg, parameter, J, taylor ); { if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } } break; // ------------------------------------------------- case NevvOp: if( compare_change_count ) { forward_nevv_op_0( compare_change_number, arg, parameter, J, taylor ); { if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } } break; // ------------------------------------------------- case ParOp: forward_par_op_0( i_var, arg, num_par, parameter, J, taylor ); 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, arg[0], J, taylor); break; // ------------------------------------------------- case SinOp: // cos(x), sin(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); forward_sin_op_0(i_var, arg[0], J, taylor); break; // ------------------------------------------------- case SinhOp: // cosh(x), sinh(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); forward_sinh_op_0(i_var, arg[0], J, taylor); break; // ------------------------------------------------- case SqrtOp: forward_sqrt_op_0(i_var, 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, arg[0], J, taylor); break; // ------------------------------------------------- case TanhOp: // tanh(x)^2, tanh(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); forward_tanh_op_0(i_var, arg[0], J, taylor); break; // ------------------------------------------------- case UserOp: // start or end an atomic operation sequence CPPAD_ASSERT_UNKNOWN( NumRes( UserOp ) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg( UserOp ) == 4 ); if( user_state == user_start ) { user_index = arg[0]; user_id = arg[1]; user_n = arg[2]; user_m = arg[3]; user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif if(user_tx.size() != user_n) user_tx.resize(user_n); if(user_ty.size() != user_m) user_ty.resize(user_m); # if CPPAD_FORWARD0SWEEP_TRACE if( user_iy.size() != user_m ) user_iy.resize(user_m); # endif user_j = 0; user_i = 0; user_state = user_arg; } else { CPPAD_ASSERT_UNKNOWN( user_state == user_end ); CPPAD_ASSERT_UNKNOWN( user_index == size_t(arg[0]) ); CPPAD_ASSERT_UNKNOWN( user_id == size_t(arg[1]) ); CPPAD_ASSERT_UNKNOWN( user_n == size_t(arg[2]) ); CPPAD_ASSERT_UNKNOWN( user_m == size_t(arg[3]) ); # ifndef NDEBUG if( ! user_ok ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base.forward: returned false"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif # if CPPAD_FORWARD0SWEEP_TRACE user_state = user_trace; # else user_state = user_start; # endif } break; case UsrapOp: // parameter argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( user_j < user_n ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); user_tx[user_j++] = parameter[ arg[0] ]; if( user_j == user_n ) { // call users function for this operation user_atom->set_id(user_id); CPPAD_ATOMIC_CALL(p, q, user_vx, user_vy, user_tx, user_ty ); user_state = user_ret; } break; case UsravOp: // variable argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( user_j < user_n ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= i_var ); user_tx[user_j++] = taylor[ arg[0] * J + 0 ]; if( user_j == user_n ) { // call users function for this operation user_atom->set_id(user_id); CPPAD_ATOMIC_CALL(p, q, user_vx, user_vy, user_tx, user_ty ); user_state = user_ret; } break; case UsrrpOp: // parameter result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( user_i < user_m ); # if CPPAD_FORWARD0SWEEP_TRACE user_iy[user_i] = 0; # endif user_i++; if( user_i == user_m ) user_state = user_end; break; case UsrrvOp: // variable result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( user_i < user_m ); # if CPPAD_FORWARD0SWEEP_TRACE user_iy[user_i] = i_var; # endif taylor[ i_var * J + 0 ] = user_ty[user_i++]; if( user_i == user_m ) user_state = user_end; 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_FORWARD0SWEEP_TRACE size_t d = 0; if( user_state == user_trace ) { user_state = user_start; CPPAD_ASSERT_UNKNOWN( op == UserOp ); CPPAD_ASSERT_UNKNOWN( NumArg(UsrrvOp) == 0 ); for(size_t i = 0; i < user_m; i++) if( user_iy[i] > 0 ) { size_t i_tmp = (i_op + i) - user_m; printOp( std::cout, play, i_tmp, user_iy[i], UsrrvOp, CPPAD_NULL ); Base* Z_tmp = taylor + user_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; const addr_t* arg_tmp = arg; if( op == CSumOp ) arg_tmp = arg - arg[-1] - 4; if( op == CSkipOp ) arg_tmp = arg - arg[-1] - 7; if( op != UsrrvOp ) { printOp( std::cout, play, i_op, i_var, op, arg_tmp ); 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( user_state == user_start ); CPPAD_ASSERT_UNKNOWN( i_var + 1 == play->num_var_rec() ); return; } } // END_CPPAD_NAMESPACE // preprocessor symbols that are local to this file # undef CPPAD_FORWARD0SWEEP_TRACE # undef CPPAD_ATOMIC_CALL # endif cppad-20160000.1/cppad/local/capacity_order.hpp0000644000175200017650000001643512656321770020323 0ustar coincoin-web// $Id: capacity_order.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_CAPACITY_ORDER_HPP # define CPPAD_CAPACITY_ORDER_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin capacity_order$$ $spell var taylor_ xq yq $$ $section Controlling Taylor Coefficients Memory Allocation$$ $mindex Forward capacity_order control$$ $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 $code%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/capacity_order.cpp %$$ $head Example$$ The file $cref capacity_order.cpp$$ contains an example and test of these operations. It returns true if it succeeds and false otherwise. $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 \c 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_.free() is called. \param r is the number of directions to allocate memory for. If c == 1 then \c r must also be one. In all cases, it must hold that 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 \c 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_.free(); 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_; pod_vector new_taylor; new_taylor.extend(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_.free() 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 \c is zero (one), \c num_direction_taylor_ is set to zero (one). Otherwise, if \c num_direction_taylor_ is zero, it is set to one. Othwerwise, \c 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 cppad-20160000.1/cppad/local/sign.hpp0000644000175200017650000000502612656321770016265 0ustar coincoin-web// $Id: sign.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SIGN_HPP # define CPPAD_SIGN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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/sign.cpp %$$ The file $cref sign.cpp$$ contains an example and test of this function. It returns true if it succeeds and false otherwise. $end ------------------------------------------------------------------------------- */ // BEGIN CppAD namespace namespace CppAD { template AD AD::Sign (void) const { AD result; result.value_ = sign(value_); CPPAD_ASSERT_UNKNOWN( Parameter(result) ); if( Variable(*this) ) { // add this operation to the tape CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(SignOp) == 1 ); ADTape *tape = tape_this(); // corresponding operand address tape->Rec_.PutArg(taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(SignOp); // make result a variable result.tape_id_ = tape->id_; } return result; } template inline AD sign(const AD &x) { return x.Sign(); } template inline AD sign(const VecAD_reference &x) { return sign( x.ADBase() ); } } // END CppAD namespace # endif cppad-20160000.1/cppad/local/base_cond_exp.hpp0000644000175200017650000001631712656321770020123 0ustar coincoin-web// $Id: base_cond_exp.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_BASE_COND_EXP_HPP # define CPPAD_BASE_COND_EXP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin base_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$$ $mindex CondExp require CPPAD_COND_EXP_REL$$ $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 \c Type is the \c Base type for this base require operation. The argument \c Rel is one of \c Lt, \c Le, \c Eq, \c Ge, \c Gt. The argument \c Op is the corresponding \c 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 \c Type is the \c 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 \c 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 \c exp_if_true and \c 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 cppad-20160000.1/cppad/local/base_double.hpp0000644000175200017650000001251212656321770017567 0ustar coincoin-web// $Id: base_double.hpp 3769 2015-12-29 16:13:16Z bradbell $ # ifndef CPPAD_BASE_DOUBLE_HPP # define CPPAD_BASE_DOUBLE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include /* $begin base_double.hpp$$ $spell 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 $codep */ 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 $codep */ 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 $codep */ 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 $codep */ 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); } } /* $$ $head Integer$$ $codep */ namespace CppAD { inline int Integer(const double& x) { return static_cast(x); } } /* $$ $head azmul$$ $codep */ namespace CppAD { CPPAD_AZMUL( double ) } /* $$ $head Ordered$$ The $code double$$ type supports ordered comparisons $codep */ 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 define the unary standard math functions required to use $code AD$$: $codep */ namespace CppAD { CPPAD_STANDARD_MATH_UNARY(double, acos) CPPAD_STANDARD_MATH_UNARY(double, asin) CPPAD_STANDARD_MATH_UNARY(double, atan) CPPAD_STANDARD_MATH_UNARY(double, cos) CPPAD_STANDARD_MATH_UNARY(double, cosh) CPPAD_STANDARD_MATH_UNARY(double, exp) CPPAD_STANDARD_MATH_UNARY(double, fabs) CPPAD_STANDARD_MATH_UNARY(double, log) CPPAD_STANDARD_MATH_UNARY(double, log10) CPPAD_STANDARD_MATH_UNARY(double, sin) CPPAD_STANDARD_MATH_UNARY(double, sinh) CPPAD_STANDARD_MATH_UNARY(double, sqrt) CPPAD_STANDARD_MATH_UNARY(double, tan) CPPAD_STANDARD_MATH_UNARY(double, tanh) # if CPPAD_USE_CPLUSPLUS_2011 CPPAD_STANDARD_MATH_UNARY(double, erf) CPPAD_STANDARD_MATH_UNARY(double, asinh) CPPAD_STANDARD_MATH_UNARY(double, acosh) CPPAD_STANDARD_MATH_UNARY(double, atanh) CPPAD_STANDARD_MATH_UNARY(double, expm1) CPPAD_STANDARD_MATH_UNARY(double, log1p) # endif } /* $$ The absolute value function is special because its $code std$$ name is $code fabs$$ $codep */ 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$$: $codep */ 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$$: $codep */ namespace CppAD { inline double pow(const double& x, const double& y) { return std::pow(x, y); } } /*$$ $head numeric_limits$$ The following defines the CppAD $cref numeric_limits$$ for the type $code double$$: $codep */ namespace CppAD { CPPAD_NUMERIC_LIMITS(double, double) } /*$$ $head to_string$$ There is no need to define $code to_string$$ for $code double$$ because it is defined by including $code cppad/utility/to_string.hpp$$; see $cref to_string$$. See $cref/base_complex.hpp/base_complex.hpp/to_string/$$ for an example where it is necessary to define $code to_string$$ for a $icode Base$$ type. $end */ # endif cppad-20160000.1/cppad/local/sparse_set.hpp0000644000175200017650000002516312656321770017501 0ustar coincoin-web// $Id: sparse_set.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_SET_HPP # define CPPAD_SPARSE_SET_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file sparse_set.hpp Vector of sets of positive integers stored as std::set. */ /*! Vector of sets of positive integers, each set stored as a standard set. */ class sparse_set { private: /// type used for each set in the vector sets typedef std::set Set; /// 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_; /// The vector of sets CppAD::vector data_; /// index for which we were retrieving next_element /// (use n_set_ if no such index exists). size_t next_index_; /// Next element that we will return using next_element /// (use end_ for no such element exists; i.e., past end of the set). Set::iterator next_element_; public: // ----------------------------------------------------------------- /*! Default constructor (no sets) */ sparse_set(void) : n_set_(0) , end_(0) , next_index_(0) { } // ----------------------------------------------------------------- /*! Make use of copy constructor an error \param v vector that we are attempting to make a copy of. */ sparse_set(const sparse_set& v) { // Error: // Probably a sparse_set argument has been passed by value CPPAD_ASSERT_UNKNOWN(false); } // ----------------------------------------------------------------- /*! Destructor */ ~sparse_set(void) { } // ----------------------------------------------------------------- /*! Change number of sets, set end, and initialize all sets as empty If \c n_set_in is zero, any memory currently allocated for this object is freed. Otherwise, new memory may be allocated for the sets (if needed). \param n_set_in is the number of sets in this vector of sets. \param end_in is the maximum element plus one (the minimum element is 0). */ void resize(size_t n_set_in, size_t end_in) { n_set_ = n_set_in; end_ = end_in; if( n_set_ == 0 ) { // free all memory connected with data_ data_.clear(); return; } // now start a new vector with empty sets data_.resize(n_set_); // value that signfies past end of list next_index_ = n_set_; } // ----------------------------------------------------------------- /*! Add one element to a set. \param index is the index for this set in the vector of sets. \param element is the element we are adding to the set. \par Checked Assertions \li index < n_set_ \li element < end_ */ void add_element(size_t index, size_t element) { // This routine should use the std::insert operator // that cashes the iterator of previous insertion for when // insertions occur in order. We should speed test that this // actually makes things faster. CPPAD_ASSERT_UNKNOWN( index < n_set_ ); CPPAD_ASSERT_UNKNOWN( element < end_ ); data_[ index ].insert( element ); } // ----------------------------------------------------------------- /*! Is an element of a set. \param index is the index for this set in the vector of sets. \param element is the element we are adding to the set. \par Checked Assertions \li index < n_set_ \li element < end_ */ bool is_element(size_t index, size_t element) { // This routine should use the std::insert operator // that cashes the iterator of previous insertion for when // insertions occur in order. We should speed test that this // actually makes things faster. CPPAD_ASSERT_UNKNOWN( index < n_set_ ); CPPAD_ASSERT_UNKNOWN( element < end_ ); std::set::iterator itr = data_[ index ].find( element ); return itr != data_[index].end(); } // ----------------------------------------------------------------- /*! Begin retrieving elements from one of the sets. \param index is the index for the set that is going to be retrieved. The elements of the set are retrieved in increasing order. \par Checked Assertions \li index < n_set_ */ void begin(size_t index) { // initialize element to search for in this set CPPAD_ASSERT_UNKNOWN( index < n_set_ ); next_index_ = index; next_element_ = data_[index].begin(); return; } // ----------------------------------------------------------------- /*! Get the next element from the current retrieval set. \return is the next element in the set with index specified by the previous call to \c begin. If no such element exists, \c this->end() is returned. */ size_t next_element(void) { if( next_element_ == data_[next_index_].end() ) return end_; return *next_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 Checked Assertions \li target < n_set_ */ void clear(size_t target) { CPPAD_ASSERT_UNKNOWN( target < n_set_ ); data_[target].clear(); } // ----------------------------------------------------------------- /*! Assign one set equal to another set. \param this_target is the index (in this \c sparse_set object) of the set being assinged. \param other_value is the index (in the other \c sparse_set object) of the that we are using as the value to assign to the target set. \param other is the other \c sparse_set object (which may be the same as this \c sparse_set object). \par Checked Assertions \li this_target < n_set_ \li other_value < other.n_set_ */ void assignment( size_t this_target , size_t other_value , const sparse_set& other ) { CPPAD_ASSERT_UNKNOWN( this_target < n_set_ ); CPPAD_ASSERT_UNKNOWN( other_value < other.n_set_ ); data_[this_target] = other.data_[other_value]; } // ----------------------------------------------------------------- /*! Assign a set equal to the union of two other sets. \param this_target is the index (in this \c sparse_set object) of the set being assinged. \param this_left is the index (in this \c sparse_set object) of the left operand for the union operation. It is OK for \a this_target and \a this_left to be the same value. \param other_right is the index (in the other \c sparse_set object) of the right operand for the union operation. It is OK for \a this_target and \a other_right to be the same value. \param other is the other \c sparse_set object (which may be the same as this \c sparse_set object). \par Checked Assertions \li this_target < n_set_ \li this_left < n_set_ \li other_right < other.n_set_ */ void binary_union( size_t this_target , size_t this_left , size_t other_right , const sparse_set& other ) { CPPAD_ASSERT_UNKNOWN( this_target < n_set_ ); CPPAD_ASSERT_UNKNOWN( this_left < n_set_ ); CPPAD_ASSERT_UNKNOWN( other_right < other.n_set_ ); // use a temporary set for holding results // (in case target set is same as one of the other sets) Set temp; std::set_union( data_[this_left].begin() , data_[this_left].end() , other.data_[other_right].begin() , other.data_[other_right].end() , std::inserter(temp, temp.begin()) ); // move results to the target set with out copying elements data_[this_target].swap(temp); } // ----------------------------------------------------------------- /*! Sum over all sets of the number of elements /return The the total number of elements */ size_t number_elements(void) const { size_t i, count; count = 0; for(i = 0; i < n_set_; i++) count += data_[i].size(); return count; } // ----------------------------------------------------------------- /*! Fetch n_set for vector of sets object. \return Number of from sets for this vector of sets object */ size_t n_set(void) const { return n_set_; } // ----------------------------------------------------------------- /*! Fetch end for this vector of sets object. \return is the maximum element value plus one (the minimum element value is 0). */ size_t end(void) const { return end_; } }; /*! Copy a user vector of sets sparsity pattern to an internal sparse_set object. \tparam VectorSet is a simple vector with elements of type \c std::set. \param internal The input value of sparisty does not matter. Upon return it contains the same sparsity pattern as \c user (or the transposed sparsity pattern). \param user sparsity pattern that we are placing \c internal. \param n_row number of rows in the sparsity pattern in \c user (range dimension). \param n_col number of columns in the sparsity pattern in \c user (domain dimension). \param transpose if true, the sparsity pattern in \c internal is the transpose of the one in \c user. Otherwise it is the same sparsity pattern. */ template void sparsity_user2internal( sparse_set& internal , const VectorSet& user , size_t n_row , size_t n_col , bool transpose ) { CPPAD_ASSERT_KNOWN( size_t( user.size() ) == n_row, "Size of this vector of sets sparsity pattern is not equal\n" "the range dimension for the corresponding function." ); size_t i, j; std::set::const_iterator itr; // transposed pattern case if( transpose ) { internal.resize(n_col, n_row); for(i = 0; i < n_row; i++) { itr = user[i].begin(); while(itr != user[i].end()) { j = *itr++; CPPAD_ASSERT_KNOWN( j < n_col, "An element in this vector of sets sparsity pattern " "is greater than or equal\n" "the domain dimension for the corresponding function." ); internal.add_element(j, i); } } return; } // same pattern case internal.resize(n_row, n_col); for(i = 0; i < n_row; i++) { itr = user[i].begin(); while(itr != user[i].end()) { j = *itr++; CPPAD_ASSERT_UNKNOWN( j < n_col ); internal.add_element(i, j); } } return; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/old_atomic.hpp0000644000175200017650000010161212656321770017435 0ustar coincoin-web// $Id: old_atomic.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_OLD_ATOMIC_HPP # define CPPAD_OLD_ATOMIC_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin old_atomic$$ $spell hes std Jacobian jac Tvector afun vx vy bool namespace CppAD const Taylor tx ty px py $$ $section User Defined Atomic AD Functions$$ $mindex operation old_atomic$$ $head Deprecated 2013-05-27$$ Using $code CPPAD_USER_ATOMIC$$ has been deprecated. Use $cref atomic_base$$ 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^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, $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; see $cref/use AD/old_atomic/Example/Use AD/$$ $head Partial Implementation$$ The routines $cref/forward/old_atomic/forward/$$, $cref/reverse/old_atomic/reverse/$$, $cref/for_jac_sparse/old_atomic/for_jac_sparse/$$, $cref/rev_jac_sparse/old_atomic/rev_jac_sparse/$$, and $cref/rev_hes_sparse/old_atomic/rev_hes_sparse/$$, must be defined by the user. The $icode forward$$ the routine, 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/old_atomic/forward/$$) or taking the derivative of ($cref/reverse/old_atomic/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/old_atomic/forward/$$, the argument $icode ty$$ has prototype $codei% CppAD::vector<%Base%>& %ty% %$$ while in calls to $cref/reverse/old_atomic/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^n$$ at which the $codei%AD<%Base%>%$$ version of $latex y = f(x)$$ is to be evaluated. The dimension of the domain space for $latex y = f (x)$$ is specified by $cref/n/old_atomic/n/$$ $codei%= %ax%.size()%$$, 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/old_atomic/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/old_atomic clear/old_atomic/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/old_atomic/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^{n \times (k+1)} \rightarrow B^{m \times (k+1)}$$ by $latex \[ y_i^\ell = F_i^\ell ( \{ x_j^\ell \} ) \] $$ We use $latex G : B^{m \times (k+1)} \rightarrow B$$ to denote an arbitrary scalar valued function of the Taylor coefficients for $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^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^{n \times q}$$ and the Jacobian $latex S(x) \in B^{m \times q}$$. $subhead r$$ The $icode for_jac_sparse$$ argument $icode r$$ has prototype $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^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^{q \times m}$$ and the Jacobian $latex R(x) \in B^{q \times n}$$. $subhead s$$ The $icode rev_jac_sparse$$ argument $icode s$$ has prototype $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^m \rightarrow B$$. 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^{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^{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^{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^{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^{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 user atomic functions for a specific value of $icode Base$$. $subhead Restriction$$ The user atomic $code clear$$ routine cannot be called while in $cref/parallel/ta_in_parallel/$$ execution mode. $children% test_more/old_reciprocal.cpp% test_more/old_usead_1.cpp% test_more/old_usead_2.cpp% test_more/old_tan.cpp% test_more/old_mat_mul.cpp %$$ $head Example$$ $subhead Simple$$ The file $cref old_reciprocal.cpp$$ contains the simplest example and test of a user atomic operation. $subhead Use AD$$ The examples $cref old_usead_1.cpp$$ and $cref 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. $subhead Tangent Function$$ The file $cref old_tan.cpp$$ contains an example and test implementation of the tangent function as a user atomic operation. $subhead Matrix Multiplication$$ The file $cref old_mat_mul.cpp$$ contains an example and test implementation of matrix multiplication a a user atomic operation. $end ------------------------------------------------------------------------------ */ # include # include // needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file old_atomic.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 \c id is \c ax and \c 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 \c afun, preceeded by a pound sign, is a version of \c 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 old_atomic 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::old_atomic 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 old_atomic object is generated each time the user invokes the CPPAD_USER_ATOMIC macro; see static object in that macro. */ template class old_atomic : public atomic_base { public: /// disable old_atomic::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. */ old_atomic(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_id(size_t id) { id_ = id; } /*! Link from old_atomic to forward mode \copydetails atomic_base::forward */ virtual bool forward( size_t p , size_t q , const vector& vx , vector& vy , const vector& 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; // old_atomic 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 old_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 ) { 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 old_atomic \copydetails atomic_base::for_sparse_jac */ virtual bool for_sparse_jac( size_t q , const vector< std::set >& r , vector< std::set >& s ) { 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 old_atomic. \copydetails atomic_base::rev_sparse_jac */ virtual bool rev_sparse_jac( size_t q , const vector< std::set >& rt , vector< std::set >& st ) { 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 old_atomic \copydetails atomic_base::rev_sparse_hes */ virtual bool rev_sparse_hes( const vector& vx, const vector& s , vector& t , size_t q , const vector< std::set >& r , const vector< std::set >& u , vector< std::set >& v ) { size_t 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 cppad-20160000.1/cppad/local/rev_jac_sweep.hpp0000644000175200017650000005765212656321770020155 0ustar coincoin-web// $Id: rev_jac_sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_REV_JAC_SWEEP_HPP # define CPPAD_REV_JAC_SWEEP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file rev_jac_sweep.hpp Compute Reverse mode Jacobian sparsity patterns. */ /*! \def CPPAD_REV_JAC_SWEEP_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_SWEEP_TRACE 0 /* \def CPPAD_ATOMIC_CALL This avoids warnings when NDEBUG is defined and user_ok is not used. If \c NDEBUG is defined, this resolves to \code user_atom->rev_sparse_jac \endcode otherwise, it respolves to \code user_ok = user_atom->rev_sparse_jac \endcode This maco is undefined at the end of this file to facillitate is use with a different definition in other files. */ # ifdef NDEBUG # define CPPAD_ATOMIC_CALL user_atom->rev_sparse_jac # else # define CPPAD_ATOMIC_CALL user_ok = user_atom->rev_sparse_jac # endif /*! Given the sparsity pattern for the dependent variables, RevJacSweep computes the sparsity pattern for all the independent variables. \tparam Base base type for the operator; i.e., this operation sequence was recorded using AD< \a Base > and computations by this routine are done using type \a Base. \tparam Vector_set is the type used for vectors of sets. It can be either \c sparse_pack, \c sparse_set, or \c sparse_list. \param 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., \a play->num_var_rec(). This is also the number of rows in the entire sparsity pattern \a RevJac. \param play The information stored in \a 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. The object \a play is effectly constant. It is not declared const because while playing back the tape the object \a play holds information about the currentl location with in the tape and this changes during playback. \param var_sparsity For i = 0 , ... , \a numvar - 1, (all the variables on the tape) the forward Jacobian sparsity pattern for variable i corresponds to the set with index i in \a var_sparsity. \b \b \b Input: For i = 0 , ... , \a 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 , ... , \a n, the sparsity pattern for the dependent variable with index (j-1) is given by the set with index index j in \a var_sparsity. */ template void RevJacSweep( bool dependency, size_t n, size_t numvar, player *play, Vector_set& var_sparsity ) { OpCode op; size_t i_op; size_t i_var; const addr_t* arg = CPPAD_NULL; 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; vecad_sparsity.resize(num_vecad_vec, limit); pod_vector vecad_ind; if( num_vecad_vec > 0 ) { size_t length; 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 UserOp. typedef std::set size_set; size_set::iterator set_itr; // iterator for a standard set size_set::iterator set_end; // end of iterator sequence vector< size_set > set_r; // set sparsity pattern for the argument x vector< size_set > set_s; // set sparisty pattern for the result y // vector bool_r; // bool sparsity pattern for the argument x vector bool_s; // bool sparisty pattern for the result y // vectorBool pack_r; // pack sparsity pattern for the argument x vectorBool pack_s; // pack sparisty pattern for the result y // const size_t user_q = limit; // maximum element plus one size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator size_t user_i = 0; // index in result vector size_t user_j = 0; // index in argument vector size_t user_m = 0; // size of result vector size_t user_n = 0; // size of arugment vector // atomic_base* user_atom = CPPAD_NULL; // user's atomic op calculator bool user_pack = false; // sparsity pattern type is pack bool user_bool = false; // sparsity pattern type is bool bool user_set = false; // sparsity pattern type is set # ifndef NDEBUG bool user_ok = false; // atomic op return value # endif // next expected operator in a UserOp sequence enum { user_start, user_arg, user_ret, user_end } user_state = user_end; // Initialize play->reverse_start(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( op == EndOp ); # if CPPAD_REV_JAC_SWEEP_TRACE std::cout << std::endl; CppAD::vectorBool z_value(limit); # endif bool more_operators = true; while(more_operators) { // next op play->reverse_next(op, arg, i_op, i_var); # ifndef NDEBUG if( i_op <= n ) { CPPAD_ASSERT_UNKNOWN((op == InvOp) | (op == BeginOp)); } else CPPAD_ASSERT_UNKNOWN((op != InvOp) & (op != BeginOp)); # endif // 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, 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, 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, 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, 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, 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, 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, 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, arg[0], var_sparsity ); break; # endif // ------------------------------------------------- case BeginOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); more_operators = false; break; // ------------------------------------------------- case CSkipOp: // CSkipOp has a variable number of arguments and // reverse_next thinks it one has one argument. // We must inform reverse_next of this special case. play->reverse_cskip(op, arg, i_op, i_var); break; // ------------------------------------------------- case CSumOp: // CSumOp has a variable number of arguments and // reverse_next thinks it one has one argument. // We must inform reverse_next of this special case. play->reverse_csum(op, arg, i_op, i_var); 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, 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, 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, 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, arg[1], var_sparsity ); break; // ------------------------------------------------- case DivvpOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); reverse_sparse_jacobian_unary_op( i_var, 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, arg[0], var_sparsity ); break; // ------------------------------------------------- case ExpOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); reverse_sparse_jacobian_unary_op( i_var, 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, 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 EqpvOp: case EqvvOp: case LtpvOp: case LtvpOp: case LtvvOp: case LepvOp: case LevpOp: case LevvOp: case NepvOp: case NevvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 0); break; // ------------------------------------------------- case LogOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); reverse_sparse_jacobian_unary_op( i_var, 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, arg[0], var_sparsity ); break; # endif // ------------------------------------------------- case MulpvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); reverse_sparse_jacobian_unary_op( i_var, 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, arg[0], var_sparsity ); break; // ------------------------------------------------- case PowpvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 3); reverse_sparse_jacobian_unary_op( i_var, 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, 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, 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, arg[0], var_sparsity ); break; // ------------------------------------------------- case SqrtOp: CPPAD_ASSERT_NARG_NRES(op, 1, 1); reverse_sparse_jacobian_unary_op( i_var, 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, arg[1], var_sparsity ); break; // ------------------------------------------------- case SubvpOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); reverse_sparse_jacobian_unary_op( i_var, 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, 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, arg[0], var_sparsity ); break; // ------------------------------------------------- case UserOp: // start or end atomic operation sequence CPPAD_ASSERT_UNKNOWN( NumRes( UserOp ) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg( UserOp ) == 4 ); if( user_state == user_end ) { user_index = arg[0]; user_id = arg[1]; user_n = arg[2]; user_m = arg[3]; user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif user_pack = user_atom->sparsity() == atomic_base::pack_sparsity_enum; user_bool = user_atom->sparsity() == atomic_base::bool_sparsity_enum; user_set = user_atom->sparsity() == atomic_base::set_sparsity_enum; CPPAD_ASSERT_UNKNOWN( user_pack || user_bool || user_set ); if( user_pack ) { if( pack_r.size() != user_m * user_q ) pack_r.resize( user_m * user_q ); if( pack_s.size() != user_n * user_q ) pack_s.resize( user_n * user_q ); for(i = 0; i < user_m; i++) for(j = 0; j < user_q; j++) pack_r[ i * user_q + j] = false; } if( user_bool ) { if( bool_r.size() != user_m * user_q ) bool_r.resize( user_m * user_q ); if( bool_s.size() != user_n * user_q ) bool_s.resize( user_n * user_q ); for(i = 0; i < user_m; i++) for(j = 0; j < user_q; j++) bool_r[ i * user_q + j] = false; } if( user_set ) { if(set_r.size() != user_m ) set_r.resize(user_m); if(set_s.size() != user_n ) set_s.resize(user_n); for(i = 0; i < user_m; i++) set_r[i].clear(); } user_j = user_n; user_i = user_m; user_state = user_ret; } else { CPPAD_ASSERT_UNKNOWN( user_state == user_start ); CPPAD_ASSERT_UNKNOWN( user_index == size_t(arg[0]) ); CPPAD_ASSERT_UNKNOWN( user_id == size_t(arg[1]) ); CPPAD_ASSERT_UNKNOWN( user_n == size_t(arg[2]) ); CPPAD_ASSERT_UNKNOWN( user_m == size_t(arg[3]) ); # ifndef NDEBUG if( ! user_ok ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base.rev_sparse_jac: returned false\n"; if( user_pack ) msg += "sparsity = pack_sparsity_enum"; if( user_bool ) msg += "sparsity = bool_sparsity_enum"; if( user_set ) msg += "sparsity = set_sparsity_enum"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif user_state = user_end; } break; case UsrapOp: // parameter argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( 0 < user_j && user_j <= user_n ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); --user_j; if( user_j == 0 ) user_state = user_start; break; case UsravOp: // variable argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( 0 < user_j && user_j <= user_n ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= i_var ); CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); --user_j; // 2DO: It might be faster if we add set union to var_sparsity // where one of the sets is not in var_sparsity. if( user_pack ) { for(j = 0; j < user_q; j++) if( pack_s[ user_j * user_q + j ] ) var_sparsity.add_element(arg[0], j); } if( user_bool ) { for(j = 0; j < user_q; j++) if( bool_s[ user_j * user_q + j ] ) var_sparsity.add_element(arg[0], j); } if( user_set ) { set_itr = set_s[user_j].begin(); set_end = set_s[user_j].end(); while( set_itr != set_end ) var_sparsity.add_element(arg[0], *set_itr++); } if( user_j == 0 ) user_state = user_start; break; case UsrrpOp: // parameter result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( 0 < user_i && user_i <= user_m ); CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); --user_i; if( user_i == 0 ) { // call users function for this operation user_atom->set_id(user_id); if( user_pack ) CPPAD_ATOMIC_CALL( user_q, pack_r, pack_s); if( user_bool ) CPPAD_ATOMIC_CALL( user_q, bool_r, bool_s); if( user_set ) CPPAD_ATOMIC_CALL( user_q, set_r, set_s); user_state = user_arg; } break; case UsrrvOp: // variable result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( 0 < user_i && user_i <= user_m ); --user_i; var_sparsity.begin(i_var); i = var_sparsity.next_element(); while( i < user_q ) { if( user_pack ) pack_r[ user_i * user_q + i ] = true; if( user_bool ) bool_r[ user_i * user_q + i ] = true; if( user_set ) set_r[user_i].insert(i); i = var_sparsity.next_element(); } if( user_i == 0 ) { // call users function for this operation user_atom->set_id(user_id); if( user_pack ) CPPAD_ATOMIC_CALL( user_q, pack_r, pack_s); if( user_bool ) CPPAD_ATOMIC_CALL( user_q, bool_r, bool_s); if( user_set ) CPPAD_ATOMIC_CALL( user_q, set_r, set_s); user_state = user_arg; } break; // ------------------------------------------------- case ZmulpvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); reverse_sparse_jacobian_unary_op( i_var, arg[1], var_sparsity ); break; // ------------------------------------------------- case ZmulvpOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); reverse_sparse_jacobian_unary_op( i_var, arg[0], var_sparsity ); break; // ------------------------------------------------- case ZmulvvOp: CPPAD_ASSERT_NARG_NRES(op, 2, 1); reverse_sparse_jacobian_binary_op( i_var, arg, var_sparsity ); break; // ------------------------------------------------- default: CPPAD_ASSERT_UNKNOWN(0); } # if CPPAD_REV_JAC_SWEEP_TRACE for(j = 0; j < limit; j++) z_value[j] = false; var_sparsity.begin(i_var); j = var_sparsity.next_element(); while( j < limit ) { z_value[j] = true; j = var_sparsity.next_element(); } printOp( std::cout, play, i_op, i_var, op, arg ); 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( i_op == 0 ); CPPAD_ASSERT_UNKNOWN( i_var == 0 ); return; } } // END_CPPAD_NAMESPACE // preprocessor symbols that are local to this file # undef CPPAD_REV_JAC_SWEEP_TRACE # undef CPPAD_ATOMIC_CALL # endif cppad-20160000.1/cppad/local/check_for_nan.hpp0000644000175200017650000001241212656321770020101 0ustar coincoin-web// $Id$ # ifndef CPPAD_CHECK_FOR_NAN_HPP # define CPPAD_CHECK_FOR_NAN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin check_for_nan$$ $spell std vec Cpp const bool newline $$ $section Check an ADFun Object For Nan Results$$ $head Syntax$$ $icode%f%.check_for_nan(%b%) %$$ $icode%b% = %f%.check_for_nan() %$$ $codei%get_check_for_nan(%vec%, %file%) %$$ $head Debugging$$ If $code NDEBUG$$ is not defined, and the result of a $cref/forward/forward_order/$$ or $cref/reverse/reverse_any/$$ calculation contains a $cref nan$$, CppAD can halt with an error message. $head f$$ For the syntax where $icode b$$ is an argument, $icode f$$ has prototype $codei% ADFun<%Base%> %f% %$$ (see $codei%ADFun<%Base%>%$$ $cref/constructor/FunConstruct/$$). For the syntax where $icode b$$ is the result, $icode f$$ has prototype $codei% const ADFun<%Base%> %f% %$$ $head b$$ This argument or result has prototype $codei% bool %b% %$$ Future calls to $icode%f%.Forward%$$ will (will not) check for $code nan$$. depending on if $icode b$$ is true (false). $head Default$$ The value for this setting after construction of $icode f$$) is true. The value of this setting is not affected by calling $cref Dependent$$ for this function object. $head Error Message$$ If this error is detected during zero order forward mode, the values of the independent variables that resulted in the $code nan$$ are written to a temporary binary file. This is so that you can run the original source code with those values to see what is causing the $code nan$$. $subhead vector_size$$ The error message with contain the text $codei%vector_size = %vector_size%$$ followed the newline character $code '\n'$$. The value of $icode vector_size$$ is the number of elements in the independent vector. $subhead file_name$$ The error message with contain the text $codei%file_name = %file_name%$$ followed the newline character $code '\n'$$. The value of $icode file_name$$ is the name of the temporary file that contains the dependent variable values. $subhead index$$ The error message will contain the text $codei%index = %index%$$ followed by the newline character $code '\n'$$. The value of $icode index$$ is the lowest dependent variable index that has the value $code nan$$. $head get_check_for_nan$$ This routine can be used to get the independent variable values that result in a $code nan$$. $subhead vec$$ This argument has prototype $codei% CppAD::vector<%Base%>& %vec% %$$ It size must be equal to the corresponding value of $cref/vector_size/check_for_nan/Error Message/vector_size/$$ in the corresponding error message. The input value of its elements does not matter. Upon return, it will contain the values for the independent variables, in the corresponding call to $cref Independent$$, that resulted in the $code nan$$. (Note that the call to $code Independent$$ uses an vector with elements of type $codei%AD<%Base%>%$$ and $icode vec$$ has elements of type $icode Base$$.) $subhead file$$ This argument has prototype $codei% const std::string& %file% %$$ It must be the value of $cref/file_name/check_for_nan/Error Message/file_name/$$ in the corresponding error message. $head Example$$ $children% example/check_for_nan.cpp %$$ The file $cref check_for_nan.cpp$$ contains an example and test of these operations. It returns true if it succeeds and false otherwise. $end */ # include # include # include # if CPPAD_HAS_MKSTEMP # include # include # else # if CPPAD_HAS_TMPNAM_S # include # else # include # endif # endif namespace CppAD { // BEGIN_CPPAD_NAMESPACE template void put_check_for_nan(const CppAD::vector& vec, std::string& file_name) { size_t char_size = sizeof(Base) * vec.size(); const char* char_ptr = reinterpret_cast( vec.data() ); # if CPPAD_HAS_MKSTEMP char pattern[] = "/tmp/fileXXXXXX"; int fd = mkstemp(pattern); file_name = pattern; write(fd, char_ptr, char_size); close(fd); # else # if CPPAD_HAS_TMPNAM_S std::vector name(L_tmpnam_s); if( tmpnam_s( name.data(), L_tmpnam_s ) != 0 ) { CPPAD_ASSERT_KNOWN( false, "Cannot create a temporary file name" ); } file_name = name.data(); # else file_name = tmpnam( CPPAD_NULL ); # endif std::fstream file_out(file_name.c_str(), std::ios::out|std::ios::binary ); file_out.write(char_ptr, char_size); file_out.close(); # endif return; } template void get_check_for_nan(CppAD::vector& vec, const std::string& file_name) { // size_t n = vec.size(); size_t char_size = sizeof(Base) * n; char* char_ptr = reinterpret_cast( vec.data() ); // std::fstream file_in(file_name.c_str(), std::ios::in|std::ios::binary ); file_in.read(char_ptr, char_size); // return; } } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/omp_max_thread.hpp0000644000175200017650000000520012656321770020306 0ustar coincoin-web// $Id: omp_max_thread.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_OMP_MAX_THREAD_HPP # define CPPAD_OMP_MAX_THREAD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin omp_max_thread$$ $spell alloc num omp OpenMp CppAD $$ $section OpenMP Parallel Setup$$ $mindex omp_max_thread$$ $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 cppad-20160000.1/cppad/local/forward1sweep.hpp0000644000175200017650000006736412656321770020133 0ustar coincoin-web// $Id: forward1sweep.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FORWARD1SWEEP_HPP # define CPPAD_FORWARD1SWEEP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file forward1sweep.hpp Compute one Taylor coefficient for each order requested. */ /* \def CPPAD_ATOMIC_CALL This avoids warnings when NDEBUG is defined and user_ok is not used. If NDEBUG is defined, this resolves to \code user_atom->forward \endcode otherwise, it respolves to \code user_ok = user_atom->forward \endcode This macro is undefined at the end of this file to facillitate its use with a different definition in other files. */ # ifdef NDEBUG # define CPPAD_ATOMIC_CALL user_atom->forward # else # define CPPAD_ATOMIC_CALL user_ok = user_atom->forward # endif /*! \def CPPAD_FORWARD1SWEEP_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_FORWARD1SWEEP_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. \n \n The object play is effectly constant. The exception to this is that while palying back the tape the object play holds information about the current location with in the tape and this changes during palyback. \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. */ template void forward1sweep( std::ostream& s_out, const bool print, const size_t p, const size_t q, const size_t n, const size_t numvar, player* play, 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 ) { // 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 ); /* */ // op code for current instruction OpCode op; // index for current instruction size_t i_op; // next variables size_t i_var; // operation argument indices const addr_t* arg = CPPAD_NULL; // 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; } // work space used by UserOp. vector user_vx; // empty vecotor vector user_vy; // empty vecotor vector user_tx; // argument vector Taylor coefficients vector user_ty; // result vector Taylor coefficients size_t user_index = 0; // indentifier for this atomic operation size_t user_id = 0; // user identifier for this call to operator size_t user_i = 0; // index in result vector size_t user_j = 0; // index in argument vector size_t user_m = 0; // size of result vector size_t user_n = 0; // size of arugment vector // atomic_base* user_atom = CPPAD_NULL; // user's atomic op calculator # ifndef NDEBUG bool user_ok = false; // atomic op return value # endif // // next expected operator in a UserOp sequence enum { user_start, user_arg, user_ret, user_end, user_trace } user_state = user_start; // 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 user calculation // (not needed for order zero) const size_t user_q1 = q+1; // variable indices for results vector // (done differently for order zero). vector user_iy; // skip the BeginOp at the beginning of the recording play->forward_start(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( op == BeginOp ); # if CPPAD_FORWARD1SWEEP_TRACE std::cout << std::endl; # endif bool more_operators = true; while(more_operators) { // this op play->forward_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( (i_op > n) | (op == InvOp) ); CPPAD_ASSERT_UNKNOWN( (i_op <= n) | (op != InvOp) ); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); CPPAD_ASSERT_ARG_BEFORE_RESULT(op, arg, i_var); // check if we are skipping this operation while( cskip_op[i_op] ) { if( op == CSumOp ) { // CSumOp has a variable number of arguments play->forward_csum(op, arg, i_op, i_var); } CPPAD_ASSERT_UNKNOWN( op != CSkipOp ); // if( op == CSkipOp ) // { // CSkip has a variable number of arguments // play->forward_cskip(op, arg, i_op, i_var); // } play->forward_next(op, arg, i_op, i_var); CPPAD_ASSERT_UNKNOWN( i_op < play->num_op_rec() ); } // action depends on the operator switch( op ) { case AbsOp: forward_abs_op(p, q, i_var, 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, 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, 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, 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, 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, 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, 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, arg[0], J, taylor); break; // --------------------------------------------------- case CoshOp: // sinh(x), cosh(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); forward_cosh_op(p, q, i_var, arg[0], J, taylor); break; // ------------------------------------------------- case CSkipOp: // CSkipOp has a variable number of arguments and // forward_next thinks it has no arguments. // we must inform forward_next of this special case. if( p == 0 ) { forward_cskip_op_0( i_var, arg, num_par, parameter, J, taylor, cskip_op ); } play->forward_cskip(op, arg, i_op, i_var); break; // ------------------------------------------------- case CSumOp: // CSumOp has a variable number of arguments and // forward_next thinks it has no arguments. // we must inform forward_next of this special case. forward_csum_op( p, q, i_var, arg, num_par, parameter, J, taylor ); play->forward_csum(op, arg, i_op, i_var); 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 EqpvOp: if( ( p == 0 ) & ( compare_change_count > 0 ) ) { forward_eqpv_op_0( compare_change_number, arg, parameter, J, taylor ); if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } break; // ------------------------------------------------- case EqvvOp: if( ( p == 0 ) & ( compare_change_count > 0 ) ) { forward_eqvv_op_0( compare_change_number, arg, parameter, J, taylor ); if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } break; // ------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 case ErfOp: CPPAD_ASSERT_UNKNOWN( CPPAD_USE_CPLUSPLUS_2011 ); // 2DO: implement zero order version of this function forward_erf_op(p, q, i_var, arg, parameter, J, taylor); break; # endif // ------------------------------------------------- case ExpOp: forward_exp_op(p, q, i_var, arg[0], J, taylor); break; // --------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 case Expm1Op: forward_expm1_op(p, q, i_var, arg[0], J, taylor); break; # endif // --------------------------------------------------- case InvOp: CPPAD_ASSERT_NARG_NRES(op, 0, 1); 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 LepvOp: if( ( p == 0 ) & ( compare_change_count > 0 ) ) { forward_lepv_op_0( compare_change_number, arg, parameter, J, taylor ); if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } break; case LevpOp: if( ( p == 0 ) & ( compare_change_count > 0 ) ) { forward_levp_op_0( compare_change_number, arg, parameter, J, taylor ); if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } break; // ------------------------------------------------- case LevvOp: if( ( p == 0 ) & ( compare_change_count > 0 ) ) { forward_levv_op_0( compare_change_number, arg, parameter, J, taylor ); if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } break; // ------------------------------------------------- case LogOp: forward_log_op(p, q, i_var, arg[0], J, taylor); break; // ------------------------------------------------- # if CPPAD_USE_CPLUSPLUS_2011 case Log1pOp: forward_log1p_op(p, q, i_var, arg[0], J, taylor); break; # endif // ------------------------------------------------- case LtpvOp: if( ( p == 0 ) & ( compare_change_count > 0 ) ) { forward_ltpv_op_0( compare_change_number, arg, parameter, J, taylor ); if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } break; case LtvpOp: if( ( p == 0 ) & ( compare_change_count > 0 ) ) { forward_ltvp_op_0( compare_change_number, arg, parameter, J, taylor ); if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } break; // ------------------------------------------------- case LtvvOp: if( ( p == 0 ) & ( compare_change_count > 0 ) ) { forward_ltvv_op_0( compare_change_number, arg, parameter, J, taylor ); if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } break; // ------------------------------------------------- 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 NepvOp: if( ( p == 0 ) & ( compare_change_count > 0 ) ) { forward_nepv_op_0( compare_change_number, arg, parameter, J, taylor ); if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } break; // ------------------------------------------------- case NevvOp: if( ( p == 0 ) & ( compare_change_count > 0 ) ) { forward_nevv_op_0( compare_change_number, arg, parameter, J, taylor ); if( compare_change_count == compare_change_number ) compare_change_op_index = i_op; } break; // ------------------------------------------------- case ParOp: i = p; if( i == 0 ) { forward_par_op_0( i_var, arg, num_par, parameter, J, taylor ); i++; } while(i <= q) { taylor[ i_var * J + i] = Base(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, arg[0], J, taylor); break; // ------------------------------------------------- case SinOp: // cos(x), sin(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); forward_sin_op(p, q, i_var, arg[0], J, taylor); break; // ------------------------------------------------- case SinhOp: // cosh(x), sinh(x) CPPAD_ASSERT_UNKNOWN( i_var < numvar ); forward_sinh_op(p, q, i_var, arg[0], J, taylor); break; // ------------------------------------------------- case SqrtOp: forward_sqrt_op(p, q, i_var, 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, 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, arg[0], J, taylor); break; // ------------------------------------------------- case UserOp: // start or end an atomic operation sequence CPPAD_ASSERT_UNKNOWN( NumRes( UserOp ) == 0 ); CPPAD_ASSERT_UNKNOWN( NumArg( UserOp ) == 4 ); if( user_state == user_start ) { user_index = arg[0]; user_id = arg[1]; user_n = arg[2]; user_m = arg[3]; user_atom = atomic_base::class_object(user_index); # ifndef NDEBUG if( user_atom == CPPAD_NULL ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base function has been deleted"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif if(user_tx.size() != user_n * user_q1) user_tx.resize(user_n * user_q1); if(user_ty.size() != user_m * user_q1) user_ty.resize(user_m * user_q1); if(user_iy.size() != user_m) user_iy.resize(user_m); user_j = 0; user_i = 0; user_state = user_arg; } else { CPPAD_ASSERT_UNKNOWN( user_state == user_end ); CPPAD_ASSERT_UNKNOWN( user_index == size_t(arg[0]) ); CPPAD_ASSERT_UNKNOWN( user_id == size_t(arg[1]) ); CPPAD_ASSERT_UNKNOWN( user_n == size_t(arg[2]) ); CPPAD_ASSERT_UNKNOWN( user_m == size_t(arg[3]) ); // call users function for this operation user_atom->set_id(user_id); CPPAD_ATOMIC_CALL( p, q, user_vx, user_vy, user_tx, user_ty ); # ifndef NDEBUG if( ! user_ok ) { std::string msg = atomic_base::class_name(user_index) + ": atomic_base.forward: returned false"; CPPAD_ASSERT_KNOWN(false, msg.c_str() ); } # endif for(i = 0; i < user_m; i++) if( user_iy[i] > 0 ) for(k = p; k <= q; k++) taylor[ user_iy[i] * J + k ] = user_ty[ i * user_q1 + k ]; # if CPPAD_FORWARD1SWEEP_TRACE user_state = user_trace; # else user_state = user_start; # endif } break; case UsrapOp: // parameter argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( user_j < user_n ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); user_tx[user_j * user_q1 + 0] = parameter[ arg[0]]; for(k = 1; k < user_q1; k++) user_tx[user_j * user_q1 + k] = Base(0); ++user_j; if( user_j == user_n ) user_state = user_ret; break; case UsravOp: // variable argument in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_arg ); CPPAD_ASSERT_UNKNOWN( user_j < user_n ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) <= i_var ); for(k = 0; k < user_q1; k++) user_tx[user_j * user_q1 + k] = taylor[ arg[0] * J + k]; ++user_j; if( user_j == user_n ) user_state = user_ret; break; case UsrrpOp: // parameter result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( user_i < user_m ); user_iy[user_i] = 0; user_ty[user_i * user_q1 + 0] = parameter[ arg[0]]; for(k = 1; k < p; k++) user_ty[user_i * user_q1 + k] = Base(0); user_i++; if( user_i == user_m ) user_state = user_end; break; case UsrrvOp: // variable result in an atomic operation sequence CPPAD_ASSERT_UNKNOWN( user_state == user_ret ); CPPAD_ASSERT_UNKNOWN( user_i < user_m ); user_iy[user_i] = i_var; for(k = 0; k < p; k++) user_ty[user_i * user_q1 + k] = taylor[ i_var * J + k]; user_i++; if( user_i == user_m ) user_state = user_end; 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_FORWARD1SWEEP_TRACE if( user_state == user_trace ) { user_state = user_start; CPPAD_ASSERT_UNKNOWN( op == UserOp ); CPPAD_ASSERT_UNKNOWN( NumArg(UsrrvOp) == 0 ); for(i = 0; i < user_m; i++) if( user_iy[i] > 0 ) { size_t i_tmp = (i_op + i) - user_m; printOp( std::cout, play, i_tmp, user_iy[i], UsrrvOp, CPPAD_NULL ); Base* Z_tmp = taylor + user_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; const addr_t* arg_tmp = arg; if( op == CSumOp ) arg_tmp = arg - arg[-1] - 4; if( op == CSkipOp ) arg_tmp = arg - arg[-1] - 7; if( op != UsrrvOp ) { printOp( std::cout, play, i_op, i_var, op, arg_tmp ); 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( user_state == user_start ); CPPAD_ASSERT_UNKNOWN( i_var + 1 == play->num_var_rec() ); if( (p == 0) & (compare_change_count == 0) ) compare_change_number = 0; return; } // preprocessor symbols that are local to this file # undef CPPAD_FORWARD1SWEEP_TRACE # undef CPPAD_ATOMIC_CALL } // END_CPPAD_NAMESPACE # endif cppad-20160000.1/cppad/local/bool_fun.hpp0000644000175200017650000001442112656321770017127 0ustar coincoin-web// $Id: bool_fun.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_BOOL_FUN_HPP # define CPPAD_BOOL_FUN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin BoolFun$$ $spell namespace bool CppAD const $$ $section AD Boolean Functions$$ $mindex bool CPPAD_BOOL_UNARY CPPAD_BOOL_BINARY$$ $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/bool_fun.cpp %$$ The file $cref bool_fun.cpp$$ contains an example and test of these operations. It returns true if it succeeds and false otherwise. $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., \c 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 inline bool AD::UnaryBool( bool FunName(const Base &x), const AD &x ) { return FunName(x.value_); } /*! Macro that defines a binary function bool F(AD x, AD y) 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., \c 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 inline 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 cppad-20160000.1/cppad/local/pow.hpp0000644000175200017650000001621012656321770016127 0ustar coincoin-web// $Id: pow.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_POW_HPP # define CPPAD_POW_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin pow$$ $spell Vec std namespace CppAD const $$ $section The AD Power Function$$ $mindex pow exponent$$ $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/pow.cpp %$$ The file $cref pow.cpp$$ is an examples and tests of this function. It returns true if it succeeds and false otherwise. $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 ADTape* tape = AD::tape_ptr(); if( tape == CPPAD_NULL ) return result; tape_id_t tape_id = tape->id_; // tape_id cannot match the default value for tape_id_; i.e., 0 CPPAD_ASSERT_UNKNOWN( tape_id > 0 ); bool var_x = x.tape_id_ == tape_id; bool var_y = y.tape_id_ == tape_id; if( var_x ) { if( var_y ) { // result = variable^variable CPPAD_ASSERT_UNKNOWN( NumRes(PowvvOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumArg(PowvvOp) == 2 ); // put operand addresses in tape tape->Rec_.PutArg(x.taddr_, y.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(PowvvOp); // make result a variable result.tape_id_ = tape_id; } else if( IdenticalZero( y.value_ ) ) { // result = variable^0 } else { // result = variable^parameter CPPAD_ASSERT_UNKNOWN( NumRes(PowvpOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumArg(PowvpOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(y.value_); tape->Rec_.PutArg(x.taddr_, p); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(PowvpOp); // make result a variable result.tape_id_ = tape_id; } } else if( var_y ) { if( IdenticalZero(x.value_) ) { // result = 0^variable } else { // result = parameter^variable CPPAD_ASSERT_UNKNOWN( NumRes(PowpvOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumArg(PowpvOp) == 2 ); // put operand addresses in tape addr_t p = tape->Rec_.PutPar(x.value_); tape->Rec_.PutArg(p, y.taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(PowpvOp); // make result a variable result.tape_id_ = tape_id; } } 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/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 cppad-20160000.1/cppad/example/0002755000175200017650000000000012656321770015154 5ustar coincoin-webcppad-20160000.1/cppad/example/matrix_mul.hpp0000644000175200017650000003573512656321770020061 0ustar coincoin-web// $Id: matrix_mul.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_MATRIX_MUL_HPP # define CPPAD_MATRIX_MUL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin atomic_matrix_mul.hpp$$ $spell $$ $section Matrix Multiply as an Atomic Operation$$ $nospell $head Start Class Definition$$ $codep */ # include namespace { // Begin empty namespace using CppAD::vector; // void my_union( std::set& result , const std::set& left , const std::set& right ) { std::set temp; std::set_union( left.begin() , left.end() , right.begin() , right.end() , std::inserter(temp, temp.begin()) ); result.swap(temp); } // // matrix result = left * right class matrix_mul : public CppAD::atomic_base { /* $$ $head Constructor$$ $codep */ private: // number of rows in left operand and in the result const size_t nr_result_; // number of columns in left operand and rows in right operand const size_t n_middle_; // number of columns in right operand and in the result const size_t nc_result_; // dimension of the domain space const size_t n_; // dimension of the range space # ifndef NDEBUG const size_t m_; # endif public: // --------------------------------------------------------------------- // constructor matrix_mul(size_t nr_result, size_t n_middle, size_t nc_result) : CppAD::atomic_base("matrix_mul"), nr_result_(nr_result) , n_middle_(n_middle) , nc_result_(nc_result) , n_( nr_result * n_middle + n_middle * nc_result ) # ifndef NDEBUG , m_( n_middle * nc_result ) # endif { } private: /* $$ $head Left Operand Element Index$$ $codep */ // left matrix element index in the taylor coefficient vector tx. 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 { assert( i < nr_result_ ); assert( j < n_middle_ ); return (i * n_middle_ + j) * nk + k; } /* $$ $head Right Operand Element Index$$ $codep */ // right matrix element index in the taylor coefficient vector tx. 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 { assert( i < n_middle_ ); assert( j < nc_result_ ); size_t offset = nr_result_ * n_middle_; return (offset + i * nc_result_ + j) * nk + k; } /* $$ $head Result Element Index$$ $codep */ // result matrix element index in the taylor coefficient vector ty. 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 { assert( i < nr_result_ ); assert( j < nc_result_ ); return (i * nc_result_ + j) * nk + k; } /* $$ $head Forward Matrix Multipliy$$ $codep */ // 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& tx , // domain space Taylor coefficients vector& ty ) // range space Taylor coefficients { size_t nk = tx.size() / n_; assert( nk == ty.size() / m_ ); // size_t k_result = k_left + k_right; assert( k_result < nk ); // for(size_t i = 0; i < nr_result_; i++) { for(size_t j = 0; j < nc_result_; j++) { double sum = 0.0; for(size_t ell = 0; ell < n_middle_; ell++) { size_t i_left = left(i, ell, k_left, nk); size_t i_right = right(ell, j, k_right, nk); sum += tx[i_left] * tx[i_right]; } size_t i_result = result(i, j, k_result, nk); ty[i_result] += sum; } } } /* $$ $head Reverse Matrix Multipliy$$ $codep */ // 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& 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 nk = tx.size() / n_; assert( nk == ty.size() / m_ ); 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_result_; i++) { for(size_t j = 0; j < nc_result_; j++) { size_t i_result = result(i, j, k_result, nk); for(size_t ell = 0; ell < n_middle_; ell++) { size_t i_left = left(i, ell, k_left, nk); size_t i_right = right(ell, j, k_right, nk); // 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$$ $codep */ // forward mode routine called by CppAD bool forward( size_t q , size_t p , const vector& vx , vector& vy , const vector& tx , vector& ty ) { size_t p1 = p + 1; assert( vx.size() == 0 || n_ == vx.size() ); assert( vx.size() == 0 || m_ == vy.size() ); assert( n_ * p1 == tx.size() ); assert( m_ * p1 == 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_result_; i++) { for(j = 0; j < nc_result_; j++) { bool var = false; for(ell = 0; ell < n_middle_; ell++) { size_t i_left = left(i, ell, k, nk); size_t i_right = right(ell, j, k, nk); 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); vy[i_result] = var; } } } // initialize result as zero size_t k; for(i = 0; i < nr_result_; i++) { for(j = 0; j < nc_result_; j++) { for(k = q; k <= p; k++) ty[ result(i, j, k, p1) ] = 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); } // all orders are implented, so always return true return true; } /* $$ $head reverse$$ $codep */ // reverse mode routine called by CppAD virtual bool reverse( size_t p , const vector& tx , const vector& ty , vector& px , const vector& py ) { size_t p1 = p + 1; assert( n_ * p1 == tx.size() ); assert( m_ * p1 == 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 = p1; 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); } // all orders are implented, so always return true return true; } /* $$ $head for_sparse_jac$$ $codep */ // forward Jacobian sparsity routine called by CppAD virtual bool for_sparse_jac( size_t q , const vector& r , vector& s ) { assert( n_ * q == r.size() ); assert( m_ * 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_result_; i++) { for(size_t j = 0; j < nc_result_; j++) { size_t i_result = result(i, j, k, nk); for(p = 0; p < q; p++) s[i_result * q + p] = false; for(size_t ell = 0; ell < n_middle_; ell++) { size_t i_left = left(i, ell, k, nk); size_t i_right = right(ell, j, k, nk); for(p = 0; p < q; p++) { // 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; } virtual bool for_sparse_jac( size_t q , const vector< std::set >& r , vector< std::set >& s ) { assert( n_ == r.size() ); assert( m_ == s.size() ); // sparsity for S(x) = f'(x) * R size_t nk = 1; size_t k = 0; for(size_t i = 0; i < nr_result_; i++) { for(size_t j = 0; j < nc_result_; j++) { size_t i_result = result(i, j, k, nk); s[i_result].clear(); for(size_t ell = 0; ell < n_middle_; ell++) { size_t i_left = left(i, ell, k, nk); size_t i_right = right(ell, j, k, nk); // my_union( s[i_result], s[i_result], r[i_left] ); my_union( s[i_result], s[i_result], r[i_right] ); } } } return true; } /* $$ $head rev_sparse_jac$$ $codep */ // reverse Jacobian sparsity routine called by CppAD virtual bool rev_sparse_jac( size_t q , const vector& rt , vector& st ) { assert( n_ * q == st.size() ); assert( m_ * q == rt.size() ); size_t i, j, p; // initialize for(i = 0; i < n_; 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_result_; i++) { for(j = 0; j < nc_result_; j++) { size_t i_result = result(i, j, k, nk); for(size_t ell = 0; ell < n_middle_; ell++) { size_t i_left = left(i, ell, k, nk); size_t i_right = right(ell, j, k, nk); for(p = 0; p < q; p++) { st[i_left * q + p] |= bool( rt[i_result * q + p] ); st[i_right* q + p] |= bool( rt[i_result * q + p] ); } } } } return true; } virtual bool rev_sparse_jac( size_t q , const vector< std::set >& rt , vector< std::set >& st ) { assert( n_ == st.size() ); assert( m_ == rt.size() ); size_t i, j; // initialize for(i = 0; i < n_; 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_result_; i++) { for(j = 0; j < nc_result_; j++) { size_t i_result = result(i, j, k, nk); for(size_t ell = 0; ell < n_middle_; ell++) { size_t i_left = left(i, ell, k, nk); size_t i_right = right(ell, j, k, nk); // my_union(st[i_left], st[i_left], rt[i_result]); my_union(st[i_right], st[i_right], rt[i_result]); } } } return true; } /* $$ $head rev_sparse_hes$$ $codep */ // reverse Hessian sparsity routine called by CppAD virtual bool rev_sparse_hes( const vector& vx, const vector& s , vector& t , size_t q , const vector< std::set >& r , const vector< std::set >& u , vector< std::set >& v ) { size_t n = vx.size(); assert( t.size() == n ); assert( r.size() == n ); assert( v.size() == n ); # ifndef NDEBUG size_t m = s.size(); assert( u.size() == m ); # endif size_t i, j; // // initilaize sparsity patterns as false for(j = 0; j < n; j++) { t[j] = false; v[j].clear(); } size_t nk = 1; size_t k = 0; for(i = 0; i < nr_result_; i++) { for(j = 0; j < nc_result_; j++) { size_t i_result = result(i, j, k, nk); for(size_t ell = 0; ell < n_middle_; ell++) { size_t i_left = left(i, ell, k, nk); size_t i_right = right(ell, j, k, nk); // // 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) my_union(v[i_left], v[i_left], u[i_result] ); my_union(v[i_right], 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] ) { my_union(v[i_left], v[i_left], r[i_right] ); my_union(v[i_right], v[i_right], r[i_left] ); } } } } return true; } virtual bool rev_sparse_hes( const vector& vx, const vector& s , vector& t , size_t q , const vector& r , const vector& u , vector& v ) { size_t n = vx.size(); assert( t.size() == n ); assert( r.size() == n * q ); assert( v.size() == n * q ); # ifndef NDEBUG size_t m = s.size(); assert( u.size() == m * q ); # endif size_t i, j, p; // // initilaize sparsity patterns as false for(j = 0; j < n; 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_result_; i++) { for(j = 0; j < nc_result_; j++) { size_t i_result = result(i, j, k, nk); for(size_t ell = 0; ell < n_middle_; ell++) { size_t i_left = left(i, ell, k, nk); size_t i_right = right(ell, j, k, nk); // // 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$$ $codep */ }; // End of matrix_mul class } // End empty namespace /* $$ $$ $comment end nospell$$ $end */ # endif cppad-20160000.1/cppad/example/eigen_plugin.hpp0000644000175200017650000000160012656321770020325 0ustar coincoin-web// $Id: eigen_plugin.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_EIGEN_PLUGIN_HPP # define CPPAD_EIGEN_PLUGIN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /*$ $begin eigen_plugin.hpp$$ $spell eigen_plugin.hpp typedef $$ $section Source Code for eigen_plugin.hpp$$ $codep */ // Declaration needed so an Eigen vector is a simple vector typedef Scalar value_type; /* $$ $end */ # endif cppad-20160000.1/cppad/example/base_adolc.hpp0000644000175200017650000001666412656321770017754 0ustar coincoin-web// $Id: base_adolc.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_BASE_ADOLC_HPP # define CPPAD_BASE_ADOLC_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin base_adolc.hpp$$ $spell 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/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. It returns true if it succeeds and false otherwise. 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: $codep */ # 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). $codep */ 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 $codep */ namespace CppAD { CPPAD_COND_EXP_REL(adouble) } /* $$ $head EqualOpSeq$$ The Adolc user interface does not specify a way to determine if two $code adouble$$ variables correspond to the same operations sequence. Make $code EqualOpSeq$$ an error if it gets used: $codep */ 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. $codep */ 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; } } /* $$ $head Integer$$ $codep */ inline int Integer(const adouble &x) { return static_cast( x.getValue() ); } /* $$ $head azmul$$ $codep */ namespace CppAD { CPPAD_AZMUL( adouble ) } /* $$ $head Ordered$$ $codep */ 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: $codep */ 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$$. $codep */ 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: $codep */ 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$$: $codep */ namespace CppAD { CPPAD_NUMERIC_LIMITS(double, adouble) } /* $$ $end */ # endif cppad-20160000.1/cppad/example/cppad_eigen.hpp0000644000175200017650000001106412656321770020123 0ustar coincoin-web// $Id: cppad_eigen.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_CPPAD_EIGEN_HPP # define CPPAD_CPPAD_EIGEN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin cppad_eigen.hpp$$ $spell impl typename Real Real inline neg eps plugin 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% cppad/example/eigen_plugin.hpp% example/eigen_array.cpp% example/eigen_det.cpp %$$ $head Purpose$$ Enables the use of the $href%http://eigen.tuxfamily.org%eigen%$$ linear algebra package with the type $icode%AD<%Base%>%$$. $head Example$$ The files $cref eigen_array.cpp$$ and $cref eigen_det.cpp$$ contain an example and test of this include file. It returns true if it succeeds and false otherwise. $head Include Files$$ The file $code cppad_eigen.hpp$$ includes both $code $$ and $code $$. In addition, The file $cref eigen_plugin.hpp$$ is used to define $code value_type$$ in the Eigen matrix class definition so its vectors are $cref/simple vectors/SimpleVector/$$. $codep */ # define EIGEN_MATRIXBASE_PLUGIN # include # include /* $$ $head Eigen NumTraits$$ Eigen needs the following definitions to work properly with $codei%AD<%Base%>%$$ scalars: $codep */ 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 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(); } }; } /* $$ $head CppAD Namespace$$ Eigen also needs the following definitions to work properly with $codei%AD<%Base%>%$$ scalars: $codep */ 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; } } namespace Eigen { namespace internal { template struct significant_decimals_default_impl< CppAD::AD, false> { typedef CppAD::AD Scalar; typedef typename NumTraits::Real RealScalar; static inline int run() { Scalar neg_log_eps = - log( NumTraits::epsilon() ); int ceil_neg_log_eps = Integer( neg_log_eps ); if( Scalar(ceil_neg_log_eps) < neg_log_eps ) ceil_neg_log_eps++; return ceil_neg_log_eps; } }; } } /* $$ $end */ # endif cppad-20160000.1/cppad/ipopt/0002755000175200017650000000000012656321770014654 5ustar coincoin-webcppad-20160000.1/cppad/ipopt/solve_callback.hpp0000644000175200017650000010257012656321770020334 0ustar coincoin-web// $Id: solve_callback.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SOLVE_CALLBACK_HPP # define CPPAD_SOLVE_CALLBACK_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include # include 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 \c values is not \c NULL, \c values is a vector with size \c nele_jac. The input value of its elements does not matter. On output, For k = 0 , ... , nele_jac-1, values[k] is the value for the 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 cppad-20160000.1/cppad/ipopt/solve_result.hpp0000644000175200017650000000365612656321770020123 0ustar coincoin-web// $Id: solve_result.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SOLVE_RESULT_HPP # define CPPAD_SOLVE_RESULT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ namespace CppAD { // BEGIN_CPPAD_NAMESPACE 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 cppad-20160000.1/cppad/ipopt/solve.hpp0000644000175200017650000004111112656321770016511 0ustar coincoin-web// $Id: solve.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SOLVE_HPP # define CPPAD_SOLVE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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 cppad-20160000.1/compare_c/0002755000175200017650000000000012656321770014362 5ustar coincoin-webcppad-20160000.1/compare_c/makefile.in0000644000175200017650000005215612656321770016476 0ustar coincoin-web# 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 = det_by_minor_c$(EXEEXT) det_by_minor_cpp$(EXEEXT) subdir = compare_c 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_det_by_minor_c_OBJECTS = det_by_minor_c.$(OBJEXT) det_by_minor_c_OBJECTS = $(am_det_by_minor_c_OBJECTS) det_by_minor_c_LDADD = $(LDADD) am_det_by_minor_cpp_OBJECTS = det_by_minor_cpp.$(OBJEXT) det_by_minor_cpp_OBJECTS = $(am_det_by_minor_cpp_OBJECTS) det_by_minor_cpp_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 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 = 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 = $(det_by_minor_c_SOURCES) $(det_by_minor_cpp_SOURCES) DIST_SOURCES = $(det_by_minor_c_SOURCES) $(det_by_minor_cpp_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@ # # erase configures choice of flags DEFS = DEPDIR = @DEPDIR@ DL_LIB = @DL_LIB@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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 = -O2 -DNDEBUG AM_CFLAGS = -O2 -DNDEBUG # det_by_minor_c_SOURCES = det_by_minor_c.c det_by_minor_cpp_SOURCES = det_by_minor_cpp.cpp all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .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) --gnu compare_c/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu compare_c/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) det_by_minor_c$(EXEEXT): $(det_by_minor_c_OBJECTS) $(det_by_minor_c_DEPENDENCIES) $(EXTRA_det_by_minor_c_DEPENDENCIES) @rm -f det_by_minor_c$(EXEEXT) $(AM_V_CCLD)$(LINK) $(det_by_minor_c_OBJECTS) $(det_by_minor_c_LDADD) $(LIBS) det_by_minor_cpp$(EXEEXT): $(det_by_minor_cpp_OBJECTS) $(det_by_minor_cpp_DEPENDENCIES) $(EXTRA_det_by_minor_cpp_DEPENDENCIES) @rm -f det_by_minor_cpp$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(det_by_minor_cpp_OBJECTS) $(det_by_minor_cpp_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_by_minor_c.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_by_minor_cpp.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .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: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: makefile installdirs: install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) 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: all check check-am install 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 det_by_minor_c.c: det_by_minor.c cp $(srcdir)/det_by_minor.c det_by_minor_c.c det_by_minor_cpp.cpp: det_by_minor.c cp $(srcdir)/det_by_minor.c det_by_minor_cpp.cpp # test: det_by_minor_c det_by_minor_cpp echo "Running version compiled using C compiler" ./det_by_minor_c echo "Running version compiled using C++ compiler" ./det_by_minor_cpp # 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: cppad-20160000.1/compare_c/makefile.am0000644000175200017650000000257112656321770016461 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 # See ./CMakeLists.txt for specifications. # BUILT_SOURCES = det_by_minor_c.c det_by_minor_cpp.cpp det_by_minor_c.c: det_by_minor.c cp $(srcdir)/det_by_minor.c det_by_minor_c.c 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 = -O2 -DNDEBUG AM_CFLAGS = -O2 -DNDEBUG # check_PROGRAMS = det_by_minor_c det_by_minor_cpp # det_by_minor_c_SOURCES = det_by_minor_c.c det_by_minor_cpp_SOURCES = det_by_minor_cpp.cpp # test: det_by_minor_c det_by_minor_cpp echo "Running version compiled using C compiler" ./det_by_minor_c echo "Running version compiled using C++ compiler" ./det_by_minor_cpp cppad-20160000.1/compare_c/det_by_minor.c0000644000175200017650000003466712656321770017216 0ustar coincoin-web/* $Id: */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include # include # include // In the case of plain C, we defined the type bool together with ture, false # ifndef __cplusplus # define bool int # define true 1 # define false 0 # endif /* ------------------------------------------------------------------------------- $begin det_of_minor_c$$ $spell det const $$ $section Determinant of a Minor$$ $head Syntax$$ $icode%d% = det_of_minor(%a%, %m%, %n%, %r%, %c%)%$$ $head Purpose$$ 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 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 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] \] $$ $head m$$ The argument $icode m$$ has prototype $codei% 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% %$$ and is the size of the square minor $latex M$$. $head r$$ The argument $icode r$$ has prototype $codei% size_t* %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% size_t* %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% double %d% %$$ and is equal to the determinant of the minor $latex M$$. $spell Cj $$ $head Source Code$$ $codep */ 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; } /* $$ $end ------------------------------------------------------------------------------- $begin det_by_minor_c$$ $spell det const $$ $section Compute Determinant using Expansion by Minors$$ $head Syntax$$ $icode%d% = det_by_minor(%a%, %n%)%$$ $head Purpose$$ returns the determinant 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_{i, j} \]$$ $head a$$ The argument $icode a$$ has prototype $codei% 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] \] $$ $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$$. $hilitecmd%codep%$$ $hiliteseq% %det_of_minor%(%det_of_minor_c %$$ $spell det malloc sizeof $$ $head Source Code$$ $codep */ 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; } /* $$ $end -------------------------------------------------------------------------- $begin uniform_01_c$$ $section Simulate a [0,1] Uniform Random Variate$$ $head Syntax$$ $codei%random_seed(%seed%) %$$ $codei%uniform_01(%n%, %a%)%$$ $head Purpose$$ This routine is used to create random values for speed testing purposes. $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 a$$. $head a$$ The argument $icode a$$ has prototype $codei% 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 randomly sampled over the interval [0,1]. $hilitecmd%codep%$$ $hiliteseq% %elapsed_seconds%(%elapsed_seconds_c% %repeat_det_by_minor%(%elapsed_seconds_c %$$ $spell srand $$ $head Source Code$$ $codep */ void random_seed(size_t seed) { srand(seed); } void uniform_01(unsigned n, double* a) { static double factor = 1. / (double) RAND_MAX; while(n--) a[n] = rand() * factor; } /* $$ $end ------------------------------------------------------------------------------ $begin correct_det_by_minor_c$$ $spell det bool $$ $section Correctness Test of det_by_minor Routine$$ $head Syntax$$ $icode%flag% = correct_det_by_minor()%$$ $head flag$$ The return value has prototype $codei% 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 %$$ $spell fabs $$ $head Source Code$$ $codep */ 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] ); if( fabs(det / check - 1.0) < 1e-10 ) return true; return false; } /* $$ $end ------------------------------------------------------------------------------ $begin repeat_det_by_minor_c$$ $spell det $$ $section Repeat det_by_minor Routine A Specified Number of Times$$ $head Syntax$$ $codei%repeat_det_by_minor(%repeat%, %size%)%$$ $head repeat$$ The argument has prototype $codei% size_t %repeat% %$$ It specifies the number of times to repeat the calculation. $head size$$ The argument has prototype $codei% 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 %$$ $spell malloc sizeof $$ $head Source Code$$ $codep */ 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; } /* $$ $end ------------------------------------------------------------------------------ $begin elapsed_seconds_c$$ $spell gettimeofday $$ $section Returns Elapsed Number of Seconds$$ $head Syntax$$ $icode%s% = elapsed_seconds()%$$ $head Purpose$$ This routine is accurate to within .02 seconds It does not necessary work for time intervals that are greater than a day. $head s$$ is a $code double$$ equal to the number of seconds since the first call to $code elapsed_seconds$$. $spell Microsoft cassert milli sys endif usec diff bool struct timeval $$ $head Source Code$$ $codep */ # if _MSC_VER // --------------------------------------------------------------------------- // Microsoft version of timer # 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. ); return diff; } # else // --------------------------------------------------------------------------- // Unix version of timer # include 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 /* $$ $end ----------------------------------------------------------------------------- $begin time_det_by_minor_c$$ $spell det $$ $section Determine Amount of Time to Execute det_by_minor$$ $head Syntax$$ $icode%time% = time_test(%size%, %time_min%)%$$ $head Purpose$$ reports the amount of wall clock time for $code det_by_minor$$ to compute the determinant of a square matrix. The $icode size$$ has prototype $codei% size_t %size% %$$ It specifies the number of rows (and columns) in the square matrix that the determinant is being calculated for. $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 calculations is repeated the necessary number of times so that this amount of execution time (or more) is reached. $head time$$ The return value $icode time$$ has prototype $codei% double %time% %$$ and is the number of wall clock seconds that it took for $code det_by_minor$$ to compute its determinant (plus overhead which includes choosing a random matrix). $hilitecmd%codep%$$ $hiliteseq% %elapsed_seconds%(%elapsed_seconds_c% %repeat_det_by_minor%(%elapsed_seconds_c %$$ $spell det $$ $head Source Code$$ $codep */ 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; } /* $$ $end ------------------------------------------------------------------------------ $begin main_compare_c$$ $section Main Program For Comparing C and C++ Speed$$ $hilitecmd%codep%$$ $hiliteseq% %correct_det_by_minor%(%correct_det_by_minor_c% %random_seed%(%uniform_01_c %$$ $spell bool printf det $$ $head Source Code$$ $codep */ 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; } /* $$ $end */ cppad-20160000.1/compare_c/CMakeLists.txt0000644000175200017650000000426012656321770017122 0ustar coincoin-web# $Id: CMakeLists.txt 2581 2012-11-18 00:55:01Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # $begin compare_c$$ $newlinech #$$ # $spell # det # cpp # $$ # # $section Compare Speed of C and C++$$ # $index compare, speed C and C++$$ # $index speed, compare C and C++$$ # $index C, compare speed with C++$$ # $index C++, compare speed with C$$ # # $head Syntax$$ # $codei%compare_c/det_by_minor_c # %$$ # $codei compare_c/det_by_minor_cpp$$ # # $head Purpose$$ # Compares the speed of the exact same source code compiled # using C versus C++. # # $childtable% # compare_c/det_by_minor.c # %$$ # # $end # ----------------------------------------------------------------------------- # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE RELEASE) # 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) add_cppad_cxx_flags(det_by_minor_${com}) 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} ) ENDFOREACH(com) # Add the check_compare_c target ADD_CUSTOM_TARGET( check_compare_c DEPENDS check_det_by_minor_c check_det_by_minor_cpp ) cppad-20160000.1/config.guess0000755000175200017650000012367212561675772014774 0ustar coincoin-web#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # 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 . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: cppad-20160000.1/config.sub0000755000175200017650000010624612561675772014435 0ustar coincoin-web#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # 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 . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-* | ppc64p7-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: cppad-20160000.1/speed/0002755000175200017650000000000012656321771013533 5ustar coincoin-webcppad-20160000.1/speed/add_test.sh0000755000175200017650000000442012656321770015656 0ustar coincoin-web#! /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. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # 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). # echo "Change this script so that it automates the omhelp commands" echo "at the beginning of the created files." echo exit 1 # 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 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 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 fi list=" 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 done # sed -i main.cpp -e "s/speed\/link[^%]*\$/&%\n\tspeed\/link_$test_name.cpp/" # copy=`sed -n ../COPYING -e '/^\/\*/,/\*\/$/p'` link=`sed -n link_$test_name.cpp -e "/^ *extern *bool *link_$test_name/,/^);/p"` 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 \\\\/" 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 \\\\/" cppad-20160000.1/speed/profile/0002755000175200017650000000000012656321770015172 5ustar coincoin-webcppad-20160000.1/speed/profile/makefile.in0000644000175200017650000005500112656321770017276 0ustar coincoin-web# 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 = speed_profile$(EXEEXT) subdir = speed/profile ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = gprof.sed CONFIG_CLEAN_VPATH_FILES = am__objects_1 = main.$(OBJEXT) ode.$(OBJEXT) det_lu.$(OBJEXT) \ det_minor.$(OBJEXT) mat_mul.$(OBJEXT) poly.$(OBJEXT) \ sparse_hessian.$(OBJEXT) sparse_jacobian.$(OBJEXT) \ link_det_lu.$(OBJEXT) link_det_minor.$(OBJEXT) \ link_mat_mul.$(OBJEXT) link_ode.$(OBJEXT) link_poly.$(OBJEXT) \ link_sparse_hessian.$(OBJEXT) link_sparse_jacobian.$(OBJEXT) \ microsoft_timer.$(OBJEXT) am_speed_profile_OBJECTS = $(am__objects_1) speed_profile_OBJECTS = $(am_speed_profile_OBJECTS) speed_profile_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 = $(speed_profile_SOURCES) DIST_SOURCES = $(speed_profile_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)/gprof.sed.in $(srcdir)/makefile.in \ $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ 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 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- source_list = \ main.cpp \ ode.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.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 # # 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 # # BEGIN DEBUG # AM_CXXFLAGS = -g $(CXX_FLAGS) -DCPPAD_PROFILE_SPEED # END DEBUG # AM_LDFLAGS = -pg # speed_profile_SOURCES = $(source_list) all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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) --gnu speed/profile/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/profile/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): gprof.sed: $(top_builddir)/config.status $(srcdir)/gprof.sed.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ clean-checkPROGRAMS: -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) speed_profile$(EXEEXT): $(speed_profile_OBJECTS) $(speed_profile_DEPENDENCIES) $(EXTRA_speed_profile_DEPENDENCIES) @rm -f speed_profile$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(speed_profile_OBJECTS) $(speed_profile_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_lu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_minor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_det_lu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_det_minor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_mat_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_ode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_poly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_sparse_hessian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_sparse_jacobian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mat_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/microsoft_timer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_hessian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_jacobian.Po@am__quote@ .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: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: makefile installdirs: install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) 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: all check check-am install 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 # main.cpp: $(srcdir)/../main.cpp cp $(srcdir)/../main.cpp main.cpp ode.cpp: $(srcdir)/../cppad/ode.cpp cp $(srcdir)/../cppad/ode.cpp ode.cpp det_lu.cpp: $(srcdir)/../cppad/det_lu.cpp cp $(srcdir)/../cppad/det_lu.cpp det_lu.cpp det_minor.cpp: $(srcdir)/../cppad/det_minor.cpp cp $(srcdir)/../cppad/det_minor.cpp det_minor.cpp mat_mul.cpp: $(srcdir)/../cppad/mat_mul.cpp cp $(srcdir)/../cppad/mat_mul.cpp mat_mul.cpp poly.cpp: $(srcdir)/../cppad/poly.cpp cp $(srcdir)/../cppad/poly.cpp poly.cpp sparse_hessian.cpp: $(srcdir)/../cppad/sparse_hessian.cpp cp $(srcdir)/../cppad/sparse_hessian.cpp sparse_hessian.cpp sparse_jacobian.cpp: $(srcdir)/../cppad/sparse_jacobian.cpp cp $(srcdir)/../cppad/sparse_jacobian.cpp sparse_jacobian.cpp link_det_lu.cpp: $(srcdir)/../src/link_det_lu.cpp cp $(srcdir)/../src/link_det_lu.cpp link_det_lu.cpp link_det_minor.cpp: $(srcdir)/../src/link_det_minor.cpp cp $(srcdir)/../src/link_det_minor.cpp link_det_minor.cpp link_mat_mul.cpp: $(srcdir)/../src/link_mat_mul.cpp cp $(srcdir)/../src/link_mat_mul.cpp link_mat_mul.cpp link_ode.cpp: $(srcdir)/../src/link_ode.cpp cp $(srcdir)/../src/link_ode.cpp link_ode.cpp link_poly.cpp: $(srcdir)/../src/link_poly.cpp cp $(srcdir)/../src/link_poly.cpp link_poly.cpp link_sparse_hessian.cpp: $(srcdir)/../src/link_sparse_hessian.cpp cp $(srcdir)/../src/link_sparse_hessian.cpp link_sparse_hessian.cpp link_sparse_jacobian.cpp: $(srcdir)/../src/link_sparse_jacobian.cpp cp $(srcdir)/../src/link_sparse_jacobian.cpp link_sparse_jacobian.cpp microsoft_timer.cpp: $(srcdir)/../src/microsoft_timer.cpp cp $(srcdir)/../src/microsoft_timer.cpp microsoft_timer.cpp # test: check ./speed_profile correct 123 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: cppad-20160000.1/speed/profile/makefile.am0000644000175200017650000000620112656321770017263 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- source_list = \ main.cpp \ ode.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.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 # # make separate copy of source files because building with different flags BUILT_SOURCES = $(source_list) # main.cpp: $(srcdir)/../main.cpp cp $(srcdir)/../main.cpp main.cpp ode.cpp: $(srcdir)/../cppad/ode.cpp cp $(srcdir)/../cppad/ode.cpp ode.cpp det_lu.cpp: $(srcdir)/../cppad/det_lu.cpp cp $(srcdir)/../cppad/det_lu.cpp det_lu.cpp det_minor.cpp: $(srcdir)/../cppad/det_minor.cpp cp $(srcdir)/../cppad/det_minor.cpp det_minor.cpp mat_mul.cpp: $(srcdir)/../cppad/mat_mul.cpp cp $(srcdir)/../cppad/mat_mul.cpp mat_mul.cpp poly.cpp: $(srcdir)/../cppad/poly.cpp cp $(srcdir)/../cppad/poly.cpp poly.cpp sparse_hessian.cpp: $(srcdir)/../cppad/sparse_hessian.cpp cp $(srcdir)/../cppad/sparse_hessian.cpp sparse_hessian.cpp sparse_jacobian.cpp: $(srcdir)/../cppad/sparse_jacobian.cpp cp $(srcdir)/../cppad/sparse_jacobian.cpp sparse_jacobian.cpp link_det_lu.cpp: $(srcdir)/../src/link_det_lu.cpp cp $(srcdir)/../src/link_det_lu.cpp link_det_lu.cpp link_det_minor.cpp: $(srcdir)/../src/link_det_minor.cpp cp $(srcdir)/../src/link_det_minor.cpp link_det_minor.cpp link_mat_mul.cpp: $(srcdir)/../src/link_mat_mul.cpp cp $(srcdir)/../src/link_mat_mul.cpp link_mat_mul.cpp link_ode.cpp: $(srcdir)/../src/link_ode.cpp cp $(srcdir)/../src/link_ode.cpp link_ode.cpp link_poly.cpp: $(srcdir)/../src/link_poly.cpp cp $(srcdir)/../src/link_poly.cpp link_poly.cpp link_sparse_hessian.cpp: $(srcdir)/../src/link_sparse_hessian.cpp cp $(srcdir)/../src/link_sparse_hessian.cpp link_sparse_hessian.cpp link_sparse_jacobian.cpp: $(srcdir)/../src/link_sparse_jacobian.cpp cp $(srcdir)/../src/link_sparse_jacobian.cpp link_sparse_jacobian.cpp microsoft_timer.cpp: $(srcdir)/../src/microsoft_timer.cpp cp $(srcdir)/../src/microsoft_timer.cpp microsoft_timer.cpp # # 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_LDFLAGS = -pg # speed_profile_SOURCES = $(source_list) # test: check ./speed_profile correct 123 cppad-20160000.1/speed/profile/gprof.sed.in0000644000175200017650000000161112656321770017406 0ustar coincoin-web#! /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 multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # remove template information s/<[^<>]*>//g s/<[^<>]*>//g s/<[^<>]*>//g s/<[^<>]*>//g s/<[^<>]*>//g # remove argument information s/([^()]*)//g s/([^()]*)//g # remove names space information s/[a-zA-Z0-9_]*:://g s/[a-zA-Z0-9_]*:://g s/[a-zA-Z0-9_]*:://g s/[a-zA-Z0-9_]*:://g cppad-20160000.1/speed/profile/CMakeLists.txt0000644000175200017650000000476312656321770017742 0ustar coincoin-web# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the speed/profile directory tests # Inherit environment from ../CMakeList.txt # CMAKE_BUILD_TYPE determined by parent directory # Adds flags to the compiler command line for sources in the current directory # and below. This command can be used to add any flags, but it was originally # intended to add preprocessor definitions. ADD_DEFINITIONS("-DCPPAD_PROFILE_SPEED ${cppad_profile_flag}") # Extra flags used by the linker when creating an executable. SET(CMAKE_EXE_LINKER_FLAGS ${cppad_profile_flag}) # Local include directories to search (not in package_prefix/includdir) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(speed_profile EXCLUDE_FROM_ALL ../main.cpp ../cppad/ode.cpp ../cppad/det_lu.cpp ../cppad/det_minor.cpp ../cppad/mat_mul.cpp ../cppad/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 ) # Compiler flags for cppad source add_cppad_cxx_flags( speed_profile ) # 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} ) # Add the check_speed_profile target ADD_CUSTOM_TARGET(check_speed_profile speed_profile correct 54321 DEPENDS speed_profile ) # Sed script to make gprof output more readable, use: # ./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 ) cppad-20160000.1/speed/fadbad/0002755000175200017650000000000012656321770014733 5ustar coincoin-webcppad-20160000.1/speed/fadbad/mat_mul.cpp0000644000175200017650000000526612656321770017104 0ustar coincoin-web// $Id: mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin fadbad_mat_mul.cpp$$ $spell 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$$ See $cref link_mat_mul$$. $head Implementation$$ $codep */ # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_mat_mul( size_t size , size_t repeat , CppAD::vector& x , CppAD::vector& z , CppAD::vector& dz ) { // speed test global option values if( global_memory || global_onetape || global_atomic || global_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; } /* $$ $end */ cppad-20160000.1/speed/fadbad/det_minor.cpp0000644000175200017650000000505312656321770017420 0ustar coincoin-web// $Id: det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin fadbad_det_minor.cpp$$ $spell 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$$ See $cref link_det_minor$$. $head Implementation$$ $codep */ # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_minor( size_t size , size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { // speed test global option values if( global_atomic ) return false; if( global_memory || global_onetape || global_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; } /* $$ $end */ cppad-20160000.1/speed/fadbad/makefile.in0000644000175200017650000004755312656321770017054 0ustar coincoin-web# 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 = speed_fadbad$(EXEEXT) subdir = speed/fadbad 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_speed_fadbad_OBJECTS = main.$(OBJEXT) det_lu.$(OBJEXT) \ det_minor.$(OBJEXT) mat_mul.$(OBJEXT) ode.$(OBJEXT) \ poly.$(OBJEXT) sparse_hessian.$(OBJEXT) \ sparse_jacobian.$(OBJEXT) speed_fadbad_OBJECTS = $(am_speed_fadbad_OBJECTS) speed_fadbad_LDADD = $(LDADD) speed_fadbad_DEPENDENCIES = 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 = $(speed_fadbad_SOURCES) DIST_SOURCES = $(speed_fadbad_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 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp # AM_CPPFLAGS = \ -I$(top_srcdir) \ -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 # speed_fadbad_SOURCES = \ main.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ ode.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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) --gnu speed/fadbad/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/fadbad/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) speed_fadbad$(EXEEXT): $(speed_fadbad_OBJECTS) $(speed_fadbad_DEPENDENCIES) $(EXTRA_speed_fadbad_DEPENDENCIES) @rm -f speed_fadbad$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(speed_fadbad_OBJECTS) $(speed_fadbad_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_lu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_minor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mat_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_hessian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_jacobian.Po@am__quote@ .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: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: makefile installdirs: install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) 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: all check check-am install 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 main.cpp: cp $(srcdir)/../main.cpp main.cpp test: check ./speed_fadbad correct 123 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: cppad-20160000.1/speed/fadbad/poly.cpp0000644000175200017650000000523112656321770016421 0ustar coincoin-web// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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 $$ $section Fadbad Speed: Second Derivative of a Polynomial$$ $mindex link_poly speed$$ $head Specifications$$ See $cref link_poly$$. $head Implementation$$ $codep */ # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; 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 { if( global_atomic ) return false; if( global_memory || global_onetape || global_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 */ cppad-20160000.1/speed/fadbad/sparse_jacobian.cpp0000644000175200017650000000240312656321770020557 0ustar coincoin-web// $Id: sparse_jacobian.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. -------------------------------------------------------------------------- */ # include # include /* $begin fadbad_sparse_jacobian.cpp$$ $spell const bool CppAD fadbad sparse_jacobian $$ $section fadbad Speed: sparse_jacobian$$ $codep */ // 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 ) { return false; } /* $$ $end */ cppad-20160000.1/speed/fadbad/ode.cpp0000644000175200017650000000515712656321770016214 0ustar coincoin-web// $Id: ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin fadbad_ode.cpp$$ $spell fadiff cassert namespace fabs const std typedef diff Jacobian cstring cppad hpp onetape Fadbad bool CppAD $$ $section Fadbad Speed: Ode$$ $mindex link_ode speed$$ $head Specifications$$ See $cref link_ode$$. $head Implementation$$ $codep */ # include # include # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; namespace fadbad { // 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 ) { // speed test global option values if( global_atomic ) return false; if( global_memory || global_onetape || global_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; } /* $$ $end */ cppad-20160000.1/speed/fadbad/sparse_hessian.cpp0000644000175200017650000000235312656321770020447 0ustar coincoin-web// $Id: sparse_hessian.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. -------------------------------------------------------------------------- */ # include /* $begin fadbad_sparse_hessian.cpp$$ $spell const Fadbad bool CppAD $$ $section Fadbad Speed: Sparse Hessian$$ $codep */ // 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 ) { return false; } /* $$ $end */ cppad-20160000.1/speed/fadbad/makefile.am0000644000175200017650000000273712656321770017036 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp main.cpp: cp $(srcdir)/../main.cpp main.cpp # # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # check_PROGRAMS = speed_fadbad # AM_CPPFLAGS = \ -I$(top_srcdir) \ -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 # speed_fadbad_SOURCES = \ main.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ ode.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp test: check ./speed_fadbad correct 123 cppad-20160000.1/speed/fadbad/CMakeLists.txt0000644000175200017650000000353312656321770017475 0ustar coincoin-web# $Id: CMakeLists.txt 3122 2014-02-26 03:23:19Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the speed/fadbad directory tests # Inherit environment from ../CMakeList.txt # CMAKE_BUILD_TYPE determined by parent directory # assert fadbad_prefix is defined IF ( NOT 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 # and below. This command can be used to add any flags, but it was originally # intended to add preprocessor definitions. ADD_DEFINITIONS("-DCPPAD_FADBAD_SPEED") # Local include directories to search (not in package_prefix/includdir) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(speed_fadbad EXCLUDE_FROM_ALL ../main.cpp det_lu.cpp det_minor.cpp mat_mul.cpp ode.cpp poly.cpp sparse_hessian.cpp sparse_jacobian.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags( speed_fadbad ) # fadbad is an include file only library TARGET_LINK_LIBRARIES(speed_fadbad speed_src ) # Add the check_speed_fadbad target ADD_CUSTOM_TARGET(check_speed_fadbad speed_fadbad correct 54321 DEPENDS speed_fadbad speed_src ) cppad-20160000.1/speed/fadbad/det_lu.cpp0000644000175200017650000000506112656321770016713 0ustar coincoin-web// $Id: det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin fadbad_det_lu.cpp$$ $spell 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$$ See $cref link_det_lu$$. $head Implementation$$ $codep */ # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_lu( size_t size , size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { // speed test global option values if( global_onetape || global_atomic ) return false; if( global_memory || global_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; } /* $$ $end */ cppad-20160000.1/speed/adolc/0002755000175200017650000000000012656321770014614 5ustar coincoin-webcppad-20160000.1/speed/adolc/det_minor.cpp0000644000175200017650000001011312656321770017272 0ustar coincoin-web// $Id: det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin adolc_det_minor.cpp$$ $spell 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$$ See $cref link_det_minor$$. $head Implementation$$ $codep */ # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_minor( size_t size , size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { // speed test global option values if( global_atomic ) return false; if( global_memory || global_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_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 */ cppad-20160000.1/speed/adolc/makefile.in0000644000175200017650000005064512656321770016731 0ustar coincoin-web# 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 = speed_adolc$(EXEEXT) subdir = speed/adolc 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_speed_adolc_OBJECTS = alloc_mat.$(OBJEXT) main.$(OBJEXT) \ det_lu.$(OBJEXT) det_minor.$(OBJEXT) mat_mul.$(OBJEXT) \ ode.$(OBJEXT) poly.$(OBJEXT) sparse_hessian.$(OBJEXT) \ sparse_jacobian.$(OBJEXT) speed_adolc_OBJECTS = $(am_speed_adolc_OBJECTS) speed_adolc_LDADD = $(LDADD) speed_adolc_DEPENDENCIES = 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 = $(speed_adolc_SOURCES) DIST_SOURCES = $(speed_adolc_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 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp # AM_CPPFLAGS = \ -I$(top_srcdir) \ -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 # speed_adolc_SOURCES = \ adolc_alloc_mat.hpp \ alloc_mat.cpp \ main.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ ode.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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) --gnu speed/adolc/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/adolc/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) speed_adolc$(EXEEXT): $(speed_adolc_OBJECTS) $(speed_adolc_DEPENDENCIES) $(EXTRA_speed_adolc_DEPENDENCIES) @rm -f speed_adolc$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(speed_adolc_OBJECTS) $(speed_adolc_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloc_mat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_lu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_minor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mat_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_hessian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_jacobian.Po@am__quote@ .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: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: makefile installdirs: install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) 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: all check check-am install 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 main.cpp: cp $(srcdir)/../main.cpp main.cpp test: check ./speed_adolc correct 123 colpack ./speed_adolc correct 123 onetape colpack # 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: cppad-20160000.1/speed/adolc/adolc_alloc_mat.hpp0000644000175200017650000000137512656321770020426 0ustar coincoin-web// $Id: adolc_alloc_mat.hpp 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. -------------------------------------------------------------------------- */ # ifndef CPPAD_ADOLC_ALLOC_MAT_HPP # define CPPAD_ADOLC_ALLOC_MAT_HPP double** adolc_alloc_mat(size_t m, size_t n); void adolc_free_mat(double** mat); # endif cppad-20160000.1/speed/adolc/poly.cpp0000644000175200017650000001021712656321770016302 0ustar coincoin-web// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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 $$ $section Adolc Speed: Second Derivative of a Polynomial$$ $mindex link_poly speed$$ $head Specifications$$ See $cref link_poly$$. $head Implementation$$ $codep */ # include # include # include # include # include # include # include "adolc_alloc_mat.hpp" // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_poly( size_t size , size_t repeat , CppAD::vector &a , // coefficients of polynomial CppAD::vector &z , // polynomial argument value CppAD::vector &ddp ) // second derivative w.r.t z { if( global_atomic ) return false; if( global_memory || global_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_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; } /* $$ $end */ cppad-20160000.1/speed/adolc/sparse_jacobian.cpp0000644000175200017650000001407712656321770020452 0ustar coincoin-web// $Id: sparse_jacobian.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. -------------------------------------------------------------------------- */ # 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 $$ $section adolc Speed: Sparse Jacobian$$ $mindex link_sparse_jacobian speed$$ $head Specifications$$ See $cref link_sparse_jacobian$$. $head Implementation$$ $codep */ # include # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; extern bool global_colpack, global_boolsparsity; 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 ) { if( global_atomic || (! global_colpack) ) return false; if( global_memory || global_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]; extern bool global_boolsparsity; if( global_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_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 */ cppad-20160000.1/speed/adolc/adolc_usrparms.sh0000755000175200017650000000436012656321770020172 0ustar coincoin-web#! /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. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- #! /bin/bash # message=" usage: adolc_usrparms.sh adolc_usrparms.sh show adolc_usrparms.sh modify The frist usage prints the value of BUFSIZE and TBUFSIZE. The second usage show how the usrparms.h file would be modified. The third usage actually modifies the file. : The distribution directory corresponding to adolc; e.g., adolc-1.10.2. The file where the buffer sizes are specified is /adolc/usrparms.h. BUFSIZE: Buffer size for tapes. TBUFSIZE: Buffer size for temporary Taylor store. : the value we are changing the Adolc BUFSIZE parameter to. : the value we are changing the Adolc TBUFSIZE parameter to. " if [ "$1" == "" ] then 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 fi # # case where we print the value of BUFSIZE and TBUFSIZE if [ "$2" == "" ] then 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 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 fi echo "$message" exit 1 cppad-20160000.1/speed/adolc/ode.cpp0000644000175200017650000000770212656321770016073 0ustar coincoin-web// $Id: ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin adolc_ode.cpp$$ $spell typedef adouble jacobian jacobian jac_ptr alloc cppad.hpp Jacobian Adolc bool CppAD onetape $$ $section Adolc Speed: Ode$$ $mindex link_ode speed$$ $head Specifications$$ See $cref link_ode$$. $head Implementation$$ $codep */ # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_ode( size_t size , size_t repeat , CppAD::vector &x , CppAD::vector &jac ) { // speed test global option values if( global_atomic ) return false; if( global_memory || global_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_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; } /* $$ $end */ cppad-20160000.1/speed/adolc/sparse_hessian.cpp0000644000175200017650000001316212656321770020330 0ustar coincoin-web// $Id: sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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 $$ $section Adolc Speed: Sparse Hessian$$ $mindex link_sparse_hessian speed$$ $head Specifications$$ See $cref link_sparse_hessian$$. $head Implementation$$ $codep */ # include # include # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; extern bool global_colpack, global_boolsparsity; 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 ) { if( global_atomic || (! global_colpack) ) return false; if( global_memory || global_optimize || global_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_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; } /* $$ $end */ cppad-20160000.1/speed/adolc/makefile.am0000644000175200017650000000303012656321770016702 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp main.cpp: cp $(srcdir)/../main.cpp main.cpp # # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # check_PROGRAMS = speed_adolc # AM_CPPFLAGS = \ -I$(top_srcdir) \ -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 # speed_adolc_SOURCES = \ adolc_alloc_mat.hpp \ alloc_mat.cpp \ main.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ ode.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp test: check ./speed_adolc correct 123 colpack ./speed_adolc correct 123 onetape colpack cppad-20160000.1/speed/adolc/alloc_mat.cpp0000644000175200017650000000356612656321770017263 0ustar coincoin-web// $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. -------------------------------------------------------------------------- */ /* $begin adolc_alloc_mat$$ $spell 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%) %$$ $codei%adolc_free_mat(%mat%) %$$ $head Purpose$$ Use the $cref thread_alloc$$ memory allocator to allocate and free memory that can be used as a matrix with the Adolc package. $head m$$ Is the number of rows in the matrix. $head n$$ Is the number of columns in the matrix. $head mat$$ Is the matrix. To be specific, between a call to $code adolc_alloc_mat$$, and the corresponding call to $code adolc_free_mat$$, for $icode%i% = 0 , %...% , %m%-1%$$ and $icode%j% = 0 , %...% , %n%-1%$$, $icode%mat%[%i%][%j%]%$$ is the element in row $icode i$$ and column $icode j$$. $end */ # 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); for(size_t i = 0; i < m; i++) mat[i] = vec + i * n; return mat; } void adolc_free_mat(double** mat) { using CppAD::thread_alloc; thread_alloc::delete_array(mat[0]); thread_alloc::delete_array(mat); return; } cppad-20160000.1/speed/adolc/CMakeLists.txt0000644000175200017650000000362712656321770017362 0ustar coincoin-web# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the speed/adolc directory tests # Inherit environment from ../CMakeList.txt # CMAKE_BUILD_TYPE determined by parent directory # assert adolc_prefix is defined IF ( NOT adolc_prefix ) MESSAGE(FATAL_ERROR "speed/adolc/CMakeLists.txt: adolc_prefix = ${adolc_prefix}" ) ENDIF ( NOT adolc_prefix ) # Adds flags to the compiler command line for sources in the current directory # and below. This command can be used to add any flags, but it was originally # intended to add preprocessor definitions. ADD_DEFINITIONS("-DCPPAD_ADOLC_SPEED") # Local include directories to search (not in package_prefix/includdir) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(speed_adolc EXCLUDE_FROM_ALL ../main.cpp alloc_mat.cpp det_lu.cpp det_minor.cpp mat_mul.cpp ode.cpp poly.cpp sparse_hessian.cpp sparse_jacobian.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags( speed_adolc ) # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(speed_adolc 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 ) cppad-20160000.1/speed/adolc/det_lu.cpp0000644000175200017650000000705312656321770016577 0ustar coincoin-web// $Id: det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin adolc_det_lu.cpp$$ $spell 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$$ See $cref link_det_lu$$. $head Implementation$$ $codep */ # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_lu( size_t size , size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { // speed test global option values if( global_onetape || global_atomic ) return false; if( global_memory || global_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; } /* $$ $end */ cppad-20160000.1/speed/adolc/mat_mul.cpp0000644000175200017650000001020712656321770016754 0ustar coincoin-web// $Id: mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin adolc_mat_mul.cpp$$ $spell 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$$ See $cref link_mat_mul$$. $head Implementation$$ $codep */ # include # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_mat_mul( size_t size , size_t repeat , CppAD::vector& x , CppAD::vector& z , CppAD::vector& dz ) { // speed test global option values if( global_memory || global_atomic || global_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_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; } /* $$ $end */ cppad-20160000.1/speed/main.cpp0000644000175200017650000005256412656321770015174 0ustar coincoin-web// $Id: main.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. -------------------------------------------------------------------------- */ # include # include # include # include # include # include # include # include # include # include # include # include # include # include # ifdef CPPAD_ADOLC_SPEED # define AD_PACKAGE "adolc" # endif # ifdef CPPAD_CPPAD_SPEED # define AD_PACKAGE "cppad" # endif # ifdef CPPAD_DOUBLE_SPEED # define AD_PACKAGE "double" # endif # ifdef CPPAD_FADBAD_SPEED # define AD_PACKAGE "fadbad" # endif # ifdef CPPAD_PROFILE_SPEED # define AD_PACKAGE "profile" # endif # ifdef CPPAD_SACADO_SPEED # define AD_PACKAGE "sacado" # endif /* $begin speed_main$$ $spell 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%$$ $head Purpose$$ A version of this program runs the correctness tests or the speed tests for one AD package identified by $icode package$$. $head package$$ $subhead AD Package$$ The command line argument $icode package$$ specifies one of the AD package. The CppAD distribution comes with support for the following packages: $cref/adolc/speed_adolc/$$, $cref/cppad/speed_cppad/$$, $cref/fadbad/speed_fadbad/$$, $cref/sacado/speed_sacado/$$. You can extend this program to include other package. Such an extension need not include all the tests. For example, $cref link_sparse_hessian$$ just returns $code false$$ for the $cref/fadbad/fadbad_sparse_hessian.cpp/$$ and $cref/sacado/sacado_sparse_hessian.cpp/$$ packages. $subhead double$$ The value $icode package$$ can be $code 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 $code double$$ to the speed of the derivative computations. (It is often useful to divide the speed of the derivative computation by the speed of the function evaluation in $code double$$.) $subhead profile$$ In the special case where $icode package$$ is $code profile$$, the CppAD package is compiled and run with profiling to aid in determining where it is spending most of its time. $head test$$ It the argument $icode test$$ specifies which test to run and has the following possible values: $cref/correct/speed_main/test/correct/$$, $cref/speed/speed_main/test/speed/$$, $cref/det_minor/link_det_minor/$$, $cref/det_lu/link_det_lu/$$, $cref/mat_mul/link_mat_mul/$$, $cref/ode/link_ode/$$, $cref/poly/link_poly/$$, $cref/sparse_hessian/link_sparse_hessian/$$, $cref/sparse_jacobian/link_sparse_jacobian/$$. You can experiment with changing the implementation of a particular test for a particular package. $subhead correct$$ If $icode test$$ is equal to $code correct$$, all of the correctness tests are run. $subhead speed$$ If $icode test$$ is equal to $code speed$$, all of the speed tests are run. $head seed$$ The command line argument $icode seed$$ is a positive integer. The random number simulator $cref uniform_01$$ is initialized with the call $codei% uniform_01(%seed%) %$$ before any of the testing routines (listed above) are called. $head option_list$$ This is a list of options that follow $icode seed$$ value. The order of the options does not matter and the list can be empty. Each option in the list, must be separate command line argument to the main program. The documentation below specifics how CppAD uses these options, see the examples in $cref speed_adolc$$ for how another package might uses these options. $subhead onetape$$ If the option $code onetape$$ is present, the symbol $codep extern bool global_onetape $$ is true and otherwise it is false. If this external symbol is true, CppAD will use one taping of the operation sequence for all the repetitions of that speed test. Otherwise, the $cref/operation sequence/glossary/Operation/Sequence/$$ will be retaped for each test repetition. $pre $$ All of the tests, except $cref/det_lu/link_det_lu/$$, have a fixed operations sequence. The operation sequence for $code det_lu$$ may be different for each repetition of the test because it depends on the matrix for which the determinant is being calculated. For this reason, the CppAD test $cref cppad_det_lu.cpp$$ returns false (indicating that the test not implemented) when $code global_onetape$$ is true. $subhead optimize$$ If the option $code optimize$$ is present, the symbol $codep extern bool global_optimize $$ is true and otherwise it is false. If this external symbol is true, CppAD will optimize the operation sequence before doing computations. If it is false, this optimization will not be done. $subhead atomic$$ If the option $code atomic$$ is present, the symbol $codep extern bool global_atomic $$ is true and otherwise it is false. If this external symbol is true, CppAD will use its user defined $cref/atomic/atomic_base/$$ operation is used for the test. If no such atomic operation exists, and atomic is chosen, CppAD returns false for the test. $subhead memory$$ If the option $code memory$$ is present, the symbol $codep extern bool global_memory $$ is true and otherwise it is false. If it is true, the CppAD $cref/hold_memory/ta_hold_memory/$$ routine will be called by the main program before any of the tests are executed. This should make the CppAD $code thread_alloc$$ allocator faster. If it is false, CppAD will used standard memory allocation. $head Sparsity Options$$ The following options only apply to the $cref/sparse_jacobian/link_sparse_jacobian/$$ and $cref/sparse_hessian/link_sparse_hessian/$$ tests. The other tests will ignore these options: $subhead boolsparsity$$ If the option $code boolsparsity$$ is present, the symbol $codep extern bool global_boolsparsity $$ is true and otherwise it is false. If it is true, CppAD will use a $cref/vector of bool/glossary/Sparsity Pattern/Vector of Boolean/$$ for its sparsity patterns. Otherwise it will use a $cref/vector of sets/glossary/Sparsity Pattern/Vector of Sets/$$. $subhead colpack$$ If the option $code colpack$$ is present, the symbol $codep extern bool global_colpack $$ is true and otherwise it is false. If this external symbol is true, CppAD will use $cref/colpack/colpack_prefix/$$ to do the coloring for its Otherwise, it will use it's own coloring algorithm. $head Correctness Results$$ One, but not both, of the following two output lines $codei% %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, $icode optionlist$$ are the options (in $icode option_list$$) separated by the underbar $code _$$ character (whereas they are separated by spaces in $icode option_list$$), and $icode flag$$ is $code true$$ or $code false$$. $head Speed Results$$ 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% ] %$$ The values $icode package$$, $icode test$$, $icode optionlist$$, and $icode flag$$ are as in the correctness results above. The values $icode size_1$$, ..., $icode size_n$$ are the size arguments used for the corresponding tests. The values $icode rate_1$$, ..., $icode rate_n$$ are the number of times per second that the corresponding size problem executed. $subhead n_sweep$$ The $cref/sparse_jacobian/link_sparse_jacobian/$$ and $cref/sparse_hessian/link_sparse_hessian/$$ tests has an extra output line with the following form $codei% %package%_sparse_%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 sweeps (colors) used for each sparse Jacobian (Hessian) calculation; see $icode n_sweep$$ for $cref/sparse_jacobian/sparse_jacobian/n_sweep/$$ and $cref/sparse_hessian/sparse_hessian/n_sweep/$$. $children% 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$$ Each $cref/package/speed_main/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: $table $rref link_det_lu$$ $rref link_det_minor$$ $rref link_mat_mul$$ $rref link_ode$$ $rref link_poly$$ $rref link_sparse_hessian$$ $rref link_sparse_jacobian$$ $tend $end ----------------------------------------------------------------------------- */ // external routines # define CPPAD_DECLARE_SPEED(name) \ extern bool available_##name(void); \ extern bool correct_##name(bool is_package_double); \ extern void speed_##name(size_t size, size_t repeat) CPPAD_DECLARE_SPEED(det_lu); CPPAD_DECLARE_SPEED(det_minor); CPPAD_DECLARE_SPEED(mat_mul); CPPAD_DECLARE_SPEED(ode); CPPAD_DECLARE_SPEED(poly); CPPAD_DECLARE_SPEED(sparse_hessian); CPPAD_DECLARE_SPEED(sparse_jacobian); // info is different for each test extern void info_sparse_jacobian(size_t size, size_t& n_sweep); extern void info_sparse_hessian(size_t size, size_t& n_sweep); // -------------------------------------------------------------------------- bool global_onetape; bool global_colpack; bool global_optimize; bool global_atomic; bool global_memory; bool global_boolsparsity; namespace { using std::cout; using std::endl; // ---------------------------------------------------------------- // not available test message void not_available_message(const char* test_name) { cout << AD_PACKAGE << ": " << test_name; cout << " is not availabe with " << endl; cout << "onetape = " << global_onetape << endl; cout << "colpack = " << global_colpack << endl; cout << "optimize = " << global_optimize << endl; cout << "atomic = " << global_atomic << endl; cout << "memory = " << global_memory << endl; cout << "boolsparsity = " << global_boolsparsity << endl; } // ------------------------------------------------------ // 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); # else ok = correct_case(false); # endif } cout << AD_PACKAGE << "_" << case_name; if( global_onetape ) cout << "_onetape"; if( global_colpack ) cout << "_colpack"; if( global_optimize ) cout << "_optimize"; if( global_atomic ) cout << "_atomic"; if( global_memory ) cout << "_memory"; if( global_boolsparsity ) cout << "_boolsparsity"; 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; 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]); size_t i; test_enum match = test_error; int iseed = 0; bool error = argc < 3; if( ! error ) { for(i = 0; i < n_test; i++) if( strcmp(test_list[i].name, argv[1]) == 0 ) match = test_list[i].index; error = match == test_error; iseed = std::atoi( argv[2] ); error |= iseed < 0; global_onetape = false; global_colpack = false; global_optimize = false; global_atomic = false; global_memory = false; global_boolsparsity = false; for(i = 3; i < size_t(argc); i++) { if( strcmp(argv[i], "onetape") == 0 ) global_onetape = true; else if( strcmp(argv[i], "colpack") == 0 ) global_colpack = true; else if( strcmp(argv[i], "optimize") == 0 ) global_optimize = true; else if( strcmp(argv[i], "atomic") == 0 ) global_atomic = true; else if( strcmp(argv[i], "memory") == 0 ) global_memory = true; else if( strcmp(argv[i], "boolsparsity") == 0 ) global_boolsparsity = true; else error = true; } } if( error ) { cout << "usage: ./speed_" << AD_PACKAGE << " test seed option_list" << endl; cout << "test choices: " << endl; for(i = 0; i < n_test; i++) cout << "\t" << test_list[i].name << endl; cout << "seed choices: "; cout << "a positive integer used as a random seed." << endl; cout << "option choices: "; cout << " \"onetape\","; cout << " \"colpack\","; cout << " \"optimize\","; cout << " \"atomic\","; cout << " \"memory\","; cout << " \"boolsparsity\"." << endl << endl; return 1; } if( global_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(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] = 100 * (i + 1) * (i + 1); size_sparse_jacobian[i] = 100 * (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(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(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; } # endif return static_cast( ! ok ); } cppad-20160000.1/speed/cppad/0002755000175200017650000000000012656321771014622 5ustar coincoin-webcppad-20160000.1/speed/cppad/CMakeLists.txt0000644000175200017650000000331212656321770017356 0ustar coincoin-web# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the speed/cppad directory tests # Inherit environment from ../CMakeList.txt # CMAKE_BUILD_TYPE determined by parent directory # Adds flags to the compiler command line for sources in the current directory # and below. This command can be used to add any flags, but it was originally # intended to add preprocessor definitions. ADD_DEFINITIONS("-DCPPAD_CPPAD_SPEED") # Local include directories to search (not in package_prefix/includdir) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(speed_cppad EXCLUDE_FROM_ALL ../main.cpp det_lu.cpp det_minor.cpp mat_mul.cpp ode.cpp poly.cpp sparse_hessian.cpp sparse_jacobian.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags( speed_cppad ) # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(speed_cppad 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 ) cppad-20160000.1/speed/cppad/det_lu.cpp0000644000175200017650000000516112656321770016602 0ustar coincoin-web// $Id: det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin cppad_det_lu.cpp$$ $spell 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$$ See $cref link_det_lu$$. $head Implementation$$ $codep */ # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize; bool link_det_lu( size_t size , size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { // speed test global option values if( global_onetape || global_atomic ) return false; // ----------------------------------------------------- // 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_optimize ) f.optimize(); // skip comparison operators f.compare_change_count(0); // evaluate and return gradient using reverse mode f.Forward(0, matrix); gradient = f.Reverse(1, w); } return true; } /* $$ $end */ cppad-20160000.1/speed/cppad/mat_mul.cpp0000644000175200017650000001017312656321770016763 0ustar coincoin-web/* $Id: mat_mul.cpp 3741 2015-10-07 14:51:10Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin cppad_mat_mul.cpp$$ $spell resize nr nc cppad mul hpp bool onetape sq var std::cout endl CppAD dz typedef boolsparsity enum $$ $section CppAD Speed, Matrix Multiplication$$ $mindex link_mat_mul multiply$$ $head Specifications$$ See $cref link_mat_mul$$. $head Implementation$$ $codep */ # include # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize, global_boolsparsity; bool link_mat_mul( size_t size , size_t repeat , CppAD::vector& x , CppAD::vector& z , CppAD::vector& dz ) { // ----------------------------------------------------- // 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(2 * n), ay(n); size_t nr_result = size; size_t n_middle = size; size_t nc_result = size; matrix_mul atom_mul(nr_result, n_middle, nc_result); // if( global_boolsparsity ) atom_mul.option( CppAD::atomic_base::pack_sparsity_enum ); else atom_mul.option( CppAD::atomic_base::set_sparsity_enum ); // ------------------------------------------------------ if( ! global_onetape ) while(repeat--) { // get the next matrix CppAD::uniform_01(n, x); for( j = 0; j < n; j++) X[j] = x[j]; // declare independent variables Independent(X); // do computations if( ! global_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_optimize ) f.optimize(); // skip comparison operators f.compare_change_count(0); // evaluate and return gradient using reverse mode z = f.Forward(0, x); dz = f.Reverse(1, w); } 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_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_optimize ) f.optimize(); // 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. (If there are future calls to // mat_mul they would create new temporary work space.) CppAD::user_atomic::clear(); return true; } /* $$ $end */ cppad-20160000.1/speed/cppad/det_minor.cpp0000644000175200017650000000665312656321770017315 0ustar coincoin-web// $Id: det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin cppad_det_minor.cpp$$ $spell 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$$ See $cref link_det_minor$$. $head Implementation$$ $codep */ # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize; bool link_det_minor( size_t size , size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { // speed test global option values if( global_atomic ) return false; // ----------------------------------------------------- // 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_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_optimize ) f.optimize(); // skip comparison operators f.compare_change_count(0); // evaluate the determinant at the new matrix value f.Forward(0, matrix); // evaluate and return gradient using reverse mode gradient = f.Reverse(1, w); } 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_optimize ) f.optimize(); // skip comparison operators f.compare_change_count(0); // ------------------------------------------------------ while(repeat--) { // get the next matrix CppAD::uniform_01(n, matrix); // evaluate the determinant at the new matrix value f.Forward(0, matrix); // evaluate and return gradient using reverse mode gradient = f.Reverse(1, w); } } return true; } /* $$ $end */ cppad-20160000.1/speed/cppad/makefile.in0000644000175200017650000004761212656321771016737 0ustar coincoin-web# 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 = speed_cppad$(EXEEXT) subdir = speed/cppad 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_speed_cppad_OBJECTS = main.$(OBJEXT) det_lu.$(OBJEXT) \ det_minor.$(OBJEXT) mat_mul.$(OBJEXT) ode.$(OBJEXT) \ poly.$(OBJEXT) sparse_hessian.$(OBJEXT) \ sparse_jacobian.$(OBJEXT) speed_cppad_OBJECTS = $(am_speed_cppad_OBJECTS) speed_cppad_LDADD = $(LDADD) speed_cppad_DEPENDENCIES = 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 = $(speed_cppad_SOURCES) DIST_SOURCES = $(speed_cppad_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 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # # 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 # # BEGIN DEBUG # AM_CXXFLAGS = -g $(CXX_FLAGS) -DCPPAD_CPPAD_SPEED # END DEBUG # LDADD = -lspeed AM_LDFLAGS = -L../src # speed_cppad_SOURCES = \ main.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ ode.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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) --gnu speed/cppad/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/cppad/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) speed_cppad$(EXEEXT): $(speed_cppad_OBJECTS) $(speed_cppad_DEPENDENCIES) $(EXTRA_speed_cppad_DEPENDENCIES) @rm -f speed_cppad$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(speed_cppad_OBJECTS) $(speed_cppad_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_lu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_minor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mat_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_hessian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_jacobian.Po@am__quote@ .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: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: makefile installdirs: install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) 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: all check check-am install 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 main.cpp: cp $(srcdir)/../main.cpp main.cpp test: check ./speed_cppad correct 123 ./speed_cppad correct 123 onetape ./speed_cppad correct 123 optimize ./speed_cppad correct 123 atomic ./speed_cppad correct 123 memory ./speed_cppad correct 123 boolsparsity # 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: cppad-20160000.1/speed/cppad/poly.cpp0000644000175200017650000000743312656321771016316 0ustar coincoin-web// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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 $$ $section CppAD Speed: Second Derivative of a Polynomial$$ $mindex link_poly speed$$ $head Specifications$$ See $cref link_poly$$. $head Implementation$$ $codep */ # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize; 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 { // speed test global option values if( global_atomic ) return false; // ----------------------------------------------------- // 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_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_optimize ) f.optimize(); // skip comparison operators f.compare_change_count(0); // pre-allocate memory for three forward mode calculations f.capacity_order(3); // evaluate the polynomial 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_optimize ) f.optimize(); // 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; } /* $$ $end */ cppad-20160000.1/speed/cppad/sparse_jacobian.cpp0000644000175200017650000001244012656321771020450 0ustar coincoin-web// $Id: sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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 $$ $section CppAD Speed: Sparse Jacobian$$ $mindex link_sparse_jacobian speed$$ $head Specifications$$ See $cref link_sparse_jacobian$$. $head Implementation$$ $codep */ # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_colpack, global_atomic, global_optimize, global_boolsparsity; namespace { using CppAD::vector; typedef vector< std::set > SetVector; typedef vector BoolVector; void calc_sparsity(SetVector& sparsity_set, CppAD::ADFun& f) { size_t n = f.Domain(); SetVector r_set(n); for(size_t j = 0; j < n; j++) r_set[j].insert(j); sparsity_set = f.ForSparseJac(n, r_set); } void calc_sparsity(BoolVector& sparsity_bool, CppAD::ADFun& f) { size_t n = f.Domain(); BoolVector r_bool(n * n); size_t i, j; for(i = 0; i < n; i++) { for(j = 0; j < n; j++) r_bool[ i * n + j] = false; r_bool[ i * n + i] = true; } sparsity_bool = f.ForSparseJac(n, r_bool); } } 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 ) { if( global_atomic ) return false; # ifndef CPPAD_COLPACK_SPEED if( global_colpack ) return false; # endif // ----------------------------------------------------- // setup typedef vector< std::set > SetVector; typedef CppAD::AD ADScalar; typedef CppAD::vector ADVector; size_t j; size_t order = 0; // derivative order corresponding to function size_t n = size; // number of independent variables ADVector a_x(n); // AD domain space vector ADVector a_y(m); // AD range space vector y = g(x) CppAD::ADFun f; // AD function object // declare sparsity pattern SetVector set_sparsity(m); BoolVector bool_sparsity(m * n); // ------------------------------------------------------ if( ! global_onetape ) while(repeat--) { // choose a value for x CppAD::uniform_01(n, x); for(j = 0; j < n; j++) a_x[j] = x[j]; // declare independent variables Independent(a_x); // 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_optimize ) f.optimize(); // skip comparison operators f.compare_change_count(0); // calculate the Jacobian sparsity pattern for this function if( global_boolsparsity ) calc_sparsity(bool_sparsity, f); else calc_sparsity(set_sparsity, f); // structure that holds some of the work done by SparseJacobian CppAD::sparse_jacobian_work work; # ifdef CPPAD_COLPACK_SPEED if( global_colpack ) work.color_method = "colpack"; # endif // calculate the Jacobian at this x // (use forward mode because m > n ?) if( global_boolsparsity) n_sweep = f.SparseJacobianForward( x, bool_sparsity, row, col, jacobian, work ); else n_sweep = f.SparseJacobianForward( x, set_sparsity, row, col, jacobian, work ); } else { // choose a value for x CppAD::uniform_01(n, x); for(j = 0; j < n; j++) a_x[j] = x[j]; // declare independent variables Independent(a_x); // 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_optimize ) f.optimize(); // skip comparison operators f.compare_change_count(0); // calculate the Jacobian sparsity pattern for this function if( global_boolsparsity ) calc_sparsity(bool_sparsity, f); else calc_sparsity(set_sparsity, f); // structure that holds some of the work done by SparseJacobian CppAD::sparse_jacobian_work work; # ifdef CPPAD_COLPACK_SPEED if( global_colpack ) work.color_method = "colpack"; # endif while(repeat--) { // choose a value for x CppAD::uniform_01(n, x); // calculate the Jacobian at this x // (use forward mode because m > n ?) if( global_boolsparsity ) n_sweep = f.SparseJacobianForward( x, bool_sparsity, row, col, jacobian, work ); else n_sweep = f.SparseJacobianForward( x, set_sparsity, row, col, jacobian, work ); } } return true; } /* $$ $end */ cppad-20160000.1/speed/cppad/ode.cpp0000644000175200017650000000567012656321771016103 0ustar coincoin-web// $Id: ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin cppad_ode.cpp$$ $spell 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$$ See $cref link_ode$$. $head Implementation$$ $codep */ # include # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize; bool link_ode( size_t size , size_t repeat , CppAD::vector &x , CppAD::vector &jacobian ) { // speed test global option values if( global_atomic ) return false; // -------------------------------------------------------------------- // 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_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_optimize ) f.optimize(); // 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_optimize ) f.optimize(); // 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; } /* $$ $end */ cppad-20160000.1/speed/cppad/sparse_hessian.cpp0000644000175200017650000001315512656321771020340 0ustar coincoin-web// $Id: sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin cppad_sparse_hessian.cpp$$ $spell ifdef ifndef colpack boolsparsity namespace Jac onetape work work 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$$ See $cref link_sparse_hessian$$. $head Implementation$$ $codep */ # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_colpack, global_atomic, global_optimize, global_boolsparsity; namespace { using CppAD::vector; typedef vector< std::set > SetVector; typedef vector BoolVector; void calc_sparsity(SetVector& sparsity_set, CppAD::ADFun& f) { size_t n = f.Domain(); size_t m = f.Range(); CPPAD_ASSERT_UNKNOWN( m == 1 ); SetVector r_set(n); for(size_t i = 0; i < n; i++) r_set[i].insert(i); f.ForSparseJac(n, r_set); // SetVector s_set(m); s_set[0].insert(0); // sparsity_set = f.RevSparseHes(n, s_set); } void calc_sparsity(BoolVector& sparsity_bool, CppAD::ADFun& f) { size_t n = f.Domain(); size_t m = f.Range(); CPPAD_ASSERT_UNKNOWN( m == 1 ); BoolVector r_bool(n * n); size_t i, j; 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); // BoolVector s_bool(m); s_bool[0] = true; // sparsity_bool = f.RevSparseHes(n, s_bool); } } 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 ) { if( global_atomic ) return false; # ifndef CPPAD_COLPACK_SPEED if( global_colpack ) return false; # endif // ----------------------------------------------------- // setup typedef vector DblVector; typedef vector< std::set > SetVector; typedef CppAD::AD ADScalar; typedef vector ADVector; size_t j; size_t order = 0; // derivative order corresponding to function size_t m = 1; // number of dependent variables size_t n = size; // number of independent variables ADVector a_x(n); // AD domain space vector ADVector a_y(m); // AD range space vector DblVector w(m); // double range space vector CppAD::ADFun f; // AD function object // weights for hessian calculation (only one component of f) w[0] = 1.; // declare sparsity pattern SetVector set_sparsity(n); BoolVector bool_sparsity(n * n); // ------------------------------------------------------ if( ! global_onetape ) while(repeat--) { // choose a value for x CppAD::uniform_01(n, x); for(j = 0; j < n; j++) a_x[j] = x[j]; // declare independent variables Independent(a_x); // AD computation of f(x) CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); // create function object f : X -> Y f.Dependent(a_x, a_y); if( global_optimize ) f.optimize(); // skip comparison operators f.compare_change_count(0); // calculate the Hessian sparsity pattern for this function if( global_boolsparsity ) calc_sparsity(bool_sparsity, f); else calc_sparsity(set_sparsity, f); // structure that holds some of work done by SparseHessian CppAD::sparse_hessian_work work; # ifdef CPPAD_COLPACK_SPEED if( global_colpack ) work.color_method = "colpack.star"; # endif // calculate this Hessian at this x if( global_boolsparsity) n_sweep = f.SparseHessian( x, w, bool_sparsity, row, col, hessian, work ); else n_sweep = f.SparseHessian( x, w, set_sparsity, row, col, hessian, work ); } else { // choose a value for x CppAD::uniform_01(n, x); for(j = 0; j < n; j++) a_x[j] = x[j]; // declare independent variables Independent(a_x); // AD computation of f(x) CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); // create function object f : X -> Y f.Dependent(a_x, a_y); if( global_optimize ) f.optimize(); // skip comparison operators f.compare_change_count(0); // calculate the Hessian sparsity pattern for this function if( global_boolsparsity) calc_sparsity(bool_sparsity, f); else calc_sparsity(set_sparsity, f); // declare structure that holds some of work done by SparseHessian CppAD::sparse_hessian_work work; # ifdef CPPAD_COLPACK_SPEED if( global_colpack ) work.color_method = "colpack.star"; # endif while(repeat--) { // choose a value for x CppAD::uniform_01(n, x); // calculate hessian at this x if( global_boolsparsity ) n_sweep = f.SparseHessian( x, w, bool_sparsity, row, col, hessian, work ); else n_sweep = f.SparseHessian( x, w, set_sparsity, row, col, hessian, work ); } } return true; } /* $$ $end */ cppad-20160000.1/speed/cppad/makefile.am0000644000175200017650000000302012656321771016707 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp main.cpp: cp $(srcdir)/../main.cpp main.cpp # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # 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 # LDADD = -lspeed AM_LDFLAGS = -L../src # speed_cppad_SOURCES = \ main.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ ode.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp test: check ./speed_cppad correct 123 ./speed_cppad correct 123 onetape ./speed_cppad correct 123 optimize ./speed_cppad correct 123 atomic ./speed_cppad correct 123 memory ./speed_cppad correct 123 boolsparsity cppad-20160000.1/speed/src/0002755000175200017650000000000012656321771014322 5ustar coincoin-webcppad-20160000.1/speed/src/link_poly.cpp0000644000175200017650000000722512656321771017032 0ustar coincoin-web// $Id: link_poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin link_poly$$ $spell 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 ); %$$ $head Purpose$$ Each $cref/package/speed_main/package/$$ must define a version of this routine as specified below. This is used by the $cref speed_main$$ program to run the corresponding speed and correctness tests. $head Method$$ The same template routine $cref Poly$$ is used by the different AD packages. $head Return Value$$ If this speed test is not yet supported by a particular $icode package$$, the corresponding return value for $code link_poly$$ should be $code false$$. $head size$$ The argument $icode size$$ is the order of the polynomial (the number of coefficients in the polynomial). $head repeat$$ The argument $icode repeat$$ is the number of different argument values that the second derivative (or just the polynomial) will be computed at. $head a$$ The argument $icode a$$ is a vector with $icode%size%$$ elements. The input value of its elements does not matter. The output value of its elements is the coefficients of the polynomial that is differentiated ($th i$$ element is coefficient of order $icode i$$). $head z$$ The argument $icode z$$ is a vector with one element. The input value of the element does not matter. The output of its element is the polynomial argument value were the last second derivative (or polynomial value) was computed. $head ddp$$ The argument $icode ddp$$ is a vector with one element. The input value of its element does not matter. The output value of its element is the second derivative of the polynomial with respect to it's argument value. $subhead double$$ In the case where $icode package$$ is $code double$$, the output value of the element of $icode ddp$$ is the polynomial value (the second derivative is not computed). $end ----------------------------------------------------------------------------- */ # include # include # include extern bool link_poly( 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); 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); 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], 1e-10, 1e-10); return ok; } void speed_poly(size_t size, size_t repeat) { CppAD::vector a(size), z(1), ddp(1); link_poly(size, repeat, a, z, ddp); return; } cppad-20160000.1/speed/src/link_sparse_jacobian.cpp0000644000175200017650000002610712656321771021172 0ustar coincoin-web// $Id: link_sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin link_sparse_jacobian$$ $spell 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% ); %$$ $head Method$$ Given a range space dimension $icode m$$ the row index vector $latex row$$, and column index vector $latex col$$, a corresponding function $latex f : \B{R}^n \rightarrow \B{R}^m $$ 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]]]} \] $$ for some $latex k$$ between zero and $icode%K% = %row%.size()-1%$$. All the other terms of the Jacobian are zero. $head size$$ The argument $icode size$$, referred to as $latex n$$ below, is the dimension of the domain space for $latex f(x)$$. $head repeat$$ The argument $icode repeat$$ is the number of times to repeat the test (with a different value for $icode x$$ corresponding to each repetition). $head m$$ Is the dimension of the range space for the function $latex f(x)$$. $head row$$ The size of the vector $icode row$$ defines the value $latex K$$. All the elements of $icode row$$ are between zero and $latex m-1$$. $head col$$ The argument $icode col$$ is a vector with size $latex 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 $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%] %$$ $head x$$ The argument $icode x$$ has prototype $codei% 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. On output, it has been set to the argument value for which the function, or its derivative, is being evaluated and placed in $icode jacobian$$. The value of this vector need not change with each repetition. $head jacobian$$ The argument $icode jacobian$$ has prototype $codei% CppAD::vector& %jacobian% %$$ and its size is $icode K$$. The input value of its elements does not matter. The output value of its elements is the Jacobian of the function $latex f(x)$$. To be more specific, for $latex k = 0 , \ldots , K - 1$$, $latex \[ \D{f[ \R{row}[k] ]}{x[ \R{col}[k] ]} (x) = \R{jacobian} [k] \] $$ $head n_sweep$$ The input value of $icode n_sweep$$ does not matter. On output, it is the value $cref/n_sweep/sparse_jacobian/n_sweep/$$ corresponding to the evaluation of $icode jacobian$$. This is also the number of colors corresponding to the $cref/coloring method/sparse_jacobian/work/color_method/$$, which can be set to $cref/colpack/speed_main/Sparsity Options/colpack/$$, and is otherwise $code cppad$$. $subhead double$$ In the case where $icode package$$ is $code double$$, only the first $latex m$$ elements of $icode jacobian$$ are used and they are set to the value of $latex f(x)$$. $end ----------------------------------------------------------------------------- */ # include # include # include # include # include /*! \{ \file link_sparse_jacobian.cpp Defines and implement sparse Jacobian speed link to package specific code. */ namespace { 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++) { r = size_t( m * random[k] ); r = std::min(m-1, r); // c = size_t( 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. \param repeat [in] number of times tha the test is repeated. \param m [in] is the dimension of the range space for f(x). \param row [in] is the row indices correpsonding to non-zero Jacobian entries. \param col [in] is the column indices corresponding to non-zero Jacobian entries. \param x [out] is a vector of size \c n containing the argument at which the Jacobian was evaluated during the last repetition. \param jacobian [out] is a vector with size row.size() containing the value of the Jacobian of f(x) corresponding to the last repetition. \param n_sweep [out] The input value of this parameter does not matter. Upon return, it is the number of sweeps (colors) corresponding to the sparse jacobian claculation. \return is true, if the sparse Jacobian speed test is implemented for this package, 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 ); /*! Is sparse Jacobian test avaialable. \return 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); } /*! Does final sparse Jacobian value pass correctness test. \param is_package_double [in] if true, we are checking function values instead of derivatives. \return 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); 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); return ok; } /*! Sparse Jacobian speed test. \param size [in] is the dimension of the argument space for this speed test. \param repeat [in] is the number of times to repeate the speed test. */ void speed_sparse_jacobian(size_t size, size_t repeat) { CPPAD_ASSERT_UNKNOWN( size > 0 ); static size_t previous_size = 0; static vector row, col; 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. \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. */ 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; } cppad-20160000.1/speed/src/makefile.in0000644000175200017650000004710412656321771016433 0ustar coincoin-web# 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@ subdir = speed/src 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 = 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 = libspeed_a_AR = $(AR) $(ARFLAGS) libspeed_a_LIBADD = am_libspeed_a_OBJECTS = link_det_lu.$(OBJEXT) link_det_minor.$(OBJEXT) \ link_mat_mul.$(OBJEXT) link_ode.$(OBJEXT) link_poly.$(OBJEXT) \ link_sparse_hessian.$(OBJEXT) link_sparse_jacobian.$(OBJEXT) \ microsoft_timer.$(OBJEXT) libspeed_a_OBJECTS = $(am_libspeed_a_OBJECTS) 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 = $(libspeed_a_SOURCES) DIST_SOURCES = $(libspeed_a_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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # # 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) \ $(EIGEN_INCLUDE) # noinst_LIBRARIES = libspeed.a libspeed_a_SOURCES = \ 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 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) --gnu speed/src/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/src/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-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libspeed.a: $(libspeed_a_OBJECTS) $(libspeed_a_DEPENDENCIES) $(EXTRA_libspeed_a_DEPENDENCIES) $(AM_V_at)-rm -f libspeed.a $(AM_V_AR)$(libspeed_a_AR) libspeed.a $(libspeed_a_OBJECTS) $(libspeed_a_LIBADD) $(AM_V_at)$(RANLIB) libspeed.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_det_lu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_det_minor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_mat_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_ode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_poly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_sparse_hessian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link_sparse_jacobian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/microsoft_timer.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 check: check-am all-am: makefile $(LIBRARIES) 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-generic clean-noinstLIBRARIES 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: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean 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 .PRECIOUS: makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: cppad-20160000.1/speed/src/link_ode.cpp0000644000175200017650000001013212656321771016605 0ustar coincoin-web// $Id: link_ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin link_ode$$ $spell 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% ); %$$ $head Purpose$$ Each $cref/package/speed_main/package/$$ must define a version of this routine as specified below. This is used by the $cref speed_main$$ program to run the corresponding speed and correctness tests. $head Method$$ The same template routine $cref ode_evaluate$$ is used by th different AD packages. $head f$$ The function $latex f : \B{R}^n \rightarrow \B{R}^n$$ that is defined and computed by evaluating $cref ode_evaluate$$ with a call of the form $codei% ode_evaluate(%x%, %p%, %fp%) %$$ with $icode p$$ equal to zero. Calls with the value $icode p$$ equal to one are used to check the derivative values. $head Return Value$$ If this speed test is not yet supported by a particular $icode package$$, the corresponding return value for $code link_ode$$ should be $code false$$. $head size$$ The argument $icode size$$ is the number of variables in the ordinary differential equations which is also equal to $latex n$$. $head repeat$$ The argument $icode repeat$$ is the number of times the Jacobian is computed. $head x$$ The argument $icode x$$ is a vector with $latex n$$ elements. The input value of the elements of $icode 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. $head jacobian$$ The argument $icode jacobian$$ is a vector with $latex n^2$$ elements. The input value of its elements does not matter. The output value of its elements is the Jacobian of the function $latex f(x)$$ that corresponds to output value of $icode x$$. 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 ] \] $$ $subhead double$$ In the case where $icode package$$ is $code double$$, only the first $latex n$$ element of $icode jacobian$$ are modified and they are to the function value $latex f(x)$$ corresponding to the output value of $icode x$$. $end ----------------------------------------------------------------------------- */ # include # include # include extern bool link_ode( 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); return link_ode(n, repeat, x, jacobian); } bool correct_ode(bool is_package_double) { 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); return ok; } void speed_ode(size_t n, size_t repeat) { CppAD::vector x(n); CppAD::vector jacobian(n * n); link_ode(n, repeat, x, jacobian); return; } cppad-20160000.1/speed/src/link_sparse_hessian.cpp0000644000175200017650000002432312656321771021054 0ustar coincoin-web// $Id: link_sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin link_sparse_hessian$$ $spell 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% ); %$$ $head Method$$ Given a row index vector $latex row$$ and a second column vector $latex col$$, the corresponding function $latex f : \B{R}^n \rightarrow \B{R} $$ is defined by $cref sparse_hes_fun$$. 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 size$$ The argument $icode size$$, referred to as $latex n$$ below, is the dimension of the domain space for $latex f(x)$$. $head repeat$$ The argument $icode repeat$$ is the number of times to repeat the test (with a different value for $icode x$$ corresponding to each repetition). $head x$$ The argument $icode x$$ has prototype $codei% 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. 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. $head row$$ The argument $icode row$$ has prototype $codei% const CppAD::vector %row% %$$ Its size defines the value $latex K$$. It contains the row indices for the corresponding function $latex f(x)$$. All the elements of $icode row$$ are between zero and $latex n-1$$. $head col$$ The argument $icode col$$ has prototype $codei% 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 $latex f(x)$$. All the elements of $icode col$$ are between zero and $latex 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 hessian$$ The argument $icode hessian$$ has prototype $codei% CppAD::vector& hessian %$$ and its size is $icode K$$. The input value of its elements does not matter. The output value of its elements is the Hessian of the function $latex f(x)$$. To be more specific, for $latex k = 0 , \ldots , K-1$$, $latex \[ \DD{f}{ x[ \R{row}[k] ] }{ x[ \R{col}[k] ]} = \R{hessian} [k] \] $$ $head n_sweep$$ The input value of $icode n_sweep$$ does not matter. On output, it is the value $cref/n_sweep/sparse_hessian/n_sweep/$$ corresponding to the evaluation of $icode hessian$$. This is also the number of colors corresponding to the $cref/coloring method/sparse_hessian/work/color_method/$$, which can be set to $cref/colpack/speed_main/Sparsity Options/colpack/$$, and is otherwise $code cppad$$. $subhead double$$ In the case where $icode package$$ is $code double$$, only the first element of $icode hessian$$ is used and it is actually the value of $latex f(x)$$ (derivatives are not computed). $end ----------------------------------------------------------------------------- */ # include # include # include # include # include /*! \{ \file link_sparse_hessian.cpp Defines and implement sparse Hessian speed link to package specific code. */ namespace { 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++) { j = std::min(i, size_t(random[ell] * i) ); bool ok = true; for(k = k_start; k < col.size(); k++) ok &= j != col[k]; if( ok ) { row.push_back(i); col.push_back(j); } } } } } /*! Package specific implementation of a sparse Hessian claculation. \param size [in] is the size of the domain space; i.e. specifies \c n. \param repeat [in] number of times tha the test is repeated. \param x [out] is a vector of size \c n containing the argument at which the Hessian was evaluated during the last repetition. \param row [in] is the row indices correpsonding to non-zero Hessian entries. \param col [in] is the column indices corresponding to non-zero Hessian entries; col.size() == row.size(). \param hessian [out] is a vector, with hessian.size() == row.size(), containing the value of the Hessian of f(x) corresponding to the last repetition. \param n_sweep [out] The input value of this parameter does not matter. Upon return, it is the number of sweeps (colors) corresponding to the sparse hessian claculation. \return is true, if the sparse Hessian speed test is implemented for this package, and false otherwise. */ 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 ); /*! Is sparse Hessian test avaialable. \return true, if spare Hessian available for this package, and false otherwise. */ bool available_sparse_hessian(void) { size_t n = 2; size_t repeat = 1; vector x(n); vector 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); } /*! Does final sparse Hessian value pass correctness test. \param is_package_double if true, we are checking function values instead of derivatives. \return true, if correctness test passes, and false otherwise. */ bool correct_sparse_hessian(bool is_package_double) { size_t n = 10; size_t repeat = 1; vector x(n); vector row, col; choose_row_col(n, row, col); size_t K = row.size(); vector hessian(K); // 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], 1e-10, 1e-10); return ok; } /*! Sparse Hessian speed test. \param size is the dimension of the argument space for this speed test. \param repeat is the number of times to repeate the speed test. */ void speed_sparse_hessian(size_t size, size_t repeat) { CPPAD_ASSERT_UNKNOWN( size > 0 ); static size_t previous_size = 0; static vector row, col; 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); // 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. \param n_sweep [out] The input value of this parameter does not matter. Upon return, it is the value \c n_sweep retruned by the corresponding call to \c link_sparse_hessian. */ void info_sparse_hessian(size_t size, size_t& n_sweep) { size_t n = size; size_t repeat = 1; vector row, col; choose_row_col(n, row, col); // note that cppad/speed/sparse_hessian.cpp assumes that x.size() // is the size corresponding to this test vector x(n); size_t K = row.size(); vector hessian(K); link_sparse_hessian(n, repeat, row, col, x, hessian, n_sweep); return; } cppad-20160000.1/speed/src/microsoft_timer.cpp0000644000175200017650000000475012656321771020237 0ustar coincoin-web/* $Id: microsoft_timer.cpp 3724 2015-09-21 05:04:18Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin microsoft_timer$$ $spell Microsoft cpp src $$ $section Microsoft Version of Elapsed Number of Seconds$$ $head Syntax$$ $icode%s% = microsoft_timer()%$$ $head Purpose$$ This routine is accurate to within .02 seconds (see $cref elapsed_seconds$$ which uses this routine when the preprocessor symbol $code _MSC_VER$$ is defined). It does not necessary work for time intervals that are greater than a day. It uses $code ::GetSystemTime$$ for timing. $head s$$ is a $code double$$ equal to the number of seconds since the first call to $code microsoft_timer$$. $head Linking$$ The source code for this routine is located in $code speed/src/microsoft_timer.cpp$$. The preprocessor symbol $code _MSC_VER$$ must be defined, or this routine is not compiled. $end ----------------------------------------------------------------------- */ # if _MSC_VER # include # include // Note that the doxygen for this routine does not get generated because // _MSC_VER is not defined during generation. In general, it is a problem // that not all preprocessor options get documented. /*! \{ \file microsoft_timer.cpp \brief Microsoft version of elapsed_seconds. */ /*! Microsoft version of elapsed number of seconds since frist call. \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. ); return diff; } # endif cppad-20160000.1/speed/src/makefile.am0000644000175200017650000000224612656321771016420 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 = # # 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) \ $(EIGEN_INCLUDE) # noinst_LIBRARIES = libspeed.a libspeed_a_SOURCES = \ 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 cppad-20160000.1/speed/src/link_det_lu.cpp0000644000175200017650000000674012656321771017324 0ustar coincoin-web// $Id: link_det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin link_det_lu$$ $spell 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% ); %$$ $head Purpose$$ Each $cref/package/speed_main/package/$$ must define a version of this routine as specified below. This is used by the $cref speed_main$$ program to run the corresponding speed and correctness tests. $head Method$$ The same template routine $cref det_by_lu$$ is used by the different AD packages. $head Return Value$$ If this speed test is not yet supported by a particular $icode package$$, the corresponding return value for $code link_det_lu$$ should be $code false$$. $head size$$ The argument $icode size$$ is the number of rows and columns in the matrix. $head repeat$$ The argument $icode repeat$$ is the number of different matrices that the gradient (or determinant) is computed for. $head matrix$$ The argument $icode matrix$$ is a vector with $icode%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. $head gradient$$ The argument $icode gradient$$ is a vector with $icode%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 $icode matrix$$ with respect to its elements. $subhead double$$ In the case where $icode package$$ is $code double$$, only the first element of $icode gradient$$ is used and it is actually the determinant value (the gradient value is not computed). $end ----------------------------------------------------------------------------- */ # include # include # include extern bool link_det_lu( 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); 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; } void speed_det_lu(size_t size, size_t repeat) { CppAD::vector matrix(size * size); CppAD::vector gradient(size * size); link_det_lu(size, repeat, matrix, gradient); return; } cppad-20160000.1/speed/src/link_mat_mul.cpp0000644000175200017650000001055712656321771017507 0ustar coincoin-web// $Id: link_mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin link_mat_mul$$ $spell 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% ); %$$ $head Purpose$$ Each $cref/package/speed_main/package/$$ must define a version of this routine as specified below. This is used by the $cref speed_main$$ program to run the corresponding speed and correctness tests. $head Return Value$$ If this speed test is not yet supported by a particular $icode package$$, the corresponding return value for $code link_mat_mul$$ should be $code false$$. $head n$$ The argument $icode n$$ is the number of rows and columns in the square matrix $icode x$$. $head repeat$$ The argument $icode repeat$$ is the number of different argument values that the derivative of $icode z$$ (or just the value of $icode z$$) will be computed. $head x$$ The argument $icode x$$ is a vector with $icode%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 $icode z$$; $latex \[ x_{i,j} = x[ i * s + j ] \] $$ where $icode%s% = %size%$$. $head z$$ The argument $icode z$$ is a vector with one element. The input value of the element does not matter. The output of its element the sum of the elements of $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} \end{array} \] $$ $head dz$$ The argument $icode dz$$ is a vector with $icode%dz%.size() = %size% * %size%$$. The input values of its elements do not matter. The output value of its elements form the derivative of $icode z$$ with respect to $icode x$$. $end ----------------------------------------------------------------------------- */ # include # include extern bool link_mat_mul( 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); 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); 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], 1e-10, 1e-10); return ok; } // partial w.r.t. x00 check = x00 + x00 + x01 + x10; ok &= CppAD::NearEqual(check, dz[0 * size + 0], 1e-10, 1e-10); // partial w.r.t. x01 check = x10 + x00 + x11 + x10; ok &= CppAD::NearEqual(check, dz[0 * size + 1], 1e-10, 1e-10); // partial w.r.t. x10 check = x01 + x00 + x11 + x01; ok &= CppAD::NearEqual(check, dz[1 * size + 0], 1e-10, 1e-10); // partial w.r.t. x11 check = x01 + x10 + x11 + x11; ok &= CppAD::NearEqual(check, dz[1 * size + 1], 1e-10, 1e-10); return ok; } void speed_mat_mul(size_t size, size_t repeat) { CppAD::vector x(size * size), z(1), dz(size * size); link_mat_mul(size, repeat, x, z, dz); return; } cppad-20160000.1/speed/src/CMakeLists.txt0000644000175200017650000000236112656321771017062 0ustar coincoin-web# $Id: CMakeLists.txt 3754 2015-11-26 22:23:05Z 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. # ----------------------------------------------------------------------------- # Build the cppad_ipopt/src library # Inherit environment from ../CMakeList.txt # CMAKE_BUILD_TYPE determined by parent directory # add_library( [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] # 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). ADD_LIBRARY(speed_src STATIC EXCLUDE_FROM_ALL 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 ) # Compiler flags for cppad source add_cppad_cxx_flags( speed_src ) cppad-20160000.1/speed/src/link_det_minor.cpp0000644000175200017650000000704412656321771020026 0ustar coincoin-web// $Id: link_det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin link_det_minor$$ $spell 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% ); %$$ $head Purpose$$ Each $cref/package/speed_main/package/$$ must define a version of this routine as specified below. This is used by the $cref speed_main$$ program to run the corresponding speed and correctness tests. $head Method$$ The same template class $cref det_by_minor$$ is used by the different AD packages. $head Return Value$$ If this speed test is not yet supported by a particular $icode package$$, the corresponding return value for $code link_det_minor$$ should be $code false$$. $head size$$ The argument $icode size$$ is the number of rows and columns in the matrix. $head repeat$$ The argument $icode repeat$$ is the number of different matrices that the gradient (or determinant) is computed for. $head matrix$$ The argument $icode matrix$$ is a vector with $icode%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. $head gradient$$ The argument $icode gradient$$ is a vector with $icode%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 $icode matrix$$ with respect to its elements. $subhead double$$ In the case where $icode package$$ is $code double$$, only the first element of $icode gradient$$ is used and it is actually the determinant value (the gradient value is not computed). $end ----------------------------------------------------------------------------- */ # include # include # include extern bool link_det_minor( 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); 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; } void speed_det_minor(size_t size, size_t repeat) { CppAD::vector matrix(size * size); CppAD::vector gradient(size * size); link_det_minor(size, repeat, matrix, gradient); return; } cppad-20160000.1/speed/double/0002755000175200017650000000000012656321771015005 5ustar coincoin-webcppad-20160000.1/speed/double/mat_mul.cpp0000644000175200017650000000327712656321771017156 0ustar coincoin-web// $Id: mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin double_mat_mul.cpp$$ $spell 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$$ See $cref link_mat_mul$$. $head Implementation$$ $codep */ # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize; bool link_mat_mul( size_t size , size_t repeat , CppAD::vector& x , CppAD::vector& z , CppAD::vector& dz ) { if(global_onetape||global_atomic||global_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); } return true; } /* $$ $end */ cppad-20160000.1/speed/double/det_minor.cpp0000644000175200017650000000333212656321771017470 0ustar coincoin-web// $Id: det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin double_det_minor.cpp$$ $spell onetape retape bool cppad det CppAD hpp $$ $section Double Speed: Determinant by Minor Expansion$$ $mindex link_det_minor speed$$ $head Specifications$$ See $cref link_det_minor$$. $head Implementation$$ $codep */ # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize; bool link_det_minor( size_t size , size_t repeat , CppAD::vector &matrix , CppAD::vector &det ) { if(global_onetape||global_atomic||global_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 */ cppad-20160000.1/speed/double/makefile.in0000644000175200017650000004735512656321771017126 0ustar coincoin-web# 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 = speed_double$(EXEEXT) subdir = speed/double 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_speed_double_OBJECTS = main.$(OBJEXT) det_lu.$(OBJEXT) \ det_minor.$(OBJEXT) mat_mul.$(OBJEXT) ode.$(OBJEXT) \ poly.$(OBJEXT) sparse_hessian.$(OBJEXT) \ sparse_jacobian.$(OBJEXT) speed_double_OBJECTS = $(am_speed_double_OBJECTS) speed_double_LDADD = $(LDADD) speed_double_DEPENDENCIES = 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 = $(speed_double_SOURCES) DIST_SOURCES = $(speed_double_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 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # # 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 # # BEGIN DEBUG # AM_CXXFLAGS = -g $(CXX_FLAGS) -DCPPAD_DOUBLE_SPEED # END DEBUG # LDADD = -lspeed AM_LDFLAGS = -L../src # speed_double_SOURCES = \ main.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ ode.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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) --gnu speed/double/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/double/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) speed_double$(EXEEXT): $(speed_double_OBJECTS) $(speed_double_DEPENDENCIES) $(EXTRA_speed_double_DEPENDENCIES) @rm -f speed_double$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(speed_double_OBJECTS) $(speed_double_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_lu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_minor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mat_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_hessian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_jacobian.Po@am__quote@ .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: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: makefile installdirs: install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) 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: all check check-am install 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 main.cpp: cp $(srcdir)/../main.cpp main.cpp test: check ./speed_double correct 123 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: cppad-20160000.1/speed/double/poly.cpp0000644000175200017650000000327612656321771016502 0ustar coincoin-web// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin double_poly.cpp$$ $spell onetape retape bool cppad CppAD hpp $$ $section Double Speed: Evaluate a Polynomial$$ $mindex link_poly speed$$ $head Specifications$$ See $cref link_poly$$. $head Implementation$$ $codep */ # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize; 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 { if(global_onetape||global_atomic||global_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 */ cppad-20160000.1/speed/double/sparse_jacobian.cpp0000644000175200017650000000431612656321771020636 0ustar coincoin-web// $Id: sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin double_sparse_jacobian.cpp$$ $spell 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$$ See $cref link_sparse_jacobian$$. $head Implementation$$ $codep */ # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize, global_boolsparsity; 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 ) { if(global_onetape||global_atomic||global_optimize||global_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; } /* $$ $end */ cppad-20160000.1/speed/double/ode.cpp0000644000175200017650000000331712656321771016262 0ustar coincoin-web// $Id: ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin double_ode.cpp$$ $spell onetape Jacobian CppAD cppad hpp bool cstring retape resize endif $$ $section Double Speed: Ode Solution$$ $mindex link_ode speed$$ $head Specifications$$ See $cref link_ode$$. $head Implementation$$ $codep */ # include # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize; bool link_ode( size_t size , size_t repeat , CppAD::vector &x , CppAD::vector &jacobian ) { if(global_onetape||global_atomic||global_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 */ cppad-20160000.1/speed/double/sparse_hessian.cpp0000644000175200017650000000420212656321771020514 0ustar coincoin-web// $Id: sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin double_sparse_hessian.cpp$$ $spell onetape boolsparsity const hes bool cppad hpp CppAD $$ $section Double Speed: Sparse Hessian$$ $mindex link_sparse_hessian speed$$ $head Specifications$$ See $cref link_sparse_hessian$$. $head Implementation$$ $codep */ # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize, global_boolsparsity; 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 ) { if(global_onetape||global_atomic||global_optimize||global_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; } /* $$ $end */ cppad-20160000.1/speed/double/makefile.am0000644000175200017650000000254212656321771017102 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp main.cpp: cp $(srcdir)/../main.cpp main.cpp # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # 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 # LDADD = -lspeed AM_LDFLAGS = -L../src # speed_double_SOURCES = \ main.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ ode.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp test: check ./speed_double correct 123 cppad-20160000.1/speed/double/CMakeLists.txt0000644000175200017650000000325312656321771017546 0ustar coincoin-web# $Id: CMakeLists.txt 3122 2014-02-26 03:23:19Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the speed/double directory tests # Inherit environment from ../CMakeList.txt # CMAKE_BUILD_TYPE determined by parent directory # Adds flags to the compiler command line for sources in the current directory # and below. This command can be used to add any flags, but it was originally # intended to add preprocessor definitions. ADD_DEFINITIONS("-DCPPAD_DOUBLE_SPEED") # Local include directories to search (not in package_prefix/includdir) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(speed_double EXCLUDE_FROM_ALL ../main.cpp det_lu.cpp det_minor.cpp mat_mul.cpp ode.cpp poly.cpp sparse_hessian.cpp sparse_jacobian.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags( speed_double ) # double does not use any external library TARGET_LINK_LIBRARIES(speed_double speed_src ) # Add the check_speed_double target ADD_CUSTOM_TARGET(check_speed_double speed_double correct 54321 DEPENDS speed_double speed_src ) cppad-20160000.1/speed/double/det_lu.cpp0000644000175200017650000000335212656321771016766 0ustar coincoin-web// $Id: det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin double_det_lu.cpp$$ $spell onetape bool cppad hpp Lu det CppAD $$ $section Double Speed: Determinant Using Lu Factorization$$ $mindex link_det_lu speed matrix factor$$ $head Specifications$$ See $cref link_det_lu$$. $head Implementation$$ $codep */ # include # include # include // Note that CppAD uses global_memory at the main program level extern bool global_onetape, global_atomic, global_optimize; bool link_det_lu( size_t size , size_t repeat , CppAD::vector &matrix , CppAD::vector &det ) { if(global_onetape||global_atomic||global_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 */ cppad-20160000.1/speed/sacado/0002755000175200017650000000000012656321771014765 5ustar coincoin-webcppad-20160000.1/speed/sacado/det_minor.cpp0000644000175200017650000000472612656321771017460 0ustar coincoin-web// $Id: det_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sacado_det_minor.cpp$$ $spell 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$$ See $cref link_det_minor$$. $head Implementation$$ $codep */ # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_minor( size_t size , size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { // speed test global option values if( global_atomic ) return false; if( global_memory || global_onetape || global_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 */ cppad-20160000.1/speed/sacado/makefile.in0000644000175200017650000004763512656321771017107 0ustar coincoin-web# 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 = speed_sacado$(EXEEXT) subdir = speed/sacado 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_speed_sacado_OBJECTS = main.$(OBJEXT) det_lu.$(OBJEXT) \ det_minor.$(OBJEXT) mat_mul.$(OBJEXT) ode.$(OBJEXT) \ poly.$(OBJEXT) sparse_hessian.$(OBJEXT) \ sparse_jacobian.$(OBJEXT) speed_sacado_OBJECTS = $(am_speed_sacado_OBJECTS) speed_sacado_LDADD = $(LDADD) speed_sacado_DEPENDENCIES = 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 = $(speed_sacado_SOURCES) DIST_SOURCES = $(speed_sacado_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 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp # AM_CPPFLAGS = \ -I$(top_srcdir) \ -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 # speed_sacado_SOURCES = \ main.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ ode.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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) --gnu speed/sacado/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/sacado/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) speed_sacado$(EXEEXT): $(speed_sacado_OBJECTS) $(speed_sacado_DEPENDENCIES) $(EXTRA_speed_sacado_DEPENDENCIES) @rm -f speed_sacado$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(speed_sacado_OBJECTS) $(speed_sacado_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_lu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_minor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mat_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_hessian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_jacobian.Po@am__quote@ .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: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: makefile installdirs: install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) 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." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) 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: all check check-am install 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 main.cpp: cp $(srcdir)/../main.cpp main.cpp test: check ./speed_sacado correct 123 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: cppad-20160000.1/speed/sacado/poly.cpp0000644000175200017650000000534212656321771016456 0ustar coincoin-web// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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 $$ $section Sacado Speed: Second Derivative of a Polynomial$$ $mindex link_poly speed$$ $head Specifications$$ See $cref link_poly$$. $head Implementation$$ $codep */ # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; 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 { if( global_atomic ) return false; if( global_memory || global_onetape || global_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 */ cppad-20160000.1/speed/sacado/sparse_jacobian.cpp0000644000175200017650000000240312656321771020611 0ustar coincoin-web// $Id: sparse_jacobian.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. -------------------------------------------------------------------------- */ # include # include /* $begin sacado_sparse_jacobian.cpp$$ $spell const bool CppAD sacado sparse_jacobian $$ $section sacado Speed: sparse_jacobian$$ $codep */ // 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 ) { return false; } /* $$ $end */ cppad-20160000.1/speed/sacado/ode.cpp0000644000175200017650000000467012656321771016245 0ustar coincoin-web// $Id: ode.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sacado_ode.cpp$$ $spell jacobian Sacado cppad hpp bool onetape CppAD typedef endif cassert $$ $section Sacado Speed: Gradient of Ode Solution$$ $mindex link_ode speed$$ $head Specifications$$ See $cref link_ode$$. $head Implementation$$ $codep */ # include // # include # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_ode( size_t size , size_t repeat , CppAD::vector &x , CppAD::vector &jacobian ) { // speed test global option values if( global_atomic ) return false; if( global_memory || global_onetape || global_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 */ cppad-20160000.1/speed/sacado/sparse_hessian.cpp0000644000175200017650000000240212656321771020474 0ustar coincoin-web// $Id: sparse_hessian.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. -------------------------------------------------------------------------- */ # include /* $begin sacado_sparse_hessian.cpp$$ $spell boolsparsity const Sacado bool CppAD $$ $section Sacado Speed: Sparse Hessian$$ $codep */ // 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 ) { return false; } /* $$ $end */ cppad-20160000.1/speed/sacado/makefile.am0000644000175200017650000000302212656321771017054 0ustar coincoin-web# $Id: makefile.am 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. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp main.cpp: cp $(srcdir)/../main.cpp main.cpp # # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # check_PROGRAMS = speed_sacado # AM_CPPFLAGS = \ -I$(top_srcdir) \ -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 # speed_sacado_SOURCES = \ main.cpp \ det_lu.cpp \ det_minor.cpp \ mat_mul.cpp \ ode.cpp \ poly.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp test: check ./speed_sacado correct 123 cppad-20160000.1/speed/sacado/CMakeLists.txt0000644000175200017650000000507712656321771017534 0ustar coincoin-web# $Id: CMakeLists.txt 3320 2014-09-11 23:06:21Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the speed/sacado directory tests # Inherit environment from ../CMakeList.txt # CMAKE_BUILD_TYPE determined by parent directory # assert sacado_prefix is defined IF ( NOT 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 # and below. This command can be used to add any flags, but it was originally # intended to add preprocessor definitions. ADD_DEFINITIONS("-DCPPAD_SACADO_SPEED -DRAD_AUTO_AD_Const") # Local include directories to search (not in package_prefix/includdir) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(speed_sacado EXCLUDE_FROM_ALL ../main.cpp det_lu.cpp det_minor.cpp mat_mul.cpp ode.cpp poly.cpp sparse_hessian.cpp sparse_jacobian.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags( speed_sacado ) # Find name used for teuchos library SET(teuchos_lib NOTFOUND) FOREACH(dir ${cmake_install_libdirs}) FILE(GLOB file_list ${sacado_prefix}/${dir}/libteuchoscore.*) IF(file_list) SET(teuchos_lib teuchoscore) ENDIF(file_list) FILE(GLOB file_list ${sacado_prefix}/${dir}/libteuchos.*) IF(file_list) SET(teuchos_lib teuchos) ENDIF(file_list) ENDFOREACH(dir) # List of libraries to be linked into the specified target IF(teuchos_lib) TARGET_LINK_LIBRARIES(speed_sacado speed_src sacado ${teuchos_lib}) ELSE(teuchos_lib) MESSAGE(FATAT_ERROR " For all dir in cmake_install_libdirs, cannot find either sacado_prefix/dir/teuchos sacado_prefix/dir/teuchoscore where sacado_prefix = ${sacado_prefix} cmake_install_libdirs = ${cmake_install_libdirs} teuchos_lib= ${teuchos_lib} " ) ENDIF(teuchos_lib) # # Add the check_speed_sacado target ADD_CUSTOM_TARGET(check_speed_sacado speed_sacado correct 54321 DEPENDS speed_sacado speed_src ) cppad-20160000.1/speed/sacado/det_lu.cpp0000644000175200017650000000474212656321771016752 0ustar coincoin-web// $Id: det_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sacado_det_lu.cpp$$ $spell 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$$ See $cref link_det_lu$$. $head Implementation$$ $codep */ # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_det_lu( size_t size , size_t repeat , CppAD::vector &matrix , CppAD::vector &gradient ) { // speed test global option values if( global_onetape || global_atomic ) return false; if( global_memory || global_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 */ cppad-20160000.1/speed/sacado/mat_mul.cpp0000644000175200017650000000517112656321771017131 0ustar coincoin-web// $Id: mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sacado_mat_mul.cpp$$ $spell 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$$ See $cref link_mat_mul$$. $head Implementation$$ $codep */ # include # include # include # include // list of possible options extern bool global_memory, global_onetape, global_atomic, global_optimize; bool link_mat_mul( size_t size , size_t repeat , CppAD::vector& x , CppAD::vector& z , CppAD::vector& dz ) { // speed test global option values if( global_memory || global_onetape || global_atomic || global_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; } /* $$ $end */ cppad-20160000.1/speed/example/0002755000175200017650000000000012656321771015166 5ustar coincoin-webcppad-20160000.1/speed/example/makefile.in0000644000175200017650000005052212656321771017275 0ustar coincoin-web# 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 = speed_example$(EXEEXT) subdir = speed/example 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__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) speed_example_OBJECTS = $(am_speed_example_OBJECTS) speed_example_LDADD = $(LDADD) speed_example_DEPENDENCIES = 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 = $(speed_example_SOURCES) DIST_SOURCES = $(speed_example_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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # EXTRA_DIST = \ speed_program.cpp # AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # AM_CXXFLAGS = -g $(CXX_FLAGS) # LDADD = -lspeed AM_LDFLAGS = -L../src speed_example_SOURCES = \ 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 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) --gnu speed/example/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu speed/example/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) ../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) $(AM_V_CXXLD)$(CXXLINK) $(speed_example_OBJECTS) $(speed_example_LDADD) $(LIBS) 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@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elapsed_seconds.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mat_sum_sq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_evaluate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_hes_fun.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_jac_fun.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/speed_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time_test.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) -rm -f ../src/$(DEPDIR)/$(am__dirstamp) -rm -f ../src/$(am__dirstamp) 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 ../src/$(DEPDIR) ./$(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 ../src/$(DEPDIR) ./$(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 ./speed_example # 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: cppad-20160000.1/speed/example/sparse_jac_fun.cpp0000644000175200017650000000367412656321771020664 0ustar coincoin-web// $Id: sparse_jac_fun.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sparse_jac_fun.cpp$$ $spell jac $$ $section sparse_jac_fun: Example and test$$ $mindex sparse_jac_fun$$ $code $verbatim%speed/example/sparse_jac_fun.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include bool sparse_jac_fun(void) { using CppAD::NearEqual; using CppAD::AD; 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; } // END C++ cppad-20160000.1/speed/example/det_of_minor.cpp0000644000175200017650000000401012656321771020327 0ustar coincoin-web// $Id: det_of_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin det_of_minor.cpp$$ $spell det Cpp $$ $section Determinant of a Minor: Example and Test$$ $mindex det_of_minor$$ $code $verbatim%speed/example/det_of_minor.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include 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 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) ); return ok; } // END C++ cppad-20160000.1/speed/example/sparse_hes_fun.cpp0000644000175200017650000000415212656321771020676 0ustar coincoin-web// $Id: sparse_hes_fun.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sparse_hes_fun.cpp$$ $spell hes $$ $section sparse_hes_fun: Example and test$$ $mindex sparse_hes_fun$$ $code $verbatim%speed/example/sparse_hes_fun.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include bool sparse_hes_fun(void) { using CppAD::NearEqual; bool ok = true; 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; } // END C++ cppad-20160000.1/speed/example/det_by_lu.cpp0000644000175200017650000000274612656321771017647 0ustar coincoin-web// $Id: det_by_lu.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin det_by_lu.cpp$$ $spell Cpp Lu $$ $section Determinant Using Lu Factorization: Example and Test$$ $mindex minors$$ $code $verbatim%speed/example/det_by_lu.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool det_by_lu() { bool ok = true; // dimension of the matrix size_t n = 3; // 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]; // 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, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/speed/example/speed_program.cpp0000644000175200017650000000423612656321771020524 0ustar coincoin-web// $Id: speed_program.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin speed_program.cpp$$ $spell 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 $$ $head Program$$ $codep */ # 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; // 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; } /* $$ $head Output$$ 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 $$ $end */ cppad-20160000.1/speed/example/makefile.am0000644000175200017650000000237712656321771017271 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 = # EXTRA_DIST = \ speed_program.cpp # check_PROGRAMS = speed_example # AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # AM_CXXFLAGS = -g $(CXX_FLAGS) # LDADD = -lspeed AM_LDFLAGS = -L../src speed_example_SOURCES = \ 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 test: check ./speed_example cppad-20160000.1/speed/example/mat_sum_sq.cpp0000644000175200017650000000332412656321771020042 0ustar coincoin-web// $Id: mat_sum_sq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin mat_sum_sq.cpp$$ $spell sq $$ $section Sum of the Elements of the Square of a Matrix: Example and Test$$ $mindex mat_sum_sq$$ $code $verbatim%speed/example/mat_sum_sq.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include # include 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 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; } // END C++ cppad-20160000.1/speed/example/det_by_minor.cpp0000644000175200017650000000273112656321771020345 0ustar coincoin-web// $Id: det_by_minor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin det_by_minor.cpp$$ $spell Cpp $$ $section Determinant Using Expansion by Minors: Example and Test$$ $mindex minors$$ $code $verbatim%speed/example/det_by_minor.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool det_by_minor() { bool ok = true; // dimension of the matrix size_t n = 3; // 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]; // 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; } // END C++ cppad-20160000.1/speed/example/elapsed_seconds.cpp0000644000175200017650000000264212656321771021027 0ustar coincoin-web// $Id: elapsed_seconds.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin elapsed_seconds.cpp$$ $spell Cpp Lu $$ $section Elapsed Seconds: Example and Test$$ $mindex seconds timer$$ $code $verbatim%speed/example/elapsed_seconds.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include # include # 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; } // END C++ cppad-20160000.1/speed/example/example.cpp0000644000175200017650000000640212656321771017325 0ustar coincoin-web// $Id: example.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin speed_example.cpp$$ $spell $$ $section Run the Speed Examples$$ $mindex program$$ $head Running Tests$$ To build this program and run its correctness tests see $cref cmake_check$$. $code $verbatim%speed/example/example.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include // 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( ! ok ); } // END C++ cppad-20160000.1/speed/example/CMakeLists.txt0000644000175200017650000000267712656321771017740 0ustar coincoin-web# $Id: CMakeLists.txt 3122 2014-02-26 03:23:19Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the speed/cppad directory tests # Inherit environment from ../CMakeList.txt # CMAKE_BUILD_TYPE determined by parent directory # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) # We do not add ../src/speed_src library to avoid undefined externals. # Instead we build our own copy of ../src/microsoft_timer.cpp. ADD_EXECUTABLE(speed_example EXCLUDE_FROM_ALL 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" ) # Compiler flags for cppad source add_cppad_cxx_flags( speed_example ) # Add the check_speed_example target ADD_CUSTOM_TARGET(check_speed_example speed_example DEPENDS speed_example speed_src ) cppad-20160000.1/speed/example/ode_evaluate.cpp0000644000175200017650000000322412656321771020326 0ustar coincoin-web// $Id: ode_evaluate.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ode_evaluate.cpp$$ $spell $$ $section ode_evaluate: Example and test$$ $mindex ode_evaluate$$ $code $verbatim%speed/example/ode_evaluate.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include bool ode_evaluate(void) { using CppAD::NearEqual; using CppAD::AD; 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); return ok; } // END C++ cppad-20160000.1/speed/example/time_test.cpp0000644000175200017650000000405612656321771017672 0ustar coincoin-web// $Id: time_test.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin time_test.cpp$$ $spell cppad.hpp Microsoft namespace std const cout ctime ifdef const endif cpp $$ $section time_test: Example and test$$ $mindex time_test$$ $code $verbatim%speed/example/time_test.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include namespace { // empty namespace using CppAD::vector; // 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] = i; b[i] = 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; } // END C++ cppad-20160000.1/speed/example/speed_test.cpp0000644000175200017650000000423112656321771020027 0ustar coincoin-web// $Id: speed_test.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin speed_test.cpp$$ $spell cppad.hpp Microsoft namespace std const cout ctime ifdef const endif cpp $$ $section speed_test: Example and test$$ $mindex speed_test$$ $code $verbatim%speed/example/speed_test.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # 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] = i; b[i] = 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_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++ cppad-20160000.1/speed/CMakeLists.txt0000644000175200017650000000374112656321771016276 0ustar coincoin-web# $Id: CMakeLists.txt 3754 2015-11-26 22:23:05Z 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. # ----------------------------------------------------------------------------- # Build the speed/* directory tests # Inherit environment from ../CMakeList.txt # CppAD developers use DEBUG for debugging speed tests. # SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -DNDEBUG") # Specify build type for this directory and all its subdirectories. # Possible values are DEBUG, RELEASE, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE RELEASE) # Initialize list of tests as empty SET(check_depends "") # The CMakeLists.txt file in the specified source directory is processed # before the current input file continues beyond this command. # add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL]) ADD_SUBDIRECTORY(src) # ADD_SUBDIRECTORY(cppad) add_to_list(check_depends check_speed_cppad) # ADD_SUBDIRECTORY(double) add_to_list(check_depends check_speed_double) # ADD_SUBDIRECTORY(example) add_to_list(check_depends check_speed_example) # IF ( cppad_profile_flag ) ADD_SUBDIRECTORY(profile) add_to_list(check_depends check_speed_profile) ENDIF ( cppad_profile_flag ) # IF ( adolc_prefix ) ADD_SUBDIRECTORY(adolc) add_to_list(check_depends check_speed_adolc) ENDIF( adolc_prefix ) IF ( fadbad_prefix ) ADD_SUBDIRECTORY(fadbad) add_to_list(check_depends check_speed_fadbad) ENDIF( fadbad_prefix ) IF ( sacado_prefix ) ADD_SUBDIRECTORY(sacado) add_to_list(check_depends check_speed_sacado) ENDIF( sacado_prefix ) # check_speed ADD_CUSTOM_TARGET(check_speed DEPENDS ${check_depends} ) cppad-20160000.1/configure.ac0000644000175200017650000006112612656321771014725 0ustar coincoin-webdnl $Id: configure.ac 3786 2016-02-08 13:14:26Z bradbell $ dnl --------------------------------------------------------------------------- dnl CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell dnl dnl CppAD is distributed under multiple licenses. This distribution is under dnl the terms of the dnl GNU General Public License Version 3. dnl dnl A copy of this license is included in the COPYING file of this distribution. dnl Please visit http://www.coin-or.org/CppAD/ for information on other licenses. dnl --------------------------------------------------------------------------- dnl dnl Process this file with autoconf to produce a configure script. dnl package version bug-report AC_INIT([cppad], [20160000.1], [cppad@list.coin-or.org]) AM_SILENT_RULES([yes]) dnl By defalut disable maintainer mode when running configure; dnl --enable-maintainer-mode will enable it. dnl This avoids the autoconf and automake tools being launched by make AM_MAINTAINER_MODE dnl Set the default install prefix to the installers home directory dnl cygwin begin delete: AC_PREFIX_DEFAULT(${HOME}) dnl cygwin end delete: dnl cygwin replace: AC_PREFIX_DEFAULT(/usr) dnl Run any macros required for proper operation of generated makefiles dnl nostdinc: Do not define standard include directories in generated makefiles dnl Note this must come before AC_PROG_CC; see dnl http://lists.gnu.org/archive/html/automake/2010-08/msg00113.html AM_INIT_AUTOMAKE([nostdinc subdir-objects -Wall]) # check if we have ar program have_ar='yes' AM_PROG_AR([have_ar='no']) AC_MSG_NOTICE([have_ar = $have_ar]) dnl ---------------------------------------------------------------------- AC_MSG_NOTICE([*** Check command line arguments that are longer used ****]) if test "$CPP_ERROR_WARN" != "" ; then AC_MSG_ERROR([The CPP_ERROR_WARN configure option is now CXX_FLAGS]) fi dnl AC_ARG_WITH(SpeedExample, AC_HELP_STRING( [--with-SpeedExample], [is not necessary, see install instructions.]), [SpeedExample="yes"], [SpeedExample="no"] ) if test "$SpeedExample" = "yes" ; then AC_MSG_ERROR([--with-SpeedExample not necessary, see install instructions.]) fi dnl AC_ARG_WITH(profiling, AC_HELP_STRING( [--with-profiling], [is not necessary, see install instructions.]), [profiling="yes"], [profiling="no"] ) if test "$profiling" = "yes" ; then AC_MSG_ERROR([--with-profiling not necessary, see install instructions.]) fi dnl AC_ARG_WITH(Speed, AC_HELP_STRING( [--with-Speed], [is not necessary, see install instructions.]), [Speed="yes"], [Speed="no"] ) if test "$Speed" = "yes" ; then AC_MSG_ERROR([--with-Speed not necessary, see install instructions.]) fi dnl AC_ARG_WITH(Introduction, AC_HELP_STRING( [--with-Introduction], [is not necessary, see install instructions.]), [Introduction="yes"], [Introduction="no"] ) if test "$Introduction" = "yes" ; then AC_MSG_ERROR([--with-Introduction not necessary, see install instructions.]) fi dnl AC_ARG_WITH(Example, AC_HELP_STRING( [--with-Example], [is not necessary, see install instructions.]), [Example="yes"], [Example="no"] ) if test "$Example" = "yes" ; then AC_MSG_ERROR([--with-Example not necessary, see install instructions.]) fi dnl AC_ARG_WITH(TestMore, AC_HELP_STRING( [--with-TestMore], [is not necessary, see install instructions.]), [TestMore="yes"], [TestMore="no"] ) if test "$TestMore" = "yes" ; then AC_MSG_ERROR([--with-TestMore not necessary, see install instructions.]) fi dnl AC_ARG_WITH(PrintFor, AC_HELP_STRING( [--with-PrintFor], [is not necessary, see install instructions.]), [PrintFor="yes"], [PrintFor="no"] ) if test "$PrintFor" = "yes" ; then AC_MSG_ERROR([--with-PrintFor not necessary, see install instructions.]) fi dnl -------------------------------------------------------------------------- AC_MSG_NOTICE([****** Check command line arguments that are used ***********]) dnl ----------------------------------------------------------------------- dnl The case where enable_msvc != no is defined and supported by Ted Ralphs AC_MSG_CHECKING([--enable-msvc]) AC_ARG_ENABLE([msvc], [AC_HELP_STRING([--enable-msvc], [Prefer (i)cl/ifort/link over GNU on MinGW/Cygwin.])], [enable_msvc=$enableval], [enable_msvc=no] ) AC_MSG_RESULT([$enable_msvc]) dnl the prefix directory corresponding to CppAD ------------------------- dnl The following seems to work but NONE is not in autoconf specifications AC_MSG_CHECKING([--prefix]) if test "$prefix" = "NONE" ; then AC_MSG_RESULT([$HOME]) else AC_MSG_RESULT([$prefix]) fi dnl Are we installing the documentation ----------------------------------- dnl cygwin begin delete: AC_MSG_CHECKING([--with-Documentation]) AC_ARG_WITH(Documentation, AC_HELP_STRING([--with-Documentation], [default is no]), [Documentation="yes"], [Documentation="no"] ) AM_CONDITIONAL(CppAD_DOCUMENTATION, test "$Documentation" = "yes") AC_MSG_RESULT([$Documentation]) dnl cygwin end delete: dnl cygwin replace: AM_CONDITIONAL(CppAD_DOCUMENTATION, test "yes" = "yes") dnl Are we using standard vectors ---------------------------------------- AC_MSG_CHECKING([--with-stdvector]) AC_ARG_WITH(stdvector, AC_HELP_STRING([--with-stdvector], [default is no]), [stdvector="yes"], [stdvector="no"] ) if test "$stdvector" = "yes" ; then AC_SUBST(cppad_stdvector, 1) else AC_SUBST(cppad_stdvector, 0) fi AC_MSG_RESULT([$stdvector]) dnl Are we using boost vectors ---------------------------------------- AC_MSG_CHECKING([--with-boostvector]) AC_ARG_WITH(boostvector, AC_HELP_STRING([--with-boostvector], [default is no]), [boostvector="yes"], [boostvector="no"] ) AC_MSG_RESULT([$boostvector]) if test "$boostvector" = "yes" ; then if test "$stdvector" != "no" ; then AC_MSG_ERROR([cannot --with both stdvector and boostvector]) fi AC_SUBST(cppad_boostvector, 1) else AC_SUBST(cppad_boostvector, 0) fi dnl Are we using eigen vectors ---------------------------------------- AC_MSG_CHECKING([--with-eigenvector]) AC_ARG_WITH(eigenvector, AC_HELP_STRING([--with-eigenvector], [default is no]), [eigenvector="yes"], [eigenvector="no"] ) AC_MSG_RESULT([$eigenvector]) if test "$eigenvector" = "yes" ; then if test "$stdvector" != "no" ; then AC_MSG_ERROR([cannot --with both stdvector and eigenvector]) fi if test "$boostvector" != "no" ; then AC_MSG_ERROR([cannot --with both boostvector and eigenvector]) fi AC_SUBST(cppad_eigenvector, 1) else AC_SUBST(cppad_eigenvector, 0) fi dnl Are we using sparse_set or sparse_list ---------------------------- AC_MSG_CHECKING([--with-sparse_set]) AC_ARG_WITH(sparse_set, AC_HELP_STRING([--with-sparse_set], [default is not specified]), [sparse_set="yes"], [sparse_set="no"] ) AC_MSG_RESULT([$sparse_set]) dnl AC_MSG_CHECKING([--with-sparse_list]) AC_ARG_WITH(sparse_list, AC_HELP_STRING([--with-sparse_list], [default is not specified]), [sparse_list="yes"], [sparse_list="no"] ) AC_MSG_RESULT([$sparse_list]) if test "$sparse_set" = "yes" ; then if test "$sparse_list" == "yes" ; then AC_MSG_ERROR([cannot --with both sparse_set and sparse_list]) fi AC_SUBST(cppad_internal_sparse_set, sparse_set) else AC_SUBST(cppad_internal_sparse_set, sparse_list) fi dnl Are we including deprecated features in the install----------- AC_MSG_CHECKING([--with-deprecated]) AC_ARG_WITH(deprecated, AC_HELP_STRING( [--with-deprecated], [include an implicit AD constructor from any type] ), [deprecated="yes"], [deprecated="no"] ) AC_MSG_RESULT([$deprecated]) AM_CONDITIONAL(CppAD_DEPRECATED, test "$deprecated" = 'yes' ) if test "$deprecated" = "yes" ; then AC_SUBST(cppad_deprecated, "1") else AC_SUBST(cppad_deprecated, "0") fi dnl The postfix directiory corresponding to CppAD ------------------------ AC_MSG_CHECKING([POSTFIX_DIR]) AC_ARG_VAR(POSTFIX_DIR, [postfix directory for CppAD installation] ) AM_CONDITIONAL(CppAD_POSTFIX, test "$POSTFIX_DIR" != "") if test "$POSTFIX_DIR" != "" ; then AC_MSG_RESULT([$POSTFIX_DIR]) else AC_MSG_RESULT([no]) fi dnl The prefix corresponding to the installation of Adolc --------------- AC_MSG_CHECKING([ADOLC_DIR]) AC_ARG_VAR(ADOLC_DIR, [value of configure prefix directory during Adolc install] ) AM_CONDITIONAL(CppAD_ADOLC, test "$ADOLC_DIR" != "") if test "$ADOLC_DIR" != "" ; then AC_MSG_RESULT([$ADOLC_DIR]) if test "$have_ar" = "no"; then AC_MSG_ERROR([ar is missing and ADOLC_DIR is present]) fi else AC_MSG_RESULT([no]) fi dnl The prefix corresponding to the installation of Eigen --------------- AC_MSG_CHECKING([EIGEN_DIR]) AC_ARG_VAR(EIGEN_DIR, [value of configure prefix directory during Eigen install] ) AM_CONDITIONAL(CppAD_EIGEN_DIR, test "$EIGEN_DIR" != "") if test "$EIGEN_DIR" != "" ; then AC_MSG_RESULT([$EIGEN_DIR]) AC_SUBST(EIGEN_INCLUDE, [-I$EIGEN_DIR/include]) else AC_MSG_RESULT([no]) AC_SUBST(EIGEN_INCLUDE, []) fi dnl The directory corresponding to the installation of FADBAD ----------- AC_MSG_CHECKING([FADBAD_DIR]) AC_ARG_VAR(FADBAD_DIR, [parent directory directly above FADBAD++ directory] ) AM_CONDITIONAL(CppAD_FADBAD, test "$FADBAD_DIR" != "") if test "$FADBAD_DIR" != "" ; then AC_MSG_RESULT([$FADBAD_DIR]) if test "$have_ar" = "no"; then AC_MSG_ERROR([ar is missing and FADBAD_DIR is present]) fi else AC_MSG_RESULT([no]) fi dnl The directory corresponding to the installation of SACADO ----------- AC_MSG_CHECKING([SACADO_DIR]) AC_ARG_VAR(SACADO_DIR, [value of the configure prefix directory during Sacado install] ) AM_CONDITIONAL(CppAD_SACADO, test "$SACADO_DIR" != "") if test "$SACADO_DIR" != "" ; then AC_MSG_RESULT([$SACADO_DIR]) if test "$have_ar" = "no"; then AC_MSG_ERROR([ar is missing and SACADO_DIR is present]) fi else AC_MSG_RESULT([no]) fi dnl The directory corresponding to the installation of IPOPT ----------- AC_MSG_CHECKING([IPOPT_DIR]) AC_ARG_VAR(IPOPT_DIR, [value of the configure prefix directory during Ipopt install] ) AM_CONDITIONAL(CppAD_IPOPT, test "$IPOPT_DIR" != "") if test "$IPOPT_DIR" != "" ; then AC_MSG_RESULT([$IPOPT_DIR]) if test "$have_ar" = "no"; then AC_MSG_ERROR([ar is missing and IPOPT_DIR is present]) fi else AC_MSG_RESULT([no]) fi dnl The directory corresponding to the installation of BOOST ------------ AC_MSG_CHECKING([BOOST_DIR]) AC_ARG_VAR(BOOST_DIR, [parent directory directly above boost directory] ) AM_CONDITIONAL(CppAD_BOOST_DIR, test "$BOOST_DIR" != "") if test "$BOOST_DIR" != "" ; then AC_MSG_RESULT([$BOOST_DIR]) AC_SUBST(BOOST_INCLUDE, [-I$BOOST_DIR/include]) else AC_MSG_RESULT([no]) AC_SUBST(BOOST_INCLUDE,[]) fi dnl The C++ compiler flags CXX_FLAGS ------------------------------------- dnl see AC_SUBST(CXXFLAGS, "") next to AC_PROG_CXX # AC_MSG_CHECKING([CXX_FLAGS]) AC_ARG_VAR(CXX_FLAGS, [ CXXFLAGS is ignored, use CXX_FLAGS for compiler flags] ) # cxx_flags for fadbad and eigen if test "$CXX_FLAGS" != "" ; then AC_MSG_RESULT([$CXX_FLAGS]) cxx_flags_fadbad=`echo "$CXX_FLAGS" | sed -e 's|-Wshadow||'` cxx_flags_eigen="$cxx_flags_fadbda -Wno-long-long" else AC_MSG_RESULT([no]) cxx_flags_fadbad="" cxx_flags_eigen="" fi AC_SUBST(CXX_FLAGS_FADBAD, "$cxx_flags_fadbad") AC_SUBST(CXX_FLAGS_EIGEN, "$cxx_flags_eigen") dnl The compiler OpenMP flags OPENMP_FLAGS ---------------------------------- AC_MSG_CHECKING([OPENMP_FLAGS]) AC_ARG_VAR(OPENMP_FLAGS, [ flags that instruct compiler to interpret OpenMP directrives ] ) if test "$OPENMP_FLAGS" != "" ; then AC_MSG_RESULT([$OPENMP_FLAGS]) else AC_MSG_RESULT([no]) fi AM_CONDITIONAL(CppAD_OPENMP, test "$OPENMP_FLAGS" != "") dnl The compiler OpenMP flags MAX_NUM_THREADS ------------------------------- AC_MSG_CHECKING([MAX_NUM_THREADS]) AC_ARG_VAR(MAX_NUM_THREADS, [ maximum number of threads that can be used with CppAD ] ) if test "$MAX_NUM_THREADS" != "" ; then AC_MSG_RESULT([$MAX_NUM_THREADS]) if test "$MAX_NUM_THREADS" -lt "4" ; then AC_MSG_ERROR( [ MAX_NUM_THREADS=$MAX_NUM_THREADS is less than 4 ] ) fi max_num_threads="$MAX_NUM_THREADS" else max_num_threads="48" AC_MSG_RESULT([no, using default value $max_num_threads]) fi AC_SUBST(cppad_max_num_threads, [$max_num_threads]) dnl type used for addresses in AD tapes [ default = unsigned int ] ----------- AC_MSG_CHECKING([TAPE_ADDR_TYPE]) AC_ARG_VAR(TAPE_ADDR_TYPE, [type used for addresses in AD tapes]) if test "$TAPE_ADDR_TYPE" == "" ; then addr_t="unsigned int" else addr_t="$TAPE_ADDR_TYPE" fi AC_SUBST(cppad_tape_addr_type, [$addr_t]) AC_MSG_RESULT([$addr_t]) ok="no" if test "$addr_t" == "size_t" ; then ok="yes" fi if test "$addr_t" == "int" ; then AC_MSG_WARN( [TAPE_ADDR_TYPE=int is for CppAD developers (not users)] ) ok="yes" fi if test "$addr_t" == "unsigned int" ; then ok="yes" fi if test "$addr_t" == "unsigned short int" ; then ok="yes" fi if test "$ok" == "no" ; then AC_MSG_ERROR( [$addr_t is not a valid choice for TAPE_ADDR_TYPE] ) fi dnl type used for tape identifier [ default = unsigned int ] ----------- AC_MSG_CHECKING([TAPE_ID_TYPE]) AC_ARG_VAR(TAPE_ID_TYPE, [type used for addresses in AD tapes]) if test "$TAPE_ID_TYPE" == "" ; then tape_id_t="unsigned int" else tape_id_t="$TAPE_ID_TYPE" fi AC_SUBST(cppad_tape_id_type, [$tape_id_t]) AC_MSG_RESULT([$tape_id_t]) ok="no" if test "$tape_id_t" == "size_t" ; then ok="yes" fi if test "$tape_id_t" == "int" ; then AC_MSG_WARN( [TAPE_ID_TYPE=int is for CppAD developers (not users)] ) ok="yes" fi if test "$tape_id_t" == "unsigned int" ; then ok="yes" fi if test "$tape_id_t" == "unsigned short int" ; then ok="yes" fi if test "$ok" == "no" ; then AC_MSG_ERROR( [$tape_id_t is not a valid choice for TAPE_ID_TYPE] ) fi AC_MSG_NOTICE([********** End Checking Command Line arguments ***************]) dnl -------------------------------------------------------------------------- if test "$enable_msvc" == "no" then cxx_list="g++ clang++ CC pgCC icpc gpp cxx cc++" cc_list="gcc clang cc pgcc icc" fc_list="gfortran ifort g95 fort77 f77 g77 pgf90 pgf77 ifc frt af77" else dnl This case defined and supported by Ted Ralphs cxx_list="icl cl g++" cc_list="icl cl gcc" fc_list="ifort gfortran" fi dnl -------------------------------------------------------------------------- dnl AC_PROG_CXX([compiler-search-list]) outputs CXX as C++ compiler to use AC_PROG_CXX([$cxx_list]) dnl erase any setting of CXXFLAGS, see CXX_FLAGS documentation AC_SUBST(CXXFLAGS, "") dnl AC_PROG_CC([compiler-search-list]) outputs CC as C++ compiler to use AC_PROG_CC([$cc_list]) dnl erase any setting of CFLAGS AC_SUBST(CFLAGS, "") dnl AC_PROG_FC ([compiler-search-list], [dialect]) AC_PROG_FC([$fc_list]) dnl not compiling any fortran so no need to touch flags dnl Check for pkgconfig AC_CHECK_PROG(have_pkg_config, [pkg-config], [yes], [no]) AM_CONDITIONAL(CppAD_PKG_CONFIG, test "$have_pkg_config" = "yes") dnl check if we can build libraries AM_CONDITIONAL(CppAD_HAVE_AR, test "$have_ar" = 'yes' ) if test "$have_ar" = 'no'; then AC_MSG_WARN( [cannot build any libraries because ar is missing; e.g,, speed/* not built] ) fi dnl test_one.sh.in settings for cppad_cxx_flags AC_SUBST(cppad_cxx_flags, "-g -O0") dnl auto-tools version does not colpack AC_SUBST(cppad_has_colpack, 0) dnl auto-tools version will assumes mkstemp is available. AC_SUBST(cppad_has_mkstemp, 1) dnl auto-tools version cannot use c++11 compiler dnl so supress corresponding features AC_SUBST(cppad_has_nullptr, 0) AC_SUBST(cppad_has_rvalue, 0) AC_SUBST(cppad_has_cstdint_8_to_64, 0) AC_SUBST(cppad_use_cplusplus_2011, 0) AC_SUBST(cppad_has_high_resolution_clock, 0) dnl Determine if size_t has same size as unsigned int AC_CHECK_SIZEOF([size_t]) AC_CHECK_SIZEOF([unsigned int]) if test "$ac_cv_sizeof_size_t" != "$ac_cv_sizeof_unsigned_int" ; then AC_SUBST(cppad_size_t_not_unsigned_int, 1) else AC_SUBST(cppad_size_t_not_unsigned_int, 0) fi dnl Determine which definition we are using for CPPAD_TESTVECTOR if test "$stdvector$boostvector$eigenvector" = "nonono" ; then AC_SUBST(cppad_cppadvector, 1) else AC_SUBST(cppad_cppadvector, 0) fi dnl the gettimeofday check automatically generates a yes / no configure msg AC_CHECK_FUNC( gettimeofday, [gettimeofday="yes"], [gettimeofday="no"] ) if test "$gettimeofday" = "yes" ; then AC_SUBST(cppad_has_gettimeofday, 1) else AC_SUBST(cppad_has_gettimeofday, 0) fi dnl Use LIBTOOL for cppad_ipopt ? dnl AC_PROG_LIBTOOL dnl Determine if ranlib is present and where it is if present (set RANLIB) AC_PROG_RANLIB AC_MSG_CHECKING([whether using Microsoft C++ compiler]) AM_CONDITIONAL(CppAD_MS_COMPILER, test "$CXX" == "cl" || test "$CXX" == "icl") if test "$CXX" == "cl" || test "$CXX" == "icl"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi dnl Have configure check source directory to see if cppad/cppad.hpp is there AC_CONFIG_SRCDIR(cppad/cppad.hpp) dnl AC_PROG_CP outputs CPP as command to run C preprocessor AC_PROG_CPP dnl Do nothing if complier supports inline, otherwise try to find a subsitute dnl definition or, if cannot, define inline as empty AC_C_INLINE dnl determine FCLIBS, flags necessary for linking C++ with modern fortran AC_FC_LIBRARY_LDFLAGS dnl absolute path corresponding to top_builddig and top_srcdir in makefile.am dnl (used by cppad-uninstalled.pc.in). abs_top_builddir=`pwd` AC_SUBST(ABS_TOP_BUILDDIR, "$abs_top_builddir") abs_top_srcdir=`cd $srcdir ; pwd` AC_SUBST(ABS_TOP_SRCDIR, "$abs_top_srcdir") dnl -------------------------------------------------------------------------- dnl Check for C libraries dnl check for pthread library AC_CHECK_LIB( [pthread], [pthread_barrier_wait], [pthread="yes"], [pthread="no"] ) AM_CONDITIONAL(CppAD_PTHREAD, test "$pthread" = "yes") if test "$pthread" == "yes" ; then AC_SUBST(PTHREAD_LIB,"-lpthread") else AC_SUBST(PTHREAD_LIB,"") fi dnl check for dl library AC_SUBST(DL_LIB, "") AC_CHECK_LIB( [dl], [dlopen], [DL_LIB="-ldl"], [DL_LIB=""] ) dnl -------------------------------------------------------------------------- dnl check for boost thread library AC_LANG_PUSH([C++]) LDFLAGS_save=$LDFLAGS CXXFLAGS_save=$CXXFLAGS boost_thread_found='no' if test "$BOOST_DIR" != '' ; then CXXFLAGS="-I$BOOST_DIR/include $CXXFLAGS" fi if test "$BOOST_DIR" == '' && test "$boost_thread_found" == 'no' ; then bthread_lib='-lboost_thread-mt' LDFLAGS="$LDFLAGS_save $bthread_lib" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [# include ], [boost::barrier wait(1);] )], [boost_thread_found='yes'], [boost_thread_found='no'] ) fi if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then bthread_lib="$BOOST_DIR/lib/libboost_thread-mt.so" LDFLAGS="$LDFLAGS_save $bthread_lib" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [# include ], [boost::barrier wait(1);] )], [boost_thread_found='yes'], [boost_thread_found='no'] ) fi if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then bthread_lib="$BOOST_DIR/lib/libboost_thread-mt.a" LDFLAGS="$LDFLAGS_save $bthread_lib" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [# include ], [boost::barrier wait(1);] )], [boost_thread_found='yes'], [boost_thread_found='no'] ) fi if test "$BOOST_DIR" == '' && test "$boost_thread_found" == 'no' ; then bthread_lib='-lboost_thread' LDFLAGS="$LDFLAGS_save $bthread_lib" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [# include ], [boost::barrier wait(1);] )], [boost_thread_found='yes'], [boost_thread_found='no'] ) fi if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then bthread_lib="$BOOST_DIR/lib/libboost_thread.so" LDFLAGS="$LDFLAGS_save $bthread_lib" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [# include ], [boost::barrier wait(1);] )], [boost_thread_found='yes'], [boost_thread_found='no'] ) fi if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then bthread_lib="$BOOST_DIR/lib/libboost_thread.a" LDFLAGS="$LDFLAGS_save $bthread_lib" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [# include ], [boost::barrier wait(1);] )], [boost_thread_found='yes'], [boost_thread_found='no'] ) fi AM_CONDITIONAL(CppAD_BTHREAD, test "$boost_thread_found" = 'yes') if test "$boost_thread_found" == 'yes' ; then AC_SUBST(BTHREAD_LIB,"$bthread_lib") AC_MSG_RESULT([boost::thread library... yes]) else AC_SUBST(BTHREAD_LIB,'') AC_MSG_RESULT([boost::thread library... no]) fi LDFLAGS=$LDFLAGS_save CXXFLAGS=$CXXFLAGS_save AC_LANG_POP([C++]) # dnl -------------------------------------------------------------------------- dnl Library directories if test -e $IPOPT_DIR/lib/coin ; then IPOPT_LIBS="-L $IPOPT_DIR/lib/coin -L $IPOPT_DIR/lib/coin/ThirdParty" IPOPT_LD_PATH="$IPOPT_DIR/lib/coin:$IPOPT_DIR/lib/coin/ThirdParty" else IPOPT_LIBS="-L $IPOPT_DIR/lib" IPOPT_LD_PATH="$IPOPT_DIR/lib" fi AC_SUBST(CPPAD_IPOPT_LD_PATH, "$IPOPT_LD_PATH") # AC_SUBST(CPPAD_IPOPT_LIBS, "$IPOPT_LIBS -lipopt") if test "$have_pkg_config" == "yes"; then dnl set CPPAD_IPOPT_LIBS PKG_CONFIG_PATH="$IPOPT_DIR/lib/pkgconfig:$IPOPT_DIR/share/pkgconfig" PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$IPOPT_DIR/lib64/pkgconfig" export PKG_CONFIG_PATH if pkg-config --libs ipopt >& /dev/null ; then CPPAD_IPOPT_LIBS=`pkg-config --libs ipopt` else dnl check for blas library AC_LANG_PUSH([Fortran]) AC_CHECK_LIB( [blas], [ddot], [CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -lblas"], ) dnl check for lapack library AC_CHECK_LIB( [lapack], [dgesv], [CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -llapack"], ) AC_LANG_POP([Fortran]) fi else dnl check for blas library AC_LANG_PUSH([Fortran]) AC_CHECK_LIB( [blas], [ddot], [CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -lblas"], ) dnl check for lapack library AC_CHECK_LIB( [lapack], [dgesv], [CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -llapack"], ) AC_LANG_POP([Fortran]) fi AC_MSG_RESULT([cppad_ipopt_nlp libraries: $CPPAD_IPOPT_LIBS]) dnl -------------------------------------------------------------------------- dnl Names set here so same cppad.pc.in works for both with cmake and autoconf. dnl (note that autoconf configuration does not allow for Colpack). dnl AC_SUBST(cppad_description, "Differentiation of C++ Algorithms") AC_SUBST(cppad_version, ${PACKAGE_VERSION} ) AC_SUBST(cppad_url, "http://www.coin-or.org/CppAD") if test "$prefix" == "NONE" ; then cppad_pkgconfig_cflags_value="-I$HOME/include" cppad_pkgconfig_libs_value="-L$HOME/lib" else cppad_pkgconfig_cflags_value="-I$prefix/include" cppad_pkgconfig_libs_value="-L$prefix/lib" fi if test "$POSTFIX_DIR" != "" ; then cppad_pkgconfig_cflags_value="$cppad_cflags_value/$POSTFIX_DIR" cppad_pkgconfig_libs_value="$cppad_pkgconfig_libs_value/$POSTFIX_DIR" fi if test "$IPOPT_DIR" == "" ; then cppad_pkgconfig_libs_value="" cppad_pkgconfig_requires_value="" else cppad_pkgconfig_libs_value="$cppad_pkgconfig_libs_value -lcppad_ipopt" cppad_pkgconfig_requires_value="ipopt" fi AC_SUBST(cppad_pkgconfig_cflags, "$cppad_pkgconfig_cflags_value") AC_SUBST(cppad_pkgconfig_libs, "$cppad_pkgconfig_libs_value") AC_SUBST(cppad_pkgconfig_requires, "$cppad_pkgconfig_requires_value") dnl dnl names set here so cppad.pc-uninstalled works both with cmake and autoconf AC_SUBST(cppad_SOURCE_DIR, ${ABS_TOP_SRCDIR} ) dnl dnl names set here so */test_one.sh.in works both with cmake and autoconf AC_SUBST(adolc_prefix, ${ADOLC_DIR} ) AC_SUBST(eigen_prefix, ${EIGEN_DIR} ) AC_SUBST(ipopt_prefix, ${IPOPT_DIR} ) dnl dnl ----------------------------------------------------------------------- dnl AC_CONFIG_FILES(file-list) for each file in the list, configure will dnl read file.in, do its substitutions, and create file AC_CONFIG_FILES([ cppad/configure.hpp cppad_ipopt/example/test.sh cppad_ipopt/speed/test.sh cppad_ipopt/test/test.sh example/ipopt_solve/test.sh example/test_one.sh pkgconfig/cppad.pc pkgconfig/cppad-uninstalled.pc test_more/test_one.sh makefile compare_c/makefile cppad_ipopt/src/makefile cppad_ipopt/example/makefile cppad_ipopt/speed/makefile cppad_ipopt/test/makefile example/makefile example/atomic/makefile example/ipopt_solve/makefile introduction/get_started/makefile introduction/exp_apx/makefile multi_thread/makefile multi_thread/test_multi/makefile print_for/makefile speed/adolc/makefile speed/cppad/makefile speed/double/makefile speed/example/makefile speed/fadbad/makefile speed/profile/makefile speed/profile/gprof.sed speed/sacado/makefile speed/src/makefile test_more/makefile ]) dnl END AC_CONFIG_FILES dnl the comment line above is used by ./new_stable.sh AC_CONFIG_COMMANDS( [example_ipopt_solve_test.sh], [chmod +x example/ipopt_solve/test.sh], ) [] AC_CONFIG_COMMANDS( [cppad_ipopt_example_test.sh], [chmod +x cppad_ipopt/example/test.sh], ) [] AC_CONFIG_COMMANDS( [cppad_ipopt_speed_test.sh], [chmod +x cppad_ipopt/speed/test.sh], [] ) AC_CONFIG_COMMANDS( [cppad_ipopt_test_test.sh], [chmod +x cppad_ipopt/test/test.sh], [] ) AC_CONFIG_COMMANDS( [example_test_one.sh], [chmod +x example/test_one.sh], [] ) AC_CONFIG_COMMANDS( [test_more_test_one.sh], [chmod +x test_more/test_one.sh], [] ) dnl create all the requested output files AC_OUTPUT cppad-20160000.1/uw_copy_040507.html0000644000175200017650000011554210527074276015633 0ustar coincoin-webVol 4, Part 5, Chapter 7

Chapter 7

PATENT, INVENTION, AND COPYRIGHT POLICY

Section 1. Patent and Invention Policy

  1. This policy covers both patented and nonpatented innovations, including computer software with commercial value, and is applicable to all faculty, staff, and students. The policy is intended to show the University's positive attitude toward transfer of results of its research to the private sector.
  2. The purpose of university research is to seek new knowledge for the general benefit. Although university research is not directed intentionally toward inventions, commercially valuable inventions do often result, and it is generally in the best interests of the University and the public that patents be obtained and/or licenses granted as described in this policy. Inventions shall be promptly reported to the University's Office of Intellectual Property and Technology Transfer and all concerned shall cooperate to assure prompt initiation of appropriate technology transfer actions. The term "invention" means any invention or discovery which is or may be patentable or otherwise protectable as to ownership. An invention may be a process, machine, manufacture, composition of matter or design, or any new or useful improvement thereof. An invention is deemed to be "made" when it is conceived or first actually reduced to practice.
  3. University employees shall report all inventions and discoveries to the University's Office of Intellectual Property and Technology Transfer. As a condition of employment, and even if a specific patent agreement is not signed, University employees agree to assign all inventions in which the University has an interest to the University, to an invention management agency designated by the University, or to the sponsor if required under agreements governing the research. Employees shall execute documents of assignment and do everything reasonably required to assist the assignee(s) in obtaining, protecting, and maintaining patent or other proprietary rights. Students who are also employees, students working on a sponsored project, and students who have used University resources (other than for lecture-based coursework) shall also report all inventions and discoveries to the University's Office of Intellectual Property and Technology Transfer and shall assign all such inventions and discoveries in the same manner as University employees. Inventions in which the University has an interest but which do not meet University criteria for patenting shall be managed in accordance with policies and procedures determined by the University Office of Intellectual Property and Technology Transfer. If and to the extent permitted by state law and other University policies, those procedures may include: (a) a mechanism by which the inventor(s) may personally pay patenting costs; (b) the formation of a commercial enterprise to pursue commercialization; and, under very rare circumstances, (c) the transfer, for appropriate consideration, of the patent rights to the inventor(s). These procedures shall be implemented at the discretion of the Vice Provost for Intellectual Property and Technology Transfer.

    Although all inventions and discoveries must be reported to the Office of Intellectual Property and Technology Transfer, there are instances when the University may choose not to assert ownership. The University will not require assignment of interests for any invention for which no equipment, supplies, facilities, or trade secret information of the University was used and which was developed entirely on the employee's own time, unless (a) the inventions related (i) directly to the business of the University, or (ii) the University's actual or demonstrably anticipated research or development, or (b) the invention results from any work performed by the employee for the University.

  4. Research funded wholly or in part by an outside sponsor is subject to this policy as modified by the provisions of the agreement covering such work. Employees engaged in sponsored research are bound by the provisions of the agreement between the University and the sponsor. Title to any inventions conceived or first reduced to practice in the course of research supported by Federal agencies, industry, or other sponsors shall generally vest in the University. In rare cases, an industrial sponsor may possess a dominant patent position in a certain technology area so that any patent the University might seek would be of little or no value. For this or other reasons, an exception to the University title policy may be approved by the University's Office of Intellectual Property and Technology Transfer when to do so will honor the general principles of this policy, protect the equities involved, and satisfy the requirements of the parties.
  5. Industry supported research is valued by the University when it embraces a proper balance between the University's educational mission and industry's quest for the development of commercial products, processes, and services. Interaction with industry may take any of several forms, including grants, contracts, consortia agreements, and affiliate programs. Industry sponsors may be assured of at least a non-exclusive license to inventions conceived or developed with their support. Where the sponsor uses the invention entirely within its own operations, the license may be royalty-free. Where the sponsor, or a third party, manufactures and sells products, services, or processes based on the invention, reasonable royalty payments to the University, or its assignee, are required. If necessary for the effective development and marketing of a University invention, an exclusive license may be granted, usually for a limited time period. Where an invention is not identifiable in advance, the University may grant the sponsor an option to an exclusive license if the sponsor agrees to finance the cost of the University's patent application and observe certain diligence requirements that will assure promptly bringing the invention into public use. The patent financing may be treated as an offset against royalties payable when the invention is marketed.
  6. The University retains the right to file patents itself or to use other patent management firms. The University has agreements with the Washington Research Foundation, Research Corporation Technologies of Tucson, Arizona and Battelle Development Corporation in Columbus, Ohio as patent and license agents.
  7. Both the University and the inventor are entitled to a share of income from licensed inventions; the University on the basis of salary and facilities support for the inventor and the cost of patent or license administration; and the inventor on the basis of creative activity, documenting the invention, and assisting as necessary with commercialization. Thus, the University allocates a share of income to the inventor. The remainder is dedicated to further research by allocating shares to the college/department (or other unit) in which the invention was conceived or first reduced to practice and to the Office of the Provost.
  8. The University may take an equity position in a company whether or not license fees or royalties are paid to the University as part of a negotiated agreement. A typical circumstance under which the University might receive equity would be as part of an agreement licensing University-developed technology to a start-up or developing business venture. Another example might occur when an employee of the University utilizes the expertise and/or technology he or she has developed in the course of University employment and assists a business venture in the commercialization of an idea. (A business venture includes corporations, partnerships, or other commercial enterprises.) Such a commercial association with the University and its employees adds both value and credibility to the new business venture. To assure a balance of interests for the business venture as well as for the University, the University will generally require that it receive an equity position in such circumstances.
  9. The University's equity interests are managed and disposed of in accordance with guidelines established by the Treasury Office in consultation with the Office of the Provost and the policies and procedures stated in the University Handbook and Administrative Policy Statements. University employees may be eligible to receive a portion of the University's equity interest in accordance with the policies and procedures described in the University's Administrative Policy Statements and as allowed under state law and University conflict of interest policies. When such equities are liquidated, the net proceeds, after recovery of all University costs and after any distributions to eligible recipients, accrue to appropriate University accounts and are administered by the Provost to promote research and technology transfer across the entire University. If the proceeds from the disposition of a particular equity interest are unusually large, the Provost shall confer with the University Budget Committee, the Research Advisory Board, or other appropriate faculty bodies, on alternative uses for amounts in excess of a base figure (set at $3 million in 2000 dollars).

    There may be situations in which both the University and its employees separately own equity interests in a business venture. In such circumstances, the employee's equity interest is considered to be independent of the University's equity interest and is not held, managed, disposed of, or distributed by the University. An example would be a case in which the University receives an equity interest in a business venture as a result of licensing certain intellectual property developed by one of its employees and in which the same employee also owns a equity interest as a result of being a founder of the business venture receiving the license. In this example, the employee's equity interest is not held or managed by the University, but rather by the employee, and the employee's status as a founder having an ownership stake in the business venture renders the employee ineligible to receive a distribution of a portion of the University-owned equity.

  10. As a public institution, the University should undertake sponsored research only when the results can be published. Publication may be deferred for a reasonable time during which the University and the sponsor review the feasibility of patent coverage or other protection on an invention described in the publication. Likewise, graduate student theses or dissertations containing invention details may be withheld from the Library shelves for a limited period while this evaluation process is conducted. Some research agreements may involve University access to a sponsor's proprietary data subject to a clause defining the conditions under which such data will be identified, accepted, and used. Students should be able to participate in such research in a meaningful way without access to proprietary data. When publication of the research involving proprietary data is contemplated, the University may agree to provide the sponsor with advance copy prior to submission for publication to allow the sponsor an opportunity to identify any inadvertent disclosure of proprietary data.
  11. Employee consulting with commercial enterprises can be of significant benefit to the University, the employee, the commercial entity, and the general public. However, such involvements include the potential for conflicts of interest, for the inhibition of the free exchange of information, and for interference with the employee's primary allegiance to the University. University employees should be guided in these arrangements by the policy stated in Volume Four, Part V, Chapters 2 and 6 of the University Handbook. Invention clauses in consulting agreements must be consistent with the policy of the University and with University commitments under sponsored research agreements. Questions concerning potential conflicts should be referred to the University's Office of the Provost and the Office of Research.
  12. Conflicts of interest are of prime concern when a faculty member is involved in "deeper than consulting" arrangements with business ventures. Although the faculty member may hold an equity interest or a management position in a business venture, he or she must do so consistent with the principles and procedures of Executive Order 57 (University Handbook, Volume Four, Part V, Chapter 6, Section 6, Involvement with Commercial Enterprise, Deeper than Consulting). In situations where the employee is a board member, manager, or receives shares of stock, the option to purchase stock, or other equity interest in return for the use of his or her services and/or inventions in a business venture, approval by the Office of the Provost (after review by the dean and the chair) is required. The primary focus of the review by the Office of the Provost will be to ensure that potential conflicts of interest and exposure to liability are properly managed. For example, the interests of the graduate students involved in such cases must be protected, there must be no direct managerial involvement of the faculty member in the business venture, there must be an arms-length relationship between the faculty member's responsibilities to the business venture and the faculty member's academic responsibilities, and mechanisms must be in place to ensure that the research program of the faculty member is not distorted by his or her interests in the business venture.

Section 2. Copyright Policy

  1. Background.
  2. The University encourages the publication of scholarly works as an inherent part of its educational mission. In this connection, the University acknowledges the right of faculty, staff, and students to prepare and publish, through individual initiative, articles, pamphlets, and books that are copyrighted by the authors or their publishers and that may generate royalty income for the authors.

    The variety and number of copyrightable materials that may be created in the university community have increased significantly in recent years as have the author-university- sponsor relationships under which such materials are produced. Therefore, the following statement of University policy on ownership and use of copyrightable materials is provided to clarify the respective rights of individuals and the University in this increasingly important area. The policy will be administered by the University's Office of Intellectual Property and Technology Transfer.

  3. General Statement of University Policy on Ownership and Use of Copyrightable Materials
  4. University faculty, staff, and students retain all rights in copyrightable materials they create, including scholarly works, subject to the following exceptions and conditions:

    1. Grant and Contract Limitations. Conditions regarding rights in data or restrictions on copyright privileges contained in sponsored grants, contracts, or other awards are binding on the University and on faculty, staff, or student authors. Copyright works, with the exception of routine progress reports, prepared as required elements of such sponsored grants, contracts, or other awards shall be reported to the Office of Intellectual Property and Technology Transfer for review prior to any external dissemination of the work. If necessary to fulfill grant and contract limitations, authors shall execute an appropriate written assignment of copyrights to the University.
    2. University-Owned Materials. Materials shall be "University-owned" within the meaning of this policy statement if the work is a "work for hire" under copyright law or the author was commissioned in writing by the University (or one of its colleges, schools, departments, or other divisions) to develop the materials as a part of the author's regularly compensated duties, as for example, released time arrangements in the case of faculty members. As to a faculty member, "commissioned in writing" specifically does not refer to his or her general obligation to produce scholarly works.
    3. University-Sponsored Materials. Materials shall be "University-sponsored materials" within the meaning of this policy statement if the author developed the materials in the course of performance of his or her normal duties and utilized University staff, resources, or funding to develop the work. As to a faculty member, "normal duties" does not include his or her usual scholarly activity unless it involves extensive uncompensated use of University resources.
    4. Written Agreements. It is desirable to reach agreement in writing as to the rights of the University and of participants before work begins whenever (1) a question exists as to whether the materials will be University-owned or University-sponsored, or (2) copyrightable materials are likely to result from the joint efforts of persons in academic departments and University service departments. As to jointly-developed materials, determination of rights in written form shall be accomplished no later than prior to sale of the materials in question. Questions concerning the interpretation and administration of this policy shall be resolved in accordance with Section 3.
    5. Proportional Ownership. In case of materials developed in substantial part under commission and in substantial part through other means, the materials shall be regarded as "University-owned" in an appropriate proportion. In the case of materials developed in substantial part during the course of normal duties and with use of University staff, resources, or funding the materials shall be regarded as "University-sponsored" in an appropriate proportion.
    6. Royalty-Free Privileges to University. The University retains a right to royalty-free use of any copyrightable materials developed by University employees (other than books and materials available from a publisher through normal distribution channels) when the development of such materials was advanced through the use of University facilities, supplies, equipment, or staff services. This right exists even though the materials do not constitute University-owned or University-sponsored materials as defined above (e.g., where use of facilities by a faculty member was not extensive).
    7. Student Writings. Students employed by the University in any capacity are covered by the terms of this policy. In addition, where a student receives financial aid or remuneration under a sponsored research, training, or fellowship program, his or her rights in copyrightable materials are limited by the terms of the University agreement with the sponsoring agency. The University has no ownership rights in copyrightable materials developed by students who are not employees of the University or in materials unrelated to their employment.

  5. Types of Materials.
  6. The types of materials to which this policy is intended to apply include:

    1. Video and audio recordings, tapes, and cassettes.
    2. Film, film strips and other visual aids.
    3. Books, texts, study guides and similar published materials.
    4. Computer programs and software when copyright rather than patent or trade secret protection is relied upon as the primary source of legal protection. (When the primary commercial value of a computer program lies in its transfer in limited quantities under arrangements of confidentiality, it shall be treated as unpatented technology and be subject to the University Patent and Invention Policy.)
    5. Musical or dramatic compositions.
    6. Internet-based productions and multimedia products.
    7. Other copyrightable materials.

  7. Rights Involved in use of University-Owned or University- Sponsored Materials.
    1. Two categories of use are differentiated for purposes of this policy: internal use and external use. Internal use refers to use by any unit of the University for instruction, research, or other educational purposes. External use refers to use by other educational institutions, government and other nonprofit institutions, and use resulting from lease or other contractual arrangements for commercial distribution of the materials.
    2. Use of University-owned or University-sponsored materials under this policy shall be subject to the following conditions:
      1. Internal use
        1. Each instance of use of such materials within the University requires the approval of the author and the department or college unless advance approval is waived through a prior written understanding or the author's consent is implicit in the terms of the grant or contract supporting the work. Internal uses of such materials will not involve a transfer of funds between departments unless the lending department incurs incremental costs in order to make the materials available.
        2. As long as the author or producer of such materials remains an employee of the University, the author may: (a) request reasonable revisions of the materials prior to any instance of internal use, or (b) ask that the materials be withdrawn from internal use if revisions are not feasible.
        3. In cases where the University has invested significant funds in the production of the materials and the author/producer is unable to agree with the department head on appropriate revision or withdrawal of materials, the question will be referred to the dean of the school or college for mediation.

        4. If the author or producer terminates employment with the University, then the University retains the right to continue internal use of the material unless the author/producer and the University agree in writing on special conditions for subsequent internal use of the materials and the procedures for their revision.

      2. External use
      3. Licensing or sale of University-owned or University- sponsored materials for external use shall be preceded by a written agreement between the University and the author or producer specifying the conditions of use, and including provisions concerning the right of the author or producer to revise the materials periodically, or to withdraw them from use-- subject to existing agreements--in the event revisions are not feasible.

  1. Division of Royalties.

    1. General Policy on Royalties. As to University-owned materials, all royalties and income should inure to the University and its schools, colleges, and departments as such materials are prepared in exchange for agreed compensation. As to University-sponsored materials, a sharing of royalties and income is appropriate because of the author's provision of creative efforts on the one hand and the University's provision of salary, facilities, administrative support, and other resources.
    2. Royalties on Sales to Outside Users. Where University-owned or University-sponsored materials are to be sold or rented to outside users, the following guidelines pertaining to financial arrangements should be observed (subject to any limitations specified by granting agencies):
      1. All incremental expenses related to the distribution of copies will be recovered from each sale or rental. Original costs for production of the materials shall be recovered only if and as agreed to in writing prior to preparation of the materials by the author and the academic departments and/or other University units which incur those costs.
      2. In the case of University-owned materials, royalty and other income from sale or use of the materials (after recovery of costs as specified in 1.) shall be divided one-half to the University and one-half to the school/college/department of the author or authors. The University share shall be used to promote research across the whole University and shall normally be administered by the Office of Research. The school/college/department share shall be allocated to the dean of the college or school, and may be used for research, education, and communications. At least 75% of this share should normally go to the author's department for use there according to departmental and college goals. The dean should have discretion in distributing the remaining 25% to promote activities according to the nature and needs of the college or school in question.
      3. In the case of University-sponsored materials, royalty and other income from the sale or use of materials (after recovery of costs as specified in a.) shall be divided according to the Administrative Policy Statement 59.4, "Technology Transfer." In any given case covered by this subsection, the author may dedicate all or any portion of his/her allocation to the school/college/department, the Office of Research, or other administrative unit, subject to the provisions of Administrative Policy Statement 59.4).
      4. In certain instances it may be advantageous to market University-owned or University-sponsored materials through outside commercial sources or the University Press. Net royalty income from such sources shall be divided as specified in b. and c.
      5. Royalty and other income from updating and revision of University-sponsored materials shall be treated as income and royalty from such University-sponsored materials, unless otherwise agreed to in writing by the author/producer and the University before preparation of the original materials. The net income from such upkeep or revision shall be separately computed on an annual basis for the purpose of applying the distributions referenced in paragraph c.

  2. Protection and Liability.

    1. Protection. The Office of Intellectual Property and Technology Transfer shall investigate allegations of unauthorized use or copyright infringement of University-owned and University-sponsored materials and shall recommend appropriate action. If such action is started by the University, all costs of such action shall be borne by the University. All proceeds in excess of such costs shall be shared as provided in Subection F. (subject to sponsoring agency limitations if a grant or contract is involved).
    2. Liability. When there are allegations of violation of personal or property rights by the University, or by the author or producer of University-owned or University-sponsored materials copyrighted by the University, the University shall assume responsibility for the defense of any action and the satisfaction of any judgment rendered against the University or the author or producer.

Section 3. Interpretation and Administration of Policy.

  1. The President has designated the Vice Provost for Intellectual Property and Technology Transfer as the officer of the University to administer, apply, and interpret the provisions of this policy. The Vice Provost shall have the authority to determine whether the facts of a given case merit special consideration.
  2. Committee. The President of the University will appoint an Intellectual Property Management Advisory Committee to review periodically the policy set forth in this statement and recommend such changes to the President as the Committee deems desirable. The Committee will also advise on broader intellectual property issues that arise in the promotion and protection of research. The Committee will report to the Vice Provost for Intellectual Property and Technology Transfer and consist of no fewer than five members, a majority of whom shall be chosen from the faculty.

  3. Distribution of Statement. When this statement becomes effective as University policy, the President's office shall see that all departments and administrative offices of the University are properly informed. Thereafter, the Vice Provost for Intellectual Property and Technology Transfer shall remind deans and department heads periodically of the existence of the policy, inform them about any significant interpretations of the policy, and invite comments or questions regarding it.
  4. Duties of Vice Provost for Intellectual Property and Technology Transfer. The Vice Provost for Intellectual Property and Technology Transfer shall manage the Office of Intellectual Property and Technology Transfer, which will represent the University in negotiating agreements with inventors, authors or producers, or licensees pursuant to this policy. She or he may consult also with department heads and the heads of production units involved in a specific technology transfer transaction, and she or he shall sign or recommend all agreements for signing consistent with delegated authority. Where copyright coverage should be obtained on University-sponsored or University-owned materials, the Office of Intellectual Property and Technology Transfer will facilitate the copyright application. The faculty or staff member who is the author of University-owned or University-sponsored materials shall execute a written transfer of copyright to the University when necessary or appropriate.
  5. Inquiries on Status of Materials. Any faculty or staff member who has a question as to whether or not particular materials will be considered University-owned or University- sponsored should initiate an inquiry to the Office of Intellectual Property and Technology Transfer as to their status. This inquiry, with all relevant facts, should be forwarded via the author's department head. Thereafter, the Vice Provost for Intellectual Property and Technology Transfer shall advise the author or producer as promptly as possible as to whether or not it appears that the materials should be regarded as University-owned or University-sponsored within the meaning of this policy. The Vice Provost for Intellectual Property and Technology Transfer's decision in such cases will be considered as an advisory opinion subject to final clarification when the work is completed. At that time, the faculty or staff member should either (1) indicate concurrence in the original decision, or (2) request that the question of rights be submitted for decision to the Vice Provost for Intellectual Property and Technology Transfer. In the latter case, the decision of the Vice Provost will be final unless the faculty or staff member requests arbitration of the question.
  6. Arbitration. In the event of any differences between faculty or staff members, on the one hand, and the Vice Provost for Intellectual Property and Technology Transfer, on the other hand, and when the questions cannot be reconciled by direct negotiation, the matter shall be submitted for binding arbitration either to a single arbitrator agreed on by all parties or to a special three-person panel consisting of one person representing the faculty or staff member, one person representing the University, and a third person designated by the first two. Knowledgeable members of the University community will normally be chosen for such panels in order to expedite a decision and minimize cost. In the event costs are incurred, they shall be divided equally between the faculty/staff member and the University. Decisions of the panel will be binding on both parties. The panel shall have full access to any pertinent records over which the faculty/staff member or the University has jurisdiction.

BR, March 1969; Executive Order No. 36 of the President, June 1, 1972; revised October 3, 1977; September 26, 1983; September 21, 1992; May 2, 2000, December 20, 2000; October 27, 2003.

cppad-20160000.1/build.sh0000755000175200017650000003501012656321771014066 0ustar coincoin-web#! /bin/bash -e # $Id: build.sh 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # prefix directories for the corresponding packages ADOLC_DIR=$HOME/prefix/adolc BOOST_DIR=/usr CPPAD_DIR=$HOME/prefix/cppad EIGEN_DIR=$HOME/prefix/eigen FADBAD_DIR=$HOME/prefix/fadbad IPOPT_DIR=$HOME/prefix/ipopt SACADO_DIR=$HOME/prefix/sacado # version type is one of "trunk" or "stable" version_type="stable" # ----------------------------------------------------------------------------- if [ $0 != "./build.sh" ] then echo "./build.sh: must be executed in the directory that contians it" exit 1 fi if [ "$2" != "" ] 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: ./build.sh $option" ./build.sh $option done echo "==============================================================" exit 0 fi # ----------------------------------------------------------------------------- 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-|'` fi # # Files are created by the configure command and copied to the source tree configure_file_list=" cppad/configure.hpp example/test_one.sh test_more/test_one.sh " # ----------------------------------------------------------------------------- # change version to current date if [ "$1" = "version" ] then echo 'bin/version.sh copy' bin/version.sh copy # echo "OK: ./build.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: ./build.sh automake" exit 0 fi # ----------------------------------------------------------------------------- # configure if [ "$1" == "configure" ] then log_dir=`pwd` log_file="$1.log" # echo "cd build" cd build # dir_list=" --prefix=$CPPAD_DIR " if [ -e $ADOLC_DIR/include/adolc ] then dir_list="$dir_list ADOLC_DIR=$ADOLC_DIR" fi 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 if [ -e $SACADO_DIR/include/Sacado.hpp ] then dir_list="$dir_list SACADO_DIR=$SACADO_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++98 -Wshadow" #_build_test_only: if [ -e $EIGEN_DIR/include/Eigen ] #_build_test_only: then #_build_test_only: cxx_flags="-Wall -ansi -pedantic-errors -std=c++98 -Wno-long-long -Wno-sign-compare" #_build_test_only: fi cat << EOF ../configure > $log_file \\ $dir_list \\ CXX_FLAGS=\"$cxx_flags\" \\ $special_types OPENMP_FLAGS=-fopenmp \\ --with-sparse_list --with-Documentation \\ --with-deprecated EOF # ../configure > $log_dir/$log_file \ $dir_list \ CXX_FLAGS="$cxx_flags" \ $special_types OPENMP_FLAGS=-fopenmp \ --with-sparse_list --with-Documentation \ --with-deprecated # for file in $configure_file_list do echo "cp $file ../$file" cp $file ../$file done # echo "OK: ./build.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 # # 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: ./build.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 build.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: ./build.sh omhelp" exit 0 fi # ----------------------------------------------------------------------------- if [ "$1" = "doxygen" ] then echo "bin/run_doxygen.sh" bin/run_doxygen.sh # echo "OK: ./build.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: ./build.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: ./build.sh copy2doc" 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 build.sh dist command list=`echo $list | sed -e 's|omhelp||'` fi echo "./build.sh $list" ./build.sh $list echo "OK: ./build.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:||' build.sh" sed -i -e 's|^#_build_test_only:||' build.sh # echo "./build.sh configure >> $log_file" ./build.sh configure >> $log_dir/$log_file # # test user documentation echo "bin/run_omhelp.sh xml >> $log_file" bin/run_omhelp.sh xml >> $log_dir/$log_file # # test developer documentation echo "./build.sh doxygen >> $log_file" ./build.sh doxygen >> $log_dir/$log_file # # ---------------------------------------------------------------------- # 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: ./build.sh test" exit 0 fi # ----------------------------------------------------------------------------- # report build.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: ./build.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 cppad-20160000.1/missing0000755000175200017650000001533012561675772014042 0ustar coincoin-web#! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2013-10-28.13; # UTC # Copyright (C) 1996-2014 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=http://www.perl.org/ flex_URL=http://flex.sourceforge.net/ gnu_software_URL=http://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: cppad-20160000.1/NEWS0000644000175200017650000000033012450414402013106 0ustar coincoin-webThe HTML and XML summary of recent changes for the version of CppAD corresponding to the current date are in the files: http://www.coin-or.org/CppAD/Doc/whats_new.htm http://www.coin-or.org/CppAD/Doc/whats_new.xml cppad-20160000.1/CMakeLists.txt0000644000175200017650000003163412656321771015200 0ustar coincoin-web# $Id: CMakeLists.txt 3786 2016-02-08 13:14:26Z 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. # ----------------------------------------------------------------------------- # ============================================================================= # Some constants # ============================================================================= # Set the minimum required version of cmake for this project. # see http://www.cmake.org/pipermail/cmake/2013-January/053213.html CMAKE_MINIMUM_REQUIRED(VERSION 2.8) # cppad_version is used by set_version.sh to get the version number. SET(cppad_version "20160000.1" ) SET(cppad_url "http://www.coin-or.org/CppAD" ) SET(cppad_description "Differentiation of C++ Algorithms" ) # Set name of this project and create the variables # cppad_BINARY_DIR and cppad_SOURCE_DIR. # project(projectname [CXX] [C] [Java]) PROJECT(cppad) # Add this directory to the list of C++ preprocessor include directories # for the entire project. # include_directories([AFTER|BEFORE] [SYSTEM] dir1 dir2 ...) INCLUDE_DIRECTORIES( ${cppad_SOURCE_DIR} ) # ============================================================================= # Some system cmake language extensions # ============================================================================= # CHECK_CXX_SOURCE_COMPILES(source variable) # Checks whether the code given in source will compile, link and run and # return zero status. You can set # CMAKE_REQUIRED_LIBRARIES, CMAKE_REQUIRED_FLAGS and CMAKE_REQUIRED_INCLUDES # accordingly if additional libraries or compiler flags are required. INCLUDE(CheckCXXSourceRuns) # ============================================================================ # Some local cmake language # ============================================================================ # dos_path_to_unix(dos_path unix_path) INCLUDE(cmake/dos_path_to_unix.cmake) # # add_to_list(variable_list constant_value) INCLUDE(cmake/add_to_list.cmake) # # command_line_arg(variable default type description) INCLUDE(cmake/command_line_arg.cmake) # # optional_package(prefix_variable description) INCLUDE(cmake/optional_package.cmake) # # add_cppad_cxx_flags(target_name) INCLUDE(cmake/add_cppad_cxx_flags.cmake) # # sources_libs_define(prefix_name sources libs define) INCLUDE(cmake/sources_libs_define.cmake) # # check_source_runs(source variable) INCLUDE(cmake/check_source_runs.cmake) # ============================================================================= # command line arguments # ============================================================================= # cmake_install_datadir command_line_arg(cmake_install_datadir share STRING "directory, below prefix, where cmake installs cppad data files" ) # ----------------------------------------------------------------------------- # cmake_install_docdir command_line_arg(cmake_install_docdir NOTFOUND STRING "directory, below prefix, where cmake installs cppad documentation files" ) # ----------------------------------------------------------------------------- # cmake_install_includedirs command_line_arg(cmake_install_includedirs include STRING "directories, below prefix, where cmake installs include files" ) # ----------------------------------------------------------------------------- # cmake_install_libdirs command_line_arg(cmake_install_libdirs lib STRING "directories, below prefix, where cmake installs library files" ) # ----------------------------------------------------------------------------- # cppad_prefix command_line_arg(cppad_prefix /usr PATH "cppad install prefix" ) SET(CMAKE_INSTALL_PREFIX "${cppad_prefix}" CACHE PATH "value copied from cppad_prefix" FORCE ) IF( cmake_install_prefix ) MESSAGE(FATAL_ERROR "cmake_install_prefix has been changed to cppad_prefix" ) ENDIF( cmake_install_prefix ) # ----------------------------------------------------------------------------- # cppad_postfix command_line_arg(cppad_postfix NOTFOUND STRING "cppad install postfix" ) IF( cmake_install_postfix ) MESSAGE(FATAL_ERROR "cmake_install_postfix has been changed to cppad_postfix" ) ENDIF( cmake_install_postfix ) # ----------------------------------------------------------------------------- # cppad_cxx_flags command_line_arg(cppad_cxx_flags NOTFOUND STRING "compile flags used with cppad (besides debug, release, and profile flags)" ) # ----------------------------------------------------------------------------- # cppad_profile_flag command_line_arg(cppad_profile_flag NOTFOUND STRING "compile flag used to compoile and link a profile version of a program" ) # ----------------------------------------------------------------------------- # External package prefixes # # adolc_prefix optional_package(adolc_prefix "adolc install prefix") # # colpack_prefix optional_package(colpack_prefix "colpack install prefix") # # eigen_prefix optional_package(eigen_prefix "eigen install prefix") # # fadbad_prefix optional_package(fadbad_prefix "fadbad install prefix") # # ipopt_prefix optional_package(ipopt_prefix "ipopt install prefix") # # sacado_prefix optional_package(sacado_prefix "sacado install prefix") # ----------------------------------------------------------------------------- # cppad_has_colpack, colpack_libs, cppad_lib # IF( colpack_prefix ) SET(cppad_has_colpack 1) SET( colpack_libs "ColPack" ) SET( cppad_lib "cppad_lib" ) ELSE( colpack_prefix ) SET(cppad_has_colpack 0) SET( colpack_libs "" ) SET( cppad_lib "" ) ENDIF( colpack_prefix ) # ============================================================================= # automated system configuration # ============================================================================= # cppad_cxx_flags_sacado IF( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" ) SET(cppad_cxx_flags_sacado "${cppad_cxx_flags} -D HAS_C99_TR1_CMATH" ) ELSE( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" ) SET(cppad_cxx_flags_sacado ${cppad_cxx_flags} ) ENDIF( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" ) IF( sacado_prefix ) MESSAGE(STATUS "cppad_cxx_flags_sacado = ${cppad_cxx_flags_sacado}") ENDIF( sacado_prefix ) # ----------------------------------------------------------------------------- # cppad_cxx_flags_eigen STRING(REGEX REPLACE "(.*)-Wshadow(.*)" "\\1-Wno-shadow -Wno-deprecated-declarations\\2" cppad_cxx_flags_eigen "${cppad_cxx_flags}" ) IF( eigen_prefix ) MESSAGE(STATUS "cppad_cxx_flags_eigen = ${cppad_cxx_flags_eigen}") ENDIF( eigen_prefix ) # ----------------------------------------------------------------------------- # cppad_cxx_flags_fadbad STRING(REGEX REPLACE "(.*)-Wshadow(.*)" "\\1-Wno-shadow\\2" cppad_cxx_flags_fadbad "${cppad_cxx_flags}" ) IF( fadbad_prefix ) MESSAGE(STATUS "cppad_cxx_flags_fadbad = ${cppad_cxx_flags_fadbad}") ENDIF( fadbad_prefix ) # ----------------------------------------------------------------------------- # CMAKE_CXX_FLAGS # remove Visual Studio C++ warning level if specified in cppad_cxx_flags IF ( cppad_cxx_flags MATCHES "/W[0-9]" ) STRING( REGEX REPLACE "/W[0-9]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ) ENDIF ( cppad_cxx_flags MATCHES "/W[0-9]" ) MESSAGE(STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}") # ----------------------------------------------------------------------------- # set cppad_abs_${middle_name} for middle_name equal to: # includedir, liddir, datadir, docdir FOREACH(middle_names includedirs libdirs datadir docdir) STRING(REGEX REPLACE "dirs" "dir" middle_name ${middle_names}) SET(middle_value NOTFOUND) FOREACH(dir ${cmake_install_${middle_names}}) IF( NOT middle_value ) SET(middle_value ${dir}) ENDIF( NOT middle_value ) ENDFOREACH(dir ${cmake_install_${middle_names}}) # SET(tmp "${cppad_prefix}/${middle_value}" ) IF ( cppad_postfix ) SET(cppad_abs_${middle_name} ${tmp}/${cppad_postfix}) ELSE ( cppad_postfix ) SET(cppad_abs_${middle_name} ${tmp}) ENDIF ( cppad_postfix ) ENDFOREACH(middle_names includedirs libdirs datadir docdir) # ----------------------------------------------------------------------------- # boost_prefix FIND_PACKAGE(Boost) IF ( Boost_FOUND ) # Extract the Boost prefix from Boost_INCLUDE_DIRS # # convert to using unix directory separator dos_path_to_unix("${Boost_INCLUDE_DIRS}" boost_include_dirs) # # convert to just one directory STRING(REGEX REPLACE "([^ ]+).*" "\\1" boost_include_dir "${boost_include_dirs}" ) # # extract part before last backslash STRING(REGEX REPLACE "([^ ]*)/[^/ ]*" "\\1" boost_prefix "${boost_include_dir}" ) MESSAGE(STATUS "boost_prefix = ${boost_prefix}") # # add boost include directories FOREACH(dir ${cmake_install_includedirs}) IF( IS_DIRECTORY ${boost_prefix}/${dir} ) INCLUDE_DIRECTORIES( ${boost_prefix}/${dir} ) MESSAGE(STATUS "Found ${boost_prefix}/${dir}") ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} ) ENDFOREACH( dir ) # # add boost link directories FOREACH(dir ${cmake_install_libdirs}) IF( IS_DIRECTORY ${boost_prefix}/${dir} ) LINK_DIRECTORIES( ${boost_prefix}/${dir} ) MESSAGE(STATUS "Found ${boost_prefix}/${dir}") ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} ) ENDFOREACH( dir ) ENDIF ( Boost_FOUND ) # ----------------------------------------------------------------------------- # ipopt_LIBRARIES and ipopt_LIBRARY_DIRS IF( ipopt_prefix ) FIND_PACKAGE(PkgConfig) IF( NOT PKG_CONFIG_FOUND ) MESSAGE(FATAL_ERROR "Using ipopt_prefix but cannot find pkg-config") ENDIF( NOT PKG_CONFIG_FOUND ) # # Set the system environment variable PKG_CONFIG_PATH FOREACH(dir ${cmake_install_libdirs}) IF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc") SET( ENV{PKG_CONFIG_PATH} ${ipopt_prefix}/${dir}/pkgconfig ) ENDIF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc") ENDFOREACH(dir) # # pkg_check_modules( [REQUIRED] []*) # ipopt_LIBRARIES ... only the libraries (w/o the '-l') # ipopt_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') pkg_check_modules(ipopt ipopt) IF( NOT ipopt_FOUND ) MESSAGE(FATAL_ERROR "For all directories dir in cmake_install_libdirs, cannot find the file ipopt_prefix/dir/pkgconfig/ipopt.pc where ipopt_prefix = ${ipopt_prefix} cmake_install_libdirs = ${cmake_install_libdirs} " ) ENDIF( NOT ipopt_FOUND ) ENDIF( ipopt_prefix ) # ============================================================================= # Currently building tests as normal executables # ============================================================================= # The CMakeLists.txt file in the specified source directory is processed # before the current input file continues beyond this command. # add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL]) # # Initialize list of tests as empty SET(check_depends "") # ADD_SUBDIRECTORY(cppad) ADD_SUBDIRECTORY(pkgconfig) IF( colpack_prefix ) ADD_SUBDIRECTORY(cppad_lib) ENDIF( colpack_prefix) # ADD_SUBDIRECTORY(compare_c) add_to_list(check_depends check_compare_c) # ADD_SUBDIRECTORY(example) add_to_list(check_depends check_example) # ADD_SUBDIRECTORY(introduction) add_to_list(check_depends check_introduction) # ADD_SUBDIRECTORY(print_for) add_to_list(check_depends check_print_for) # ADD_SUBDIRECTORY(test_more) add_to_list(check_depends check_test_more) # ADD_SUBDIRECTORY(multi_thread) add_to_list(check_depends check_multi_thread) # ADD_SUBDIRECTORY(speed) add_to_list(check_depends check_speed) # IF ( ipopt_prefix ) ADD_SUBDIRECTORY(cppad_ipopt) add_to_list(check_depends check_cppad_ipopt) ENDIF( ipopt_prefix ) # ADD_CUSTOM_TARGET(check DEPENDS ${check_depends}) # # ============================================================================= # install procedure # ============================================================================= # install(DIRECTORY dirs... DESTINATION # [FILE_PERMISSIONS permissions...] # [DIRECTORY_PERMISSIONS permissions...] # [USE_SOURCE_PERMISSIONS] [OPTIONAL] # [CONFIGURATIONS [Debug|Release|...]] # [COMPONENT ] [FILES_MATCHING] # [[PATTERN | REGEX ] # [EXCLUDE] [PERMISSIONS permissions...]] [...] # ) # Note a trailing / in the source directory name drops the source directory # name during the copy. # # During install copy all the cppad include files to # ${cppad_abs_includedir}/cppad INSTALL( DIRECTORY "${CMAKE_SOURCE_DIR}/cppad/" DESTINATION ${cppad_abs_includedir}/cppad FILES_MATCHING PATTERN "*.hpp" ) # # During install copy doc direcrory to cppad_abs_docdir/cppad IF ( cmake_install_docdir ) INSTALL( DIRECTORY "doc/" DESTINATION ${cppad_abs_docdir}/cppad ) ENDIF ( cmake_install_docdir ) # IF( ${cppad_deprecated} ) # During install copy deprecated include files INSTALL( DIRECTORY "${CMAKE_SOURCE_DIR}/cppad/deprecated/" DESTINATION ${cppad_abs_includedir}/cppad ) ENDIF( ${cppad_deprecated} ) cppad-20160000.1/cppad_lib/0002755000175200017650000000000012656321771014350 5ustar coincoin-webcppad-20160000.1/cppad_lib/cppad_colpack.cpp0000644000175200017650000001512012656321771017634 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include # include # include # if CPPAD_HAS_COLPACK == 0 namespace CppAD { CPPAD_LIB_EXPORT void this_routine_should_never_get_called(void) { CPPAD_ASSERT_UNKNOWN(false); } } # else // CPPAD_HAS_COLPACK # include namespace CppAD { // BEGIN_CPPAD_NAMESPACE /*! \file cppad_colpack.cpp The CppAD interface to the Colpack coloring algorithms. */ /*! Determine which rows of a general sparse matrix can be computed together. \param color is a vector with color.size() == m. For i = 0 , ... , m-1, color[i] is the color for the corresponding row of the matrix. If color[i1]==color[i2], (i1, j1) is in sparsity pattern, and (i2, j2) is in sparsity pattern, then j1 is not equal to j2. \param m is the number of rows in the matrix. \param n is the number of columns in the matrix. \param adolc_pattern is a vector with adolc_pattern.size() == m. For i = 0 , ... , m-1, and for k = 1, ... ,adolc_pattern[i][0], the entry with index (i, adolc_pattern[i][k]) is a non-zero in the sparsity pattern for the matrix. */ // ---------------------------------------------------------------------- CPPAD_LIB_EXPORT void cppad_colpack_general( CppAD::vector& color , size_t m , size_t n , const CppAD::vector& adolc_pattern ) { size_t i, k; CPPAD_ASSERT_UNKNOWN( adolc_pattern.size() == m ); CPPAD_ASSERT_UNKNOWN( color.size() == m ); // Use adolc sparsity pattern to create corresponding bipartite graph ColPack::BipartiteGraphPartialColoringInterface graph( SRC_MEM_ADOLC, adolc_pattern.data(), m, n ); // row ordered Partial-Distance-Two-Coloring of the bipartite graph graph.PartialDistanceTwoColoring( "SMALLEST_LAST", "ROW_PARTIAL_DISTANCE_TWO" ); // Use coloring information to create seed matrix int n_seed_row; int n_seed_col; double** seed_matrix = graph.GetSeedMatrix(&n_seed_row, &n_seed_col); CPPAD_ASSERT_UNKNOWN( size_t(n_seed_col) == m ); // now return coloring in format required by CppAD for(i = 0; i < m; i++) color[i] = m; for(k = 0; k < size_t(n_seed_row); k++) { for(i = 0; i < m; i++) { if( seed_matrix[k][i] != 0.0 ) { // check that no row appears twice in the coloring CPPAD_ASSERT_UNKNOWN( color[i] == m ); color[i] = k; } } } # ifndef NDEBUG // check that all non-zero rows appear in the coloring for(i = 0; i < m; i++) CPPAD_ASSERT_UNKNOWN(color[i] < m || adolc_pattern[i][0] == 0); // check that no rows with the same color have overlapping entries CppAD::vector found(n); for(k = 0; k < size_t(n_seed_row); k++) { size_t j, ell; for(j = 0; j < n; j++) found[j] = false; for(i = 0; i < m; i++) if( color[i] == k ) { for(ell = 0; ell < adolc_pattern[i][0]; ell++) { j = adolc_pattern[i][1 + ell]; CPPAD_ASSERT_UNKNOWN( ! found[j] ); found[j] = true; } } } # endif return; } // ---------------------------------------------------------------------- /*! Determine which rows of a symmetrix sparse matrix can be computed together. \param color is a vector with color.size() == m. For i = 0 , ... , m-1, color[i] is the color for the corresponding row of the matrix. We say that a sparsity pattern entry (i, j) is valid if for all i1, such that i1 != i and color[i1]==color[i], and all j1, such that (i1, j1) is in sparsity pattern, j1 != j. The coloring is chosen so that for all (i, j) in the sparsity pattern; either (i, j) or (j, i) is valid (possibly both). \param m is the number of rows (and columns) in the matrix. \param adolc_pattern is a vector with adolc_pattern.size() == m. For i = 0 , ... , m-1, and for k = 1, ... ,adolc_pattern[i][0], the entry with index (i, adolc_pattern[i][k]) is in the sparsity pattern for the symmetric matrix. */ CPPAD_LIB_EXPORT void cppad_colpack_symmetric( CppAD::vector& color , size_t m , const CppAD::vector& adolc_pattern ) { size_t i; CPPAD_ASSERT_UNKNOWN( adolc_pattern.size() == m ); CPPAD_ASSERT_UNKNOWN( color.size() == m ); // Use adolc sparsity pattern to create corresponding bipartite graph ColPack::GraphColoringInterface graph( SRC_MEM_ADOLC, adolc_pattern.data(), m ); // Use STAR coloring because it has a direct recovery scheme; i.e., // not necessary to solve equations to extract values. graph.Coloring("SMALLEST_LAST", "STAR"); // Use coloring information to create seed matrix int n_seed_row; int n_seed_col; double** seed_matrix = graph.GetSeedMatrix(&n_seed_row, &n_seed_col); CPPAD_ASSERT_UNKNOWN( size_t(n_seed_row) == m ); // now return coloring for each row in format required by CppAD for(i = 0; i < m; i++) color[i] = m; for(i = 0; i < m; i++) { for(size_t k = 0; k < size_t(n_seed_col); k++) { if( seed_matrix[i][k] != 0.0 ) { CPPAD_ASSERT_UNKNOWN( color[i] == m ); color[i] = k; } } } # ifndef NDEBUG // check that every entry in the symetric matrix can be direclty recovered size_t i1, i2, j1, j2, k1, k2, nz1, nz2; for(i1 = 0; i1 < m; i1++) { nz1 = size_t(adolc_pattern[i1][0]); for(k1 = 1; k1 <= nz1; k1++) { j1 = adolc_pattern[i1][k1]; // check of a forward on color[i1] followed by a reverse // can recover entry (i1, j1) bool color_i1_ok = true; for(i2 = 0; i2 < m; i2++) if( i1 != i2 && color[i1] == color[i2] ) { nz2 = adolc_pattern[i2][0]; for(k2 = 1; k2 <= nz2; k2++) { j2 = adolc_pattern[i2][k2]; color_i1_ok &= (j1 != j2); } } // check of a forward on color[j1] followed by a reverse // can recover entry (j1, i1) bool color_j1_ok = true; for(j2 = 0; j2 < m; j2++) if( j1 != j2 && color[j1] == color[j2] ) { nz2 = adolc_pattern[j2][0]; for(k2 = 1; k2 <= nz2; k2++) { i2 = adolc_pattern[j2][k2]; color_j1_ok &= (i1 != i2); } } CPPAD_ASSERT_UNKNOWN( color_i1_ok || color_j1_ok ); } } # endif return; } } // END_CPPAD_NAMESPACE # endif // CPPAD_HAS_COLPACK cppad-20160000.1/cppad_lib/CMakeLists.txt0000644000175200017650000000331512656321771017110 0ustar coincoin-web# $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build and install the cppad_lib shared library # # string(REGEX REPLACE # # [...]) # # (year - 2000) dot (remove leading 0 from mmdd) dot (release) # Note that the dot (release) is optional # Also name that when mmdd is 0000 get (year - 2000) dot dot (release) STRING(REGEX REPLACE "20([0-9][0-9])0*([0-9]*)([.]?[0-9]*)" "\\1.\\2\\3" soversion ${cppad_version} ) # In case where mmdd is 0000, dot (release) is present. Convert to # (year - 2000) dot 0 dot (release) STRING(REGEX REPLACE "([.][.])" ".0." soversion ${soversion} ) MESSAGE(STATUS "soversion=${soversion}") # # add_library( [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN) # ) ADD_LIBRARY( cppad_lib SHARED cppad_colpack.cpp ) # set_target_properties(target1 target2 ... # PROPERTIES prop1 value1 prop2 value2 ...) SET_TARGET_PROPERTIES( cppad_lib PROPERTIES SOVERSION ${soversion} ) # # install(TARGETS myExe mySharedLib myStaticLib # RUNTIME DESTINATION bin # LIBRARY DESTINATION lib # ARCHIVE DESTINATION lib/static) INSTALL(TARGETS cppad_lib DESTINATION ${cppad_abs_libdir}) cppad-20160000.1/cmake/0002755000175200017650000000000012656321725013512 5ustar coincoin-webcppad-20160000.1/cmake/optional_package.cmake0000644000175200017650000000425612116375602020013 0ustar coincoin-web# $Id: optional_package.cmake 2771 2013-03-08 14:53:54Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # Eclipse Public License Version 1.0. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # optional_package(prefix_variable description) # # prefix_variable: (out) # is a PATH variable that holds the prefix for this optional package. # If this variable is not set by the cmake command line (or gui), # it is set to the default value NOTFOUND. # If this variable is set by the cmake command line, the following is done: # 1. All the valid include subdirectories are added using INCLUDE_DIRECTORIES. # 2. All the valid library subdirectories are added using LINK_DIRECTORIES. # where the valid include and library directories are determined by # cmake_install_includedirs and cmakd_install_libdirs respectively. # # description: (in) # is a description for the install prefix for this optional package. # MACRO(optional_package prefix_variable description) SET(${prefix_variable} NOTFOUND CACHE PATH "${description}") SET(prefix ${${prefix_variable}} ) MESSAGE(STATUS "${prefix_variable} = ${prefix}") IF ( prefix ) # List of preprocessor include file search directories FOREACH(dir ${cmake_install_includedirs}) IF(IS_DIRECTORY ${prefix}/${dir} ) INCLUDE_DIRECTORIES( ${prefix}/${dir} ) MESSAGE(STATUS "Found ${prefix}/${dir}") ENDIF(IS_DIRECTORY ${prefix}/${dir} ) ENDFOREACH(dir) # Paths in which the linker will search for libraries, # only applies to targets created after it is called FOREACH(dir ${cmake_install_libdirs}) IF(IS_DIRECTORY ${prefix}/${dir} ) LINK_DIRECTORIES( ${prefix}/${dir} ) MESSAGE(STATUS "Found ${prefix}/${dir}") ENDIF(IS_DIRECTORY ${prefix}/${dir} ) ENDFOREACH(dir) ENDIF ( prefix ) ENDMACRO(optional_package) cppad-20160000.1/cmake/check_source_runs.cmake0000644000175200017650000000265612460766640020231 0ustar coincoin-web# $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 # Eclipse Public License Version 1.0. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # check_source_runs(source variable) # # source: (in) # contains the source for the program that will be run. # # variable: (out) # the value of this variable is 1 if the program runs and # returns a zero status. Otherwise its value is 0. # Note that this is the reverse of the status flag returned by the program. # MACRO(check_source_runs source variable) SET(CMAKE_REQUIRED_INCLUDES "" ) SET(CMAKE_REQUIRED_LIBRARIES "" ) SET(CMAKE_REQUIRED_DEFINITIONS "" ) IF( cppad_cxx_flags ) SET(CMAKE_REQUIRED_FLAGS "${cppad_cxx_flags}" ) ELSE( cppad_cxx_flags ) SET(CMAKE_REQUIRED_FLAGS "" ) ENDIF( cppad_cxx_flags ) CHECK_CXX_SOURCE_RUNS("${source}" ${variable}_result) IF( ${variable}_result ) SET(${variable} 1) ELSE( ${variable}_result ) SET(${variable} 0) ENDIF( ${variable}_result ) MESSAGE(STATUS "${variable} = ${${variable}}" ) ENDMACRO( check_source_runs ) cppad-20160000.1/cmake/add_to_list.cmake0000644000175200017650000000242712116403430016765 0ustar coincoin-web# $Id: add_to_list.cmake 2772 2013-03-08 15:43:20Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # Eclipse Public License Version 1.0. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # ============================================================================= # add_to_list(variable_list constant_value) # # variables_list: (in/out) # The variable containing the list of values. # The original list may be ""; i.e., the empty list. # # constant_value: (in) # Is the value we are adding to the list. This value cannot be empty. # MACRO(add_to_list variable_list constant_value ) IF( "${${variable_list}}" STREQUAL "" ) SET( ${variable_list} ${constant_value} ) ELSE( "${${variable_list}}" STREQUAL "" ) SET( ${variable_list} ${${variable_list}} ${constant_value} ) ENDIF( "${${variable_list}}" STREQUAL "" ) ENDMACRO(add_to_list) cppad-20160000.1/cmake/dos_path_to_unix.cmake0000644000175200017650000000201412116365320020043 0ustar coincoin-web# $Id: dos_path_to_unix.cmake 2770 2013-03-08 13:42:40Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # Eclipse Public License Version 1.0. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # dos_path_to_unix(dos_path unix_path) # # dos_path: (in) # is the value of the path we are converting to unix format; i.e., # all \ characters are replaced by / characters. # # unix_path: (out) # is the variable where the result of the conversion is placed. # MACRO(dos_path_to_unix dos_path unix_path) STRING(REGEX REPLACE "[\\]" "/" ${unix_path} "${dos_path}" ) ENDMACRO(dos_path_to_unix dos_path unix_path) cppad-20160000.1/cmake/sources_libs_define.cmake0000644000175200017650000000302112303102011020462 0ustar coincoin-web# $Id: sources_libs_define.cmake 3119 2014-02-25 11:52:41Z 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 # Eclipse Public License Version 1.0. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # sources_libs_define(prefix_name sources libs define) # # prefix_name: (in) # If the variable ${prefix_name}_prefix is NOTFOUND, # sources and libs are set to the empty string "" and no definition is added. # # Otherwise ${prefix_name}_sources is set to ${sources}, # ${prefix_name}_libs is set to ${libs}. If ${define} is not empty "", # the defintion -DCPPAD_${define} is added; i.e., # ADD_DEFINITIONS("-DCPPAD_${define}") # MACRO(sources_libs_define prefix_name soruces libs define) IF ( ${prefix_name}_prefix ) SET( ${prefix_name}_sources ${sources} ) SET( ${prefix_name}_libs ${libs} ) IF( NOT "${define}" STREQUAL "" ) ADD_DEFINITIONS("-DCPPAD_${define}") MESSAGE(STATUS "-DCPPAD_${define}" ) ENDIF( NOT "${define}" STREQUAL "" ) ELSE ( ${prefix_name}_prefix ) SET( ${prefix_name}_sources "" ) SET( ${prefix_name}_libs "" ) ENDIF ( ${prefix_name}_prefix ) ENDMACRO( sources_libs_define ) cppad-20160000.1/cmake/add_cppad_cxx_flags.cmake0000644000175200017650000000367012404425355020450 0ustar coincoin-web# $Id: add_cppad_cxx_flags.cmake 3320 2014-09-11 23:06:21Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # Eclipse Public License Version 1.0. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # ----------------------------------------------------------------------------- # add_cppad_cxx_flags(target_name) # # target_name: (in) # For package equal to "eigen", "fadbad", "scaado", if target_name ends in # _package, the compiler flags for this target are set to # cppad_cxx_flags_package # Otherwise, the compiler flags for this target are set to # cppad_cxx_flags. # # Side Effects: # The variables package and flags are used for scratch space and not # defined after the completion of this macro. # MACRO(add_cppad_cxx_flags target_name) # SET(flags ${cppad_cxx_flags}) FOREACH(package eigen fadbad sacado) IF( ${target_name} MATCHES ".*_${package}$" ) SET(flags "${cppad_cxx_flags_${package}}") MESSAGE(STATUS "${target_name} cxx_flags = ${cppad_cxx_flags_${package}}" ) ENDIF( ${target_name} MATCHES ".*_${package}$" ) IF( ${target_name} MATCHES ".*_${package}_lib$" ) SET(flags "${cppad_cxx_flags_${package}}") MESSAGE(STATUS "${target_name} cxx_flags = ${cppad_cxx_flags_${package}}" ) ENDIF( ${target_name} MATCHES ".*_${package}_lib$" ) ENDFOREACH(package) IF( flags ) SET_TARGET_PROPERTIES( ${target_name} PROPERTIES COMPILE_FLAGS "${flags}" ) ELSE( flags ) SET_TARGET_PROPERTIES( ${target_name} PROPERTIES COMPILE_FLAGS "" ) ENDIF( flags ) ENDMACRO(add_cppad_cxx_flags) cppad-20160000.1/cmake/command_line_arg.cmake0000644000175200017650000000346412461230277017772 0ustar coincoin-web# $Id: command_line_arg.cmake 3615 2015-01-25 18:06:55Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # Eclipse Public License Version 1.0. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # command_line_arg(variable default type description) # # variable: (out) # is the variable we are setting to its default value. # The varaiable can be changed on the cmake command line (or in the camke gui). # The final value of the variable is printed with the cmake output. # # default: (in) # is the default value for this variable; i.e., # if it is not set by the cmake command line or gui. # # type: (in) # must be one of the following: # STRING, if the variable holds an arbitrary string. # PATH, if the variable holds a directory. # BOOL, if the variable only has the values true or false. # # description: (in) # Is a description of how the variable affects the CppAD install procedure. # MACRO(command_line_arg variable default type description) IF( NOT ( ${type} STREQUAL "STRING" ) ) IF( NOT ( ${type} STREQUAL "PATH" ) ) IF( NOT ( ${type} STREQUAL "BOOL" ) ) MESSAGE(FATAL_ERROR, "command_line_arg: bug in CppAD cmake commands") ENDIF( NOT ( ${type} STREQUAL "BOOL" ) ) ENDIF( NOT ( ${type} STREQUAL "PATH" ) ) ENDIF( NOT ( ${type} STREQUAL "STRING" ) ) # SET(${variable} "${default}" CACHE ${type} "${description}") MESSAGE(STATUS "${variable} = ${${variable}}") ENDMACRO( command_line_arg ) cppad-20160000.1/multi_thread/0002755000175200017650000000000012656321772015115 5ustar coincoin-webcppad-20160000.1/multi_thread/multi_newton.hpp0000644000175200017650000000202612656321771020347 0ustar coincoin-web// $Id: multi_newton.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_MULTI_NEWTON_HPP # define CPPAD_MULTI_NEWTON_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ extern bool multi_newton( CppAD::vector &xout , void fun(double x, double& f, double& df) , size_t num_sub , double xlow , double xup , double epsilon , size_t max_itr , size_t num_threads ); # endif cppad-20160000.1/multi_thread/multi_newton_work.hpp0000644000175200017650000000220612656321771021411 0ustar coincoin-web// $Id: multi_newton_work.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_MULTI_NEWTON_WORK_HPP # define CPPAD_MULTI_NEWTON_WORK_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include extern bool multi_newton_setup( 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 ); extern void multi_newton_worker(void); extern bool multi_newton_combine(CppAD::vector& xout); # endif cppad-20160000.1/multi_thread/CMakeLists.txt0000644000175200017650000000655712656321771017667 0ustar coincoin-web# $Id: CMakeLists.txt 3632 2015-02-03 13:57:08Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the multi_thread/* directory tests # Inherit environment from ../CMakeList.txt # initialize list as empty SET(check_depends "") # 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 INCLUDE(CheckLibraryExists) # If openmp found, set OpenMP_CXX_FLAGS and process its subdirectory # FIND_PACKAGE(OpenMP) IF ( OPENMP_FOUND ) # OpenMP_CXX_FLAGS - flags to add to the CXX compiler for OpenMP support ADD_SUBDIRECTORY(openmp) add_to_list(check_depends check_multi_thread_openmp) ENDIF ( OPENMP_FOUND ) # If pthreads found, set pthread_lib and pthread_lib_path and process subdir # # find_library( name1 [path1 path2 ...]) SET(pthread_lib "pthread") 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) add_to_list(check_depends check_multi_thread_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 " # 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) add_to_list(check_depends check_multi_thread_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 ) # check_multi_thread ADD_CUSTOM_TARGET(check_multi_thread DEPENDS ${check_depends}) cppad-20160000.1/multi_thread/harmonic.cpp0000644000175200017650000000460012656321771017416 0ustar coincoin-web// $Id: harmonic.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin harmonic.cpp$$ $spell inv num bool $$ $section Multi-Threaded Implementation of Summation of 1/i$$ $mindex harmonic multi_thread$$ $head Syntax$$ $icode%ok% = harmonic(%sum%, %num_sum%, %num_threads%)%$$ $head Summation$$ Multi-threaded computation of the summation that defines the harmonic series $latex \[ s = 1 + 1/2 + 1/3 + ... + 1/n \] $$ $head ok$$ This return value has prototype $codei% bool %ok% %$$ If this return value is false, an error occurred during $code harmonic$$. $head sum$$ This argument has prototype $codei% 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 num_sum$$ This argument has prototype $codei% size_t %num_sum% %$$ It specifies the number of terms in the summation; i.e. $latex n$$. $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 a multi-threading environment. $childtable% multi_thread/harmonic_time.cpp% multi_thread/harmonic_work.cpp %$$ $head Source$$ $code $verbatim%multi_thread/harmonic.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ // general purpose multi-threading interface # include "team_thread.hpp" // special utilities for the harmonic problem # include "harmonic_work.hpp" bool harmonic(double& sum, size_t num_sum, size_t num_threads) { // sum = 1/num_sum + 1/(num_sum-1) + ... + 1 bool ok = true; // setup the work for num_threads_ threads ok &= harmonic_setup(num_sum, num_threads); // now do the work for each thread if( num_threads > 0 ) team_work( harmonic_worker ); else harmonic_worker(); // now combine the result for all the threads ok &= harmonic_combine(sum); return ok; } // END C++ cppad-20160000.1/multi_thread/team_example.cpp0000644000175200017650000001041412656321771020257 0ustar coincoin-web// $Id: team_example.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin team_example.cpp$$ $spell CppAD $$ $section Using a Team of AD Threads: Example and Test$$ $mindex thread$$ $head Purpose$$ This example demonstrates how use a team threads with CppAD. $head thread_team$$ The following three implementations of the $cref team_thread.hpp$$ specifications are included: $table $rref team_openmp.cpp$$ $rref team_bthread.cpp$$ $rref team_pthread.cpp$$ $tend $head Source Code$$ $code $verbatim%multi_thread/team_example.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end ------------------------------------------------------------------------------ */ // BEGIN C++ # include # 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 > 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; 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; } // END C++ cppad-20160000.1/multi_thread/makefile.in0000644000175200017650000006235712656321771017234 0ustar coincoin-web# 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 = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) subdir = multi_thread ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/makefile.am $(dist_noinst_SCRIPTS) \ $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @CppAD_OPENMP_TRUE@am__EXEEXT_1 = openmp_test$(EXEEXT) @CppAD_BTHREAD_TRUE@am__EXEEXT_2 = bthread_test$(EXEEXT) @CppAD_PTHREAD_TRUE@am__EXEEXT_3 = pthread_test$(EXEEXT) am__objects_1 = thread_test.$(OBJEXT) multi_newton_time.$(OBJEXT) \ multi_newton.$(OBJEXT) multi_newton_work.$(OBJEXT) \ team_example.$(OBJEXT) harmonic_time.$(OBJEXT) \ harmonic.$(OBJEXT) harmonic_work.$(OBJEXT) am__dirstamp = $(am__leading_dot)dirstamp am_bthread_test_OBJECTS = $(am__objects_1) \ bthread/team_bthread.$(OBJEXT) bthread/a11c_bthread.$(OBJEXT) \ bthread/simple_ad_bthread.$(OBJEXT) bthread_test_OBJECTS = $(am_bthread_test_OBJECTS) bthread_test_LDADD = $(LDADD) am__DEPENDENCIES_1 = bthread_test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_openmp_test_OBJECTS = $(am__objects_1) openmp/team_openmp.$(OBJEXT) \ openmp/a11c_openmp.$(OBJEXT) openmp/simple_ad_openmp.$(OBJEXT) openmp_test_OBJECTS = $(am_openmp_test_OBJECTS) openmp_test_LDADD = $(LDADD) openmp_test_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am_pthread_test_OBJECTS = $(am__objects_1) \ pthread/team_pthread.$(OBJEXT) pthread/a11c_pthread.$(OBJEXT) \ pthread/simple_ad_pthread.$(OBJEXT) pthread_test_OBJECTS = $(am_pthread_test_OBJECTS) pthread_test_LDADD = $(LDADD) pthread_test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) SCRIPTS = $(dist_noinst_SCRIPTS) 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 = $(bthread_test_SOURCES) $(openmp_test_SOURCES) \ $(pthread_test_SOURCES) DIST_SOURCES = $(bthread_test_SOURCES) $(openmp_test_SOURCES) \ $(pthread_test_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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # automake input file # # CppAD puts 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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_OPENMP_FALSE@OPENMP_TEST = # @CppAD_OPENMP_TRUE@OPENMP_TEST = openmp_test # BTHREAD_LIB empty in this case @CppAD_BTHREAD_FALSE@BTHREAD_TEST = # # BTHREAD_LIB set to proper value in this case @CppAD_BTHREAD_TRUE@BTHREAD_TEST = bthread_test @CppAD_BOOST_DIR_TRUE@@CppAD_BTHREAD_TRUE@BOOST_LIB = -L$(BOOST_DIR)/lib @CppAD_BTHREAD_FALSE@BOOST_LIB = @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) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(OPENMP_FLAGS) # AM_LDFLAGS = $(OPENMP_FLAGS) LDADD = $(BOOST_LIB) $(BTHREAD_LIB) $(PTHREAD_LIB) # SHARED_SRC = \ thread_test.cpp \ team_thread.hpp \ \ multi_newton_time.cpp multi_newton_time.hpp \ multi_newton.cpp multi_newton.hpp \ multi_newton_work.cpp multi_newton_work.hpp \ team_example.cpp team_example.hpp \ harmonic_time.cpp harmonic_time.hpp \ harmonic.cpp harmonic.hpp \ harmonic_work.cpp harmonic_work.hpp # bthread_test_SOURCES = \ $(SHARED_SRC) \ bthread/team_bthread.cpp \ bthread/a11c_bthread.cpp \ bthread/simple_ad_bthread.cpp # openmp_test_SOURCES = \ $(SHARED_SRC) \ openmp/team_openmp.cpp \ openmp/a11c_openmp.cpp \ openmp/simple_ad_openmp.cpp # pthread_test_SOURCES = \ $(SHARED_SRC) \ pthread/team_pthread.cpp \ pthread/a11c_pthread.cpp \ pthread/simple_ad_pthread.cpp # dist_noinst_SCRIPTS = test.sh 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) --gnu multi_thread/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu multi_thread/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) bthread/$(am__dirstamp): @$(MKDIR_P) bthread @: > bthread/$(am__dirstamp) bthread/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) bthread/$(DEPDIR) @: > bthread/$(DEPDIR)/$(am__dirstamp) bthread/team_bthread.$(OBJEXT): bthread/$(am__dirstamp) \ bthread/$(DEPDIR)/$(am__dirstamp) bthread/a11c_bthread.$(OBJEXT): bthread/$(am__dirstamp) \ bthread/$(DEPDIR)/$(am__dirstamp) bthread/simple_ad_bthread.$(OBJEXT): bthread/$(am__dirstamp) \ bthread/$(DEPDIR)/$(am__dirstamp) bthread_test$(EXEEXT): $(bthread_test_OBJECTS) $(bthread_test_DEPENDENCIES) $(EXTRA_bthread_test_DEPENDENCIES) @rm -f bthread_test$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(bthread_test_OBJECTS) $(bthread_test_LDADD) $(LIBS) openmp/$(am__dirstamp): @$(MKDIR_P) openmp @: > openmp/$(am__dirstamp) openmp/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) openmp/$(DEPDIR) @: > openmp/$(DEPDIR)/$(am__dirstamp) openmp/team_openmp.$(OBJEXT): openmp/$(am__dirstamp) \ openmp/$(DEPDIR)/$(am__dirstamp) openmp/a11c_openmp.$(OBJEXT): openmp/$(am__dirstamp) \ openmp/$(DEPDIR)/$(am__dirstamp) openmp/simple_ad_openmp.$(OBJEXT): openmp/$(am__dirstamp) \ openmp/$(DEPDIR)/$(am__dirstamp) openmp_test$(EXEEXT): $(openmp_test_OBJECTS) $(openmp_test_DEPENDENCIES) $(EXTRA_openmp_test_DEPENDENCIES) @rm -f openmp_test$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(openmp_test_OBJECTS) $(openmp_test_LDADD) $(LIBS) pthread/$(am__dirstamp): @$(MKDIR_P) pthread @: > pthread/$(am__dirstamp) pthread/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) pthread/$(DEPDIR) @: > pthread/$(DEPDIR)/$(am__dirstamp) pthread/team_pthread.$(OBJEXT): pthread/$(am__dirstamp) \ pthread/$(DEPDIR)/$(am__dirstamp) pthread/a11c_pthread.$(OBJEXT): pthread/$(am__dirstamp) \ pthread/$(DEPDIR)/$(am__dirstamp) pthread/simple_ad_pthread.$(OBJEXT): pthread/$(am__dirstamp) \ pthread/$(DEPDIR)/$(am__dirstamp) pthread_test$(EXEEXT): $(pthread_test_OBJECTS) $(pthread_test_DEPENDENCIES) $(EXTRA_pthread_test_DEPENDENCIES) @rm -f pthread_test$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(pthread_test_OBJECTS) $(pthread_test_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f bthread/*.$(OBJEXT) -rm -f openmp/*.$(OBJEXT) -rm -f pthread/*.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/harmonic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/harmonic_time.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/harmonic_work.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi_newton.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi_newton_time.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi_newton_work.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@ @AMDEP_TRUE@@am__include@ @am__quote@bthread/$(DEPDIR)/a11c_bthread.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bthread/$(DEPDIR)/simple_ad_bthread.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@bthread/$(DEPDIR)/team_bthread.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@openmp/$(DEPDIR)/a11c_openmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@openmp/$(DEPDIR)/simple_ad_openmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@openmp/$(DEPDIR)/team_openmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pthread/$(DEPDIR)/a11c_pthread.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pthread/$(DEPDIR)/simple_ad_pthread.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@pthread/$(DEPDIR)/team_pthread.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 $(SCRIPTS) 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) -rm -f bthread/$(DEPDIR)/$(am__dirstamp) -rm -f bthread/$(am__dirstamp) -rm -f openmp/$(DEPDIR)/$(am__dirstamp) -rm -f openmp/$(am__dirstamp) -rm -f pthread/$(DEPDIR)/$(am__dirstamp) -rm -f pthread/$(am__dirstamp) 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) bthread/$(DEPDIR) openmp/$(DEPDIR) pthread/$(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) bthread/$(DEPDIR) openmp/$(DEPDIR) pthread/$(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 $(srcdir)/test.sh # 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: cppad-20160000.1/multi_thread/harmonic_work.cpp0000644000175200017650000001320212656321771020456 0ustar coincoin-web// $Id: harmonic_work.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin harmonic_work.cpp$$ $spell inv num $$ $section Multi-threading Sum of 1/i Utility Routines$$ $mindex harmonic_work setup worker combine$$ $head Syntax$$ $icode%ok% = harmonic_setup(%num_sum%, %num_threads%) %$$ $codei%harmonic_worker() %$$ $icode%ok% = harmonic_combine(%sum%) %$$ $head Purpose$$ These routines aid in the multi-threading computation of the summation that defines the harmonic series $latex \[ 1 + 1/2 + 1/3 + ... + 1/n \] $$ $head harmonic_setup$$ Calling this function splits up the computation of the summation into different parts for each thread. $subhead num_sum$$ The argument $icode num_sum$$ has prototype $codei% size_t %num_sum% %$$ It specifies the value of $latex n$$ in the summation. $subhead num_threads$$ The argument $icode num_threads$$ has prototype $codei% size_t %num_threads% %$$ It specifies the number of threads that will be used for the summation. In the special case where $icode num_thread$$ is zero, the summation should be done by one thread, but without the overhead of the multi_threading system. $head harmonic_worker$$ Calling this function does the computation for one thread. Following a call to $code harmonic_setup$$, this function should be called by each of the $icode num_threads$$ threads. $head harmonic_combine$$ After the $icode num_threads$$ threads have completed their calls to $code harmonic_worker$$, this function call will combine the results and return the final summation. $head Source$$ $code $verbatim%multi_thread/harmonic_work.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include "harmonic_work.hpp" # define MAX_NUMBER_THREADS 48 namespace { using CppAD::thread_alloc; // number of threads specified by previous call to harmonic_setup size_t num_threads_ = 0; // structure with information for one thread typedef struct { // index to start summation at (worker input) size_t start; // index to end summation at (worker input) size_t stop; // summation for this thread (worker output) double sum; // 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_[MAX_NUMBER_THREADS]; } // ----------------------------------------------------------------------- // do the work for one thread 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; } // ----------------------------------------------------------------------- // setup the work up for multiple threads bool harmonic_setup(size_t num_sum, size_t num_threads) { // sum = 1/num_sum + 1/(num_sum-1) + ... + 1 num_threads_ = num_threads; num_threads = std::max(num_threads_, size_t(1)); bool ok = num_threads == thread_alloc::num_threads(); ok &= num_sum >= num_threads; size_t thread_num; 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); // 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; } // ----------------------------------------------------------------------- // get the result of the work bool harmonic_combine(double& sum) { // sum = 1/num_sum + 1/(num_sum-1) + ... + 1 bool ok = true; 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 C++ cppad-20160000.1/multi_thread/multi_newton_time.cpp0000644000175200017650000001732012656321771021363 0ustar coincoin-web// $Id: multi_newton_time.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin multi_newton_time.cpp$$ $spell num Cpp bool alloc openmp $$ . $section Timing Test of Multi-Threaded Newton Method$$ $mindex multi_newton_time multi_thread AD speed$$ $head Syntax$$ $icode%ok% = multi_newton_time(%time_out%, %num_threads%, %num_zero%, %num_sub%, %num_sum%, %use_ad% )%$$ $head 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. $head ok$$ This return value has prototype $codei% bool %ok% %$$ If it is true, $code multi_newton_time$$ passed the correctness test. Otherwise it is false. $head time_out$$ This argument has prototype $codei% 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. $head test_time$$ Is the minimum amount of wall clock time that the test should take. The number of repeats for the test will be increased until this time is reached. 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 multi-threading and $codei% 1 == CppAD::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% == CppAD::thread_alloc::num_threads() %$$ when $code multi_newton_time$$ is called. $head num_zero$$ This argument has prototype $codei% size_t %num_zero% %$$ and it must be greater than one. It specifies the actual number of zeros in the test function $latex \sin(x)$$. To be specific, $code multi_newton_time$$ will attempt to determine all of the values of $latex x$$ for which $latex \sin(x) = 0 $$ and $latex x$$ is in the interval $codei% [ 0 , (%num_zero% - 1) * %pi% ] %$$. $head num_sub$$ This argument has prototype $codei% size_t %num_sub% %$$ It specifies the number of sub-intervals to divide the total interval into. It must be greater than zero and should probably be greater than two times $icode num_zero$$. $head num_sum$$ This argument has prototype $codei% 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) \] $$ where $latex n$$ is equal to $icode num_sum$$. Larger values of $icode num_sum$$ simulate a case where the evaluation of the function $latex f(x)$$ takes more time. $head use_ad$$ This argument has prototype $codei% bool %user_ad% %$$ If $icode use_ad$$ is $code true$$, then derivatives will be computed using CppAD. Note that this derivative computation includes re-taping the function for each value of $latex x$$ (even though re-taping is not necessary). $pre $$ If $icode use_ad$$ is $code false$$, derivatives will be computed using a hand coded routine. $head Source$$ $code $verbatim%multi_thread/multi_newton_time.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include # include # include "multi_newton.hpp" namespace { // empty namespace // values correspond to arguments in previous call to multi_newton_time size_t num_threads_;// value passed to multi_newton_time size_t num_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 CppAD::vector xout_; // either fun_ad or fun_no depending on value of use_ad void (*fun_)(double x, double& f, double& df) = 0; // 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) { // use CppAD::vector because it uses fast multi-threaded memory alloc using CppAD::vector; using CppAD::AD; 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 = (num_zero_ - 1) * pi; double eps = xup * 100. * CppAD::numeric_limits::epsilon(); size_t max_itr = 20; bool ok = multi_newton( 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 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; using CppAD::thread_alloc; // Set local namespace environment variables num_threads_ = num_threads; num_zero_ = num_zero; num_sub_ = num_sub; num_sum_ = num_sum; if( use_ad ) fun_ = fun_ad; else fun_ = fun_no; // expect number of threads to already be set up if( num_threads > 0 ) ok &= num_threads == CppAD::thread_alloc::num_threads(); else ok &= 1 == CppAD::thread_alloc::num_threads(); // run the test case and set time return value time_out = CppAD::time_test(test_repeat, test_time); // Call test_once for a correctness check double pi = 4. * std::atan(1.); double xup = (num_zero_ - 1) * pi; double eps = xup * 100. * CppAD::numeric_limits::epsilon(); ok &= (xout_.size() == num_zero); size_t i = 0; for(i = 0; i < num_zero; i++) ok &= std::fabs( xout_[i] - pi * i) <= 2 * eps; // xout_ is a static variable, so clear it to free its memory xout_.clear(); // return correctness check result return ok; } // END C++ cppad-20160000.1/multi_thread/harmonic.hpp0000644000175200017650000000133612656321771017426 0ustar coincoin-web// $Id: harmonic.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_HARMONIC_HPP # define CPPAD_HARMONIC_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ extern bool harmonic(double& sum, size_t num_sum, size_t num_threads); # endif cppad-20160000.1/multi_thread/pthread/0002755000175200017650000000000012656321771016543 5ustar coincoin-webcppad-20160000.1/multi_thread/pthread/simple_ad_pthread.cpp0000644000175200017650000002300212656321771022706 0ustar coincoin-web// $Id: simple_ad_pthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin simple_ad_pthread.cpp$$ $spell pthread CppAD $$ $section A Simple pthread AD: Example and Test$$ $mindex AD$$ $head Purpose$$ This example demonstrates how CppAD can be used in a pthread multi-threading environment. $head Source Code$$ $code $verbatim%multi_thread/pthread/simple_ad_pthread.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end ------------------------------------------------------------------------------ */ // BEGIN C++ # include # include # 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); 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(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; } // END C++ cppad-20160000.1/multi_thread/pthread/CMakeLists.txt0000644000175200017650000000360512656321771021305 0ustar coincoin-web# $Id: CMakeLists.txt 3724 2015-09-21 05:04:18Z 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. # ----------------------------------------------------------------------------- # Build the multi_thread/pthread directory tests # Inherit environment from ../CMakeList.txt # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # Local include directories to search (not in package_prefix/include) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/.. ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(multi_thread_pthread EXCLUDE_FROM_ALL ../thread_test.cpp ../../speed/src/microsoft_timer.cpp ../multi_newton_time.cpp ../multi_newton.cpp ../multi_newton_work.cpp ../team_example.cpp ../harmonic_time.cpp ../harmonic.cpp ../harmonic_work.cpp a11c_pthread.cpp simple_ad_pthread.cpp team_pthread.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags( multi_thread_pthread ) # Paths in which the linker will search for libraries, # only applies to targets created after it is called LINK_DIRECTORIES( ${pthread_lib_path} ) # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(multi_thread_pthread ${pthread_lib}) # Add the check_multi_thread_pthread target ADD_CUSTOM_TARGET(check_multi_thread_pthread multi_thread_pthread simple_ad DEPENDS multi_thread_pthread ) cppad-20160000.1/multi_thread/pthread/a11c_pthread.cpp0000644000175200017650000000665312656321771021513 0ustar coincoin-web// $Id: a11c_pthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin a11c_pthread.cpp$$ $spell 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 $verbatim%multi_thread/pthread/a11c_pthread.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end ---------------------------------------------------------------------------- */ // BEGIN C++ # include # include # include # include // define CPPAD_NULPTR # include # 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.0; 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); 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( &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. * 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; return ok; } // END C++ cppad-20160000.1/multi_thread/pthread/team_pthread.cpp0000644000175200017650000002477712656321771021723 0ustar coincoin-web// $Id: team_pthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin team_pthread.cpp$$ $spell 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$$ There is a bug in $code pthread_exit$$, using cygwin 5.1 and g++ version 4.3.4, whereby calling $code pthread_exit$$ is not the same as returning from 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: $codep */ # define DEMONSTRATE_BUG_IN_CYGWIN 0 /* $$ $code $verbatim%multi_thread/pthread/team_pthread.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # 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(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); # 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(&(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, num_threads ); ok &= (rc == 0); rc = pthread_barrier_init( &wait_for_job_, no_barrierattr, num_threads ); ok &= (rc == 0); // structure used to create the threads pthread_t pthread_id; // default for pthread_attr_setdetachstate is PTHREAD_CREATE_JOINABLE 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; // 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(); return ok; } const char* team_name(void) { return "pthread"; } // END C++ cppad-20160000.1/multi_thread/team_example.hpp0000644000175200017650000000130312656321771020261 0ustar coincoin-web// $Id: team_example.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_TEAM_EXAMPLE_HPP # define CPPAD_TEAM_EXAMPLE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ extern bool team_example(void); # endif cppad-20160000.1/multi_thread/thread_test.cpp0000644000175200017650000002713712656321771020136 0ustar coincoin-web// $Id: thread_test.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin thread_test.cpp$$ $escape $$ $spell inv mega cpp num pthread pthreads openmp bthread $$ $section Run Multi-Threading Examples and Speed Tests$$ $mindex thread_test multi openmp pthread bthread$$ $head Syntax$$ $codei%./multi_thread_%threading% a11c ./multi_thread_%threading% simple_ad ./multi_thread_%threading% team_example ./multi_thread_%threading% harmonic %test_time% %max_threads% %mega_sum% ./multi_thread_%threading% multi_newton %test_time% %max_threads% \ %num_zero% %num_sub% %num_sum% %use_ad% %$$ $head Running Tests$$ You can build this program and run the default version of its test parameters by executing the following commands: $codei% cd multi_thread make test %$$ After this operation you can run the syntax above for the different valid values of $icode threading$$: $subhead threading$$ If the $cref cmake$$ command output indicates that $code openmp$$ is supported by your system, you can execute the syntax above with $icode threading$$ equal to $code openmp$$. $pre $$ If the $cref cmake$$ command output indicates that $code pthreads$$ with barriers is supported by your system, you can execute the syntax above with $icode threading$$ equal to $code pthread$$. $pre $$ If the $cref cmake$$ command output indicates that $code boost$$ threads is supported is by your system, you can execute the syntax above with $icode threading$$ equal to $code bthread$$. $head Purpose$$ Runs the CppAD multi-threading examples and timing tests: $children% multi_thread/openmp/a11c_openmp.cpp% multi_thread/bthread/a11c_bthread.cpp% multi_thread/pthread/a11c_pthread.cpp% multi_thread/openmp/simple_ad_openmp.cpp% multi_thread/bthread/simple_ad_bthread.cpp% multi_thread/pthread/simple_ad_pthread.cpp% multi_thread/team_example.cpp% multi_thread/harmonic.cpp% multi_thread/multi_newton.cpp% multi_thread/team_thread.hpp %$$ $head a11c$$ The examples $cref a11c_openmp.cpp$$, $cref a11c_bthread.cpp$$, and $cref a11c_pthread.cpp$$ demonstrate simple multi-threading, without algorithmic differentiation. $head simple_ad$$ The examples $cref simple_ad_openmp.cpp$$, $cref simple_ad_bthread.cpp$$, and $cref simple_ad_pthread.cpp$$ demonstrate simple multi-threading, with algorithmic differentiation, using OpenMP, boost threads and pthreads respectively. $head team_example$$ The $cref team_example.cpp$$ routine demonstrates simple multi-threading with algorithmic differentiation and using a $cref/team of threads/team_thread.hpp/$$. $head harmonic$$ The $cref harmonic_time.cpp$$ 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 mega_sum$$ The command line argument $icode mega_sum$$ is an integer greater than or equal one and has the same meaning as in $cref/harmonic_time.cpp/harmonic_time.cpp/mega_sum/$$. $head multi_newton$$ The $cref multi_newton_time.cpp$$ routine preforms a timing test for a multi-threading example with algorithmic differentiation using a team of threads. $subhead test_time$$ Is the minimum amount of wall clock time that the test should take. The number of repeats for the test will be increased until this time is reached. 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_zero$$ The command line argument $icode num_zero$$ is an integer greater than or equal two and has the same meaning as in $cref/multi_newton_time.cpp/multi_newton_time.cpp/num_zero/$$. $subhead num_sub$$ The command line argument $icode num_sub$$ is an integer greater than or equal one and has the same meaning as in $cref/multi_newton_time.cpp/multi_newton_time.cpp/num_sub/$$. $subhead num_sum$$ The command line argument $icode num_sum$$ is an integer greater than or equal one and has the same meaning as in $cref/multi_newton_time.cpp/multi_newton_time.cpp/num_sum/$$. $subhead use_ad$$ The command line argument $icode use_ad$$ is either $code true$$ or $code false$$ and has the same meaning as in $cref/multi_newton_time.cpp/multi_newton_time.cpp/use_ad/$$. $head Team Implementations$$ The following routines are used to implement the specific threading systems through the common interface $cref team_thread.hpp$$: $table $rref team_openmp.cpp$$ $rref team_bthread.cpp$$ $rref team_pthread.cpp$$ $tend $head Source$$ $code $verbatim%multi_thread/thread_test.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include # include # include "team_thread.hpp" # include "team_example.hpp" # include "harmonic_time.hpp" # include "multi_newton_time.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 = "./_test a11c\n" "./_test simple_ad\n" "./_test team_example\n" "./_test harmonic test_time max_threads mega_sum\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_newton = std::strcmp(test_name, "multi_newton") == 0; if( run_a11c || run_simple_ad || run_team_example ) ok = (argc == 2); else if( run_harmonic ) 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 if( run_harmonic ) { // mega_sum mega_sum = arg2size_t( *++argv, 1, "run: mega_sum 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 size_t num_threads, inuse_this_thread = 0; cout << "time_all = [" << endl; for(num_threads = 0; num_threads <= max_threads; num_threads++) { double time_out; // set the number of threads if( num_threads > 0 ) ok &= team_create(num_threads); // ammount of memory initialy inuse by thread zero ok &= 0 == thread_alloc::thread_num(); inuse_this_thread = thread_alloc::inuse(0); // run the requested test if( run_harmonic ) ok &= harmonic_time(time_out, test_time, num_threads, mega_sum); else { ok &= run_multi_newton; ok &= multi_newton_time( time_out , test_time , num_threads , num_zero , num_sub , num_sum , use_ad ); } // set back to one thread and fee all avaialable memory if( num_threads > 0 ) ok &= team_destroy(); size_t thread; for(thread = 0; thread < num_threads; thread++) { thread_alloc::free_available(thread); if( thread == 0 ) ok &= thread_alloc::inuse(thread) == inuse_this_thread; else ok &= thread_alloc::inuse(thread) == 0; } cout << "\t" << time_out << " % "; 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; } // END C++ cppad-20160000.1/multi_thread/multi_newton_time.hpp0000644000175200017650000000156312656321771021372 0ustar coincoin-web// $Id: multi_newton_time.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_MULTI_NEWTON_TIME_HPP # define CPPAD_MULTI_NEWTON_TIME_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ bool multi_newton_time( double& time_out , double test_time , size_t num_thread , size_t num_zero , size_t num_sub , size_t num_sum , bool use_ad ); # endif cppad-20160000.1/multi_thread/harmonic_work.hpp0000644000175200017650000000152112656321771020464 0ustar coincoin-web// $Id: harmonic_work.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_HARMONIC_WORK_HPP # define CPPAD_HARMONIC_WORK_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include extern void harmonic_worker(void); extern bool harmonic_setup(size_t num_sum, size_t num_threads); extern bool harmonic_combine(double& sum); # endif cppad-20160000.1/multi_thread/test.sh0000755000175200017650000000424712656321771016437 0ustar coincoin-web#! /bin/sh -e # $Id: 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. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # 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|'` ;; 1) program=`echo "$program_list" | sed -e 's| [^ ]* \([^ ]*\).*|\1|'` ;; 2) program=`echo "$program_list" | sed -e 's| [^ ]* [^ ]* ||'` ;; esac } n_program='3' program_list=' openmp_test pthread_test bthread_test' 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 done if [ "$n_program" = '0' ] then echo "multi_thread/test.sh: nothing to test" exit 0 fi i_program='0' next_program # -------------------------------------------------------------------------- # test_time=1 max_thread=4, mega_sum=1 ./$program harmonic 1 4 1 next_program echo # test_time= 2 max_thread=4, num_zero=20, num_sub=30, num_sum=500, use_ad=true ./$program multi_newton 2 4 20 30 500 true next_program echo # case that failed in the past ./$program multi_newton 1 1 100 700 1 true next_program echo # case that failed in the past ./$program multi_newton 1 2 3 12 1 true next_program echo # 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 done cppad-20160000.1/multi_thread/test_multi/0002755000175200017650000000000012656321771017305 5ustar coincoin-webcppad-20160000.1/multi_thread/test_multi/user_atomic.cpp0000644000175200017650000001277012656321771022330 0ustar coincoin-web// $Id: user_atomic.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 # define NUMBER_THREADS 4 # define NUMBER_CALLS 40 // y[0] = x[0] + x[1] // y[1] = x[1] + x[2] namespace { # ifdef CPPAD_TEST_OPENMP // ------------------------------------------------------------------ // 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 the current thread number size_t thread_number(void) { return static_cast( omp_get_thread_num() ); } # endif // y[0] = x[0] + x[1] bool user_atomic_forward( size_t id , size_t k , size_t 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; ty[0] = tx[0] + tx[1]; ty[1] = tx[1] + tx[2]; if( vy.size() > 0 ) { vy[0] = (vx[0] | vx[1]); vy[1] = (vx[1] | vx[2]); } return true; } bool user_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 user_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 user_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 ) { return false; } bool user_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_user_atomic , CppAD::vector , double , user_atomic_forward , user_atomic_reverse , user_atomic_for_jac_sparse , user_atomic_rev_jac_sparse , user_atomic_rev_hes_sparse ) bool user_atomic(int call_index) { bool ok = true; using CppAD::AD; using CppAD::vector; size_t j; size_t m = 2; size_t n = size_t(call_index + 3); vector< AD > ax(n), ay(m); for(j = 0; j < n; j++) ax[j] = AD(j + 1); CppAD::Independent(ax); // use user atomic function size_t id = 0; my_user_atomic(id, ax, ay); // create function CppAD::ADFun g(ax, ay); // now use the tape with the user atomic function vector x(n), y(m); for(j = 0; j < n; j++) x[j] = (j + 1) * (j + 1); y = g.Forward(0, x); // y[0] = x[0] + x[1] ok &= (y[0] == x[0] + x[1]); // y[1] = x[1] + x[2] ok &= (y[0] == x[0] + x[1]); return ok; } } # ifdef CPPAD_TEST_OPENMP # include bool user_atomic_openmp(void) { using CppAD::thread_alloc; bool ok = true; bool ok_all[NUMBER_CALLS]; size_t num_threads = NUMBER_THREADS; int int_num_threads = int(num_threads); // make first call in sequential mode int call_index = 0; ok &= user_atomic(call_index); // turn off dynamic thread adjustment 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(); # pragma omp parallel for for(call_index = 0; call_index < NUMBER_CALLS; call_index++) ok_all[call_index] = user_atomic(call_index); // end omp parallel for // tear down parallel mode omp_set_num_threads(1); thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL); thread_alloc::hold_memory(false); CppAD::parallel_ad(); // combine all the ok flags into one for(call_index = 0; call_index < int_num_threads; call_index++) ok &= ok_all[call_index]; // -------------------------------------------------------------------- // Free all temporary work space associated with user_atomic objects. // (If there are future calls to user atomic functions, they will // create new temporary work space.) CppAD::user_atomic::clear(); return ok; } # endif cppad-20160000.1/multi_thread/test_multi/makefile.in0000644000175200017650000004545512656321771021425 0ustar coincoin-web# 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 = test_multi$(EXEEXT) subdir = multi_thread/test_multi 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_test_multi_OBJECTS = test_multi.$(OBJEXT) user_atomic.$(OBJEXT) test_multi_OBJECTS = $(am_test_multi_OBJECTS) test_multi_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 = $(test_multi_SOURCES) DIST_SOURCES = $(test_multi_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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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_OPENMP_FALSE@TEST_OPENMP_FLAG = # @CppAD_OPENMP_TRUE@TEST_OPENMP_FLAG = -DCPPAD_TEST_OPENMP # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ $(OPENMP_FLAGS) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(TEST_OPENMP_FLAG) # AM_CXXFLAGS = -g $(ADOLC_FLAGS) $(CXX_FLAGS) # AM_LDFLAGS = $(ADOLC_LIB) $(OPENMP_FLAGS) # test_multi_SOURCES = \ test_multi.cpp \ user_atomic.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) --gnu multi_thread/test_multi/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu multi_thread/test_multi/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) test_multi$(EXEEXT): $(test_multi_OBJECTS) $(test_multi_DEPENDENCIES) $(EXTRA_test_multi_DEPENDENCIES) @rm -f test_multi$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(test_multi_OBJECTS) $(test_multi_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_multi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user_atomic.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 ./test_multi # 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: cppad-20160000.1/multi_thread/test_multi/makefile.am0000644000175200017650000000222312656321771021376 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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_OPENMP TEST_OPENMP_FLAG = -DCPPAD_TEST_OPENMP else TEST_OPENMP_FLAG = endif # check_PROGRAMS = test_multi # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ $(OPENMP_FLAGS) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(TEST_OPENMP_FLAG) # AM_CXXFLAGS = -g $(ADOLC_FLAGS) $(CXX_FLAGS) # AM_LDFLAGS = $(ADOLC_LIB) $(OPENMP_FLAGS) # test_multi_SOURCES = \ test_multi.cpp \ user_atomic.cpp test: check ./test_multi cppad-20160000.1/multi_thread/test_multi/test_multi.cpp0000644000175200017650000000405712656321771022206 0ustar coincoin-web// $Id: test_multi.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. -------------------------------------------------------------------------- */ // system include files used for I/O # include // memory leak checker # include // various examples / tests extern bool user_atomic_openmp(void); namespace { // function that runs one test static size_t Run_ok_count = 0; static size_t Run_error_count = 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; // ok &= name.size() < size_t(width); ok &= TestOk(); if( ok ) { std::cout << "OK" << std::endl; Run_ok_count++; } 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 namespace std; # ifdef CPPAD_TEST_OPENMP ok &= Run( user_atomic_openmp, "user_atomic_openmp" ); # endif // check for errors using std::cout; using std::endl; assert( ok || (Run_error_count > 0) ); if( CppAD::thread_alloc::free_all() ) { Run_ok_count++; cout << "OK: " << "No memory leak detected" << endl; } else { ok = false; Run_error_count++; cout << "Error: " << "memory leak detected" << endl; } // convert int(size_t) to avoid warning on _MSC_VER systems if( ok ) cout << "All " << int(Run_ok_count) << " tests passed." << endl; else cout << int(Run_error_count) << " tests failed." << endl; return static_cast( ! ok ); } // END PROGRAM cppad-20160000.1/multi_thread/openmp/0002755000175200017650000000000012656321772016413 5ustar coincoin-webcppad-20160000.1/multi_thread/openmp/a11c_openmp.cpp0000644000175200017650000000411612656321772021222 0ustar coincoin-web// $Id: a11c_openmp.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin a11c_openmp.cpp$$ $spell 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 $verbatim%multi_thread/openmp/a11c_openmp.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end ---------------------------------------------------------------------------- */ // BEGIN C++ # include # include # include # include # 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::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; } // END C++ cppad-20160000.1/multi_thread/openmp/team_openmp.cpp0000644000175200017650000000521412656321772021423 0ustar coincoin-web// $Id: team_openmp.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin team_openmp.cpp$$ $spell openmp $$ $section OpenMP Implementation of a Team of AD Threads$$ See $cref team_thread.hpp$$ for this routines specifications. $code $verbatim%multi_thread/openmp/team_openmp.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # 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( 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 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; 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(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; } const char* team_name(void) { return "openmp"; } // END C++ cppad-20160000.1/multi_thread/openmp/simple_ad_openmp.cpp0000644000175200017650000001374112656321772022436 0ustar coincoin-web// $Id: simple_ad_openmp.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin simple_ad_openmp.cpp$$ $spell openmp CppAD $$ $section A Simple OpenMP AD: Example and Test$$ $mindex AD$$ $head Purpose$$ This example demonstrates how CppAD can be used in a OpenMP multi-threading environment. $head Source Code$$ $code $verbatim%multi_thread/openmp/simple_ad_openmp.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end ------------------------------------------------------------------------------ */ // BEGIN C++ # include # include # 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(); // 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(); // 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; } } 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(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; } // END C++ cppad-20160000.1/multi_thread/openmp/CMakeLists.txt0000644000175200017650000000355512656321772021161 0ustar coincoin-web# $Id: CMakeLists.txt 3724 2015-09-21 05:04:18Z 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. # ----------------------------------------------------------------------------- # Build the multi_thread/openmp directory tests # Inherit environment from ../CMakeList.txt # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE RELEASE) # Local include directories to search (not in package_prefix/include) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/.. ) # Cannot find specifications for CMAKE_CXX_FLAGS in version 2.6 documentation # so using ADD_DEFINITIONS instead. ADD_DEFINITIONS( ${OpenMP_CXX_FLAGS} ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(multi_thread_openmp EXCLUDE_FROM_ALL ../thread_test.cpp ../../speed/src/microsoft_timer.cpp ../multi_newton_time.cpp ../multi_newton.cpp ../multi_newton_work.cpp ../team_example.cpp ../harmonic_time.cpp ../harmonic.cpp ../harmonic_work.cpp a11c_openmp.cpp simple_ad_openmp.cpp team_openmp.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags( multi_thread_openmp ) # Extra flags used by linker for openmp support SET(CMAKE_EXE_LINKER_FLAGS ${OpenMP_CXX_FLAGS} ) # Add the check_multi_thread_openmp target ADD_CUSTOM_TARGET(check_multi_thread_openmp multi_thread_openmp simple_ad DEPENDS multi_thread_openmp ) cppad-20160000.1/multi_thread/harmonic_time.cpp0000644000175200017650000001071212656321772020436 0ustar coincoin-web// $Id: harmonic_time.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin harmonic_time.cpp$$ $spell openmp pthreads alloc num bool mega inv CppAD parallelize $$ $section Timing Test of Multi-Threaded Summation of 1/i$$ $mindex harmonic_time multi_thread speed$$ $head Syntax$$ $icode%ok% = harmonic_time(%time_out%, %num_threads%, %mega_sum%)%$$ $head Purpose$$ Runs a correctness and timing test for a multi-threaded computation of the summation that defines the harmonic series $latex \[ 1 + 1/2 + 1/3 + ... + 1/n \] $$ This routine must be called in sequential execution mode, even though $cref/in_parallel/ta_in_parallel/$$ may return true. $head ok$$ This return value has prototype $codei% bool %ok% %$$ If it is true, $code harmonic_time$$ passed the correctness test. Otherwise it is false. $head time_out$$ This argument has prototype $codei% 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 $cref/summation/harmonic_time.cpp/Purpose/$$. $head test_time$$ Is the minimum amount of wall clock time that the test should take. The number of repeats for the test will be increased until this time is reached. 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 == CppAD::thread_alloc::num_threads() %$$ when $code harmonic_time$$ is called. If it is non-zero, the test is run with the multi-threading and $codei% %num_threads% = CppAD::thread_alloc::num_threads() %$$ when $code harmonic_time$$ is called. $head mega_sum$$ This argument has prototype $codei% size_t& %mega_sum% %$$ and is greater than zero. The value $latex n$$ in the $cref/summation/harmonic_time.cpp/Purpose/$$. is equal to $latex 10^6$$ times $icode mega_sum$$. $head Source$$ $code $verbatim%multi_thread/harmonic_time.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include # include # include # include # include // Note there is no mention of parallel mode in the documentation for // speed_test (so it is safe to use without special consideration). # include # include "harmonic.hpp" namespace { // empty namespace // value of num_threads in previous call to harmonic_time. size_t num_threads_; // value of mega_sum in previous call to harmonic_time. size_t mega_sum_; // 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_, num_sum, num_threads_); 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; } } // end empty namespace bool harmonic_time( double& time_out, double test_time, size_t num_threads, size_t mega_sum) { bool ok = true; using std::vector; // arguments passed to harmonic_time num_threads_ = num_threads; mega_sum_ = mega_sum; // convert zero to actual number of threads num_threads = std::max(num_threads_, size_t(1)); // expect number of threads to already be set up ok &= num_threads == CppAD::thread_alloc::num_threads(); // run the test case and set the time return value time_out = CppAD::time_test(test_repeat, test_time); // Correctness check double eps = 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) <= eps; return ok; } // END C++ cppad-20160000.1/multi_thread/team_thread.hpp0000644000175200017650000000736112656321772020110 0ustar coincoin-web// $Id: team_thread.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_TEAM_THREAD_HPP # define CPPAD_TEAM_THREAD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin team_thread.hpp$$ $spell pthreads const cstddef bool pthread initializes hpp num CppAD ta $$ $section Specifications for A Team of AD Threads$$ $head Syntax$$ $codei%include "team_thread.hpp" %ok% = team_create(%num_threads%) %ok% = team_work(%worker%) %ok% = team_destroy() %name% = team_name() %$$ $head Purpose$$ These routines start, use, and stop a team of threads that can be used with the CppAD type $code AD$$. For example, these could be OpenMP threads, pthreads, or Boost threads to name a few. $head Restrictions$$ Calls to the routines $code team_create$$, $code team_work$$, and $code team_destroy$$, must all be done by the master thread; i.e., $cref/thread_num/ta_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 ($cref/in_parallel/ta_in_parallel/$$ must be false). $head team_create$$ The argument $icode%num_threads% > 0%$$ has type $code size_t$$ and specifies the number of threads in this team. This initializes both $code AD$$ and $code team_work$$ to be used with $icode num_threads$$. If $icode%num_threads% > 1%$$, $icode%num_threads% - 1%$$ new threads are created and put in a waiting state until $code team_work$$ is called. $head team_work$$ This routine may be called one or more times between the call to $code team_create$$ and $code team_destroy$$. The argument $icode worker$$ has type $codei%bool %worker%(void)%$$. Each call to $code team_work$$ runs $icode num_threads$$ versions of $icode worker$$ with the corresponding value of $cref/thread_num/ta_thread_num/$$ between zero and $icode%num_threads% - 1%$$ and different for each thread, $head team_destroy$$ 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 %$$ $head team_name$$ This routines returns a name that identifies this thread_team. The return value has prototype $codei% const char* %name% %$$ and is a statically allocated $code '\0'$$ terminated C string. $head ok$$ The return value $icode ok$$ has type $code bool$$. It is $code false$$ if an error is detected during the corresponding call. Otherwise it is $code true$$. $children% multi_thread/openmp/team_openmp.cpp% multi_thread/bthread/team_bthread.cpp% multi_thread/pthread/team_pthread.cpp %$$ $head Example Use$$ Example use of these specifications can be found in the file $cref team_example.cpp$$. $head Example Implementation$$ Example implementations of these specifications can be found in the files: $table $rref team_openmp.cpp$$ $rref team_bthread.cpp$$ $rref team_pthread.cpp$$ $tend $head Speed Test of Implementation$$ Speed tests of using CppAD with the team implementations above can be found in: $table $rref harmonic.cpp$$ $rref multi_newton.cpp$$ $tend $head Source$$ $codep */ # include // 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); /* $$ $end */ # endif cppad-20160000.1/multi_thread/harmonic_time.hpp0000644000175200017650000000140212656321772020437 0ustar coincoin-web// $Id: harmonic_time.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_HARMONIC_TIME_HPP # define CPPAD_HARMONIC_TIME_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ bool harmonic_time( double& time_out, double test_time, size_t n_thread, size_t mega_sum); # endif cppad-20160000.1/multi_thread/multi_newton.cpp0000644000175200017650000001176712656321772020357 0ustar coincoin-web// $Id: multi_newton.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin multi_newton.cpp$$ $spell CppAD xout num xlow xup itr bool df $$ $section A Multi-Threaded Newton's Method$$ $mindex multi_newton threading thread multi-threading$$ $head Syntax$$ $icode%ok% = %multi_newton(%xout%, %fun%, %num_sub%, %xlow%, %xup%, %epsilon%, %max_itr%, %num_threads% )%$$ $head Purpose$$ Multi-threaded determination of the argument values $latex x$$, in the interval $latex [a, b]$$ (where $latex a < b$$), such that $latex f(x) = 0$$. $head Method$$ For $latex i = 0 , \ldots , n$$, we define the $th i$$ grid point $latex g_i$$ by $latex \[ g_i = a \frac{n - i}{n} + b \frac{i}{n} \] $$ For $latex i = 0 , \ldots , n-1$$, we define the $th i$$ sub-interval of $latex [a, b]$$ by $latex \[ 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 $latex i = 0 , \ldots , n-1$$ and at most one zero is found for each sub-interval. $head ok$$ The return value $icode ok$$ has prototype $codei% bool %ok% %$$ If an error occurs, it is false, otherwise it is true. $head xout$$ The argument $icode xout$$ has the prototype $codei% CppAD::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 \] $$ for each valid index $codei%0% <= %i% < %xout%.size()%$$. Two $latex x$$ solutions are considered equal (and joined as one) if the absolute difference between the solutions is less than $latex (b - a) / n$$. $head fun$$ The argument $icode fun$$ has prototype $codei% 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%) %$$ where the arguments to $icode fun$$ have the prototypes $codei% 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. $head num_sub$$ The argument $icode num_sub$$ has prototype $codei% 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% %$$ 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% %$$ 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% %$$ It specifies the convergence criteria for Newton's method in terms of how small the function value must be. $head max_itr$$ The argument $icode max_itr$$ has prototype $codei% 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). $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. $childtable% multi_thread/multi_newton_time.cpp% multi_thread/multi_newton_work.cpp %$$ $head Source$$ $code $verbatim%multi_thread/multi_newton.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end --------------------------------------------------------------------------- */ // BEGIN C++ // general purpose multi-threading interface # include "team_thread.hpp" // special utilities for the multi_newton problem # include "multi_newton_work.hpp" bool multi_newton( CppAD::vector &xout , void fun(double x, double& f, double& df) , size_t num_sub , double xlow , double xup , double epsilon , size_t max_itr , size_t num_threads ) { bool ok = true; using CppAD::AD; using CppAD::vector; // setup the work for num_threads threads ok &= multi_newton_setup( fun, 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 result for all the threads ok &= multi_newton_combine(xout); return ok; } // END C++ cppad-20160000.1/multi_thread/multi_newton_work.cpp0000644000175200017650000003113512656321772021410 0ustar coincoin-web// $Id: multi_newton_work.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin multi_newton_work.cpp$$ $spell num $$ $section Multi-threading Newton Method Utility Routines$$ $mindex multi_newton_work setup worker combine$$ $spell Cpp xlow xup itr df xout df $$ $head Syntax$$ $icode%ok% = multi_newton_setup( %fun%, %num_sub%, %xlow%, %xup%, %epsilon%, %max_itr%, %num_threads% )%$$ $codei%multi_newton_worker() %$$ $icode%ok% = multi_newton_combine(%xout%) %$$ $head Purpose$$ These routines aid in the computation of multiple zeros of a function $latex f: [ a, b] \rightarrow {\bf R}$$. $head multi_newton_setup$$ Calling this functions splits up the computation of the zeros into different sub-intervals for each thread. $subhead fun$$ The argument $icode fun$$ has prototype $codei% void %fun% (double %x%, double& %f%, double& %df%) %$$ This argument must evaluate the function $latex f(x)$$, and its derivative $latex f^{(1)} (x)$$, using the syntax $codei% %fun%(%x%, %f%, %df%) %$$ where the arguments have the prototypes $codei% double %x% double& %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. $subhead num_sub$$ The argument $icode num_sub$$ has prototype $codei% size_t %num_sub% %$$ It specifies the number of sub-intervals; i.e., $latex n$$ in to split the calculation into. $head xlow$$ The argument $icode xlow$$ has prototype $codei% double %xlow% %$$ It specifies the lower limit for the entire search; i.e., $latex a$$. $subhead xup$$ The argument $icode xup$$ has prototype $codei% double %xup% %$$ It specifies the upper limit for the entire search; i.e., $latex b$$. $subhead epsilon$$ The argument $icode epsilon$$ has prototype $codei% double %epsilon% %$$ It specifies the convergence criteria for Newton's method in terms of how small the function value $latex | f(x) | \leq \varepsilon$$. $head max_itr$$ The argument $icode max_itr$$ has prototype $codei% size_t %max_itr% %$$ It specifies the maximum number of iterations of Newton's method to try before giving up on convergence. $subhead 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 multi-threading. $head multi_newton_worker$$ Calling this function does the computation for one thread. Following a call to $code multi_newton_setup$$, this function should be called by each of the $icode num_threads$$ threads. $head multi_newton_combine$$ After the $icode num_threads$$ threads have completed their calls to $code multi_newton_worker$$, this function call will combine the results and return the final set of approximate zeros for $latex f(x)$$. $subhead xout$$ The argument $icode xout$$ has the prototype $codei% CppAD::vector& %xout% %$$ The input size and value of the elements of $icode xout$$ do not matter. Upon return from $code multi_newton_combine$$, the size of $icode xout$$ is less than or equal $latex n$$ and $codei% | %f%( %xout%[%i%] ) | <= %epsilon% %$$ for each valid index $icode i$$. In addition, the elements of $icode xout$$ are in ascending order and $codei% %xout%[i+1] - %xout%[%i%] >= 0.5 * (%xup% - %xlow%) / %num_sub% %$$ $head Source$$ $code $verbatim%multi_thread/multi_newton_work.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include "multi_newton_work.hpp" # define USE_THREAD_ALLOC_FOR_WORK_ALL 1 namespace { using CppAD::thread_alloc; // This vector template class frees all memory when resized to zero. // In addition, its memory allocation works well during multi-threading. using CppAD::vector; // number of threads in previous call to multi_newton_setup size_t num_threads_ = 0; // convergence criteria in previous call to multi_newton_setup double epsilon_ = 0.; // maximum number of iterations in previous call to multi_newton_setup size_t max_itr_ = 0; // length for all sub-intervals double sub_length_ = 0.; // function we are finding zeros of in previous call to multi_newton_setup void (*fun_)(double x, double& f, double& df) = 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_combine: 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_combine: work_all.size() == 0 // (use pointers instead of values to avoid false sharing) vector work_all_; } // ----------------------------------------------------------------------- // do the work for one thread void multi_newton_worker(void) { using CppAD::vector; // 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 * sub_length_; // over sub_length_ away from x_low double flast = 2 * 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 + i * sub_length_; // note that when i == num_sub - 1, xup_i = xup (exactly) double xup_i = xup - (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; } // ----------------------------------------------------------------------- // setup the work up for multiple threads bool multi_newton_setup( 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 ) { num_threads_ = num_threads; num_threads = std::max(num_threads_, size_t(1)); bool ok = num_threads == thread_alloc::num_threads(); // inputs that are same for all threads epsilon_ = epsilon; max_itr_ = max_itr; fun_ = fun; // 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 CppAD::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; # 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 + sum_num * sub_length_; // when thread_num == num_threads - 1, xup_thread = xup double xup_thread = xlow + (sum_num + num_sub_thread) * sub_length_; if( thread_num == num_threads - 1 ) xup_thread = xup; // 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; } // ----------------------------------------------------------------------- // get the result of the work bool multi_newton_combine(CppAD::vector& xout) { // number of threads in the calculation size_t num_threads = std::max(num_threads_, size_t(1)); // remove duplicates and points that are not solutions xout.resize(0); bool ok = true; size_t thread_num; // initialize as more that sub_lenght_ / 2 from any possible solution double xlast = - sub_length_; for(thread_num = 0; thread_num < num_threads; thread_num++) { vector& x = work_all_[thread_num]->x; 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]; } } } ok &= work_all_[thread_num]->ok; } // go down so free memory for other threads before memory for master thread_num = num_threads; while(thread_num--) { # if USE_THREAD_ALLOC_FOR_WORK_ALL // call the destructor for CppAD::vector destructor work_all_[thread_num]->x.~vector(); // delete the raw memory allocation void* v_ptr = static_cast( work_all_[thread_num] ); thread_alloc::return_memory( v_ptr ); # else delete work_all_[thread_num]; # endif // Note that xout corresponds to memroy that is inuse by master // (so we can only chech have freed all their memory). 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 // (becasue it is a static variable) work_all_.clear(); return ok; } // END C++ cppad-20160000.1/multi_thread/bthread/0002755000175200017650000000000012656321772016526 5ustar coincoin-webcppad-20160000.1/multi_thread/bthread/CMakeLists.txt0000644000175200017650000000360712656321772021272 0ustar coincoin-web# $Id: CMakeLists.txt 3724 2015-09-21 05:04:18Z 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. # ----------------------------------------------------------------------------- # Build the multi_thread/bthread directory tests # Inherit environment from ../CMakeList.txt # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE RELEASE) # Local include directories to search (not in package_prefix/include) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/.. ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(multi_thread_bthread EXCLUDE_FROM_ALL ../thread_test.cpp ../../speed/src/microsoft_timer.cpp ../multi_newton_time.cpp ../multi_newton.cpp ../multi_newton_work.cpp ../team_example.cpp ../harmonic_time.cpp ../harmonic.cpp ../harmonic_work.cpp a11c_bthread.cpp simple_ad_bthread.cpp team_bthread.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags( multi_thread_bthread ) # Paths in which the linker will search for libraries, # only applies to targets created after it is called LINK_DIRECTORIES( ${bthread_lib_path} ) # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(multi_thread_bthread ${bthread_lib}) # Add the check_multi_thread_bthread target ADD_CUSTOM_TARGET(check_multi_thread_bthread multi_thread_bthread simple_ad DEPENDS multi_thread_bthread ) cppad-20160000.1/multi_thread/bthread/a11c_bthread.cpp0000644000175200017650000000574212656321772021456 0ustar coincoin-web// $Id: a11c_bthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin a11c_bthread.cpp$$ $spell 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 $verbatim%multi_thread/bthread/a11c_bthread.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end ---------------------------------------------------------------------------- */ // BEGIN C++ # include # include # include # include # 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.0; 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. * 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; return ok; } // END C++ cppad-20160000.1/multi_thread/bthread/team_bthread.cpp0000644000175200017650000002027712656321772021657 0ustar coincoin-web// $Id: team_bthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin team_bthread.cpp$$ $spell bthread $$ $section Boost Thread Implementation of a Team of AD Threads$$ $mindex bthread$$ See $cref team_thread.hpp$$ for this routines specifications. $code $verbatim%multi_thread/bthread/team_bthread.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # 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 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 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(num_threads); wait_for_job_ = new boost::barrier(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(); return ok; } const char* team_name(void) { return "bthread"; } // END C++ cppad-20160000.1/multi_thread/bthread/simple_ad_bthread.cpp0000644000175200017650000002052312656321772022660 0ustar coincoin-web// $Id: simple_ad_bthread.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin simple_ad_bthread.cpp$$ $spell bthread CppAD $$ $section A Simple Boost Threading AD: Example and Test$$ $mindex thread AD$$ $head Purpose$$ This example demonstrates how CppAD can be used in a boost multi-threading environment. $head Source Code$$ $code $verbatim%multi_thread/bthread/simple_ad_bthread.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end ------------------------------------------------------------------------------ */ // BEGIN C++ # include # include # 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); 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(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; } // END C++ cppad-20160000.1/multi_thread/makefile.am0000644000175200017650000000455012656321772017213 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 puts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # if CppAD_OPENMP OPENMP_TEST = openmp_test else OPENMP_TEST = endif # if CppAD_BTHREAD # BTHREAD_LIB set to proper value in this case BTHREAD_TEST = bthread_test if CppAD_BOOST_DIR BOOST_LIB = -L$(BOOST_DIR)/lib endif else # BTHREAD_LIB empty in this case BTHREAD_TEST = BOOST_LIB = endif # if CppAD_PTHREAD PTHREAD_TEST = pthread_test else PTHREAD_TEST = endif # 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) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(OPENMP_FLAGS) # AM_LDFLAGS = $(OPENMP_FLAGS) LDADD = $(BOOST_LIB) $(BTHREAD_LIB) $(PTHREAD_LIB) # SHARED_SRC = \ thread_test.cpp \ team_thread.hpp \ \ multi_newton_time.cpp multi_newton_time.hpp \ multi_newton.cpp multi_newton.hpp \ multi_newton_work.cpp multi_newton_work.hpp \ team_example.cpp team_example.hpp \ harmonic_time.cpp harmonic_time.hpp \ harmonic.cpp harmonic.hpp \ harmonic_work.cpp harmonic_work.hpp # bthread_test_SOURCES = \ $(SHARED_SRC) \ bthread/team_bthread.cpp \ bthread/a11c_bthread.cpp \ bthread/simple_ad_bthread.cpp # openmp_test_SOURCES = \ $(SHARED_SRC) \ openmp/team_openmp.cpp \ openmp/a11c_openmp.cpp \ openmp/simple_ad_openmp.cpp # pthread_test_SOURCES = \ $(SHARED_SRC) \ pthread/team_pthread.cpp \ pthread/a11c_pthread.cpp \ pthread/simple_ad_pthread.cpp # dist_noinst_SCRIPTS = test.sh # test: check $(srcdir)/test.sh cppad-20160000.1/introduction/0002755000175200017650000000000012656321772015155 5ustar coincoin-webcppad-20160000.1/introduction/CMakeLists.txt0000644000175200017650000000147412656321772017721 0ustar coincoin-web# $Id: CMakeLists.txt 2683 2012-12-30 18:17:03Z 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. # ----------------------------------------------------------------------------- # Build the introduction/* directory tests # ADD_SUBDIRECTORY(exp_apx) ADD_SUBDIRECTORY(get_started) ADD_CUSTOM_TARGET(check_introduction DEPENDS check_introduction_exp_apx check_introduction_get_started ) cppad-20160000.1/introduction/exp_apx/0002755000175200017650000000000012656321772016621 5ustar coincoin-webcppad-20160000.1/introduction/exp_apx/exp_2_for0.cpp0000644000175200017650000000271712656321772021275 0ustar coincoin-web// $Id: exp_2_for0.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_2_for0.cpp$$ $spell std exp_2_seq cmath bool fabs $$ $section exp_2: Verify Zero Order Forward Sweep$$ $mindex exp_2$$ $codep */ # include // 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); } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/exp_eps.cpp0000644000175200017650000000167012656321772020772 0ustar coincoin-web// $Id: exp_eps.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 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; } // END C++ cppad-20160000.1/introduction/exp_apx/exp_2_for1.cpp0000644000175200017650000000321112656321772021264 0ustar coincoin-web// $Id: exp_2_for1.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_2_for1.cpp$$ $spell std exp_2_for cmath fabs bool $$ $section exp_2: Verify First Order Forward Sweep$$ $mindex exp_2$$ $codep */ # 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]; // 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); } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/exp_eps.omh0000644000175200017650000010100112656321772020760 0ustar coincoin-web$Id: exp_eps.omh 3757 2015-11-30 12:03:07Z bradbell $ ---------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. ----------------------------------------------------------------------------- $begin exp_eps.hpp$$ $spell exp_eps $$ $section exp_eps: Implementation$$ $mindex exp_eps$$ $code $verbatim%introduction/exp_apx/exp_eps.hpp%0%// BEGIN C++%// END C++%$$ $$ $end ----------------------------------------------------------------------------- $begin exp_eps.cpp$$ $spell exp_eps $$ $section exp_eps: Test of exp_eps$$ $code $verbatim%introduction/exp_apx/exp_eps.cpp%0%// BEGIN C++%// END C++%$$ $$ $end ----------------------------------------------------------------------------- $begin exp_eps_for0$$ $spell cpp exp_eps_seq bool $$ $section exp_eps: Operation Sequence and Zero Order Forward Sweep$$ $mindex example$$ $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_eps.hpp$$ to compute $codei%exp_eps(%x%, %epsilon%)%$$ with $icode x$$ is equal to .5 and $icode epsilon$$ is equal to .2. For this case, the mathematical form for the operation sequence corresponding to the $code exp_eps$$ is $latex \[ 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 $cref/exp_2/exp_2_for0/Mathematical Form/$$. $head Operation Sequence$$ We consider the $cref/operation sequence/glossary/Operation/Sequence/$$ corresponding to the algorithm $cref exp_eps.hpp$$ with the argument $icode x$$ is equal to .5 and $icode epsilon$$ is equal to .2. $subhead Variable$$ We refer to values that depend on the input variables $icode x$$ and $icode epsilon$$ as variables. $subhead Parameter$$ We refer to values that do not depend on the input variables $icode x$$ or $icode epsilon$$ as parameters. Operations where the result is a parameter are not included in the zero order sweep below. $subhead Index$$ The Index column contains the index in the operation sequence of the corresponding atomic operation and variable. A Forward sweep starts with the first operation and ends with the last. $subhead Code$$ The Code column contains the C++ source code corresponding to the corresponding atomic operation in the sequence. $subhead Operation$$ The Operation column contains the mathematical function corresponding to each atomic operation in the sequence. $subhead Zero Order$$ The Zero Order column contains the $cref/zero order derivative/exp_2_for0/Zero Order Expansion/$$ for the corresponding variable in the operation sequence. Forward mode refers to the fact that these coefficients are computed in the same order as the original algorithm; i.e., in order of increasing index. $subhead Sweep$$ $center $table $bold Index$$ $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$$ $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$$ $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$$ $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$$ $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$$ $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$$ $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$$ $tend $$ $head Return Value$$ The return value for this case is $latex \[ 1.625 = v_7^{(0)} = f ( x^{(0)} , \varepsilon^{(0)} ) \] $$ $head Comparisons$$ If $icode x$$ were negative, 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) $$ This in turn would result in a different operation sequence. Thus the operation sequence above only corresponds to $cref exp_eps.hpp$$ for values of $icode x$$ and $icode epsilon$$ within a certain range. Note that there is a neighborhood of $latex x = 0.5$$ for which the comparisons would have the same result and hence the operation sequence would be the same. $children% introduction/exp_apx/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$$ Suppose that $latex 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 $latex v_1^{(0)} , v_2^{(0)} , \ldots , v_7^{(0)}$$. $lnext Create a modified version of $cref exp_eps_for0.cpp$$ that verifies the values you obtained for the previous exercise. $lnext Create and run a main program that reports the result of calling the modified version of $cref exp_eps_for0.cpp$$ in the previous exercise. $lend $end ----------------------------------------------------------------------------- $begin exp_eps_for1$$ $spell exp_eps_for $$ $section exp_eps: First Order Forward Sweep$$ $head First Order Expansion$$ We define $latex x(t)$$ and $latex \varepsilon(t) ]$$ near $latex t = 0$$ by the first order expansions $latex \[ \begin{array}{rcl} x(t) & = & x^{(0)} + x^{(1)} * t \\ \varepsilon(t) & = & \varepsilon^{(0)} + \varepsilon^{(1)} * t \end{array} \]$$ It follows that $latex x^{(0)}$$ ($latex \varepsilon^{(0)}$$) is the zero, and $latex x^{(1)}$$ ($latex \varepsilon^{(1)}$$) the first, order derivative of $latex x(t)$$ at $latex t = 0$$ ($latex \varepsilon (t)$$) at $latex t = 0$$. $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_eps.hpp$$ to compute $codei%exp_eps(%x%, %epsilon%)%$$ with $icode x$$ is equal to .5 and $icode epsilon$$ is equal to .2. For this case, the mathematical function for the operation sequence corresponding to $code exp_eps$$ is $latex \[ f ( x , \varepsilon ) = 1 + x + x^2 / 2 \] $$ The corresponding partial derivative with respect to $latex x$$, and the value of the derivative, are $latex \[ \partial_x f ( x , \varepsilon ) = 1 + x = 1.5 \] $$ $head Operation Sequence$$ $subhead Index$$ The Index column contains the index in the operation sequence of the corresponding atomic operation. A Forward sweep starts with the first operation and ends with the last. $subhead Operation$$ The Operation column contains the mathematical function corresponding to each atomic operation in the sequence. $subhead Zero Order$$ The Zero Order column contains the zero order derivatives for the corresponding variable in the operation sequence (see $cref/zero order sweep/exp_2_for1/Operation Sequence/Sweep/$$). $subhead Derivative$$ The Derivative column contains the mathematical function corresponding to the derivative with respect to $latex t$$, at $latex t = 0$$, for each variable in the sequence. $subhead First Order$$ 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 \] $$ We use $latex x^{(1)} = 1$$ and $latex \varepsilon^{(1)} = 0$$, so that differentiation with respect to $latex t$$, at $latex t = 0$$, is the same partial differentiation with respect to $latex x$$ at $latex x = x^{(0)}$$. $subhead Sweep$$ $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$$ $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$$ $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$$ $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$$ $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$$ $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$$ $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$$ $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$$ $tend $$ $head Return Value$$ The derivative of the return value for this case is $latex \[ \begin{array}{rcl} 1.5 & = & v_7^{(1)} = \left[ \D{v_7}{t} \right]_{t=0} = \left[ \D{}{t} f( x^{(0)} + x^{(1)} * t , \varepsilon^{(0)} ) \right]_{t=0} \\ & = & \partial_x f ( x^{(0)} , \varepsilon^{(0)} ) * x^{(1)} = \partial_x f ( x^{(0)} , \varepsilon^{(0)} ) \end{array} \] $$ (We have used the fact that $latex x^{(1)} = 1$$ and $latex \varepsilon^{(1)} = 0$$.) $children% introduction/exp_apx/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$$ Suppose that $latex 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 $latex v_1^{(0)}, v_2^{(0)}, \cdots , v_7^{(0)}$$ and $latex v_1^{(1)}, v_2^{(1)}, \cdots , v_7^{(1)}$$ ? $lnext Create a modified version of $cref exp_eps_for1.cpp$$ that verifies the derivative values from the previous exercise. Also create and run a main program that reports the result of calling the modified version of $cref exp_eps_for1.cpp$$. $lnext Suppose that $latex x = .1$$ and $latex \epsilon = .2$$, what is the operation sequence corresponding to $codei% exp_eps(%x%, %epsilon%) %$$ $lend $end ----------------------------------------------------------------------------- $begin exp_eps_rev1$$ $spell exp_eps_rev $$ $section exp_eps: First Order Reverse Sweep$$ $mindex mode$$ $head Purpose$$ First order reverse mode uses the $cref/operation sequence/exp_eps_for0/Operation Sequence/$$, and zero order forward sweep values, to compute the first order derivative of one dependent variable with respect to all the independent variables. The computations are done in reverse of the order of the computations in the original algorithm. $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_eps.hpp$$ to compute $codei%exp_eps(%x%, %epsilon%)%$$ with $icode x$$ is equal to .5 and $icode epsilon$$ is equal to .2. For this case, the mathematical function for the operation sequence corresponding to $code exp_eps$$ is $latex \[ f ( x , \varepsilon ) = 1 + x + x^2 / 2 \] $$ The corresponding partial derivatives, and the value of the derivatives, are $latex \[ \begin{array}{rcl} \partial_x f ( x , \varepsilon ) & = & 1 + x = 1.5 \\ \partial_\varepsilon f ( x , \varepsilon ) & = & 0 \end{array} \] $$ $head epsilon$$ Since $latex \varepsilon$$ is an independent variable, it could included as an argument to all of the $latex f_j$$ functions below. The result would be that all the partials with respect to $latex \varepsilon$$ would be zero and hence we drop it to simplify the presentation. $head 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 $cref exp_eps.hpp$$ which is $latex v_7$$. We begin with the function $latex f_7$$ where $latex v_7$$ is both an argument and the value of the function; i.e., $latex \[ \begin{array}{rcl} f_7 ( v_1 , v_2 , v_3 , v_4 , v_5 , v_6 , v_7 ) & = & v_7 \\ \D{f_7}{v_7} & = & 1 \end{array} \] $$ All the other partial derivatives of $latex f_7$$ are zero. $head Index 7: f_6$$ The last operation has index 7, $latex \[ 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 ) $$ as equal to $latex f_7$$ except that $latex v_7$$ is eliminated using this operation; i.e. $latex \[ 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 $latex \[ \begin{array}{rcll} \D{f_6}{v_4} & = & \D{f_7}{v_4} + \D{f_7}{v_7} * \D{v_7}{v_4} & = 1 \\ \D{f_6}{v_6} & = & \D{f_7}{v_6} + \D{f_7}{v_7} * \D{v_7}{v_6} & = 1 \end{array} \] $$ All the other partial derivatives of $latex f_6$$ are zero. $head Index 6: f_5$$ The previous operation has index 6, $latex \[ v_6 = v_5 / 2 \] $$ We define the function $latex f_5 ( v_1 , v_2 , v_3 , v_4 , v_5 ) $$ as equal to $latex f_6 $$ except that $latex v_6 $$ is eliminated using this operation; i.e., $latex \[ f_5 = f_6 [ v_1 , v_2 , v_3 , v_4 , v_5 , v_6 ( v_5 ) ] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_5}{v_4} & = & \D{f_6}{v_4} & = 1 \\ \D{f_5}{v_5} & = & \D{f_6}{v_5} + \D{f_6}{v_6} * \D{v_6}{v_5} & = 0.5 \end{array} \] $$ All the other partial derivatives of $latex f_5$$ are zero. $head Index 5: f_4$$ The previous operation has index 5, $latex \[ v_5 = v_3 * v_1 \] $$ We define the function $latex f_4 ( v_1 , v_2 , v_3 , v_4 ) $$ as equal to $latex f_5 $$ except that $latex v_5 $$ is eliminated using this operation; i.e., $latex \[ f_4 = f_5 [ v_1 , v_2 , v_3 , v_4 , v_5 ( v_3 , v_1 ) ] \] $$ Given the information from the forward sweep, we have $latex v_3 = 0.5 $$ and $latex v_1 = 0.5 $$. It follows that $latex \[ \begin{array}{rcll} \D{f_4}{v_1} & = & \D{f_5}{v_1} + \D{f_5}{v_5} * \D{v_5}{v_1} & = 0.25 \\ \D{f_4}{v_2} & = & \D{f_5}{v_2} & = 0 \\ \D{f_4}{v_3} & = & \D{f_5}{v_3} + \D{f_5}{v_5} * \D{v_5}{v_3} & = 0.25 \\ \D{f_4}{v_4} & = & \D{f_5}{v_4} & = 1 \end{array} \] $$ $head Index 4: f_3$$ The previous operation has index 4, $latex \[ v_4 = 1 + v_3 \] $$ We define the function $latex f_3 ( v_1 , v_2 , v_3 ) $$ as equal to $latex f_4 $$ except that $latex v_4 $$ is eliminated using this operation; i.e., $latex \[ f_3 = f_4 [ v_1 , v_2 , v_3 , v_4 ( v_3 ) ] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_3}{v_1} & = & \D{f_4}{v_1} & = 0.25 \\ \D{f_3}{v_2} & = & \D{f_4}{v_2} & = 0 \\ \D{f_3}{v_3} & = & \D{f_4}{v_3} + \D{f_4}{v_4} * \D{v_4}{v_3} & = 1.25 \end{array} \] $$ $head Index 3: f_2$$ The previous operation has index 3, $latex \[ v_3 = v_2 / 1 \] $$ We define the function $latex f_2 ( v_1 , v_2 ) $$ as equal to $latex f_3 $$ except that $latex v_3 $$ is eliminated using this operation; i.e., $latex \[ f_2 = f_4 [ v_1 , v_2 , v_3 ( v_2 ) ] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_2}{v_1} & = & \D{f_3}{v_1} & = 0.25 \\ \D{f_2}{v_2} & = & \D{f_3}{v_2} + \D{f_3}{v_3} * \D{v_3}{v_2} & = 1.25 \end{array} \] $$ $head Index 2: f_1$$ The previous operation has index 1, $latex \[ v_2 = 1 * v_1 \] $$ We define the function $latex f_1 ( v_1 ) $$ as equal to $latex f_2 $$ except that $latex v_2 $$ is eliminated using this operation; i.e., $latex \[ f_1 = f_2 [ v_1 , v_2 ( v_1 ) ] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_1}{v_1} & = & \D{f_2}{v_1} + \D{f_2}{v_2} * \D{v_2}{v_1} & = 1.5 \end{array} \] $$ Note that $latex v_1$$ is equal to $latex x$$, so the derivative of $codei%exp_eps(%x%, %epsilon%)%$$ at $icode x$$ equal to .5 and $icode epsilon$$ equal .2 is 1.5 in the $icode x$$ direction and zero in the $icode epsilon$$ direction. We also note that $cref/forward/exp_eps_for1/$$ forward mode gave the same result for the partial in the $icode x$$ direction. $children% introduction/exp_apx/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 other partials of $latex f_j$$ must be equal to the corresponding partials of $latex f_{j+1}$$. $head Exercises$$ $list number$$ Consider the case where $latex x = .1$$ and we first preform a zero order forward mode sweep for the operation sequence used above (in reverse order). What are the results of a first order reverse mode sweep; i.e., what are the corresponding values for $latex \D{f_j}{v_k}$$ for all $latex j, k$$ such that $latex \D{f_j}{v_k} \neq 0$$. $lnext Create a modified version of $cref exp_eps_rev1.cpp$$ 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 $cref exp_eps_rev1.cpp$$. $lend $end ----------------------------------------------------------------------------- $begin exp_eps_for2$$ $spell exp_eps_for $$ $section exp_eps: Second Order Forward Mode$$ $head Second Order Expansion$$ We define $latex x(t)$$ and $latex \varepsilon(t) ]$$ near $latex t = 0$$ 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 \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) \end{array} \] $$ $head Purpose$$ In general, a second order forward sweep is given the $cref/first order expansion/exp_2_for1/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. $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_eps.hpp$$ to compute $codei%exp_eps(%x%, %epsilon%)%$$ with $icode x$$ is equal to .5 and $icode epsilon$$ is equal to .2. For this case, the mathematical function for the operation sequence corresponding to $code exp_eps$$ is $latex \[ f ( x , \varepsilon ) = 1 + x + x^2 / 2 \] $$ The corresponding second partial derivative with respect to $latex x$$, and the value of the derivative, are $latex \[ \Dpow{2}{x} f ( x , \varepsilon ) = 1. \] $$ $head Operation Sequence$$ $subhead Index$$ The Index column contains the index in the operation sequence of the corresponding atomic operation. A Forward sweep starts with the first operation and ends with the last. $subhead Zero$$ The Zero column contains the zero order sweep results for the corresponding variable in the operation sequence (see $cref/zero order sweep/exp_2_for0/Operation Sequence/Sweep/$$). $subhead Operation$$ The Operation column contains the first order sweep operation for this variable. $subhead First$$ The First column contains the first order sweep results for the corresponding variable in the operation sequence (see $cref/first order sweep/exp_2_for1/Operation Sequence/Sweep/$$). $subhead Derivative$$ The Derivative column contains the mathematical function corresponding to the second derivative with respect to $latex t$$, at $latex t = 0$$, for each variable in the sequence. $subhead 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 $th i$$ variable is given by $latex \[ 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$$ so that second order differentiation with respect to $latex t$$, at $latex t = 0$$, is the same as the second partial differentiation with respect to $latex x$$ at $latex x = x^{(0)}$$. $subhead Sweep$$ $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$$ $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 $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 $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 $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 $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 $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 $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 $tend $$ $head Return Value$$ The second derivative of the return value for this case is $latex \[ \begin{array}{rcl} 1 & = & v_7^{(2)} = \left[ \Dpow{2}{t} v_7 \right]_{t=0} = \left[ \Dpow{2}{t} f( x^{(0)} + x^{(1)} * t , \varepsilon^{(0)} ) \right]_{t=0} \\ & = & x^{(1)} * \Dpow{2}{x} f ( x^{(0)} , \varepsilon^{(0)} ) * x^{(1)} = \Dpow{2}{x} f ( x^{(0)} , \varepsilon^{(0)} ) \end{array} \] $$ (We have used the fact that $latex x^{(1)} = 1$$, $latex x^{(2)} = 0$$, $latex \varepsilon^{(1)} = 1$$, and $latex \varepsilon^{(2)} = 0$$.) $children% introduction/exp_apx/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$$ Which statement in the routine defined by $cref exp_eps_for2.cpp$$ uses the values that are calculated by the routine defined by $cref exp_eps_for1.cpp$$ ? $lnext Suppose that $latex x = .1$$, what are the results of a zero, first, and second order forward sweep for the operation sequence above; i.e., what are the corresponding values for $latex v_i^{(k)}$$ for $latex i = 1, \ldots , 7$$ and $latex k = 0, 1, 2$$. $lnext Create a modified version of $cref exp_eps_for2.cpp$$ that verifies the derivative values from the previous exercise. Also create and run a main program that reports the result of calling the modified version of $cref exp_eps_for2.cpp$$. $lend $end ----------------------------------------------------------------------------- $begin exp_eps_rev2$$ $spell exp_eps_rev $$ $section exp_eps: Second Order Reverse Sweep$$ $head Purpose$$ In general, a second order reverse sweep is given the $cref/first order expansion/exp_eps_for1/First Order Expansion/$$ for all of the variables in an operation sequence. Given a choice of a particular variable, it computes the derivative, of that variables first order expansion coefficient, with respect to all of the independent variables. $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_eps.hpp$$ to compute $codei%exp_eps(%x%, %epsilon%)%$$ with $icode x$$ is equal to .5 and $icode epsilon$$ is equal to .2. For this case, the mathematical function for the operation sequence corresponding to $code exp_eps$$ is $latex \[ f ( x , \varepsilon ) = 1 + x + x^2 / 2 \] $$ The corresponding derivative of the partial derivative with respect to $latex x$$ is $latex \[ \begin{array}{rcl} \Dpow{2}{x} f ( x , \varepsilon ) & = & 1 \\ \partial_\varepsilon \partial_x f ( x , \varepsilon ) & = & 0 \end{array} \] $$ $head epsilon$$ Since $latex \varepsilon$$ is an independent variable, it could included as an argument to all of the $latex f_j$$ functions below. The result would be that all the partials with respect to $latex \varepsilon$$ would be zero and hence we drop it to simplify the presentation. $head 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 $cref exp_eps.hpp$$ which is $latex v_7$$. We begin with the function $latex f_7$$ where $latex v_7$$ is both an argument and the value of the function; i.e., $latex \[ \begin{array}{rcl} f_7 \left( v_1^{(0)} , v_1^{(1)} , \ldots , v_7^{(0)} , v_7^{(1)} \right) & = & v_7^{(1)} \\ \D{f_7}{v_7^{(1)}} & = & 1 \end{array} \] $$ All the other partial derivatives of $latex f_7$$ are zero. $head Index 7: f_6$$ 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)} \end{array} \] $$ We define the function $latex f_6 \left( v_1^{(0)} , \ldots , v_6^{(1)} \right) $$ as equal to $latex f_7$$ except that $latex v_7^{(0)}$$ and $latex v_7^{(1)}$$ are eliminated using this operation; i.e. $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) \right] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_6}{v_4^{(1)}} & = & \D{f_7}{v_4^{(1)}} + \D{f_7}{v_7^{(1)}} * \D{v_7^{(1)}}{v_4^{(1)}} & = 1 \\ \D{f_6}{v_6^{(1)}} & = & \D{f_7}{v_6^{(1)}} + \D{f_7}{v_7^{(1)}} * \D{v_7^{(1)}}{v_6^{(1)}} & = 1 \end{array} \] $$ All the other partial derivatives of $latex f_6$$ are zero. $head Index 6: f_5$$ The previous operation has index 6, $latex \[ \begin{array}{rcl} v_6^{(0)} & = & v_5^{(0)} / 2 \\ v_6^{(1)} & = & v_5^{(1)} / 2 \end{array} \] $$ We define the function $latex f_5 \left( v_1^{(0)} , \ldots , v_5^{(1)} \right) $$ as equal to $latex f_6 $$ except that $latex v_6^{(0)}$$ and $latex v_6^{(1)}$$ are eliminated using this operation; i.e. $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) \right] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_5}{v_4^{(1)}} & = & \D{f_6}{v_4^{(1)}} & = 1 \\ \D{f_5}{v_5^{(1)}} & = & \D{f_6}{v_5} + \D{f_6}{v_6^{(1)}} * \D{v_6^{(1)}}{v_5^{(1)}} & = 0.5 \end{array} \] $$ All the other partial derivatives of $latex f_5$$ are zero. $head Index 5: f_4$$ 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)} \end{array} \] $$ We define the function $latex f_4 \left( v_1^{(0)} , \ldots , v_4^{(1)} \right) $$ as equal to $latex f_5 $$ except that $latex v_5^{(0)}$$ and $latex v_5^{(1)}$$ are eliminated using this operation; i.e. $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) , \right] \] $$ Given the information from the forward sweep, we have $latex v_1^{(0)} = 0.5$$, $latex v_3^{(0)} = 0.5$$, $latex v_1^{(1)} = 1$$, $latex v_3^{(1)} = 1$$, and the fact that the partial of $latex f_5$$ with respect to $latex v_5^{(0)}$$ is zero, we have $latex \[ \begin{array}{rcll} \D{f_4}{v_1^{(0)}} & = & \D{f_5}{v_1^{(0)}} + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_1^{(0)}} & = 0.5 \\ \D{f_4}{v_1^{(1)}} & = & \D{f_5}{v_1^{(1)}} + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_1^{(1)}} & = 0.25 \\ \D{f_4}{v_3^{(0)}} & = & \D{f_5}{v_3^{(0)}} + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_3^{(0)}} & = 0.5 \\ \D{f_4}{v_3^{(1)}} & = & \D{f_3}{v_1^{(1)}} + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_3^{(1)}} & = 0.25 \\ \D{f_4}{v_4^{(1)}} & = & \D{f_5}{v_4^{(1)}} & = 1 \end{array} \] $$ All the other partial derivatives of $latex f_5$$ are zero. $head Index 4: f_3$$ The previous operation has index 4, $latex \[ \begin{array}{rcl} v_4^{(0)} = 1 + v_3^{(0)} \\ v_4^{(1)} = v_3^{(1)} \end{array} \] $$ We define the function $latex f_3 \left( v_1^{(0)} , \ldots , v_3^{(1)} \right) $$ as equal to $latex f_4 $$ except that $latex v_4^{(0)}$$ and $latex v_4^{(1)}$$ are eliminated using this operation; i.e. $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) \right] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_3}{v_1^{(0)}} & = & \D{f_4}{v_1^{(0)}} & = 0.5 \\ \D{f_3}{v_1^{(1)}} & = & \D{f_4}{v_1^{(1)}} & = 0.25 \\ \D{f_3}{v_2^{(0)}} & = & \D{f_4}{v_2^{(0)}} & = 0 \\ \D{f_3}{v_2^{(1)}} & = & \D{f_4}{v_2^{(1)}} & = 0 \\ \D{f_3}{v_3^{(0)}} & = & \D{f_4}{v_3^{(0)}} + \D{f_4}{v_4^{(0)}} * \D{v_4^{(0)}}{v_3^{(0)}} & = 0.5 \\ \D{f_3}{v_3^{(1)}} & = & \D{f_4}{v_3^{(1)}} + \D{f_4}{v_4^{(1)}} * \D{v_4^{(1)}}{v_3^{(1)}} & = 1.25 \end{array} \] $$ $head Index 3: f_2$$ The previous operation has index 3, $latex \[ \begin{array}{rcl} v_3^{(0)} & = & v_2^{(0)} / 1 \\ v_3^{(1)} & = & v_2^{(1)} / 1 \end{array} \] $$ We define the function $latex f_2 \left( v_1^{(0)} , \ldots , v_2^{(1)} \right) $$ as equal to $latex f_3 $$ except that $latex v_3^{(0)}$$ and $latex v_3^{(1)}$$ are eliminated using this operation; i.e. $latex \[ f_2 = f_3 \left[ v_1^{(0)} , \ldots , v_2^{(1)} , v_3^{(0)} \left( v_2^{(0)} \right) , v_3^{(1)} \left( v_2^{(1)} \right) \right] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_2}{v_1^{(0)}} & = & \D{f_3}{v_1^{(0)}} & = 0.5 \\ \D{f_2}{v_1^{(1)}} & = & \D{f_3}{v_1^{(1)}} & = 0.25 \\ \D{f_2}{v_2^{(0)}} & = & \D{f_3}{v_2^{(0)}} + \D{f_3}{v_3^{(0)}} * \D{v_3^{(0)}}{v_2^{(0)}} & = 0.5 \\ \D{f_2}{v_2^{(1)}} & = & \D{f_3}{v_2^{(1)}} + \D{f_3}{v_3^{(1)}} * \D{v_3^{(1)}}{v_2^{(0)}} & = 1.25 \end{array} \] $$ $head Index 2: f_1$$ The previous operation has index 1, $latex \[ \begin{array}{rcl} v_2^{(0)} & = & 1 * v_1^{(0)} \\ v_2^{(1)} & = & 1 * v_1^{(1)} \end{array} \] $$ We define the function $latex f_1 \left( v_1^{(0)} , v_1^{(1)} \right) $$ as equal to $latex f_2 $$ except that $latex v_2^{(0)}$$ and $latex v_2^{(1)}$$ are eliminated using this operation; i.e. $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) \right] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_1}{v_1^{(0)}} & = & \D{f_2}{v_1^{(0)}} + \D{f_2}{v_2^{(0)}} * \D{v_2^{(0)}}{v_1^{(0)}} & = 1 \\ \D{f_1}{v_1^{(1)}} & = & \D{f_2}{v_1^{(1)}} + \D{f_2}{v_2^{(1)}} * \D{v_2^{(1)}}{v_1^{(1)}} & = 1.5 \end{array} \] $$ Note that $latex v_1$$ is equal to $latex x$$, so the second partial derivative of $codei%exp_eps(%x%, %epsilon%)%$$ at $icode x$$ equal to .5 and $icode epsilon$$ equal .2 is $latex \[ \Dpow{2}{x} v_7^{(0)} = \D{v_7^{(1)}}{x} = \D{f_1}{v_1^{(0)}} = 1 \] $$ There is a theorem about algorithmic differentiation that explains why the other partial of $latex f_1$$ is equal to the first partial of $codei%exp_eps(%x%, %epsilon%)%$$ with respect to $latex x$$. $children% introduction/exp_apx/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 other partials of $latex f_j$$ must be equal to the corresponding partials of $latex f_{j+1}$$. $head Exercises$$ $list number$$ Consider the case where $latex x = .1$$ and we first preform a zero order forward mode sweep for the operation sequence used above (in reverse order). What are the results of a first order reverse mode sweep; i.e., what are the corresponding values for $latex \D{f_j}{v_k}$$ for all $latex j, k$$ such that $latex \D{f_j}{v_k} \neq 0$$. $lnext Create a modified version of $cref exp_eps_rev2.cpp$$ 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 $cref exp_eps_rev2.cpp$$. $lend $end ----------------------------------------------------------------------------- cppad-20160000.1/introduction/exp_apx/exp_2_for2.cpp0000644000175200017650000000324312656321772021272 0ustar coincoin-web// $Id: exp_2_for2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_2_for2.cpp$$ $spell std exp_2_for cmath fabs bool $$ $section exp_2: Verify Second Order Forward Sweep$$ $mindex exp_2$$ $codep */ # include // 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; } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/exp_eps.hpp0000644000175200017650000001262612656321772021002 0ustar coincoin-web// $Id: exp_eps.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_EXP_EPS_HPP # define CPPAD_EXP_EPS_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_eps$$ $spell cppad-%yyyymmdd% hpp Apx cpp const exp_eps bool $$ $section An Epsilon Accurate Exponential Approximation$$ $mindex exp_eps example algorithm$$ $head Syntax$$ $codei%# include "exp_eps.hpp"%$$ $pre $$ $icode%y% = exp_eps(%x%, %epsilon%)%$$ $head Purpose$$ This is a an example algorithm that is used to demonstrate how Algorithmic Differentiation works with loops and boolean decision variables (see $cref exp_2$$ for a simpler example). $head Mathematical Function$$ The exponential function can be defined by $latex \[ \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 ! \} \] $$ The mathematical form for our approximation of the exponential function is $latex \[ \begin{array}{rcl} {\rm exp\_eps} (x , \varepsilon ) & = & \left\{ \begin{array}{ll} \frac{1}{ {\rm exp\_eps} (-x , \varepsilon ) } & {\rm if} \; x < 0 \\ 1 + x^1 / 1 ! + \cdots + x^{k( x, \varepsilon)} / k( x, \varepsilon ) ! & {\rm otherwise} \end{array} \right. \end{array} \] $$ $head include$$ The include command in the syntax is relative to $codei% cppad-%yyyymmdd%/introduction/exp_apx %$$ where $codei%cppad-%yyyymmdd%$$ is the distribution directory created during the beginning steps of the $cref%installation%Install%$$ of CppAD. $head x$$ The argument $icode x$$ has prototype $codei% const %Type% &%x% %$$ (see $icode Type$$ below). It specifies the point at which to evaluate the approximation for the exponential function. $head epsilon$$ The argument $icode epsilon$$ has prototype $codei% const %Type% &%epsilon% %$$ It specifies the accuracy with which to approximate the exponential function value; i.e., it is the value of $latex \varepsilon$$ in the exponential function approximation defined above. $head y$$ The result $icode y$$ has prototype $codei% %Type% %y% %$$ It is the value of the exponential function approximation defined above. $head Type$$ If $icode u$$ and $icode v$$ are $icode Type$$ objects and $icode i$$ is an $code int$$: $table $bold Operation$$ $cnext $bold Result Type$$ $cnext $bold Description$$ $rnext $icode%Type%(%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$$ $rnext $icode%u% > %v%$$ $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$$ $rnext $icode%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$$ $rnext $icode%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$$ $tend $children% introduction/exp_apx/exp_eps.omh% introduction/exp_apx/exp_eps_cppad.cpp %$$ $head Implementation$$ The file $cref exp_eps.hpp$$ contains a C++ implementation of this function. $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$$ Using the definition of $latex k( x, \varepsilon )$$ above, what is the value of $latex k(.5, 1)$$, $latex k(.5, .1)$$, and $latex k(.5, .01)$$ ? $lnext Suppose that we make the following call to $code exp_eps$$: $codep 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$$ the first time through the $code while$$ loop in $cref exp_eps.hpp$$ ? $lnext Continuing the previous exercise, what is the value assigned to $code k$$, $code temp$$, $code term$$, and $code sum$$ the second time through the $code while$$ loop in $cref exp_eps.hpp$$ ? $lend $end ----------------------------------------------------------------------------- */ // 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; } // END C++ # endif cppad-20160000.1/introduction/exp_apx/exp_2_rev1.cpp0000644000175200017650000000346312656321772021303 0ustar coincoin-web// $Id: exp_2_rev1.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_2_rev1.cpp$$ $spell cstddef cmath exp_2_rev bool std fabs $$ $section exp_2: Verify First Order Reverse Sweep$$ $mindex exp_2 mode$$ $codep */ # include // define size_t # include // 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; } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/exp_eps_cppad.cpp0000644000175200017650000001113612656321772022137 0ustar coincoin-web// $Id: exp_eps_cppad.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 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 $$ $section exp_eps: CppAD Forward and Reverse Sweeps$$. $head Purpose$$ Use CppAD forward and reverse modes to compute the partial derivative with respect to $latex x$$, at the point $latex x = .5$$ and $latex \varepsilon = .2$$, of the function $codei% exp_eps(%x%, %epsilon%) %$$ as defined by the $cref exp_eps.hpp$$ include file. $head Exercises$$ $list number$$ Create and test a modified version of the routine below that computes the same order derivatives with respect to $latex x$$, at the point $latex x = .1$$ and $latex \varepsilon = .2$$, of the function $codei% exp_eps(%x%, %epsilon%) %$$ $lnext Create and test a modified version of the routine below that computes partial derivative with respect to $latex x$$, at the point $latex x = .1$$ and $latex \varepsilon = .2$$, of the function corresponding to the operation sequence 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%) %$$ to run zero order forward mode at a point different form the point where the operation sequence corresponding to $icode f$$ was recorded. $lend $codep */ # 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); return ok; } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/exp_2_rev2.cpp0000644000175200017650000000531112656321772021276 0ustar coincoin-web// $Id: exp_2_rev2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_2_rev2.cpp$$ $spell cstddef cmath exp_2_rev bool std fabs $$ $section exp_2: Verify Second Order Reverse Sweep$$ $mindex exp_2 mode$$ $codep */ # include // define size_t # include // 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; } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/exp_2.cpp0000644000175200017650000000155312656321772020344 0ustar coincoin-web// $Id: exp_2.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 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; } // END C++ cppad-20160000.1/introduction/exp_apx/exp_2.omh0000644000175200017650000006556312656321772020360 0ustar coincoin-web$Id: exp_2.omh 3757 2015-11-30 12:03:07Z bradbell $ ----------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. ----------------------------------------------------------------------------- $begin exp_2.hpp$$ $spell exp $$ $section exp_2: Implementation$$ $mindex exp_2$$ $code $verbatim%introduction/exp_apx/exp_2.hpp%0%// BEGIN C++%// END C++%$$ $$ $end ----------------------------------------------------------------------------- $begin exp_2.cpp$$ $spell exp $$ $section exp_2: Test$$ $code $verbatim%introduction/exp_apx/exp_2.cpp%0%// BEGIN C++%// END C++%$$ $$ $end ----------------------------------------------------------------------------- $begin exp_2_for0$$ $spell cpp exp_2_seq bool $$ $section exp_2: Operation Sequence and Zero Order Forward Mode$$ $mindex example$$ $head Mathematical Form$$ The operation sequence (see below) corresponding to 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 \] $$ An algorithmic differentiation package does not operate on the mathematical function $latex f(x)$$ but rather on the particular algorithm used to compute the function (in this case $cref exp_2.hpp$$). $head Zero Order Expansion$$ In general, a zero order forward sweep is given a vector $latex x^{(0)} \in \B{R}^n$$ and it returns the corresponding vector $latex y^{(0)} \in \B{R}^m$$ given by $latex \[ y^{(0)} = f( x^{(0)} ) \]$$ The superscript $latex (0)$$ denotes zero order derivative; i.e., it is equal to the value of the corresponding variable. For the example we are considering here, both $latex n$$ and $latex m$$ are equal to one. $head Operation Sequence$$ An atomic $icode Type$$ operation is an operation that has a $icode Type$$ result and is not made up of other more basic operations. A sequence of atomic $icode Type$$ operations is called a $icode Type$$ operation sequence. Given an C++ algorithm and its inputs, there is a corresponding $icode Type$$ operation sequence for each type. If $icode Type$$ is clear from the context, we drop it and just refer to the operation sequence. $pre $$ We consider the case where $cref exp_2.hpp$$ is executed with $latex x^{(0)} = .5$$. The table below contains the corresponding operation sequence and the results of a zero order sweep. $subhead Index$$ The Index column contains the index in the operation sequence of the corresponding atomic operation and variable. A Forward sweep starts with the first operation and ends with the last. $subhead Code$$ The Code column contains the C++ source code corresponding to the corresponding atomic operation in the sequence. $subhead Operation$$ The Operation column contains the mathematical function corresponding to each atomic operation in the sequence. $subhead Zero Order$$ The Zero Order column contains the zero order derivative for the corresponding variable in the operation sequence. Forward mode refers to the fact that these coefficients are computed in the same order as the original algorithm; i.e, in order of increasing index in the operation sequence. $subhead Sweep$$ $center $table $bold Index$$ $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$$ $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$$ $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$$ $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$$ $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$$ $tend $$ $head Return Value$$ The return value for this case is $latex \[ 1.625 = v_5^{(0)} = f( x^{(0)} ) \] $$ $children% introduction/exp_apx/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$$ Suppose that $latex 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 $latex \[ v_1^{(0)} , v_2^{(0)} , \cdots , v_5^{(0)} \]$$ $lnext Create a modified version of $cref exp_2_for0.cpp$$ that verifies the values you obtained for the previous exercise. $lnext Create and run a main program that reports the result of calling the modified version of $cref exp_2_for0.cpp$$ in the previous exercise. $lend $end ------------------------------------------------------------------------------ $begin exp_2_for1$$ $spell exp_2_for $$ $section exp_2: First Order Forward Mode$$ $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 \]$$ it follows that $latex x^{(0)}$$ is the zero, and $latex x^{(1)}$$ the first, order derivative of $latex x(t)$$ at $latex t = 0$$. $head Purpose$$ In general, a first order forward sweep is given the $cref/zero order derivative/exp_2_for0/Zero Order Expansion/$$ 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. $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ f(x) = 1 + x + x^2 / 2 \] $$ The corresponding derivative function is $latex \[ \partial_x f (x) = 1 + x \] $$ An algorithmic differentiation package does not operate on the mathematical form of the function, or its derivative, but rather on the $cref/operation sequence/exp_2_for0/Operation Sequence/$$ for the for the algorithm that is used to evaluate the function. $head Operation Sequence$$ We consider the case where $cref exp_2.hpp$$ is executed with $latex x = .5$$. The corresponding operation sequence and zero order forward mode values (see $cref/zero order sweep/exp_2_for0/Operation Sequence/Sweep/$$) are inputs and are used by a first order forward sweep. $subhead Index$$ The Index column contains the index in the operation sequence of the corresponding atomic operation. A Forward sweep starts with the first operation and ends with the last. $subhead Operation$$ The Operation column contains the mathematical function corresponding to each atomic operation in the sequence. $subhead Zero Order$$ The Zero Order column contains the zero order derivatives for the corresponding variable in the operation sequence (see $cref/zero order sweep/exp_2_for0/Operation Sequence/Sweep/$$). $subhead Derivative$$ The Derivative column contains the mathematical function corresponding to the derivative with respect to $latex t$$, at $latex t = 0$$, for each variable in the sequence. $subhead First Order$$ 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 \] $$ We use $latex x^{(1)} = 1$$ so that differentiation with respect to $latex t$$, at $latex t = 0$$, is the same as partial differentiation with respect to $latex x$$ at $latex x = x^{(0)}$$. $subhead Sweep$$ $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$$ $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$$ $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$$ $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$$ $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$$ $tend $$ $head Return Value$$ 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)} ) \end{array} \] $$ (We have used the fact that $latex x^{(1)} = 1$$.) $children% introduction/exp_apx/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$$ Which statement in the routine defined by $cref exp_2_for1.cpp$$ uses the values that are calculated by the routine defined by $cref exp_2_for0.cpp$$ ? $lnext Suppose that $latex x = .1$$, what are the results of a zero and first order forward sweep for the operation sequence above; i.e., what are the corresponding values for $latex v_1^{(0)}, v_2^{(0)}, \cdots , v_5^{(0)}$$ and $latex v_1^{(1)}, v_2^{(1)}, \cdots , v_5^{(1)}$$ ? $lnext Create a modified version of $cref exp_2_for1.cpp$$ that verifies the derivative values from the previous exercise. Also create and run a main program that reports the result of calling the modified version of $cref exp_2_for1.cpp$$. $lend $end ------------------------------------------------------------------------------ $begin exp_2_rev1$$ $spell exp_2_rev $$ $section exp_2: First Order Reverse Mode$$ $head Purpose$$ First order reverse mode uses the $cref/operation sequence/exp_2_for0/Operation Sequence/$$, and zero order forward sweep values, to compute the first order derivative of one dependent variable with respect to all the independent variables. The computations are done in reverse of the order of the computations in the original algorithm. $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ f(x) = 1 + x + x^2 / 2 \] $$ The corresponding derivative function is $latex \[ \partial_x f (x) = 1 + x \] $$ $head f_5$$ For our example, we chose to compute the derivative of the value returned by $cref exp_2.hpp$$ which is equal to the symbol $latex v_5$$ in the $cref/exp_2 operation sequence/exp_2_for0/Operation Sequence/$$. We begin with the function $latex f_5 $$ where $latex v_5$$ is both an argument and the value of the function; i.e., $latex \[ \begin{array}{rcl} f_5 ( v_1 , v_2 , v_3 , v_4 , v_5 ) & = & v_5 \\ \D{f_5}{v_5} & = & 1 \end{array} \] $$ All the other partial derivatives of $latex f_5 $$ are zero. $head 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, $latex \[ v_5 = v_2 + v_4 \] $$ We define the function $latex f_4 ( v_1 , v_2 , v_3 , v_4 ) $$ as equal to $latex f_5 $$ except that $latex v_5 $$ is eliminated using this operation; i.e. $latex \[ f_4 = f_5 [ v_1 , v_2 , v_3 , v_4 , v_5 ( v_2 , v_4 ) ] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_4}{v_2} & = & \D{f_5}{v_2} + \D{f_5}{v_5} * \D{v_5}{v_2} & = 1 \\ \D{f_4}{v_4} & = & \D{f_5}{v_4} + \D{f_5}{v_5} * \D{v_5}{v_4} & = 1 \end{array} \] $$ All the other partial derivatives of $latex f_4$$ are zero. $head Index 4: f_3$$ The next operation has index 4, $latex \[ v_4 = v_3 / 2 \] $$ We define the function $latex f_3 ( v_1 , v_2 , v_3 ) $$ as equal to $latex f_4 $$ except that $latex v_4 $$ is eliminated using this operation; i.e., $latex \[ f_3 = f_4 [ v_1 , v_2 , v_3 , v_4 ( v_3 ) ] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_3}{v_1} & = & \D{f_4}{v_1} & = 0 \\ \D{f_3}{v_2} & = & \D{f_4}{v_2} & = 1 \\ \D{f_3}{v_3} & = & \D{f_4}{v_3} + \D{f_4}{v_4} * \D{v_4}{v_3} & = 0.5 \end{array} \] $$ $head Index 3: f_2$$ The next operation has index 3, $latex \[ v_3 = v_1 * v_1 \] $$ We define the function $latex f_2 ( v_1 , v_2 ) $$ as equal to $latex f_3 $$ except that $latex v_3 $$ is eliminated using this operation; i.e., $latex \[ f_2 = f_3 [ v_1 , v_2 , v_3 ( v_1 ) ] \] $$ Note that the value of $latex v_1$$ is equal to $latex x$$ which is .5 for this evaluation. It follows that $latex \[ \begin{array}{rcll} \D{f_2}{v_1} & = & \D{f_3}{v_1} + \D{f_3}{v_3} * \D{v_3}{v_1} & = 0.5 \\ \D{f_2}{v_2} & = & \D{f_3}{v_2} & = 1 \end{array} \] $$ $head Index 2: f_1$$ The next operation has index 2, $latex \[ v_2 = 1 + v_1 \] $$ We define the function $latex f_1 ( v_1 ) $$ as equal to $latex f_2 $$ except that $latex v_2 $$ is eliminated using this operation; i.e., $latex \[ f_1 = f_2 [ v_1 , v_2 ( v_1 ) ] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_1}{v_1} & = & \D{f_2}{v_1} + \D{f_2}{v_2} * \D{v_2}{v_1} & = 1.5 \end{array} \] $$ Note that $latex v_1$$ is equal to $latex x$$, so the derivative of this is the derivative of the function defined by $cref exp_2.hpp$$ at $latex x = .5$$. $children% introduction/exp_apx/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 other partials of $latex f_j$$ must be equal to the corresponding partials of $latex f_{j+1}$$. $head Exercises$$ $list number$$ Which statement in the routine defined by $cref exp_2_rev1.cpp$$ uses the values that are calculated by the routine defined by $cref exp_2_for0.cpp$$ ? $lnext Consider the case where $latex x = .1$$ and we first preform a zero order forward sweep for the operation sequence used above. What are the results of a first order reverse sweep; i.e., what are the corresponding derivatives of $latex f_5 , f_4 , \ldots , f_1$$. $lnext Create a modified version of $cref exp_2_rev1.cpp$$ 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 $cref exp_2_rev1.cpp$$. $lend $end ------------------------------------------------------------------------------ $begin exp_2_for2$$ $spell exp_2_for $$ $section exp_2: Second Order Forward Mode$$ $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 \]$$ It follows that for $latex k = 0 , 1 , 2$$, $latex \[ x^{(k)} = \dpow{k}{t} x (0) \] $$ $head Purpose$$ In general, a second order forward sweep is given the $cref/first order expansion/exp_2_for1/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. $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ f(x) = 1 + x + x^2 / 2 \] $$ The corresponding second derivative function is $latex \[ \Dpow{2}{x} f (x) = 1 \] $$ $head Operation Sequence$$ We consider the case where $cref exp_2.hpp$$ is executed with $latex 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. $subhead Index$$ The Index column contains the index in the operation sequence of the corresponding atomic operation. A Forward sweep starts with the first operation and ends with the last. $subhead Zero$$ The Zero column contains the zero order sweep results for the corresponding variable in the operation sequence (see $cref/zero order sweep/exp_2_for0/Operation Sequence/Sweep/$$). $subhead Operation$$ The Operation column contains the first order sweep operation for this variable. $subhead First$$ The First column contains the first order sweep results for the corresponding variable in the operation sequence (see $cref/first order sweep/exp_2_for1/Operation Sequence/Sweep/$$). $subhead Derivative$$ The Derivative column contains the mathematical function corresponding to the second derivative with respect to $latex t$$, at $latex t = 0$$, for each variable in the sequence. $subhead 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 $th i$$ variable is given by $latex \[ 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 with respect to $latex t$$, at $latex t = 0$$, is the same as the second partial differentiation with respect to $latex x$$ at $latex x = x^{(0)}$$. $subhead Sweep$$ $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$$ $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$$ $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$$ $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 $latex v_3^{(2)} = 2 * (v_1^{(1)} * v_1^{(1)} + v_1^{(0)} * v_1^{(2)} )$$ $cnext $cnext $latex v_3^{(2)} = 2$$ $rnext 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$$ $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$$ $tend $$ $head Return Value$$ 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)} ) \end{array} \] $$ (We have used the fact that $latex x^{(1)} = 1$$ and $latex x^{(2)} = 0$$.) $children% introduction/exp_apx/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$$ Which statement in the routine defined by $cref exp_2_for2.cpp$$ uses the values that are calculated by the routine defined by $cref exp_2_for1.cpp$$ ? $lnext Suppose that $latex x = .1$$, what are the results of a zero, first, and second order forward sweep for the operation sequence above; i.e., what are the corresponding values for $latex v_i^{(k)}$$ for $latex i = 1, \ldots , 5$$ and $latex k = 0, 1, 2$$. $lnext Create a modified version of $cref exp_2_for2.cpp$$ that verifies the derivative values from the previous exercise. Also create and run a main program that reports the result of calling the modified version of $cref exp_2_for2.cpp$$. $lend $end ------------------------------------------------------------------------------ $begin exp_2_rev2$$ $spell exp_2_rev $$ $section exp_2: Second Order Reverse Mode$$ $head Purpose$$ In general, a second order reverse sweep is given the $cref/first order expansion/exp_2_for1/First Order Expansion/$$ for all of the variables in an operation sequence. Given a choice of a particular variable, it computes the derivative, of that variables first order expansion coefficient, with respect to all of the independent variables. $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ f(x) = 1 + x + x^2 / 2 \] $$ The corresponding second derivative is $latex \[ \Dpow{2}{x} f (x) = 1 \] $$ $head f_5$$ For our example, we chose to compute the derivative of $latex v_5^{(1)}$$ with respect to all the independent variable. For the case computed for the $cref/first order sweep/exp_2_for1/Operation Sequence/Sweep/$$, $latex v_5^{(1)}$$ is the derivative of the value returned by $cref exp_2.hpp$$. This the value computed will be the second derivative of the value returned by $cref exp_2.hpp$$. We begin with the function $latex f_5 $$ where $latex v_5^{(1)}$$ is both an argument and the value of the function; i.e., $latex \[ \begin{array}{rcl} f_5 \left( v_1^{(0)}, v_1^{(1)} , \ldots , v_5^{(0)} , v_5^{(1)} \right) & = & v_5^{(1)} \\ \D{f_5}{v_5^{(1)}} & = & 1 \end{array} \] $$ All the other partial derivatives of $latex f_5 $$ are zero. $head 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 $latex \[ \begin{array}{rcl} v_5^{(0)} & = & v_2^{(0)} + v_4^{(0)} \\ v_5^{(1)} & = & v_2^{(1)} + v_4^{(1)} \end{array} \] $$ We define the function $latex f_4 \left( v_1^{(0)} , \ldots , v_4^{(1)} \right) $$ as equal to $latex f_5 $$ except that $latex v_5^{(0)} $$ and $latex v_5^{(1)}$$ are eliminated using this operation; i.e. $latex \[ f_4 = f_5 \left[ v_1^{(0)} , \ldots , v_4^{(1)} , v_5^{(0)} \left( v_2^{(0)} , v_4^{(0)} \right) , v_5^{(1)} \left( v_2^{(1)} , v_4^{(1)} \right) \right] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_4}{v_2^{(1)}} & = & \D{f_5}{v_2^{(1)}} + \D{f_5}{v_5^{(1)}} * \D{v_5^{(1)}}{v_2^{(1)}} & = 1 \\ \D{f_4}{v_4^{(1)}} & = & \D{f_5}{v_4^{(1)}} + \D{f_5}{v_5^{(1)}} * \D{v_5}{v_4^{(1)}} & = 1 \end{array} \] $$ All the other partial derivatives of $latex f_4$$ are zero. $head Index 4: f_3$$ The next operation has index 4, $latex \[ \begin{array}{rcl} v_4^{(0)} & = & v_3^{(0)} / 2 \\ v_4^{(1)} & = & v_3^{(1)} / 2 \end{array} \] $$ We define the function $latex f_3 \left( v_1^{(0)} , \ldots , v_3^{(1)} \right) $$ as equal to $latex f_4 $$ except that $latex v_4^{(0)}$$ and $latex v_4^{(1)}$$ are eliminated using this operation; i.e., $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) \right] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_3}{v_2^{(1)}} & = & \D{f_4}{v_2^{(1)}} & = 1 \\ \D{f_3}{v_3^{(1)}} & = & \D{f_4}{v_3^{(1)}} + \D{f_4}{v_4^{(1)}} * \D{v_4^{(1)}}{v_3^{(1)}} & = 0.5 \end{array} \] $$ All the other partial derivatives of $latex f_3$$ are zero. $head Index 3: f_2$$ 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)} \end{array} \] $$ We define the function $latex f_2 \left( v_1^{(0)} , \ldots , v_2^{(1)} \right) $$ as equal to $latex f_3 $$ except that $latex v_3^{(0)} $$ and $latex v_3^{(1)}$$ are eliminated using this operation; i.e., $latex \[ f_2 = f_3 \left[ v_1^{(0)} , \ldots , v_2^{(1)} , v_3^{(0)} ( v_1^{(0)} ) , v_3^{(1)} ( v_1^{(0)} , v_1^{(1)} ) \right] \] $$ Note that, from the $cref/first order forward sweep/exp_2_for1/Operation Sequence/Sweep/$$, the value of $latex v_1^{(0)}$$ is equal to $latex .5$$ and $latex v_1^{(1)}$$ is equal 1. It follows that $latex \[ \begin{array}{rcll} \D{f_2}{v_1^{(0)}} & = & \D{f_3}{v_1^{(0)}} + \D{f_3}{v_3^{(0)}} * \D{v_3^{(0)}}{v_1^{(0)}} + \D{f_3}{v_3^{(1)}} * \D{v_3^{(1)}}{v_1^{(0)}} & = 1 \\ \D{f_2}{v_1^{(1)}} & = & \D{f_3}{v_1^{(1)}} + \D{f_3}{v_3^{(1)}} * \D{v_3^{(1)}}{v_1^{(1)}} & = 0.5 \\ \D{f_2}{v_2^{(0)}} & = & \D{f_3}{v_2^{(0)}} & = 0 \\ \D{f_2}{v_2^{(1)}} & = & \D{f_3}{v_2^{(1)}} & = 1 \end{array} \] $$ $head Index 2: f_1$$ The next operation has index 2, $latex \[ \begin{array}{rcl} v_2^{(0)} & = & 1 + v_1^{(0)} \\ v_2^{(1)} & = & v_1^{(1)} \end{array} \] $$ We define the function $latex f_1 ( v_1^{(0)} , v_1^{(1)} ) $$ as equal to $latex f_2 $$ except that $latex v_2^{(0)} $$ and $latex v_2^{(1)} $$ are eliminated using this operation; i.e., $latex \[ f_1 = f_2 \left[ v_1^{(0)} , v_1^{(1)} , v_2^{(0)} ( v_1^{(0)} ) , v_2^{(1)} ( v_1^{(1)} ) \right] \] $$ It follows that $latex \[ \begin{array}{rcll} \D{f_1}{v_1^{(0)}} & = & \D{f_2}{v_1^{(0)}} + \D{f_2}{v_2^{(0)}} * \D{v_2^{(0)}}{v_1^{(0)}} & = 1 \\ \D{f_1}{v_1^{(1)}} & = & \D{f_2}{v_1^{(1)}} + \D{f_2}{v_2^{(1)}} * \D{v_2^{(1)}}{v_1^{(1)}} & = 1.5 \end{array} \] $$ Note that $latex v_1$$ is equal to $latex x$$, so the second derivative of the function defined by $cref exp_2.hpp$$ at $latex x = .5$$ is given by $latex \[ \Dpow{2}{x} v_5^{(0)} = \D{ v_5^{(1)} }{x} = \D{ v_5^{(1)} }{v_1^{(0)}} = \D{f_1}{v_1^{(0)}} = 1 \] $$ There is a theorem about Algorithmic Differentiation that explains why the other partial of $latex f_1$$ is equal to the first derivative of the function defined by $cref exp_2.hpp$$ at $latex x = .5$$. $children% introduction/exp_apx/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 other partials of $latex f_j$$ must be equal to the corresponding partials of $latex f_{j+1}$$. $head Exercises$$ $list number$$ Which statement in the routine defined by $cref exp_2_rev2.cpp$$ uses the values that are calculated by the routine defined by $cref exp_2_for0.cpp$$ ? Which statements use values that are calculate by the routine defined in $cref exp_2_for1.cpp$$ ? $lnext Consider the case where $latex 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 $latex f_5 , f_4 , \ldots , f_1$$. $lnext Create a modified version of $cref exp_2_rev2.cpp$$ that verifies the values you obtained for the previous exercise. Also create and run a main program that reports the result of calling the modified version of $cref exp_2_rev2.cpp$$. $lend $end ------------------------------------------------------------------------------ cppad-20160000.1/introduction/exp_apx/exp_2.hpp0000644000175200017650000001002412656321772020342 0ustar coincoin-web// $Id: exp_2.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_EXP_2_HPP # define CPPAD_EXP_2_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_2$$ $spell cppad-%yyyymmdd% hpp Apx cpp const exp bool $$ $section Second Order Exponential Approximation$$ $mindex exp_2 example algorithm$$ $head Syntax$$ $codei%# include "exp_2.hpp"%$$ $pre $$ $icode%y% = exp_2(%x%)%$$ $head Purpose$$ This is a simple example algorithm that is used to demonstrate Algorithmic Differentiation (see $cref exp_eps$$ for a more complex example). $head Mathematical Form$$ The exponential function can be defined by $latex \[ \exp (x) = 1 + x^1 / 1 ! + x^2 / 2 ! + \cdots \] $$ The second order approximation for the exponential function is $latex \[ {\rm exp\_2} (x) = 1 + x + x^2 / 2 \] $$ $head include$$ The include command in the syntax is relative to $codei% cppad-%yyyymmdd%/introduction/exp_apx %$$ where $codei%cppad-%yyyymmdd%$$ is the distribution directory created during the beginning steps of the $cref%installation%Install%$$ of CppAD. $head x$$ The argument $icode x$$ has prototype $codei% const %Type% &%x% %$$ (see $icode Type$$ below). It specifies the point at which to evaluate the approximation for the second order exponential approximation. $head y$$ The result $icode y$$ has prototype $codei% %Type% %y% %$$ It is the value of the exponential function approximation defined above. $head Type$$ If $icode u$$ and $icode v$$ are $icode Type$$ objects and $icode i$$ is an $code int$$: $table $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$$ $rnext $icode%Type u %=% 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$$ $rnext $icode%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$$ $tend $childtable% introduction/exp_apx/exp_2.omh% introduction/exp_apx/exp_2_cppad.cpp %$$ $head Implementation$$ The file $cref exp_2.hpp$$ contains a C++ implementation of this function. $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); $$ What is the value assigned to $code v1$$, $code v2$$, ... ,$code v5$$ in $cref exp_2.hpp$$ ? $lnext Extend the routine $code exp_2.hpp$$ to a routine $code exp_3.hpp$$ that computes $latex \[ 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); $$ using $code exp_3$$ created in the previous problem. What is the value assigned to the new variables in $code exp_3$$ (variables that are in $code exp_3$$ and not in $code exp_2$$) ? $lend $end ------------------------------------------------------------------------------ */ // BEGIN C++ template 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 } // END C++ # endif cppad-20160000.1/introduction/exp_apx/main.cpp0000644000175200017650000000574012656321772020255 0ustar coincoin-web// $Id: main.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_apx_main.cpp$$ $spell 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 main.cpp$$ $code $verbatim%introduction/exp_apx/main.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ // system include files used for I/O # include // 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); namespace { static size_t Run_ok_count = 0; static size_t Run_error_count = 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.c_str(); // ok &= name.size() < size_t(width); ok &= TestOk(); if( ok ) { std::cout << "OK" << std::endl; Run_ok_count++; } 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 namespace std; // This comment is used by OneTest // external compiled tests ok &= Run( exp_2, "exp_2" ); ok &= Run( exp_2_cppad, "exp_2_cppad" ); ok &= Run( exp_2_for0, "exp_2_for0" ); ok &= Run( exp_2_for1, "exp_2_for1" ); ok &= Run( exp_2_for2, "exp_2_for2" ); ok &= Run( exp_2_rev1, "exp_2_rev1" ); ok &= Run( exp_2_rev2, "exp_2_rev2" ); ok &= Run( exp_eps, "exp_eps" ); ok &= Run( exp_eps_cppad, "exp_eps_cppad" ); ok &= Run( exp_eps_for0, "exp_eps_for0" ); ok &= Run( exp_eps_for1, "exp_eps_for1" ); ok &= Run( exp_eps_for2, "exp_eps_for2" ); ok &= Run( exp_eps_rev1, "exp_eps_rev1" ); ok &= Run( exp_eps_rev2, "exp_eps_rev2" ); if( ok ) cout << "All " << int(Run_ok_count) << " tests passed." << endl; else cout << int(Run_error_count) << " tests failed." << endl; return static_cast( ! ok ); } // END C++ cppad-20160000.1/introduction/exp_apx/exp_2_cppad.cpp0000644000175200017650000000774212656321772021521 0ustar coincoin-web// $Id: exp_2_cppad.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 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 $$ $section exp_2: CppAD Forward and Reverse Sweeps$$. $head Purpose$$ Use CppAD forward and reverse modes to compute the partial derivative with respect to $latex x$$, at the point $latex x = .5$$, of the function $codei% exp_2(%x%) %$$ as defined by the $cref exp_2.hpp$$ include file. $head Exercises$$ $list number$$ Create and test a modified version of the routine below that computes the same order derivatives with respect to $latex x$$, at the point $latex x = .1$$ of the function $codei% exp_2(%x%) %$$ $lnext Create a routine called $codei% exp_3(%x%) %$$ that evaluates the function $latex \[ 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)$$ at the point $latex x = .5$$. $lend $codep */ # 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); return ok; } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/makefile.am0000644000175200017650000000241412656321772020714 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 = # # Microsoft project files EXTRA_DIST = \ exp_2.omh \ exp_eps.omh # check_PROGRAMS = exp_apx # AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) AM_CXXFLAGS = -g $(CXX_FLAGS) # exp_apx_SOURCES = \ main.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 test: check ./exp_apx cppad-20160000.1/introduction/exp_apx/exp_eps_for0.cpp0000644000175200017650000000334612656321772021722 0ustar coincoin-web// $Id: exp_eps_for0.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_eps_for0.cpp$$ $spell std exp_eps_seq cmath bool fabs $$ $section exp_eps: Verify Zero Order Forward Sweep$$ $mindex exp_eps$$ $codep */ # include // 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); } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/exp_eps_for1.cpp0000644000175200017650000000360412656321772021720 0ustar coincoin-web// $Id: exp_eps_for1.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_eps_for1.cpp$$ $spell std vars exp_eps_for cmath fabs bool $$ $section exp_eps: Verify First Order Forward Sweep$$ $mindex exp_2$$ $codep */ # 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]; // 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); } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/exp_eps_for2.cpp0000644000175200017650000000367212656321772021726 0ustar coincoin-web// $Id: exp_eps_for2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_eps_for2.cpp$$ $spell std vars exp_eps_for cmath fabs bool $$ $section exp_eps: Verify Second Order Forward Sweep$$ $mindex first exp_2$$ $codep */ # include // 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; } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/CMakeLists.txt0000644000175200017650000000251312656321772021360 0ustar coincoin-web# $Id: CMakeLists.txt 2683 2012-12-30 18:17:03Z 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. # ----------------------------------------------------------------------------- # Build the introduction/exp_apx directory tests # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # ADD_EXECUTABLE(introduction_exp_apx EXCLUDE_FROM_ALL main.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 ) # Compiler flags for cppad source add_cppad_cxx_flags( introduction_exp_apx ) # Add the check_speed_example target ADD_CUSTOM_TARGET(check_introduction_exp_apx introduction_exp_apx DEPENDS introduction_exp_apx ) cppad-20160000.1/introduction/exp_apx/exp_eps_rev1.cpp0000644000175200017650000000421512656321772021725 0ustar coincoin-web// $Id: exp_eps_rev1.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_eps_rev1.cpp$$ $spell 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$$ $codep */ # include // define size_t # include // 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; } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/exp_eps_rev2.cpp0000644000175200017650000000665712656321772021742 0ustar coincoin-web// $Id: exp_eps_rev2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp_eps_rev2.cpp$$ $spell 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$$ $codep */ # include // define size_t # include // 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; } /* $$ $end */ cppad-20160000.1/introduction/exp_apx/makefile.in0000644000175200017650000005100512656321772020725 0ustar coincoin-web# 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 = exp_apx$(EXEEXT) subdir = introduction/exp_apx 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_exp_apx_OBJECTS = main.$(OBJEXT) exp_2.$(OBJEXT) \ exp_2_cppad.$(OBJEXT) exp_2_for1.$(OBJEXT) \ exp_2_for2.$(OBJEXT) exp_2_rev1.$(OBJEXT) exp_2_rev2.$(OBJEXT) \ exp_2_for0.$(OBJEXT) exp_eps.$(OBJEXT) exp_eps_cppad.$(OBJEXT) \ exp_eps_for1.$(OBJEXT) exp_eps_for2.$(OBJEXT) \ exp_eps_for0.$(OBJEXT) exp_eps_rev1.$(OBJEXT) \ exp_eps_rev2.$(OBJEXT) exp_apx_OBJECTS = $(am_exp_apx_OBJECTS) exp_apx_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 = $(exp_apx_SOURCES) DIST_SOURCES = $(exp_apx_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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # # Microsoft project files EXTRA_DIST = \ exp_2.omh \ exp_eps.omh # AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) AM_CXXFLAGS = -g $(CXX_FLAGS) # exp_apx_SOURCES = \ main.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 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) --gnu introduction/exp_apx/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu introduction/exp_apx/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) exp_apx$(EXEEXT): $(exp_apx_OBJECTS) $(exp_apx_DEPENDENCIES) $(EXTRA_exp_apx_DEPENDENCIES) @rm -f exp_apx$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(exp_apx_OBJECTS) $(exp_apx_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_2_cppad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_2_for0.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_2_for1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_2_for2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_2_rev1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_2_rev2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_eps.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_eps_cppad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_eps_for0.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_eps_for1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_eps_for2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_eps_rev1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_eps_rev2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.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 ./exp_apx # 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: cppad-20160000.1/introduction/get_started/0002755000175200017650000000000012656321772017462 5ustar coincoin-webcppad-20160000.1/introduction/get_started/makefile.am0000644000175200017650000000166712656321772021566 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 = get_started # AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) AM_CXXFLAGS = -g $(CXX_FLAGS) # get_started_SOURCES = get_started.cpp # test: check ./get_started cppad-20160000.1/introduction/get_started/CMakeLists.txt0000644000175200017650000000215312656321772022221 0ustar coincoin-web# $Id: CMakeLists.txt 2683 2012-12-30 18:17:03Z 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. # ----------------------------------------------------------------------------- # Build the introduction/get_started directory tests # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # ADD_EXECUTABLE(introduction_get_started EXCLUDE_FROM_ALL get_started.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags( introduction_get_started ) # Add the check_speed_example target ADD_CUSTOM_TARGET(check_introduction_get_started introduction_get_started DEPENDS introduction_get_started ) cppad-20160000.1/introduction/get_started/makefile.in0000644000175200017650000004477112656321772021602 0ustar coincoin-web# 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 = get_started$(EXEEXT) subdir = introduction/get_started 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_get_started_OBJECTS = get_started.$(OBJEXT) get_started_OBJECTS = $(am_get_started_OBJECTS) get_started_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 = $(get_started_SOURCES) DIST_SOURCES = $(get_started_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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) AM_CXXFLAGS = -g $(CXX_FLAGS) # get_started_SOURCES = get_started.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) --gnu introduction/get_started/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu introduction/get_started/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) get_started$(EXEEXT): $(get_started_OBJECTS) $(get_started_DEPENDENCIES) $(EXTRA_get_started_DEPENDENCIES) @rm -f get_started$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(get_started_OBJECTS) $(get_started_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_started.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 ./get_started # 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: cppad-20160000.1/introduction/get_started/get_started.cpp0000644000175200017650000001170412656321772022474 0ustar coincoin-web// $Id: get_started.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin get_started.cpp$$ $spell cppad.hpp http://www.coin-or.org/CppAD/ getstarted namespace iostream const std powx Jacobian jac endl da cout $$ $section Getting Started Using CppAD to Compute Derivatives$$ $mindex simple example start$$ $head Purpose$$ Demonstrate the use of CppAD by computing the derivative of a simple example function. $head Function$$ The example function $latex f : \B{R} \rightarrow \B{R}$$ is defined by $latex \[ 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} \] $$ $head Value$$ For the particular case in this example, $latex k$$ is equal to 5, $latex a = (1, 1, 1, 1, 1)$$, and $latex x = 3$$. If follows that $latex \[ f' ( 3 ) = 1 + 2 * 3 + 3 * 3^2 + 4 * 3^3 = 142 \] $$ $head Poly$$ The routine $code Poly$$ is defined below for this particular application. 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 $head Program$$ $codep */ #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; } } // 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 return error_code; } /* $$ $head Output$$ Executing the program above will generate the following output: $codep f'(3) computed by CppAD = 142 $$ $head Running$$ To build and run this program see $cref cmake_check$$. $end */ cppad-20160000.1/configure0000755000175200017650000102737712656112262014352 0ustar coincoin-web#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for cppad 20160000.1. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: cppad@list.coin-or.org about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='cppad' PACKAGE_TARNAME='cppad' PACKAGE_VERSION='20160000.1' PACKAGE_STRING='cppad 20160000.1' PACKAGE_BUGREPORT='cppad@list.coin-or.org' PACKAGE_URL='' ac_default_prefix=${HOME} # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_unique_file="cppad/cppad.hpp" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS ipopt_prefix eigen_prefix adolc_prefix cppad_SOURCE_DIR cppad_pkgconfig_requires cppad_pkgconfig_libs cppad_pkgconfig_cflags cppad_url cppad_version cppad_description CPPAD_IPOPT_LIBS CPPAD_IPOPT_LD_PATH BTHREAD_LIB CppAD_BTHREAD_FALSE CppAD_BTHREAD_TRUE DL_LIB PTHREAD_LIB CppAD_PTHREAD_FALSE CppAD_PTHREAD_TRUE ABS_TOP_SRCDIR ABS_TOP_BUILDDIR FCLIBS host_os host_vendor host_cpu host build_os build_vendor build_cpu build CppAD_MS_COMPILER_FALSE CppAD_MS_COMPILER_TRUE RANLIB cppad_has_gettimeofday cppad_cppadvector cppad_size_t_not_unsigned_int EGREP GREP CPP cppad_has_high_resolution_clock cppad_use_cplusplus_2011 cppad_has_cstdint_8_to_64 cppad_has_rvalue cppad_has_nullptr cppad_has_mkstemp cppad_has_colpack cppad_cxx_flags CppAD_HAVE_AR_FALSE CppAD_HAVE_AR_TRUE CppAD_PKG_CONFIG_FALSE CppAD_PKG_CONFIG_TRUE have_pkg_config ac_ct_FC FCFLAGS FC am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE ac_ct_CXX CXXFLAGS CXX cppad_tape_id_type TAPE_ID_TYPE cppad_tape_addr_type TAPE_ADDR_TYPE cppad_max_num_threads MAX_NUM_THREADS CppAD_OPENMP_FALSE CppAD_OPENMP_TRUE OPENMP_FLAGS CXX_FLAGS_EIGEN CXX_FLAGS_FADBAD CXX_FLAGS BOOST_INCLUDE CppAD_BOOST_DIR_FALSE CppAD_BOOST_DIR_TRUE BOOST_DIR CppAD_IPOPT_FALSE CppAD_IPOPT_TRUE IPOPT_DIR CppAD_SACADO_FALSE CppAD_SACADO_TRUE SACADO_DIR CppAD_FADBAD_FALSE CppAD_FADBAD_TRUE FADBAD_DIR EIGEN_INCLUDE CppAD_EIGEN_DIR_FALSE CppAD_EIGEN_DIR_TRUE EIGEN_DIR CppAD_ADOLC_FALSE CppAD_ADOLC_TRUE ADOLC_DIR CppAD_POSTFIX_FALSE CppAD_POSTFIX_TRUE POSTFIX_DIR cppad_deprecated CppAD_DEPRECATED_FALSE CppAD_DEPRECATED_TRUE cppad_internal_sparse_set cppad_eigenvector cppad_boostvector cppad_stdvector CppAD_DOCUMENTATION_FALSE CppAD_DOCUMENTATION_TRUE am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC ac_ct_AR AR am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_maintainer_mode enable_dependency_tracking with_SpeedExample with_profiling with_Speed with_Introduction with_Example with_TestMore with_PrintFor enable_msvc with_Documentation with_stdvector with_boostvector with_eigenvector with_sparse_set with_sparse_list with_deprecated ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS POSTFIX_DIR ADOLC_DIR EIGEN_DIR FADBAD_DIR SACADO_DIR IPOPT_DIR BOOST_DIR CXX_FLAGS OPENMP_FLAGS MAX_NUM_THREADS TAPE_ADDR_TYPE TAPE_ID_TYPE CXX CXXFLAGS CCC FC FCFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures cppad 20160000.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/cppad] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of cppad 20160000.1:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-msvc Prefer (i)cl/ifort/link over GNU on MinGW/Cygwin. Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-SpeedExample is not necessary, see install instructions. --with-profiling is not necessary, see install instructions. --with-Speed is not necessary, see install instructions. --with-Introduction is not necessary, see install instructions. --with-Example is not necessary, see install instructions. --with-TestMore is not necessary, see install instructions. --with-PrintFor is not necessary, see install instructions. --with-Documentation default is no --with-stdvector default is no --with-boostvector default is no --with-eigenvector default is no --with-sparse_set default is not specified --with-sparse_list default is not specified --with-deprecated include an implicit AD constructor from any type Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory POSTFIX_DIR postfix directory for CppAD installation ADOLC_DIR value of configure prefix directory during Adolc install EIGEN_DIR value of configure prefix directory during Eigen install FADBAD_DIR parent directory directly above FADBAD++ directory SACADO_DIR value of the configure prefix directory during Sacado install IPOPT_DIR value of the configure prefix directory during Ipopt install BOOST_DIR parent directory directly above boost directory CXX_FLAGS CXXFLAGS is ignored, use CXX_FLAGS for compiler flags OPENMP_FLAGS flags that instruct compiler to interpret OpenMP directrives MAX_NUM_THREADS maximum number of threads that can be used with CppAD TAPE_ADDR_TYPE type used for addresses in AD tapes TAPE_ID_TYPE type used for addresses in AD tapes CXX C++ compiler command CXXFLAGS C++ compiler flags FC Fortran compiler command FCFLAGS Fortran compiler flags CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF cppad configure 20160000.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_fc_try_compile LINENO # --------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_fc_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_fc_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_fc_try_compile # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 &5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link # ac_fn_fc_try_link LINENO # ------------------------ # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_fc_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_fc_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_fc_try_link cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by cppad $as_me 20160000.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=0;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else USE_MAINTAINER_MODE=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 $as_echo "$USE_MAINTAINER_MODE" >&6; } if test $USE_MAINTAINER_MODE = yes; then MAINTAINER_MODE_TRUE= MAINTAINER_MODE_FALSE='#' else MAINTAINER_MODE_TRUE='#' MAINTAINER_MODE_FALSE= fi MAINT=$MAINTAINER_MODE_TRUE am__api_version='1.15' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='cppad' VERSION='20160000.1' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi # check if we have ar program have_ar='yes' DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi if test -n "$ac_tool_prefix"; then for ac_prog in ar lib "link -lib" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar lib "link -lib" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} { $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5 $as_echo_n "checking the archiver ($AR) interface... " >&6; } if ${am_cv_ar_interface+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am_cv_ar_interface=ar cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int some_variable = 0; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 (eval $am_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then am_cv_ar_interface=ar else am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 (eval $am_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then am_cv_ar_interface=lib else am_cv_ar_interface=unknown fi fi rm -f conftest.lib libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5 $as_echo "$am_cv_ar_interface" >&6; } case $am_cv_ar_interface in ar) ;; lib) # Microsoft lib, so override with the ar-lib wrapper script. # FIXME: It is wrong to rewrite AR. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__AR in this case, # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something # similar. AR="$am_aux_dir/ar-lib $AR" ;; unknown) have_ar='no' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: have_ar = $have_ar" >&5 $as_echo "$as_me: have_ar = $have_ar" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: *** Check command line arguments that are longer used ****" >&5 $as_echo "$as_me: *** Check command line arguments that are longer used ****" >&6;} if test "$CPP_ERROR_WARN" != "" ; then as_fn_error $? "The CPP_ERROR_WARN configure option is now CXX_FLAGS" "$LINENO" 5 fi # Check whether --with-SpeedExample was given. if test "${with_SpeedExample+set}" = set; then : withval=$with_SpeedExample; SpeedExample="yes" else SpeedExample="no" fi if test "$SpeedExample" = "yes" ; then as_fn_error $? "--with-SpeedExample not necessary, see install instructions." "$LINENO" 5 fi # Check whether --with-profiling was given. if test "${with_profiling+set}" = set; then : withval=$with_profiling; profiling="yes" else profiling="no" fi if test "$profiling" = "yes" ; then as_fn_error $? "--with-profiling not necessary, see install instructions." "$LINENO" 5 fi # Check whether --with-Speed was given. if test "${with_Speed+set}" = set; then : withval=$with_Speed; Speed="yes" else Speed="no" fi if test "$Speed" = "yes" ; then as_fn_error $? "--with-Speed not necessary, see install instructions." "$LINENO" 5 fi # Check whether --with-Introduction was given. if test "${with_Introduction+set}" = set; then : withval=$with_Introduction; Introduction="yes" else Introduction="no" fi if test "$Introduction" = "yes" ; then as_fn_error $? "--with-Introduction not necessary, see install instructions." "$LINENO" 5 fi # Check whether --with-Example was given. if test "${with_Example+set}" = set; then : withval=$with_Example; Example="yes" else Example="no" fi if test "$Example" = "yes" ; then as_fn_error $? "--with-Example not necessary, see install instructions." "$LINENO" 5 fi # Check whether --with-TestMore was given. if test "${with_TestMore+set}" = set; then : withval=$with_TestMore; TestMore="yes" else TestMore="no" fi if test "$TestMore" = "yes" ; then as_fn_error $? "--with-TestMore not necessary, see install instructions." "$LINENO" 5 fi # Check whether --with-PrintFor was given. if test "${with_PrintFor+set}" = set; then : withval=$with_PrintFor; PrintFor="yes" else PrintFor="no" fi if test "$PrintFor" = "yes" ; then as_fn_error $? "--with-PrintFor not necessary, see install instructions." "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: ****** Check command line arguments that are used ***********" >&5 $as_echo "$as_me: ****** Check command line arguments that are used ***********" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-msvc" >&5 $as_echo_n "checking --enable-msvc... " >&6; } # Check whether --enable-msvc was given. if test "${enable_msvc+set}" = set; then : enableval=$enable_msvc; enable_msvc=$enableval else enable_msvc=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_msvc" >&5 $as_echo "$enable_msvc" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking --prefix" >&5 $as_echo_n "checking --prefix... " >&6; } if test "$prefix" = "NONE" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HOME" >&5 $as_echo "$HOME" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $prefix" >&5 $as_echo "$prefix" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-Documentation" >&5 $as_echo_n "checking --with-Documentation... " >&6; } # Check whether --with-Documentation was given. if test "${with_Documentation+set}" = set; then : withval=$with_Documentation; Documentation="yes" else Documentation="no" fi if test "$Documentation" = "yes"; then CppAD_DOCUMENTATION_TRUE= CppAD_DOCUMENTATION_FALSE='#' else CppAD_DOCUMENTATION_TRUE='#' CppAD_DOCUMENTATION_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $Documentation" >&5 $as_echo "$Documentation" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-stdvector" >&5 $as_echo_n "checking --with-stdvector... " >&6; } # Check whether --with-stdvector was given. if test "${with_stdvector+set}" = set; then : withval=$with_stdvector; stdvector="yes" else stdvector="no" fi if test "$stdvector" = "yes" ; then cppad_stdvector=1 else cppad_stdvector=0 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $stdvector" >&5 $as_echo "$stdvector" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-boostvector" >&5 $as_echo_n "checking --with-boostvector... " >&6; } # Check whether --with-boostvector was given. if test "${with_boostvector+set}" = set; then : withval=$with_boostvector; boostvector="yes" else boostvector="no" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boostvector" >&5 $as_echo "$boostvector" >&6; } if test "$boostvector" = "yes" ; then if test "$stdvector" != "no" ; then as_fn_error $? "cannot --with both stdvector and boostvector" "$LINENO" 5 fi cppad_boostvector=1 else cppad_boostvector=0 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-eigenvector" >&5 $as_echo_n "checking --with-eigenvector... " >&6; } # Check whether --with-eigenvector was given. if test "${with_eigenvector+set}" = set; then : withval=$with_eigenvector; eigenvector="yes" else eigenvector="no" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $eigenvector" >&5 $as_echo "$eigenvector" >&6; } if test "$eigenvector" = "yes" ; then if test "$stdvector" != "no" ; then as_fn_error $? "cannot --with both stdvector and eigenvector" "$LINENO" 5 fi if test "$boostvector" != "no" ; then as_fn_error $? "cannot --with both boostvector and eigenvector" "$LINENO" 5 fi cppad_eigenvector=1 else cppad_eigenvector=0 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-sparse_set" >&5 $as_echo_n "checking --with-sparse_set... " >&6; } # Check whether --with-sparse_set was given. if test "${with_sparse_set+set}" = set; then : withval=$with_sparse_set; sparse_set="yes" else sparse_set="no" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sparse_set" >&5 $as_echo "$sparse_set" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-sparse_list" >&5 $as_echo_n "checking --with-sparse_list... " >&6; } # Check whether --with-sparse_list was given. if test "${with_sparse_list+set}" = set; then : withval=$with_sparse_list; sparse_list="yes" else sparse_list="no" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sparse_list" >&5 $as_echo "$sparse_list" >&6; } if test "$sparse_set" = "yes" ; then if test "$sparse_list" == "yes" ; then as_fn_error $? "cannot --with both sparse_set and sparse_list" "$LINENO" 5 fi cppad_internal_sparse_set=sparse_set else cppad_internal_sparse_set=sparse_list fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-deprecated" >&5 $as_echo_n "checking --with-deprecated... " >&6; } # Check whether --with-deprecated was given. if test "${with_deprecated+set}" = set; then : withval=$with_deprecated; deprecated="yes" else deprecated="no" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $deprecated" >&5 $as_echo "$deprecated" >&6; } if test "$deprecated" = 'yes' ; then CppAD_DEPRECATED_TRUE= CppAD_DEPRECATED_FALSE='#' else CppAD_DEPRECATED_TRUE='#' CppAD_DEPRECATED_FALSE= fi if test "$deprecated" = "yes" ; then cppad_deprecated="1" else cppad_deprecated="0" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking POSTFIX_DIR" >&5 $as_echo_n "checking POSTFIX_DIR... " >&6; } if test "$POSTFIX_DIR" != ""; then CppAD_POSTFIX_TRUE= CppAD_POSTFIX_FALSE='#' else CppAD_POSTFIX_TRUE='#' CppAD_POSTFIX_FALSE= fi if test "$POSTFIX_DIR" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $POSTFIX_DIR" >&5 $as_echo "$POSTFIX_DIR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking ADOLC_DIR" >&5 $as_echo_n "checking ADOLC_DIR... " >&6; } if test "$ADOLC_DIR" != ""; then CppAD_ADOLC_TRUE= CppAD_ADOLC_FALSE='#' else CppAD_ADOLC_TRUE='#' CppAD_ADOLC_FALSE= fi if test "$ADOLC_DIR" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ADOLC_DIR" >&5 $as_echo "$ADOLC_DIR" >&6; } if test "$have_ar" = "no"; then as_fn_error $? "ar is missing and ADOLC_DIR is present" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking EIGEN_DIR" >&5 $as_echo_n "checking EIGEN_DIR... " >&6; } if test "$EIGEN_DIR" != ""; then CppAD_EIGEN_DIR_TRUE= CppAD_EIGEN_DIR_FALSE='#' else CppAD_EIGEN_DIR_TRUE='#' CppAD_EIGEN_DIR_FALSE= fi if test "$EIGEN_DIR" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $EIGEN_DIR" >&5 $as_echo "$EIGEN_DIR" >&6; } EIGEN_INCLUDE=-I$EIGEN_DIR/include else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking FADBAD_DIR" >&5 $as_echo_n "checking FADBAD_DIR... " >&6; } if test "$FADBAD_DIR" != ""; then CppAD_FADBAD_TRUE= CppAD_FADBAD_FALSE='#' else CppAD_FADBAD_TRUE='#' CppAD_FADBAD_FALSE= fi if test "$FADBAD_DIR" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FADBAD_DIR" >&5 $as_echo "$FADBAD_DIR" >&6; } if test "$have_ar" = "no"; then as_fn_error $? "ar is missing and FADBAD_DIR is present" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking SACADO_DIR" >&5 $as_echo_n "checking SACADO_DIR... " >&6; } if test "$SACADO_DIR" != ""; then CppAD_SACADO_TRUE= CppAD_SACADO_FALSE='#' else CppAD_SACADO_TRUE='#' CppAD_SACADO_FALSE= fi if test "$SACADO_DIR" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SACADO_DIR" >&5 $as_echo "$SACADO_DIR" >&6; } if test "$have_ar" = "no"; then as_fn_error $? "ar is missing and SACADO_DIR is present" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking IPOPT_DIR" >&5 $as_echo_n "checking IPOPT_DIR... " >&6; } if test "$IPOPT_DIR" != ""; then CppAD_IPOPT_TRUE= CppAD_IPOPT_FALSE='#' else CppAD_IPOPT_TRUE='#' CppAD_IPOPT_FALSE= fi if test "$IPOPT_DIR" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $IPOPT_DIR" >&5 $as_echo "$IPOPT_DIR" >&6; } if test "$have_ar" = "no"; then as_fn_error $? "ar is missing and IPOPT_DIR is present" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking BOOST_DIR" >&5 $as_echo_n "checking BOOST_DIR... " >&6; } if test "$BOOST_DIR" != ""; then CppAD_BOOST_DIR_TRUE= CppAD_BOOST_DIR_FALSE='#' else CppAD_BOOST_DIR_TRUE='#' CppAD_BOOST_DIR_FALSE= fi if test "$BOOST_DIR" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOST_DIR" >&5 $as_echo "$BOOST_DIR" >&6; } BOOST_INCLUDE=-I$BOOST_DIR/include else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # { $as_echo "$as_me:${as_lineno-$LINENO}: checking CXX_FLAGS" >&5 $as_echo_n "checking CXX_FLAGS... " >&6; } # cxx_flags for fadbad and eigen if test "$CXX_FLAGS" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX_FLAGS" >&5 $as_echo "$CXX_FLAGS" >&6; } cxx_flags_fadbad=`echo "$CXX_FLAGS" | sed -e 's|-Wshadow||'` cxx_flags_eigen="$cxx_flags_fadbda -Wno-long-long" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } cxx_flags_fadbad="" cxx_flags_eigen="" fi CXX_FLAGS_FADBAD="$cxx_flags_fadbad" CXX_FLAGS_EIGEN="$cxx_flags_eigen" { $as_echo "$as_me:${as_lineno-$LINENO}: checking OPENMP_FLAGS" >&5 $as_echo_n "checking OPENMP_FLAGS... " >&6; } if test "$OPENMP_FLAGS" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENMP_FLAGS" >&5 $as_echo "$OPENMP_FLAGS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "$OPENMP_FLAGS" != ""; then CppAD_OPENMP_TRUE= CppAD_OPENMP_FALSE='#' else CppAD_OPENMP_TRUE='#' CppAD_OPENMP_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking MAX_NUM_THREADS" >&5 $as_echo_n "checking MAX_NUM_THREADS... " >&6; } if test "$MAX_NUM_THREADS" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAX_NUM_THREADS" >&5 $as_echo "$MAX_NUM_THREADS" >&6; } if test "$MAX_NUM_THREADS" -lt "4" ; then as_fn_error $? " MAX_NUM_THREADS=$MAX_NUM_THREADS is less than 4 " "$LINENO" 5 fi max_num_threads="$MAX_NUM_THREADS" else max_num_threads="48" { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using default value $max_num_threads" >&5 $as_echo "no, using default value $max_num_threads" >&6; } fi cppad_max_num_threads=$max_num_threads { $as_echo "$as_me:${as_lineno-$LINENO}: checking TAPE_ADDR_TYPE" >&5 $as_echo_n "checking TAPE_ADDR_TYPE... " >&6; } if test "$TAPE_ADDR_TYPE" == "" ; then addr_t="unsigned int" else addr_t="$TAPE_ADDR_TYPE" fi cppad_tape_addr_type=$addr_t { $as_echo "$as_me:${as_lineno-$LINENO}: result: $addr_t" >&5 $as_echo "$addr_t" >&6; } ok="no" if test "$addr_t" == "size_t" ; then ok="yes" fi if test "$addr_t" == "int" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: TAPE_ADDR_TYPE=int is for CppAD developers (not users) " >&5 $as_echo "$as_me: WARNING: TAPE_ADDR_TYPE=int is for CppAD developers (not users) " >&2;} ok="yes" fi if test "$addr_t" == "unsigned int" ; then ok="yes" fi if test "$addr_t" == "unsigned short int" ; then ok="yes" fi if test "$ok" == "no" ; then as_fn_error $? "$addr_t is not a valid choice for TAPE_ADDR_TYPE " "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking TAPE_ID_TYPE" >&5 $as_echo_n "checking TAPE_ID_TYPE... " >&6; } if test "$TAPE_ID_TYPE" == "" ; then tape_id_t="unsigned int" else tape_id_t="$TAPE_ID_TYPE" fi cppad_tape_id_type=$tape_id_t { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tape_id_t" >&5 $as_echo "$tape_id_t" >&6; } ok="no" if test "$tape_id_t" == "size_t" ; then ok="yes" fi if test "$tape_id_t" == "int" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: TAPE_ID_TYPE=int is for CppAD developers (not users) " >&5 $as_echo "$as_me: WARNING: TAPE_ID_TYPE=int is for CppAD developers (not users) " >&2;} ok="yes" fi if test "$tape_id_t" == "unsigned int" ; then ok="yes" fi if test "$tape_id_t" == "unsigned short int" ; then ok="yes" fi if test "$ok" == "no" ; then as_fn_error $? "$tape_id_t is not a valid choice for TAPE_ID_TYPE " "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: ********** End Checking Command Line arguments ***************" >&5 $as_echo "$as_me: ********** End Checking Command Line arguments ***************" >&6;} if test "$enable_msvc" == "no" then cxx_list="g++ clang++ CC pgCC icpc gpp cxx cc++" cc_list="gcc clang cc pgcc icc" fc_list="gfortran ifort g95 fort77 f77 g77 pgf90 pgf77 ifc frt af77" else cxx_list="icl cl g++" cc_list="icl cl gcc" fc_list="ifort gfortran" fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in $cxx_list do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in $cxx_list do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi CXXFLAGS="" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then for ac_prog in $cc_list do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in $cc_list do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi CFLAGS="" ac_ext=${ac_fc_srcext-f} ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5' ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_fc_compiler_gnu if test -n "$ac_tool_prefix"; then for ac_prog in $fc_list do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_FC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$FC"; then ac_cv_prog_FC="$FC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_FC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi FC=$ac_cv_prog_FC if test -n "$FC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FC" >&5 $as_echo "$FC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$FC" && break done fi if test -z "$FC"; then ac_ct_FC=$FC for ac_prog in $fc_list do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_FC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_FC"; then ac_cv_prog_ac_ct_FC="$ac_ct_FC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_FC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_FC=$ac_cv_prog_ac_ct_FC if test -n "$ac_ct_FC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FC" >&5 $as_echo "$ac_ct_FC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_FC" && break done if test "x$ac_ct_FC" = x; then FC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac FC=$ac_ct_FC fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done rm -f a.out # If we don't use `.F' as extension, the preprocessor is not run on the # input file. (Note that this only needs to work for GNU compilers.) ac_save_ext=$ac_ext ac_ext=F { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Fortran compiler" >&5 $as_echo_n "checking whether we are using the GNU Fortran compiler... " >&6; } if ${ac_cv_fc_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat > conftest.$ac_ext <<_ACEOF program main #ifndef __GNUC__ choke me #endif end _ACEOF if ac_fn_fc_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_fc_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_compiler_gnu" >&5 $as_echo "$ac_cv_fc_compiler_gnu" >&6; } ac_ext=$ac_save_ext ac_test_FCFLAGS=${FCFLAGS+set} ac_save_FCFLAGS=$FCFLAGS FCFLAGS= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $FC accepts -g" >&5 $as_echo_n "checking whether $FC accepts -g... " >&6; } if ${ac_cv_prog_fc_g+:} false; then : $as_echo_n "(cached) " >&6 else FCFLAGS=-g cat > conftest.$ac_ext <<_ACEOF program main end _ACEOF if ac_fn_fc_try_compile "$LINENO"; then : ac_cv_prog_fc_g=yes else ac_cv_prog_fc_g=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_fc_g" >&5 $as_echo "$ac_cv_prog_fc_g" >&6; } if test "$ac_test_FCFLAGS" = set; then FCFLAGS=$ac_save_FCFLAGS elif test $ac_cv_prog_fc_g = yes; then if test "x$ac_cv_fc_compiler_gnu" = xyes; then FCFLAGS="-g -O2" else FCFLAGS="-g" fi else if test "x$ac_cv_fc_compiler_gnu" = xyes; then FCFLAGS="-O2" else FCFLAGS= fi fi if test $ac_compiler_gnu = yes; then GFC=yes else GFC= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_have_pkg_config+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$have_pkg_config"; then ac_cv_prog_have_pkg_config="$have_pkg_config" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_have_pkg_config="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_have_pkg_config" && ac_cv_prog_have_pkg_config="no" fi fi have_pkg_config=$ac_cv_prog_have_pkg_config if test -n "$have_pkg_config"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_pkg_config" >&5 $as_echo "$have_pkg_config" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "$have_pkg_config" = "yes"; then CppAD_PKG_CONFIG_TRUE= CppAD_PKG_CONFIG_FALSE='#' else CppAD_PKG_CONFIG_TRUE='#' CppAD_PKG_CONFIG_FALSE= fi if test "$have_ar" = 'yes' ; then CppAD_HAVE_AR_TRUE= CppAD_HAVE_AR_FALSE='#' else CppAD_HAVE_AR_TRUE='#' CppAD_HAVE_AR_FALSE= fi if test "$have_ar" = 'no'; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot build any libraries because ar is missing; e.g,, speed/* not built " >&5 $as_echo "$as_me: WARNING: cannot build any libraries because ar is missing; e.g,, speed/* not built " >&2;} fi cppad_cxx_flags="-g -O0" cppad_has_colpack=0 cppad_has_mkstemp=1 cppad_has_nullptr=0 cppad_has_rvalue=0 cppad_has_cstdint_8_to_64=0 cppad_use_cplusplus_2011=0 cppad_has_high_resolution_clock=0 ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5 $as_echo_n "checking size of size_t... " >&6; } if ${ac_cv_sizeof_size_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default"; then : else if test "$ac_cv_type_size_t" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (size_t) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_size_t=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_size_t" >&5 $as_echo "$ac_cv_sizeof_size_t" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_SIZE_T $ac_cv_sizeof_size_t _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned int" >&5 $as_echo_n "checking size of unsigned int... " >&6; } if ${ac_cv_sizeof_unsigned_int+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned int))" "ac_cv_sizeof_unsigned_int" "$ac_includes_default"; then : else if test "$ac_cv_type_unsigned_int" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (unsigned int) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_unsigned_int=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_int" >&5 $as_echo "$ac_cv_sizeof_unsigned_int" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_UNSIGNED_INT $ac_cv_sizeof_unsigned_int _ACEOF if test "$ac_cv_sizeof_size_t" != "$ac_cv_sizeof_unsigned_int" ; then cppad_size_t_not_unsigned_int=1 else cppad_size_t_not_unsigned_int=0 fi if test "$stdvector$boostvector$eigenvector" = "nonono" ; then cppad_cppadvector=1 else cppad_cppadvector=0 fi ac_fn_c_check_func "$LINENO" "gettimeofday" "ac_cv_func_gettimeofday" if test "x$ac_cv_func_gettimeofday" = xyes; then : gettimeofday="yes" else gettimeofday="no" fi if test "$gettimeofday" = "yes" ; then cppad_has_gettimeofday=1 else cppad_has_gettimeofday=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether using Microsoft C++ compiler" >&5 $as_echo_n "checking whether using Microsoft C++ compiler... " >&6; } if test "$CXX" == "cl" || test "$CXX" == "icl"; then CppAD_MS_COMPILER_TRUE= CppAD_MS_COMPILER_FALSE='#' else CppAD_MS_COMPILER_TRUE='#' CppAD_MS_COMPILER_FALSE= fi if test "$CXX" == "cl" || test "$CXX" == "icl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac ac_ext=${ac_fc_srcext-f} ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5' ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_fc_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to get verbose linking output from $FC" >&5 $as_echo_n "checking how to get verbose linking output from $FC... " >&6; } if ${ac_cv_prog_fc_v+:} false; then : $as_echo_n "(cached) " >&6 else cat > conftest.$ac_ext <<_ACEOF program main end _ACEOF if ac_fn_fc_try_compile "$LINENO"; then : ac_cv_prog_fc_v= # Try some options frequently used verbose output for ac_verb in -v -verbose --verbose -V -\#\#\#; do cat > conftest.$ac_ext <<_ACEOF program main end _ACEOF # Compile and link our simple test program by passing a flag (argument # 1 to this macro) to the Fortran compiler in order to get # "verbose" output that we can then parse for the Fortran linker # flags. ac_save_FCFLAGS=$FCFLAGS FCFLAGS="$FCFLAGS $ac_verb" eval "set x $ac_link" shift $as_echo "$as_me:${as_lineno-$LINENO}: $*" >&5 # gfortran 4.3 outputs lines setting COLLECT_GCC_OPTIONS, COMPILER_PATH, # LIBRARY_PATH; skip all such settings. ac_fc_v_output=`eval $ac_link 5>&1 2>&1 | sed '/^Driving:/d; /^Configured with:/d; '"/^[_$as_cr_Letters][_$as_cr_alnum]*=/d"` $as_echo "$ac_fc_v_output" >&5 FCFLAGS=$ac_save_FCFLAGS rm -rf conftest* # On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where # /foo, /bar, and /baz are search directories for the Fortran linker. # Here, we change these into -L/foo -L/bar -L/baz (and put it first): ac_fc_v_output="`echo $ac_fc_v_output | grep 'LPATH is:' | sed 's|.*LPATH is\(: *[^ ]*\).*|\1|;s|: */| -L/|g'` $ac_fc_v_output" # FIXME: we keep getting bitten by quoted arguments; a more general fix # that detects unbalanced quotes in FLIBS should be implemented # and (ugh) tested at some point. case $ac_fc_v_output in # With xlf replace commas with spaces, # and remove "-link" and closing parenthesis. *xlfentry*) ac_fc_v_output=`echo $ac_fc_v_output | sed ' s/,/ /g s/ -link / /g s/) *$// ' ` ;; # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted # $LIBS confuse us, and the libraries appear later in the output anyway). *mGLOB_options_string*) ac_fc_v_output=`echo $ac_fc_v_output | sed 's/"-mGLOB[^"]*"/ /g'` ;; # Portland Group compiler has singly- or doubly-quoted -cmdline argument # Singly-quoted arguments were reported for versions 5.2-4 and 6.0-4. # Doubly-quoted arguments were reported for "PGF90/x86 Linux/x86 5.0-2". *-cmdline\ * | *-ignore\ * | *-def\ *) ac_fc_v_output=`echo $ac_fc_v_output | sed "\ s/-cmdline *'[^']*'/ /g; s/-cmdline *\"[^\"]*\"/ /g s/-ignore *'[^']*'/ /g; s/-ignore *\"[^\"]*\"/ /g s/-def *'[^']*'/ /g; s/-def *\"[^\"]*\"/ /g"` ;; # If we are using fort77 (the f2c wrapper) then filter output and delete quotes. *fort77*f2c*gcc*) ac_fc_v_output=`echo "$ac_fc_v_output" | sed -n ' /:[ ]\+Running[ ]\{1,\}"gcc"/{ /"-c"/d /[.]c"*/d s/^.*"gcc"/"gcc"/ s/"//gp }'` ;; # If we are using Cray Fortran then delete quotes. *cft90*) ac_fc_v_output=`echo $ac_fc_v_output | sed 's/"//g'` ;; esac # look for -l* and *.a constructs in the output for ac_arg in $ac_fc_v_output; do case $ac_arg in [\\/]*.a | ?:[\\/]*.a | -[lLRu]*) ac_cv_prog_fc_v=$ac_verb break 2 ;; esac done done if test -z "$ac_cv_prog_fc_v"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot determine how to obtain linking information from $FC" >&5 $as_echo "$as_me: WARNING: cannot determine how to obtain linking information from $FC" >&2;} fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: compilation failed" >&5 $as_echo "$as_me: WARNING: compilation failed" >&2;} fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_fc_v" >&5 $as_echo "$ac_cv_prog_fc_v" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran libraries of $FC" >&5 $as_echo_n "checking for Fortran libraries of $FC... " >&6; } if ${ac_cv_fc_libs+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$FCLIBS" != "x"; then ac_cv_fc_libs="$FCLIBS" # Let the user override the test. else cat > conftest.$ac_ext <<_ACEOF program main end _ACEOF # Compile and link our simple test program by passing a flag (argument # 1 to this macro) to the Fortran compiler in order to get # "verbose" output that we can then parse for the Fortran linker # flags. ac_save_FCFLAGS=$FCFLAGS FCFLAGS="$FCFLAGS $ac_cv_prog_fc_v" eval "set x $ac_link" shift $as_echo "$as_me:${as_lineno-$LINENO}: $*" >&5 # gfortran 4.3 outputs lines setting COLLECT_GCC_OPTIONS, COMPILER_PATH, # LIBRARY_PATH; skip all such settings. ac_fc_v_output=`eval $ac_link 5>&1 2>&1 | sed '/^Driving:/d; /^Configured with:/d; '"/^[_$as_cr_Letters][_$as_cr_alnum]*=/d"` $as_echo "$ac_fc_v_output" >&5 FCFLAGS=$ac_save_FCFLAGS rm -rf conftest* # On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where # /foo, /bar, and /baz are search directories for the Fortran linker. # Here, we change these into -L/foo -L/bar -L/baz (and put it first): ac_fc_v_output="`echo $ac_fc_v_output | grep 'LPATH is:' | sed 's|.*LPATH is\(: *[^ ]*\).*|\1|;s|: */| -L/|g'` $ac_fc_v_output" # FIXME: we keep getting bitten by quoted arguments; a more general fix # that detects unbalanced quotes in FLIBS should be implemented # and (ugh) tested at some point. case $ac_fc_v_output in # With xlf replace commas with spaces, # and remove "-link" and closing parenthesis. *xlfentry*) ac_fc_v_output=`echo $ac_fc_v_output | sed ' s/,/ /g s/ -link / /g s/) *$// ' ` ;; # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted # $LIBS confuse us, and the libraries appear later in the output anyway). *mGLOB_options_string*) ac_fc_v_output=`echo $ac_fc_v_output | sed 's/"-mGLOB[^"]*"/ /g'` ;; # Portland Group compiler has singly- or doubly-quoted -cmdline argument # Singly-quoted arguments were reported for versions 5.2-4 and 6.0-4. # Doubly-quoted arguments were reported for "PGF90/x86 Linux/x86 5.0-2". *-cmdline\ * | *-ignore\ * | *-def\ *) ac_fc_v_output=`echo $ac_fc_v_output | sed "\ s/-cmdline *'[^']*'/ /g; s/-cmdline *\"[^\"]*\"/ /g s/-ignore *'[^']*'/ /g; s/-ignore *\"[^\"]*\"/ /g s/-def *'[^']*'/ /g; s/-def *\"[^\"]*\"/ /g"` ;; # If we are using fort77 (the f2c wrapper) then filter output and delete quotes. *fort77*f2c*gcc*) ac_fc_v_output=`echo "$ac_fc_v_output" | sed -n ' /:[ ]\+Running[ ]\{1,\}"gcc"/{ /"-c"/d /[.]c"*/d s/^.*"gcc"/"gcc"/ s/"//gp }'` ;; # If we are using Cray Fortran then delete quotes. *cft90*) ac_fc_v_output=`echo $ac_fc_v_output | sed 's/"//g'` ;; esac ac_cv_fc_libs= # Save positional arguments (if any) ac_save_positional="$@" set X $ac_fc_v_output while test $# != 1; do shift ac_arg=$1 case $ac_arg in [\\/]*.a | ?:[\\/]*.a) ac_exists=false for ac_i in $ac_cv_fc_libs; do if test x"$ac_arg" = x"$ac_i"; then ac_exists=true break fi done if test x"$ac_exists" = xtrue; then : else ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg" fi ;; -bI:*) ac_exists=false for ac_i in $ac_cv_fc_libs; do if test x"$ac_arg" = x"$ac_i"; then ac_exists=true break fi done if test x"$ac_exists" = xtrue; then : else if test "$ac_compiler_gnu" = yes; then for ac_link_opt in $ac_arg; do ac_cv_fc_libs="$ac_cv_fc_libs -Xlinker $ac_link_opt" done else ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg" fi fi ;; # Ignore these flags. -lang* | -lcrt*.o | -lc | -lgcc* | -lSystem | -libmil | -little \ |-LANG:=* | -LIST:* | -LNO:* | -link) ;; -lkernel32) case $host_os in *cygwin*) ;; *) ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg" ;; esac ;; -[LRuYz]) # These flags, when seen by themselves, take an argument. # We remove the space between option and argument and re-iterate # unless we find an empty arg or a new option (starting with -) case $2 in "" | -*);; *) ac_arg="$ac_arg$2" shift; shift set X $ac_arg "$@" ;; esac ;; -YP,*) for ac_j in `$as_echo "$ac_arg" | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do ac_exists=false for ac_i in $ac_cv_fc_libs; do if test x"$ac_j" = x"$ac_i"; then ac_exists=true break fi done if test x"$ac_exists" = xtrue; then : else ac_arg="$ac_arg $ac_j" ac_cv_fc_libs="$ac_cv_fc_libs $ac_j" fi done ;; -[lLR]*) ac_exists=false for ac_i in $ac_cv_fc_libs; do if test x"$ac_arg" = x"$ac_i"; then ac_exists=true break fi done if test x"$ac_exists" = xtrue; then : else ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg" fi ;; -zallextract*| -zdefaultextract) ac_cv_fc_libs="$ac_cv_fc_libs $ac_arg" ;; # Ignore everything else. esac done # restore positional arguments set X $ac_save_positional; shift # We only consider "LD_RUN_PATH" on Solaris systems. If this is seen, # then we insist that the "run path" must be an absolute path (i.e. it # must begin with a "/"). case `(uname -sr) 2>/dev/null` in "SunOS 5"*) ac_ld_run_path=`$as_echo "$ac_fc_v_output" | sed -n 's,^.*LD_RUN_PATH *= *\(/[^ ]*\).*$,-R\1,p'` test "x$ac_ld_run_path" != x && if test "$ac_compiler_gnu" = yes; then for ac_link_opt in $ac_ld_run_path; do ac_cv_fc_libs="$ac_cv_fc_libs -Xlinker $ac_link_opt" done else ac_cv_fc_libs="$ac_cv_fc_libs $ac_ld_run_path" fi ;; esac fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_libs" >&5 $as_echo "$ac_cv_fc_libs" >&6; } FCLIBS="$ac_cv_fc_libs" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu abs_top_builddir=`pwd` ABS_TOP_BUILDDIR="$abs_top_builddir" abs_top_srcdir=`cd $srcdir ; pwd` ABS_TOP_SRCDIR="$abs_top_srcdir" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_barrier_wait in -lpthread" >&5 $as_echo_n "checking for pthread_barrier_wait in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_barrier_wait+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_barrier_wait (); int main () { return pthread_barrier_wait (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_barrier_wait=yes else ac_cv_lib_pthread_pthread_barrier_wait=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_barrier_wait" >&5 $as_echo "$ac_cv_lib_pthread_pthread_barrier_wait" >&6; } if test "x$ac_cv_lib_pthread_pthread_barrier_wait" = xyes; then : pthread="yes" else pthread="no" fi if test "$pthread" = "yes"; then CppAD_PTHREAD_TRUE= CppAD_PTHREAD_FALSE='#' else CppAD_PTHREAD_TRUE='#' CppAD_PTHREAD_FALSE= fi if test "$pthread" == "yes" ; then PTHREAD_LIB="-lpthread" else PTHREAD_LIB="" fi DL_LIB="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : DL_LIB="-ldl" else DL_LIB="" fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu LDFLAGS_save=$LDFLAGS CXXFLAGS_save=$CXXFLAGS boost_thread_found='no' if test "$BOOST_DIR" != '' ; then CXXFLAGS="-I$BOOST_DIR/include $CXXFLAGS" fi if test "$BOOST_DIR" == '' && test "$boost_thread_found" == 'no' ; then bthread_lib='-lboost_thread-mt' LDFLAGS="$LDFLAGS_save $bthread_lib" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { boost::barrier wait(1); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : boost_thread_found='yes' else boost_thread_found='no' fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then bthread_lib="$BOOST_DIR/lib/libboost_thread-mt.so" LDFLAGS="$LDFLAGS_save $bthread_lib" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { boost::barrier wait(1); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : boost_thread_found='yes' else boost_thread_found='no' fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then bthread_lib="$BOOST_DIR/lib/libboost_thread-mt.a" LDFLAGS="$LDFLAGS_save $bthread_lib" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { boost::barrier wait(1); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : boost_thread_found='yes' else boost_thread_found='no' fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "$BOOST_DIR" == '' && test "$boost_thread_found" == 'no' ; then bthread_lib='-lboost_thread' LDFLAGS="$LDFLAGS_save $bthread_lib" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { boost::barrier wait(1); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : boost_thread_found='yes' else boost_thread_found='no' fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then bthread_lib="$BOOST_DIR/lib/libboost_thread.so" LDFLAGS="$LDFLAGS_save $bthread_lib" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { boost::barrier wait(1); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : boost_thread_found='yes' else boost_thread_found='no' fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "$BOOST_DIR" != '' && test "$boost_thread_found" == 'no' ; then bthread_lib="$BOOST_DIR/lib/libboost_thread.a" LDFLAGS="$LDFLAGS_save $bthread_lib" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { boost::barrier wait(1); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : boost_thread_found='yes' else boost_thread_found='no' fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test "$boost_thread_found" = 'yes'; then CppAD_BTHREAD_TRUE= CppAD_BTHREAD_FALSE='#' else CppAD_BTHREAD_TRUE='#' CppAD_BTHREAD_FALSE= fi if test "$boost_thread_found" == 'yes' ; then BTHREAD_LIB="$bthread_lib" { $as_echo "$as_me:${as_lineno-$LINENO}: result: boost::thread library... yes" >&5 $as_echo "boost::thread library... yes" >&6; } else BTHREAD_LIB='' { $as_echo "$as_me:${as_lineno-$LINENO}: result: boost::thread library... no" >&5 $as_echo "boost::thread library... no" >&6; } fi LDFLAGS=$LDFLAGS_save CXXFLAGS=$CXXFLAGS_save ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # if test -e $IPOPT_DIR/lib/coin ; then IPOPT_LIBS="-L $IPOPT_DIR/lib/coin -L $IPOPT_DIR/lib/coin/ThirdParty" IPOPT_LD_PATH="$IPOPT_DIR/lib/coin:$IPOPT_DIR/lib/coin/ThirdParty" else IPOPT_LIBS="-L $IPOPT_DIR/lib" IPOPT_LD_PATH="$IPOPT_DIR/lib" fi CPPAD_IPOPT_LD_PATH="$IPOPT_LD_PATH" # CPPAD_IPOPT_LIBS="$IPOPT_LIBS -lipopt" if test "$have_pkg_config" == "yes"; then PKG_CONFIG_PATH="$IPOPT_DIR/lib/pkgconfig:$IPOPT_DIR/share/pkgconfig" PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$IPOPT_DIR/lib64/pkgconfig" export PKG_CONFIG_PATH if pkg-config --libs ipopt >& /dev/null ; then CPPAD_IPOPT_LIBS=`pkg-config --libs ipopt` else ac_ext=${ac_fc_srcext-f} ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5' ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_fc_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ddot in -lblas" >&5 $as_echo_n "checking for ddot in -lblas... " >&6; } if ${ac_cv_lib_blas_ddot+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lblas $LIBS" cat > conftest.$ac_ext <<_ACEOF program main call ddot end _ACEOF if ac_fn_fc_try_link "$LINENO"; then : ac_cv_lib_blas_ddot=yes else ac_cv_lib_blas_ddot=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_blas_ddot" >&5 $as_echo "$ac_cv_lib_blas_ddot" >&6; } if test "x$ac_cv_lib_blas_ddot" = xyes; then : CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -lblas" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dgesv in -llapack" >&5 $as_echo_n "checking for dgesv in -llapack... " >&6; } if ${ac_cv_lib_lapack_dgesv+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-llapack $LIBS" cat > conftest.$ac_ext <<_ACEOF program main call dgesv end _ACEOF if ac_fn_fc_try_link "$LINENO"; then : ac_cv_lib_lapack_dgesv=yes else ac_cv_lib_lapack_dgesv=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lapack_dgesv" >&5 $as_echo "$ac_cv_lib_lapack_dgesv" >&6; } if test "x$ac_cv_lib_lapack_dgesv" = xyes; then : CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -llapack" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi else ac_ext=${ac_fc_srcext-f} ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5' ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_fc_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ddot in -lblas" >&5 $as_echo_n "checking for ddot in -lblas... " >&6; } if ${ac_cv_lib_blas_ddot+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lblas $LIBS" cat > conftest.$ac_ext <<_ACEOF program main call ddot end _ACEOF if ac_fn_fc_try_link "$LINENO"; then : ac_cv_lib_blas_ddot=yes else ac_cv_lib_blas_ddot=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_blas_ddot" >&5 $as_echo "$ac_cv_lib_blas_ddot" >&6; } if test "x$ac_cv_lib_blas_ddot" = xyes; then : CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -lblas" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dgesv in -llapack" >&5 $as_echo_n "checking for dgesv in -llapack... " >&6; } if ${ac_cv_lib_lapack_dgesv+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-llapack $LIBS" cat > conftest.$ac_ext <<_ACEOF program main call dgesv end _ACEOF if ac_fn_fc_try_link "$LINENO"; then : ac_cv_lib_lapack_dgesv=yes else ac_cv_lib_lapack_dgesv=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lapack_dgesv" >&5 $as_echo "$ac_cv_lib_lapack_dgesv" >&6; } if test "x$ac_cv_lib_lapack_dgesv" = xyes; then : CPPAD_IPOPT_LIBS="$CPPAD_IPOPT_LIBS -llapack" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: cppad_ipopt_nlp libraries: $CPPAD_IPOPT_LIBS" >&5 $as_echo "cppad_ipopt_nlp libraries: $CPPAD_IPOPT_LIBS" >&6; } cppad_description="Differentiation of C++ Algorithms" cppad_version=${PACKAGE_VERSION} cppad_url="http://www.coin-or.org/CppAD" if test "$prefix" == "NONE" ; then cppad_pkgconfig_cflags_value="-I$HOME/include" cppad_pkgconfig_libs_value="-L$HOME/lib" else cppad_pkgconfig_cflags_value="-I$prefix/include" cppad_pkgconfig_libs_value="-L$prefix/lib" fi if test "$POSTFIX_DIR" != "" ; then cppad_pkgconfig_cflags_value="$cppad_cflags_value/$POSTFIX_DIR" cppad_pkgconfig_libs_value="$cppad_pkgconfig_libs_value/$POSTFIX_DIR" fi if test "$IPOPT_DIR" == "" ; then cppad_pkgconfig_libs_value="" cppad_pkgconfig_requires_value="" else cppad_pkgconfig_libs_value="$cppad_pkgconfig_libs_value -lcppad_ipopt" cppad_pkgconfig_requires_value="ipopt" fi cppad_pkgconfig_cflags="$cppad_pkgconfig_cflags_value" cppad_pkgconfig_libs="$cppad_pkgconfig_libs_value" cppad_pkgconfig_requires="$cppad_pkgconfig_requires_value" cppad_SOURCE_DIR=${ABS_TOP_SRCDIR} adolc_prefix=${ADOLC_DIR} eigen_prefix=${EIGEN_DIR} ipopt_prefix=${IPOPT_DIR} ac_config_files="$ac_config_files cppad/configure.hpp cppad_ipopt/example/test.sh cppad_ipopt/speed/test.sh cppad_ipopt/test/test.sh example/ipopt_solve/test.sh example/test_one.sh pkgconfig/cppad.pc pkgconfig/cppad-uninstalled.pc test_more/test_one.sh makefile compare_c/makefile cppad_ipopt/src/makefile cppad_ipopt/example/makefile cppad_ipopt/speed/makefile cppad_ipopt/test/makefile example/makefile example/atomic/makefile example/ipopt_solve/makefile introduction/get_started/makefile introduction/exp_apx/makefile multi_thread/makefile multi_thread/test_multi/makefile print_for/makefile speed/adolc/makefile speed/cppad/makefile speed/double/makefile speed/example/makefile speed/fadbad/makefile speed/profile/makefile speed/profile/gprof.sed speed/sacado/makefile speed/src/makefile test_more/makefile" ac_config_commands="$ac_config_commands example_ipopt_solve_test.sh" ac_config_commands="$ac_config_commands cppad_ipopt_example_test.sh" ac_config_commands="$ac_config_commands cppad_ipopt_speed_test.sh" ac_config_commands="$ac_config_commands cppad_ipopt_test_test.sh" ac_config_commands="$ac_config_commands example_test_one.sh" ac_config_commands="$ac_config_commands test_more_test_one.sh" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that # take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. ac_script=' :mline /\\$/{ N s,\\\n,, b mline } t clear :clear s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g t quote s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g t quote b any :quote s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g s/\[/\\&/g s/\]/\\&/g s/\$/$$/g H :any ${ g s/^\n// s/\n/ /g p } ' DEFS=`sed -n "$ac_script" confdefs.h` ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_DOCUMENTATION_TRUE}" && test -z "${CppAD_DOCUMENTATION_FALSE}"; then as_fn_error $? "conditional \"CppAD_DOCUMENTATION\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_DEPRECATED_TRUE}" && test -z "${CppAD_DEPRECATED_FALSE}"; then as_fn_error $? "conditional \"CppAD_DEPRECATED\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_POSTFIX_TRUE}" && test -z "${CppAD_POSTFIX_FALSE}"; then as_fn_error $? "conditional \"CppAD_POSTFIX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_ADOLC_TRUE}" && test -z "${CppAD_ADOLC_FALSE}"; then as_fn_error $? "conditional \"CppAD_ADOLC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_EIGEN_DIR_TRUE}" && test -z "${CppAD_EIGEN_DIR_FALSE}"; then as_fn_error $? "conditional \"CppAD_EIGEN_DIR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_FADBAD_TRUE}" && test -z "${CppAD_FADBAD_FALSE}"; then as_fn_error $? "conditional \"CppAD_FADBAD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_SACADO_TRUE}" && test -z "${CppAD_SACADO_FALSE}"; then as_fn_error $? "conditional \"CppAD_SACADO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_IPOPT_TRUE}" && test -z "${CppAD_IPOPT_FALSE}"; then as_fn_error $? "conditional \"CppAD_IPOPT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_BOOST_DIR_TRUE}" && test -z "${CppAD_BOOST_DIR_FALSE}"; then as_fn_error $? "conditional \"CppAD_BOOST_DIR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_OPENMP_TRUE}" && test -z "${CppAD_OPENMP_FALSE}"; then as_fn_error $? "conditional \"CppAD_OPENMP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_PKG_CONFIG_TRUE}" && test -z "${CppAD_PKG_CONFIG_FALSE}"; then as_fn_error $? "conditional \"CppAD_PKG_CONFIG\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_HAVE_AR_TRUE}" && test -z "${CppAD_HAVE_AR_FALSE}"; then as_fn_error $? "conditional \"CppAD_HAVE_AR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_MS_COMPILER_TRUE}" && test -z "${CppAD_MS_COMPILER_FALSE}"; then as_fn_error $? "conditional \"CppAD_MS_COMPILER\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_PTHREAD_TRUE}" && test -z "${CppAD_PTHREAD_FALSE}"; then as_fn_error $? "conditional \"CppAD_PTHREAD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CppAD_BTHREAD_TRUE}" && test -z "${CppAD_BTHREAD_FALSE}"; then as_fn_error $? "conditional \"CppAD_BTHREAD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by cppad $as_me 20160000.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE Configuration files: $config_files Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ cppad config.status 20160000.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --he | --h | --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "cppad/configure.hpp") CONFIG_FILES="$CONFIG_FILES cppad/configure.hpp" ;; "cppad_ipopt/example/test.sh") CONFIG_FILES="$CONFIG_FILES cppad_ipopt/example/test.sh" ;; "cppad_ipopt/speed/test.sh") CONFIG_FILES="$CONFIG_FILES cppad_ipopt/speed/test.sh" ;; "cppad_ipopt/test/test.sh") CONFIG_FILES="$CONFIG_FILES cppad_ipopt/test/test.sh" ;; "example/ipopt_solve/test.sh") CONFIG_FILES="$CONFIG_FILES example/ipopt_solve/test.sh" ;; "example/test_one.sh") CONFIG_FILES="$CONFIG_FILES example/test_one.sh" ;; "pkgconfig/cppad.pc") CONFIG_FILES="$CONFIG_FILES pkgconfig/cppad.pc" ;; "pkgconfig/cppad-uninstalled.pc") CONFIG_FILES="$CONFIG_FILES pkgconfig/cppad-uninstalled.pc" ;; "test_more/test_one.sh") CONFIG_FILES="$CONFIG_FILES test_more/test_one.sh" ;; "makefile") CONFIG_FILES="$CONFIG_FILES makefile" ;; "compare_c/makefile") CONFIG_FILES="$CONFIG_FILES compare_c/makefile" ;; "cppad_ipopt/src/makefile") CONFIG_FILES="$CONFIG_FILES cppad_ipopt/src/makefile" ;; "cppad_ipopt/example/makefile") CONFIG_FILES="$CONFIG_FILES cppad_ipopt/example/makefile" ;; "cppad_ipopt/speed/makefile") CONFIG_FILES="$CONFIG_FILES cppad_ipopt/speed/makefile" ;; "cppad_ipopt/test/makefile") CONFIG_FILES="$CONFIG_FILES cppad_ipopt/test/makefile" ;; "example/makefile") CONFIG_FILES="$CONFIG_FILES example/makefile" ;; "example/atomic/makefile") CONFIG_FILES="$CONFIG_FILES example/atomic/makefile" ;; "example/ipopt_solve/makefile") CONFIG_FILES="$CONFIG_FILES example/ipopt_solve/makefile" ;; "introduction/get_started/makefile") CONFIG_FILES="$CONFIG_FILES introduction/get_started/makefile" ;; "introduction/exp_apx/makefile") CONFIG_FILES="$CONFIG_FILES introduction/exp_apx/makefile" ;; "multi_thread/makefile") CONFIG_FILES="$CONFIG_FILES multi_thread/makefile" ;; "multi_thread/test_multi/makefile") CONFIG_FILES="$CONFIG_FILES multi_thread/test_multi/makefile" ;; "print_for/makefile") CONFIG_FILES="$CONFIG_FILES print_for/makefile" ;; "speed/adolc/makefile") CONFIG_FILES="$CONFIG_FILES speed/adolc/makefile" ;; "speed/cppad/makefile") CONFIG_FILES="$CONFIG_FILES speed/cppad/makefile" ;; "speed/double/makefile") CONFIG_FILES="$CONFIG_FILES speed/double/makefile" ;; "speed/example/makefile") CONFIG_FILES="$CONFIG_FILES speed/example/makefile" ;; "speed/fadbad/makefile") CONFIG_FILES="$CONFIG_FILES speed/fadbad/makefile" ;; "speed/profile/makefile") CONFIG_FILES="$CONFIG_FILES speed/profile/makefile" ;; "speed/profile/gprof.sed") CONFIG_FILES="$CONFIG_FILES speed/profile/gprof.sed" ;; "speed/sacado/makefile") CONFIG_FILES="$CONFIG_FILES speed/sacado/makefile" ;; "speed/src/makefile") CONFIG_FILES="$CONFIG_FILES speed/src/makefile" ;; "test_more/makefile") CONFIG_FILES="$CONFIG_FILES test_more/makefile" ;; "example_ipopt_solve_test.sh") CONFIG_COMMANDS="$CONFIG_COMMANDS example_ipopt_solve_test.sh" ;; "cppad_ipopt_example_test.sh") CONFIG_COMMANDS="$CONFIG_COMMANDS cppad_ipopt_example_test.sh" ;; "cppad_ipopt_speed_test.sh") CONFIG_COMMANDS="$CONFIG_COMMANDS cppad_ipopt_speed_test.sh" ;; "cppad_ipopt_test_test.sh") CONFIG_COMMANDS="$CONFIG_COMMANDS cppad_ipopt_test_test.sh" ;; "example_test_one.sh") CONFIG_COMMANDS="$CONFIG_COMMANDS example_test_one.sh" ;; "test_more_test_one.sh") CONFIG_COMMANDS="$CONFIG_COMMANDS test_more_test_one.sh" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" eval set X " :F $CONFIG_FILES :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "example_ipopt_solve_test.sh":C) chmod +x example/ipopt_solve/test.sh ;; "cppad_ipopt_example_test.sh":C) chmod +x cppad_ipopt/example/test.sh ;; "cppad_ipopt_speed_test.sh":C) chmod +x cppad_ipopt/speed/test.sh ;; "cppad_ipopt_test_test.sh":C) chmod +x cppad_ipopt/test/test.sh ;; "example_test_one.sh":C) chmod +x example/test_one.sh ;; "test_more_test_one.sh":C) chmod +x test_more/test_one.sh ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi cppad-20160000.1/AUTHORS0000644000175200017650000000146012641232435013472 0ustar coincoin-web Statement of CppAD Authorship and Copyright =========================================== To date, 2016-01-01, Bradley M. Bell is the sole author of CppAD. While Bradley M. Bell worked for the University of Washington during the development of CppAD, the following are also true: 1. The CppAD package was not written or maintained as part of any sponsored grant at the University of Washington. 2. Bradley M. Bell was not paid by the University of Washington for the time he worked on CppAD. 3. Working on CppAD was not part of Bradley M. Bell's normal duties at for the University of Washington. Thus, in accordance with Section 2 of the University of Washington's copyright policy (see the file uw_copy_040507.html in this directory) Bradley M. Bell is the copyright holder for CppAD. cppad-20160000.1/depcomp0000755000175200017650000005601612561675772014026 0ustar coincoin-web#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2013-05-30.07; # UTC # Copyright (C) 1999-2014 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: cppad-20160000.1/compile0000755000175200017650000001624512564642107014014 0ustar coincoin-web#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-10-14.11; # UTC # Copyright (C) 1999-2013 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: cppad-20160000.1/example/0002755000175200017650000000000012656321774014071 5ustar coincoin-webcppad-20160000.1/example/sub_sparse_hes.cpp0000644000175200017650000000773112656321772017606 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sub_sparse_hes.cpp$$ $section Computing Sparse Hessian for a Subset of Variables$$ $head Purpose$$ This example uses $cref/multiple levels of AD/mul_level/$$ to compute the Hessian for a subset of the variables without having to compute the sparsity pattern for the entire function. $head See Also$$ $cref sparse_sub_hes.cpp$$, $cref sparsity_sub.cpp$$, $head Function$$ We consider the function $latex f : \B{R}^{nu} \times \B{R}^{nv} \rightarrow \B{R}$$ defined by $latex \[ f (u, v) = \left( \sum_{j=0}^{nu-1} u_j^3 \right) \left( \sum_{j=0}^{nv-1} v_j \right) \] $$ $head Subset$$ Suppose that we are only interested computing the function $latex \[ H(u, v) = \partial_u \partial_u f (u, v) \] $$ where this Hessian is sparse. $head Example$$ The following code shows one way to compute this subset of the Hessian of $latex f$$. $code $verbatim%example/sub_sparse_hes.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { using CppAD::vector; template Scalar f(const vector& u,const vector& v) { size_t i; Scalar sum_v = Scalar(0); for(i = 0; i < v.size(); i++) sum_v += v[i]; Scalar sum_cube_u = Scalar(0); for(i = 0; i < u.size(); i++) sum_cube_u += u[i] * u[i] * u[i] / 6.0; return sum_v * sum_cube_u; } } bool sub_sparse_hes(void) { bool ok = true; using CppAD::AD; typedef AD adouble; typedef AD a2double; typedef vector< std::set > pattern; double eps = 10. * std::numeric_limits::epsilon(); size_t i, j; // start recording with x = (u , v) size_t nu = 10; size_t nv = 5; size_t n = nu + nv; vector ax(n); for(j = 0; j < n; j++) ax[j] = adouble(j + 2); CppAD::Independent(ax); // extract u as independent variables vector a2u(nu); for(j = 0; j < nu; j++) a2u[j] = a2double(j + 2); CppAD::Independent(a2u); // extract v as parameters vector a2v(nv); for(j = 0; j < nv; j++) a2v[j] = ax[nu+j]; // record g(u) vector a2y(1); a2y[0] = f(a2u, a2v); CppAD::ADFun g; g.Dependent(a2u, a2y); // compue sparsity pattern for Hessian of g(u) pattern r(nu), s(1); for(j = 0; j < nu; j++) r[j].insert(j); g.ForSparseJac(nu, r); s[0].insert(0); pattern p = g.RevSparseHes(nu, s); // Row and column indices for non-zeros in lower triangle of Hessian vector row, col; for(i = 0; i < nu; i++) { std::set::const_iterator itr; for(itr = p[i].begin(); itr != p[i].end(); itr++) { j = *itr; if( j <= i ) { row.push_back(i); col.push_back(j); } } } size_t K = row.size(); CppAD::sparse_hessian_work work; vector au(nu), ahes(K), aw(1); aw[0] = 1.0; for(j = 0; j < nu; j++) au[j] = ax[j]; size_t n_sweep = g.SparseHessian(au, aw, p, row, col, ahes, work); // The Hessian w.r.t u is diagonal ok &= n_sweep == 1; // record H(u, v) = Hessian of f w.r.t u CppAD::ADFun H(ax, ahes); // remove unecessary operations H.optimize(); // Now evaluate the Hessian at a particular value for u, v vector u(nu), v(nv), x(n); for(j = 0; j < n; j++) x[j] = double(j + 2); vector hes = H.Forward(0, x); // Now check the Hessian double sum_v = 0.0; for(j = 0; j < nv; j++) sum_v += x[nu + j]; for(size_t k = 0; k < K; k++) { i = row[k]; j = col[k]; ok &= i == j; double check = sum_v * x[i]; ok &= CppAD::NearEqual(hes[k], check, eps, eps); } return ok; } // END C++ cppad-20160000.1/example/tanh.cpp0000644000175200017650000000415212656321772015525 0ustar coincoin-web// $Id: tanh.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin tanh.cpp$$ $spell tanh $$ $section The AD tanh Function: Example and Test$$ $code $verbatim%example/tanh.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include bool Tanh(void) { 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); return ok; } // END C++ cppad-20160000.1/example/atomic/0002755000175200017650000000000012656321772015343 5ustar coincoin-webcppad-20160000.1/example/atomic/reciprocal.cpp0000644000175200017650000002401112656321772020166 0ustar coincoin-web// $Id: reciprocal.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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$$ $codep */ # include namespace { // isolate items below to this file using CppAD::vector; // abbreviate as vector // // a utility to compute the union of two sets. void my_union( std::set& result , const std::set& left , const std::set& right ) { std::set temp; std::set_union( left.begin() , left.end() , right.begin() , right.end() , std::inserter(temp, temp.begin()) ); result.swap(temp); } // class atomic_reciprocal : public CppAD::atomic_base { /* $$ $head Constructor $$ $codep */ 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$$ $codep */ // 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 n = tx.size() / (q + 1); size_t m = ty.size() / (q + 1); 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$$ $codep */ // 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 n = tx.size() / (q + 1); size_t m = ty.size() / (q + 1); assert( px.size() == n * (q + 1) ); assert( py.size() == m * (q + 1) ); assert( n == 1 ); assert( m == 1 ); bool ok = q <= 2; 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$$ $codep */ // forward Jacobian set sparsity routine called by CppAD virtual bool for_sparse_jac( size_t p , const vector< std::set >& r , vector< std::set >& s ) { // This function needed if using f.ForSparseJac size_t n = r.size(); size_t m = s.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$$ $codep */ // reverse Jacobian set sparsity routine called by CppAD virtual bool rev_sparse_jac( size_t p , const vector< std::set >& rt , vector< std::set >& st ) { // This function needed if using RevSparseJac or optimize size_t n = st.size(); size_t m = rt.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$$ $codep */ // reverse Hessian set sparsity routine called by CppAD virtual bool rev_sparse_hes( const vector& vx, const vector& s , vector& t , size_t p , const vector< std::set >& r , const vector< std::set >& u , vector< std::set >& v ) { // This function needed if using RevSparseHes size_t n = vx.size(); size_t m = s.size(); assert( t.size() == n ); assert( r.size() == n ); assert( u.size() == m ); assert( v.size() == n ); assert( n == 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] ) my_union(v[0], v[0], r[0] ); return true; } /* $$ $head End Class Definition$$ $codep */ }; // End of atomic_reciprocal class } // End empty namespace /* $$ $head Use Atomic Function$$ $codep */ bool reciprocal(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double eps = 10. * CppAD::numeric_limits::epsilon(); /* $$ $subhead Constructor$$ $codep */ // -------------------------------------------------------------------- // Create the atomic reciprocal object atomic_reciprocal afun("atomic_reciprocal"); /* $$ $subhead Recording$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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 */ cppad-20160000.1/example/atomic/get_started.cpp0000644000175200017650000000671212656321772020360 0ustar coincoin-web// $Id: get_started.cpp 3715 2015-08-30 12:20:43Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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$$ $codep */ # include namespace { // isolate items below to this file using CppAD::vector; // abbreviate as vector class atomic_get_started : public CppAD::atomic_base { /* $$ $head Constructor$$ $codep */ 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$$ $codep */ // 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 n = tx.size() / (q + 1); size_t m = ty.size() / (q + 1); 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$$ $codep */ }; // End of atomic_get_started class } // End empty namespace /* $$ $head Use Atomic Function$$ $codep */ bool get_started(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double eps = 10. * CppAD::numeric_limits::epsilon(); /* $$ $subhead Constructor$$ $codep */ // Create the atomic get_started object atomic_get_started afun("atomic_get_started"); /* $$ $subhead Recording$$ $codep */ // 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$$ $codep */ // 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 */ cppad-20160000.1/example/atomic/checkpoint.cpp0000644000175200017650000001242512656321772020200 0ustar coincoin-web/* $Id: checkpoint.cpp 3721 2015-09-04 03:15:40Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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} \cdot x_0 \cdot x_0 \cdot x_0 \\ \cdot x_1 \cdot x_1 \cdot x_1 \end{array} \right) \] $$ $code $verbatim%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 ok = true; using CppAD::checkpoint; using CppAD::ADFun; using CppAD::NearEqual; size_t i, j, k, n = 2, m = n; double eps = 10. * std::numeric_limits::epsilon(); // checkpoint version of the function F(x) ADVector ax(n), ay(n), az(m); for(j = 0; j < n; j++) ax[j] = double(j + 1); // could also use bool_sparsity_enum or set_sparsity_enum checkpoint atom_f("atom_f", f_algo, ax, ay, f_sparsity); checkpoint atom_g("atom_g", g_algo, ay, az, g_sparsity); // Record a version of z = g[f(x)] without checkpointing Independent(ax); f_algo(ax, ay); g_algo(ay, az); ADFun check_not(ax, az); // Record a version of z = g[f(x)] with checkpointing Independent(ax); atom_f(ax, ay); atom_g(ay, az); ADFun check_yes(ax, az); // checkpointing should use fewer operations ok &= check_yes.size_var() < check_not.size_var(); // this does not really save space becasue f and g are only used once ok &= check_not.size_var() <= check_yes.size_var() + atom_f.size_var() + atom_g.size_var(); // compare forward mode results for orders 0, 1, 2 size_t q = 2; CPPAD_TESTVECTOR(double) x_q(n*(q+1)), z_not(m*(q+1)), z_yes(m*(q+1)); for(j = 0; j < n; j++) { for(k = 0; k <= q; k++) x_q[ j * (q+1) + k ] = 1.0 / (q + 1 - k); } z_not = check_not.Forward(q, x_q); z_yes = check_yes.Forward(q, x_q); for(i = 0; i < m; i++) { for(k = 0; k <= q; k++) { double zik_not = z_not[ i * (q+1) + k]; double zik_yes = z_yes[ i * (q+1) + k]; ok &= NearEqual(zik_not, zik_yes, eps, eps); } } // compare reverse mode results CPPAD_TESTVECTOR(double) w(m*(q+1)), dw_not(n*(q+1)), dw_yes(n*(q+1)); dw_not = check_not.Reverse(q+1, w); dw_yes = check_yes.Reverse(q+1, w); for(j = 0; j < n; j++) { for(k = 0; k <= q; k++) { double dwjk_not = dw_not[ j * (q+1) + k]; double dwjk_yes = dw_yes[ j * (q+1) + k]; ok &= NearEqual(dwjk_not, dwjk_yes, eps, eps); } } // compare forward mode Jacobian sparsity patterns CppAD::vector< std::set > r(n), s_not(m), s_yes(m); for(j = 0; j < n; j++) r[j].insert(j); s_not = check_not.ForSparseJac(n, r); s_yes = check_yes.ForSparseJac(n, r); for(i = 0; i < m; i++) ok &= s_not[i] == s_yes[i]; // compare reverse mode Jacobian sparsity patterns CppAD::vector< std::set > s(m), r_not(m), r_yes(m); for(i = 0; i < m; i++) s[i].insert(i); r_not = check_not.RevSparseJac(m, s); r_yes = check_yes.RevSparseJac(m, s); for(i = 0; i < m; i++) ok &= s_not[i] == s_yes[i]; // compare reverse mode Hessian sparsity patterns CppAD::vector< std::set > s_one(1), h_not(n), h_yes(n); for(i = 0; i < m; i++) s_one[0].insert(i); h_not = check_not.RevSparseHes(n, s_one); h_yes = check_yes.RevSparseHes(n, s_one); for(i = 0; i < n; i++) ok &= h_not[i] == h_yes[i]; return ok; } } bool checkpoint(void) { bool ok = true; // different types of sparsity option_enum pack_sparsity = CppAD::atomic_base::pack_sparsity_enum; option_enum bool_sparsity = CppAD::atomic_base::bool_sparsity_enum; option_enum set_sparsity = CppAD::atomic_base::set_sparsity_enum; // test some different cases ok &= test_case(pack_sparsity, pack_sparsity); ok &= test_case(pack_sparsity, bool_sparsity); ok &= test_case(bool_sparsity, set_sparsity); ok &= test_case(set_sparsity, set_sparsity); return ok; } // END C++ cppad-20160000.1/example/atomic/makefile.am0000644000175200017650000000206012656321772017433 0ustar coincoin-web# $Id: makefile.am 3741 2015-10-07 14:51:10Z 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. # ----------------------------------------------------------------------------- # automake input file # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # check_PROGRAMS = atomic # AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # atomic_SOURCES = \ atomic.cpp \ checkpoint.cpp \ get_started.cpp \ hes_sparse.cpp \ mat_mul.cpp \ norm_sq.cpp \ reciprocal.cpp \ sparsity.cpp \ tangent.cpp test: check ./atomic cppad-20160000.1/example/atomic/test_one.sh0000755000175200017650000000310412656321772017516 0ustar coincoin-web#! /bin/bash -e # $Id: test_one.sh 3323 2014-09-12 12:10:54Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Run one of the tests if [ "$1" = "" ] then echo "usage: test_one.sh file [extra]" echo "file is the *.cpp file name with extension" echo "and extra is extra options for g++ command" exit 1 fi if [ ! -e "$1" ] then echo "Cannot find the file $1" exit 1 fi # determine the function name fun=`grep "^bool *[a-zA-Z0-9_]*( *void *)" $1 | tail -1 | \ sed -e "s/^bool *\([a-zA-Z0-9_]*\) *( *void *)/\1/"` # if [ -e test_one.exe ] then rm test_one.exe fi if [ -e test_one.cpp ] then rm test_one.cpp fi sed < atomic.cpp > test_one.cpp \ -e '/ok *\&= *Run( /d' \ -e "s/.*This line is used by test_one.sh.*/ ok \&= Run( $fun, \"$fun\");/" # if echo "$fun" | grep 'eigen' > /dev/null then cxxflags='-g -Wall -ansi -pedantic-errors -Wno-long-long' else cxxflags='-g -Wall -ansi -pedantic-errors -Wshadow' fi cmd="g++ test_one.cpp $* -o test_one.exe $cxxflags -g -std=c++11 -I../.. " echo $cmd $cmd # echo "./test_one.exe" if ! ./test_one.exe then exit 1 fi exit 0 cppad-20160000.1/example/atomic/CMakeLists.txt0000644000175200017650000000222212656321772020077 0ustar coincoin-web# $Id: CMakeLists.txt 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. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the example/atomic directory tests # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # ADD_EXECUTABLE(example_atomic EXCLUDE_FROM_ALL atomic.cpp checkpoint.cpp get_started.cpp hes_sparse.cpp mat_mul.cpp norm_sq.cpp reciprocal.cpp sparsity.cpp tangent.cpp ) # Extra compiler flags add_cppad_cxx_flags( example_atomic ) # Add the check_example_atomic target ADD_CUSTOM_TARGET(check_example_atomic example_atomic DEPENDS example_atomic ) cppad-20160000.1/example/atomic/atomic.cpp0000644000175200017650000000476512656321772017335 0ustar coincoin-web// $Id: atomic.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. -------------------------------------------------------------------------- */ // system include files used for I/O # include // C style asserts # include // for thread_alloc # include // external complied tests extern bool checkpoint(void); extern bool get_started(void); extern bool hes_sparse(void); extern bool mat_mul(void); extern bool norm_sq(void); extern bool reciprocal(void); extern bool sparsity(void); extern bool tangent(void); namespace { // function that runs one test static size_t Run_ok_count = 0; static size_t Run_error_count = 0; bool Run(bool TestOk(void), const char *name) { bool ok = true; ok &= TestOk(); if( ok ) { std::cout << "OK: " << "atomic: " << name << std::endl; Run_ok_count++; } else { std::cout << "Error: " << "atomic: " << name << std::endl; Run_error_count++; } return ok; } } // main program that runs all the tests int main(void) { bool ok = true; // This line is used by test_one.sh // external compiled tests ok &= Run( checkpoint, "checkpoint" ); ok &= Run( get_started, "get_started" ); ok &= Run( hes_sparse, "hes_sparse" ); ok &= Run( mat_mul, "mat_mul" ); ok &= Run( norm_sq, "norm_sq" ); ok &= Run( reciprocal, "reciprocal" ); ok &= Run( sparsity, "sparsity" ); ok &= Run( tangent, "tangent" ); // check for errors using std::cout; using std::endl; assert( ok || (Run_error_count > 0) ); if( CppAD::thread_alloc::free_all() ) { Run_ok_count++; cout << "OK: " << "No memory leak detected" << endl; } else { ok = false; Run_error_count++; cout << "Error: " << "memory leak detected" << endl; } // convert int(size_t) to avoid warning on _MSC_VER systems if( ok ) cout << "All " << int(Run_ok_count) << " tests passed." << endl; else cout << int(Run_error_count) << " tests failed." << endl; return static_cast( ! ok ); } cppad-20160000.1/example/atomic/hes_sparse.cpp0000644000175200017650000001542012656321772020203 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin atomic_hes_sparse.cpp$$ $section Atomic Operation Hessian Sparsity: Example and Test$$ $mindex sparsity$$ $head Purpose$$ This example demonstrates calculation of the Hessian sparsity pattern for an atomic operation. $nospell $head Start Class Definition$$ $codep */ # include namespace { // isolate items below to this file using CppAD::vector; // abbreviate as vector // // a utility to compute the union of two sets. void my_union( std::set& result , const std::set& left , const std::set& right ) { std::set temp; std::set_union( left.begin() , left.end() , right.begin() , right.end() , std::inserter(temp, temp.begin()) ); result.swap(temp); } // class atomic_hes_sparse : public CppAD::atomic_base { /* $$ $head Constructor $$ $codep */ public: // constructor (could use const char* for name) atomic_hes_sparse(const std::string& name) : CppAD::atomic_base(name) { } private: /* $$ $head forward$$ $codep */ // 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 n = tx.size() / (q + 1); size_t m = ty.size() / (q + 1); assert( n == 2 ); 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 // y^0 = f( x^0 ) = [ x0_0 * x0_0 , x0_0 * x0_1 ]^T assert( p <= 0 ); if( p <= 0 ) { ty[0] = tx[0] * tx[0]; ty[1] = tx[0] * tx[1]; } return ok; } /* $$ $head for_sparse_jac$$ $codep */ // forward Jacobian set sparsity routine called by CppAD virtual bool for_sparse_jac( size_t p , const vector< std::set >& r , vector< std::set >& s ) { // This function needed if using f.ForSparseJac // with afun.option( CppAD::atomic_base::set_sparsity_enum ) size_t n = r.size(); size_t m = s.size(); assert( n == 2 ); assert( m == 2 ); // sparsity for S(x) = f'(x) * R is union of rows of R s[0] = r[0]; my_union(s[1], r[0], r[1]); return true; } /* $$ $head rev_sparse_hes$$ $codep */ // reverse Hessian set sparsity routine called by CppAD virtual bool rev_sparse_hes( const vector& vx, const vector& s , vector& t , size_t p , const vector< std::set >& r , const vector< std::set >& u , vector< std::set >& v ) { // This function needed if using RevSparseHes // with afun.option( CppAD::atomic_base::set_sparsity_enum ) size_t n = vx.size(); size_t m = s.size(); assert( t.size() == n ); assert( r.size() == n ); assert( u.size() == m ); assert( v.size() == n ); assert( n == 2 ); assert( m == 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]; t[1] = 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] = u[0]; my_union(v[1], u[0], u[1]); // include forward Jacobian sparsity in Hessian sparsity // f_0''(x) * R if( s[0] ) my_union(v[0], v[0], r[0] ); // f_1''(x) * R if( s[1] ) { my_union(v[1], v[1], r[0] ); my_union(v[0], v[0], r[1] ); } return true; } }; // End of atomic_hes_sparse class /* $$ $head Use Atomic Function$$ $codep */ bool use_atomic_hes_sparse(bool x_1_variable) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double eps = 10. * CppAD::numeric_limits::epsilon(); // // Create the atomic hes_sparse object atomic_hes_sparse afun("atomic_hes_sparse"); // // Create the function f(u) // // domain space vector size_t n = 2; double x0_0 = 0.75, x0_1 = 2.00; vector< AD > au(n); au[0] = x0_0; au[1] = x0_1; // 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]; if( x_1_variable ) ax[1] = au[1]; else ax[1] = x0_1; afun(ax, ay); // y = [ x[0] * x[0] , 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_y0_0 = x0_0 * x0_0; double check_y0_1 = x0_0 * x0_1; ok &= NearEqual( Value(ay[0]) , check_y0_0, eps, eps); ok &= NearEqual( Value(ay[1]) , check_y0_1, eps, eps); // check zero order forward mode size_t q; vector uq(n), yq(m); q = 0; uq[0] = x0_0; uq[1] = x0_1; yq = f.Forward(q, uq); ok &= NearEqual(yq[0] , check_y0_0, eps, eps); ok &= NearEqual(yq[1] , check_y0_1, eps, eps); // forward sparse jacobian afun.option( CppAD::atomic_base::set_sparsity_enum ); vector< std::set > r(2), jac_s(2), check_s(2); r[0].insert(0); r[1].insert(1); jac_s = f.ForSparseJac(n, r); check_s[0].insert(0); ok &= jac_s[0] == check_s[0]; check_s[1].insert(0); if( x_1_variable ) check_s[1].insert(1); ok &= jac_s[1] == check_s[1]; // reverse sparse Hessian vector< std::set > h(2), check_h(2), hes_s(1); hes_s[0].insert(0); hes_s[0].insert(1); h = f.RevSparseHes(n, hes_s); check_h[0].insert(0); if( x_1_variable ) check_h[0].insert(1); ok &= h[0] == check_h[0]; if( x_1_variable ) check_h[1].insert(0); ok &= h[1] == check_h[1]; return ok; } } // End empty namespace /* $$ $head Test with x_1 Both a Variable and a Parameter$$ $codep */ bool hes_sparse(void) { bool ok = true; // test with x_1 a variable ok &= use_atomic_hes_sparse(true); // test with x_1 a parameter ok &= use_atomic_hes_sparse(false); return ok; } /* $$ $$ $comment end nospell$$ $end */ cppad-20160000.1/example/atomic/mat_mul.cpp0000644000175200017650000001734512656321772017515 0ustar coincoin-web// $Id: mat_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin atomic_mat_mul.cpp$$ $spell mul $$ $section User Atomic Matrix Multiply: Example and Test$$ $mindex multiply$$ $children% cppad/example/matrix_mul.hpp %$$ $head Class Definition$$ This example uses the file $cref atomic_matrix_mul.hpp$$ which defines matrix multiply as a $cref atomic_base$$ operation. $nospell $head Use Atomic Function$$ $codep */ # include # include bool mat_mul(void) { bool ok = true; using CppAD::AD; using CppAD::vector; size_t i, j; /* $$ $subhead Constructor$$ $codep */ // ------------------------------------------------------------------- // object that multiplies 2 x 2 matrices size_t nr_result = 2; size_t n_middle = 2; size_t nc_result = 2; matrix_mul afun(nr_result, n_middle, nc_result); /* $$ $subhead Recording$$ $codep */ // 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] = j + 1; CppAD::Independent(ax); // ------------------------------------------------------------------ vector< AD > atom_x(nr_result * n_middle + n_middle * nc_result); // left matrix atom_x[0] = ax[0]; // left[0, 0] = x0 atom_x[1] = ax[1]; // left[0, 1] = x1 atom_x[2] = 5.; // left[1, 0] = 5 atom_x[3] = 6.; // left[1, 1] = 6 // right matix atom_x[4] = ax[2]; // right[0, 0] = x2 atom_x[5] = 7.; // right[0, 1] = 7 atom_x[6] = ax[3]; // right[1, 0] = x3 atom_x[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 ] */ vector< AD > atom_y(nr_result * nc_result); 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$$ $codep */ // 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] = 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] = 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$$ $codep */ // 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$$ $codep */ //---------------------------------------------------------------------- // 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$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ /* 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 */ cppad-20160000.1/example/atomic/norm_sq.cpp0000644000175200017650000002312212656321772017523 0ustar coincoin-web// $Id: norm_sq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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$$ $codep */ # include namespace { // isolate items below to this file using CppAD::vector; // abbreviate as vector // class atomic_norm_sq : public CppAD::atomic_base { /* $$ $head Constructor $$ $codep */ public: // constructor (could use const char* for name) atomic_norm_sq(const std::string& name) : // this example only uses boolean sparsity patterns CppAD::atomic_base(name, atomic_base::bool_sparsity_enum) { } private: /* $$ $head forward$$ $codep */ // 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 n = tx.size() / (q+1); size_t m = ty.size() / (q+1); 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$$ $codep */ // 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 n = tx.size() / (q+1); size_t m = ty.size() / (q+1); assert( px.size() == n * (q+1) ); assert( py.size() == m * (q+1) ); assert( n == 2 ); assert( m == 1 ); bool ok = q <= 1; 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$$ $codep */ // forward Jacobian bool sparsity routine called by CppAD virtual bool for_sparse_jac( size_t p , const vector& r , vector& s ) { // This function needed if using f.ForSparseJac size_t n = r.size() / p; size_t m = s.size() / p; assert( n == 2 ); assert( m == 1 ); // sparsity for S(x) = f'(x) * R // 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$$ $codep */ // reverse Jacobian bool sparsity routine called by CppAD virtual bool rev_sparse_jac( size_t p , const vector& rt , vector& st ) { // This function needed if using RevSparseJac or optimize size_t n = st.size() / p; size_t m = rt.size() / p; assert( n == 2 ); assert( m == 1 ); // sparsity for S(x)^T = f'(x)^T * R^T // 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$$ $codep */ // reverse Hessian bool sparsity routine called by CppAD virtual bool rev_sparse_hes( const vector& vx, const vector& s , vector& t , size_t p , const vector& r , const vector& u , vector& v ) { // This function needed if using RevSparseHes size_t m = s.size(); size_t n = t.size(); assert( r.size() == n * p ); assert( u.size() == m * p ); assert( v.size() == n * p ); assert( n == 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$$ $codep */ }; // End of atomic_norm_sq class } // End empty namespace /* $$ $head Use Atomic Function$$ $codep */ bool norm_sq(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double eps = 10. * CppAD::numeric_limits::epsilon(); /* $$ $subhead Constructor$$ $codep */ // -------------------------------------------------------------------- // Create the atomic reciprocal object atomic_norm_sq afun("atomic_norm_sq"); /* $$ $subhead Recording$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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 */ cppad-20160000.1/example/atomic/sparsity.cpp0000644000175200017650000001571012656321772017727 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin atomic_sparsity.cpp$$ $spell enum $$ $section Atomic Sparsity Patterns: Example and Test$$ $head function$$ For this example, the atomic function $latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by $latex \[ f( x_0, x_1 , x_2 ) = \left( \begin{array}{c} x_2 \\ x_0 * x_1 \end{array} \right) \] $$ $head pack_sparsity_enum$$ This example only uses pack sparsity patterns. $nospell $head Start Class Definition$$ $codep */ # include namespace { // isolate items below to this file using CppAD::vector; // abbreviate as vector using CppAD::vectorBool; // abbreviate as vectorBool // class atomic_sparsity : public CppAD::atomic_base { /* $$ $head Constructor $$ $codep */ public: // constructor atomic_sparsity(const std::string& name) : // this exampel only uses pack sparsity patterns CppAD::atomic_base(name, pack_sparsity_enum ) { } private: /* $$ $head forward$$ $codep */ // forward virtual bool forward( size_t p , size_t q , const vector& vx , vector& vy , const vector& tx , vector& ty ) { size_t n = tx.size() / (q + 1); size_t m = ty.size() / (q + 1); assert( n == 3 ); assert( m == 2 ); // only order zero bool ok = q == 0; if( ! ok ) return ok; // check for defining variable information if( vx.size() > 0 ) { ok &= vx.size() == n; vy[0] = vx[2]; vy[1] = vx[0] || vx[1]; } // Order zero forward mode. // y[0] = x[2], y[1] = x[0] * x[1] if( p <= 0 ) { ty[0] = tx[2]; ty[1] = tx[0] * tx[1]; } return ok; } /* $$ $head for_sparse_jac$$ $codep */ // for_sparse_jac virtual bool for_sparse_jac( size_t p , const vectorBool& r , vectorBool& s ) { // This function needed if using f.ForSparseJac size_t n = r.size() / p; size_t m = s.size() / p; assert( n == 3 ); assert( m == 2 ); // sparsity for S(x) = f'(x) * R = [ 0, 0, 1 ] * R // [ x1, x0, 0 ] for(size_t j = 0; j < p; j++) { s[ 0 * p + j] = r[ 2 * p + j]; s[ 1 * p + j] = r[ 0 * p + j] || r[ 1 * p + j]; } return true; } /* $$ $head rev_sparse_jac$$ $codep */ virtual bool rev_sparse_jac( size_t p , const vectorBool& rt , vectorBool& st ) { // This function needed if using RevSparseJac or optimize size_t n = st.size() / p; size_t m = rt.size() / p; assert( n == 3 ); assert( m == 2 ); // [ 0, x1 ] // sparsity for S(x)^T = f'(x)^T * R^T = [ 0, x0 ] * R^T // [ 1, 0 ] for(size_t j = 0; j < p; j++) { st[ 0 * p + j ] = rt[ 1 * m + j ]; st[ 1 * p + j ] = rt[ 1 * m + j ]; st[ 2 * p + j ] = rt[ 0 * m + j ]; } return true; } /* $$ $head rev_sparse_hes$$ $codep */ virtual bool rev_sparse_hes( const vector& vx, const vector& s , vector& t , size_t p , const vectorBool& r , const vectorBool& u , vectorBool& v ) { // This function needed if using RevSparseHes size_t m = s.size(); size_t n = t.size(); assert( r.size() == n * p ); assert( u.size() == m * p ); assert( v.size() == n * p ); assert( n == 3 ); assert( m == 2 ); // sparsity for T(x) = S(x) * f'(x) = S(x) * [ 0, 0, 1 ] // [ x1, x0, 0 ] t[0] = s[1]; t[1] = s[1]; t[2] = s[0]; // V(x) = f'(x)^T * g''(y) * f'(x) * R + g'(y) * f''(x) * R // U(x) = g''(y) * f'(x) * R // S(x) = g'(y) // [ 0, x1 ] // sparsity for f'(x)^T * U(x) = [ 0, x0 ] * U(x) // [ 1, 0 ] size_t j; for(j = 0; j < p; j++) { v[ 0 * p + j ] = u[ 1 * m + j ]; v[ 1 * p + j ] = u[ 1 * m + j ]; v[ 2 * p + j ] = u[ 0 * m + j ]; } // include forward Jacobian sparsity in Hessian sparsity // [ 0, 1, 0 ] // sum_i S_i (x) g'(y) * f_i''(x) * R = S_1 (x) * [ 1, 0, 0 ] * R // [ 0, 0, 0 ] if( s[1] ) { for(j = 0; j < p; j++) { v[ 0 * p + j ] = bool(v[0 * p + j]) | bool(r[1 * p + j]); v[ 1 * p + j ] = bool(v[1 * p + j]) | bool(r[0 * p + j]); } } return true; } /* $$ $head End Class Definition$$ $codep */ }; // End of atomic_sparsity class } // End empty namespace /* $$ $head Use Atomic Function$$ $codep */ bool sparsity(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double eps = 10. * std::numeric_limits::epsilon(); /* $$ $subhead Constructor$$ $codep */ // Create the atomic get_started object atomic_sparsity afun("atomic_sparsity"); /* $$ $subhead Recording$$ $codep */ size_t n = 3; size_t m = 2; vector< AD > ax(n), ay(m); for(size_t j = 0; j < n; j++) ax[j] = double(j + 1); // declare independent variables and start tape recording CppAD::Independent(ax); // call user function afun(ax, ay); // create f: x -> y and stop tape recording CppAD::ADFun f; f.Dependent (ax, ay); // f(x) = x // check function value ok &= NearEqual(ay[0] , ax[2], eps, eps); ok &= NearEqual(ay[1] , ax[0] * ax[1], eps, eps); /* $$ $subhead forsparse_jac and rev_sparse_jac$$ $codep */ for(size_t dir = 0; dir < 2; dir++) { size_t ell; if( dir == 0 ) ell = n; else ell = m; // identity martrix vectorBool r(ell * ell); for(size_t i = 0; i < ell; i++) for(size_t j = 0; j < ell; j++) r[i * ell + j] = (i == j); vectorBool s; if( dir == 0 ) s = f.ForSparseJac(n, r); else s = f.RevSparseJac(m, r); // check Jacobian result ok &= s.size() == m * n; ok &= s[0 * n + 0] == false; ok &= s[0 * n + 1] == false; ok &= s[0 * n + 2] == true; ok &= s[1 * n + 0] == true; ok &= s[1 * n + 1] == true; ok &= s[1 * n + 2] == false; } /* $$ $subhead rev_sparse_hes$$ $codep */ vectorBool s(m), h(n * n); s[0] = true; s[1] = true; h = f.RevSparseHes(n, s); for(size_t i = 0; i < n; i++) { for(size_t j = 0; j < n; j++) { bool check = false; check |= (i == 0) && (j == 1); check |= (j == 0) && (i == 1); ok &= h[ i * n + j] == check; } } // return ok; } /* $$ $$ $comment end nospell$$ $end */ cppad-20160000.1/example/atomic/tangent.cpp0000644000175200017650000003243512656321772017514 0ustar coincoin-web// $Id: tangent.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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$$ $codep */ # include namespace { // Begin empty namespace using CppAD::vector; // // a utility to compute the union of two sets. void my_union( std::set& result , const std::set& left , const std::set& right ) { std::set temp; std::set_union( left.begin() , left.end() , right.begin() , right.end() , std::inserter(temp, temp.begin()) ); result.swap(temp); } // class atomic_tangent : public CppAD::atomic_base { /* $$ $head Constructor $$ $codep */ 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$$ $codep */ // 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; size_t n = tx.size() / q1; size_t m = tzy.size() / q1; 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] = tanh( tx[0] ); else tzy[0] = 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] * 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$$ $codep */ // 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; size_t n = tx.size() / q1; size_t m = tzy.size() / q1; 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] * k * j_inv; // H_{y^{j-k)} += +- H_{z^{(j)} x^{(k)} * k / j for(k = 1; k <= j; k++) qzy[q1 + j-k] += qzy[j] * tx[k] * k * j_inv; // 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$$ $codep */ // forward Jacobian sparsity routine called by CppAD virtual bool for_sparse_jac( size_t p , const vector& r , vector& s ) { size_t n = r.size() / p; size_t m = s.size() / p; 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 ) { size_t n = r.size(); size_t m = s.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$$ $codep */ // reverse Jacobian sparsity routine called by CppAD virtual bool rev_sparse_jac( size_t p , const vector& rt , vector& st ) { size_t n = st.size() / p; size_t m = rt.size() / p; assert( n == 1 ); assert( m == 2 ); // 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 ) { size_t n = st.size(); size_t m = rt.size(); assert( n == 1 ); assert( m == 2 ); // sparsity for S(x)^T = f'(x)^T * R^T my_union(st[0], rt[0], rt[1]); return true; } /* $$ $head rev_sparse_hes$$ $codep */ // 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 ) { size_t m = s.size(); size_t n = t.size(); assert( r.size() == n * p ); assert( u.size() == m * p ); assert( v.size() == n * p ); assert( n == 1 ); assert( m == 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 ) { size_t m = s.size(); size_t n = t.size(); 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; my_union(v[0], 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] ) my_union(v[0], v[0], r[0]); return true; } /* $$ $head End Class Definition$$ $codep */ }; // End of atomic_tangent class } // End empty namespace /* $$ $head Use Atomic Function$$ $codep */ bool tangent(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; float eps = 10.f * CppAD::numeric_limits::epsilon(); /* $$ $subhead Constructor$$ $codep */ // -------------------------------------------------------------------- // Creater a tan and tanh object atomic_tangent my_tan("my_tan", false), my_tanh("my_tanh", true); /* $$ $subhead Recording$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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$$ $codep */ // 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 */ cppad-20160000.1/example/atomic/makefile.in0000644000175200017650000004637412656321772017464 0ustar coincoin-web# 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_OBJECTS = atomic.$(OBJEXT) checkpoint.$(OBJEXT) \ get_started.$(OBJEXT) hes_sparse.$(OBJEXT) mat_mul.$(OBJEXT) \ norm_sq.$(OBJEXT) reciprocal.$(OBJEXT) sparsity.$(OBJEXT) \ tangent.$(OBJEXT) atomic_OBJECTS = $(am_atomic_OBJECTS) atomic_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) 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@ CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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 = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # atomic_SOURCES = \ atomic.cpp \ checkpoint.cpp \ get_started.cpp \ hes_sparse.cpp \ mat_mul.cpp \ norm_sq.cpp \ reciprocal.cpp \ 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) --gnu example/atomic/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu 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)/get_started.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hes_sparse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mat_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/norm_sq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reciprocal.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparsity.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tangent.Po@am__quote@ .cpp.o: @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: cppad-20160000.1/example/lu_ratio.cpp0000644000175200017650000001122512656321772016410 0ustar coincoin-web// $Id: lu_ratio.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin lu_ratio.cpp$$ $spell Geq Cpp Lu $$ $section LuRatio: Example and Test$$ $mindex LuRatio$$ $code $verbatim%example/lu_ratio.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include // for rand function # include # include 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; } 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; 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 &= CppAD::NearEqual(pij, sum, 1e-10, 1e-10); } } 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 *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; } // END C++ cppad-20160000.1/example/log1p.cpp0000644000175200017650000000404212656321772015613 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin log1p.cpp$$ $spell expm1 log1p $$ $section The AD log1p Function: Example and Test$$ $code $verbatim%example/log1p.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool log1p(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 10 times machine epsilon double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) x(n); x[0] = x0; // declare independent variables and start tape recording CppAD::Independent(x); // a temporary value AD expm1_of_x0 = CppAD::expm1(x[0]); // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::log1p(expm1_of_x0); // create f: x -> y and stop tape recording CppAD::ADFun f(x, y); // check value ok &= NearEqual(y[0] , x0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., eps, eps); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], 1., eps, eps); // use a VecAD::reference object with log1p CppAD::VecAD v(1); AD zero(0); v[zero] = expm1_of_x0; AD result = CppAD::log1p(v[zero]); ok &= NearEqual(result, x0, eps, eps); return ok; } // END C++ cppad-20160000.1/example/mul.cpp0000644000175200017650000000432512656321772015372 0ustar coincoin-web// $Id: mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin mul.cpp$$ $section AD Binary Multiplication: Example and Test$$ $mindex * multiply times$$ $code $verbatim%example/mul.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool Mul(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // 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, 1e-10 , 1e-10); // 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, 1e-10 , 1e-10); // 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; } // END C++ cppad-20160000.1/example/number_skip.cpp0000644000175200017650000000374712656321772017122 0ustar coincoin-web// $Id: number_skip.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin number_skip.cpp$$ $spell Taylor $$ $section Number of Variables That Can be Skipped: Example and Test$$ $mindex number_skip optimize conditional expression condition$$ $code $verbatim%example/number_skip.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool number_skip(void) { 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; return ok; } // END C++ cppad-20160000.1/example/makefile.in0000644000175200017650000012662312656321772016204 0ustar coincoin-web# 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 = example$(EXEEXT) subdir = example ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test_one.sh CONFIG_CLEAN_VPATH_FILES = 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__example_SOURCES_DIST = mul_level_adolc.cpp mul_level_adolc_ode.cpp \ example.cpp abort_recording.cpp abs.cpp acos.cpp acosh.cpp \ add.cpp add_eq.cpp ad_assign.cpp ad_ctor.cpp ad_fun.cpp \ ad_in_c.cpp ad_input.cpp ad_output.cpp asin.cpp asinh.cpp \ atan.cpp atanh.cpp atan2.cpp azmul.cpp base_alloc.hpp \ base_require.cpp bender_quad.cpp bool_fun.cpp \ bool_sparsity.cpp capacity_order.cpp change_param.cpp \ check_for_nan.cpp check_numeric_type.cpp \ check_simple_vector.cpp compare.cpp compare_change.cpp \ complex_poly.cpp cond_exp.cpp conj_grad.cpp cos.cpp cosh.cpp \ cppad_vector.cpp dependency.cpp div.cpp div_eq.cpp \ equal_op_seq.cpp erf.cpp error_handler.cpp exp.cpp expm1.cpp \ for_one.cpp for_two.cpp forward.cpp forward_dir.cpp \ forward_order.cpp for_sparse_jac.cpp fun_assign.cpp \ fun_check.cpp hes_lagrangian.cpp hes_lu_det.cpp \ hes_minor_det.cpp hessian.cpp hes_times_dir.cpp \ independent.cpp index_sort.cpp integer.cpp interface2c.cpp \ interp_onetape.cpp interp_retape.cpp jac_lu_det.cpp \ jac_minor_det.cpp jacobian.cpp num_limits.cpp log.cpp \ log1p.cpp log10.cpp lu_factor.cpp lu_invert.cpp lu_ratio.cpp \ lu_solve.cpp lu_vec_ad.cpp lu_vec_ad.hpp lu_vec_ad_ok.cpp \ mul.cpp mul_eq.cpp mul_level.cpp mul_level_ode.cpp nan.cpp \ near_equal.cpp near_equal_ext.cpp number_skip.cpp \ numeric_type.cpp ode_err_control.cpp ode_err_maxabs.cpp \ ode_gear.cpp ode_gear_control.cpp ode_stiff.cpp ode_taylor.cpp \ opt_val_hes.cpp optimize.cpp par_var.cpp poly.cpp pow.cpp \ pow_int.cpp print_for.cpp reverse_any.cpp reverse_one.cpp \ reverse_three.cpp reverse_two.cpp rev_one.cpp \ rev_sparse_hes.cpp rev_sparse_jac.cpp rev_two.cpp \ romberg_mul.cpp romberg_one.cpp rosen_34.cpp runge45_1.cpp \ runge45_2.cpp seq_property.cpp simple_vector.cpp sign.cpp \ sin.cpp sinh.cpp sparse_hessian.cpp sparse_jacobian.cpp \ sparse_sub_hes.cpp sparsity_sub.cpp sqrt.cpp stack_machine.cpp \ sub.cpp sub_eq.cpp sub_sparse_hes.cpp tan.cpp tanh.cpp \ tape_index.cpp thread_alloc.cpp to_string.cpp unary_minus.cpp \ unary_plus.cpp value.cpp var2par.cpp vec_ad.cpp \ vector_bool.cpp @CppAD_ADOLC_TRUE@am__objects_1 = mul_level_adolc.$(OBJEXT) \ @CppAD_ADOLC_TRUE@ mul_level_adolc_ode.$(OBJEXT) am_example_OBJECTS = $(am__objects_1) example.$(OBJEXT) \ abort_recording.$(OBJEXT) abs.$(OBJEXT) acos.$(OBJEXT) \ acosh.$(OBJEXT) add.$(OBJEXT) add_eq.$(OBJEXT) \ ad_assign.$(OBJEXT) ad_ctor.$(OBJEXT) ad_fun.$(OBJEXT) \ ad_in_c.$(OBJEXT) ad_input.$(OBJEXT) ad_output.$(OBJEXT) \ asin.$(OBJEXT) asinh.$(OBJEXT) atan.$(OBJEXT) atanh.$(OBJEXT) \ atan2.$(OBJEXT) azmul.$(OBJEXT) base_require.$(OBJEXT) \ bender_quad.$(OBJEXT) bool_fun.$(OBJEXT) \ bool_sparsity.$(OBJEXT) capacity_order.$(OBJEXT) \ change_param.$(OBJEXT) check_for_nan.$(OBJEXT) \ check_numeric_type.$(OBJEXT) check_simple_vector.$(OBJEXT) \ compare.$(OBJEXT) compare_change.$(OBJEXT) \ complex_poly.$(OBJEXT) cond_exp.$(OBJEXT) conj_grad.$(OBJEXT) \ cos.$(OBJEXT) cosh.$(OBJEXT) cppad_vector.$(OBJEXT) \ dependency.$(OBJEXT) div.$(OBJEXT) div_eq.$(OBJEXT) \ equal_op_seq.$(OBJEXT) erf.$(OBJEXT) error_handler.$(OBJEXT) \ exp.$(OBJEXT) expm1.$(OBJEXT) for_one.$(OBJEXT) \ for_two.$(OBJEXT) forward.$(OBJEXT) forward_dir.$(OBJEXT) \ forward_order.$(OBJEXT) for_sparse_jac.$(OBJEXT) \ fun_assign.$(OBJEXT) fun_check.$(OBJEXT) \ hes_lagrangian.$(OBJEXT) hes_lu_det.$(OBJEXT) \ hes_minor_det.$(OBJEXT) hessian.$(OBJEXT) \ hes_times_dir.$(OBJEXT) independent.$(OBJEXT) \ index_sort.$(OBJEXT) integer.$(OBJEXT) interface2c.$(OBJEXT) \ interp_onetape.$(OBJEXT) interp_retape.$(OBJEXT) \ jac_lu_det.$(OBJEXT) jac_minor_det.$(OBJEXT) \ jacobian.$(OBJEXT) num_limits.$(OBJEXT) log.$(OBJEXT) \ log1p.$(OBJEXT) log10.$(OBJEXT) lu_factor.$(OBJEXT) \ lu_invert.$(OBJEXT) lu_ratio.$(OBJEXT) lu_solve.$(OBJEXT) \ lu_vec_ad.$(OBJEXT) lu_vec_ad_ok.$(OBJEXT) mul.$(OBJEXT) \ mul_eq.$(OBJEXT) mul_level.$(OBJEXT) mul_level_ode.$(OBJEXT) \ nan.$(OBJEXT) near_equal.$(OBJEXT) near_equal_ext.$(OBJEXT) \ number_skip.$(OBJEXT) numeric_type.$(OBJEXT) \ ode_err_control.$(OBJEXT) ode_err_maxabs.$(OBJEXT) \ ode_gear.$(OBJEXT) ode_gear_control.$(OBJEXT) \ ode_stiff.$(OBJEXT) ode_taylor.$(OBJEXT) opt_val_hes.$(OBJEXT) \ optimize.$(OBJEXT) par_var.$(OBJEXT) poly.$(OBJEXT) \ pow.$(OBJEXT) pow_int.$(OBJEXT) print_for.$(OBJEXT) \ reverse_any.$(OBJEXT) reverse_one.$(OBJEXT) \ reverse_three.$(OBJEXT) reverse_two.$(OBJEXT) \ rev_one.$(OBJEXT) rev_sparse_hes.$(OBJEXT) \ rev_sparse_jac.$(OBJEXT) rev_two.$(OBJEXT) \ romberg_mul.$(OBJEXT) romberg_one.$(OBJEXT) rosen_34.$(OBJEXT) \ runge45_1.$(OBJEXT) runge45_2.$(OBJEXT) seq_property.$(OBJEXT) \ simple_vector.$(OBJEXT) sign.$(OBJEXT) sin.$(OBJEXT) \ sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \ sparse_jacobian.$(OBJEXT) sparse_sub_hes.$(OBJEXT) \ sparsity_sub.$(OBJEXT) sqrt.$(OBJEXT) stack_machine.$(OBJEXT) \ sub.$(OBJEXT) sub_eq.$(OBJEXT) sub_sparse_hes.$(OBJEXT) \ tan.$(OBJEXT) tanh.$(OBJEXT) tape_index.$(OBJEXT) \ thread_alloc.$(OBJEXT) to_string.$(OBJEXT) \ unary_minus.$(OBJEXT) unary_plus.$(OBJEXT) value.$(OBJEXT) \ var2par.$(OBJEXT) vec_ad.$(OBJEXT) vector_bool.$(OBJEXT) example_OBJECTS = $(am_example_OBJECTS) example_LDADD = $(LDADD) am__DEPENDENCIES_1 = example_DEPENDENCIES = $(am__DEPENDENCIES_1) $(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 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 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@) 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 = $(libeigen_a_SOURCES) $(example_SOURCES) DIST_SOURCES = $(am__libeigen_a_SOURCES_DIST) \ $(am__example_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 $(srcdir)/test_one.sh.in \ $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ 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 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. # ----------------------------------------------------------------------------- # automake input file # # CppAD puts 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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_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 = -DCPPAD_ADOLC_EXAMPLES -I$(ADOLC_DIR)/include @CppAD_EIGEN_DIR_FALSE@@CppAD_HAVE_AR_TRUE@EIGEN_EXTRA_FILES = eigen_det.cpp eigen_array.cpp # ------------------------------------------------------------------------- # make a special library so can have it's own compile flags (see configure.ac) @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 = -DCPPAD_EIGEN_EXAMPLES @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@ -DCPPAD_EIGEN_EXAMPLES \ @CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@ -I$(EIGEN_DIR)/include # ------------------------------------------------------------------------- # auto-tools does not support use of colpack EXTRA_DIST = \ test_one.sh.in \ colpack_hes.cpp \ colpack_jac.cpp \ $(ADOLC_EXTRA_FILES) \ $(EIGEN_EXTRA_FILES) @CppAD_MS_COMPILER_FALSE@AM_CXXFLAGS = -g $(ADOLC_FLAGS) $(EIGEN_FLAGS) $(CXX_FLAGS) # @CppAD_MS_COMPILER_TRUE@AM_CXXFLAGS = -EHsc -g $(ADOLC_FLAGS) $(EIGEN_FLAGS) $(CXX_FLAGS) # AM_CPPFLAGS = \ -I. \ -I$(top_srcdir) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(ADOLC_FLAGS) \ $(EIGEN_FLAGS) # LDADD = $(ADOLC_LIB) $(BTHREAD_LIB) $(EIGEN_LIB) $(PTHREAD_LIB) # example_SOURCES = \ $(ADOLC_SRC_FILES) \ \ example.cpp \ abort_recording.cpp \ abs.cpp \ acos.cpp \ acosh.cpp \ add.cpp \ add_eq.cpp \ ad_assign.cpp \ ad_ctor.cpp \ ad_fun.cpp \ ad_in_c.cpp \ ad_input.cpp \ ad_output.cpp \ asin.cpp \ asinh.cpp \ atan.cpp \ atanh.cpp \ atan2.cpp \ azmul.cpp \ base_alloc.hpp \ base_require.cpp \ bender_quad.cpp \ bool_fun.cpp \ bool_sparsity.cpp \ capacity_order.cpp \ change_param.cpp \ check_for_nan.cpp \ check_numeric_type.cpp \ check_simple_vector.cpp \ compare.cpp \ compare_change.cpp \ complex_poly.cpp \ cond_exp.cpp \ conj_grad.cpp \ cos.cpp \ cosh.cpp \ cppad_vector.cpp \ dependency.cpp \ div.cpp \ div_eq.cpp \ equal_op_seq.cpp \ erf.cpp \ error_handler.cpp \ exp.cpp \ expm1.cpp \ for_one.cpp \ for_two.cpp \ forward.cpp \ forward_dir.cpp \ forward_order.cpp \ for_sparse_jac.cpp \ fun_assign.cpp \ fun_check.cpp \ hes_lagrangian.cpp \ hes_lu_det.cpp \ hes_minor_det.cpp \ hessian.cpp \ hes_times_dir.cpp \ independent.cpp \ index_sort.cpp \ integer.cpp \ interface2c.cpp\ interp_onetape.cpp\ interp_retape.cpp\ jac_lu_det.cpp \ jac_minor_det.cpp \ jacobian.cpp \ num_limits.cpp \ log.cpp \ log1p.cpp \ log10.cpp \ lu_factor.cpp \ lu_invert.cpp \ lu_ratio.cpp \ lu_solve.cpp \ lu_vec_ad.cpp \ lu_vec_ad.hpp \ lu_vec_ad_ok.cpp \ mul.cpp \ mul_eq.cpp \ mul_level.cpp \ mul_level_ode.cpp \ nan.cpp \ near_equal.cpp \ near_equal_ext.cpp \ number_skip.cpp \ numeric_type.cpp \ ode_err_control.cpp \ ode_err_maxabs.cpp \ ode_gear.cpp \ ode_gear_control.cpp\ ode_stiff.cpp \ ode_taylor.cpp \ opt_val_hes.cpp \ optimize.cpp \ par_var.cpp \ poly.cpp \ pow.cpp \ pow_int.cpp \ print_for.cpp \ reverse_any.cpp \ reverse_one.cpp \ reverse_three.cpp \ reverse_two.cpp \ rev_one.cpp \ rev_sparse_hes.cpp \ rev_sparse_jac.cpp \ rev_two.cpp \ romberg_mul.cpp \ romberg_one.cpp \ rosen_34.cpp \ runge45_1.cpp \ runge45_2.cpp \ seq_property.cpp \ simple_vector.cpp \ sign.cpp \ sin.cpp \ sinh.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp \ sparse_sub_hes.cpp \ sparsity_sub.cpp \ sqrt.cpp \ stack_machine.cpp \ sub.cpp \ sub_eq.cpp \ sub_sparse_hes.cpp \ tan.cpp \ tanh.cpp \ tape_index.cpp \ thread_alloc.cpp \ to_string.cpp \ unary_minus.cpp \ unary_plus.cpp \ value.cpp \ var2par.cpp \ vec_ad.cpp \ vector_bool.cpp 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) --gnu example/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu example/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): test_one.sh: $(top_builddir)/config.status $(srcdir)/test_one.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 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) example$(EXEEXT): $(example_OBJECTS) $(example_DEPENDENCIES) $(EXTRA_example_DEPENDENCIES) @rm -f example$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(example_OBJECTS) $(example_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abort_recording.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acos.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acosh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ad_assign.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ad_ctor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ad_fun.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ad_in_c.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ad_input.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ad_output.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_eq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asinh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atan2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atanh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/azmul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_require.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bender_quad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bool_fun.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bool_sparsity.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/capacity_order.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/change_param.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_for_nan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_numeric_type.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_simple_vector.Po@am__quote@ @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)/cond_exp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conj_grad.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_vector.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dependency.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/div.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/div_eq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/equal_op_seq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/erf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error_handler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expm1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_one.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_sparse_jac.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_two.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forward.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forward_dir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forward_order.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fun_assign.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fun_check.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hes_lagrangian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hes_lu_det.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hes_minor_det.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hes_times_dir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hessian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/independent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/index_sort.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/integer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interface2c.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interp_onetape.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interp_retape.Po@am__quote@ @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@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lu_factor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lu_invert.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lu_ratio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lu_solve.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lu_vec_ad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lu_vec_ad_ok.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_eq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_level.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_level_adolc.Po@am__quote@ @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)/nan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/near_equal.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/near_equal_ext.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/num_limits.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/number_skip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numeric_type.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_err_control.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_err_maxabs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_gear.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_gear_control.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_stiff.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_taylor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opt_val_hes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optimize.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/par_var.Po@am__quote@ @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@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print_for.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rev_one.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)/rev_two.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reverse_any.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reverse_one.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reverse_three.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reverse_two.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/romberg_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/romberg_one.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rosen_34.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/runge45_1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/runge45_2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/seq_property.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sign.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple_vector.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sin.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_jacobian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_sub_hes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparsity_sub.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sqrt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack_machine.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub_eq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub_sparse_hes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tanh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tape_index.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread_alloc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/to_string.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unary_minus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unary_plus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/value.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/var2par.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vec_ad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector_bool.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) '$<'` 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 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 $(LIBRARIES) 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 clean-noinstLIBRARIES \ 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 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 .PRECIOUS: makefile test: check ./example # 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: cppad-20160000.1/example/tan.cpp0000644000175200017650000000414112656321772015353 0ustar coincoin-web// $Id: tan.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin tan.cpp$$ $spell tan tan $$ $section The AD tan Function: Example and Test$$ $code $verbatim%example/tan.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include bool Tan(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) x(n); x[0] = x0; // 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; } // END C++ cppad-20160000.1/example/asinh.cpp0000644000175200017650000000403512656321772015675 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin asinh.cpp$$ $spell sinh asinh $$ $section The AD asinh Function: Example and Test$$ $code $verbatim%example/asinh.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool asinh(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 10 times machine epsilon double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) x(n); x[0] = x0; // declare independent variables and start tape recording CppAD::Independent(x); // a temporary value AD sinh_of_x0 = CppAD::sinh(x[0]); // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::asinh(sinh_of_x0); // create f: x -> y and stop tape recording CppAD::ADFun f(x, y); // check value ok &= NearEqual(y[0] , x0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., eps, eps); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], 1., eps, eps); // use a VecAD::reference object with asinh CppAD::VecAD v(1); AD zero(0); v[zero] = sinh_of_x0; AD result = CppAD::asinh(v[zero]); ok &= NearEqual(result, x0, eps, eps); return ok; } // END C++ cppad-20160000.1/example/pow_int.cpp0000644000175200017650000000415412656321772016254 0ustar coincoin-web// $Id: pow_int.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin pow_int.cpp$$ $spell tan atan $$ $section The Pow Integer Exponent: Example and Test$$ $mindex int$$ $code $verbatim%example/pow_int.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool pow_int(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); } // 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, 1e-10 , 1e-10); } // 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, 1e-10 , 1e-10); w[i] = 0.; } return ok; } // END C++ cppad-20160000.1/example/div.cpp0000644000175200017650000000431012656321772015351 0ustar coincoin-web// $Id: div.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin div.cpp$$ $section AD Binary Division: Example and Test$$ $mindex / divide quotient$$ $code $verbatim%example/div.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool Div(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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), 1e-10 , 1e-10); // 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., 1e-10, 1e-10); // 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., 1e-10, 1e-10); // 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; } // END C++ cppad-20160000.1/example/pow.cpp0000644000175200017650000000561412656321772015404 0ustar coincoin-web/* $Id: pow.cpp 3735 2015-10-01 13:43:46Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin pow.cpp$$ $spell $$ $section The AD Power Function: Example and Test$$ $code $verbatim%example/pow.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool pow(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 2; double x = 0.5; double y = 2.; CPPAD_TESTVECTOR(AD) 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; } // END C++ cppad-20160000.1/example/atanh.cpp0000644000175200017650000000403512656321772015666 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin atanh.cpp$$ $spell tanh atanh $$ $section The AD atanh Function: Example and Test$$ $code $verbatim%example/atanh.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool atanh(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 10 times machine epsilon double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) x(n); x[0] = x0; // declare independent variables and start tape recording CppAD::Independent(x); // a temporary value AD tanh_of_x0 = CppAD::tanh(x[0]); // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::atanh(tanh_of_x0); // create f: x -> y and stop tape recording CppAD::ADFun f(x, y); // check value ok &= NearEqual(y[0] , x0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., eps, eps); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], 1., eps, eps); // use a VecAD::reference object with atanh CppAD::VecAD v(1); AD zero(0); v[zero] = tanh_of_x0; AD result = CppAD::atanh(v[zero]); ok &= NearEqual(result, x0, eps, eps); return ok; } // END C++ cppad-20160000.1/example/sparse_sub_hes.cpp0000644000175200017650000000672012656321772017603 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sparse_sub_hes.cpp$$ $spell $$ $section Sparse Hessian on Subset of Variables: Example and Test$$ $head Purpose$$ This example uses a subset of the sparsity pattern, to compute the Hessian for a subset of the variables, without having to compute the sparsity pattern for the entire function. $head See Also$$ $cref sub_sparse_hes.cpp$$ $code $verbatim%example/sparse_sub_hes.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool sparse_sub_hes(void) { bool ok = true; using CppAD::AD; typedef CppAD::vector< double > d_vector; typedef CppAD::vector< AD > a_vector; typedef CppAD::vector i_vector; typedef CppAD::vector< std::set > s_vector; // domain space vector size_t n = 12; // must be greater than or equal 3; see n_sweep below a_vector a_x(n); for(size_t j = 0; j < n; j++) a_x[j] = AD (0); // declare independent variables and starting recording CppAD::Independent(a_x); // range space vector size_t m = 1; a_vector a_y(m); a_y[0] = 0.0; for(size_t j = 1; j < n; j++) a_y[0] += a_x[j-1] * a_x[j] * a_x[j]; // create f: x -> y and stop tape recording // (without executing zero order forward calculation) CppAD::ADFun f; f.Dependent(a_x, a_y); // sparsity patteren for the sub-set of variables we are computing // the hessian w.r.t. size_t n_sub = 4; s_vector r(n); for(size_t j = 0; j < n_sub; j++) { assert( r[j].empty() ); r[j].insert(j); } // store forward sparsity for J(x) = F^{(1)} (x) * R f.ForSparseJac(n_sub, r); // compute sparsity pattern for H(x) = (S * F)^{(2)} ( x ) * R s_vector s(1); assert( s[0].empty() ); s[0].insert(0); bool transpose = true; s_vector h = f.RevSparseHes(n_sub, s, transpose); // check sparsity pattern for(size_t i = 0; i < n; i++) { std::set check; assert( check.empty() ); if( i <= n_sub ) { if( i == 0 ) check.insert(1); else { check.insert(i-1); if( i < n_sub ) check.insert(i); if( i + 1 < n_sub) check.insert(i+1); } } ok &= h[i] == check; } // set the row and column indices that correspond to lower triangle i_vector row, col; for(size_t i = 0; i < n_sub; i++) { std::set::iterator itr; for(itr = h[i].begin(); itr != h[i].end(); itr++) { if( *itr <= i ) { row.push_back( i ); col.push_back( *itr ); } } } // weighting for the Hessian d_vector w(1); w[0] = 1.0; // compute Hessian CppAD::sparse_hessian_work work; d_vector x(n), hes( row.size() ); for(size_t j = 0; j < n; j++) x[j] = double(j+1); f.SparseHessian(x, w, h, row, col, hes, work); // check the values in the sparse hessian for(size_t ell = 0; ell < row.size(); ell++) { size_t i = row[ell]; size_t j = col[ell]; if( i == j ) ok &= hes[ell] == 2.0 * x[i-1]; else { ok &= j+1 == i; ok &= hes[ell] == 2.0 * x[i]; } ell++; } return ok; } // END C++ cppad-20160000.1/example/interp_retape.cpp0000644000175200017650000000737712656321772017450 0ustar coincoin-web// $Id: interp_retape.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin interp_retape.cpp$$ $spell Retaping retape $$ $section Interpolation With Retaping: Example and Test$$ $mindex interpolate tape retape$$ $head See Also$$ $cref interp_onetape.cpp$$ $pre $$ $code $verbatim%example/interp_retape.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # 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; } } bool interp_retape(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10, 1e-10); // 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, 1e-10, 1e-10); } return ok; } // END C++ cppad-20160000.1/example/jacobian.cpp0000644000175200017650000000543512656321772016346 0ustar coincoin-web// $Id: jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin jacobian.cpp$$ $spell Cpp Jacobian $$ $section Jacobian: Example and Test$$ $mindex Jacobian$$ $code $verbatim%example/jacobian.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // --------------------------------------------------------- // define the template function JacobianCases in empty namespace template bool JacobianCases() { bool ok = true; using CppAD::AD; using CppAD::NearEqual; 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], 1e-10, 1e-10 ); ok &= NearEqual( 2.*x[0]*sin(x[1]), jac[1*n+0], 1e-10, 1e-10 ); ok &= NearEqual( 2.*x[0]*cos(x[1]), jac[2*n+0], 1e-10, 1e-10 ); ok &= NearEqual( x[0] * x[0] *exp(x[1]), jac[0*n+1], 1e-10, 1e-10 ); ok &= NearEqual( x[0] * x[0] *cos(x[1]), jac[1*n+1], 1e-10, 1e-10 ); ok &= NearEqual(-x[0] * x[0] *sin(x[1]), jac[2*n+1], 1e-10, 1e-10 ); 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; } // END C++ cppad-20160000.1/example/check_numeric_type.cpp0000644000175200017650000001030712656321772020432 0ustar coincoin-web// $Id: check_numeric_type.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin check_numeric_type.cpp$$ $section The CheckNumericType Function: Example and Test$$ $mindex check NumericType$$ $code $verbatim%example/check_numeric_type.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include // Chosing a value between 1 and 10 selects a numeric class properity to be // omitted and result in an error message being generated # 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 // computed assignment addition void operator += (const MyType &x) { d += x.d; } # endif # if CppADMyTypeOmit != 8 // computed assignment subtraction void operator -= (const MyType &x) { d -= x.d; } # endif # if CppADMyTypeOmit != 9 // computed assignment multiplication void operator *= (const MyType &x) { d *= x.d; } # endif # if CppADMyTypeOmit != 10 // computed 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; 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 &= CppAD::NearEqual(sum.Double(), b[0].Double(), 1e-10, 1e-10); sum = A[2] * x[0] + A[3] * x[1]; ok &= CppAD::NearEqual(sum.Double(), b[1].Double(), 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/romberg_mul.cpp0000644000175200017650000000510712656321772017106 0ustar coincoin-web// $Id: romberg_mul.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin Rombergmul.cpp$$ $spell Romberg $$ $section One Dimensional Romberg Integration: Example and Test$$ $code $verbatim%example/romberg_mul.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include 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; } }; } 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) / (deg[0]+1); bpow = 1.; apow = 1.; for(i = 0; i <= deg[1]; i++) { bpow *= b[1]; apow *= a[1]; } check *= (bpow - apow) / (deg[1]+1); double step = (b[1] - a[1]) / exp(log(2.)*(n[1]-1)); double spow = 1; for(k = 0; k <= n[1]; k++) { spow = spow * step * step; double bnd = 3 * (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; } // END C++ cppad-20160000.1/example/unary_plus.cpp0000644000175200017650000000356312656321772017001 0ustar coincoin-web// $Id: unary_plus.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin unary_plus.cpp$$ $spell Cpp cstddef $$ $section AD Unary Plus Operator: Example and Test$$ $code $verbatim%example/unary_plus.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool UnaryPlus(void) { 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]); return ok; } // END C++ cppad-20160000.1/example/erf.cpp0000644000175200017650000000503112656321772015344 0ustar coincoin-web// $Id: erf.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin erf.cpp$$ $spell tan erf $$ $section The AD erf Function: Example and Test$$ $code $verbatim%example/erf.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include bool Erf(void) { 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.52050; ok &= NearEqual(ay[0] , erf_x0, 0., 4e-4); # if CPPAD_USE_CPLUSPLUS_2011 ok &= NearEqual(ay[0] , erf_x0, 0., 1e-5); # 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::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); return ok; } // END C++ cppad-20160000.1/example/print_for.cpp0000644000175200017650000000416512656321772016601 0ustar coincoin-web// $Id: print_for.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin print_for_string.cpp$$ $spell Cpp $$ $section Print During Zero Order Forward Mode: Example and Test$$ $code $verbatim%example/print_for.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { 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"; // 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) 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"; return ok; } // END C++ cppad-20160000.1/example/for_one.cpp0000644000175200017650000000475012656321772016226 0ustar coincoin-web// $Id: for_one.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin for_one.cpp$$ $spell Cpp $$ $section First Order Partial Driver: Example and Test$$ $code $verbatim%example/for_one.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // ------------------------------------------------------- // define the template function ForOneCases in empty namespace template bool ForOneCases() { bool ok = true; using CppAD::AD; using CppAD::NearEqual; 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]), 1e-10, 1e-10 ); // for y[0] ok &= NearEqual( dy[1], sin(x[1]), 1e-10, 1e-10 ); // for y[1] ok &= NearEqual( dy[2], cos(x[1]), 1e-10, 1e-10 ); // 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]), 1e-10, 1e-10 ); ok &= NearEqual( dy[1], x[0]*cos(x[1]), 1e-10, 1e-10 ); ok &= NearEqual( dy[2], -x[0]*sin(x[1]), 1e-10, 1e-10 ); 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; } // END C++ cppad-20160000.1/example/mul_level_adolc_ode.cpp0000644000175200017650000002553212656321772020555 0ustar coincoin-web/* $Id: mul_level_adolc_ode.cpp 3738 2015-10-05 13:16:50Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin mul_level_adolc_ode.cpp$$ $spell hpp Taylor Cpp const std AdolcDir adouble Vec $$ $section Taylor's Ode Solver: A Multi-Level Adolc Example and Test$$ $head Purpose$$ This is a realistic example using two levels of AD; see $cref mul_level$$. The first level uses Adolc's $code adouble$$ type to tape the solution of an ordinary differential equation. This solution is then differentiated with respect to a parameter vector. The second level uses CppAD's type $code AD$$ to take derivatives during the solution of the differential equation. These derivatives are used in the application of Taylor's method to the solution of the ODE. 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 $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) \] $$ $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$$ 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} \] $$ 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)$$. $head base_adolc.hpp$$ The file $cref base_adolc.hpp$$ is implements the $cref/Base type requirements/base_require/$$ where $icode Base$$ is $code adolc$$. $head Memory Management$$ Adolc uses raw memory arrays that depend on the number of dependent and independent variables. The $cref thread_alloc$$ memory management utilities $cref/create_array/ta_create_array/$$ and $cref/delete_array/ta_delete_array/$$ are used to manage this memory allocation. $head Configuration Requirement$$ This example will be compiled and tested provided that the value $cref ipopt_prefix$$ is specified on the $cref cmake$$ command line. $head Source$$ $code $verbatim%example/mul_level_adolc_ode.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end -------------------------------------------------------------------------- */ // BEGIN C++ # include # include # include // definitions not in Adolc distribution and required to use CppAD::AD # include # include // ========================================================================== namespace { // BEGIN empty namespace // define types for each level typedef adouble a1type; typedef CppAD::AD a2type; // ------------------------------------------------------------------------- // class definition for C++ function object that defines ODE class Ode { private: // copy of a that is set by constructor and used by g(y) CPPAD_TESTVECTOR(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 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(); // 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 lenght n (or greater) in double double* x = thread_alloc::create_array(n, capacity); // the vector x with lenght n in a1type CPPAD_TESTVECTOR(a1type) a1x(n); for(i = 0; i < n; i++) 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; } // END C++ cppad-20160000.1/example/azmul.cpp0000644000175200017650000000424512656321772015726 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin azmul.cpp$$ $spell $$ $section AD Absolute Zero Multiplication: Example and Test$$ $code $verbatim%example/azmul.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool azmul(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double inf = std::numeric_limits::infinity(); double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 2; double x = 0.5; double y = 2.0; CPPAD_TESTVECTOR(AD) axy(n); axy[0] = x; axy[1] = y; // declare independent variables and start tape recording CppAD::Independent(axy); // range space vector size_t m = 5; CPPAD_TESTVECTOR(AD) az(m); az[0] = CppAD::azmul(axy[0], axy[1]); // azmul(variable, variable) az[1] = CppAD::azmul(axy[0], inf); // azmul(variable, parameter=inf) az[2] = CppAD::azmul(axy[0], 3.0); // azmul(variable, parameter=3.0) az[3] = CppAD::azmul(0.0, axy[1]); // azmul(parameter=0.0, variable) az[4] = CppAD::azmul(4.0, axy[1]); // azmul(parameter=4.0, variable) // create f: axy -> az and stop tape recording CppAD::ADFun f(axy, az); // check value when x is not zero ok &= NearEqual(az[0] , x * y, eps, eps); ok &= az[1] == inf; ok &= NearEqual(az[2] , x * 3.0, eps, eps); ok &= az[3] == 0.0; ok &= NearEqual(az[4] , 4.0 * y, eps, eps); // check value x is zero and y is infinity CPPAD_TESTVECTOR(double) xy(n), z(m); xy[0] = 0.0; xy[1] = inf; z = f.Forward(0, xy); ok &= z[0] == 0.0; ok &= z[1] == 0.0; ok &= z[2] == 0.0; ok &= z[3] == 0.0; ok &= z[4] == inf; return ok; } // END C++ cppad-20160000.1/example/lu_solve.cpp0000644000175200017650000000517712656321772016433 0ustar coincoin-web// $Id: lu_solve.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin lu_solve.cpp$$ $spell Geq Cpp Lu $$ $section LuSolve With Complex Arguments: Example and Test$$ $code $verbatim%example/lu_solve.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include // for CppAD::LuSolve # include // for CppAD::NearEqual # include // for CppAD::vector # include // for std::complex typedef std::complex 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 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(j, 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; } // END C++ cppad-20160000.1/example/index_sort.cpp0000644000175200017650000000453412656321772016755 0ustar coincoin-web// $Id: index_sort.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin index_sort.cpp$$ $section Index Sort: Example and Test$$ $mindex index_sort$$ $code $verbatim%example/index_sort.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include # include 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] ]; } return ok; } } bool index_sort(void) { 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 >(); return ok; } // END C++ cppad-20160000.1/example/cppad_vector.cpp0000644000175200017650000000577112656321772017254 0ustar coincoin-web// $Id: cppad_vector.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin cppad_vector.cpp$$ $spell Cpp $$ $section CppAD::vector Template Class: Example and Test$$ $mindex vector CppAD$$ $code $verbatim%example/cppad_vector.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include // sstream and string are used to test output operation # include bool CppAD_vector(void) { bool ok = true; using CppAD::vector; // so can use vector instead of CppAD::vector 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; } // END C++ cppad-20160000.1/example/ode_err_control.cpp0000644000175200017650000000721712656321772017757 0ustar coincoin-web// $Id: ode_err_control.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ode_err_control.cpp$$ $spell $$ $section OdeErrControl: Example and Test$$ 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) & = & - \alpha X_0 (t) \\ X_1^{(1)} (t) & = & 1 / X_0 (t) \end{array} \] $$ It follows that $latex \[ \begin{array}{rcl} X_0 (t) & = & \exp ( - \alpha t ) \\ X_1 (t) & = & [ \exp( \alpha t ) - 1 ] / \alpha \end{array} \] $$ This example tests OdeErrControl using the relations above. $head Nan$$ Note that $latex X_0 (t) > 0$$ for all $latex t$$ and that the ODE goes through a singularity between $latex X_0 (t) > 0$$ and $latex X_0 (t) < 0$$. If $latex X_0 (t) < 0$$, we return $code nan$$ in order to inform $code OdeErrControl$$ that its is taking to large a step. $code $verbatim%example/ode_err_control.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include // for quiet_NaN # include // for size_t # include // for exp # include // CppAD::OdeErrControl # include // CppAD::NearEqual # include // CppAD::vector # include // CppAD::Runge45 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; } }; } bool OdeErrControl(void) { bool ok = true; // initial return value 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); return ok; } // END C++ cppad-20160000.1/example/sqrt.cpp0000644000175200017650000000404312656321772015563 0ustar coincoin-web// $Id: sqrt.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sqrt.cpp$$ $spell sqrt $$ $section The AD sqrt Function: Example and Test$$ $code $verbatim%example/sqrt.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool Sqrt(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // 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, 1e-10, 1e-10); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], check, 1e-10, 1e-10); // 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, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/num_limits.cpp0000644000175200017650000000521412656321772016753 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin num_limits.cpp$$ $spell $$ $section Numeric Limits: Example and Test$$ $code $verbatim%example/num_limits.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # ifdef _MSC_VER // Supress Microsoft compiler warning about possible loss of precision, // in the constructors (when converting to std::complex) // Float one = 1 // Float two = 2 // 1 and 2 are small enough so no loss of precision when converting to float. # pragma warning(disable:4244) # endif # include # include namespace { typedef CppAD::AD Float; // // ----------------------------------------------------------------- bool check_epsilon(void) { bool ok = true; Float eps = CppAD::numeric_limits::epsilon(); Float eps2 = eps / 2.0; Float check = 1.0 + eps; ok &= 1.0 != check; check = 1.0 + eps2; ok &= 1.0 == check; return ok; } // ----------------------------------------------------------------- bool check_min(void) { bool ok = true; Float min = CppAD::numeric_limits::min(); Float eps = CppAD::numeric_limits::epsilon(); // Float match = (min / 100.) * 100.; ok &= abs(match / min - 1.0) > 3.0 * eps; // match = (min * 100.) / 100.; ok &= abs(match / min - 1.0) < 3.0 * eps; return ok; } // ----------------------------------------------------------------- bool check_max(void) { bool ok = true; Float max = CppAD::numeric_limits::max(); Float eps = CppAD::numeric_limits::epsilon(); // Float match = (max * 100.) / 100.; ok &= abs(match / max - 1.0) > 3.0 * eps; // match = (max / 100.) * 100.; ok &= abs(match / max - 1.0) < 3.0 * eps; return ok; } // ----------------------------------------------------------------- bool check_nan(void) { bool ok = true; Float nan = CppAD::numeric_limits::quiet_NaN(); ok &= nan != nan; return ok; } } bool num_limits(void) { bool ok = true; ok &= check_epsilon(); ok &= check_min(); ok &= check_max(); ok &= check_nan(); return ok; } // END C++ cppad-20160000.1/example/div_eq.cpp0000644000175200017650000000435112656321772016043 0ustar coincoin-web// $Id: div_eq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin div_eq.cpp$$ $section AD Computed Assignment Division: Example and Test$$ $mindex /= divide assign plus add$$ $code $verbatim%example/div_eq.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool DivEq(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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 computed 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), 1e-10 , 1e-10); ok &= NearEqual(y[1] , y[0], 1e-10 , 1e-10); // 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., 1e-10, 1e-10); ok &= NearEqual(dy[1], 1./8., 1e-10, 1e-10); // 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., 1e-10, 1e-10); // 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; } // END C++ cppad-20160000.1/example/asin.cpp0000644000175200017650000000407612656321772015532 0ustar coincoin-web/* $Id: asin.cpp 3675 2015-05-05 14:26:18Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin asin.cpp$$ $spell sin asin $$ $section The AD asin Function: Example and Test$$ $code $verbatim%example/asin.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool asin(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 10 times machine epsilon double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; 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; } // END C++ cppad-20160000.1/example/thread_alloc.cpp0000644000175200017650000001515412656321772017220 0ustar coincoin-web// $Id: thread_alloc.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin thread_alloc.cpp$$ $spell pthread openmp $$ $section Fast Multi-Threading Memory Allocator: Example and Test$$ $mindex openmp allocation pthread boost multi-thread$$ $code $verbatim%example/thread_alloc.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include # include namespace { // Begin empty namespace bool raw_allocate(void) { bool ok = true; using CppAD::thread_alloc; size_t thread; // check that no memory is initilaly inuse 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 &= ! 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 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); // free the memory for use by this thread thread_alloc::free_available(thread); // check that the tests have not held onto memory ok &= ! CppAD::memory_leak(); 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::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(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(size_min, size_out); // 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; // 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; } // END C++ cppad-20160000.1/example/cosh.cpp0000644000175200017650000000402012656321772015521 0ustar coincoin-web// $Id: cosh.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin cosh.cpp$$ $spell $$ $section The AD cosh Function: Example and Test$$ $code $verbatim%example/cosh.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool Cosh(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // 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, 1e-10, 1e-10); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], check, 1e-10, 1e-10); // 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, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/sparsity_sub.cpp0000644000175200017650000000535212656321772017325 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sparsity_sub.cpp$$ $spell Jac Jacobian Hes $$ $section Sparsity Patterns For a Subset of Variables: Example and Test$$ $head See Also$$ $cref sparse_sub_hes.cpp$$, $cref sub_sparse_hes.cpp$$. $head ForSparseJac$$ The routine $cref ForSparseJac$$ is used to compute the sparsity for both the full Jacobian (see $icode s$$) and a subset of the Jacobian (see $icode s2$$). $head RevSparseHes$$ The routine $cref RevSparseHes$$ is used to compute both sparsity for both the full Hessian (see $icode h$$) and a subset of the Hessian (see $icode h2$$). $code $verbatim%example/sparsity_sub.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool sparsity_sub(void) { // C++ source code bool ok = true; // using std::cout; using CppAD::vector; using CppAD::AD; using CppAD::vectorBool; size_t n = 4; size_t m = n-1; vector< AD > ax(n), ay(m); for(size_t j = 0; j < n; j++) ax[j] = double(j+1); CppAD::Independent(ax); for(size_t i = 0; i < m; i++) ay[i] = (ax[i+1] - ax[i]) * (ax[i+1] - ax[i]); CppAD::ADFun f(ax, ay); // Evaluate the full Jacobian sparsity pattern for f vectorBool r(n * n), s(m * n); for(size_t j = 0 ; j < n; j++) { for(size_t i = 0; i < n; i++) r[i * n + j] = (i == j); } s = f.ForSparseJac(n, r); // evaluate the sparsity for the Hessian of f_0 + ... + f_{m-1} vectorBool t(m), h(n * n); for(size_t i = 0; i < m; i++) t[i] = true; h = f.RevSparseHes(n, t); // evaluate the Jacobian sparsity pattern for first n/2 components of x size_t n2 = n / 2; vectorBool r2(n * n2), s2(m * n2); for(size_t j = 0 ; j < n2; j++) { for(size_t i = 0; i < n; i++) r2[i * n2 + j] = (i == j); } s2 = f.ForSparseJac(n2, r2); // evaluate the sparsity for the subset of Hessian of // f_0 + ... + f_{m-1} where first partial has only first n/2 components vectorBool h2(n2 * n); h2 = f.RevSparseHes(n2, t); // check sparsity pattern for Jacobian for(size_t i = 0; i < m; i++) { for(size_t j = 0; j < n2; j++) ok &= s2[i * n2 + j] == s[i * n + j]; } // check sparsity pattern for Hessian for(size_t i = 0; i < n2; i++) { for(size_t j = 0; j < n; j++) ok &= h2[i * n + j] == h[i * n + j]; } return ok; } // END C++ cppad-20160000.1/example/unary_minus.cpp0000644000175200017650000000357412656321772017153 0ustar coincoin-web// $Id: unary_minus.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin unary_minus.cpp$$ $spell Cpp cstddef $$ $section AD Unary Minus Operator: Example and Test$$ $code $verbatim%example/unary_minus.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool UnaryMinus(void) { 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]); return ok; } // END C++ cppad-20160000.1/example/capacity_order.cpp0000644000175200017650000000676112656321772017573 0ustar coincoin-web// $Id: capacity_order.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin capacity_order.cpp$$ $spell Taylor $$ $section Controlling Taylor Coefficient Memory Allocation: Example and Test$$ $mindex capacity_order$$ $code $verbatim%example/capacity_order.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { bool test(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; using CppAD::thread_alloc; // domain space vector size_t n(1), m(1); CPPAD_TESTVECTOR(AD) ax(n), ay(n); // declare independent variables and start tape recording ax[0] = 1.0; CppAD::Independent(ax); // Set y = x^3, use enough variables so more that the minimal amount // 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); 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; } // END C++ cppad-20160000.1/example/complex_poly.cpp0000644000175200017650000000402712656321772017306 0ustar coincoin-web// $Id: complex_poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin complex_poly.cpp$$ $spell Cpp $$ $section Complex Polynomial: Example and Test$$ $mindex polynomial$$ $head Poly$$ Select this link to view specifications for $cref Poly$$: $code $verbatim%example/complex_poly.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool complex_poly(void) { 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(i, 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; } // END C++ cppad-20160000.1/example/ad_assign.cpp0000644000175200017650000000245412656321772016526 0ustar coincoin-web// $Id: ad_assign.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ad_assign.cpp$$ $spell Cpp $$ $section AD Assignment: Example and Test$$ $mindex assign object$$ $code $verbatim%example/ad_assign.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include 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 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; } // END C++ cppad-20160000.1/example/ad_ctor.cpp0000644000175200017650000000260112656321772016203 0ustar coincoin-web// $Id: ad_ctor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ad_ctor.cpp$$ $spell Cpp $$ $section AD Constructors: Example and Test$$ $mindex constructor object$$ $code $verbatim%example/ad_ctor.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include 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 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; } // END C++ cppad-20160000.1/example/optimize.cpp0000644000175200017650000000656212656321772016442 0ustar coincoin-web// $Id: optimize.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin optimize.cpp$$ $section ADFun Operation Sequence Optimization: Example and Test$$ $mindex optimize$$ $code $verbatim%example/optimize.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { template void fun( const VectorFloat& x, VectorFloat& y, size_t& n_var, size_t& n_opt ) { typedef typename VectorFloat::value_type Float; // One for each independent variable and one phantom variable at // the beginning of operation sequence. n_var = 1 + x.size(); // One operator for each independent variable and one to mark // beginning of operation sequence. n_opt = 1 + x.size(); // Create a variable that is is only used in the comparision operation // (was optimized out until 2015-01-12). Float a = 1. / x[0]; n_var += 1; n_opt += 1; // Create a variable that is used by the result Float b = x[0] * 5.; n_var += 1; n_opt += 1; // only one variable created for this comparison operation // but the value depends on which branch is taken. Float c; if( a < x[0] ) c = 2.0 * b; else c = 3.0 * b; n_var += 1; n_opt += 1; // Create a variable that is optimized out because it // will always have the same value as b Float d = 5. * x[0]; n_var += 1; n_opt += 0; // Create three variables that will be converted to one // cumulative summation. Note that a is not connected to // the result y (in the operation sequence). y[0] = 1.0 + b + c + d; n_var += 3; n_opt += 1; } } bool optimize(void) { bool ok = true; using CppAD::AD; // domain space vector size_t n = 1; CPPAD_TESTVECTOR(AD) ax(n); ax[0] = 0.5; // declare independent variables and start tape recording CppAD::Independent(ax); // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); size_t n_var, n_opt; fun(ax, ay, n_var, n_opt); // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); ok &= (f.size_var() == n_var); // Optimize the operation sequence f.optimize(); ok &= (f.size_var() == n_opt); // Check result for a zero order calculation for a different x, // where the result of the comparison is he same. CPPAD_TESTVECTOR(double) x(n), y(m), check(m); x[0] = 0.75; y = f.Forward(0, x); ok &= f.CompareChange() == 0; fun(x, check, n_var, n_opt); ok &= (y[0] == check[0]); // Check case where result of the comparision is differnent x[0] = 2.0; y = f.Forward(0, x); ok &= f.CompareChange() == 1; fun(x, check, n_var, n_opt); ok &= (y[0] != check[0]); // re-tape at new x value, re-optimize, and re-evaluate forward ax[0] = x[0]; CppAD::Independent(ax); fun(ax, ay, n_var, n_opt); f.Dependent(ax, ay); f.optimize(); y = f.Forward(0, x); ok &= f.CompareChange() == 0; ok &= (y[0] == check[0]); return ok; } // END C++ cppad-20160000.1/example/par_var.cpp0000644000175200017650000000371412656321772016230 0ustar coincoin-web// $Id: par_var.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin par_var.cpp$$ $section AD Parameter and Variable Functions: Example and Test$$ $code $verbatim%example/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] = abs(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++ cppad-20160000.1/example/value.cpp0000644000175200017650000000326112656321772015707 0ustar coincoin-web// $Id: value.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin value.cpp$$ $spell Cpp cstddef $$ $section Convert From AD to its Base Type: Example and Test$$ $mindex Value record$$ $code $verbatim%example/value.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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.); return ok; } // END C++ cppad-20160000.1/example/sign.cpp0000644000175200017650000000372612656321772015541 0ustar coincoin-web// $Id: sign.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sign.cpp$$ $spell $$ $section Sign Function: Example and Test$$ $code $verbatim%example/sign.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include 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) 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; } // END C++ cppad-20160000.1/example/jac_minor_det.cpp0000644000175200017650000000412712656321773017373 0ustar coincoin-web// $Id: jac_minor_det.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin jac_minor_det.cpp$$ $spell Cpp $$ $section Gradient of Determinant Using Expansion by Minors: Example and Test$$ $mindex minors$$ $code $verbatim%example/jac_minor_det.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include typedef std::complex Complex; typedef CppAD::AD 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 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) 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; } // END C++ cppad-20160000.1/example/reverse_one.cpp0000644000175200017650000000523712656321773017115 0ustar coincoin-web// $Id: reverse_one.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin reverse_one.cpp$$ $spell Cpp $$ $section First Order Reverse Mode: Example and Test$$ $code $verbatim%example/reverse_one.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // ---------------------------------------------------------- // define the template function reverse_one_cases in empty namespace template bool reverse_one_cases(void) { bool ok = true; 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[0] * X[1]; // create f : X -> Y and stop recording CppAD::ADFun f(X, Y); // 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.*X[0]*X[1], 1e-10, 1e-10); ok &= NearEqual(dw[1] , X[0]*X[0], 1e-10, 1e-10); // 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], 1e-10, 1e-10); // 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], 1e-10, 1e-10); ok &= NearEqual(dw[1] , x[0]*x[0], 1e-10, 1e-10); 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; } // END C++ cppad-20160000.1/example/cond_exp.cpp0000644000175200017650000000636212656321773016400 0ustar coincoin-web// $Id: cond_exp.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin cond_exp.cpp$$ $spell Cpp cstddef CondExp $$ $section Conditional Expressions: Example and Test$$ $mindex CondExp$$ $head Description$$ Use $code CondExp$$ to compute $latex \[ 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$$ ) with out having to re-tape; i.e., using only one $cref ADFun$$ object. Note that $latex x_j \log ( x_j ) \rightarrow 0 $$ as $latex x_j \downarrow 0$$ and we need to handle the case $latex x_j = 0$$ in a special way to avoid multiplying zero by infinity. $code $verbatim%example/cond_exp.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool CondExp(void) { bool ok = true; using CppAD::isnan; using CppAD::AD; using CppAD::NearEqual; using CppAD::log; using CppAD::abs; 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; } // END C++ cppad-20160000.1/example/vector_bool.cpp0000644000175200017650000000541312656321773017112 0ustar coincoin-web// $Id: vector_bool.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin vector_bool.cpp$$ $spell Cpp bool $$ $section CppAD::vectorBool Class: Example and Test$$ $mindex bool vectorBool CppAD$$ $code $verbatim%example/vector_bool.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include // sstream and string are used to test output operation # include 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; } // END C++ cppad-20160000.1/example/sinh.cpp0000644000175200017650000000402612656321773015535 0ustar coincoin-web// $Id: sinh.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sinh.cpp$$ $spell sinh $$ $section The AD sinh Function: Example and Test$$ $code $verbatim%example/sinh.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool Sinh(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // 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, 1e-10, 1e-10); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], check, 1e-10, 1e-10); // 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, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/check_for_nan.cpp0000644000175200017650000000601012656321773017346 0ustar coincoin-web/* $Id: check_for_nan.cpp 3753 2015-11-24 16:39:04Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin check_for_nan.cpp$$ $section ADFun Checking For Nan: Example and Test$$ $code $verbatim%example/check_for_nan.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # 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; } } 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); # 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 varialbe index that is nan pattern = "index = "; start = msg.find(pattern) + pattern.size(); number = ""; for(size_t i = start; msg[i] != '\n'; i++) number += msg[i]; size_t index = std::atoi(number.c_str()); ok &= index == 1; // get the name of the file pattern = "file_name = "; start = msg.find(pattern) + pattern.size(); string file_name; for(size_t i = start; msg[i] != '\n'; i++) file_name += msg[i]; // get and check independent variable vector that resulted in the nan CppAD::vector vec(vector_size); CppAD::get_check_for_nan(vec, file_name); for(size_t i = 0; i < vector_size; i++) ok &= vec[i] == x[i]; } // now do calculation without an exception f.check_for_nan(false); y = f.Forward(0, x); ok &= CppAD::NearEqual(y[0], std::sqrt(x[0]), eps, eps); ok &= CppAD::isnan( y[1] ); return ok; } // END C++ cppad-20160000.1/example/forward_dir.cpp0000644000175200017650000000561612656321773017104 0ustar coincoin-web// $Id: forward_dir.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin forward_dir.cpp$$ $spell Cpp $$ $section Forward Mode: Example and Test of Multiple Directions$$ $mindex orders order$$ $code $verbatim%example/forward_dir.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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; } // END C++ cppad-20160000.1/example/log10.cpp0000644000175200017650000000404212656321773015514 0ustar coincoin-web// $Id: log10.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin log10.cpp$$ $spell log $$ $section The AD log10 Function: Example and Test$$ $code $verbatim%example/log10.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool log10(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., 1e-10, 1e-10); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], 1., 1e-10, 1e-10); // 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, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/bool_fun.cpp0000644000175200017650000000344312656321773016401 0ustar coincoin-web// $Id: bool_fun.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin bool_fun.cpp$$ $spell bool Geq Cpp $$ $section AD Boolean Functions: Example and Test$$ $mindex bool$$ $code $verbatim%example/bool_fun.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include // define abbreviation for double precision complex 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) } bool BoolFun(void) { bool ok = true; CppAD::AD x = Complex(1., 0.); CppAD::AD y = Complex(1., 1.); ok &= IsReal(x); ok &= ! AbsGeq(x, y); return ok; } // END C++ cppad-20160000.1/example/numeric_type.cpp0000644000175200017650000000515312656321773017301 0ustar coincoin-web// $Id: numeric_type.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin numeric_type.cpp$$ $section The NumericType: Example and Test$$ $mindex NumericType$$ $code $verbatim%example/numeric_type.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include 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; } // computed assignment addition void operator += (const MyType &x) { d += x.d; } // computed assignment subtraction void operator -= (const MyType &x) { d -= x.d; } // computed assignment multiplication void operator *= (const MyType &x) { d *= x.d; } // computed 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 > >(); return ok; } // END C++ cppad-20160000.1/example/runge45_2.cpp0000644000175200017650000000733212656321773016311 0ustar coincoin-web// $Id: runge45_2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin runge45_2.cpp$$ $spell 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) \] $$ for $latex j = 0 , \ldots , n-1$$. It follows that $latex \[ \begin{array}{rcl} 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} \end{array} \right. \end{array} \] $$ For a fixed $latex t_f$$, we can use $cref Runge45$$ to define $latex f : \B{R} \rightarrow \B{R}^n$$ as an approximation for $latex f(b) = X(b, t_f )$$. We can then compute $latex f^{(1)} (b)$$ which is an approximation for $latex \[ \partial_b X(b, t_f ) = \sum_{k=0}^j t_f^k / k ! \] $$ $code $verbatim%example/runge45_2.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include // for size_t # include // for machine epsilon # include // for all of CppAD 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]; } }; } bool runge_45_2(void) { typedef CppAD::AD 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 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; } // END C++ cppad-20160000.1/example/to_string.cpp0000644000175200017650000000515612656321773016611 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin to_string.cpp$$ $section to_string: Example and Test$$ $code $verbatim%example/to_string.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ // Examples with fundamental types # include namespace { template Integer string2int(const std::string& s) { Integer result = 0; size_t index = 0; if( s[0] == '-' ) ++index; while( index < s.size() ) result = 10 * result + Integer( s[index++] - '0'); if( s[0] == '-' ) return - result; return result; } template bool integer(void) { bool ok = true; // Integer max = std::numeric_limits::max(); std::string s = CppAD::to_string(max); Integer check = string2int(s); ok &= max == check; // Integer min = std::numeric_limits::min(); s = CppAD::to_string(min); check = string2int(s); ok &= min == check; // return ok; } template bool floating(void) { bool ok = true; Float eps = std::numeric_limits::epsilon(); Float pi = 4.0 * std::atan(1.); // std::string s = CppAD::to_string( pi ); Float check = std::atof( s.c_str() ); ok &= std::fabs( check - pi ) <= 2.0 * eps; // return ok; } } // Examples with AD types # include namespace { template bool ad_floating(void) { bool ok = true; Base eps = std::numeric_limits::epsilon(); Base pi = 4.0 * std::atan(1.); // std::string s = CppAD::to_string( CppAD::AD( pi ) ); Base check = std::atof( s.c_str() ); ok &= std::fabs( check - pi ) <= 2.0 * eps; // return ok; } } // Test driver bool to_string(void) { bool ok = true; ok &= integer(); ok &= integer(); ok &= integer(); # if CPPAD_USE_CPLUSPLUS_2011 ok &= integer(); # endif // ok &= floating(); ok &= floating(); ok &= floating(); // ok &= ad_floating(); ok &= ad_floating(); // return ok; } // END C++ cppad-20160000.1/example/atan.cpp0000644000175200017650000000376312656321773015526 0ustar coincoin-web// $Id: atan.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin atan.cpp$$ $spell tan atan $$ $section The AD atan Function: Example and Test$$ $code $verbatim%example/atan.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool atan(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., 1e-10, 1e-10); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], 1., 1e-10, 1e-10); // 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, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/sub_eq.cpp0000644000175200017650000000435112656321773016053 0ustar coincoin-web// $Id: sub_eq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sub_eq.cpp$$ $section AD Computed Assignment Subtraction: Example and Test$$ $mindex -= subtract assign plus add$$ $code $verbatim%example/sub_eq.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool SubEq(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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 computed 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), 1e-10 , 1e-10); ok &= NearEqual(y[1] , y[0], 1e-10 , 1e-10); // 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., 1e-10, 1e-10); ok &= NearEqual(dy[1], 2., 1e-10, 1e-10); // 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., 1e-10, 1e-10); // 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; } // END C++ cppad-20160000.1/example/check_simple_vector.cpp0000644000175200017650000001047212656321773020606 0ustar coincoin-web// $Id: check_simple_vector.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin check_simple_vector.cpp$$ $section The CheckSimpleVector Function: Example and Test$$ $mindex check SimpleVector$$ $code $verbatim%example/check_simple_vector.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include // Chosing a value between 1 and 9 selects a simple vector properity to be // omitted and result in an error message being generated # define CppADMyVectorOmit 0 // ------------------------------------------------------------------------- // example class used for non-constant elements (different from Scalar) template 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 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 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 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; } } 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 v(n); v[0] = 1.; v[1] = 2.; MyVector r = Sscal(a, v); ok &= (r[0] == 3.); ok &= (r[1] == 6.); return ok; } // END C++ cppad-20160000.1/example/sub.cpp0000644000175200017650000000423612656321773015370 0ustar coincoin-web// $Id: sub.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sub.cpp$$ $section AD Binary Subtraction: Example and Test$$ $mindex - subtract minus$$ $code $verbatim%example/sub.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool Sub(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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., 1e-10 , 1e-10); // 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., 1e-10, 1e-10); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], -1., 1e-10, 1e-10); // 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; } // END C++ cppad-20160000.1/example/mul_eq.cpp0000644000175200017650000000436612656321773016065 0ustar coincoin-web// $Id: mul_eq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin mul_eq.cpp$$ $section AD Computed Assignment Multiplication: Example and Test$$ $mindex *= multiply assign plus add$$ $code $verbatim%example/mul_eq.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool MulEq(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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 computed assignment // create f: x -> y and stop tape recording CppAD::ADFun f(x, y); // check value ok &= NearEqual(y[0] , x0*2.*4.*x0, 1e-10 , 1e-10); ok &= NearEqual(y[1] , y[0], 1e-10 , 1e-10); // 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, 1e-10, 1e-10); ok &= NearEqual(dy[1], 8.*2.*x0, 1e-10, 1e-10); // 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, 1e-10, 1e-10); // 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; } // END C++ cppad-20160000.1/example/bender_quad.cpp0000644000175200017650000001127412656321773017050 0ustar coincoin-web// $Id: bender_quad.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin bender_quad.cpp$$ $spell argmin $$ $section BenderQuad: Example and Test$$ $mindex BenderQuad$$ Define $latex F : \B{R} \times \B{R} \rightarrow \B{R}$$ by $latex \[ F(x, y) = \frac{1}{2} \sum_{i=1}^N [ y * \sin ( x * t_i ) - z_i ]^2 \] $$ where $latex z \in \B{R}^N$$ is a fixed vector. It follows that $latex \[ \begin{array}{rcl} \partial_y F(x, y) & = & \sum_{i=1}^N [ y * \sin ( x * t_i ) - z_i ] \sin( x * t_i ) \\ \partial_y \partial_y F(x, y) & = & \sum_{i=1}^N \sin ( x t_i )^2 \end{array} \] $$ Furthermore if we define $latex Y(x)$$ as the argmin of $latex F(x, y)$$ with respect to $latex y$$, $latex \[ \begin{array}{rcl} Y(x) & = & y - [ \partial_y \partial_y F(x, y) ]^{-1} \partial_y F[x, y] \\ & = & \left. \sum_{i=1}^N z_i \sin ( x t_i ) \right/ \sum_{i=1}^N z_i \sin ( x * t_i )^2 \end{array} \] $$ $code $verbatim%example/bender_quad.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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; } } 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); return ok; } // END C++ cppad-20160000.1/example/rosen_34.cpp0000644000175200017650000001101412656321773016223 0ustar coincoin-web// $Id: rosen_34.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin rosen_34.cpp$$ $spell 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} \] $$ for $latex i = 1 , \ldots , n-1$$. It follows that $latex \[ \begin{array}{rclr} X_i(0) & = & 0 & {\rm for \; all \;} i \\ X_i ' (t) & = & 1 & {\rm if \;} i = 0 \\ X_i '(t) & = & (i+1) t^i = (i+1) X_{i-1} (t) & {\rm if \;} i > 0 \end{array} \] $$ The example tests Rosen34 using the relations above: $code $verbatim%example/rosen_34.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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.; } } private: const bool use_x; }; } bool Rosen34(void) { bool ok = true; // initial return value size_t i; // temporary indices 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 &= CppAD::NearEqual(xf[i], check, 1e-10, 1e-10); // 3rd order method is exact for i < 3 if( i < 3 ) ok &= (e[i] <= 1e-10); // check value for next i check *= tf; } } return ok; } // END C++ cppad-20160000.1/example/mul_level.cpp0000644000175200017650000000763512656321773016571 0ustar coincoin-web/* $Id: mul_level.cpp 3735 2015-10-01 13:43:46Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin mul_level.cpp$$ $spell Adolc adouble CppAD abs $$ $section Multiple Level of AD: Example and Test$$ $head Purpose$$ In this example, we use $code AD< AD >$$ (level two taping), the compute values of the function $latex f : \B{R}^n \rightarrow \B{R}$$ where $latex \[ 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 $latex \[ f^{(1)} (x) * v = x_0 v_0 + \cdots + x_{n-1} v_{n-1} \] $$. where $latex v \in \B{R}^n$$. We then use $code double$$ (no taping) to compute $latex \[ \frac{d}{dx} \left[ f^{(1)} (x) * v \right] = v \] $$ This is only meant as an example of multiple levels of taping. 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 \] $$ The example $cref mul_level_adolc.cpp$$ computes the same values using Adolc's type $code adouble$$ and CppAD's type $code AD$$. $head Source$$ $code $verbatim%example/mul_level.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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]; return .5 * sum; } } bool mul_level(void) { 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); for(j = 0; j < n; j++) ok &= CppAD::NearEqual(dw[j], a1v[j], eps, eps); return ok; } // END C++ cppad-20160000.1/example/nan.cpp0000644000175200017650000000252512656321773015352 0ustar coincoin-web// $Id: nan.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin nan.cpp$$ $section nan: Example and Test$$ $code $verbatim%example/nan.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include bool nan(void) { 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); // check that nan is not equal to itself ok &= (double_nan != double_nan); return ok; } // END C++ cppad-20160000.1/example/rev_one.cpp0000644000175200017650000000507012656321773016231 0ustar coincoin-web// $Id: rev_one.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin rev_one.cpp$$ $spell Cpp $$ $section First Order Derivative Driver: Example and Test$$ $code $verbatim%example/rev_one.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // ------------------------------------------------------- // define the template function RevOneCases in empty namespace template bool RevOneCases() { bool ok = true; using CppAD::AD; using CppAD::NearEqual; 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]), 1e-10, 1e-10 ); // w.r.t x[0] ok &= NearEqual(dw[1], x[0]*exp(x[1]), 1e-10, 1e-10 ); // w.r.t x[1] // compute and check derivative of y[1] dw = f.RevOne(x, 1); ok &= NearEqual(dw[0], sin(x[1]), 1e-10, 1e-10 ); ok &= NearEqual(dw[1], x[0]*cos(x[1]), 1e-10, 1e-10 ); // compute and check derivative of y[2] dw = f.RevOne(x, 2); ok &= NearEqual(dw[0], cos(x[1]), 1e-10, 1e-10 ); ok &= NearEqual(dw[1], - x[0]*sin(x[1]), 1e-10, 1e-10 ); return ok; } } // End empty namespace # 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; } // END C++ cppad-20160000.1/example/fun_check.cpp0000644000175200017650000000737612656321773016534 0ustar coincoin-web// $Id: fun_check.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. -------------------------------------------------------------------------- */ /* ! WARNING: This file is used as an example by FunConstruct and Dependent $begin fun_check.cpp$$ $spell abs $$ $section ADFun Check and Re-Tape: Example and Test$$ $mindex FunCheck Dependent$$ $code $verbatim%example/fun_check.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // ----------------------------------------------------------- // define the template function object Fun in empty namespace template 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 in empty namespace template bool FunCheckCases(void) { bool ok = true; using CppAD::AD; using CppAD::ADFun; using CppAD::Independent; // 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 = 1e-10; double a = 1e-10; 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 # 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; } // END C++ cppad-20160000.1/example/test_one.sh.in0000755000175200017650000000445512656321773016662 0ustar coincoin-web#! /bin/bash -e # $Id: test_one.sh.in 3754 2015-11-26 22:23:05Z 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. # ----------------------------------------------------------------------------- # Run one of the tests if [ "$1" = "" ] then echo "usage: test_one.sh file [extra]" echo "file is the *.cpp file name with extension" echo "and extra is extra options for g++ command" exit 1 fi if [ ! -e "$1" ] then echo "Cannot find the file $1" exit 1 fi # determine the function name fun=`grep "^bool *[a-zA-Z0-9_]* *( *void *)" $1 | tail -1 | \ sed -e "s/^bool *\([a-zA-Z0-9_]*\) *( *void *)/\1/"` # if [ -e test_one.exe ] then rm test_one.exe fi if [ -e test_one.cpp ] then rm test_one.cpp fi sed < example.cpp > test_one.cpp \ -e '/ok *\&= *Run( /d' \ -e "s/.*This line is used by test_one.sh.*/ ok \&= Run( $fun, \"$fun\");/" # cxxflags='@cppad_cxx_flags@' if echo "$fun" | grep 'eigen' > /dev/null then cxxflags=`echo "$cxxflags" | sed -e 's|-Wshadow||'` fi cmd="g++ test_one.cpp $*" cmd="$cmd -o test_one.exe $cxxflags -L @cppad_BINARY_DIR@/cppad_lib -lcppad_lib -g -fopenmp -lboost_thread -lpthread -DCPPAD_ADOLC_EXAMPLES -DCPPAD_EIGEN_EXAMPLES -I.. " if [ -e @adolc_prefix@/include ] then cmd="$cmd -I@adolc_prefix@/include" fi if [ -e @colpack_prefix@/include ] then cmd="$cmd -I@colpack_prefix@/include" fi if [ -e @eigen_prefix@/include ] then cmd="$cmd -I@eigen_prefix@/include" fi for lib in lib lib64 do if [ -e @adolc_prefix@/$lib ] then cmd="$cmd -L@adolc_prefix@/$lib -ladolc -lColPack" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@adolc_prefix@/$lib" fi if [ -e @colpack_prefix@/$lib ] then cmd="$cmd -L@colpack_prefix@/$lib -lColPack" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@colpack_prefix@/$lib" fi done export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@cppad_BINARY_DIR@/cppad_lib" echo $cmd $cmd # echo "./test_one.exe" if ! ./test_one.exe then exit 1 fi exit 0 cppad-20160000.1/example/integer.cpp0000644000175200017650000000334612656321773016235 0ustar coincoin-web// $Id: integer.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin integer.cpp$$ $spell Cpp cstddef $$ $section Convert From AD to Integer: Example and Test$$ $mindex Integer$$ $code $verbatim%example/integer.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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.); return ok; } // END C++ cppad-20160000.1/example/compare.cpp0000644000175200017650000000510412656321773016220 0ustar coincoin-web// $Id: compare.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin compare.cpp$$ $spell Cpp $$ $section AD Binary Comparison Operators: Example and Test$$ $mindex compare < <= > >= == !=$$ $code $verbatim%example/compare.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool Compare(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // 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, 1e-10, 1e-10); // 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, 1e-10, 1e-10); // 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, 1e-10, 1e-10); ok &= NearEqual(dw[1], 3.*x0*x0*x1*x1*x0, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/add_eq.cpp0000644000175200017650000000431612656321773016013 0ustar coincoin-web// $Id: add_eq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin AddEq.cpp$$ $section AD Computed Assignment Addition: Example and Test$$ $mindex += add assign plus$$ $code $verbatim%example/add_eq.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool AddEq(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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 computed assignment // create f: x -> y and stop tape recording CppAD::ADFun f(x, y); // check value ok &= NearEqual(y[0] , x0+2.+4.+x0, 1e-10 , 1e-10); ok &= NearEqual(y[1] , y[0], 1e-10 , 1e-10); // 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., 1e-10, 1e-10); ok &= NearEqual(dy[1], 2., 1e-10, 1e-10); // 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., 1e-10, 1e-10); // 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; } // END C++ cppad-20160000.1/example/abs.cpp0000644000175200017650000000577412656321773015354 0ustar coincoin-web// $Id: abs.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin abs.cpp$$ $spell fabs abs $$ $section AD Absolute Value Function: Example and Test$$ $mindex abs fabs$$ $code $verbatim%example/abs.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool abs(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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] = abs(x[0] - 1.); y[1] = abs(x[0]); y[2] = abs(x[0] + 1.); // y[3] = fabs(x[0] - 1.); y[4] = fabs(x[0]); y[5] = fabs(x[0] + 1.); // create f: x -> y and stop tape recording 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 = abs(v[zero]); ok &= NearEqual(result, 1., 1e-10, 1e-10); result = fabs(v[zero]); ok &= NearEqual(result, 1., 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/equal_op_seq.cpp0000644000175200017650000000332412656321773017251 0ustar coincoin-web// $Id: equal_op_seq.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin equal_op_seq.cpp$$ $spell Op $$ $section EqualOpSeq: Example and Test$$ $mindex EqualOpSeq$$ $code $verbatim%example/equal_op_seq.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include 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) x(n); x[0] = x0; // 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 // 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; // 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); // both a and b are parameters (after the creation of f above) ok &= EqualOpSeq(a, b); // 1 + 1 == 2 * 1 return ok; } // END C++ cppad-20160000.1/example/sparse_hessian.cpp0000644000175200017650000001133512656321773017604 0ustar coincoin-web// $Id: sparse_hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sparse_hessian.cpp$$ $spell Cpp Hessian $$ $section Sparse Hessian: Example and Test$$ $mindex Hessian spare$$ $code $verbatim%example/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; return ok; } // END C++ cppad-20160000.1/example/hes_times_dir.cpp0000644000175200017650000000447012656321773017415 0ustar coincoin-web// $Id: hes_times_dir.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin hes_times_dir.cpp$$ $spell $$ $section Hessian Times Direction: Example and Test$$ $mindex direction$$ $code $verbatim%example/hes_times_dir.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ // 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 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; } } bool HesTimesDir(void) { bool ok = true; // initialize test result size_t j; // a domain variable variable using CppAD::AD; using CppAD::NearEqual; // 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], 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/hes_lu_det.cpp0000644000175200017650000000400112656321773016700 0ustar coincoin-web// $Id: hes_lu_det.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin hes_lu_det.cpp$$ $spell Lu Cpp $$ $section Gradient of Determinant Using LU Factorization: Example and Test$$ $code $verbatim%example/hes_lu_det.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool HesLuDet(void) { bool ok = true; using namespace CppAD; typedef std::complex Complex; 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], 1e-10 , 1e-10 ); return ok; } // END C++ cppad-20160000.1/example/for_two.cpp0000644000175200017650000000660112656321773016254 0ustar coincoin-web// $Id: for_two.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin for_two.cpp$$ $spell Cpp $$ $section Subset of Second Order Partials: Example and Test$$ $mindex partial$$ $code $verbatim%example/for_two.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // ----------------------------------------------------- // define the template function in empty namespace // bool ForTwoCases(void) template bool ForTwoCases() { bool ok = true; using CppAD::AD; using CppAD::NearEqual; 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], 1e-10, 1e-10 ); ok &= NearEqual( 2.*sin(x[1]), ddy[1*p+0], 1e-10, 1e-10 ); ok &= NearEqual( 2.*cos(x[1]), ddy[2*p+0], 1e-10, 1e-10 ); // second partial of F w.r.t x[0] and x[1] ok &= NearEqual( 2.*x[0]*exp(x[1]), ddy[0*p+1], 1e-10, 1e-10 ); ok &= NearEqual( 2.*x[0]*cos(x[1]), ddy[1*p+1], 1e-10, 1e-10 ); ok &= NearEqual(-2.*x[0]*sin(x[1]), ddy[2*p+1], 1e-10, 1e-10 ); return ok; } } // End empty namespace # include # include 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 , std::vector >(); ok &= ForTwoCases< std::vector , std::vector >(); ok &= ForTwoCases< std::valarray , std::vector >(); // Run with VectorSize_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 >(); return ok; } // END C++ cppad-20160000.1/example/ad_in_c.cpp0000644000175200017650000002721512656321773016155 0ustar coincoin-web// $Id: ad_in_c.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ad_in_c.cpp$$ $spell CppAD $$ $section Example and Test Linking CppAD to Languages Other than C++$$ $mindex C AD algorithmic differentiation automatic link$$ $code $verbatim%example/ad_in_c.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include namespace { // Begin empty namespace ***************************************** /* void debug_print(const char *label, double d) { 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"); } */ // type in C corresponding to an AD object typedef struct { void* p_void; } cad; // type in C corresponding to a an ADFun typedef struct { void* p_void; } cad_fun; // type in C corresponding to a C AD binary operator typedef enum { op_add, op_sub, op_mul, op_div } cad_binary_op; // type in C corresponding to a C AD unary operator typedef enum { op_abs, op_acos, op_asin, op_atan, op_cos, op_cosh, 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 >& 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; } } 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]; } } 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]; } 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]; } std::list 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::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::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* 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 ); } // 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* 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; } // 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) ); } // 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 = abs( *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 *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); } // 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* 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 ); // 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* p_adfun = reinterpret_cast< ADFun* > (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* 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 ); 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(); } } // End empty namespace **************************************************** # include // 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; } // END C++ cppad-20160000.1/example/exp.cpp0000644000175200017650000000402012656321773015362 0ustar coincoin-web/* $Id: exp.cpp 3683 2015-05-10 02:24:16Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin exp.cpp$$ $spell exp $$ $section The AD exp Function: Example and Test$$ $code $verbatim%example/exp.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool exp(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) 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; } // END C++ cppad-20160000.1/example/cos.cpp0000644000175200017650000000401412656321773015355 0ustar coincoin-web// $Id: cos.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin cos.cpp$$ $spell cos $$ $section The AD cos Function: Example and Test$$ $code $verbatim%example/cos.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool Cos(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // 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, 1e-10, 1e-10); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], check, 1e-10, 1e-10); // 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, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/var2par.cpp0000644000175200017650000000374212656321773016155 0ustar coincoin-web// $Id: var2par.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin var2par.cpp$$ $spell Var Cpp $$ $section Convert an AD Variable to a Parameter: Example and Test$$ $mindex Var2Par Value during taping$$ $code $verbatim%example/var2par.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include 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 return ok; } // END C++ cppad-20160000.1/example/ad_output.cpp0000644000175200017650000000361712656321773016605 0ustar coincoin-web// $Id: ad_output.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ad_output.cpp$$ $spell Cpp cstddef $$ $section AD Output Operator: Example and Test$$ $mindex <<$$ $code $verbatim%example/ad_output.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include // std::ostringstream # include // std::string # 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 } } 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 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(); // check the output ok &= (str == " 3.142 2.718"); return ok; } // END C++ cppad-20160000.1/example/error_handler.cpp0000644000175200017650000000403512656321773017422 0ustar coincoin-web// $Id: error_handler.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin error_handler.cpp$$ $spell CppAD $$ $section Replacing The CppAD Error Handler: Example and Test$$ $mindex handler$$ $code $verbatim%example/error_handler.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # 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; } } 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; } // END C++ cppad-20160000.1/example/mul_level_adolc.cpp0000644000175200017650000001147112656321773017724 0ustar coincoin-web/* $Id: mul_level_adolc.cpp 3738 2015-10-05 13:16:50Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin mul_level_adolc.cpp$$ $spell CppAD AdolcDir adouble Vec $$ $section Using Adolc with Multiple Levels of Taping: Example and Test$$ $head Purpose$$ In this example, we use $code AD< adouble> >$$ (level two taping), the compute values of the function $latex f : \B{R}^n \rightarrow \B{R}$$ where $latex \[ 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 $latex \[ f^{(1)} (x) * v = x_0 v_0 + \cdots + x_{n-1} v_{n-1} \] $$. where $latex v \in \B{R}^n$$. We then use $code double$$ (no taping) to compute $latex \[ \frac{d}{dx} \left[ f^{(1)} (x) * v \right] = v \] $$ This is only meant as an example of multiple levels of taping. 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 \] $$ The example $cref mul_level.cpp$$ computes the same values using $code AD< AD >$$ and $code AD$$. $head Memory Management$$ Adolc uses raw memory arrays that depend on the number of dependent and independent variables. The memory management utility $cref thread_alloc$$ is used to manage this memory allocation. $head Configuration Requirement$$ This example will be compiled and tested provided that the value $cref adolc_prefix$$ is specified on the $cref cmake$$ command line. $head Source$$ $code $verbatim%example/mul_level_adolc.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include // adouble definitions not in Adolc distribution and // required in order to use CppAD::AD # include # 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]; 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 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; } // END C++ cppad-20160000.1/example/add.cpp0000644000175200017650000000422412656321773015324 0ustar coincoin-web// $Id: add.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin add.cpp$$ $section AD Binary Addition: Example and Test$$ $mindex + add plus$$ $code $verbatim%example/add.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool Add(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // 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., 1e-10, 1e-10); // 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., 1e-10, 1e-10); // 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; } // END C++ cppad-20160000.1/example/ipopt_solve/0002755000175200017650000000000012656321773016433 5ustar coincoin-webcppad-20160000.1/example/ipopt_solve/CMakeLists.txt0000644000175200017650000000321212656321773021167 0ustar coincoin-web# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the example/ipopt_solve directory tests # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # Local link directories to search, as determined by pkg-config for ipopt LINK_DIRECTORIES( ${ipopt_LIBRARY_DIRS} ) # Copy a file to another location and modify its contents. # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh ) # ADD_EXECUTABLE(example_ipopt_solve EXCLUDE_FROM_ALL solve.cpp get_started.cpp ode_inverse.cpp retape.cpp ) # Extra compiler flags add_cppad_cxx_flags( example_ipopt_solve ) # 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} ) # Add the check_example_ipopt_solve target ADD_CUSTOM_TARGET(check_example_ipopt_solve example_ipopt_solve DEPENDS example_ipopt_solve ) cppad-20160000.1/example/ipopt_solve/test.sh.in0000644000175200017650000000125212656321773020351 0ustar coincoin-web#! /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. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- export LD_LIBRARY_PATH=@CPPAD_IPOPT_LD_PATH@ ./solve cppad-20160000.1/example/ipopt_solve/test_one.sh.in0000755000175200017650000000400212656321773021211 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Run one of the tests if [ "$1" = "" ] then echo "usage: test_one.sh file [extra]" echo "file is the *.cpp file name with extension" echo "and extra is extra options for g++ command" exit 1 fi if [ ! -e "$1" ] then echo "Cannot find the file $1" exit 1 fi # determine the function name fun=`grep "^bool *[a-zA-Z0-9_]* *( *void *)" $1 | tail -1 | \ sed -e "s/^bool *\([a-zA-Z0-9_]*\) *( *void *)/\1/"` # if [ -e test_one.exe ] then rm test_one.exe fi if [ -e test_one.cpp ] then rm test_one.cpp fi sed < solve.cpp > test_one.cpp \ -e '/ok *\&= *Run( /d' \ -e "s/.*This line is used by test_one.sh.*/ ok \&= Run( $fun, \"$fun\");/" # cxxflags='@cppad_cxx_flags@' if echo "$fun" | grep 'eigen' > /dev/null then cxxflags=`echo "$cxxflags" | sed -e 's|-Wshadow||'` fi cmd="g++ test_one.cpp $*" if [ -e @colpack_prefix@/include ] then cmd="$cmd ../../cppad/local/cppad_colpack.cpp" fi cmd="$cmd -o test_one.exe $cxxflags -g -fopenmp -lboost_thread -lpthread -I../.. " if [ -e @colpack_prefix@/include ] then cmd="$cmd -I@colpack_prefix@/include" fi if [ -e @ipopt_prefix@/include ] then cmd="$cmd -I@ipopt_prefix@/include" ipopt_libs=`pkg-config --libs ipopt` cmd="$cmd $ipopt_libs" fi for lib in lib lib64 do if [ -e @colpack_prefix@/$lib ] then cmd="$cmd -L@colpack_prefix@/$lib -lColPack" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@colpack_prefix@/$lib" fi done echo $cmd $cmd # echo "./test_one.exe" if ! ./test_one.exe then exit 1 fi exit 0 cppad-20160000.1/example/ipopt_solve/retape.cpp0000644000175200017650000000630412656321773020420 0ustar coincoin-web// $Id: retape.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ipopt_solve_retape.cpp$$ $spell 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 $verbatim%example/ipopt_solve/retape.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { 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( abs(x[0]) <= eps ) fg[0] = x[0] * x[0] / (2.0 * eps); else fg[0] = abs(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 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; } // END C++ cppad-20160000.1/example/ipopt_solve/makefile.in0000644000175200017650000004625112656321773020546 0ustar coincoin-web# 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 = solve$(EXEEXT) subdir = example/ipopt_solve ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test.sh CONFIG_CLEAN_VPATH_FILES = am_solve_OBJECTS = solve.$(OBJEXT) get_started.$(OBJEXT) \ ode_inverse.$(OBJEXT) retape.$(OBJEXT) solve_OBJECTS = $(am_solve_OBJECTS) solve_LDADD = $(LDADD) am__DEPENDENCIES_1 = solve_DEPENDENCIES = $(am__DEPENDENCIES_1) $(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 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 = $(solve_SOURCES) DIST_SOURCES = $(solve_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 $(srcdir)/test.sh.in \ $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ 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 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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 = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # LDADD = \ $(CPPAD_IPOPT_LIBS) \ $(FCLIBS) \ $(PTHREAD_LIB) \ $(DL_LIB) # solve_SOURCES = \ solve.cpp \ get_started.cpp \ ode_inverse.cpp \ retape.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) --gnu example/ipopt_solve/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu example/ipopt_solve/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): test.sh: $(top_builddir)/config.status $(srcdir)/test.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ clean-checkPROGRAMS: -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) solve$(EXEEXT): $(solve_OBJECTS) $(solve_DEPENDENCIES) $(EXTRA_solve_DEPENDENCIES) @rm -f solve$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(solve_OBJECTS) $(solve_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_started.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_inverse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/retape.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/solve.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 ./test.sh # 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: cppad-20160000.1/example/ipopt_solve/ode_inverse.cpp0000644000175200017650000002274312656321773021447 0ustar coincoin-web// $Id: ode_inverse.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ipopt_solve_ode_inverse.cpp$$ $spell $$ $section ODE Inverse Problem Definitions: Source Code$$ $mindex example$$ $head Purpose$$ This example demonstrates how to invert for parameters in a ODE where the solution of the ODE is numerically approximated. $head Forward Problem$$ 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 ) \end{array} \] $$ with the initial conditions $latex \[ y_0 (0 , a) = ( a_0 , 0 )^\R{T} \] $$ Our forward problem is stated as follows: Given $latex a \in \B{R}^3$$ determine the value of $latex y ( t , a ) $$, for $latex t \in R$$, that solves the initial value problem above. $head Measurements$$ Suppose we are also given measurement times $latex s \in \B{R}^5$$ 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 \] $$ where $latex e_{i-1} \sim {\bf N} (0 , \sigma^2 )$$ is the measurement noise, and $latex \sigma > 0$$ is the standard deviation of the noise. $subhead Simulation Analytic Solution$$ The following analytic solution to the forward problem is used 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 } \end{array} \] $$ $subhead Simulation Parameter Values$$ $table $latex \bar{a}_0 = 1$$ $pre $$ $cnext initial value of $latex y_0 (t, a)$$ $rnext $latex \bar{a}_1 = 2$$ $pre $$ $cnext transfer rate from compartment zero to compartment one $rnext $latex \bar{a}_2 = 1$$ $pre $$ $cnext transfer rate from compartment one to outside world $rnext $latex \sigma = 0$$ $pre $$ $cnext standard deviation of measurement noise $rnext $latex e_i = 0$$ $pre $$ $cnext simulated measurement noise, $latex i = 1 , \ldots , Nz$$ $rnext $latex s_i = i * .5$$ $pre $$ $cnext time corresponding to the $th i$$ measurement, $latex i = 0 , \ldots , 3$$ $tend $subhead Simulated Measurement Values$$ The simulated measurement values are given by the equation $latex \[ \begin{array}{rcl} z_i & = & e_i + y_1 ( s_{i+1} , \bar{a} ) \\ & = & \bar{a}_0 * \bar{a}_1 * \frac{\exp( - \bar{a}_2 * s_i ) - \exp( -\bar{a}_1 * s_i )} { \bar{a}_1 - \bar{a}_2 } \end{array} \] $$ for $latex i = 0, \ldots , 3$$. $head Inverse Problem$$ The maximum likelihood estimate for $latex a$$ given $latex z$$ solves the following optimization problem $latex \[ \begin{array}{rcl} {\rm minimize} \; & \sum_{i=0}^3 ( z_i - y_1 ( s_{i+1} , a ) )^2 & \;{\rm w.r.t} \; a \in \B{R}^3 \end{array} \] $$ $head Trapezoidal Approximation$$ We are given a number of approximation points per measurement interval $latex np$$ and define the time grid $latex t \in \B{R}^{4 \cdot np + 1}$$ as follows: $latex t_0 = s_0$$ and 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} \] $$ We note that for $latex i = 1 , \ldots , 4$$, $latex t_{i \cdot np} = s_i$$. This example uses a trapezoidal approximation to solve the ODE. Given $latex a \in \B{R}^3$$ and $latex y^{k-1} \approx y( t_{k-1} , a )$$, the a trapezoidal method approximates $latex y ( t_j , a )$$ by the value $latex y^k \in \B{R}^2$$ ) that solves the equation $latex \[ y^k = y^{k-1} + \frac{G( y^k , a ) + G( y^{k-1} , a ) }{2} * (t_k - t_{k-1}) \] $$ 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 \end{array} \] $$ $head Solution Method$$ We use constraints to embed the forward problem in the inverse problem. To be specific, we solve the optimization problem $latex \[ \begin{array}{rcl} {\rm minimize} & \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 \\ {\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 \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) \] $$ $head Source$$ The following source code implements the ODE inversion method proposed above: $code $verbatim%example/ipopt_solve/ode_inverse.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end ------------------------------------------------------------------------------ */ // BEGIN C++ # include 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 ) 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); return ok; } // END C++ cppad-20160000.1/example/ipopt_solve/get_started.cpp0000644000175200017650000001027312656321773021445 0ustar coincoin-web// $Id: get_started.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ipopt_solve_get_started.cpp$$ $spell 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 solve the example problem in the Ipopt documentation; i.e., the problem $latex \[ \begin{array}{lc} {\rm minimize \; } & x_1 * x_4 * (x_1 + x_2 + x_3) + x_3 \\ {\rm subject \; to \; } & x_1 * x_2 * x_3 * x_4 \geq 25 \\ & x_1^2 + x_2^2 + x_3^2 + x_4^2 = 40 \\ & 1 \leq x_1, x_2, x_3, x_4 \leq 5 \end{array} \] $$ $head Configuration Requirement$$ This example will be compiled and tested provided that $cref ipopt_prefix$$ is specified on the $cref cmake$$ command line. $code $verbatim%example/ipopt_solve/get_started.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { 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; } }; } 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 ); } return ok; } // END C++ cppad-20160000.1/example/ipopt_solve/makefile.am0000644000175200017650000000223312656321773020525 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 = solve # AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # LDADD = \ $(CPPAD_IPOPT_LIBS) \ $(FCLIBS) \ $(PTHREAD_LIB) \ $(DL_LIB) # solve_SOURCES = \ solve.cpp \ get_started.cpp \ ode_inverse.cpp \ retape.cpp test: check ./test.sh cppad-20160000.1/example/ipopt_solve/solve.cpp0000644000175200017650000000442212656321773020267 0ustar coincoin-web/* $Id: solve.cpp 3746 2015-11-09 04:50:27Z 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. -------------------------------------------------------------------------- */ // system include files used for I/O # include // C style asserts # include // ipopt solve include file # include // external complied tests extern bool get_started(void); extern bool ode_inverse(void); extern bool retape(void); namespace { // function that runs one test static size_t Run_ok_count = 0; static size_t Run_error_count = 0; bool Run(bool TestOk(void), const char *name) { bool ok = true; double s0 = CppAD::elapsed_seconds(); ok &= TestOk(); double s1 = CppAD::elapsed_seconds(); double sec = std::floor(100*(s1 - s0) + 0.5) / 100.; if( ok ) { std::cout << "OK: " << "ipopt_solve: " << name; std::cout << ", seconds = " << sec << std::endl; Run_ok_count++; } else { std::cout << "Error: " << "ipopt_solve: " << name << std::endl; Run_error_count++; } return ok; } } // main program that runs all the tests int main(void) { bool ok = true; // This line is used by test_one.sh // external compiled tests ok &= Run( get_started, "get_started" ); ok &= Run( ode_inverse, "ode_inverse" ); ok &= Run( retape, "retape" ); // check for errors using std::cout; using std::endl; assert( ok || (Run_error_count > 0) ); if( CppAD::thread_alloc::free_all() ) { Run_ok_count++; cout << "OK: " << "No memory leak detected" << endl; } else { ok = false; Run_error_count++; cout << "Error: " << "memory leak detected" << endl; } // convert int(size_t) to avoid warning on _MSC_VER systems if( ok ) cout << "All " << int(Run_ok_count) << " tests passed." << endl; else cout << int(Run_error_count) << " tests failed." << endl; return static_cast( ! ok ); } cppad-20160000.1/example/lu_factor.cpp0000644000175200017650000000564212656321773016557 0ustar coincoin-web// $Id: lu_factor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin lu_factor.cpp$$ $spell Geq Cpp Lu $$ $section LuFactor: Example and Test$$ $mindex LuFactor$$ $code $verbatim%example/lu_factor.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include // for rand function # include // for CppAD::LuFactor # include // for CppAD::NearEqual # include // for CppAD::vector bool LuFactor(void) { bool ok = true; # ifndef _MSC_VER using std::rand; using std::srand; # endif 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 &= CppAD::NearEqual(pij, sum, 1e-10, 1e-10); } } return ok; } // END C++ cppad-20160000.1/example/colpack_jac.cpp0000644000175200017650000000610112656321773017021 0ustar coincoin-web// $Id: colpack_jac.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin colpack_jac.cpp$$ $spell colpack_jac jacobian $$ $section Using ColPack: Example and Test$$ $mindex colpack jacobian sparse$$ $code $verbatim%example/colpack_jac.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool colpack_jac(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; typedef CPPAD_TESTVECTOR(AD) a_vector; typedef CPPAD_TESTVECTOR(double) d_vector; typedef CppAD::vector i_vector; size_t i, j, k, ell; double eps = 10. * CppAD::numeric_limits::epsilon(); // domain space vector size_t n = 4; a_vector a_x(n); for(j = 0; j < n; j++) a_x[j] = AD (0); // declare independent variables and starting recording CppAD::Independent(a_x); size_t m = 3; a_vector a_y(m); a_y[0] = a_x[0] + a_x[1]; a_y[1] = a_x[2] + a_x[3]; a_y[2] = a_x[0] + a_x[1] + a_x[2] + a_x[3] * a_x[3] / 2.; // create f: x -> y and stop tape recording CppAD::ADFun f(a_x, a_y); // new value for the independent variable vector d_vector x(n); for(j = 0; j < n; j++) x[j] = double(j); /* [ 1 1 0 0 ] jac = [ 0 0 1 1 ] [ 1 1 1 x_3] */ d_vector check(m * n); check[0] = 1.; check[1] = 1.; check[2] = 0.; check[3] = 0.; check[4] = 0.; check[5] = 0.; check[6] = 1.; check[7] = 1.; check[8] = 1.; check[9] = 1.; check[10] = 1.; check[11] = x[3]; // Normally one would use f.ForSparseJac or f.RevSparseJac to compute // sparsity pattern, but for this example we extract it from check. std::vector< std::set > p(m); // using row and column indices to compute non-zero in rows 1 and 2 i_vector row, col; for(i = 0; i < m; i++) { for(j = 0; j < n; j++) { ell = i * n + j; if( check[ell] != 0. ) { row.push_back(i); col.push_back(j); p[i].insert(j); } } } size_t K = row.size(); d_vector jac(K); // empty work structure CppAD::sparse_jacobian_work work; ok &= work.color_method == "cppad"; // choose to use ColPack work.color_method = "colpack"; // forward mode size_t n_sweep = f.SparseJacobianForward(x, p, row, col, jac, work); for(k = 0; k < K; k++) { ell = row[k] * n + col[k]; ok &= NearEqual(check[ell], jac[k], eps, eps); } ok &= n_sweep == 4; // reverse mode work.clear(); work.color_method = "colpack"; n_sweep = f.SparseJacobianReverse(x, p, row, col, jac, work); for(k = 0; k < K; k++) { ell = row[k] * n + col[k]; ok &= NearEqual(check[ell], jac[k], eps, eps); } ok &= n_sweep == 2; return ok; } // END C++ cppad-20160000.1/example/lu_vec_ad.hpp0000644000175200017650000000175212656321773016525 0ustar coincoin-web// $Id: lu_vec_ad.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_LU_VEC_AD_HPP # define CPPAD_LU_VEC_AD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include namespace CppAD { extern CppAD::AD LuVecAD( size_t n, size_t m, CppAD::VecAD &Matrix, CppAD::VecAD &Rhs, CppAD::VecAD &Result, CppAD::AD &logdet ); } # endif cppad-20160000.1/example/log.cpp0000644000175200017650000000376212656321773015363 0ustar coincoin-web// $Id: log.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin log.cpp$$ $spell exp log $$ $section The AD log Function: Example and Test$$ $code $verbatim%example/log.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool log(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., 1e-10, 1e-10); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], 1., 1e-10, 1e-10); // 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, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/seq_property.cpp0000644000175200017650000001043112656321773017325 0ustar coincoin-web// $Id: seq_property.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin seq_property.cpp$$ $spell 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 $verbatim%example/seq_property.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include 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 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] becasue it is a parameter nvar += 1; // special variable for y[0] because it is a parameter narg += 1; // identifies which parameter corresponds to y[0] 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::OpCode); sum += narg * sizeof(CPPAD_TAPE_ADDR_TYPE); sum += npar * sizeof(double); sum += ntext * sizeof(char); sum += nvecad * sizeof(CPPAD_TAPE_ADDR_TYPE); ok &= f.size_op_seq() == sum; return ok; } // END C++ cppad-20160000.1/example/conj_grad.cpp0000644000175200017650000001557312656321773016533 0ustar coincoin-web// $Id: conj_grad.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin conj_grad.cpp$$ $spell checkpointing goto $$ $section Differentiate Conjugate Gradient Algorithm: Example and Test$$ $head Purpose$$ The conjugate gradient algorithm is sparse linear solver and a good example where checkpointing can be applied (for each iteration). This example is a preliminary version of a new library routine for the conjugate gradient algorithm. $head Algorithm$$ Given a positive definite matrix $latex A \in \B{R}^{n \times n}$$, a vector $latex b \in \B{R}^n$$, and tolerance $latex \varepsilon$$, the conjugate gradient algorithm finds an $latex x \in \B{R}^n$$ such that $latex \| A x - b \|^2 / n \leq \varepsilon^2$$ (or it terminates at a specified maximum number of iterations). $list number$$ Input: $pre $$ The matrix $latex A \in \B{R}^{n \times n}$$, the vector $latex b \in \B{R}^n$$, a tolerance $latex \varepsilon \geq 0$$, a maximum number of iterations $latex m$$, and the initial approximate solution $latex x^0 \in \B{R}^n$$ (can use zero for $latex x^0$$). $lnext Initialize: $pre $$ $latex g^0 = A * x^0 - b$$, $latex d^0 = - g^0$$, $latex s_0 = ( g^0 )^\R{T} g^0$$, $latex k = 0$$. $lnext Convergence Check: $pre $$ if $latex k = m$$ or $latex \sqrt{ s_k / n } < \varepsilon $$, return $latex k$$ as the number of iterations and $latex x^k$$ as the approximate solution. $lnext Next $latex x$$: $pre $$ $latex \mu_{k+1} = s_k / [ ( d^k )^\R{T} A d^k ]$$, $latex x^{k+1} = x^k + \mu_{k+1} d^k$$. $lnext Next $latex g$$: $pre $$ $latex g^{k+1} = g^k + \mu_{k+1} A d^k$$, $latex s_{k+1} = ( g^{k+1} )^\R{T} g^{k+1}$$. $lnext Next $latex d$$: $pre $$ $latex d^{k+1} = - g^k + ( s_{k+1} / s_k ) d^k$$. $lnext Iterate: $pre $$ $latex k = k + 1$$, goto Convergence Check. $lend $code $verbatim%example/conj_grad.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include 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 // 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; // ---------------------------------------------------------------------- // 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; } // END C++ cppad-20160000.1/example/vec_ad.cpp0000644000175200017650000001230012656321773016007 0ustar coincoin-web// $Id: vec_ad.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin vec_ad.cpp$$ $spell Vec Cpp cstddef $$ $section AD Vectors that Record Index Operations: Example and Test$$ $mindex VecAD vec_ad.cpp$$ $code $verbatim%example/vec_ad.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # 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(abs(a[0]), abs(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; } } bool vec_ad(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); ok &= NearEqual(Y[1] , num1 / den, 1e-10 , 1e-10); // 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, 1e-10, 1e-10); ok &= NearEqual(dy[1], b[1] / den - num1 * x[3] / dsq, 1e-10, 1e-10); // 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, 1e-10 , 1e-10); ok &= NearEqual(y[1] , num1 / den, 1e-10 , 1e-10); // forward computation of partials w.r.t. x[1] dx[0] = 0.; dx[1] = 1.; dx[2] = 0.; dx[3] = 0.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0],-b[1] / den + num0 * x[2] / dsq, 1e-10, 1e-10); ok &= NearEqual(dy[1], 0. + num1 * x[2] / dsq, 1e-10, 1e-10); // 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, 1e-10, 1e-10); ok &= NearEqual(dw[1],-b[1] / den + num0 * x[2] / dsq, 1e-10, 1e-10); ok &= NearEqual(dw[2], 0. + num0 * x[1] / dsq, 1e-10, 1e-10); ok &= NearEqual(dw[3], b[0] / den - num0 * x[0] / dsq, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/forward_order.cpp0000644000175200017650000000466712656321773017446 0ustar coincoin-web// $Id: forward_order.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin forward_order.cpp$$ $spell Cpp $$ $section Forward Mode: Example and Test of Multiple Orders$$ $code $verbatim%example/forward_order.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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); // check number of orders per variable ok &= f.size_order() == 3; return ok; } // END C++ cppad-20160000.1/example/acosh.cpp0000644000175200017650000000403512656321773015671 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin acosh.cpp$$ $spell cosh acosh $$ $section The AD acosh Function: Example and Test$$ $code $verbatim%example/acosh.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool acosh(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 10 times machine epsilon double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) x(n); x[0] = x0; // declare independent variables and start tape recording CppAD::Independent(x); // a temporary value AD cosh_of_x0 = CppAD::cosh(x[0]); // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) y(m); y[0] = CppAD::acosh(cosh_of_x0); // create f: x -> y and stop tape recording CppAD::ADFun f(x, y); // check value ok &= NearEqual(y[0] , x0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., eps, eps); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], 1., eps, eps); // use a VecAD::reference object with acosh CppAD::VecAD v(1); AD zero(0); v[zero] = cosh_of_x0; AD result = CppAD::acosh(v[zero]); ok &= NearEqual(result, x0, eps, eps); return ok; } // END C++ cppad-20160000.1/example/eigen_det.cpp0000644000175200017650000000530612656321773016521 0ustar coincoin-web// $Id: eigen_det.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin eigen_det.cpp$$ $spell Eigen $$ $section Using Eigen To Compute Determinant: Example and Test$$ $mindex determinant$$ $code $verbatim%example/eigen_det.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # 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); } return ok; } // END C++ cppad-20160000.1/example/ode_taylor.cpp0000644000175200017650000001146012656321773016735 0ustar coincoin-web// $Id: ode_taylor.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin 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 $verbatim%example/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 = 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++ cppad-20160000.1/example/fun_assign.cpp0000644000175200017650000000630512656321773016732 0ustar coincoin-web// $Id: fun_assign.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin fun_assign.cpp$$ $section ADFun Assignment: Example and Test$$ $mindex assignment$$ $code $verbatim%example/fun_assign.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # 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() == f.size_forward_bool() ); ok &= ( g.size_forward_set() == f.size_forward_set() ); // 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; } // END C++ cppad-20160000.1/example/ad_input.cpp0000644000175200017650000000275012656321773016401 0ustar coincoin-web// $Id: ad_input.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ad_input.cpp$$ $spell Cpp cstddef $$ $section AD Output Operator: Example and Test$$ $mindex << input$$ $code $verbatim%example/ad_input.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include // std::istringstream # include // 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 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; } // END C++ cppad-20160000.1/example/compare_change.cpp0000644000175200017650000001144212656321773017527 0ustar coincoin-web// $Id: compare_change.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin compare_change.cpp$$ $spell Cpp $$ $section CompareChange and Re-Tape: Example and Test$$ $mindex compare change re-tape$$ $code $verbatim%example/compare_change.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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; } } bool compare_change(void) { 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]); # ifdef NDEBUG // CppAD does not spend time checking operator index when // NDEBUG is defined missed_error = false; AD::abort_recording(); # endif } catch( error_info info ) { missed_error = false; ok &= info.known; ok &= info.msg == check_msg; // Must abort the recording so we can start a new one // (and to avoid a memory leak). AD::abort_recording(); } } ok &= ! missed_error; // 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; } // END C++ cppad-20160000.1/example/forward.cpp0000644000175200017650000000567312656321773016251 0ustar coincoin-web// $Id: forward.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin forward.cpp$$ $spell Cpp $$ $section Forward Mode: Example and Test$$ $code $verbatim%example/forward.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include namespace { // -------------------------------------------------------- // 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; 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; } // END C++ cppad-20160000.1/example/ad_fun.cpp0000644000175200017650000000645312656321773016036 0ustar coincoin-web// $Id: ad_fun.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ad_fun.cpp$$ $spell $$ $section Creating Your Own Interface to an ADFun Object$$ $mindex example test$$ $code $verbatim%example/ad_fun.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include 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); } }; } // 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; 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], 1e-10, 1e-10 ); ok &= NearEqual( 2.*x[0]*sin(x[1]), jac[1*n+0], 1e-10, 1e-10 ); ok &= NearEqual( 2.*x[0]*cos(x[1]), jac[2*n+0], 1e-10, 1e-10 ); ok &= NearEqual( x[0] * x[0] *exp(x[1]), jac[0*n+1], 1e-10, 1e-10 ); ok &= NearEqual( x[0] * x[0] *cos(x[1]), jac[1*n+1], 1e-10, 1e-10 ); ok &= NearEqual(-x[0] * x[0] *sin(x[1]), jac[2*n+1], 1e-10, 1e-10 ); return ok; } // END C++ cppad-20160000.1/example/rev_two.cpp0000644000175200017650000000643512656321773016267 0ustar coincoin-web// $Id: rev_two.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin rev_two.cpp$$ $spell Cpp $$ $section Second Partials Reverse Driver: Example and Test$$ $code $verbatim%example/rev_two.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // ----------------------------------------------------- // define the template function in empty namespace // bool RevTwoCases(void) template bool RevTwoCases() { bool ok = true; using CppAD::AD; using CppAD::NearEqual; 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], 1e-10, 1e-10 ); ok &= NearEqual( 2.*x[0]*exp(x[1]), ddw[1*p+0], 1e-10, 1e-10 ); // partials of y[1] w.r.t x[1] is x[0] * x[0] * cos(x[1]) // check partials of F_1 w.r.t x[1] and x[k] for k = 0, 1 ok &= NearEqual( 2.*x[0]*cos(x[1]), ddw[0*p+1], 1e-10, 1e-10 ); ok &= NearEqual( -x[0]*x[0]*sin(x[1]), ddw[1*p+1], 1e-10, 1e-10 ); return ok; } } // End empty namespace # include # include 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 , std::vector >(); ok &= RevTwoCases< std::vector , std::vector >(); ok &= RevTwoCases< std::valarray , std::vector >(); // Run with VectorSize_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 >(); return ok; } // END C++ cppad-20160000.1/example/ode_gear_control.cpp0000644000175200017650000000722012656321773020100 0ustar coincoin-web// $Id: ode_gear_control.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ode_gear_control.cpp$$ $spell Runge $$ $section OdeGearControl: Example and Test$$ $mindex OdeGearControl$$ Define $latex X : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} X_0 (t) & = & - \exp ( - w_0 t ) \\ X_1 (t) & = & \frac{w_0}{w_1 - w_0} [ \exp ( - w_0 t ) - \exp( - w_1 t )] \end{array} \] $$ 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) \end{array} \] $$ The example tests OdeGearControl using the relations above: $code $verbatim%example/ode_gear_control.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # 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.; } } }; } bool OdeGearControl(void) { bool ok = true; // initial return value 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 = 1e-10; 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 &= CppAD::NearEqual(x0, xf[0], 1e-4, 1e-4); ok &= CppAD::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 &= CppAD::NearEqual(x1, xf[1], 1e-4, 1e-4); ok &= CppAD::NearEqual(0., ef[1], 1e-4, 1e-4); return ok; } // END C++ cppad-20160000.1/example/makefile.am0000644000175200017650000001152012656321773016161 0ustar coincoin-web# $Id: makefile.am 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. # ----------------------------------------------------------------------------- # automake input file # # CppAD puts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # ------------------------------------------------------------------------- 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 = -DCPPAD_ADOLC_EXAMPLES -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 EIGEN_FLAGS = -DCPPAD_EIGEN_EXAMPLES libeigen_a_CXXFLAGS = \ -g $(CXX_FLAGS_EIGEN) \ -DCPPAD_EIGEN_EXAMPLES \ -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_FLAGS = endif # ------------------------------------------------------------------------- # auto-tools does not support use of colpack EXTRA_DIST = \ test_one.sh.in \ colpack_hes.cpp \ colpack_jac.cpp \ $(ADOLC_EXTRA_FILES) \ $(EIGEN_EXTRA_FILES) # check_PROGRAMS = example # 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) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(ADOLC_FLAGS) \ $(EIGEN_FLAGS) # LDADD = $(ADOLC_LIB) $(BTHREAD_LIB) $(EIGEN_LIB) $(PTHREAD_LIB) # example_SOURCES = \ $(ADOLC_SRC_FILES) \ \ example.cpp \ abort_recording.cpp \ abs.cpp \ acos.cpp \ acosh.cpp \ add.cpp \ add_eq.cpp \ ad_assign.cpp \ ad_ctor.cpp \ ad_fun.cpp \ ad_in_c.cpp \ ad_input.cpp \ ad_output.cpp \ asin.cpp \ asinh.cpp \ atan.cpp \ atanh.cpp \ atan2.cpp \ azmul.cpp \ base_alloc.hpp \ base_require.cpp \ bender_quad.cpp \ bool_fun.cpp \ bool_sparsity.cpp \ capacity_order.cpp \ change_param.cpp \ check_for_nan.cpp \ check_numeric_type.cpp \ check_simple_vector.cpp \ compare.cpp \ compare_change.cpp \ complex_poly.cpp \ cond_exp.cpp \ conj_grad.cpp \ cos.cpp \ cosh.cpp \ cppad_vector.cpp \ dependency.cpp \ div.cpp \ div_eq.cpp \ equal_op_seq.cpp \ erf.cpp \ error_handler.cpp \ exp.cpp \ expm1.cpp \ for_one.cpp \ for_two.cpp \ forward.cpp \ forward_dir.cpp \ forward_order.cpp \ for_sparse_jac.cpp \ fun_assign.cpp \ fun_check.cpp \ hes_lagrangian.cpp \ hes_lu_det.cpp \ hes_minor_det.cpp \ hessian.cpp \ hes_times_dir.cpp \ independent.cpp \ index_sort.cpp \ integer.cpp \ interface2c.cpp\ interp_onetape.cpp\ interp_retape.cpp\ jac_lu_det.cpp \ jac_minor_det.cpp \ jacobian.cpp \ num_limits.cpp \ log.cpp \ log1p.cpp \ log10.cpp \ lu_factor.cpp \ lu_invert.cpp \ lu_ratio.cpp \ lu_solve.cpp \ lu_vec_ad.cpp \ lu_vec_ad.hpp \ lu_vec_ad_ok.cpp \ mul.cpp \ mul_eq.cpp \ mul_level.cpp \ mul_level_ode.cpp \ nan.cpp \ near_equal.cpp \ near_equal_ext.cpp \ number_skip.cpp \ numeric_type.cpp \ ode_err_control.cpp \ ode_err_maxabs.cpp \ ode_gear.cpp \ ode_gear_control.cpp\ ode_stiff.cpp \ ode_taylor.cpp \ opt_val_hes.cpp \ optimize.cpp \ par_var.cpp \ poly.cpp \ pow.cpp \ pow_int.cpp \ print_for.cpp \ reverse_any.cpp \ reverse_one.cpp \ reverse_three.cpp \ reverse_two.cpp \ rev_one.cpp \ rev_sparse_hes.cpp \ rev_sparse_jac.cpp \ rev_two.cpp \ romberg_mul.cpp \ romberg_one.cpp \ rosen_34.cpp \ runge45_1.cpp \ runge45_2.cpp \ seq_property.cpp \ simple_vector.cpp \ sign.cpp \ sin.cpp \ sinh.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp \ sparse_sub_hes.cpp \ sparsity_sub.cpp \ sqrt.cpp \ stack_machine.cpp \ sub.cpp \ sub_eq.cpp \ sub_sparse_hes.cpp \ tan.cpp \ tanh.cpp \ tape_index.cpp \ thread_alloc.cpp \ to_string.cpp \ unary_minus.cpp \ unary_plus.cpp \ value.cpp \ var2par.cpp \ vec_ad.cpp \ vector_bool.cpp test: check ./example cppad-20160000.1/example/acos.cpp0000644000175200017650000000407612656321773015526 0ustar coincoin-web/* $Id: acos.cpp 3680 2015-05-07 19:17:37Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin acos.cpp$$ $spell cos acos $$ $section The AD acos Function: Example and Test$$ $code $verbatim%example/acos.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool acos(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 10 times machine epsilon double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; 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; } // END C++ cppad-20160000.1/example/ode_gear.cpp0000644000175200017650000000771612656321773016352 0ustar coincoin-web// $Id: ode_gear.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ode_gear.cpp$$ $spell 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} \] $$ for $latex i = 1 , \ldots , n-1$$. It follows that $latex \[ \begin{array}{rclr} x_i(0) & = & 0 & {\rm for \; all \;} i \\ x_i ' (t) & = & 1 & {\rm if \;} i = 0 \\ x_i '(t) & = & (i+1) t^i = (i+1) x_{i-1} (t) & {\rm if \;} i > 0 \end{array} \] $$ The example tests OdeGear using the relations above: $code $verbatim%example/ode_gear.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # 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.; } } private: const bool use_x; }; } bool OdeGear(void) { bool ok = true; // initial return value size_t i, j; // temporary indices 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, 1e-10, 1e-10 ); // error bound should be zero up to order m-1 if( i + 1 < m ) ok &= CppAD::NearEqual( e[i], 0., 1e-10, 1e-10 ); // check value for next i check *= T[m]; } } return ok; } // END C++ cppad-20160000.1/example/hes_lagrangian.cpp0000644000175200017650000001374512656321773017546 0ustar coincoin-web// $Id: hes_lagrangian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin hes_lagrangian.cpp$$ $spell 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$$ $mindex HesLagrangian constructor$$ $code $verbatim%example/hes_lagrangian.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # 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; 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, 1e-10, 1e-10); // L_01 = L_10 = 0 ok &= NearEqual(H[0 * n + 1], 0., 1e-10, 1e-10); ok &= NearEqual(H[1 * n + 0], 0., 1e-10, 1e-10); // L_02 = L_20 = 0 ok &= NearEqual(H[0 * n + 2], 0., 1e-10, 1e-10); ok &= NearEqual(H[2 * n + 0], 0., 1e-10, 1e-10); // L_11 = 0 ok &= NearEqual(H[1 * n + 1], 0., 1e-10, 1e-10); // L_12 = L_21 = 0 ok &= NearEqual(H[1 * n + 2], 0., 1e-10, 1e-10); ok &= NearEqual(H[2 * n + 1], 0., 1e-10, 1e-10); // L_22 = - y1 / (x2 * x2) check = - y1 / (x2 * x2); ok &= NearEqual(H[2 * n + 2], check, 1e-10, 1e-10); return ok; } bool UseL() { using CppAD::AD; using CppAD::vector; // double values corresponding to XYZ vector double x0(.5), x1(1e3), x2(1), y0(2.), y1(3.), z(4.); // domain space vector size_t n = 3; vector< AD > XYZ(n); XYZ[0] = x0; XYZ[1] = x1; XYZ[2] = x2; // declare X as independent variable vector and start recording CppAD::Independent(XYZ); // add the Lagragian multipliers to XYZ // (note that this modifies the vector XYZ) XYZ.push_back(y0); XYZ.push_back(y1); XYZ.push_back(z); // range space vector size_t m = 1; vector< AD > L(m); L[0] = Lagragian(XYZ); // create K: X -> L and stop tape recording // We cannot use the ADFun sequence constructor because XYZ has // changed between the call to Independent and here. CppAD::ADFun K; K.Dependent(L); // Operation sequence corresponding to K does depends on // value of y0, y1, and z. Must redo calculations above when // 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 > X(n); X[0] = x0; X[1] = x1; X[2] = x2; // declare X as independent variable vector and start recording CppAD::Independent(X); // range space vector size_t m = 3; vector< AD > FG(m); FG = fg(X); // create K: X -> FG and stop tape recording CppAD::ADFun K; K.Dependent(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; // 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; } // END C++ cppad-20160000.1/example/runge45_1.cpp0000644000175200017650000000616212656321773016310 0ustar coincoin-web// $Id: runge45_1.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin runge45_1.cpp$$ $spell 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} \] $$ for $latex i = 1 , \ldots , n-1$$. It follows that $latex \[ \begin{array}{rclr} X_i(0) & = & 0 & {\rm for \; all \;} i \\ X_i ' (t) & = & 1 & {\rm if \;} i = 0 \\ X_i '(t) & = & (i+1) t^i = (i+1) X_{i-1} (t) & {\rm if \;} i > 0 \end{array} \] $$ The example tests Runge45 using the relations above: $code $verbatim%example/runge45_1.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include // for size_t # include // for CppAD::NearEqual # include // for CppAD::vector # include // for CppAD::Runge45 // Runge45 requires fabs to be defined (not std::fabs) // defines this for doubles, but runge_45.hpp does not. # 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] = (i+1) * x[i-1]; else f[i] = (i+1) * ti; } } private: const bool use_x; }; } bool runge_45_1(void) { bool ok = true; // initial return value size_t i; // 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] 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 &= CppAD::NearEqual(xf[i], check, 1e-10, 1e-10); // 4th order method is exact for i < 4 if( i < 4 ) ok &= (e[i] <= 1e-10); // check value for next i check *= tf; } } return ok; } // END C++ cppad-20160000.1/example/romberg_one.cpp0000644000175200017650000000377512656321773017104 0ustar coincoin-web// $Id: romberg_one.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin romberg_one.cpp$$ $spell Romberg $$ $section One Dimensional Romberg Integration: Example and Test$$ $code $verbatim%example/romberg_one.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # 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; } }; } 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) / (degree+1); // step size corresponding to r double step = (b - a) / exp(log(2.)*(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 < (degree+1) * spow; ok &= CppAD::NearEqual(check, r, 0., e); } return ok; } // END C++ cppad-20160000.1/example/ode_err_maxabs.cpp0000644000175200017650000000712012656321773017544 0ustar coincoin-web// $Id: ode_err_maxabs.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ode_err_maxabs.cpp$$ $spell Runge Maxabs $$ $section OdeErrControl: Example and Test Using Maxabs Argument$$ $mindex OdeErrControl$$ Define $latex X : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} X_0 (t) & = & - \exp ( - w_0 t ) \\ X_1 (t) & = & \frac{w_0}{w_1 - w_0} [ \exp ( - w_0 t ) - \exp( - w_1 t )] \end{array} \] $$ 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) \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 $verbatim%example/ode_err_maxabs.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include // for size_t # include // for exp # include // CppAD::OdeErrControl # include // CppAD::NearEqual # include // CppAD::vector # 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; } }; } bool OdeErrMaxabs(void) { 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); return ok; } // END C++ cppad-20160000.1/example/reverse_three.cpp0000644000175200017650000000743712656321773017447 0ustar coincoin-web// $Id: reverse_three.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin reverse_three.cpp$$ $spell Taylor Cpp $$ $section Third Order Reverse Mode: Example and Test$$ $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)} \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 $verbatim%example/reverse_three.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // ---------------------------------------------------------- // define the template function cases in empty namespace 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); 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; } // END C++ cppad-20160000.1/example/mul_level_ode.cpp0000644000175200017650000002244312656321773017412 0ustar coincoin-web/* $Id: mul_level_ode.cpp 3738 2015-10-05 13:16:50Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin mul_level_ode.cpp$$ $spell Taylor Cpp const std Adolc adouble $$ $section Taylor's Ode Solver: A Multi-Level AD Example and Test$$ $head Purpose$$ This is a realistic example using two levels of AD; see $cref mul_level$$. The first level uses $code AD$$ to tape the solution of an ordinary differential equation. This solution is then differentiated with respect to a parameter vector. The second level uses $code AD< AD >$$ to take derivatives during the solution of the differential equation. These derivatives are used in the application of Taylor's method to the solution of the ODE. 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 $latex \[ g(y) = \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$$ 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} \] $$ 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)$$. $head Source$$ $code $verbatim%example/mul_level_ode.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end -------------------------------------------------------------------------- */ // BEGIN C++ # include // ========================================================================= // define types for each level namespace { // BEGIN empty namespace typedef CppAD::AD a1type; typedef CppAD::AD a2type; // ------------------------------------------------------------------------- // class definition for C++ function object that defines ODE class Ode { private: // copy of a that is set by constructor and used by g(y) CPPAD_TESTVECTOR(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 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::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 f(a1x, a1y_final); // check function values double check = 1.; double t = 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 becasue 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; } // END C++ cppad-20160000.1/example/ode_stiff.cpp0000644000175200017650000001222712656321773016540 0ustar coincoin-web// $Id: ode_stiff.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ode_stiff.cpp$$ $spell 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) \end{array} \] $$ If $latex a_0 \gg a_1 > 0$$, this is a stiff Ode and the analytic solution is $latex \[ \begin{array}{rcl} x_0 (t) & = & \exp( - a_0 t ) \\ x_1 (t) & = & a_0 [ \exp( - a_1 t ) - \exp( - a_0 t ) ] / ( a_0 - a_1 ) \end{array} \] $$ The example tests Rosen34 using the relations above: $code $verbatim%example/ode_stiff.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include // 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; } // END C++ cppad-20160000.1/example/sin.cpp0000644000175200017650000000401212656321773015360 0ustar coincoin-web// $Id: sin.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sin.cpp$$ $spell sin $$ $section The AD sin Function: Example and Test$$ $code $verbatim%example/sin.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool Sin(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // 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, 1e-10, 1e-10); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], check, 1e-10, 1e-10); // 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, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/simple_vector.cpp0000644000175200017650000000556012656321773017453 0ustar coincoin-web// $Id: simple_vector.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin simple_vector.cpp$$ $spell Cpp $$ $section Simple Vector Template Class: Example and Test$$ $code $verbatim%example/simple_vector.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end -------------------------------------------------------------------------- */ // BEGIN C++ # include // std::cout and std::endl # include // std::vector # include // std::valarray # 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; } } bool SimpleVector (void) { bool ok = true; // 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 >(); # endif // use CheckSimpleVector for more extensive testing CppAD::CheckSimpleVector >(); CppAD::CheckSimpleVector >(); CppAD::CheckSimpleVector >(); CppAD::CheckSimpleVector >(); CppAD::CheckSimpleVector >(); return ok; } // END C++ cppad-20160000.1/example/abort_recording.cpp0000644000175200017650000000411012656321773017731 0ustar coincoin-web// $Id: abort_recording.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin abort_recording.cpp$$ $spell $$ $section Abort Current Recording: Example and Test$$ $mindex recording$$ $code $verbatim%example/abort_recording.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool abort_recording(void) { bool ok = true; double eps = 10. * CppAD::numeric_limits::epsilon(); 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); return ok; } // END C++ cppad-20160000.1/example/colpack_hes.cpp0000644000175200017650000000735012656321773017052 0ustar coincoin-web// $Id: colpack_hes.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin colpack_hes.cpp$$ $spell colpack_hes jacobian $$ $section Using ColPack: Example and Test$$ $mindex colpack hessian sparse$$ $code $verbatim%example/colpack_hes.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool colpack_hes(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; typedef CPPAD_TESTVECTOR(AD) a_vector; typedef CPPAD_TESTVECTOR(double) d_vector; typedef CppAD::vector i_vector; size_t i, j, k, ell; double eps = 10. * CppAD::numeric_limits::epsilon(); // domain space vector size_t n = 5; a_vector a_x(n); for(j = 0; j < n; j++) a_x[j] = AD (0); // declare independent variables and starting recording CppAD::Independent(a_x); // colpack example case where hessian is a spear head // i.e, H(i, j) non zero implies i = 0, j = 0, or i = j AD sum = 0.0; // partial_0 partial_j = x[j] // partial_j partial_j = x[0] for(j = 1; j < n; j++) sum += a_x[0] * a_x[j] * a_x[j] / 2.0; // // partial_i partial_i = 2 * x[i] for(i = 0; i < n; i++) sum += a_x[i] * a_x[i] * a_x[i] / 3.0; // declare dependent variables size_t m = 1; a_vector a_y(m); a_y[0] = sum; // create f: x -> y and stop tape recording CppAD::ADFun f(a_x, a_y); // new value for the independent variable vector d_vector x(n); for(j = 0; j < n; j++) x[j] = double(j + 1); /* [ 2 2 3 4 5 ] hes = [ 2 5 0 0 0 ] [ 3 0 7 0 0 ] [ 4 0 0 9 0 ] [ 5 0 0 0 11 ] */ d_vector check(n * n); for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { size_t index = i * n + j; check[index] = 0.0; if( i == 0 && 1 <= j ) check[index] += x[j]; if( 1 <= i && j == 0 ) check[index] += x[i]; if( i == j ) { check[index] += 2.0 * x[i]; if( i != 0 ) check[index] += x[0]; } } } // Normally one would use f.RevSparseHes to compute // sparsity pattern, but for this example we extract it from check. std::vector< std::set > p(n); i_vector row, col; for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { ell = i * n + j; if( check[ell] != 0. ) { // insert this non-zero entry in sparsity pattern p[i].insert(j); // the Hessian is symmetric, so only upper lower triangle if( j <= i ) { row.push_back(i); col.push_back(j); } } } } size_t K = row.size(); d_vector hes(K); // contrast and check results using both cppad and colpack CppAD::sparse_hessian_work work; for(size_t i_method = 0; i_method < 3; i_method++) { // empty work structure ok &= work.color_method == "cppad.symmetric"; if( i_method == 2 ) work.color_method = "colpack.star"; // compute Hessian d_vector w(m); w[0] = 1.0; size_t n_sweep = f.SparseHessian(x, w, p, row, col, hes, work); // check result for(k = 0; k < K; k++) { ell = row[k] * n + col[k]; ok &= NearEqual(check[ell], hes[k], eps, eps); } if( work.color_method != "cppad.general" ) ok &= n_sweep == 2; else ok &= n_sweep == 5; // // check that clear resets color_method to cppad.symmetric work.clear(); ok &= work.color_method == "cppad.symmetric"; } return ok; } // END C++ cppad-20160000.1/example/lu_vec_ad.cpp0000644000175200017650000002024312656321773016514 0ustar coincoin-web// $Id: lu_vec_ad.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin lu_vec_ad.cpp$$ $escape #$$ $spell 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%)%$$ $head Purpose$$ Solves the linear equation $latex \[ Matrix * Result = Rhs \] $$ where $icode Matrix$$ is an $latex n \times n$$ matrix, $icode Rhs$$ is an $latex n x m$$ matrix, and $icode Result$$ is an $latex n x m$$ matrix. $pre $$ The routine $cref LuSolve$$ uses an arbitrary vector type, instead of $cref VecAD$$, to hold its elements. The pivoting operations for a $code ADFun$$ object corresponding to an $code LuVecAD$$ solution will change to be optimal for the matrix being factored. $pre $$ It is often the case that $code LuSolve$$ is faster than $code LuVecAD$$ when $code LuSolve$$ uses a simple vector class with $cref/elements of type double/SimpleVector/Elements of Specified Type/$$, but the corresponding $cref ADFun$$ objects have a fixed set of pivoting operations. $head Storage Convention$$ The matrices stored in row major order. To be specific, if $latex A$$ contains the vector storage for an $latex n x m$$ matrix, $latex i$$ is between zero and $latex n-1$$, and $latex j$$ is between zero and $latex m-1$$, $latex \[ A_{i,j} = A[ i * m + j ] \] $$ (The length of $latex A$$ must be equal to $latex n * m $$.) $head n$$ is the number of rows in $icode Matrix$$, $icode Rhs$$, and $icode Result$$. $head m$$ is the number of columns in $icode Rhs$$ and $icode Result$$. It is ok for $icode m$$ to be zero which is reasonable when you are only interested in the determinant of $icode Matrix$$. $head Matrix$$ On input, this is an $latex n \times n$$ matrix containing the variable coefficients for the equation we wish to solve. On output, the elements of $icode Matrix$$ have been overwritten and are not specified. $head Rhs$$ On input, this is an $latex n \times m$$ matrix containing the right hand side for the equation we wish to solve. On output, the elements of $icode Rhs$$ have been overwritten and are not specified. If $icode m$$ is zero, $icode Rhs$$ is not used. $head Result$$ On input, this is an $latex n \times m$$ matrix and the value of its elements do not matter. On output, the elements of $icode Rhs$$ contain the solution of the equation we wish to solve (unless the value returned by $code LuVecAD$$ is equal to zero). If $icode m$$ is zero, $icode Result$$ is not used. $head 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 Matrix$$ (but not quite). To be more specific, 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 ) \] $$ This enables $code LuVecAD$$ to use logs of absolute values. $head Example$$ $children% example/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 ------------------------------------------------------------------------------ */ # include "lu_vec_ad.hpp" # include // BEGIN CppAD namespace namespace CppAD { AD LuVecAD( size_t n, size_t m, CppAD::VecAD &Matrix, CppAD::VecAD &Rhs, CppAD::VecAD &Result, CppAD::AD &logdet) { 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 = abs(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 = abs(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; } } // END CppAD namespace cppad-20160000.1/example/opt_val_hes.cpp0000644000175200017650000001121012656321773017070 0ustar coincoin-web// $Id: opt_val_hes.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin opt_val_hes.cpp$$ $spell hes $$ $section opt_val_hes: Example and Test$$ $mindex opt_val_hes$$ Fix $latex z \in \B{R}^\ell$$ and define the functions $latex S_k : \B{R} \times \B{R} \rightarrow \B{R}^\ell$$ by and $latex F : \B{R} \times \B{R} \rightarrow \B{R}$$ by $latex \[ \begin{array}{rcl} S_k (x, y) & = & \frac{1}{2} [ y * \sin ( x * t_k ) - z_k ]^2 \\ F(x, y) & = & \sum_{k=0}^{\ell-1} S_k (x, y) \end{array} \] $$ It follows that $latex \[ \begin{array}{rcl} \partial_y F(x, y) & = & \sum_{k=0}^{\ell-1} [ y * \sin ( x * t_k ) - z_k ] \sin( x * t_k ) \\ \partial_y \partial_y F(x, y) & = & \sum_{k=0}^{\ell-1} \sin ( x t_k )^2 \end{array} \] $$ Furthermore if we define $latex Y(x)$$ as solving the equation $latex \partial F[ x, Y(x) ] = 0 $$ we have $latex \[ \begin{array}{rcl} 0 & = & \sum_{k=0}^{\ell-1} [ Y(x) * \sin ( x * t_k ) - z_k ] \sin( x * t_k ) \\ Y(x) \sum_{k=0}^{\ell-1} \sin ( x * t_k )^2 - \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 } \end{array} \] $$ $code $verbatim%example/opt_val_hes.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # 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; } } 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); int signdet = 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 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; } // END C++ cppad-20160000.1/example/poly.cpp0000644000175200017650000000236712656321773015565 0ustar coincoin-web// $Id: poly.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin poly.cpp$$ $section Polynomial Evaluation: Example and Test$$ $code $verbatim%example/poly.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include 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; } // END C++ cppad-20160000.1/example/bool_sparsity.cpp0000644000175200017650000001215412656321773017466 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin bool_sparsity.cpp$$ $spell Bool $$ $section Using vectorBool Sparsity To Conserve Memory: Example and Test$$ $head Purpose$$ This example show how to conserve memory when computing sparsity patterns. $code $verbatim%example/bool_sparsity.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { using CppAD::vector; using std::cout; using CppAD::vectorBool; using CppAD::AD; using CppAD::ADFun; // function f(x) that we are computing sparsity patterns for template vector fun(const vector& x) { size_t n = x.size(); vector ret(n + 1); for(size_t j = 0; j < n; j++) { size_t k = (j + 1) % n; ret[j] = x[j] * x[j] * x[k]; } ret[n] = 0.0; return ret; } // check sparsity pattern for f(x) bool check_jac(const vectorBool& pattern, size_t n) { bool ok = true; for(size_t i = 0; i < n; i++) { size_t k = (i + 1) % n; for(size_t j = 0; j < n; j++) { bool non_zero = (i == j) || (j == k); ok &= pattern[ i * n + j] == non_zero; } } for(size_t j = 0; j < n; j++) ok &= pattern[ n * n + j] == false; return ok; } // check sparsity pattern for the Hessian of sum_i f_i(x) bool check_hes(const vectorBool& pattern, size_t n) { bool ok = true; for(size_t i = 0; i < n; i++) { size_t k1 = (i + 1) % n; size_t k2 = (n + i - 1) % n; for(size_t j = 0; j < n; j++) { bool non_zero = (i == j) || (j == k1) || (j == k2); ok &= pattern[ i * n + j] == non_zero; } } return ok; } // compute sparsity for Jacobian of f(x) using forward mode bool for_sparse_jac(ADFun& f) { bool ok = true; size_t n = f.Domain(); size_t m = f.Range(); // // number of columns of the sparsity patter to compute at a time size_t n_col = vectorBool::bit_per_unit(); vectorBool pattern(m * n), s(m * n_col), r(n * n_col); // size_t n_loop = (n - 1) / n_col + 1; for(size_t i_loop = 0; i_loop < n_loop; i_loop++) { size_t j_col = i_loop * n_col; for(size_t i = 0; i < n; i++) { for(size_t j = 0; j < n_col; j++) r[i * n_col + j] = (i == j_col + j); } s = f.ForSparseJac(n_col, r); for(size_t i = 0; i < m; i++) { for(size_t j = 0; j < n_col; j++) if( j_col + j < n ) pattern[ i * n + j_col + j ] = s[ i * n_col + j]; } } ok &= check_jac(pattern, n); // return ok; } // compute sparsity for Jacobian of f(x) using reverse mode bool rev_sparse_jac(ADFun& f) { bool ok = true; size_t n = f.Domain(); size_t m = f.Range(); // // number of rows of the sparsity patter to compute at a time size_t n_row = vectorBool::bit_per_unit(); vectorBool pattern(m * n), s(n_row * n), r(n_row * m); // size_t n_loop = (m - 1) / n_row + 1; for(size_t i_loop = 0; i_loop < n_loop; i_loop++) { size_t i_row = i_loop * n_row; for(size_t i = 0; i < n_row; i++) { for(size_t j = 0; j < m; j++) r[i * m + j] = (i_row + i == j); } s = f.RevSparseJac(n_row, r); for(size_t i = 0; i < n_row; i++) { for(size_t j = 0; j < n; j++) if( i_row + i < m ) pattern[ (i_row + i) * n + j ] = s[ i * n + j]; } } ok &= check_jac(pattern, n); // return ok; } // compute sparsity for Hessian of sum_i f_i (x) bool rev_sparse_hes(ADFun& f) { bool ok = true; size_t n = f.Domain(); size_t m = f.Range(); // // number of columns of the sparsity patter to compute at a time size_t n_col = vectorBool::bit_per_unit(); vectorBool pattern(n * n), r(n * n_col), h(n * n_col); // consider case where Hessian for sum of f_i(x) w.r.t i vectorBool s(m); for(size_t i = 0; i < m; i++) s[i] = true; // size_t n_loop = (n - 1) / n_col + 1; for(size_t i_loop = 0; i_loop < n_loop; i_loop++) { size_t j_col = i_loop * n_col; for(size_t i = 0; i < n; i++) { for(size_t j = 0; j < n_col; j++) r[i * n_col + j] = (i == j_col + j); } // f.ForSparseJac(n_col, r); bool transpose = true; h = f.RevSparseHes(n_col, s, transpose); // for(size_t i = 0; i < n; i++) { for(size_t j = 0; j < n_col; j++) if( j_col + j < n ) pattern[ i * n + j_col + j ] = h[ i * n_col + j]; } } ok &= check_hes(pattern, n); // return ok; } } // driver for all of the cases above bool bool_sparsity(void) { bool ok = true; // // record the funcion size_t n = 100; size_t m = n + 1; vector< AD > x(n), y(m); for(size_t j = 0; j < n; j++) x[j] = AD(j+1); CppAD::Independent(x); y = fun(x); ADFun f(x, y); // // run the three example / tests ok &= for_sparse_jac(f); ok &= rev_sparse_jac(f); ok &= rev_sparse_hes(f); return ok; } // END C++ cppad-20160000.1/example/expm1.cpp0000644000175200017650000000376512656321773015637 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin expm1.cpp$$ $spell exp $$ $section The AD exp Function: Example and Test$$ $code $verbatim%example/expm1.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool expm1(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) ax(n); ax[0] = x0; // declare independent variables and start tape recording CppAD::Independent(ax); // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = CppAD::expm1(ax[0]); // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); // expx0 value double expx0 = std::exp(x0); ok &= NearEqual(ay[0], expx0-1.0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], expx0, eps, eps); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], expx0, eps, eps); // use a VecAD::reference object with exp CppAD::VecAD v(1); AD zero(0); v[zero] = x0; AD result = CppAD::expm1(v[zero]); ok &= NearEqual(result, expx0-1.0, eps, eps); return ok; } // END C++ cppad-20160000.1/example/change_param.cpp0000644000175200017650000000767512656321773017216 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include /* $begin change_param.cpp$$ $spell Jacobian $$ $section Computing a Jacobian With Constants that Change$$ $mindex multiple AD level$$ $head Purpose$$ In this example we use two levels of taping so that a derivative can have constant parameters that can be changed. To be specific, we consider the function $latex f : \B{R}^2 \rightarrow \B{R}^2$$ $latex \[ f(x) = p \left( \begin{array}{c} \sin( x_0 ) \\ \sin( x_1 ) \end{array} \right) \]$$ were $latex p \in \B{R}$$ is a parameter. The Jacobian of this function is $latex \[ g(x,p) = p \left( \begin{array}{cc} \cos( x_0 ) & 0 \\ 0 & \cos( x_1 ) \end{array} \right) \] $$ In this example we use two levels of AD to avoid computing the partial of $latex f(x)$$ with respect to $latex p$$, but still allow for the evaluation of $latex g(x, p)$$ at different values of $latex p$$. $end */ bool change_param(void) { bool ok = true; // initialize test result typedef CppAD::AD a1type; // for first level of taping typedef CppAD::AD a2type; // for second level of taping size_t nu = 3; // number components in u size_t nx = 2; // number components in x size_t ny = 2; // num components in f(x) size_t nJ = ny * nx; // number components in Jacobian of f(x) // temporary indices size_t j; // declare first level of independent variables // (Start taping now so can record dependency of a1f on a1p.) CPPAD_TESTVECTOR(a1type) a1u(nu); for(j = 0; j < nu; j++) a1u[j] = 0.; CppAD::Independent(a1u); // parameter in computation of Jacobian a1type a1p = a1u[2]; // declare second level of independent variables CPPAD_TESTVECTOR(a2type) a2x(nx); for(j = 0; j < nx; j++) a2x[j] = 0.; CppAD::Independent(a2x); // compute dependent variables at second level CPPAD_TESTVECTOR(a2type) a2y(ny); a2y[0] = sin( a2x[0] ) * a1p; a2y[1] = sin( a2x[1] ) * a1p; // declare function object that computes values at the first level // (make sure we do not run zero order forward during constructor) CppAD::ADFun a1f; a1f.Dependent(a2x, a2y); // compute the Jacobian of a1f at a1u[0], a1u[1] CPPAD_TESTVECTOR(a1type) a1x(nx); a1x[0] = a1u[0]; a1x[1] = a1u[1]; CPPAD_TESTVECTOR(a1type) a1J(nJ); a1J = a1f.Jacobian( a1x ); // declare function object that maps u = (x, p) to Jacobian of f // (make sure we do not run zero order forward during constructor) CppAD::ADFun g; g.Dependent(a1u, a1J); // remove extra variables used during the reconding of a1f, // but not needed any more. g.optimize(); // compute the Jacobian of f using zero order forward // sweep with double values CPPAD_TESTVECTOR(double) J(nJ), u(nu); for(j = 0; j < nu; j++) u[j] = double(j+1); J = g.Forward(0, u); // accuracy for tests double eps = 100. * CppAD::numeric_limits::epsilon(); // y[0] = sin( x[0] ) * p // y[1] = sin( x[1] ) * p CPPAD_TESTVECTOR(double) x(nx); x[0] = u[0]; x[1] = u[1]; double p = u[2]; // J[0] = partial y[0] w.r.t x[0] = cos( x[0] ) * p double check = cos( x[0] ) * p; ok &= fabs( check - J[0] ) <= eps; // J[1] = partial y[0] w.r.t x[1] = 0.; check = 0.; ok &= fabs( check - J[1] ) <= eps; // J[2] = partial y[1] w.r.t. x[0] = 0. check = 0.; ok &= fabs( check - J[2] ) <= eps; // J[3] = partial y[1] w.r.t x[1] = cos( x[1] ) * p check = cos( x[1] ) * p; ok &= fabs( check - J[3] ) <= eps; return ok; } // END PROGRAM cppad-20160000.1/example/hessian.cpp0000644000175200017650000000527312656321773016233 0ustar coincoin-web// $Id: hessian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin hessian.cpp$$ $spell Cpp Hessian $$ $section Hessian: Example and Test$$ $mindex Hessian$$ $code $verbatim%example/hessian.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // --------------------------------------------------------- // define the template function HessianCases in empty namespace template bool HessianCases() { bool ok = true; using CppAD::AD; using CppAD::NearEqual; 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], 1e-10, 1e-10 ); ok &= NearEqual( 2.*x[0]*cos(x[1]), hes[0*n+1], 1e-10, 1e-10 ); ok &= NearEqual( 2.*x[0]*cos(x[1]), hes[1*n+0], 1e-10, 1e-10 ); ok &= NearEqual( - x[0]*x[0]*sin(x[1]), hes[1*n+1], 1e-10, 1e-10 ); 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; } // END C++ cppad-20160000.1/example/dependency.cpp0000644000175200017650000001024612656321773016713 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin dependency.cpp$$ $spell CppAD Jac $$ $section Computing Dependency: Example and Test$$ $head Discussion$$ The partial of an dependent variable with respect to an independent variable might always be zero even though the dependent variable depends on the value of the dependent variable. Consider the following case $latex \[ f(x) = {\rm sign} (x) = \left\{ \begin{array}{rl} +1 & {\rm if} \; x > 0 \\ 0 & {\rm if} \; x = 0 \\ -1 & {\rm if} \; x < 0 \end{array} \right. \] $$ In this case the value of $latex f(x)$$ depends on the value of $latex x$$ but CppAD always returns zero for the derivative of the $cref sign$$ function. $head Dependency Pattern$$ If the $th i$$ dependent variables depends on the value of the $th j$$ independent variable, the corresponding entry in the dependency pattern is non-zero (true). Otherwise it is zero (false). CppAD uses $cref/sparsity patterns/glossary/Sparsity Pattern/$$ to represent dependency matrices. The $icode dependency$$ argument to $cref/ForSparseJac/ForSparseJac/dependency/$$ and $cref/RevSparseJac/RevSparseJac/dependency/$$ is a flag that signals that the dependency pattern (instead of the sparsity pattern) is computed. $code $verbatim%example/dependency.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { double heavyside(const double& x) { if( x <= 0.0 ) return 0.0; return 1.0; } CPPAD_DISCRETE_FUNCTION(double, heavyside) } bool dependency(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // VecAD object for use later CppAD::VecAD vec_ad(2); vec_ad[0] = 0.0; vec_ad[1] = 1.0; // domain space vector size_t n = 5; CPPAD_TESTVECTOR(AD) ax(n); for(size_t j = 0; j < n; j++) ax[j] = AD(j + 1); // declare independent variables and start tape recording CppAD::Independent(ax); // some AD constants AD azero(0.0), aone(1.0); // range space vector size_t m = n; size_t m1 = n - 1; CPPAD_TESTVECTOR(AD) ay(m); ay[m1-0] = sign( ax[0] ); ay[m1-1] = CondExpLe( ax[1], azero, azero, aone); ay[m1-2] = CondExpLe( azero, ax[2], azero, aone); ay[m1-3] = heavyside( ax[3] ); ay[m1-4] = vec_ad[ ax[4] - AD(4.0) ]; // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); // ----------------------------------------------------------- // ForSparseJac and bool dependency bool transpose = false; bool dependency; // could replace CppAD::vectorBooll by CPPAD_TEST_VECTOR CppAD::vectorBool eye_bool(n * n), depend_bool(m * n); for(size_t i = 0; i < n; i++) { for(size_t j = 0; j < n; j++) eye_bool[i * n + j] = (i == j); } dependency = true; depend_bool = f.ForSparseJac(n, eye_bool, transpose, dependency); for(size_t i = 0; i < m; i++) { for(size_t j = 0; j < n; j++) ok &= depend_bool[i * n + j] == (i == (m1-j)); } dependency = false; depend_bool = f.ForSparseJac(n, eye_bool, transpose, dependency); for(size_t i = 0; i < m; i++) { for(size_t j = 0; j < n; j++) ok &= depend_bool[i * n + j] == false; } // ----------------------------------------------------------- // RevSparseJac and set dependency CppAD::vector< std::set > eye_set(m), depend_set(m); for(size_t i = 0; i < m; i++) { ok &= eye_set[i].empty(); eye_set[i].insert(i); } dependency = true; depend_set = f.RevSparseJac(n, eye_set, transpose, dependency); for(size_t i = 0; i < m; i++) { std::set check; check.insert(m1 - i); ok &= depend_set[i] == check; } dependency = false; depend_set = f.RevSparseJac(n, eye_set, transpose, dependency); for(size_t i = 0; i < m; i++) ok &= depend_set[i].empty(); return ok; } // END C++ cppad-20160000.1/example/example.cpp0000644000175200017650000003337612656321773016241 0ustar coincoin-web// $Id: example.cpp 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. -------------------------------------------------------------------------- */ /* $begin example.cpp$$ $spell Cpp $$ $section CppAD Examples and Tests$$ $head Running Tests$$ To build this program and run its correctness tests see $cref cmake_check$$. $code $verbatim%example/example.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ // system include files used for I/O # include // C style asserts # include // standard string # include // memory utility # include // prototype external compiled tests (this line expected by bin/new_test.sh) extern bool abort_recording(void); extern bool ad_assign(void); extern bool ad_ctor(void); extern bool abs(void); extern bool acos(void); extern bool acosh(void); extern bool Add(void); extern bool AddEq(void); extern bool ad_fun(void); extern bool ad_in_c(void); extern bool ad_input(void); extern bool ad_output(void); extern bool asin(void); extern bool asinh(void); extern bool atan(void); extern bool atanh(void); extern bool atan2(void); extern bool azmul(void); extern bool base_require(void); extern bool BenderQuad(void); extern bool BoolFun(void); extern bool bool_sparsity(void); extern bool capacity_order(void); extern bool change_param(void); extern bool check_for_nan(void); extern bool CheckNumericType(void); extern bool CheckSimpleVector(void); extern bool colpack_hes(void); extern bool colpack_jac(void); extern bool Compare(void); extern bool compare_change(void); extern bool complex_poly(void); extern bool CondExp(void); extern bool conj_grad(void); extern bool Cos(void); extern bool Cosh(void); extern bool CppAD_vector(void); extern bool dependency(void); extern bool Div(void); extern bool DivEq(void); extern bool eigen_array(void); extern bool eigen_det(void); extern bool EqualOpSeq(void); extern bool Erf(void); extern bool ErrorHandler(void); extern bool exp(void); extern bool expm1(void); extern bool ForOne(void); extern bool ForTwo(void); extern bool ForSparseJac(void); extern bool Forward(void); extern bool forward_dir(void); extern bool forward_order(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 index_sort(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 log(void); extern bool log10(void); extern bool log1p(void); extern bool LuFactor(void); extern bool LuInvert(void); extern bool LuRatio(void); extern bool LuSolve(void); extern bool LuVecADOk(void); extern bool Mul(void); extern bool MulEq(void); extern bool mul_level(void); extern bool mul_level_adolc(void); extern bool mul_level_ode(void); extern bool mul_level_adolc_ode(void); extern bool nan(void); extern bool Near_Equal(void); extern bool NearEqualExt(void); extern bool number_skip(void); extern bool NumericType(void); extern bool num_limits(void); extern bool OdeErrControl(void); extern bool OdeErrMaxabs(void); extern bool OdeGear(void); extern bool OdeGearControl(void); extern bool OdeStiff(void); extern bool ode_taylor(void); extern bool opt_val_hes(void); extern bool optimize(void); extern bool ParVar(void); extern bool Poly(void); extern bool pow(void); extern bool pow_int(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 RevSparseHes(void); extern bool RevSparseJac(void); extern bool RevTwo(void); extern bool RombergMul(void); extern bool RombergOne(void); extern bool Rosen34(void); extern bool runge_45_1(void); extern bool runge_45_2(void); extern bool seq_property(void); extern bool sign(void); extern bool SimpleVector(void); extern bool Sin(void); extern bool Sinh(void); extern bool sparse_hessian(void); extern bool sparse_jacobian(void); extern bool sparse_sub_hes(void); extern bool sparsity_sub(void); extern bool Sqrt(void); extern bool StackMachine(void); extern bool Sub(void); extern bool SubEq(void); extern bool sub_sparse_hes(void); extern bool Tan(void); extern bool Tanh(void); extern bool TapeIndex(void); extern bool thread_alloc(void); extern bool to_string(void); extern bool UnaryMinus(void); extern bool UnaryPlus(void); extern bool Value(void); extern bool Var2Par(void); extern bool vec_ad(void); extern bool vectorBool(void); namespace { // function that runs one test static size_t Run_ok_count = 0; static size_t Run_error_count = 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; // ok &= name.size() < size_t(width); ok &= TestOk(); if( ok ) { std::cout << "OK" << std::endl; Run_ok_count++; } else { std::cout << "Error" << std::endl; Run_error_count++; } return ok; } } // main program that runs all the tests int main(void) { bool ok = true; // This line is used by test_one.sh // run external compiled tests (this line expected by bin/new_test.sh) ok &= Run( abort_recording, "abort_recording" ); ok &= Run( ad_assign, "ad_assign" ); ok &= Run( ad_ctor, "ad_ctor" ); ok &= Run( abs, "abs" ); ok &= Run( acos, "acos" ); ok &= Run( acosh, "acosh" ); ok &= Run( Add, "Add" ); ok &= Run( AddEq, "AddEq" ); ok &= Run( ad_fun, "ad_fun" ); ok &= Run( ad_in_c, "ad_in_c" ); ok &= Run( ad_input, "ad_input" ); ok &= Run( ad_output, "ad_output" ); ok &= Run( asin, "asin" ); ok &= Run( asinh, "asinh" ); ok &= Run( atan, "atan" ); ok &= Run( atanh, "atanh" ); ok &= Run( atan2, "atan2" ); ok &= Run( azmul, "azmul" ); ok &= Run( BenderQuad, "BenderQuad" ); ok &= Run( BoolFun, "BoolFun" ); ok &= Run( bool_sparsity, "bool_sparsity" ); ok &= Run( capacity_order, "capacity_order" ); ok &= Run( change_param, "change_param" ); ok &= Run( check_for_nan, "check_for_nan" ); ok &= Run( CheckNumericType, "CheckNumericType" ); ok &= Run( CheckSimpleVector, "CheckSimpleVector"); ok &= Run( Compare, "Compare" ); ok &= Run( compare_change, "compare_change" ); ok &= Run( complex_poly, "complex_poly" ); ok &= Run( CondExp, "CondExp" ); ok &= Run( conj_grad, "conj_grad" ); ok &= Run( Cos, "Cos" ); ok &= Run( Cosh, "Cosh" ); ok &= Run( CppAD_vector, "CppAD_vector" ); ok &= Run( dependency, "dependency" ); ok &= Run( Div, "Div" ); ok &= Run( DivEq, "DivEq" ); ok &= Run( EqualOpSeq, "EqualOpSeq" ); ok &= Run( Erf, "Erf" ); ok &= Run( ErrorHandler, "ErrorHandler" ); ok &= Run( exp, "exp" ); ok &= Run( expm1, "expm1" ); ok &= Run( ForOne, "ForOne" ); ok &= Run( ForTwo, "ForTwo" ); ok &= Run( Forward, "Forward" ); ok &= Run( forward_dir, "forward_dir" ); ok &= Run( forward_order, "forward_order" ); ok &= Run( ForSparseJac, "ForSparseJac" ); ok &= Run( fun_assign, "fun_assign" ); ok &= Run( FunCheck, "FunCheck" ); ok &= Run( HesLagrangian, "HesLagrangian" ); ok &= Run( HesLuDet, "HesLuDet" ); ok &= Run( HesMinorDet, "HesMinorDet" ); ok &= Run( Hessian, "Hessian" ); ok &= Run( HesTimesDir, "HesTimesDir" ); ok &= Run( Independent, "Independent" ); ok &= Run( index_sort, "index_sort" ); ok &= Run( Integer, "Integer" ); ok &= Run( Interface2C, "Interface2C" ); ok &= Run( interp_onetape, "interp_onetape" ); ok &= Run( interp_retape, "interp_retape" ); ok &= Run( JacLuDet, "JacLuDet" ); ok &= Run( JacMinorDet, "JacMinorDet" ); ok &= Run( Jacobian, "Jacobian" ); ok &= Run( log, "log" ); ok &= Run( log10, "log10" ); ok &= Run( log1p, "log1p" ); ok &= Run( LuFactor, "LuFactor" ); ok &= Run( LuInvert, "LuInvert" ); ok &= Run( LuRatio, "LuRatio" ); ok &= Run( LuSolve, "LuSolve" ); ok &= Run( LuVecADOk, "LuVecADOk" ); ok &= Run( Mul, "Mul" ); ok &= Run( MulEq, "MulEq" ); ok &= Run( mul_level, "mul_level" ); ok &= Run( mul_level_ode, "mul_level_ode" ); ok &= Run( nan, "nan" ); ok &= Run( Near_Equal, "Near_Equal" ); ok &= Run( NearEqualExt, "NearEqualExt" ); ok &= Run( number_skip, "number_skip" ); ok &= Run( NumericType, "NumericType" ); ok &= Run( num_limits, "num_limits" ); ok &= Run( OdeErrControl, "OdeErrControl" ); ok &= Run( OdeErrMaxabs, "OdeErrMaxabs" ); ok &= Run( OdeGear, "OdeGear" ); ok &= Run( OdeGearControl, "OdeGearControl" ); ok &= Run( OdeStiff, "OdeStiff" ); ok &= Run( ode_taylor, "ode_taylor" ); ok &= Run( opt_val_hes, "opt_val_hes" ); ok &= Run( optimize, "optimize" ); ok &= Run( ParVar, "ParVar" ); ok &= Run( Poly, "Poly" ); ok &= Run( pow, "pow" ); ok &= Run( pow_int, "pow_int" ); ok &= Run( reverse_any, "reverse_any" ); ok &= Run( reverse_one, "reverse_one" ); ok &= Run( reverse_three, "reverse_three" ); ok &= Run( reverse_two, "reverse_two" ); ok &= Run( RevOne, "RevOne" ); ok &= Run( RevSparseHes, "RevSparseHes" ); ok &= Run( RevSparseJac, "RevSparseJac" ); ok &= Run( RevTwo, "RevTwo" ); ok &= Run( RombergMul, "RombergMul" ); ok &= Run( RombergOne, "RombergOne" ); ok &= Run( Rosen34, "Rosen34" ); ok &= Run( runge_45_1, "runge_45_1" ); ok &= Run( runge_45_2, "runge_45_2" ); ok &= Run( seq_property, "seq_property" ); ok &= Run( sign, "sign" ); ok &= Run( SimpleVector, "SimpleVector" ); ok &= Run( Sin, "Sin" ); ok &= Run( Sinh, "Sinh" ); ok &= Run( sparse_hessian, "sparse_hessian" ); ok &= Run( sparse_jacobian, "sparse_jacobian" ); ok &= Run( sparse_sub_hes, "sparse_sub_hes" ); ok &= Run( sparsity_sub, "sparsity_sub" ); ok &= Run( Sqrt, "Sqrt" ); ok &= Run( StackMachine, "StackMachine" ); ok &= Run( Sub, "Sub" ); ok &= Run( SubEq, "SubEq" ); ok &= Run( sub_sparse_hes, "sub_sparse_hes" ); ok &= Run( Tan, "Tan" ); ok &= Run( Tanh, "Tanh" ); ok &= Run( TapeIndex, "TapeIndex" ); ok &= Run( thread_alloc, "thread_alloc" ); ok &= Run( to_string, "to_string" ); ok &= Run( UnaryMinus, "UnaryMinus" ); ok &= Run( UnaryPlus, "UnaryPlus" ); ok &= Run( Value, "Value" ); ok &= Run( Var2Par, "Var2Par" ); ok &= Run( vec_ad, "vec_ad" ); ok &= Run( vectorBool, "vectorBool" ); # ifdef CPPAD_ADOLC_EXAMPLES ok &= Run( mul_level_adolc, "mul_level_adolc" ); ok &= Run( mul_level_adolc_ode, "mul_level_adolc_ode" ); # endif # ifdef CPPAD_COLPACK_EXAMPLES ok &= Run( colpack_hes, "colpack_hes" ); ok &= Run( colpack_jac, "colpack_jac" ); # endif # ifdef CPPAD_EIGEN_EXAMPLES ok &= Run( eigen_array, "eigen_array" ); ok &= Run( eigen_det, "eigen_det" ); # endif // check for errors using std::cout; using std::endl; assert( ok || (Run_error_count > 0) ); if( CppAD::thread_alloc::free_all() ) { Run_ok_count++; cout << "OK: " << "No memory leak detected" << endl; } else { ok = false; Run_error_count++; cout << "Error: " << "memory leak detected" << endl; } // Run base_require after memory leak check because base_alloc.hpp uses // thread_alloc to allocate memory for static copies of nan. ok &= Run( base_require, "base_require" ); // convert int(size_t) to avoid warning on _MSC_VER systems if( ok ) cout << "All " << int(Run_ok_count) << " tests passed." << endl; else cout << int(Run_error_count) << " tests failed." << endl; return static_cast( ! ok ); } // END C++ cppad-20160000.1/example/atan2.cpp0000644000175200017650000000420012656321773015573 0ustar coincoin-web// $Id: atan2.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin atan2.cpp$$ $spell tan atan $$ $section The AD atan2 Function: Example and Test$$ $code $verbatim%example/atan2.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include bool atan2(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., 1e-10, 1e-10); // reverse computation of derivative of y[0] CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n); w[0] = 1.; dw = f.Reverse(1, w); ok &= NearEqual(dw[0], 1., 1e-10, 1e-10); // 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, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/independent.cpp0000644000175200017650000000610612656321773017072 0ustar coincoin-web// $Id: independent.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. -------------------------------------------------------------------------- */ /* WARNING: This file is used an an example by omh/FunConstruct.omh. $begin independent.cpp$$ $comment ! NOTE the title states that this example is used two places !$$ $section Independent and ADFun Constructor: Example and Test$$ $code $verbatim%example/independent.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // -------------------------------------------------------- // define the template function Test(void) in empty namespace template bool Test(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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., 1e-10 , 1e-10); ok &= NearEqual(Y[1] , 0., 1e-10 , 1e-10); // 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., 1e-10 , 1e-10); ok &= NearEqual(y[1] , 2., 1e-10 , 1e-10); // 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., 1e-10 , 1e-10); ok &= NearEqual(dy[1] , x[1], 1e-10 , 1e-10); // 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., 1e-10 , 1e-10); ok &= NearEqual(dy[1] , x[0], 1e-10 , 1e-10); 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; } // END C++ cppad-20160000.1/example/lu_invert.cpp0000644000175200017650000000637412656321773016613 0ustar coincoin-web// $Id: lu_invert.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin lu_invert.cpp$$ $spell Geq Cpp Lu $$ $section LuInvert: Example and Test$$ $mindex LuInvert$$ $code $verbatim%example/lu_invert.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include // for rand function # include // for CppAD::LuInvert # include // for CppAD::NearEqual # include // for CppAD::vector bool LuInvert(void) { bool ok = true; # ifndef _MSC_VER using std::rand; using std::srand; # endif 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], 1e-10, 1e-10 ); } } return ok; } // END C++ cppad-20160000.1/example/near_equal.cpp0000644000175200017650000000370612656321773016714 0ustar coincoin-web// $Id: near_equal.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin near_equal.cpp$$ $spell cpp abs o Microsoft $$ $section NearEqual Function: Example and Test$$ $head File Name$$ This file is called $code near_equal.cpp$$ instead of $code NearEqual.cpp$$ to avoid a name conflict with $code ../lib/NearEqual.cpp$$ in the corresponding Microsoft project file. $code $verbatim%example/near_equal.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # 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); return ok; } // END C++ cppad-20160000.1/example/interp_onetape.cpp0000644000175200017650000001003712656321773017607 0ustar coincoin-web// $Id: interp_onetape.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin interp_onetape.cpp$$ $spell retaping retape $$ $section Interpolation With Out Retaping: Example and Test$$ $mindex interpolate tape retape$$ $head See Also$$ $cref interp_retape.cpp$$ $pre $$ $code $verbatim%example/interp_onetape.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # 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) } bool interp_onetape(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10, 1e-10); // evaluate f where x has different value x[0] = .7 * ArgumentValue[2] + .3 * ArgumentValue[3]; y = f.Forward(0, x); // check function value 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, 1e-10, 1e-10); // 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, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/hes_minor_det.cpp0000644000175200017650000000434012656321773017412 0ustar coincoin-web// $Id: hes_minor_det.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin hes_minor_det.cpp$$ $spell Cpp $$ $section Gradient of Determinant Using Expansion by Minors: Example and Test$$ $mindex minors$$ $code $verbatim%example/hes_minor_det.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include typedef std::complex Complex; typedef CppAD::AD 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 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]; return ok; } // END C++ cppad-20160000.1/example/for_sparse_jac.cpp0000644000175200017650000001423412656321773017556 0ustar coincoin-web// $Id: for_sparse_jac.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin for_sparse_jac.cpp$$ $spell Jacobian Jac Dep Cpp $$ $section Forward Mode Jacobian Sparsity: Example and Test$$ $mindex ForSparseJac sparsity$$ $code $verbatim%example/for_sparse_jac.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include namespace { // ------------------------------------------------------------- // define the template function BoolCases template // vector class, elements of type bool bool BoolCases(void) { bool ok = true; using CppAD::AD; // domain space vector size_t n = 2; 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; } // define the template function SetCases template // vector class, elements of type std::set bool SetCases(void) { bool ok = true; using CppAD::AD; // domain space vector size_t n = 2; 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; } } // 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 >(); return ok; } // END C++ cppad-20160000.1/example/rev_sparse_jac.cpp0000644000175200017650000001311112656321773017555 0ustar coincoin-web// $Id: rev_sparse_jac.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin rev_sparse_jac.cpp$$ $spell Jacobian Jac Dep Cpp $$ $section Reverse Mode Jacobian Sparsity: Example and Test$$ $mindex RevSparseJac sparsity$$ $code $verbatim%example/rev_sparse_jac.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // ------------------------------------------------------------- // define the template function BoolCases template // vector class, elements of type bool bool BoolCases(void) { bool ok = true; using CppAD::AD; // domain space vector size_t n = 2; 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; } // define the template function SetCases template // vector class, elements of type std::set bool SetCases(void) { bool ok = true; using CppAD::AD; // domain space vector size_t n = 2; 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; } } // 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 >(); return ok; } // END C++ cppad-20160000.1/example/stack_machine.cpp0000644000175200017650000001222612656321773017366 0ustar coincoin-web// $Id: stack_machine.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin stack_machine.cpp$$ $spell $$ $section Example Differentiating a Stack Machine Interpreter$$ $mindex test$$ $code $verbatim%example/stack_machine.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include # include # include # include # include 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 > &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; using std::string; using std::stack; using CppAD::AD; using CppAD::NearEqual; 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., 1e-10, 1e-10); ok &= NearEqual(dy[1], 2., 1e-10, 1e-10); ok &= NearEqual(dy[2], 2., 1e-10, 1e-10); ok &= NearEqual(dy[3], .5, 1e-10, 1e-10); // Use Jacobian routine (which automatically decides which mode to use) dy = f.Jacobian(x); ok &= NearEqual(dy[0], 1., 1e-10, 1e-10); ok &= NearEqual(dy[1], 2., 1e-10, 1e-10); ok &= NearEqual(dy[2], 2., 1e-10, 1e-10); ok &= NearEqual(dy[3], .5, 1e-10, 1e-10); return ok; } // END C++ cppad-20160000.1/example/jac_lu_det.cpp0000644000175200017650000000347112656321773016670 0ustar coincoin-web// $Id: jac_lu_det.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin jac_lu_det.cpp$$ $spell Lu Cpp $$ $section Gradient of Determinant Using Lu Factorization: Example and Test$$ $code $verbatim%example/jac_lu_det.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include bool JacLuDet(void) { bool ok = true; using namespace CppAD; size_t n = 2; // 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); // 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 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], 1e-10 , 1e-10 ); return ok; } // END C++ cppad-20160000.1/example/near_equal_ext.cpp0000644000175200017650000000312412656321773017566 0ustar coincoin-web// $Id: near_equal_ext.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin near_equal_ext.cpp$$ $spell cpp abs o Microsoft $$ $section Compare AD with Base Objects: Example and Test$$ $mindex NearEqualExt$$ $code $verbatim%example/near_equal_ext.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # 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); return ok; } // END C++ cppad-20160000.1/example/CMakeLists.txt0000644000175200017650000001103712656321773016630 0ustar coincoin-web# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the example directory tests # Inherit environment from ../CMakeList.txt # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # initialize check_depends SET(check_depends example) # atomic examples ADD_SUBDIRECTORY(atomic) add_to_list(check_depends check_example_atomic) # adolc_prefix SET(sources mul_level_adolc.cpp mul_level_adolc_ode.cpp) sources_libs_define(adolc "${sources}" adolc ADOLC_EXAMPLES) # colpack_prefix SET(colpack_sources colpack_hes.cpp colpack_jac.cpp ) # eigen_prefix IF ( eigen_prefix ) # compile eigen library separately so can use different compiler flags ADD_LIBRARY(example_eigen_lib EXCLUDE_FROM_ALL eigen_det.cpp eigen_array.cpp ) # Adds -D define flags to the compilation of source files. ADD_DEFINITIONS("-DCPPAD_EIGEN_EXAMPLES") add_cppad_cxx_flags(example_eigen_lib) # # Add eigen to list of libraries SET(eigen_libs example_eigen_lib) ELSE ( eigen_prefix ) SET(eigen_libs "") ENDIF ( eigen_prefix ) # ipopt_prefix IF( ipopt_prefix ) ADD_SUBDIRECTORY(ipopt_solve) add_to_list(check_depends check_example_ipopt_solve) ENDIF( ipopt_prefix ) # Copy a file to another location and modify its contents. # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(example EXCLUDE_FROM_ALL example.cpp ${adolc_sources} ${colpack_sources} abort_recording.cpp abs.cpp acos.cpp acosh.cpp add.cpp add_eq.cpp ad_assign.cpp ad_ctor.cpp ad_fun.cpp ad_in_c.cpp ad_input.cpp ad_output.cpp asin.cpp asinh.cpp atan.cpp atanh.cpp atan2.cpp azmul.cpp base_alloc.hpp base_require.cpp bender_quad.cpp bool_fun.cpp bool_sparsity.cpp capacity_order.cpp change_param.cpp check_for_nan.cpp check_numeric_type.cpp check_simple_vector.cpp compare.cpp compare_change.cpp complex_poly.cpp cond_exp.cpp conj_grad.cpp cos.cpp cosh.cpp cppad_vector.cpp dependency.cpp div.cpp div_eq.cpp equal_op_seq.cpp erf.cpp error_handler.cpp exp.cpp expm1.cpp for_one.cpp for_two.cpp forward.cpp forward_dir.cpp forward_order.cpp for_sparse_jac.cpp fun_assign.cpp fun_check.cpp hes_lagrangian.cpp hes_lu_det.cpp hes_minor_det.cpp hessian.cpp hes_times_dir.cpp independent.cpp index_sort.cpp integer.cpp interface2c.cpp interp_onetape.cpp interp_retape.cpp jac_lu_det.cpp jac_minor_det.cpp jacobian.cpp num_limits.cpp log.cpp log1p.cpp log10.cpp lu_factor.cpp lu_invert.cpp lu_ratio.cpp lu_solve.cpp lu_vec_ad.cpp lu_vec_ad.hpp lu_vec_ad_ok.cpp mul.cpp mul_eq.cpp mul_level.cpp mul_level_ode.cpp nan.cpp near_equal.cpp near_equal_ext.cpp number_skip.cpp numeric_type.cpp ode_err_control.cpp ode_err_maxabs.cpp ode_gear.cpp ode_gear_control.cpp ode_stiff.cpp ode_taylor.cpp opt_val_hes.cpp optimize.cpp par_var.cpp poly.cpp pow.cpp pow_int.cpp print_for.cpp reverse_any.cpp reverse_one.cpp reverse_three.cpp reverse_two.cpp rev_one.cpp rev_sparse_hes.cpp rev_sparse_jac.cpp rev_two.cpp romberg_mul.cpp romberg_one.cpp rosen_34.cpp runge45_1.cpp runge45_2.cpp seq_property.cpp simple_vector.cpp sign.cpp sin.cpp sinh.cpp sparse_hessian.cpp sparse_jacobian.cpp sparse_sub_hes.cpp sparsity_sub.cpp sqrt.cpp stack_machine.cpp sub.cpp sub_eq.cpp sub_sparse_hes.cpp tan.cpp tanh.cpp tape_index.cpp thread_alloc.cpp to_string.cpp unary_minus.cpp unary_plus.cpp value.cpp var2par.cpp vec_ad.cpp vector_bool.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags(example) # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(example ${cppad_lib} ${adolc_libs} ${colpack_libs} ${eigen_libs} ) # Add the check_example target ADD_CUSTOM_TARGET(check_example example DEPENDS ${check_depends}) cppad-20160000.1/example/base_require.cpp0000644000175200017650000000377612656321773017255 0ustar coincoin-web// $Id: base_require.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin base_require.cpp$$ $spell alloc $$ $section Using a User Defined AD Base Type: Example and Test$$ $mindex type$$ $code $verbatim%example/base_require.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $head Purpose$$ The type $code base_alloc$$, defined in $cref base_alloc.hpp$$, meets the requirements specified by $cref base_require$$ for $icode Base$$ in $codei%AD<%Base%>%$$. The program below is an example use of $codei%AD%$$. $end */ // BEGIN C++ # include "base_alloc.hpp" # 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); return ok; } // END C++ cppad-20160000.1/example/rev_sparse_hes.cpp0000644000175200017650000001314012656321773017601 0ustar coincoin-web// $Id: rev_sparse_hes.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin rev_sparse_hes.cpp$$ $spell Hessian Jac Hes Dep Cpp $$ $section Reverse Mode Hessian Sparsity: Example and Test$$ $mindex RevSparseHes sparsity$$ $code $verbatim%example/rev_sparse_hes.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include 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 in empty namespace template // 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) 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 = 2; CPPAD_TESTVECTOR(AD) Y(m); Y[0] = sin( X[2] ); Y[1] = X[0] * 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); } // 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 in empty namespace template // vector class, elements of type std::set bool SetCases(void) { bool ok = true; using CppAD::AD; // 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 = 2; CPPAD_TESTVECTOR(AD) Y(m); Y[0] = sin( X[2] ); Y[1] = X[0] * 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); } // 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; } } // End empty namespace # include # include bool RevSparseHes(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 >(); return ok; } // END C++ cppad-20160000.1/example/sparse_jacobian.cpp0000644000175200017650000001555712656321773017732 0ustar coincoin-web// $Id: sparse_jacobian.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin sparse_jacobian.cpp$$ $spell Cpp Jacobian $$ $section Sparse Jacobian: Example and Test$$ $mindex Jacobian spare$$ $code $verbatim%example/sparse_jacobian.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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; 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; return ok; } } // End empty namespace bool sparse_jacobian(void) { bool ok = true; ok &= forward(); ok &= reverse(); return ok; } // END C++ cppad-20160000.1/example/eigen_array.cpp0000644000175200017650000000374712656321773017072 0ustar coincoin-web// $Id: eigen_array.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin eigen_array.cpp$$ $spell Eigen $$ $section Using Eigen Arrays: Example and Test$$ $mindex array$$ $code $verbatim%example/eigen_array.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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() + sin(a_x.array()); // 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); } } return ok; } // END C++ cppad-20160000.1/example/interface2c.cpp0000644000175200017650000001116512656321773016763 0ustar coincoin-web// $Id: interface2c.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin interface2c.cpp$$ $spell $$ $section Interfacing to C: Example and Test$$ $mindex C interface difference central$$ $code $verbatim%example/interface2c.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include // CppAD utilities # include // 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 Float sumGauss(const Float &x, const CppAD::vector &a) { // number of components in a size_t na = a.size(); // number of Gaussians size_t n = na / 3; // check the restricitons on na 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 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 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]; // 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 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 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; } // END C++ cppad-20160000.1/example/reverse_two.cpp0000644000175200017650000000546312656321774017147 0ustar coincoin-web// $Id: reverse_two.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin reverse_two.cpp$$ $spell Cpp $$ $section Second Order Reverse ModeExample and Test$$ $mindex example$$ $code $verbatim%example/reverse_two.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // ---------------------------------------------------------- // define the template function reverse_two_cases in empty namespace template bool reverse_two_cases(void) { bool ok = true; 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[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], 1e-10, 1e-10); // 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, 1e-10, 1e-10); // 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], 1e-10, 1e-10); ok &= NearEqual(dw[1*2+0] , x[0]*x[0], 1e-10, 1e-10); // check derivative of f^{(1)} (x) * dx check = 2.*x[1]*dx[1] + 2.*x[0]*dx[1]; ok &= NearEqual(dw[0*2+1] , check, 1e-10, 1e-10); check = 2.*x[0]*dx[1]; ok &= NearEqual(dw[1*2+1] , check, 1e-10, 1e-10); 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; } // END C++ cppad-20160000.1/example/lu_vec_ad_ok.cpp0000644000175200017650000000664012656321774017213 0ustar coincoin-web// $Id: lu_vec_ad_ok.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin lu_vec_ad_ok.cpp$$ $spell Geq Cpp Lu $$ $section Lu Factor and Solve With Recorded Pivoting: Example and Test$$ $mindex record pivot$$ $code $verbatim%example/lu_vec_ad_ok.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include "lu_vec_ad.hpp" # include bool LuVecADOk(void) { bool ok = true; using namespace CppAD; typedef AD ADdouble; 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, 1e-10, 1e-10); // 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, 1e-10, 1e-10 ); } } CPPAD_TESTVECTOR(double) y2(1 + n * m); CPPAD_TESTVECTOR(double) A2(n * n); for(i = 0; i < n * n; i++) A[i] = A2[i] = a2[i]; y2 = f.Forward(0, A2); determinant = Det(A); ok &= NearEqual(y2[ n * m], Value(determinant), 1e-10, 1e-10); // Check solution of Rhs = A2 * Result for(k = 0; k < m; k++) { 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, 1e-10, 1e-10 ); } } return ok; } // END C++ cppad-20160000.1/example/tape_index.cpp0000644000175200017650000000500612656321774016714 0ustar coincoin-web// $Id: tape_index.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin tape_index.cpp$$ $section Taping Array Index Operation: Example and Test$$ $mindex tape operation$$ $code $verbatim%example/tape_index.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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) } bool TapeIndex(void) { 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 return ok; } // END C++ cppad-20160000.1/example/reverse_any.cpp0000644000175200017650000001606612656321774017126 0ustar coincoin-web// $Id: reverse_any.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin reverse_any.cpp$$ $spell Taylor $$ $section Reverse Mode General Case: Example and Test$$ $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$$). 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(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$$ We apply reverse mode to compute the derivative of $latex H : \B{R}^2 \rightarrow \B{R}$$ 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 \end{array} \] $$ Given the zero and first order Taylor coefficients $latex x^{(0)} $$ and $latex x^{(1)}$$, we use $latex X(t)$$, $latex Y(t)$$ and $latex Z(t)$$ for the corresponding functions; i.e., $latex \[ \begin{array}{rcl} X(t) & = & x^{(0)} + x^{(1)} t \\ 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: $list number$$ Use forward mode on $latex F(x)$$ to compute $latex y^{(0)}$$ and $latex y^{(1)}$$. $lnext Free some, or all, of the memory corresponding to $latex F(x)$$. $lnext Use forward mode on $latex G(y)$$ to compute $latex z^{(0)}$$ and $latex z^{(1)}$$ $lnext Use reverse mode on $latex G(y)$$ to compute the derivative of $latex h^{(1)}$$ with respect to $latex y^{(0)}$$ and $latex y^{(1)}$$. $lnext Free all the memory corresponding to $latex G(y)$$. $lnext Use reverse mode on $latex F(x)$$ to compute the derivative of $latex h^{(1)}$$ with respect to $latex x^{(0)}$$ and $latex x^{(1)}$$. $lend 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)} ] \end{array} \] $$ where $latex \partial_{x(0)}$$ denotes the partial with respect to $latex x^{(0)}$$. $code $verbatim%example/reverse_any.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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; } } 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); return ok; } } bool reverse_any(void) { bool ok = true; ok &= reverse_any_case(true); ok &= reverse_any_case(false); return ok; } // END C++ cppad-20160000.1/example/base_alloc.hpp0000644000175200017650000002165612656321774016676 0ustar coincoin-web// $Id: base_alloc.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_BASE_ALLOC_HPP # define CPPAD_BASE_ALLOC_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin base_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 $$ $section Example AD Where Base Constructor Allocates Memory$$ $head Purpose$$ Demonstrate use of $codei%AD<%Base%>%$$ where memory is allocated for each element of the type $icode Base$$. In addition, this is a complete example where all the $cref/required Base/base_require/$$ type operations are defined (as apposed to other examples where some of the operations for the Base type are already defined). $head Include File$$ This file uses some of the definitions in $cref base_require$$ and $cref thread_alloc$$. $codep */ # include # include /* $$ $head Computed Assignment Macro$$ This macro is used for the $code base_alloc$$ computed assignment operators; to be specific, used with $icode op $$ equal to $code +=$$, $code -=$$, $code *=$$, $code /=$$. $codep */ # define BASE_ALLOC_ASSIGN_OPERATOR(op) \ void operator op (const base_alloc& x) \ { *ptrdbl_ op *x.ptrdbl_; } /* $$ $head Binary Operator Macro$$ This macro is used for the $code base_alloc$$ binary operators (as member functions); to be specific, used with $icode op $$ equal to $code +$$, $code -$$, $code *$$, $code /$$. $codep */ # 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; \ } /* $$ $head Boolean Operator Macro$$ This macro can be used for the $code base_alloc$$ binary operators that have a $code bool$$ result; to be specific, used with $icode op $$ equal to $code ==$$, $code !=$$, $code <$$, $code <=$$, $code >=$$, and $code >$$, $codep */ # 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; \ } /* $$ $head Class Definition$$ The following example class defines the necessary $cref base_member$$ functions. It is made more complicated by storing a pointer to a $code double$$ instead of the $code double$$ value itself. $codep */ 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(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(<=) }; /* $$ $head CondExpOp$$ The type $code base_alloc$$ does not use $cref CondExp$$ operations. Hence its $code CondExpOp$$ function is defined by $codep */ 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(); } } /* $$ $head CondExpRel$$ The $cref/CPPAD_COND_EXP_REL/base_cond_exp/CondExpRel/$$ macro invocation $codep */ namespace CppAD { CPPAD_COND_EXP_REL(base_alloc) } /* $$ uses $code CondExpOp$$ above to define $codei%CondExp%Rel%$$ for $code base_alloc$$ arguments and $icode%Rel%$$ equal to $code Lt$$, $code Le$$, $code Eq$$, $code Ge$$, and $code Gt$$. $head EqualOpSeq$$ The type $code base_alloc$$ is simple (in this respect) and so we define $codep */ namespace CppAD { inline bool EqualOpSeq(const base_alloc& x, const base_alloc& y) { return *x.ptrdbl_ == *y.ptrdbl_; } } /* $$ $head Identical$$ The type $code base_alloc$$ is simple (in this respect) and so we define $codep */ 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_); } } /* $$ $head Output Operator$$ $codep */ namespace CppAD { std::ostream& operator << (std::ostream &os, const base_alloc& x) { os << *x.ptrdbl_; return os; } } /* $$ $head Integer$$ $codep */ namespace CppAD { inline int Integer(const base_alloc& x) { return static_cast(*x.ptrdbl_); } } /* $$ $head azmul$$ $codep */ namespace CppAD { CPPAD_AZMUL( base_alloc ) } /* $$ $head Ordered$$ The $code base_alloc$$ type supports ordered comparisons $codep */ 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_); } } /* $$ $head Unary Standard Math$$ The macro $cref/CPPAD_STANDARD_MATH_UNARY/base_std_math/CPPAD_STANDARD_MATH_UNARY/$$ would not work with the type $code base_alloc$$ so we define a special macro for this type: $codep */ # 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 $cref/unary standard math/base_std_math/Unary Standard Math/$$ functions (except for $code abs$$): $codep */ 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(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 its $code std$$ name is $code fabs$$ $codep */ namespace CppAD { inline base_alloc abs(const base_alloc& x) { return std::fabs(*x.ptrdbl_); } } /* $$ $head erf, asinh, acosh, atanh, expm1, log1p$$ The following defines the $cref/erf, asinh, acosh, atanh, expm1, log1p /base_std_math /erf, asinh, acosh, atanh, expm1, log1p /$$ functions required by $code AD$$: $codep */ # if CPPAD_USE_CPLUSPLUS_2011 BASE_ALLOC_STD_MATH(erf) BASE_ALLOC_STD_MATH(asinh) BASE_ALLOC_STD_MATH(acosh) BASE_ALLOC_STD_MATH(atanh) BASE_ALLOC_STD_MATH(expm1) BASE_ALLOC_STD_MATH(log1p) # endif /* $$ $head sign$$ The following defines the $code CppAD::sign$$ function that is required to use $code AD$$: $codep */ 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; } } /* $$ $head pow $$ The following defines a $code CppAD::pow$$ function that is required to use $code AD$$: $codep */ namespace CppAD { inline base_alloc pow(const base_alloc& x, const base_alloc& y) { return std::pow(*x.ptrdbl_, *y.ptrdbl_); } } /* $$ $head numeric_limits$$ The following defines the CppAD $cref numeric_limits$$ for the type $code base_alloc$$: $codep */ namespace CppAD { CPPAD_NUMERIC_LIMITS(double, base_alloc) } /* $$ $end */ # endif cppad-20160000.1/README0000644000175200017650000000525012450414402013275 0ustar coincoin-webHomepage: http://www.coin-or.org/CppAD/ License: CppAD is available from Coin-OR http://www.coin-or.org with both the CPL and GPL licenses; see the CppAD download page: http://www.coin-or.org/CppAD/Doc/download.xml Documentation: The documentation is available with the math either in latex, or rendered using MathML: http://www.coin-or.org/CppAD/Doc/cppad.htm latex http://www.coin-or.org/CppAD/Doc/cppad.xml MathML Install: http://www.coin-or.org/CppAD/Doc/install.htm Mailing List: The mailing list is used for CppAD discussion and bug reporting. Only members of the mailing list can post messages (this avoids spam on the mailing list). You can join the mailing list using its general information page http://list.coin-or.org/mailman/listinfo/CppAD Sub-Directories: bin Helper shell and sed scripts used for CppAD development. build If present, used to build examples and tests. bug Directory containing demonstration of known bugs (may be empty). cmake CMake macros used by the CMakeLists.txt files. compare_c Compare speed of C and C++ on the same soruce code. cppad CppAD include directory (will be copied to prefix/include). cppad_ipopt Deprecated version of a CppAD interface to the Ipopt optimizer. doc If present, replaces http://www.coin-or.org/CppAD/Doc in links. example Most all the CppAD example files are here. introduction Contains an introduction to Algorithmic Differentiation. multi_thread Multi-threading examples and tests. omh User documentation in OMhelp format (without any source code). pkgconfig pkg-config support files. print_for Example printing during forward mode. speed Speed tests for CppAD and comparison with other AD packages. test_more Extra correctness tests that are not intended as examples. Files: AUTHORS Statement of authorship and copyright. CMakeLists.txt Top level CMake commands. COPYING Statement of user license to use this version of software. ChangeLog Pointer to logs for recent changes. INSTALL Points to install instructions. NEWS Pointer to release notes; i.e., whats new. README This file. build.sh Script used to create auto-tools distribution (deprecated). configure.ac Command for auto-tools configuration (deprecated). doc.omh Top level user documentation file. epl-v10.* Eclipse public license files in text and html. gpl-3.0.txt GNU general public license. makefile.am Top level automake input file. uw_copy*.html UW policy on intellectual property. auto-tolls created files: config.guess, config.sub, configure, decomp, install-sh, makefile.in, missing. cppad-20160000.1/test_more/0002755000175200017650000000000012656321775014440 5ustar coincoin-webcppad-20160000.1/test_more/asinh.cpp0000644000175200017650000000374312656321774016252 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include bool asinh(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 10 times machine epsilon double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) ax(n); ax[0] = x0; // declare independent variables and start tape recording CppAD::Independent(ax); // a temporary value AD sinh_of_x0 = CppAD::sinh(ax[0]); // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = CppAD::asinh(sinh_of_x0); // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); // check value ok &= NearEqual(ay[0] , x0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., eps, eps); // forward computation of higher order partials w.r.t. x[0] size_t n_order = 5; for(size_t order = 2; order < n_order; order++) { dx[0] = 0.; dy = f.Forward(order, dx); ok &= NearEqual(dy[0], 0., eps, eps); } // reverse computation of derivatives CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n_order * n); w[0] = 1.; dw = f.Reverse(n_order, w); ok &= NearEqual(dw[0], 1., eps, eps); for(size_t order = 1; order < n_order; order++) ok &= NearEqual(dw[order * n + 0], 0., eps, eps); return ok; } // END C++ cppad-20160000.1/test_more/add.cpp0000644000175200017650000000665012656321774015700 0ustar coincoin-web// $Id: add.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Two old Add examples now used just for valiadation testing */ # include namespace { // BEGIN empty namespace bool AddTestOne(void) { bool ok = true; 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) return ok; } bool AddTestTwo(void) { bool ok = true; using namespace CppAD; // 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, 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = 2.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } } // END empty namespace bool Add(void) { bool ok = true; ok &= AddTestOne(); ok &= AddTestTwo(); return ok; } cppad-20160000.1/test_more/forward.cpp0000644000175200017650000001453212656321774016612 0ustar coincoin-web/* $Id: forward.cpp 3744 2015-11-06 15:33:15Z 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. -------------------------------------------------------------------------- */ /* Two old Forward example now used just for valiadation testing */ # include namespace { // Begin empty namespace template // vector class, elements of type double bool ForwardCases(void) { bool ok = true; using namespace CppAD; // 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], 1e-10, 1e-10); // 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], 1e-10, 1e-10); // 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], 1e-10, 1e-10); // 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], 1e-10, 1e-10); // 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., 1e-10, 1e-10); // 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], 1e-10, 1e-10); // 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], 1e-10, 1e-10); return ok; } bool ForwardOlder(void) { bool ok = true; using namespace CppAD; // 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], 1e-10, 1e-10); ok &= NearEqual(v0[1] , f0[1], 1e-10, 1e-10); // 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] , 1e-10, 1e-10); ok &= NearEqual(v1[1] , g1[0]*u1[0] + g1[1]*u1[1] + g1[2]*u1[2] , 1e-10, 1e-10); // use ADFun object to evaluate ------------------------------------ // (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] , 1e-10, 1e-10); 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, 1e-10, 1e-10); return ok; } 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 forward_nan(void) { 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; } return ok; } } // END empty namespace # include # include bool Forward(void) { bool ok = true; ok &= ForwardCases< CppAD::vector >(); ok &= ForwardCases< std::vector >(); ok &= ForwardCases< std::valarray >(); ok &= ForwardOlder(); # ifndef NDEBUG // CppAD does not check for nan when NDEBUG is defined ok &= forward_nan(); # endif return ok; } cppad-20160000.1/test_more/cosh.cpp0000644000175200017650000000365512656321774016106 0ustar coincoin-web// $Id: cosh.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old example now just used for validation testing. */ # include bool Cosh(void) { bool ok = true; using CppAD::sinh; using CppAD::cosh; using namespace CppAD; // 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]), 1e-10 , 1e-10); // 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 *= j; ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); 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(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); } return ok; } cppad-20160000.1/test_more/rosen_34.cpp0000644000175200017650000000701512656321774016600 0ustar coincoin-web// $Id: rosen_34.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old OdeImplicit example now used just for valiadation testing of Rosen34 */ // BEGIN C++ # include # include # include /* Case where x[0](0) = 1, x[0]'(t) = - w[0] * x[0](t) x[1](0) = 1, x[1]'(t) = - w[1] * x[1](t) x[2](0) = 0, x[2]'(t) = w[2] * t x[0](t) = exp( - w[0] * t ) x[1](t) = exp( - w[1] * t ) x[2](t) = w[2] * t^2 / 2 */ 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 bool Rosen34(void) { bool ok = true; using namespace CppAD; 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] = 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. / (nstep * nstep) ); AD x1 = exp( - w[1] * t1 ); ok &= NearEqual(x[1], x1, 0., 1. / (nstep * nstep) ); AD x2 = w[2] * t1 * t1 / 2.; ok &= NearEqual(x[2], x2, 1e-14, 1e-14); // 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. / (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. / (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], 1e-14, 1e-14 ); return ok; } // END C++ cppad-20160000.1/test_more/jacobian.cpp0000644000175200017650000000533512656321774016715 0ustar coincoin-web// $Id: jacobian.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 { // --------------------------------------------------------- template Vector eval_g(const Vector& x) { 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]; return g; } template Vector eval_jac_g(const Vector& x) { 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]; return jac_g; } } // End empty namespace bool jacobian(void) { bool ok = true; using CppAD::vector; size_t i, j, k; 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 &= CppAD::NearEqual(jac_g[k], check[k], 1e-10, 1e-10); // one argument sparse jacobian jac_g = fun_g.SparseJacobian(x); for(k = 0; k < m *n; k++) ok &= CppAD::NearEqual(jac_g[k], check[k], 1e-10, 1e-10); // 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 &= CppAD::NearEqual(jac_g[k], check[k], 1e-10, 1e-10); // 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 &= CppAD::NearEqual(jac_g[k], check[k], 1e-10, 1e-10); return ok; } // END PROGRAM cppad-20160000.1/test_more/from_base.cpp0000644000175200017650000000263312656321774017102 0ustar coincoin-web// $Id: from_base.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old FromBase example now used just for valiadation testing */ # include bool FromBase(void) { bool ok = true; using namespace CppAD; // 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); // check that resulting objects are parameters ok &= Parameter(x); ok &= Parameter(y); ok &= Parameter(X); ok &= Parameter(Y); // check values of objects ok &= (x == 1.); ok &= (X == x); 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 ); ok &= (x == 4.); ok &= (X == x); return ok; } // END PROGRAM cppad-20160000.1/test_more/sparse_hessian.cpp0000644000175200017650000001531512656321774020155 0ustar coincoin-web// $Id: sparse_hessian.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old SparseHessian example */ # include namespace { // --------------------------------------------------------- bool rc_tridiagonal(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; size_t i, j, k, ell; double eps = 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], eps, eps); ell = c[k] * n + r[k]; ok &= NearEqual(check[ell], hes[k], eps, eps); } return ok; } template bool bool_case() { bool ok = true; using CppAD::AD; using CppAD::NearEqual; size_t i, j, k; // 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 ] [ 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], 1e-10, 1e-10 ); // 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], 1e-10, 1e-10 ); return ok; } template bool set_case() { bool ok = true; using CppAD::AD; using CppAD::NearEqual; size_t i, j, k; // 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 ] [ 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], 1e-10, 1e-10 ); // 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], 1e-10, 1e-10 ); return ok; } } // End empty namespace # include # include bool sparse_hessian(void) { 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; } cppad-20160000.1/test_more/sparse_vec_ad.cpp0000644000175200017650000000566612656321774017754 0ustar coincoin-web// $Id: sparse_vec_ad.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include bool sparse_vec_ad(void) { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 3; 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) ) ); } return ok; } cppad-20160000.1/test_more/for_hess.cpp0000644000175200017650000000615312656321774016756 0ustar coincoin-web// $Id: for_hess.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old ForHess example now used just for valiadation testing */ # include bool ForHess(void) { bool ok = true; using namespace CppAD; using CppAD::exp; using CppAD::sin; using CppAD::cos; 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], 1e-10, 1e-10); ok &= NearEqual( 2. * Di[1] , H1[ i + 3 * i], 1e-10, 1e-10); // 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], 1e-10, 1e-10); double H1ij = Cij[1] - Di[1] - Dj[1]; ok &= NearEqual( H1ij, H1[j + 3 * i], 1e-10, 1e-10); // reset all components of u1 to zero u1[j] = 0.; } } return ok; } cppad-20160000.1/test_more/cond_exp_rev.cpp0000644000175200017650000000673212656321774017624 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // Test that reverse mode handles conditional expressions properly // in that infinity and nans do not propagate thouh un-used case. # include bool cond_exp_rev(void) { bool ok = true; using CppAD::vector; using CppAD::AD; AD anan = std::numeric_limits::quiet_NaN(); AD azero = 0.0; size_t n = 2; vector< AD > ax(n), ay; ax[0] = 1.0; ax[1] = anan; Independent(ax); // AbsOp ay.push_back( CondExpGt(ax[0], azero, ax[0], abs(ax[1]) )); // AcosOp ay.push_back( CondExpGt(ax[0], azero, ax[0], acos(ax[1]) )); // AddvvOp ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[0] + ax[1] )); // AddpvOp ay.push_back( CondExpGt(ax[0], azero, ax[0], 1.0 + ax[1] )); // AsinOp ay.push_back( CondExpGt(ax[0], azero, ax[0], asin(ax[1]) )); // AtanOp ay.push_back( CondExpGt(ax[0], azero, ax[0], atan(ax[1]) )); // CosOp ay.push_back( CondExpGt(ax[0], azero, ax[0], cos(ax[1]) )); // CoshOp ay.push_back( CondExpGt(ax[0], azero, ax[0], cosh(ax[1]) )); // DivvvOp ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[0] / ax[1] )); // DivpvOp ay.push_back( CondExpGt(ax[0], azero, ax[0], 1.0 / ax[1] )); // DivvpOp ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[1] / 2.0 )); // ErfOp ay.push_back( CondExpGt(ax[0], azero, ax[0], erf(ax[1]) )); // ExpOp ay.push_back( CondExpGt(ax[0], azero, ax[0], exp(ax[1]) )); // LogOp ay.push_back( CondExpGt(ax[0], azero, ax[0], log(ax[1]) )); // MulvvOp ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[0] * ax[1] )); // MulpvOp ay.push_back( CondExpGt(ax[0], azero, ax[0], 2.0 * ax[1] )); // PowvvOP // uses check in log, mul, and exp ay.push_back( CondExpGt(ax[0], azero, ax[0], pow(ax[1], ax[1]) )); // PowvpOP // uses check in log, mul, and exp ay.push_back( CondExpGt(ax[0], azero, ax[0], pow(ax[1], 2.0) )); // PowpvOP // uses check in log, mul, and exp ay.push_back( CondExpGt(ax[0], azero, ax[0], pow(2.0, ax[1]) )); // SignOp ay.push_back( CondExpGt(ax[0], azero, ax[0], sign(ax[1]) )); // SinOp ay.push_back( CondExpGt(ax[0], azero, ax[0], sin(ax[1]) )); // SinhOp ay.push_back( CondExpGt(ax[0], azero, ax[0], sinh(ax[1]) )); // SqrtOp ay.push_back( CondExpGt(ax[0], azero, ax[0], sqrt(ax[1]) )); // SubvvOp ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[0] - ax[1] )); // SubpvOp ay.push_back( CondExpGt(ax[0], azero, ax[0], 1.0 - ax[1] )); // SubvpOp ay.push_back( CondExpGt(ax[0], azero, ax[0], ax[1] - 1.0 )); // TanOp ay.push_back( CondExpGt(ax[0], azero, ax[0], tan(ax[1]) )); // TanhOp ay.push_back( CondExpGt(ax[0], azero, ax[0], tanh(ax[1]) )); // create f : x -> y size_t m = ay.size(); CppAD::ADFun f(ax, ay); // weighting vector and reverse mode derivative vector w(m), dw(n); for(size_t i = 0; i < m; i++) w[i] = 0.0; // check DivvOp for(size_t i = 0; i < m; i++) { w[i] = 1.0; dw = f.Reverse(1, w); ok &= dw[0] == 1.0; ok &= dw[1] == 0.0; w[i] = 0.0; } return ok; } cppad-20160000.1/test_more/mul.cpp0000644000175200017650000001026212656321774015737 0ustar coincoin-web// $Id: mul.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Two old Mul examples now used just for valiadation testing */ # include namespace { // BEGIN empty namespace bool MulTestOne(void) { bool ok = true; 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) return ok; } bool MulTestTwo(void) { bool ok = true; using namespace CppAD; // 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, 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); 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(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); } return ok; } } // END empty namespace bool Mul(void) { bool ok = true; ok &= MulTestOne(); ok &= MulTestTwo(); return ok; } cppad-20160000.1/test_more/simple_vector.cpp0000644000175200017650000000575712656321774020032 0ustar coincoin-web// $Id: simple_vector.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. -------------------------------------------------------------------------- */ /* Old simple vector example now used just for validation testing */ // BEGIN C++ // need this to define size_t # include // # include // # define MySimpleVector std::vector // # include // # define MySimpleVector std::valarray // Assuming CppAD (http://www.seanet.com/~bradbell/cppad) is installed # include # define MySimpleVector CppAD::vector // Assuming Boost (http://www.boost.org) is installed // # include // # define MySimpleVector boost::numeric::ublas::vector // 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; } private: 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); return ok; } // END C++ cppad-20160000.1/test_more/cppad_eigen.cpp0000644000175200017650000000425012656321774017400 0ustar coincoin-web// $Id: cppad_eigen.cpp 3760 2015-12-01 04:12: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. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test of Eigen Interface to CppAD Scalar Types $end */ # 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(); # if ! CPPAD_DEPRECATED // 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 ; # endif return ok; } cppad-20160000.1/test_more/base_adolc.cpp0000644000175200017650000000646512656321774017230 0ustar coincoin-web// $Id: base_adolc.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include // adouble definitions not in Adolc distribution and // required in order to use CppAD::AD # include # include bool base_adolc(void) { 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; } // END PROGRAM cppad-20160000.1/test_more/old_usead_1.cpp0000644000175200017650000002442712656321774017331 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin old_usead_1.cpp$$ $spell checkpoint var $$ $section Using AD to Compute Atomic Function Derivatives$$ $mindex inside user checkpoint$$ $head Deprecated 2013-05-27$$ This example has been deprecated because it is easier to use the $cref checkpoint$$ class instead. $head Purpose$$ Consider the case where an inner function is used repeatedly in the definition of an outer function. In this case, it may reduce the number of variables $cref/size_var/seq_property/size_var/$$, and hence the required memory. $head Simple Case$$ This example is the same as $cref old_reciprocal.cpp$$, except that it uses AD to compute the derivatives needed by an atomic function. This is a simple example of an inner function, and hence not really useful for the purpose above; see $cref old_usead_2.cpp$$ for a more complete example. $code $verbatim%test_more/old_usead_1.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // Begin empty namespace using CppAD::AD; using CppAD::ADFun; using CppAD::vector; // ---------------------------------------------------------------------- // function that computes reciprocal ADFun* r_ptr_; void create_r(void) { vector< AD > ax(1), ay(1); ax[0] = 1; CppAD::Independent(ax); ay[0] = 1.0 / ax[0]; r_ptr_ = new ADFun(ax, ay); } void destroy_r(void) { delete r_ptr_; r_ptr_ = CPPAD_NULL; } // ---------------------------------------------------------------------- // forward mode routine called by CppAD bool reciprocal_forward( size_t id , size_t k , size_t n , size_t m , const vector& vx , vector& vy , const vector& tx , vector& ty ) { assert( id == 0 ); assert( n == 1 ); assert( m == 1 ); assert( k == 0 || vx.size() == 0 ); bool ok = true; vector x_q(1), y_q(1); // check for special case if( vx.size() > 0 ) vy[0] = vx[0]; // make sure r_ has proper lower order Taylor coefficients stored // then compute ty[k] for(size_t q = 0; q <= k; q++) { x_q[0] = tx[q]; y_q = r_ptr_->Forward(q, x_q); if( q == k ) ty[k] = y_q[0]; assert( q == k || ty[q] == y_q[0] ); } return ok; } // ---------------------------------------------------------------------- // reverse mode routine called by CppAD bool reciprocal_reverse( size_t id , size_t k , size_t n , size_t m , const vector& tx , const vector& ty , vector& px , const vector& py ) { assert( id == 0 ); assert( n == 1 ); assert( m == 1 ); bool ok = true; vector x_q(1), w(k+1), dw(k+1); // make sure r_ has proper forward mode coefficients size_t q; for(q = 0; q <= k; q++) { x_q[0] = tx[q]; # ifdef NDEBUG r_ptr_->Forward(q, x_q); # else vector y_q(1); y_q = r_ptr_->Forward(q, x_q); assert( ty[q] == y_q[0] ); # endif } for(q = 0; q <=k; q++) w[q] = py[q]; dw = r_ptr_->Reverse(k+1, w); for(q = 0; q <=k; q++) px[q] = dw[q]; return ok; } // ---------------------------------------------------------------------- // forward Jacobian sparsity routine called by CppAD bool reciprocal_for_jac_sparse( size_t id , size_t n , size_t m , size_t p , const vector< std::set >& r , vector< std::set >& s ) { assert( id == 0 ); assert( n == 1 ); assert( m == 1 ); bool ok = true; vector< std::set > R(1), S(1); R[0] = r[0]; S = r_ptr_->ForSparseJac(p, R); s[0] = S[0]; return ok; } // ---------------------------------------------------------------------- // reverse Jacobian sparsity routine called by CppAD bool reciprocal_rev_jac_sparse( size_t id , size_t n , size_t m , size_t p , vector< std::set >& r , const vector< std::set >& s ) { assert( id == 0 ); assert( n == 1 ); assert( m == 1 ); bool ok = true; vector< std::set > R(p), S(p); size_t q; for(q = 0; q < p; q++) S[q] = s[q]; R = r_ptr_->RevSparseJac(p, S); for(q = 0; q < p; q++) r[q] = R[q]; return ok; } // ---------------------------------------------------------------------- // reverse Hessian sparsity routine called by CppAD bool reciprocal_rev_hes_sparse( size_t id , size_t n , size_t m , size_t p , const vector< std::set >& r , const vector& s , vector& t , const vector< std::set >& u , vector< std::set >& v ) { // Can just return false if not use RevSparseHes. assert( id == 0 ); assert( n == 1 ); assert( m == 1 ); bool ok = true; // compute sparsity pattern for T(x) = S(x) * f'(x) vector T(1), S(1); S[0] = s[0]; T = r_ptr_->RevSparseJac(1, S); t[0] = T[0]; // compute sparsity pattern for A(x) = U(x)^T * f'(x) vector Ut(p), A(p); size_t q; for(q = 0; q < p; q++) Ut[q] = false; std::set::iterator itr; for(itr = u[0].begin(); itr != u[0].end(); itr++) Ut[*itr] = true; A = r_ptr_-> RevSparseJac(p, Ut); // compute sparsity pattern for H(x) = R^T * (S * F)''(x) vector H(p), R(n); for(q = 0; q < p; q++) R[q] = false; for(itr = r[0].begin(); itr != r[0].end(); itr++) R[*itr] = true; r_ptr_->ForSparseJac(p, R); H = r_ptr_->RevSparseHes(p, S); // compute sparsity pattern for V(x) = A(x)^T + H(x)^T v[0].clear(); for(q = 0; q < p; q++) if( A[q] | H[q] ) v[0].insert(q); return ok; } // --------------------------------------------------------------------- // Declare the AD routine reciprocal(id, ax, ay) CPPAD_USER_ATOMIC( reciprocal , CppAD::vector , double , reciprocal_forward , reciprocal_reverse , reciprocal_for_jac_sparse , reciprocal_rev_jac_sparse , reciprocal_rev_hes_sparse ) } // End empty namespace bool old_usead_1(void) { bool ok = true; using CppAD::NearEqual; double eps = 10. * CppAD::numeric_limits::epsilon(); // -------------------------------------------------------------------- // Create the ADFun r_ create_r(); // -------------------------------------------------------------------- // Create the function f(x) // // domain space vector size_t n = 1; double x0 = 0.5; vector< AD > ax(n); ax[0] = x0; // declare independent variables and start tape recording CppAD::Independent(ax); // range space vector size_t m = 1; vector< AD > ay(m); // call user function and store reciprocal(x) in au[0] vector< AD > au(m); size_t id = 0; // not used reciprocal(id, ax, au); // u = 1 / x // call user function and store reciprocal(u) in ay[0] reciprocal(id, au, ay); // y = 1 / u = x // create f: x -> y and stop tape recording ADFun f; f.Dependent(ax, ay); // f(x) = x // -------------------------------------------------------------------- // Check function value results // // check function value double check = x0; ok &= NearEqual( Value(ay[0]) , check, eps, eps); // check zero order forward mode size_t q; vector x_q(n), y_q(m); q = 0; x_q[0] = x0; y_q = f.Forward(q, x_q); ok &= NearEqual(y_q[0] , check, eps, eps); // check first order forward mode q = 1; x_q[0] = 1; y_q = f.Forward(q, x_q); check = 1.; ok &= NearEqual(y_q[0] , check, eps, eps); // check second order forward mode q = 2; x_q[0] = 0; y_q = f.Forward(q, x_q); check = 0.; ok &= NearEqual(y_q[0] , check, eps, eps); // -------------------------------------------------------------------- // Check reverse mode results // // third order reverse mode q = 3; vector w(m), dw(n * q); w[0] = 1.; dw = f.Reverse(q, w); check = 1.; ok &= NearEqual(dw[0] , check, eps, eps); check = 0.; ok &= NearEqual(dw[1] , check, eps, eps); ok &= NearEqual(dw[2] , check, eps, eps); // -------------------------------------------------------------------- // forward mode sparstiy pattern size_t p = n; CppAD::vectorBool r1(n * p), s1(m * p); r1[0] = true; // compute sparsity pattern for x[0] s1 = f.ForSparseJac(p, r1); ok &= s1[0] == true; // f[0] depends on x[0] // -------------------------------------------------------------------- // reverse mode sparstiy pattern q = m; CppAD::vectorBool s2(q * m), r2(q * n); s2[0] = true; // compute sparsity pattern for f[0] r2 = f.RevSparseJac(q, s2); ok &= r2[0] == true; // f[0] depends on x[0] // -------------------------------------------------------------------- // Hessian sparsity (using previous ForSparseJac call) CppAD::vectorBool s3(m), h(p * n); s3[0] = true; // compute sparsity pattern for f[0] h = f.RevSparseJac(p, s3); ok &= h[0] == true; // second partial of f[0] w.r.t. x[0] may be non-zero // ----------------------------------------------------------------- // Free all memory associated with the object r_ptr destroy_r(); // ----------------------------------------------------------------- // Free all temporary work space associated with old_atomic objects. // (If there are future calls to user atomic functions, they will // create new temporary work space.) CppAD::user_atomic::clear(); return ok; } // END C++ cppad-20160000.1/test_more/optimize.cpp0000644000175200017650000013413012656321774017003 0ustar coincoin-web/* $Id: optimize.cpp 3735 2015-10-01 13:43:46Z 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. -------------------------------------------------------------------------- */ // 2DO: Test that optimize.hpp use of base_atomic::rev_sparse_jac works. # include # include namespace { // include conditional skip optimization bool conditional_skip_; // accuracy for almost equal checks double eps_ = 10. * std::numeric_limits::epsilon(); using CppAD::NearEqual; // note this enum type is not part of the API (but its values are) CppAD::atomic_base::option_enum atomic_sparsity_option_; // // ---------------------------------------------------------------- // Test nested conditional expressions. bool nested_cond_exp(void) { bool ok = true; using CppAD::AD; 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 &= y[0] == c3; } 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::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 &= y[0] == x[0] + double(3) * x[1]; // check result where false case is used; i.e., au[0] <= au[1] x[0] = 1.; x[1] = 1; y = f.Forward(0, x); ok &= y[0] == x[0] + double(4) * x[1]; return ok; } // ------------------------------------------------------------------- // 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; // 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 &= y[0] == x[0] + x[1]; // 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 &= y[0] == x[0] - x[1]; // 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 &= dy[0] == dx[0] - dx[1]; // optimized first order reverse w[0] = 1.; dx = f.Reverse(1, w); ok &= dx[0] == 1.; ok &= dx[1] == -1.; return ok; } // ------------------------------------------------------------------- // Test of optimizing out arguments to an atomic function void g_algo( 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::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 &= z[0] == x[0] - x[1]; return ok; } bool atomic_arguments(void) { bool ok = true; using CppAD::AD; 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 &= (y[0] == x[0] + x[1]); 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 = CppAD::abs(x[0]); y[0] = sin(x[0]); original += 3; opt += 2; // binary operator where left operand is a variable // and right operand is a parameter 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; 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], eps_, eps_); // 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], eps_, eps_); return ok; } bool depend_two(void) { // Test VecAD operations bool ok = true; using CppAD::AD; 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 &= (y[i] == 0.); else ok &= (y[i] == x[1]); } 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 &= (y[i] == 0.); else ok &= (y[i] == x[1]); } return ok; } bool depend_three(void) { // Power function is a special case for optimize bool ok = true; using CppAD::AD; 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 &= ( y[j] == Value(Y[j]) ); // 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, eps_, eps_ ); check = log( x[0] ) * pow( x[0], x[1] ); ok &= NearEqual( dw[1], check, eps_, eps_ ); check = 0.; ok &= NearEqual( dw[2], check, eps_, eps_ ); return ok; } bool depend_four(void) { // erf function is a special case for optimize bool ok = true; # if CPPAD_USE_CPLUSPLUS_2011 using CppAD::AD; 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], eps_, eps_); # 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; 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], eps_, eps_); // 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], eps_, eps_); 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; 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 &= ( y[i] == Value( Y[i] ) ); 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 &= ( y[i] == Value( Y[i] ) ); 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; 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 &= ( y[i] == Value( Y[i] ) ); 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 &= ( y[i] == Value( Y[i] ) ); 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; 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] = abs(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 &= ( y[0] == Value( Y[0] ) ); 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 &= ( y[0] == Value( Y[0] ) ); 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; 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 &= ( y[i] == Value( Y[i] ) ); 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 &= ( y[i] == Value( Y[i] ) ); return ok; } // ------------------------------------------------------------------- bool forward_csum(void) { bool ok = true; using namespace CppAD; // 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], eps_, eps_); // evaluate derivative of F in X[0] direction CppAD::vector x1( F.Domain() ); CppAD::vector y1( F.Range() ); x1[0] = 1.; x1[1] = 0.; y1 = F.Forward(1, x1); ok &= NearEqual(y1[0] , x1[0]+x1[0]+x1[1], eps_, eps_); // 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., eps_, eps_); return ok; } // ------------------------------------------------------------------- bool reverse_csum(void) { bool ok = true; using namespace CppAD; // 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], eps_, eps_); // evaluate derivative of F CppAD::vector dF( F.Domain() ); CppAD::vector w( F.Range() ); w[0] = 1.; dF = F.Reverse(1, w); ok &= NearEqual(dF[0] , 0., eps_, eps_); ok &= NearEqual(dF[1] , 1., eps_, eps_); return ok; } bool forward_sparse_jacobian() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 3; // 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; 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 &= y[0] == 2.; else ok &= y[0] == 3.; if( 0. < x[1] + .5 ) ok &= y[1] == 2.; else ok &= y[1] == 3.; ok &= y[2] == x[2] + .5;; ok &= y[3] == 2.; return ok; } // check that CondExp properly handels expressions that get // removed during opitmization bool cond_exp_removed(void) { bool ok = true; using CppAD::AD; AD zero(0.); size_t n = 1; CppAD::vector< AD > X(n); 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, eps_, eps_); w[0] = 1.0; dw = f.Reverse(1, w); // derivative of cos is minus sin ok &= NearEqual(dw[0], - true_case, eps_, eps_); return ok; } // ------------------------------------------------------------------- void my_union( std::set& result , const std::set& left , const std::set& right ) { std::set temp; std::set_union( left.begin() , left.end() , right.begin() , right.end() , std::inserter(temp, temp.begin()) ); result.swap(temp); } 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] my_union(r[0], r[0], s[0]); my_union(r[1], r[1], s[0]); // y[1] = x[1] + x[2] my_union(r[1], r[1], s[1]); my_union(r[2], 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; 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] = (j + 1) * (j + 1); y = g.Forward(0, x); // y[0] = x[0] + x[1] ok &= (y[0] == x[0] + x[1]); // y[1] = x[1] + x[2] ok &= (y[0] == x[0] + x[1]); 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; 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 &= y[0] == -6.0; 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::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 &= y_before[0] == y_after[0]; 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::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 &= y_before[0] == y_after[0]; ok &= dy_before[0] == dy_after[0]; 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; 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 &= dx[j] == 2.0; else ok &= dx[j] == 0.0; } 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; // 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 &= y[0] == x[0] + x[1]; ok &= y[1] == x[0] - x[1]; ok &= y[2] == exp(x[0]); // check case where x[0] < 3 x[0] = 1.0; x[1] = 2.0; y = f.Forward(0, x); ok &= y[0] == x[0] + x[1]; ok &= y[1] == x[0] - x[1]; ok &= y[2] == exp(x[0]); return ok; } } bool optimize(void) { bool ok = true; conditional_skip_ = true; atomic_sparsity_option_ = CppAD::atomic_base::bool_sparsity_enum; // 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(); } // CppAD::user_atomic::clear(); return ok; } cppad-20160000.1/test_more/pow_int.cpp0000644000175200017650000000340212656321774016617 0ustar coincoin-web// $Id: pow_int.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old example now just used for validation testing. */ # include bool PowInt(void) { bool ok = true; using CppAD::pow; using CppAD::exp; using CppAD::log; using namespace CppAD; // 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.), 1e-10 , 1e-10); ok &= NearEqual(Z[1] , exp( - log(u) * 5.), 1e-10 , 1e-10); // forward computation of partials v[0] = 1.; w = f.Forward(1, v); ok &= NearEqual(w[0] , 5. * exp( log(u) * 4.), 1e-10 , 1e-10); ok &= NearEqual(w[1] , - 5. * exp( - log(u) * 6.), 1e-10 , 1e-10); return ok; } cppad-20160000.1/test_more/num_limits.cpp0000644000175200017650000001372512656321774017331 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* old num_limits.cpp example / test $spell $$ $section Numeric Limits: Example and Test$$ $index limits$$ $index example, limits$$ $index test, limits$$ $head Assumption$$ This code assumes that the decimal point is infront of the mantissa. Hence dividing the minimum normalized value looses precision, while multiplying the maximum normalized value results in infinity. $head Externals$$ This example using external routines to get and set values so that the complier does not set the correspdong code and optimize it out. $code old verbatim%example/num_limits.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # ifdef _MSC_VER // Supress Microsoft compiler warning about possible loss of precision, // in the constructors (when converting to std::complex) // Type one = 1 // Type two = 2 // 1 and 2 are small enough so no loss of precision when converting to float. # pragma warning(disable:4244) # endif # include # include # include "extern_value.hpp" namespace { using CppAD::vector; using CppAD::abs_geq; template Type add_one(const Type& value) { return( Type(1) + value ); } // ----------------------------------------------------------------- template bool check_epsilon(void) { bool ok = true; typedef extern_value value; value eps( CppAD::numeric_limits::epsilon() ); value one( Type(1) ); value two( Type(2) ); value tmp( Type(0) ); // tmp.set( add_one( eps.get() / two.get() ) ); ok &= one.get() == tmp.get(); // tmp.set( add_one( eps.get() ) ); ok &= one.get() != tmp.get(); return ok; } // ----------------------------------------------------------------- template bool check_min(void) { bool ok = true; typedef extern_value value; value min( CppAD::numeric_limits::min() ); value eps3( Type(3) * CppAD::numeric_limits::epsilon() ); value one( Type(1) ); value hun( Type(100) ); value tmp( Type(0) ); // tmp.set( min.get() / hun.get() ); tmp.set( tmp.get() * hun.get() ); ok &= abs_geq(tmp.get()/min.get() - one.get(), eps3.get()); // tmp.set( min.get() * hun.get() ); tmp.set( tmp.get() / hun.get() ); ok &= ! abs_geq(tmp.get()/min.get() - one.get(), eps3.get()); return ok; } // ----------------------------------------------------------------- template bool check_max(void) { bool ok = true; typedef extern_value value; value max2( CppAD::numeric_limits::max() / Type(2) ); value eps3( Type(3) * CppAD::numeric_limits::epsilon() ); value one( Type(1) ); value hun( Type(100) ); value tmp( Type(0) ); // In complex case, this operaiton can result in (inf, 0) tmp.set( max2.get() * hun.get() ); // In complex case, this operaiotn can result in (inf,-nan) // (where nan corresponds to inf * 0) tmp.set( tmp.get() / hun.get() ); if( ! CppAD::isnan( tmp.get() ) ) ok &= abs_geq( tmp.get() / max2.get() - one.get(), eps3.get() ); // tmp.set( max2.get() / hun.get() ); tmp.set( tmp.get() * hun.get() ); ok &= ! abs_geq(tmp.get() / max2.get() - one.get(), eps3.get() ); return ok; } // ----------------------------------------------------------------- template bool check_quiet_NaN(void) { bool ok = true; typedef extern_value value; value nan( CppAD::numeric_limits::quiet_NaN() ); value same( nan.get() ); // ok &= nan.get() != same.get(); ok &= ! (nan.get() == same.get() ); // return ok; } } bool num_limits(void) { bool ok = true; using CppAD::AD; // ------------------------------------------------------------------- // epsilon for Base types defined by CppAD ok &= check_epsilon(); ok &= check_epsilon(); ok &= check_epsilon< std::complex >(); ok &= check_epsilon< std::complex >(); // epsilon for some AD types. ok &= check_epsilon< AD >(); ok &= check_epsilon< AD >(); ok &= check_epsilon< AD > >(); ok &= check_epsilon< AD > >(); // ------------------------------------------------------------------- // min for Base types defined by CppAD ok &= check_min(); ok &= check_min(); ok &= check_min< std::complex >(); ok &= check_min< std::complex >(); // min for some AD types. ok &= check_min< AD >(); ok &= check_min< AD >(); ok &= check_min< AD > >(); ok &= check_min< AD > >(); // ------------------------------------------------------------------- // max for Base types defined by CppAD ok &= check_max(); ok &= check_max(); ok &= check_max< std::complex >(); ok &= check_max< std::complex >(); // max for some AD types. ok &= check_max< AD >(); ok &= check_max< AD >(); ok &= check_max< AD< std::complex > >(); ok &= check_max< AD< std::complex > >(); // ------------------------------------------------------------------- // quiet_NaN for Base types defined by CppAD ok &= check_quiet_NaN(); ok &= check_quiet_NaN(); ok &= check_quiet_NaN< std::complex >(); ok &= check_quiet_NaN< std::complex >(); // quiet_NaN for some AD types. ok &= check_quiet_NaN< AD >(); ok &= check_quiet_NaN< AD >(); ok &= check_quiet_NaN< AD< std::complex > >(); ok &= check_quiet_NaN< AD< std::complex > >(); return ok; } // END C++ cppad-20160000.1/test_more/old_usead_2.cpp0000644000175200017650000003476412656321774017337 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin old_usead_2.cpp$$ $spell checkpoint var $$ $section Using AD to Compute Atomic Function Derivatives$$ $mindex inside user checkpoint$$ $head Deprecated 2013-05-27$$ This example has been deprecated because it is easier to use the $cref checkpoint$$ class instead. $head Purpose$$ Consider the case where an inner function is used repeatedly in the definition of an outer function. In this case, it may reduce the number of variables $cref/size_var/seq_property/size_var/$$, and hence the required memory. $code $verbatim%test_more/old_usead_2.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // Begin empty namespace using CppAD::AD; using CppAD::ADFun; using CppAD::vector; // ---------------------------------------------------------------------- // ODE for [t, t^2 / 2 ] in form required by Runge45 class Fun { public: void Ode( const AD &t, const vector< AD > &z, vector< AD > &f) { assert( z.size() == 2 ); assert( f.size() == 2 ); f[0] = 1.0; f[1] = z[0]; } }; // ---------------------------------------------------------------------- // Create function that takes on Runge45 step for the ODE above ADFun* r_ptr_; void create_r(void) { size_t n = 3, m = 2; vector< AD > x(n), zi(m), y(m), e(m); // The value of x does not matter because the operation sequence // does not depend on x. x[0] = 0.0; // initial value z_0 (t) at t = ti x[1] = 0.0; // initial value z_1 (t) at t = ti x[2] = 0.1; // final time for this integration CppAD::Independent(x); zi[0] = x[0]; // z_0 (t) at t = ti zi[1] = x[1]; // z_1 (t) at t = ti AD ti = 0.0; // t does not appear in ODE so does not matter AD tf = x[2]; // final time size_t M = 3; // number of Runge45 steps to take Fun F; y = CppAD::Runge45(F, M, ti, tf, zi, e); r_ptr_ = new ADFun(x, y); } void destroy_r(void) { delete r_ptr_; r_ptr_ = CPPAD_NULL; } // ---------------------------------------------------------------------- // forward mode routine called by CppAD bool solve_ode_forward( size_t id , size_t k , size_t n , size_t m , const vector& vx , vector& vy , const vector& tx , vector& ty ) { assert( id == 0 ); assert( n == 3 ); assert( m == 2 ); assert( k == 0 || vx.size() == 0 ); bool ok = true; vector xp(n), yp(m); size_t i, j; // check for special case if( vx.size() > 0 ) { //Compute r, a Jacobian sparsity pattern. // Use reverse mode because m < n. vector< std::set > s(m), r(m); for(i = 0; i < m; i++) s[i].insert(i); r = r_ptr_->RevSparseJac(m, s); std::set::const_iterator itr; for(i = 0; i < m; i++) { vy[i] = false; for(itr = s[i].begin(); itr != s[i].end(); itr++) { j = *itr; assert( j < n ); // y[i] depends on the value of x[j] // Visual Studio 2013 generates warning without bool below vy[i] |= bool( vx[j] ); } } } // make sure r_ has proper lower order Taylor coefficients stored // then compute ty[k] for(size_t q = 0; q <= k; q++) { for(j = 0; j < n; j++) xp[j] = tx[j * (k+1) + q]; yp = r_ptr_->Forward(q, xp); if( q == k ) { for(i = 0; i < m; i++) ty[i * (k+1) + q] = yp[i]; } # ifndef NDEBUG else { for(i = 0; i < m; i++) assert( ty[i * (k+1) + q] == yp[i] ); } # endif } // no longer need the Taylor coefficients in r_ptr_ // (have to reconstruct them every time) r_ptr_->capacity_order(0); return ok; } // ---------------------------------------------------------------------- // reverse mode routine called by CppAD bool solve_ode_reverse( size_t id , size_t k , size_t n , size_t m , const vector& tx , const vector& ty , vector& px , const vector& py ) { assert( id == 0 ); assert( n == 3 ); assert( m == 2 ); bool ok = true; vector xp(n), w( (k+1) * m ), dw( (k+1) * n ); // make sure r_ has proper forward mode coefficients size_t i, j, q; for(q = 0; q <= k; q++) { for(j = 0; j < n; j++) xp[j] = tx[j * (k+1) + q]; # ifdef NDEBUG r_ptr_->Forward(q, xp); # else vector yp(m); yp = r_ptr_->Forward(q, xp); for(i = 0; i < m; i++) assert( ty[i * (k+1) + q] == yp[i] ); # endif } for(i = 0; i < m; i++) { for(q = 0; q <=k; q++) w[ i * (k+1) + q] = py[ i * (k+1) + q]; } dw = r_ptr_->Reverse(k+1, w); for(j = 0; j < n; j++) { for(q = 0; q <=k; q++) px[ j * (k+1) + q] = dw[ j * (k+1) + q]; } // no longer need the Taylor coefficients in r_ptr_ // (have to reconstruct them every time) r_ptr_->capacity_order(0); return ok; } // ---------------------------------------------------------------------- // forward Jacobian sparsity routine called by CppAD bool solve_ode_for_jac_sparse( size_t id , size_t n , size_t m , size_t p , const vector< std::set >& r , vector< std::set >& s ) { assert( id == 0 ); assert( n == 3 ); assert( m == 2 ); bool ok = true; vector< std::set > R(n), S(m); for(size_t j = 0; j < n; j++) R[j] = r[j]; S = r_ptr_->ForSparseJac(p, R); for(size_t i = 0; i < m; i++) s[i] = S[i]; // no longer need the forward mode sparsity pattern // (have to reconstruct them every time) r_ptr_->size_forward_set(0); return ok; } // ---------------------------------------------------------------------- // reverse Jacobian sparsity routine called by CppAD bool solve_ode_rev_jac_sparse( size_t id , size_t n , size_t m , size_t p , vector< std::set >& r , const vector< std::set >& s ) { assert( id == 0 ); assert( n == 3 ); assert( m == 2 ); bool ok = true; vector< std::set > R(p), S(p); std::set::const_iterator itr; size_t i; // untranspose s for(i = 0; i < m; i++) { for(itr = s[i].begin(); itr != s[i].end(); itr++) S[*itr].insert(i); } R = r_ptr_->RevSparseJac(p, S); // transpose r for(i = 0; i < m; i++) r[i].clear(); for(i = 0; i < p; i++) { for(itr = R[i].begin(); itr != R[i].end(); itr++) r[*itr].insert(i); } return ok; } // ---------------------------------------------------------------------- // reverse Hessian sparsity routine called by CppAD bool solve_ode_rev_hes_sparse( size_t id , size_t n , size_t m , size_t p , const vector< std::set >& r , const vector& s , vector& t , const vector< std::set >& u , vector< std::set >& v ) { // Can just return false if not use RevSparseHes. assert( id == 0 ); assert( n == 3 ); assert( m == 2 ); bool ok = true; std::set::const_iterator itr; // compute sparsity pattern for T(x) = S(x) * f'(x) vector< std::set > S(1); size_t i, j; S[0].clear(); for(i = 0; i < m; i++) if( s[i] ) S[0].insert(i); t = r_ptr_->RevSparseJac(1, s); // compute sparsity pattern for A(x)^T = U(x)^T * f'(x) vector< std::set > Ut(p), At(p); for(i = 0; i < m; i++) { for(itr = u[i].begin(); itr != u[i].end(); itr++) Ut[*itr].insert(i); } At = r_ptr_->RevSparseJac(p, Ut); // compute sparsity pattern for H(x)^T = R^T * (S * F)''(x) vector< std::set > R(n), Ht(p); for(j = 0; j < n; j++) R[j] = r[j]; r_ptr_->ForSparseJac(p, R); Ht = r_ptr_->RevSparseHes(p, S); // compute sparsity pattern for V(x) = A(x) + H(x)^T for(j = 0; j < n; j++) v[j].clear(); for(i = 0; i < p; i++) { for(itr = At[i].begin(); itr != At[i].end(); itr++) v[*itr].insert(i); for(itr = Ht[i].begin(); itr != Ht[i].end(); itr++) v[*itr].insert(i); } // no longer need the forward mode sparsity pattern // (have to reconstruct them every time) r_ptr_->size_forward_set(0); return ok; } // --------------------------------------------------------------------- // Declare the AD routine solve_ode(id, ax, ay) CPPAD_USER_ATOMIC( solve_ode , CppAD::vector , double , solve_ode_forward , solve_ode_reverse , solve_ode_for_jac_sparse , solve_ode_rev_jac_sparse , solve_ode_rev_hes_sparse ) } // End empty namespace bool old_usead_2(void) { bool ok = true; using CppAD::NearEqual; double eps = 10. * CppAD::numeric_limits::epsilon(); // -------------------------------------------------------------------- // Create the ADFun r_ create_r(); // -------------------------------------------------------------------- // domain and range space vectors size_t n = 3, m = 2; vector< AD > au(n), ax(n), ay(m); au[0] = 0.0; // value of z_0 (t) = t, at t = 0 ax[1] = 0.0; // value of z_1 (t) = t^2/2, at t = 0 au[2] = 1.0; // final t CppAD::Independent(au); size_t M = 2; // number of r steps to take ax[0] = au[0]; // value of z_0 (t) = t, at t = 0 ax[1] = au[1]; // value of z_1 (t) = t^2/2, at t = 0 AD dt = au[2] / M; // size of each r step ax[2] = dt; for(size_t i_step = 0; i_step < M; i_step++) { size_t id = 0; // not used solve_ode(id, ax, ay); ax[0] = ay[0]; ax[1] = ay[1]; } // create f: u -> y and stop tape recording // y_0(t) = u_0 + t = u_0 + u_2 // y_1(t) = u_1 + u_0 * t + t^2 / 2 = u_1 + u_0 * u_2 + u_2^2 / 2 // where t = u_2 ADFun f; f.Dependent(au, ay); // -------------------------------------------------------------------- // Check forward mode results // // zero order forward vector up(n), yp(m); size_t q = 0; double u0 = 0.5; double u1 = 0.25; double u2 = 0.75; double check; up[0] = u0; up[1] = u1; up[2] = u2; yp = f.Forward(q, up); check = u0 + u2; ok &= NearEqual( yp[0], check, eps, eps); check = u1 + u0 * u2 + u2 * u2 / 2.0; ok &= NearEqual( yp[1], check, eps, eps); // // forward mode first derivative w.r.t t q = 1; up[0] = 0.0; up[1] = 0.0; up[2] = 1.0; yp = f.Forward(q, up); check = 1.0; ok &= NearEqual( yp[0], check, eps, eps); check = u0 + u2; ok &= NearEqual( yp[1], check, eps, eps); // // forward mode second order Taylor coefficient w.r.t t q = 2; up[0] = 0.0; up[1] = 0.0; up[2] = 0.0; yp = f.Forward(q, up); check = 0.0; ok &= NearEqual( yp[0], check, eps, eps); check = 1.0 / 2.0; ok &= NearEqual( yp[1], check, eps, eps); // -------------------------------------------------------------------- // reverse mode derivatives of \partial_t y_1 (t) vector w(m * q), dw(n * q); w[0 * q + 0] = 0.0; w[1 * q + 0] = 0.0; w[0 * q + 1] = 0.0; w[1 * q + 1] = 1.0; dw = f.Reverse(q, w); // derivative of y_1(u) = u_1 + u_0 * u_2 + u_2^2 / 2, w.r.t. u // is equal deritative of \partial_u2 y_1(u) w.r.t \partial_u2 u check = u2; ok &= NearEqual( dw[0 * q + 1], check, eps, eps); check = 1.0; ok &= NearEqual( dw[1 * q + 1], check, eps, eps); check = u0 + u2; ok &= NearEqual( dw[2 * q + 1], check, eps, eps); // derivative of \partial_t y_1 w.r.t u = u_0 + t, w.r.t u check = 1.0; ok &= NearEqual( dw[0 * q + 0], check, eps, eps); check = 0.0; ok &= NearEqual( dw[1 * q + 0], check, eps, eps); check = 1.0; ok &= NearEqual( dw[2 * q + 0], check, eps, eps); // -------------------------------------------------------------------- // forward mode sparsity pattern for the Jacobian // f_u = [ 1, 0, 1 ] // [ u_2, 1, u_2 ] size_t i, j, p = n; CppAD::vectorBool r(n * p), s(m * p); // r = identity sparsity pattern for(i = 0; i < n; i++) for(j = 0; j < p; j++) r[i*n +j] = (i == j); s = f.ForSparseJac(p, r); ok &= s[ 0 * p + 0] == true; ok &= s[ 0 * p + 1] == false; ok &= s[ 0 * p + 2] == true; ok &= s[ 1 * p + 0] == true; ok &= s[ 1 * p + 1] == true; ok &= s[ 1 * p + 2] == true; // -------------------------------------------------------------------- // reverse mode sparsity pattern for the Jacobian q = m; s.resize(q * m); r.resize(q * n); // s = identity sparsity pattern for(i = 0; i < q; i++) for(j = 0; j < m; j++) s[i*m +j] = (i == j); r = f.RevSparseJac(q, s); ok &= r[ 0 * n + 0] == true; ok &= r[ 0 * n + 1] == false; ok &= r[ 0 * n + 2] == true; ok &= r[ 1 * n + 0] == true; ok &= r[ 1 * n + 1] == true; ok &= r[ 1 * n + 2] == true; // -------------------------------------------------------------------- // Hessian sparsity for y_1 (u) = u_1 + u_0 * u_2 + u_2^2 / 2 s.resize(m); s[0] = false; s[1] = true; r.resize(n * n); for(i = 0; i < n; i++) for(j = 0; j < n; j++) r[ i * n + j ] = (i == j); CppAD::vectorBool h(n * n); h = f.RevSparseHes(n, s); ok &= h[0 * n + 0] == false; ok &= h[0 * n + 1] == false; ok &= h[0 * n + 2] == true; ok &= h[1 * n + 0] == false; ok &= h[1 * n + 1] == false; ok &= h[1 * n + 2] == false; ok &= h[2 * n + 0] == true; ok &= h[2 * n + 1] == false; ok &= h[2 * n + 2] == true; // -------------------------------------------------------------------- destroy_r(); // Free all temporary work space associated with old_atomic objects. // (If there are future calls to user atomic functions, they will // create new temporary work space.) CppAD::user_atomic::clear(); return ok; } // END C++ cppad-20160000.1/test_more/mul_zdouble.cpp0000644000175200017650000001036312656321774017465 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // Check that multilevel reverse with conditial expressions works properly // when using AD< AD >. # include namespace { using CppAD::AD; using CppAD::zdouble; using CppAD::ADFun; using CppAD::vector; typedef AD a1type; typedef AD a2type; typedef vector (*a2fun)(const vector& a2x); // zdouble eps = 10. * std::numeric_limits::epsilon(); size_t n_ = 2; size_t m_ = 1; // void record(a2fun fun, ADFun& g) { vector x(n_); vector a1x(n_), a1w(m_), a1z(m_ * n_); vector a2x(n_), a2y(m_); // for(size_t j = 0; j < n_; j++) { x[j] = 0.0; a1x[j] = a1type( x[j] ); a2x[j] = a2type( a1x[j] ); } Independent(a2x); // f(x) = x[0] / x[1] if x[1] > 0.0 else 0.0 a2y = fun(a2x); ADFun a1f; a1f.Dependent(a2x, a2y); // use reverse mode to calculate g(x) = f'(x) a1w[0] = a1type(1.0); Independent(a1x); a1f.Forward(0, a1x); a1z = a1f.Reverse(1, a1w); g.Dependent(a1x, a1z); // return; } // ---------------------------------------------------------------------- vector div(const vector& a2x) { vector a2y(m_); a2type a2zero = a2type(0.0); a2type a2four = a2type(4.0); a2y[0] = CondExpGt(a2x[1], a2zero, a2x[0] / a2x[1], a2zero); a2y[0] += CondExpGt(a2x[1], a2zero, a2four / a2x[1], a2zero); return a2y; } bool check_div(void) { bool ok = true; // record division operations ADFun g; record(div, g); vector x(n_), z(n_); // check result where x[1] <= 0.0 (would be nan without absoute zero) x[0] = 0.0; x[1] = 0.0; z = g.Forward(0, x); z = g.Forward(0, x); ok &= z[0] == 0.0; ok &= z[1] == 0.0; // check result where x[1] > 0.0 x[0] = 2.0; x[1] = 3.0; z = g.Forward(0, x); ok &= CppAD::NearEqual(z[0], 1.0/x[1], eps, eps); ok &= CppAD::NearEqual(z[1], - (x[0]+4.0)/(x[1]*x[1]), eps, eps); // return ok; } // ---------------------------------------------------------------------- vector mul(const vector& a2x) { vector a2y(m_); a2type a2zero = a2type(0.0); a2type a2four = a2type(4.0); a2y[0] = CondExpLt(a2x[0], a2four, a2x[0] * a2x[1], a2zero); a2y[0] += CondExpLt(a2x[0], a2four, a2four * a2x[1], a2zero); a2y[0] += CondExpLt(a2x[0], a2four, a2x[1] * a2four, a2zero); return a2y; } bool check_mul(void) { bool ok = true; // record multiplication operations ADFun g; record(mul, g); vector x(n_), z(n_); // check result where x[0] > 4 (would be nan without absoute zero) ok &= std::numeric_limits::has_infinity; x[0] = std::numeric_limits::infinity(); x[1] = 0.0; z = g.Forward(0, x); ok &= z[0] == 0.0; ok &= z[1] == 0.0; // check result where x[0] < 4 x[0] = 2.0; x[1] = 3.0; z = g.Forward(0, x); ok &= CppAD::NearEqual(z[0], x[1], eps, eps); ok &= CppAD::NearEqual(z[1], x[0]+8.0, eps, eps); // return ok; } // ---------------------------------------------------------------------- bool check_numeric_limits(void) { bool ok = true; // double double_eps = std::numeric_limits::epsilon(); zdouble zdouble_eps = CppAD::numeric_limits::epsilon(); ok &= double_eps == zdouble_eps; // double double_min = std::numeric_limits::min(); zdouble zdouble_min = CppAD::numeric_limits::min(); ok &= double_min == zdouble_min; // double double_max = std::numeric_limits::max(); zdouble zdouble_max = CppAD::numeric_limits::max(); ok &= double_max == zdouble_max; // return ok; } } bool mul_zdouble(void) { bool ok = true; ok &= check_div(); ok &= check_mul(); ok &= check_numeric_limits(); return ok; } cppad-20160000.1/test_more/makefile.in0000644000175200017650000011102712656321774016544 0ustar coincoin-web# 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 = test_more$(EXEEXT) subdir = test_more ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test_one.sh CONFIG_CLEAN_VPATH_FILES = 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 @CppAD_EIGEN_DIR_TRUE@am_libeigen_a_OBJECTS = \ @CppAD_EIGEN_DIR_TRUE@ libeigen_a-cppad_eigen.$(OBJEXT) libeigen_a_OBJECTS = $(am_libeigen_a_OBJECTS) am__test_more_SOURCES_DIST = base_adolc.cpp ipopt_solve.cpp \ alloc_openmp.cpp test_more.cpp abs.cpp acos.cpp acosh.cpp \ adfun_copy.cpp asin.cpp asinh.cpp assign.cpp add.cpp \ add_eq.cpp add_zero.cpp atan.cpp atanh.cpp atan2.cpp azmul.cpp \ base_alloc.cpp check_simple_vector.cpp checkpoint.cpp \ compare.cpp compare_change.cpp cond_exp.cpp cond_exp_ad.cpp \ cond_exp_rev.cpp copy.cpp cos.cpp cosh.cpp dbl_epsilon.cpp \ div.cpp div_eq.cpp div_zero_one.cpp erf.cpp exp.cpp expm1.cpp \ extern_value.cpp extern_value.hpp for_hess.cpp \ for_sparse_jac.cpp forward.cpp forward_dir.cpp \ forward_order.cpp from_base.cpp fun_check.cpp jacobian.cpp \ num_limits.cpp log.cpp log1p.cpp log10.cpp mul.cpp \ mul_cskip.cpp mul_eq.cpp mul_level.cpp mul_cond_rev.cpp \ mul_zdouble.cpp mul_zero_one.cpp near_equal_ext.cpp neg.cpp \ ode_err_control.cpp old_usead_2.cpp old_usead_1.cpp \ old_tan.cpp old_reciprocal.cpp old_mat_mul.cpp old_mat_mul.hpp \ omp_alloc.cpp optimize.cpp parameter.cpp poly.cpp pow.cpp \ pow_int.cpp print_for.cpp romberg_one.cpp rosen_34.cpp \ runge_45.cpp reverse.cpp rev_sparse_hes.cpp rev_sparse_jac.cpp \ rev_two.cpp simple_vector.cpp sin.cpp sin_cos.cpp sinh.cpp \ sparse_hessian.cpp sparse_jacobian.cpp sparse_vec_ad.cpp \ sqrt.cpp std_math.cpp sub.cpp sub_eq.cpp sub_zero.cpp tan.cpp \ test_vector.cpp to_string.cpp track_new_del.cpp value.cpp \ vec_ad.cpp vec_ad_par.cpp vec_unary.cpp zdouble.cpp @CppAD_ADOLC_TRUE@am__objects_1 = base_adolc.$(OBJEXT) @CppAD_IPOPT_TRUE@am__objects_2 = ipopt_solve.$(OBJEXT) @CppAD_OPENMP_TRUE@am__objects_3 = alloc_openmp.$(OBJEXT) am_test_more_OBJECTS = $(am__objects_1) $(am__objects_2) \ $(am__objects_3) test_more.$(OBJEXT) abs.$(OBJEXT) \ acos.$(OBJEXT) acosh.$(OBJEXT) adfun_copy.$(OBJEXT) \ asin.$(OBJEXT) asinh.$(OBJEXT) assign.$(OBJEXT) add.$(OBJEXT) \ add_eq.$(OBJEXT) add_zero.$(OBJEXT) atan.$(OBJEXT) \ atanh.$(OBJEXT) atan2.$(OBJEXT) azmul.$(OBJEXT) \ base_alloc.$(OBJEXT) check_simple_vector.$(OBJEXT) \ checkpoint.$(OBJEXT) compare.$(OBJEXT) \ compare_change.$(OBJEXT) cond_exp.$(OBJEXT) \ cond_exp_ad.$(OBJEXT) cond_exp_rev.$(OBJEXT) copy.$(OBJEXT) \ cos.$(OBJEXT) cosh.$(OBJEXT) dbl_epsilon.$(OBJEXT) \ div.$(OBJEXT) div_eq.$(OBJEXT) div_zero_one.$(OBJEXT) \ erf.$(OBJEXT) exp.$(OBJEXT) expm1.$(OBJEXT) \ extern_value.$(OBJEXT) for_hess.$(OBJEXT) \ for_sparse_jac.$(OBJEXT) forward.$(OBJEXT) \ forward_dir.$(OBJEXT) forward_order.$(OBJEXT) \ from_base.$(OBJEXT) fun_check.$(OBJEXT) jacobian.$(OBJEXT) \ num_limits.$(OBJEXT) log.$(OBJEXT) log1p.$(OBJEXT) \ log10.$(OBJEXT) mul.$(OBJEXT) mul_cskip.$(OBJEXT) \ mul_eq.$(OBJEXT) mul_level.$(OBJEXT) mul_cond_rev.$(OBJEXT) \ mul_zdouble.$(OBJEXT) mul_zero_one.$(OBJEXT) \ near_equal_ext.$(OBJEXT) neg.$(OBJEXT) \ ode_err_control.$(OBJEXT) old_usead_2.$(OBJEXT) \ old_usead_1.$(OBJEXT) old_tan.$(OBJEXT) \ old_reciprocal.$(OBJEXT) old_mat_mul.$(OBJEXT) \ omp_alloc.$(OBJEXT) optimize.$(OBJEXT) parameter.$(OBJEXT) \ poly.$(OBJEXT) pow.$(OBJEXT) pow_int.$(OBJEXT) \ print_for.$(OBJEXT) romberg_one.$(OBJEXT) rosen_34.$(OBJEXT) \ runge_45.$(OBJEXT) reverse.$(OBJEXT) rev_sparse_hes.$(OBJEXT) \ rev_sparse_jac.$(OBJEXT) rev_two.$(OBJEXT) \ simple_vector.$(OBJEXT) sin.$(OBJEXT) sin_cos.$(OBJEXT) \ sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \ sparse_jacobian.$(OBJEXT) sparse_vec_ad.$(OBJEXT) \ sqrt.$(OBJEXT) std_math.$(OBJEXT) sub.$(OBJEXT) \ sub_eq.$(OBJEXT) sub_zero.$(OBJEXT) tan.$(OBJEXT) \ test_vector.$(OBJEXT) to_string.$(OBJEXT) \ track_new_del.$(OBJEXT) value.$(OBJEXT) vec_ad.$(OBJEXT) \ vec_ad_par.$(OBJEXT) vec_unary.$(OBJEXT) zdouble.$(OBJEXT) test_more_OBJECTS = $(am_test_more_OBJECTS) test_more_LDADD = $(LDADD) am__DEPENDENCIES_1 = @CppAD_IPOPT_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) \ @CppAD_IPOPT_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @CppAD_IPOPT_TRUE@ $(am__DEPENDENCIES_1) test_more_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ $(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 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 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@) 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 = $(libeigen_a_SOURCES) $(test_more_SOURCES) DIST_SOURCES = $(am__libeigen_a_SOURCES_DIST) \ $(am__test_more_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 $(srcdir)/test_one.sh.in \ $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ 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 3769 2015-12-29 16:13:16Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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_OPENMP_FALSE@OPENMP_SRC_FILES = # # ------------------------------------------------------------------------- @CppAD_OPENMP_TRUE@OPENMP_SRC_FILES = alloc_openmp.cpp @CppAD_ADOLC_FALSE@ADOLC_SRC_FILES = # ------------------------------------------------------------------------- @CppAD_ADOLC_TRUE@ADOLC_SRC_FILES = base_adolc.cpp @CppAD_ADOLC_FALSE@ADOLC_EXTRA_FILES = base_adolc.cpp @CppAD_ADOLC_TRUE@ADOLC_EXTRA_FILES = @CppAD_ADOLC_FALSE@ADOLC_LIB = @CppAD_ADOLC_TRUE@ADOLC_LIB = -ladolc -lColPack -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64 @CppAD_ADOLC_FALSE@ADOLC_FLAGS = @CppAD_ADOLC_TRUE@ADOLC_FLAGS = -DCPPAD_ADOLC_TEST -I$(ADOLC_DIR)/include @CppAD_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 = -DCPPAD_IPOPT_TEST -I$(IPOPT_DIR)/include @CppAD_EIGEN_DIR_FALSE@EIGEN_EXTRA_FILES = cppad_eigen.cpp # ------------------------------------------------------------------------- # make a special library so can have it's own compile flags (see configure.ac) @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 @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@ -DCPPAD_EIGEN_TEST \ @CppAD_EIGEN_DIR_TRUE@ -I$(EIGEN_DIR)/include # ------------------------------------------------------------------------- # Microsoft project files and script to run a single test EXTRA_DIST = \ test_one.sh.in \ $(ADOLC_EXTRA_FILES) \ $(IPOPT_EXTRA_FILES) \ $(EIGEN_EXTRA_FILES) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ $(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) # test_more_SOURCES = \ $(ADOLC_SRC_FILES) \ $(IPOPT_SRC_FILES) \ $(OPENMP_SRC_FILES) \ test_more.cpp \ abs.cpp \ acos.cpp \ acosh.cpp \ adfun_copy.cpp \ asin.cpp \ asinh.cpp \ assign.cpp \ add.cpp \ add_eq.cpp \ add_zero.cpp \ atan.cpp \ atanh.cpp \ atan2.cpp \ azmul.cpp \ base_alloc.cpp \ check_simple_vector.cpp \ checkpoint.cpp \ compare.cpp \ compare_change.cpp \ cond_exp.cpp \ cond_exp_ad.cpp \ cond_exp_rev.cpp \ copy.cpp \ cos.cpp \ cosh.cpp \ dbl_epsilon.cpp \ div.cpp \ div_eq.cpp \ div_zero_one.cpp \ erf.cpp \ exp.cpp \ expm1.cpp \ extern_value.cpp \ extern_value.hpp \ for_hess.cpp \ for_sparse_jac.cpp \ forward.cpp \ forward_dir.cpp \ forward_order.cpp \ from_base.cpp \ fun_check.cpp \ jacobian.cpp \ num_limits.cpp \ log.cpp \ log1p.cpp \ log10.cpp \ mul.cpp \ mul_cskip.cpp \ mul_eq.cpp \ mul_level.cpp \ mul_cond_rev.cpp \ mul_zdouble.cpp \ mul_zero_one.cpp \ near_equal_ext.cpp \ neg.cpp \ ode_err_control.cpp \ old_usead_2.cpp \ old_usead_1.cpp \ old_tan.cpp \ old_reciprocal.cpp \ old_mat_mul.cpp \ old_mat_mul.hpp \ omp_alloc.cpp \ optimize.cpp \ parameter.cpp \ poly.cpp \ pow.cpp \ pow_int.cpp \ print_for.cpp \ romberg_one.cpp \ rosen_34.cpp \ runge_45.cpp \ reverse.cpp \ rev_sparse_hes.cpp \ rev_sparse_jac.cpp \ rev_two.cpp \ simple_vector.cpp \ sin.cpp \ sin_cos.cpp \ sinh.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp \ sparse_vec_ad.cpp \ sqrt.cpp \ std_math.cpp \ sub.cpp \ sub_eq.cpp \ sub_zero.cpp \ tan.cpp \ test_vector.cpp \ to_string.cpp \ track_new_del.cpp \ value.cpp \ vec_ad.cpp \ vec_ad_par.cpp \ vec_unary.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) --gnu test_more/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu test_more/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): test_one.sh: $(top_builddir)/config.status $(srcdir)/test_one.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 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) test_more$(EXEEXT): $(test_more_OBJECTS) $(test_more_DEPENDENCIES) $(EXTRA_test_more_DEPENDENCIES) @rm -f test_more$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(test_more_OBJECTS) $(test_more_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acos.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acosh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_eq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_zero.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adfun_copy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloc_openmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asinh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assign.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atan2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atanh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/azmul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_adolc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_alloc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_simple_vector.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checkpoint.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@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cond_exp_ad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cond_exp_rev.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cos.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cosh.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbl_epsilon.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)/erf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expm1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extern_value.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_hess.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_sparse_jac.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forward.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forward_dir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forward_order.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/from_base.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fun_check.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)/log.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log10.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log1p.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_cond_rev.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_cskip.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_eq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_level.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_zdouble.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_zero_one.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/near_equal_ext.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/neg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/num_limits.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_err_control.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_mat_mul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_reciprocal.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_tan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_usead_1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/old_usead_2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/omp_alloc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optimize.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parameter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_int.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print_for.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)/rev_two.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reverse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/romberg_one.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rosen_34.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/runge_45.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple_vector.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sin.Po@am__quote@ @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_jacobian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_vec_ad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sqrt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/std_math.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub_eq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub_zero.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_more.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_vector.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/to_string.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/track_new_del.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/value.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vec_ad.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vec_ad_par.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vec_unary.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zdouble.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @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) '$<'` 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` 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 $(LIBRARIES) 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 clean-noinstLIBRARIES \ 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 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 .PRECIOUS: makefile test: check ./test_more # 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: cppad-20160000.1/test_more/sparse_jacobian.cpp0000644000175200017650000003610012656321774020264 0ustar coincoin-web// $Id: sparse_jacobian.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. -------------------------------------------------------------------------- */ /* Old sparse Jacobian example */ # include namespace { // --------------------------------------------------------- bool rc_tridiagonal(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; size_t i, j, k, ell; double eps = 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] = (ell+1) * 0.5 * X[i] * X[i]; check[ell] = (ell+1) * x[i]; K++; if( i < n-1 ) { j = i + 1; ell = i * n + j; Y[i] += (ell+1) * 0.5 * X[i+1] * X[i+1]; check[ell] = (ell+1) * x[i+1]; K++; } if(i > 0 ) { j = i - 1; ell = i * n + j; Y[i] += (ell+1) * 0.5 * X[i-1] * X[i-1]; check[ell] = (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], eps, eps); } work.clear(); n_sweep = f.SparseJacobianReverse(x, p, r, c, jac, work); ok &= n_sweep == 3; for(k = 0; k < K; k++) { ell = r[k] * n + c[k]; ok &= NearEqual(check[ell], jac[k], eps, eps); } return ok; } template bool rc_set(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; size_t i, j, k, ell; double eps = 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], eps, eps); } 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], eps, eps); } ok &= (n_sweep == 1); return ok; } template bool rc_bool(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; size_t j, k, ell; double eps = 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], eps, eps); } 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], eps, eps); } ok &= (n_sweep == 1); return ok; } template bool reverse_bool(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; size_t i, j, k; // 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], 1e-10, 1e-10 ); // 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], 1e-10, 1e-10 ); return ok; } template bool reverse_set(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; size_t i, j, k; // 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], 1e-10, 1e-10 ); // 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], 1e-10, 1e-10 ); return ok; } template bool forward_bool(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; size_t j, k; // 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], 1e-10, 1e-10 ); // 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], 1e-10, 1e-10 ); return ok; } template bool forward_set(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; size_t j, k; // 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], 1e-10, 1e-10 ); // 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], 1e-10, 1e-10 ); 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] ); } } return ok; } } // End empty namespace # include # include bool sparse_jacobian(void) { bool ok = true; ok &= rc_tridiagonal(); ok &= multiple_of_n_bit(); // --------------------------------------------------------------- // 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; } cppad-20160000.1/test_more/track_new_del.cpp0000644000175200017650000000322012656321774017737 0ustar coincoin-web// $Id: track_new_del.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin TrackNewDel.cpp$$ $section Tracking Use of New and Delete: Example and Test$$ $mindex delete$$ $code $verbatim%test_more/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 lenght 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 lenght 10 newlen = 10; ptr = CPPAD_TRACK_EXTEND(newlen, ncopy, ptr); // copy data into the new part of the array for(i = ncopy; i < newlen; i++) ptr[i] = double(i); // check the values in the array for(i = 0; i < newlen; i++) 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++ cppad-20160000.1/test_more/mul_level.cpp0000644000175200017650000002305012656321774017125 0ustar coincoin-web// $Id: mul_level.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # ifdef CPPAD_ADOLC_TEST # include # include # include // adouble definitions not in Adolc distribution and // required in order to use CppAD::AD # include # endif # include # include 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); return ok; } // f(x) = |x|^2 = .5 * ( x[0]^2 + ... + x[n-1]^2 ) template Type f_Two(CPPAD_TESTVECTOR(Type) &x) { Type sum; // check assignment of AD< AD > = double sum = .5; sum += .5; size_t i = x.size(); while(i--) sum += x[i] * x[i]; // check computed assignment AD< AD > -= int sum -= 1; // check double * AD< AD > return .5 * sum; } bool Two(void) { bool ok = true; // initialize test result 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], 1e-10, 1e-10); return ok; } # ifdef CPPAD_ADOLC_TEST bool adolc(void) { 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 = 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], 1e-10, 1e-10); CPPAD_TRACK_DEL_VEC(v); // check usage of delete CPPAD_TRACK_DEL_VEC(ddf_v); return ok; } # endif // CPPAD_ADOLC_TEST 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); return ok; } // supress this test until ../bug/abs.sh is fixed # ifdef CPPAD_NOT_DEFINED bool abs(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) = abs(x) aax[0] = 1.; Independent( aax ); aay[0] = abs(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; } # endif } // END empty namespace bool mul_level(void) { bool ok = true; ok &= One(); ok &= Two(); # ifdef CPPAD_ADOLC_TEST ok &= adolc(); # endif ok &= std_math(); # ifdef CPPAD_NOT_DEFINED ok &= abs(); # endif return ok; } cppad-20160000.1/test_more/sub_eq.cpp0000644000175200017650000000631112656321774016420 0ustar coincoin-web// $Id: sub_eq.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Two old SubEq examples now used just for valiadation testing */ # include namespace { // BEGIN empty namespace bool SubEqTestOne(void) { bool ok = true; 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) return ok; } bool SubEqTestTwo(void) { bool ok = true; using namespace CppAD; // 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, 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = -1.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } } // END empty namespace bool SubEq(void) { bool ok = true; ok &= SubEqTestOne(); ok &= SubEqTestTwo(); return ok; } cppad-20160000.1/test_more/fun_check.cpp0000644000175200017650000000705412656321774017074 0ustar coincoin-web// $Id: fun_check.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* old example, now just used for testing deprecated syntax f.Dependent(y) */ // BEGIN C++ # include namespace { // ----------------------------------------------------------- // define the template function object Fun in empty namespace template 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 in empty namespace template bool FunCheckCases(void) { bool ok = true; using CppAD::AD; using CppAD::ADFun; using CppAD::Independent; // 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 = 1e-10; double a = 1e-10; 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); 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; } // END C++ cppad-20160000.1/test_more/mul_cskip.cpp0000644000175200017650000000363012656321774017131 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include // Test multiple level conditional skip where value of comparision is // uncertain during forward mode base Base value can be a variable. bool mul_cskip(void) { bool ok = true; using namespace CppAD; using CppAD::vector; typedef AD a1type; typedef AD a2type; size_t n = 2; size_t m = 1; vector x(n), y(m); x[0] = 0.0; x[1] = 1.0; // start recording a2type operations vector a2x(n), a2y(m); for (size_t j = 0; j < n; j++) a2x[j] = a2type( a1type(x[j]) ); Independent(a2x); // a1f(x) = x_0 * x_1 if x[0] == 1 // 0.0 otherwise a2type a2zero = a2type(0.0); a2type a2one = a2type(1.0); a2type a2p = a2x[0] * a2x[1]; a2y[0] = CondExpEq(a2x[0], a2one, a2p, a2zero); ADFun a1f(a2x, a2y); // Optimization will check to see if we can skip part of conditional // expression that is not used. a1f.optimize(); // f(x) = x_0 * x_1 if x[0] == 1 // 0.0 otherwise vector a1x(n), a1y(m); for (size_t j = 0; j < n; j++) a1x[j] = a1type(x[j]); Independent(a1x); a1y = a1f.Forward(0, a1x); CppAD::ADFun f(a1x, a1y); // check case where x[0] == 1 x[0] = 1.0; x[1] = 2.0; y = f.Forward(0, x); ok &= y[0] == x[1]; // check case where x[0] != 1 x[0] = 3.0; x[1] = 2.0; y = f.Forward(0, x); ok &= y[0] == 0.0; return ok; } cppad-20160000.1/test_more/ode_err_control.cpp0000644000175200017650000002474212656321774020331 0ustar coincoin-web// $Id: ode_err_control.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. -------------------------------------------------------------------------- */ # include // for size_t # include // for exp # include // CppAD::OdeErrControl # include // CppAD::NearEqual # include // CppAD::vector # include // CppAD::Runge45 /* ------------------------------------------------------------------------- Test relative error with zero initial conditions. (Uses minimum step size to integrate). */ 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] = (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 // 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); // inputs to OdeErrControl 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.; } // outputs from OdeErrControl CppAD::vector ef(n); CppAD::vector xf(n); xf = OdeErrControl(method, ti, tf, xi, smin, smax, scur, eabs, erel, ef); double check = 1.; for(i = 0; i < n; i++) { check *= tf; ok &= CppAD::NearEqual(check, xf[i], erel, 0.); } return ok; } /* Old example now just a test Define $latex X : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} X_0 (t) & = & - \exp ( - w_0 t ) \\ X_1 (t) & = & \frac{w_0}{w_1 - w_0} [ \exp ( - w_0 t ) - \exp( - w_1 t )] \end{array} \] $$ 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) \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; } }; } bool OdeErrControl_two(void) { bool ok = true; // initial return value 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 &= CppAD::NearEqual(x0, xf[0], 1e-4, 1e-4); ok &= CppAD::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 &= CppAD::NearEqual(x1, xf[1], 1e-4, 1e-4); ok &= CppAD::NearEqual(0., ef[1], 1e-4, 1e-4); 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) \end{array} \] $$ It follows that $latex \[ \begin{array}{rcl} X_0 (t) & = & \exp ( \alpha t^2 ) \\ X_1 (t) & = & \int_0^t \exp( - \alpha s^2 ) {\bf d} s \\ & = & \frac{1}{ \sqrt{\alpha} \int_0^{\sqrt{\alpha} t} \exp( - r^2 ) {\bf d} r \\ & = & \frac{\sqrt{\pi}}{ 2 \sqrt{\alpha} {\rm erf} ( \sqrt{\alpha} t ) \end{array} \] $$ If $latex X_0 (t) < 0$$, we return $code nan$$ in order to inform $code OdeErrControl$$ that its is taking to large a step. */ # include // CppAD::Rosen34 # 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; } }; } bool OdeErrControl_three(void) { bool ok = true; // initial return value double alpha = 10.; Method_three 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 * tf ); ok &= CppAD::NearEqual(x0, xf[0], 1e-4, 1e-4); ok &= CppAD::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 &= CppAD::NearEqual(x1, xf[1], 1e-4, 1e-4); ok &= CppAD::NearEqual(0., ef[1], 1e-4, 1e-4); ok &= method.F.was_negative(); 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] = (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 // 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; } // ========================================================================== bool ode_err_control(void) { bool ok = true; ok &= OdeErrControl_one(); ok &= OdeErrControl_two(); ok &= OdeErrControl_three(); ok &= OdeErrControl_four(); return ok; } cppad-20160000.1/test_more/compare.cpp0000644000175200017650000000365612656321774016601 0ustar coincoin-web// $Id: compare.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Check comparison operators between AD< AD > and Base, int */ # 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 ); return ok; } } bool Compare(void) { bool ok = true; ok &= Compare(); ok &= Compare(); ok &= Compare< CppAD::AD >(); return ok; } cppad-20160000.1/test_more/parameter.cpp0000644000175200017650000000311312656321774017117 0ustar coincoin-web// $Id: parameter.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // Test hash coding of parameter during recording # include 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); } // create f: ax -> ay ADFun f(ax, ay); ok = f.size_par() == n_parameter; return ok; } } // END empty namespace bool parameter(void) { bool ok = true; ok &= test(); ok &= test(); return ok; } cppad-20160000.1/test_more/sub_zero.cpp0000644000175200017650000000360512656321774016775 0ustar coincoin-web// $Id: sub_zero.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test the use of the special parameters zero and one with the multiply operator */ # include typedef CppAD::AD ADdouble; typedef CppAD::AD< ADdouble > ADDdouble; bool SubZero(void) { using namespace CppAD; bool ok = true; 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 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(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]; // 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); // check derivatives of g ok &= (b[0] == 1.); ok &= (b[1] == -2.); } } return ok; } cppad-20160000.1/test_more/azmul.cpp0000644000175200017650000001572012656321774016276 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include namespace { bool test_forward(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double inf = std::numeric_limits::infinity(); double eps = 10. * std::numeric_limits::epsilon(); typedef AD a1double; typedef AD a2double; // domain space vector size_t n = 2; size_t m = 3; // double level CPPAD_TESTVECTOR(double) x(n), z(m); x[0] = 3.0; x[1] = 4.0; // start a1 level recording CPPAD_TESTVECTOR(a1double) a1x(n), a1dx(n), a1y(m), a1z(m); for(size_t j = 0; j < n; j++) a1x[j] = x[j]; CppAD::Independent(a1x); // start a2 level recording CPPAD_TESTVECTOR(a2double) a2x(n), a2y(m); for(size_t j = 0; j < n; j++) a2x[j] = a1x[j]; CppAD::Independent(a2x); // y a2y[0] = CppAD::azmul(a2x[0], a2x[1]); // azmul(variable, variable) a2y[1] = CppAD::azmul(a1x[0], a2x[1]); // azmul(parameter, variable) a2y[2] = CppAD::azmul(a2x[0], a1x[1]); // azmul(variable, parameter) // create f: x -> y and stop a2 recording CppAD::ADFun a1f; a1f.Dependent(a2x, a2y); // check y a1y = a1f.Forward(0, a1x); // azmul(variable, variable) only for(size_t i = 0; i < m; i++) ok &= NearEqual(a1y[i] , x[0] * x[1], eps, eps); for(size_t j = 0; j < n; j++) a1dx[j] = a1double(1.0); a1z = a1f.Forward(1, a1dx); // create g: x -> z and stop a1 recording CppAD::ADFun g; g.Dependent(a1x, a1z); // check value when x[0] is not zero z = g.Forward(0, x); // z_0 = d_lambda [ ( x[0] + lambda ) * ( x[1] + lambda ) ] ok &= NearEqual(z[0] , x[0] + x[1], eps, eps); // z_1 = d_lambda [ x[0] * ( x[1] + lambda ) ] ok &= NearEqual(z[1] , x[0], eps, eps); // z_2 = d_lambda [ ( x[0] + lambda ) * x[1] ] ok &= NearEqual(z[2] , x[1], eps, eps); // check value x[0] is zero and x[1] is infinity x[0] = 0.0; x[1] = inf; z = g.Forward(0, x); ok &= z[0] == inf; ok &= z[1] == 0.0; ok &= z[2] == inf; return ok; } bool test_reverse(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double inf = std::numeric_limits::infinity(); double eps = 10. * std::numeric_limits::epsilon(); typedef AD a1double; typedef AD a2double; // domain space vector size_t n = 2; size_t m = 3; // double level CPPAD_TESTVECTOR(double) x(n), z(n); x[0] = 3.0; x[1] = 4.0; // start a1 level recording CPPAD_TESTVECTOR(a1double) a1x(n), a1dx(n), a1w(m), a1z(n); for(size_t j = 0; j < n; j++) a1x[j] = x[j]; CppAD::Independent(a1x); // start a2 level recording CPPAD_TESTVECTOR(a2double) a2x(n), a2y(m); for(size_t j = 0; j < n; j++) a2x[j] = a1x[j]; CppAD::Independent(a2x); // y a2y[0] = CppAD::azmul(a2x[0], a2x[1]); // azmul(variable, variable) a2y[1] = CppAD::azmul(a1x[0], a2x[1]); // azmul(parameter, variable) a2y[2] = CppAD::azmul(a2x[0], a1x[1]); // azmul(variable, parameter) // create f: x -> y and stop a2 recording CppAD::ADFun a1f; a1f.Dependent(a2x, a2y); // w(x) = y[0] + y[1] + y[2] for(size_t i = 0; i < m; i++) a1w[i] = a1double(1.0); a1f.Forward(0, a1x); a1dx = a1f.Reverse(1, a1w); // create g: x -> z and stop a1 recording CppAD::ADFun g; g.Dependent(a1x, a1dx); // check value when x[0] is not zero z = g.Forward(0, x); // partial y[0] w.r.t x[0] = x[1] // partial y[1] w.r.t x[0] = 0 // partial y[2] w.r.t x[0] = x[1] ok &= NearEqual(z[0] , x[1] + x[1], eps, eps); // partial y[0] w.r.t x[1] = x[0] // partial y[1] w.r.t x[1] = x[0] // partial y[2] w.r.t x[1] = 0 ok &= NearEqual(z[1] , x[0] + x[0], eps, eps); // check value x[0] is zero and x[1] is infinity x[0] = 0.0; x[1] = inf; z = g.Forward(0, x); ok &= z[0] == inf; ok &= z[1] == 0.0; return ok; } bool test_forward_dir(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double inf = std::numeric_limits::infinity(); double eps = 10. * std::numeric_limits::epsilon(); typedef AD a1double; typedef AD a2double; // domain space vector size_t n = 2; size_t m = 3; size_t r = 2; // double level CPPAD_TESTVECTOR(double) x(n), z(r * m); x[0] = 3.0; x[1] = 4.0; // start a1 level recording CPPAD_TESTVECTOR(a1double) a1x(n), a1dx(r * n), a1y(m), a1z(r * m); for(size_t j = 0; j < n; j++) a1x[j] = x[j]; CppAD::Independent(a1x); // start a2 level recording CPPAD_TESTVECTOR(a2double) a2x(n), a2y(m); for(size_t j = 0; j < n; j++) a2x[j] = a1x[j]; CppAD::Independent(a2x); // y a2y[0] = CppAD::azmul(a2x[0], a2x[1]); // azmul(variable, variable) a2y[1] = CppAD::azmul(a1x[0], a2x[1]); // azmul(parameter, variable) a2y[2] = CppAD::azmul(a2x[0], a1x[1]); // azmul(variable, parameter) // create f: x -> y and stop a2 recording CppAD::ADFun a1f; a1f.Dependent(a2x, a2y); // check y a1y = a1f.Forward(0, a1x); // azmul(variable, variable) only for(size_t i = 0; i < m; i++) ok &= NearEqual(a1y[i] , x[0] * x[1], eps, eps); for(size_t j = 0; j < n; j++) { for(size_t ell = 0; ell < r; ell++) a1dx[r * j + ell] = a1double(1.0 + ell); } a1z = a1f.Forward(1, r, a1dx); // create g: x -> z and stop a1 recording CppAD::ADFun g; g.Dependent(a1x, a1z); // check value when x[0] is not zero z = g.Forward(0, x); // z_00 = d_lambda [ ( x[0] + lambda ) * ( x[1] + lambda ) ] ok &= NearEqual(z[r * 0 + 0] , x[0] + x[1], eps, eps); // z_01 = d_lambda [ ( x[0] + 2 * lambda ) * ( x[1] + 2 * lambda ) ] ok &= NearEqual(z[r * 0 + 1] , 2.0*(x[0] + x[1]), eps, eps); // z_10 = d_lambda [ x[0] * ( x[1] + lambda ) ] ok &= NearEqual(z[r * 1 + 0] , x[0], eps, eps); // z_11 = d_lambda [ x[0] * ( x[1] + 2 * lambda ) ] ok &= NearEqual(z[r * 1 + 1] , 2.0 * x[0], eps, eps); // z_20 = d_lambda [ ( x[0] + lambda ) * x[1] ] ok &= NearEqual(z[r * 2 + 0] , x[1], eps, eps); // z_21 = d_lambda [ ( x[0] + 2 * lambda ) * x[1] ] ok &= NearEqual(z[r * 2 + 1] , 2.0 * x[1], eps, eps); // check value x[0] is zero and x[1] is infinity x[0] = 0.0; x[1] = inf; z = g.Forward(0, x); ok &= z[r * 0 + 0] == inf; ok &= z[r * 0 + 1] == inf; ok &= z[r * 1 + 0] == 0.0; ok &= z[r * 1 + 1] == 0.0; ok &= z[r * 2 + 0] == inf; ok &= z[r * 2 + 1] == inf; return ok; } } bool azmul(void) { bool ok = true; ok &= test_forward(); ok &= test_reverse(); ok &= test_forward_dir(); return ok; } cppad-20160000.1/test_more/runge_45.cpp0000644000175200017650000000676412656321774016606 0ustar coincoin-web// $Id: runge_45.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old OdeRunge example now used just for valiadation testing of Runge45 */ # include # include # 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; }; } // END Empty namespace bool Runge45(void) { bool ok = true; using namespace CppAD; 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, 1e-14, 1e-14); 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, 1e-14, 1e-14); // 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], 1e-14, 1e-14); else if( j <= i ) ok &= NearEqual( q[j], x[i]/w[j], 1e-14, 1e-14); else ok &= NearEqual(q[j], 0., 1e-14, 1e-14); } } // 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], 1e-14, 1e-14); else if( j == 1 ) ok &= NearEqual( q[j], x[i]/w[1], 1e-14, 1e-14); else ok &= NearEqual(q[j], 0., 1e-14, 1e-14); } return ok; } cppad-20160000.1/test_more/expm1.cpp0000644000175200017650000000374012656321774016177 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include bool expm1(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 10 times machine epsilon double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) ax(n); ax[0] = x0; // declare independent variables and start tape recording CppAD::Independent(ax); // a temporary value AD log_p1 = CppAD::log(ax[0] + 1.0); // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = CppAD::expm1(log_p1); // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); // check value ok &= NearEqual(ay[0] , x0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., eps, eps); // forward computation of higher order partials w.r.t. x[0] size_t n_order = 5; for(size_t order = 2; order < n_order; order++) { dx[0] = 0.; dy = f.Forward(order, dx); ok &= NearEqual(dy[0], 0., eps, eps); } // reverse computation of derivatives CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n_order * n); w[0] = 1.; dw = f.Reverse(n_order, w); ok &= NearEqual(dw[0], 1., eps, eps); for(size_t order = 1; order < n_order; order++) ok &= NearEqual(dw[order * n + 0], 0., eps, eps); return ok; } // END C++ cppad-20160000.1/test_more/poly.cpp0000644000175200017650000000423512656321774016130 0ustar coincoin-web// $Id: poly.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* // Old GetStarted example now used just for validation testing */ // BEGIN C++ // directory where cppad/cppad.hpp is stored must be searched by compiler # include bool Poly(void) { bool ok = true; // make CppAD routines visible without CppAD:: infront of names using namespace CppAD; // 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 // compare with derivative as computed by Poly ok &= (Poly(1, a, z[0]) == J[0]); return ok; } // END C++ cppad-20160000.1/test_more/compare_change.cpp0000644000175200017650000002301412656321774020074 0ustar coincoin-web/* $Id: compare_change.cpp 3607 2015-01-20 16:20:41Z 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. -------------------------------------------------------------------------- */ /* Old CompareChange examples and tests, now just used for validation testing */ # 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); return ok; } } bool compare_change(void) { bool ok = true; ok &= CompareChange_one(); ok &= CompareChange_two(); return ok; } // END C++ cppad-20160000.1/test_more/atanh.cpp0000644000175200017650000000374312656321774016243 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include bool atanh(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 10 times machine epsilon double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) ax(n); ax[0] = x0; // declare independent variables and start tape recording CppAD::Independent(ax); // a temporary value AD tanh_of_x0 = CppAD::tanh(ax[0]); // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = CppAD::atanh(tanh_of_x0); // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); // check value ok &= NearEqual(ay[0] , x0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., eps, eps); // forward computation of higher order partials w.r.t. x[0] size_t n_order = 5; for(size_t order = 2; order < n_order; order++) { dx[0] = 0.; dy = f.Forward(order, dx); ok &= NearEqual(dy[0], 0., eps, eps); } // reverse computation of derivatives CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n_order * n); w[0] = 1.; dw = f.Reverse(n_order, w); ok &= NearEqual(dw[0], 1., eps, eps); for(size_t order = 1; order < n_order; order++) ok &= NearEqual(dw[order * n + 0], 0., eps, eps); return ok; } // END C++ cppad-20160000.1/test_more/mul_eq.cpp0000644000175200017650000000701712656321774016430 0ustar coincoin-web// $Id: mul_eq.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Two old MulEq examples now used just for valiadation testing */ # include namespace { // BEGIN empty namespace bool MulEqTestOne(void) { bool ok = true; 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. ); return ok; } bool MulEqTestTwo(void) { bool ok = true; using namespace CppAD; // 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, 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); 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(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); } return ok; } } // END empty namespace bool MulEq(void) { bool ok = true; ok &= MulEqTestOne(); ok &= MulEqTestTwo(); return ok; } cppad-20160000.1/test_more/vec_unary.cpp0000644000175200017650000000413612656321774017140 0ustar coincoin-web// $Id: vec_unary.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test the use of VecADelem with unary operators */ # include bool VecUnary(void) { using namespace CppAD; using CppAD::abs; using CppAD::sin; using CppAD::atan; using CppAD::cos; using CppAD::exp; using CppAD::log; using CppAD::sqrt; 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] = abs( 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] = abs( x[7] ); z = f.Forward(0, x); ok &= NearEqual(z[0], - x[0], 1e-10, 1e-10); ok &= NearEqual(z[1], sin( x[1] ), 1e-10, 1e-10); ok &= NearEqual(z[2], abs( x[2] ), 1e-10, 1e-10); ok &= NearEqual(z[3], atan(x[3] ), 1e-10, 1e-10); ok &= NearEqual(z[4], cos( x[4] ), 1e-10, 1e-10); ok &= NearEqual(z[5], exp( x[5] ), 1e-10, 1e-10); ok &= NearEqual(z[6], log( x[6] ), 1e-10, 1e-10); ok &= NearEqual(z[7], sqrt(x[7] ), 1e-10, 1e-10); return ok; } cppad-20160000.1/test_more/vec_ad_par.cpp0000644000175200017650000000352112656321774017225 0ustar coincoin-web// $Id: vec_ad_par.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test the use of the parameters in VecAD element assignments */ # include typedef CppAD::AD ADdouble; typedef CppAD::AD< ADdouble > ADDdouble; bool VecADPar(void) { using namespace CppAD; 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); // check function value ok &= (d[0] == c[0] + c[1]); return ok; } cppad-20160000.1/test_more/exp.cpp0000644000175200017650000000667412656321774015752 0ustar coincoin-web// $Id: exp.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Two old exp example now used just for validation testing. */ # include # include namespace { // BEGIN empty namespace bool ExpTestOne(void) { bool ok = true; using CppAD::exp; using namespace CppAD; // 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.), 1e-10 , 1e-10); ok &= NearEqual(Z[y] , exp( exp(1.) ), 1e-10 , 1e-10); // forward computation of partials w.r.t. s v[s] = 1.; w = f.Forward(1, v); ok &= NearEqual(w[x], Z[x], 1e-10 , 1e-10); // dx/ds ok &= NearEqual(w[y], Z[y] * Z[x], 1e-10 , 1e-10); // 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], 1e-10 , 1e-10); // 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], 1e-10 , 1e-10 ); // 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], 1e-10 , 1e-10 ); return ok; } bool ExpTestTwo(void) { bool ok = true; using CppAD::exp; using namespace CppAD; // 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]), 1e-10 , 1e-10); // 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 *= j; ok &= NearEqual(jfac*w[0], exp_u, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], exp_u, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); } return ok; } } // END empty namespace bool Exp(void) { bool ok = true; ok &= ExpTestOne(); ok &= ExpTestTwo(); return ok; } cppad-20160000.1/test_more/acosh.cpp0000644000175200017650000000374412656321774016246 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include bool acosh(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 10 times machine epsilon double eps = 200. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) ax(n); ax[0] = x0; // declare independent variables and start tape recording CppAD::Independent(ax); // a temporary value AD cosh_of_x0 = CppAD::cosh(ax[0]); // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = CppAD::acosh(cosh_of_x0); // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); // check value ok &= NearEqual(ay[0] , x0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., eps, eps); // forward computation of higher order partials w.r.t. x[0] size_t n_order = 5; for(size_t order = 2; order < n_order; order++) { dx[0] = 0.; dy = f.Forward(order, dx); ok &= NearEqual(dy[0], 0., eps, eps); } // reverse computation of derivatives CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n_order * n); w[0] = 1.; dw = f.Reverse(n_order, w); ok &= NearEqual(dw[0], 1., eps, eps); for(size_t order = 1; order < n_order; order++) ok &= NearEqual(dw[order * n + 0], 0., eps, eps); return ok; } // END C++ cppad-20160000.1/test_more/sin_cos.cpp0000644000175200017650000002125012656321774016576 0ustar coincoin-web// $Id: sin_cos.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Comprehensive test of Trigonometric and Hyperbolic Sine and Cosine */ # include # include namespace { // Begin empty namespace bool Sin(void) { bool ok = true; using CppAD::sin; using CppAD::cos; using namespace CppAD; // 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]), 1e-10 , 1e-10); // 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 *= j; // check j-th derivative of z w.r.t x ok &= NearEqual(jfac*w[0], sinj * yj, 1e-10 , 1e-10); v[0] = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r( 2 * p); 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, 1e-10 , 1e-10); // derivative w.r.t y of sin^{(j)} (x * y) * y^j double value = sinjp * yj * x + j * sinj * yj / y; ok &= NearEqual(jfac*r[p+j], value , 1e-10 , 1e-10); jfac *= (j + 1); yj *= y; } return ok; } bool Cos(void) { bool ok = true; using CppAD::sin; using CppAD::cos; using namespace CppAD; // 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]), 1e-10 , 1e-10); // 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 *= j; // check j-th derivative of z w.r.t x ok &= NearEqual(jfac*w[0], cosj * yj, 1e-10 , 1e-10); v[0] = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r( 2 * p); 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, 1e-10 , 1e-10); // derivative w.r.t y of cos^{(j)} (x * y) * y^j double value = cosjp * yj * x + j * cosj * yj / y; ok &= NearEqual(jfac*r[p+j], value , 1e-10 , 1e-10); jfac *= (j + 1); yj *= y; } return ok; } bool Cosh(void) { bool ok = true; using CppAD::sinh; using CppAD::cosh; using namespace CppAD; // 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]), 1e-10 , 1e-10); // 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 *= j; // check j-th derivative of z w.r.t x ok &= NearEqual(jfac*w[0], coshj * yj, 1e-10 , 1e-10); v[0] = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r( 2 * p); 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, 1e-10 , 1e-10); // derivative w.r.t y of cosh^{(j)} (x * y) * y^j double value = coshjp * yj * x + j * coshj * yj / y; ok &= NearEqual(jfac*r[p+j], value , 1e-10 , 1e-10); jfac *= (j + 1); yj *= y; } return ok; } bool Sinh(void) { bool ok = true; using CppAD::sinh; using CppAD::cosh; using namespace CppAD; // 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]), 1e-10 , 1e-10); // 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 *= j; // check j-th derivative of z w.r.t x ok &= NearEqual(jfac*w[0], sinhj * yj, 1e-10 , 1e-10); v[0] = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r( 2 * p); 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, 1e-10 , 1e-10); // derivative w.r.t y of sinh^{(j)} (x * y) * y^j double value = sinhjp * yj * x + j * sinhj * yj / y; ok &= NearEqual(jfac*r[p+j], value , 1e-10 , 1e-10); jfac *= (j + 1); yj *= y; } return ok; } } // End empty namespace bool SinCos(void) { bool ok = Sin() & Cos() & Cosh() & Sinh(); return ok; } cppad-20160000.1/test_more/old_mat_mul.cpp0000644000175200017650000002016212656321774017436 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin old_mat_mul.cpp$$ $spell mul $$ $section Old Matrix Multiply as a User Atomic Operation: Example and Test$$ $head Deprecated 2013-05-27$$ This example has been deprecated; see $cref atomic_mat_mul.cpp$$. $children% test_more/old_mat_mul.hpp %$$ $head Include File$$ This routine uses the include file $cref old_mat_mul.hpp$$. $code $verbatim%test_more/old_mat_mul.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include "old_mat_mul.hpp" bool old_mat_mul(void) { bool ok = true; using CppAD::AD; // matrix sizes for this test size_t nr_result = 2; size_t n_middle = 2; size_t nc_result = 2; // declare the AD vectors ax and ay and X size_t n = nr_result * n_middle + n_middle * nc_result; size_t m = nr_result * nc_result; CppAD::vector< AD > X(4), ax(n), ay(m); size_t i, j; for(j = 0; j < X.size(); j++) X[j] = (j + 1); // X is the vector of independent variables CppAD::Independent(X); // left matrix ax[0] = X[0]; // left[0,0] = x[0] = 1 ax[1] = X[1]; // left[0,1] = x[1] = 2 ax[2] = 5.; // left[1,0] = 5 ax[3] = 6.; // left[1,1] = 6 // right matrix ax[4] = X[2]; // right[0,0] = x[2] = 3 ax[5] = 7.; // right[0,1] = 7 ax[6] = X[3]; // right[1,0] = x[3] = 4 ax[7] = 8.; // right[1,1] = 8 /* [ x0 , x1 ] * [ x2 , 7 ] = [ x0*x2 + x1*x3 , x0*7 + x1*8 ] [ 5 , 6 ] [ x3 , 8 ] [ 5*x2 + 6*x3 , 5*7 + 6*8 ] */ // The call back routines need to know the dimensions of the matrices. // Store information about the matrix multiply for this call to mat_mul. call_info info; info.nr_result = nr_result; info.n_middle = n_middle; info.nc_result = nc_result; // info.vx gets set by forward during call to mat_mul below assert( info.vx.size() == 0 ); size_t id = info_.size(); info_.push_back(info); // user defined AD version of matrix multiply mat_mul(id, ax, ay); //---------------------------------------------------------------------- // check AD results ok &= ay[0] == (1*3 + 2*4); ok &= Variable( ay[0] ); ok &= ay[1] == (1*7 + 2*8); ok &= Variable( ay[1] ); ok &= ay[2] == (5*3 + 6*4); ok &= Variable( ay[2] ); ok &= ay[3] == (5*7 + 6*8); ok &= Parameter( ay[3] ); //---------------------------------------------------------------------- // use mat_mul to define a function g : X -> ay CppAD::ADFun G; G.Dependent(X, ay); // g(x) = [ x0*x2 + x1*x3 , x0*7 + x1*8 , 5*x2 + 6*x3 , 5*7 + 6*8 ]^T //---------------------------------------------------------------------- // Test zero order forward mode evaluation of g(x) CppAD::vector x( X.size() ), y(m); for(j = 0; j < X.size() ; j++) x[j] = j + 2; y = G.Forward(0, x); ok &= y[0] == x[0] * x[2] + x[1] * x[3]; ok &= y[1] == x[0] * 7. + x[1] * 8.; ok &= y[2] == 5. * x[2] + 6. * x[3]; ok &= y[3] == 5. * 7. + 6. * 8.; //---------------------------------------------------------------------- // Test first order forward mode evaluation of g'(x) * [1, 2, 3, 4]^T // g'(x) = [ x2, x3, x0, x1 ] // [ 7 , 8, 0, 0 ] // [ 0 , 0, 5, 6 ] // [ 0 , 0, 0, 0 ] CppAD::vector dx( X.size() ), dy(m); for(j = 0; j < X.size() ; j++) dx[j] = j + 1; dy = G.Forward(1, dx); ok &= dy[0] == 1. * x[2] + 2. * x[3] + 3. * x[0] + 4. * x[1]; ok &= dy[1] == 1. * 7. + 2. * 8. + 3. * 0. + 4. * 0.; ok &= dy[2] == 1. * 0. + 2. * 0. + 3. * 5. + 4. * 6.; ok &= dy[3] == 1. * 0. + 2. * 0. + 3. * 0. + 4. * 0.; //---------------------------------------------------------------------- // Test second order forward mode // g_0^2 (x) = [ 0, 0, 1, 0 ], g_0^2 (x) * [1] = [3] // [ 0, 0, 0, 1 ] [2] [4] // [ 1, 0, 0, 0 ] [3] [1] // [ 0, 1, 0, 0 ] [4] [2] CppAD::vector ddx( X.size() ), ddy(m); for(j = 0; j < X.size() ; j++) ddx[j] = 0.; ddy = G.Forward(2, ddx); // [1, 2, 3, 4] * g_0^2 (x) * [1, 2, 3, 4]^T = 1*3 + 2*4 + 3*1 + 4*2 ok &= 2. * ddy[0] == 1. * 3. + 2. * 4. + 3. * 1. + 4. * 2.; // for i > 0, [1, 2, 3, 4] * g_i^2 (x) * [1, 2, 3, 4]^T = 0 ok &= ddy[1] == 0.; ok &= ddy[2] == 0.; ok &= ddy[3] == 0.; //---------------------------------------------------------------------- // Test second order reverse mode CppAD::vector w(m), dw(2 * X.size() ); for(i = 0; i < m; i++) w[i] = 0.; w[0] = 1.; dw = G.Reverse(2, w); // g_0'(x) = [ x2, x3, x0, x1 ] ok &= dw[0*2 + 0] == x[2]; ok &= dw[1*2 + 0] == x[3]; ok &= dw[2*2 + 0] == x[0]; ok &= dw[3*2 + 0] == x[1]; // g_0'(x) * [1, 2, 3, 4] = 1 * x2 + 2 * x3 + 3 * x0 + 4 * x1 // g_0^2 (x) * [1, 2, 3, 4] = [3, 4, 1, 2] ok &= dw[0*2 + 1] == 3.; ok &= dw[1*2 + 1] == 4.; ok &= dw[2*2 + 1] == 1.; ok &= dw[3*2 + 1] == 2.; //---------------------------------------------------------------------- // Test forward and reverse Jacobian sparsity pattern /* [ x0 , x1 ] * [ x2 , 7 ] = [ x0*x2 + x1*x3 , x0*7 + x1*8 ] [ 5 , 6 ] [ x3 , 8 ] [ 5*x2 + 6*x3 , 5*7 + 6*8 ] so the sparsity pattern should be s[0] = {0, 1, 2, 3} s[1] = {0, 1} s[2] = {2, 3} s[3] = {} */ CppAD::vector< std::set > r( X.size() ), s(m); for(j = 0; j < X.size() ; j++) { assert( r[j].empty() ); r[j].insert(j); } s = G.ForSparseJac( X.size() , r); for(j = 0; j < X.size() ; j++) { // s[0] = {0, 1, 2, 3} ok &= s[0].find(j) != s[0].end(); // s[1] = {0, 1} if( j == 0 || j == 1 ) ok &= s[1].find(j) != s[1].end(); else ok &= s[1].find(j) == s[1].end(); // s[2] = {2, 3} if( j == 2 || j == 3 ) ok &= s[2].find(j) != s[2].end(); else ok &= s[2].find(j) == s[2].end(); } // s[3] == {} ok &= s[3].empty(); //---------------------------------------------------------------------- // Test reverse Jacobian sparsity pattern /* [ x0 , x1 ] * [ x2 , 7 ] = [ x0*x2 + x1*x3 , x0*7 + x1*8 ] [ 5 , 6 ] [ x3 , 8 ] [ 5*x2 + 6*x3 , 5*7 + 6*8 ] so the sparsity pattern should be r[0] = {0, 1, 2, 3} r[1] = {0, 1} r[2] = {2, 3} r[3] = {} */ for(i = 0; i < m; i++) { s[i].clear(); s[i].insert(i); } r = G.RevSparseJac(m, s); for(j = 0; j < X.size() ; j++) { // r[0] = {0, 1, 2, 3} ok &= r[0].find(j) != r[0].end(); // r[1] = {0, 1} if( j == 0 || j == 1 ) ok &= r[1].find(j) != r[1].end(); else ok &= r[1].find(j) == r[1].end(); // r[2] = {2, 3} if( j == 2 || j == 3 ) ok &= r[2].find(j) != r[2].end(); else ok &= r[2].find(j) == r[2].end(); } // r[3] == {} ok &= r[3].empty(); //---------------------------------------------------------------------- /* Test reverse Hessian sparsity pattern g_0^2 (x) = [ 0, 0, 1, 0 ] and for i > 0, g_i^2 = 0 [ 0, 0, 0, 1 ] [ 1, 0, 0, 0 ] [ 0, 1, 0, 0 ] so for the sparsity pattern for the first component of g is h[0] = {2} h[1] = {3} h[2] = {0} h[3] = {1} */ CppAD::vector< std::set > h( X.size() ), t(1); t[0].clear(); t[0].insert(0); h = G.RevSparseHes(X.size() , t); size_t check[] = {2, 3, 0, 1}; for(j = 0; j < X.size() ; j++) { // h[j] = { check[j] } for(i = 0; i < n; i++) { if( i == check[j] ) ok &= h[j].find(i) != h[j].end(); else ok &= h[j].find(i) == h[j].end(); } } t[0].clear(); for( j = 1; j < X.size(); j++) t[0].insert(j); h = G.RevSparseHes(X.size() , t); for(j = 0; j < X.size() ; j++) { // h[j] = { } for(i = 0; i < X.size(); i++) ok &= h[j].find(i) == h[j].end(); } // -------------------------------------------------------------------- // Free temporary work space. (If there are future calls to // old_mat_mul they would create new temporary work space.) CppAD::user_atomic::clear(); info_.clear(); return ok; } // END C++ cppad-20160000.1/test_more/cond_exp.cpp0000644000175200017650000002724212656321774016747 0ustar coincoin-web/* $Id: cond_exp.cpp 3666 2015-02-28 16:54:17Z 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. -------------------------------------------------------------------------- */ /* Comprehensive test built on 08/07 for new user interface to CondExp */ // BEGIN C++ # include namespace { // Begin empty namespace bool CondExp_pvvv(void) { bool ok = true; 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] ); return ok; } bool CondExp_vpvv(void) { bool ok = true; 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] ); return ok; } bool CondExp_vvpv(void) { bool ok = true; 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] ); return ok; } bool CondExp_vvvp(void) { bool ok = true; 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] ); 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); return ok; } double Infinity(double zero) { return 1. / zero; } bool OldExample(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; using CppAD::log; using CppAD::abs; 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 abs( 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( abs( 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./abs( x[j] ), eps, eps); else ok &= NearEqual(dw[j], -1./abs( x[j] ), eps, eps); } // a case where x[0] is equal to zero sign = 1.; for(j = 0; j < n; j++) { sign *= -1.; x[j] = sign * double(j); } // 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./abs( x[j] ), eps, eps); else if( x[j] < 0. ) ok &= NearEqual(dw[j], -1./abs( x[j] ), eps, eps); else ok &= NearEqual(dw[j], 0.0, eps, eps); } 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; } // END C++ cppad-20160000.1/test_more/zdouble.cpp0000644000175200017650000000556512656321774016620 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin zdouble.cpp$$ $spell zdouble $$ $section zdouble: Example and Test$$ $code $verbatim%test_more/zdouble.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { template bool test(bool is_double) { bool ok = true; Base eps = 10. * std::numeric_limits::epsilon(); typedef CppAD::AD a1type; typedef CppAD::AD a2type; // value during taping size_t n = 2; CPPAD_TESTVECTOR(Base) x(n); x[0] = 0.0; x[1] = 0.0; // declare independent variable CPPAD_TESTVECTOR(a2type) a2x(n); for (size_t j = 0; j < n; j++) a2x[j] = a2type( a1type(x[j]) ); Independent(a2x); // zero and one as a2type values a2type a2zero = a2type(0.0); a2type a2one = a2type(1.0); // h(x) = x[0] / x[1] if x[1] > x[0] else 1.0 a2type h_x = CondExpGt(a2x[1], a2x[0], a2x[0] / a2x[1], a2one); // f(x) = h(x) if x[0] > 0.0 else 0.0 // = x[0] / x[1] if x[1] > x[0] and x[0] > 0.0 // = 1.0 if x[0] >= x[1] and x[0] > 0.0 // = 0.0 if x[0] <= 0.0 a2type f_x = CondExpGt(a2x[0], a2zero, h_x, a2one); // define the function f(x) size_t m = 1; CPPAD_TESTVECTOR(a2type) a2y(m); a2y[0] = f_x; CppAD::ADFun af1; af1.Dependent(a2x, a2y); // Define function g(x) = gradient of f(x) CPPAD_TESTVECTOR(a1type) a1x(n), a1z(n), a1w(m); for (size_t j = 0; j < n; j++) a1x[j] = a1type(x[j]); a1w[0] = a1type(1.0); Independent(a1x); af1.Forward(0, a1x); a1z = af1.Reverse(1, a1w); CppAD::ADFun g; g.Dependent(a1x, a1z); // check result for a case where f(x) = 0.0; CPPAD_TESTVECTOR(Base) z(2); x[0] = 0.0; x[1] = 0.0; z = g.Forward(0, x); ok &= z[0] == 0.0; ok &= z[1] == 0.0; // check result for a case where f(x) = 1.0; x[0] = 1.0; x[1] = 0.5; z = g.Forward(0, x); ok &= z[0] == 0.0; ok &= z[1] == 0.0; // check result for a case where f(x) = x[0] / x[1]; x[0] = 1.0; x[1] = 2.0; z = g.Forward(0, x); ok &= CppAD::NearEqual(z[0], 1.0/x[1], eps, eps); ok &= CppAD::NearEqual(z[1], - x[0]/(x[1]*x[1]), eps, eps); return ok; } } bool zdouble(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; using CppAD::zdouble; // bool is_double = false; ok &= test(is_double); // is_double = true; ok &= test(is_double); // return ok; } // END C++ cppad-20160000.1/test_more/sinh.cpp0000644000175200017650000000364612656321774016113 0ustar coincoin-web// $Id: sinh.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old example now just used for validation testing. */ # include bool Sinh(void) { bool ok = true; using CppAD::sinh; using CppAD::cosh; using namespace CppAD; // 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]), 1e-10 , 1e-10); // 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 *= j; ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); 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(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); } return ok; } cppad-20160000.1/test_more/old_mat_mul.hpp0000644000175200017650000003056512656321774017453 0ustar coincoin-web// $Id$ # ifndef CPPAD_OLD_MAT_MUL_HPP # define CPPAD_OLD_MAT_MUL_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin old_mat_mul.hpp$$ $spell old_mat_mul.hpp cppad CppAD namespace struct nr nc bool vx const im mj ij px py std tx ty resize nz var jac Jacobian hes vy $$ $section Define Matrix Multiply as a User Atomic Operation$$ $mindex old_mat_mul old_atomic test$$ $head Syntax$$ This file is located in the $code example$$ directory. It can be copied to the current working directory and included with the syntax $codei% # include "old_mat_mul.hpp" %$$ $head Example$$ The file $cref old_mat_mul.cpp$$ contains an example use of $code old_mat_mul.hpp$$. It returns true if it succeeds and false otherwise. $head Begin Source$$ $codep */ # include // Include CppAD definitions namespace { // Begin empty namespace using CppAD::vector; // Let vector denote CppAD::vector /* $$ $head Extra Call Information$$ $codep */ // Information we will attach to each mat_mul call struct call_info { size_t nr_result; size_t n_middle; size_t nc_result; vector vx; }; vector info_; // vector of call information // number of orders for this operation (k + 1) size_t n_order_ = 0; // number of rows in the result matrix size_t nr_result_ = 0; // number of columns in left matrix and number of rows in right matrix size_t n_middle_ = 0; // number of columns in the result matrix size_t nc_result_ = 0; // which components of x are variables vector* vx_ = CPPAD_NULL; // get the information corresponding to this call void get_info(size_t id, size_t k, size_t n, size_t m) { n_order_ = k + 1; nr_result_ = info_[id].nr_result; n_middle_ = info_[id].n_middle; nc_result_ = info_[id].nc_result; vx_ = &(info_[id].vx); assert(n == nr_result_ * n_middle_ + n_middle_ * nc_result_); assert(m == nr_result_ * nc_result_); } /* $$ $head Matrix Indexing$$ $codep */ // Convert left matrix index pair and order to a single argument index size_t left(size_t i, size_t j, size_t ell) { assert( i < nr_result_ ); assert( j < n_middle_ ); return (i * n_middle_ + j) * n_order_ + ell; } // Convert right matrix index pair and order to a single argument index size_t right(size_t i, size_t j, size_t ell) { assert( i < n_middle_ ); assert( j < nc_result_ ); size_t offset = nr_result_ * n_middle_; return (offset + i * nc_result_ + j) * n_order_ + ell; } // Convert result matrix index pair and order to a single result index size_t result(size_t i, size_t j, size_t ell) { assert( i < nr_result_ ); assert( j < nc_result_ ); return (i * nc_result_ + j) * n_order_ + ell; } /* $$ $head One Matrix Multiply$$ Forward mode matrix multiply left times right and sum into result: $codep */ void multiply_and_sum( size_t order_left , size_t order_right, const vector& tx , vector& ty ) { size_t i, j; size_t order_result = order_left + order_right; for(i = 0; i < nr_result_; i++) { for(j = 0; j < nc_result_; j++) { double sum = 0.; size_t middle, im_left, mj_right, ij_result; for(middle = 0; middle < n_middle_; middle++) { im_left = left(i, middle, order_left); mj_right = right(middle, j, order_right); sum += tx[im_left] * tx[mj_right]; } ij_result = result(i, j, order_result); ty[ ij_result ] += sum; } } return; } /* $$ $head Reverse Partials One Order$$ Compute reverse mode partials for one order and sum into px: $codep */ void reverse_multiply( size_t order_left , size_t order_right, const vector& tx , const vector& ty , vector& px , const vector& py ) { size_t i, j; size_t order_result = order_left + order_right; for(i = 0; i < nr_result_; i++) { for(j = 0; j < nc_result_; j++) { size_t middle, im_left, mj_right, ij_result; for(middle = 0; middle < n_middle_; middle++) { ij_result = result(i, j, order_result); im_left = left(i, middle, order_left); mj_right = right(middle, j, order_right); // sum += tx[im_left] * tx[mj_right]; px[im_left] += tx[mj_right] * py[ij_result]; px[mj_right] += tx[im_left] * py[ij_result]; } } } return; } /* $$ $head Set Union$$ $codep */ void my_union( std::set& result , const std::set& left , const std::set& right ) { std::set temp; std::set_union( left.begin() , left.end() , right.begin() , right.end() , std::inserter(temp, temp.begin()) ); result.swap(temp); } /* $$ $head CppAD User Atomic Callback Functions$$ $codep */ // ---------------------------------------------------------------------- // forward mode routine called by CppAD bool mat_mul_forward( size_t id , size_t k , size_t n , size_t m , const vector& vx , vector& vy , const vector& tx , vector& ty ) { size_t i, j, ell; get_info(id, k, n, m); // check if this is during the call to mat_mul(id, ax, ay) if( vx.size() > 0 ) { assert( k == 0 && vx.size() > 0 ); // store the vx information in info_ assert( vx_->size() == 0 ); info_[id].vx.resize(n); for(j = 0; j < n; j++) info_[id].vx[j] = vx[j]; assert( vx_->size() == n ); // now compute vy for(i = 0; i < nr_result_; i++) { for(j = 0; j < nc_result_; j++) { // compute vy[ result(i, j, 0) ] bool var = false; bool nz_left, nz_right; size_t middle, im_left, mj_right, ij_result; for(middle = 0; middle < n_middle_; middle++) { im_left = left(i, middle, k); mj_right = right(middle, j, k); nz_left = vx[im_left] | (tx[im_left] != 0.); nz_right = vx[mj_right] | (tx[mj_right]!= 0.); // if not multiplying by the constant zero if( nz_left & nz_right ) var |= (vx[im_left] | vx[mj_right]); } ij_result = result(i, j, k); vy[ij_result] = var; } } } // initialize result as zero for(i = 0; i < nr_result_; i++) { for(j = 0; j < nc_result_; j++) ty[ result(i, j, k) ] = 0.; } // sum the product of proper orders for(ell = 0; ell <=k; ell++) multiply_and_sum(ell, k-ell, tx, ty); // All orders are implemented and there are no possible error // conditions, so always return true. return true; } // ---------------------------------------------------------------------- // reverse mode routine called by CppAD bool mat_mul_reverse( size_t id , size_t k , size_t n , size_t m , const vector& tx , const vector& ty , vector& px , const vector& py ) { get_info(id, k, n, m); size_t ell = n * n_order_; while(ell--) px[ell] = 0.; size_t order = n_order_; while(order--) { // reverse sum the products for specified order for(ell = 0; ell <=order; ell++) reverse_multiply(ell, order-ell, tx, ty, px, py); } // All orders are implemented and there are no possible error // conditions, so always return true. return true; } // ---------------------------------------------------------------------- // forward Jacobian sparsity routine called by CppAD bool mat_mul_for_jac_sparse( size_t id , size_t n , size_t m , size_t p , const vector< std::set >& r , vector< std::set >& s ) { size_t i, j, k, im_left, middle, mj_right, ij_result; k = 0; get_info(id, k, n, m); for(i = 0; i < nr_result_; i++) { for(j = 0; j < nc_result_; j++) { ij_result = result(i, j, k); s[ij_result].clear(); for(middle = 0; middle < n_middle_; middle++) { im_left = left(i, middle, k); mj_right = right(middle, j, k); // s[ij_result] = union( s[ij_result], r[im_left] ) my_union(s[ij_result], s[ij_result], r[im_left]); // s[ij_result] = union( s[ij_result], r[mj_right] ) my_union(s[ij_result], s[ij_result], r[mj_right]); } } } return true; } // ---------------------------------------------------------------------- // reverse Jacobian sparsity routine called by CppAD bool mat_mul_rev_jac_sparse( size_t id , size_t n , size_t m , size_t p , vector< std::set >& r , const vector< std::set >& s ) { size_t i, j, k, im_left, middle, mj_right, ij_result; k = 0; get_info(id, k, n, m); for(j = 0; j < n; j++) r[j].clear(); for(i = 0; i < nr_result_; i++) { for(j = 0; j < nc_result_; j++) { ij_result = result(i, j, k); for(middle = 0; middle < n_middle_; middle++) { im_left = left(i, middle, k); mj_right = right(middle, j, k); // r[im_left] = union( r[im_left], s[ij_result] ) my_union(r[im_left], r[im_left], s[ij_result]); // r[mj_right] = union( r[mj_right], s[ij_result] ) my_union(r[mj_right], r[mj_right], s[ij_result]); } } } return true; } // ---------------------------------------------------------------------- // reverse Hessian sparsity routine called by CppAD bool mat_mul_rev_hes_sparse( size_t id , size_t n , size_t m , size_t p , const vector< std::set >& r , const vector& s , vector& t , const vector< std::set >& u , vector< std::set >& v ) { size_t i, j, k, im_left, middle, mj_right, ij_result; k = 0; get_info(id, k, n, m); for(j = 0; j < n; j++) { t[j] = false; v[j].clear(); } assert( vx_->size() == n ); for(i = 0; i < nr_result_; i++) { for(j = 0; j < nc_result_; j++) { ij_result = result(i, j, k); for(middle = 0; middle < n_middle_; middle++) { im_left = left(i, middle, k); mj_right = right(middle, j, k); // back propagate Jacobian sparsity t[im_left] = (t[im_left] | s[ij_result]); t[mj_right] = (t[mj_right] | s[ij_result]); // Visual Studio C++ 2008 warns unsafe mix of int and // bool if we use the following code directly above: // t[im_left] |= s[ij_result]; // t[mj_right] |= s[ij_result]; // back propagate Hessian sparsity // v[im_left] = union( v[im_left], u[ij_result] ) // v[mj_right] = union( v[mj_right], u[ij_result] ) my_union(v[im_left], v[im_left], u[ij_result] ); my_union(v[mj_right], v[mj_right], u[ij_result] ); // Check for case where the (i,j) result element // is in reverse Jacobian and both left and right // operands in multiplication are variables if(s[ij_result] & (*vx_)[im_left] & (*vx_)[mj_right]) { // v[im_left] = union( v[im_left], r[mj_right] ) my_union(v[im_left], v[im_left], r[mj_right] ); // v[mj_right] = union( v[mj_right], r[im_left] ) my_union(v[mj_right], v[mj_right], r[im_left] ); } } } } return true; } /* $$ $head Declare mat_mul Function$$ Declare the $code AD$$ routine $codei%mat_mul(%id%, %ax%, %ay%)%$$ and end empty namespace (we could use any $cref/simple vector template class/SimpleVector/$$ instead of $code CppAD::vector$$): $codep */ CPPAD_USER_ATOMIC( mat_mul , CppAD::vector , double , mat_mul_forward , mat_mul_reverse , mat_mul_for_jac_sparse , mat_mul_rev_jac_sparse , mat_mul_rev_hes_sparse ) } // End empty namespace /* $$ $end */ # endif cppad-20160000.1/test_more/romberg_one.cpp0000644000175200017650000000445212656321774017444 0ustar coincoin-web/* $Id: romberg_one.cpp 3747 2015-11-09 14:25:41Z 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. -------------------------------------------------------------------------- */ /* old romberg_one.cpp example / test $spell Romberg $$ $section One Dimensional Romberg Integration: Example and Test$$ $index Romberg, example$$ $index example, Romberg$$ $index test, Romberg$$ $code old verbatim%example/romberg_one.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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 < (degree+1) * spow; ok &= CppAD::NearEqual(check, r, Float(0.), e); } return ok; } } bool RombergOne(void) { bool ok = true; using CppAD::AD; ok &= RombergOneCase(); ok &= RombergOneCase< AD >(); ok &= RombergOneCase< AD< AD > >(); return ok; } // END C++ cppad-20160000.1/test_more/print_for.cpp0000644000175200017650000000524012656321774017144 0ustar coincoin-web// $Id: print_for.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // modified version of test that used to be in ../print_for/print_for.cpp # include namespace { 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. ); // check 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; // 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; } cppad-20160000.1/test_more/mul_zero_one.cpp0000644000175200017650000000357412656321774017647 0ustar coincoin-web// $Id: mul_zero_one.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test the use of the special parameters zero and one with the multiply operator */ # include typedef CppAD::AD ADdouble; typedef CppAD::AD< ADdouble > ADDdouble; bool MulZeroOne(void) { using namespace CppAD; 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]); } } return ok; } cppad-20160000.1/test_more/extern_value.hpp0000644000175200017650000000146512656321774017655 0ustar coincoin-web// $Id: extern_value.hpp 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. -------------------------------------------------------------------------- */ # ifndef CPPAD_EXTERN_VALUE_HPP # define CPPAD_EXTERN_VALUE_HPP template class extern_value { private: Type value_; public: extern_value(Type value); void set(Type value); Type get(void); }; # endif cppad-20160000.1/test_more/test_vector.cpp0000644000175200017650000000420412656321774017502 0ustar coincoin-web// $Id: test_vector.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test deprecated CPPAD_TEST_VECTOR macro (should use CPPAD_TESTVECTOR instead */ # include // 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; // 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, 1e-10 , 1e-10); // 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., 1e-10, 1e-10); // 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., 1e-10, 1e-10); // 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; } cppad-20160000.1/test_more/value.cpp0000644000175200017650000000303712656321774016260 0ustar coincoin-web// $Id: value.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old Value example now used just for valiadation testing */ // BEGIN C++ # include bool Value(void) { bool ok = true; 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); // cannot call Value after Independent (tape is recording) // dependent variable vector and indices CPPAD_TESTVECTOR(AD) Z(1); size_t x = 0; // 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() ); // 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 x double xValue = Value(Z[x]); ok &= ( xValue == -4. ); return ok; } // END C++ cppad-20160000.1/test_more/test_more.cpp0000644000175200017650000002334212656321774017146 0ustar coincoin-web// $Id: test_more.cpp 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. -------------------------------------------------------------------------- */ // system include files used for I/O # include // memory leak checker # include // prototype external compiled tests (this line expected by bin/new_test.sh) extern bool abs(void); extern bool acos(void); extern bool acosh(void); extern bool adfun_copy(void); extern bool Add(void); extern bool AddEq(void); extern bool AddZero(void); extern bool alloc_openmp(void); extern bool asin(void); extern bool asinh(void); extern bool assign(void); extern bool atan(void); extern bool atanh(void); extern bool atan2(void); extern bool azmul(void); extern bool base_adolc(void); extern bool base_alloc_test(void); extern bool check_simple_vector(void); extern bool checkpoint(void); extern bool Compare(void); extern bool compare_change(void); extern bool CondExp(void); extern bool CondExpAD(void); extern bool cond_exp_rev(void); extern bool copy(void); extern bool Cos(void); extern bool Cosh(void); extern bool cppad_eigen(void); extern bool dbl_epsilon(void); extern bool Div(void); extern bool DivEq(void); extern bool DivZeroOne(void); extern bool erf(void); extern bool Exp(void); extern bool expm1(void); extern bool ForHess(void); extern bool for_sparse_jac(void); extern bool Forward(void); extern bool forward_dir(void); extern bool forward_order(void); extern bool FromBase(void); extern bool FunCheck(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 mul_cond_rev(void); extern bool mul_cskip(void); extern bool MulEq(void); extern bool mul_zdouble(void); extern bool MulZeroOne(void); extern bool NearEqualExt(void); extern bool Neg(void); extern bool num_limits(void); extern bool ode_err_control(void); extern bool old_mat_mul(void); extern bool old_reciprocal(void); extern bool old_tan(void); extern bool old_usead_1(void); extern bool old_usead_2(void); extern bool omp_alloc(void); extern bool optimize(void); extern bool parameter(void); extern bool Poly(void); extern bool Pow(void); extern bool PowInt(void); extern bool print_for(void); extern bool reverse(void); extern bool rev_sparse_hes(void); extern bool rev_sparse_jac(void); extern bool RevTwo(void); extern bool RombergOne(void); 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 sparse_hessian(void); extern bool sparse_jacobian(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 SubZero(void); extern bool tan(void); extern bool to_string(void); extern bool test_vector(void); extern bool track_new_del(void); extern bool Value(void); extern bool VecAD(void); extern bool VecADPar(void); extern bool VecUnary(void); extern bool zdouble(void); namespace { // function that runs one test static size_t Run_ok_count = 0; static size_t Run_error_count = 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; // ok &= name.size() < size_t(width); ok &= TestOk(); if( ok ) { std::cout << "OK" << std::endl; Run_ok_count++; } 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 namespace std; // This line is used by test_one.sh // run external compiled tests (this line expected by bin/new_test.sh) ok &= Run( abs, "abs" ); ok &= Run( acos, "acos" ); ok &= Run( acosh, "acosh" ); ok &= Run( adfun_copy, "adfun_copy" ); ok &= Run( Add, "Add" ); ok &= Run( AddEq, "AddEq" ); ok &= Run( AddZero, "AddZero" ); ok &= Run( asin, "asin" ); ok &= Run( asinh, "asinh" ); ok &= Run( assign, "assign" ); ok &= Run( atan, "atan" ); ok &= Run( atanh, "atanh" ); ok &= Run( atan2, "atan2" ); ok &= Run( azmul, "azmul" ); ok &= Run( check_simple_vector, "check_simple_vector" ); ok &= Run( checkpoint, "checkpoint" ); ok &= Run( Compare, "Compare" ); ok &= Run( compare_change, "compare_change" ); ok &= Run( CondExp, "CondExp" ); ok &= Run( CondExpAD, "CondExpAD" ); ok &= Run( cond_exp_rev, "cond_exp_rev" ); ok &= Run( copy, "copy" ); ok &= Run( Cos, "Cos" ); ok &= Run( Cosh, "Cosh" ); ok &= Run( dbl_epsilon, "dbl_epsilon" ); ok &= Run( Div, "Div" ); ok &= Run( DivEq, "DivEq" ); ok &= Run( DivZeroOne, "DivZeroOne" ); ok &= Run( erf, "erf" ); ok &= Run( Exp, "Exp" ); ok &= Run( expm1, "expm1" ); ok &= Run( ForHess, "ForHess" ); ok &= Run( for_sparse_jac, "for_sparse_jac" ); ok &= Run( Forward, "Forward" ); ok &= Run( forward_dir, "forward_dir" ); ok &= Run( forward_order, "forward_order" ); ok &= Run( FromBase, "FromBase" ); ok &= Run( FunCheck, "FunCheck" ); ok &= Run( jacobian, "jacobian" ); ok &= Run( log, "log" ); ok &= Run( log10, "log10" ); ok &= Run( log1p, "log1p" ); ok &= Run( Mul, "Mul" ); ok &= Run( mul_level, "mul_level" ); ok &= Run( mul_cond_rev, "mul_cond_rev" ); ok &= Run( mul_cskip, "Mul_cskip" ); ok &= Run( MulEq, "MulEq" ); ok &= Run( mul_zdouble, "mul_zdouble" ); ok &= Run( MulZeroOne, "MulZeroOne" ); ok &= Run( NearEqualExt, "NearEqualExt" ); ok &= Run( Neg, "Neg" ); ok &= Run( num_limits, "num_limits" ); ok &= Run( ode_err_control, "ode_err_control"); ok &= Run( old_mat_mul, "old_mat_mul" ); ok &= Run( old_reciprocal, "old_reciprocal" ); ok &= Run( old_tan, "old_tan" ); ok &= Run( old_usead_1, "old_usead_1" ); ok &= Run( old_usead_2, "old_usead_2" ); ok &= Run( omp_alloc, "omp_alloc" ); ok &= Run( optimize, "optimize" ); ok &= Run( parameter, "parameter" ); ok &= Run( Poly, "Poly" ); ok &= Run( Pow, "Pow" ); ok &= Run( PowInt, "PowInt" ); ok &= Run( print_for, "print_for" ); ok &= Run( reverse, "reverse" ); ok &= Run( rev_sparse_hes, "rev_sparse_hes" ); ok &= Run( rev_sparse_jac, "rev_sparse_jac" ); ok &= Run( RevTwo, "RevTwo" ); ok &= Run( RombergOne, "RombergOne" ); ok &= Run( Rosen34, "Rosen34" ); ok &= Run( Runge45, "Runge45" ); ok &= Run( SimpleVector, "SimpleVector" ); ok &= Run( Sin, "Sin" ); ok &= Run( SinCos, "SinCos" ); ok &= Run( Sinh, "Sinh" ); ok &= Run( sparse_hessian, "sparse_hessian" ); ok &= Run( sparse_jacobian, "sparse_jacobian"); ok &= Run( sparse_vec_ad, "sparse_vec_ad" ); ok &= Run( Sqrt, "Sqrt" ); ok &= Run( std_math, "std_math" ); ok &= Run( Sub, "Sub" ); ok &= Run( SubEq, "SubEq" ); ok &= Run( SubZero, "SubZero" ); ok &= Run( tan, "tan" ); ok &= Run( to_string, "to_string" ); ok &= Run( track_new_del, "track_new_del" ); ok &= Run( Value, "Value" ); ok &= Run( VecAD, "VecAD" ); ok &= Run( VecADPar, "VecADPar" ); ok &= Run( VecUnary, "VecUnary" ); ok &= Run( zdouble, "zdouble" ); # ifdef CPPAD_ADOLC_TEST ok &= Run( base_adolc, "base_adolc" ); # endif # ifdef CPPAD_IPOPT_TEST ok &= Run( ipopt_solve, "ipopt_solve" ); # endif # ifdef CPPAD_OPENMP_TEST ok &= Run( alloc_openmp, "alloc_openmp" ); # endif # ifdef CPPAD_EIGEN_TEST ok &= Run( cppad_eigen, "cppad_eigen" ); # endif # if ! CPPAD_EIGENVECTOR ok &= Run( test_vector, "test_vector" ); # endif // check for errors using std::cout; using std::endl; assert( ok || (Run_error_count > 0) ); if( CppAD::thread_alloc::free_all() ) { Run_ok_count++; cout << "OK: " << "No memory leak detected" << endl; } else { ok = false; Run_error_count++; cout << "Error: " << "memory leak detected" << endl; } // Run base_require after memory leak check because base_alloc.hpp uses // thread_alloc to allocate memory for static copies of nan. ok &= Run( base_alloc_test, "base_alloc" ); // convert int(size_t) to avoid warning on _MSC_VER systems if( ok ) cout << "All " << int(Run_ok_count) << " tests passed." << endl; else cout << int(Run_error_count) << " tests failed." << endl; return static_cast( ! ok ); } // END PROGRAM cppad-20160000.1/test_more/test_one.sh.in0000755000175200017650000000466712656321774017236 0ustar coincoin-web#! /bin/bash -e # $Id: test_one.sh.in 3754 2015-11-26 22:23:05Z 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. # ----------------------------------------------------------------------------- # # Run one of the tests if [ "$1" = "" ] then echo "usage: test_one.sh file [extra]" echo "file is the *.cpp file name with extension" echo "and extra is extra options for g++ command" exit 1 fi if [ ! -e "$1" ] then echo "Cannot find the file $1" exit 1 fi fun=`grep "^bool *[a-zA-Z0-9_]* *( *void *)" $1 | tail -1 | \ sed -e "s/^bool *\([a-zA-Z0-9_]*\) *( *void *)/\1/"` if [ -e test_one.exe ] then rm test_one.exe fi sed < test_more.cpp > test_one.cpp \ -e '/ok *\&= *Run( /d' \ -e "s/.*This line is used by test_one.sh.*/ ok \&= Run( $fun, \"$fun\");/" # # cxxflags='@cppad_cxx_flags@' if echo "$fun" | grep 'eigen' > /dev/null then cxxflags=`echo "$cxxflags" | sed -e 's|-Wshadow||'` fi cmd="g++ test_one.cpp $*" cmd="$cmd -o test_one.exe $cxxflags -L @cppad_BINARY_DIR@/cppad_lib -lcppad_lib -g -fopenmp -DCPPAD_ADOLC_TEST -DCPPAD_OPENMP_TEST -I.. " if [ -e @adolc_prefix@/include ] then cmd="$cmd -I@adolc_prefix@/include" fi if [ -e @colpack_prefix@/include ] then cmd="$cmd -I@colpack_prefix@/include" fi if [ -e @eigen_prefix@/include ] then cmd="$cmd -I@eigen_prefix@/include" fi for lib in lib lib64 do if [ -e @adolc_prefix@/$lib ] then cmd="$cmd -L@adolc_prefix@/$lib -ladolc -lColPack" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@adolc_prefix@/$lib" fi if [ -e @colpack_prefix@/$lib ] then cmd="$cmd -L@colpack_prefix@/$lib -lColPack" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@colpack_prefix@/$lib" fi if [ -e @ipopt_prefix@/$lib/pkgconfig ] then export PKG_CONFIG_PATH="@ipopt_prefix@/$lib/pkgconfig" cflags=`pkg-config --cflags ipopt | sed -e 's|/coin$|/|' -e 's|/coin | |'` libs=`pkg-config --libs ipopt` cmd="$cmd $cflags $libs" fi done export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@cppad_BINARY_DIR@/cppad_lib" echo $cmd $cmd echo "./test_one.exe" if ! ./test_one.exe then exit 1 fi exit 0 cppad-20160000.1/test_more/extern_value.cpp0000644000175200017650000000236012656321774017643 0ustar coincoin-web// $Id: extern_value.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include "extern_value.hpp" # define INSTANTIATE(Type) template class extern_value< Type > template extern_value::extern_value(Type value) { value_ = value; } template void extern_value::set(Type value) { value_ = value; } template Type extern_value::get(void) { return value_; } INSTANTIATE( float ); INSTANTIATE( double ); INSTANTIATE( std::complex ); INSTANTIATE( std::complex ); // INSTANTIATE( CppAD::AD< float > ); INSTANTIATE( CppAD::AD< double > ); INSTANTIATE( CppAD::AD< std::complex > ); INSTANTIATE( CppAD::AD< std::complex > ); cppad-20160000.1/test_more/add_eq.cpp0000644000175200017650000000652412656321774016365 0ustar coincoin-web// $Id: add_eq.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Two old example now used just for valiadation testing */ # include namespace { // BEGIN empty namespace bool AddEqOne(void) { bool ok = true; 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. ); return ok; } bool AddEqTwo(void) { bool ok = true; using namespace CppAD; // 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, 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = 2.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } } // END empty namespace bool AddEq(void) { bool ok = true; ok &= AddEqOne(); ok &= AddEqTwo(); return ok; } // END PROGRAM cppad-20160000.1/test_more/forward_dir.cpp0000644000175200017650000012652112656321774017452 0ustar coincoin-web/* $Id: forward_dir.cpp 3683 2015-05-10 02:24:16Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // test multiple directions operators // MulvvOp is tested by example/forward_dir.cpp # include # include # 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] = abs( ax[0] ) + abs( 2.0 * ax[1] ); // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); // first order Taylor coefficients size_t r = 2, ell; CPPAD_TESTVECTOR(double) x1(r*n), y1; 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)] // = abs(0.5 + 1t + 2t^2) + abs( 2*(-1.0 + 2t + 3t^2 ) ) double y_1_0 = -3.0; double y_2_0 = -4.0; // // Y_1 (t) = F[X_1(t)] // = abs(0.5 + 2t + 3t^2) + abs( 2*(-1.0 + 3t + 4t^2 ) ) double y_1_1 = -4.0; double y_2_1 = -5.0; // 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], CppAD::abs(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; } cppad-20160000.1/test_more/for_sparse_jac.cpp0000644000175200017650000002672612656321774020136 0ustar coincoin-web// $Id: for_sparse_jac.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include # 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++; # 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++; # 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++; namespace { // Begin empty namespace bool case_one() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 3; // 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]); } } return ok; } bool case_two() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 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]); } } return ok; } bool case_three() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 2; // 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]); } } return ok; } bool case_four() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 2; // 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]); } } return ok; } } // End empty namespace bool for_sparse_jac(void) { bool ok = true; ok &= case_one(); ok &= case_two(); ok &= case_three(); ok &= case_four(); return ok; } cppad-20160000.1/test_more/cond_exp_ad.cpp0000644000175200017650000001661512656321774017415 0ustar coincoin-web// $Id: cond_exp_ad.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test of CondExp with AD< AD< Base > > types */ # include typedef CppAD::AD< double > ADdouble; typedef CppAD::AD< ADdouble > ADADdouble; namespace { // BEGIN empty namespace bool CondExpADOne(void) { 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 ) ); } return ok; } bool CondExpADTwo(void) { 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) ); } return ok; } } // END empty namespace bool CondExpAD(void) { bool ok = true; ok &= CondExpADOne(); ok &= CondExpADTwo(); return ok; } cppad-20160000.1/test_more/log.cpp0000644000175200017650000000700112656321774015720 0ustar coincoin-web/* $Id: log.cpp 3684 2015-05-10 14:01:21Z 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. -------------------------------------------------------------------------- */ /* Two old log examples now used just for validation testing */ # include namespace { // BEGIN empty namespace bool LogTestOne(void) { bool ok = true; using CppAD::log; using namespace CppAD; // 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.), 1e-10 , 1e-10); ok &= NearEqual(Z[y] , log( log(2.) ), 1e-10 , 1e-10); // forward computation of partials w.r.t. s v[s] = 1.; w = f.Forward(1, v); ok &= NearEqual(w[x], 1. / U[s], 1e-10 , 1e-10); // dx/ds ok &= NearEqual(w[y], 1. / (U[s] * Z[x]), 1e-10 , 1e-10); // 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]), 1e-10 , 1e-10); // 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]), 1e-10 , 1e-10 ); // 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]), 1e-10 , 1e-10 ); return ok; } bool LogTestTwo(void) { bool ok = true; using CppAD::log; using namespace CppAD; // 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], 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = 1.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } } // END empty namespace bool log(void) { bool ok = true; ok &= LogTestOne(); ok &= LogTestTwo(); return ok; } cppad-20160000.1/test_more/std_math.cpp0000644000175200017650000000331012656321774016741 0ustar coincoin-web// $Id: std_math.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test the using standard math functions with AD< AD > */ # include typedef CppAD::AD ADdouble; 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) ); ADDdouble y( acos(one / root_2) ); ok &= NearEqual( pi_4, y, small, small ); y = cos(pi_4); ok &= NearEqual( one / root_2, y, small, small ); y = asin(one / root_2); ok &= NearEqual( pi_4, y, small, small ); y = sin(pi_4); ok &= NearEqual( one / root_2, y, small, small ); y = atan(one); ok &= NearEqual( pi_4, y, small, small ); y = tan(pi_4); ok &= NearEqual( one, y, small, small ); y = two * cosh(one); ok &= NearEqual( exp(one) + exp(-one), y, small, small ); y = two * sinh(one); ok &= NearEqual( exp(one) - exp(-one), y, small, small ); y = log( exp(one) ); ok &= NearEqual( one, y, small, small ); y = log10( exp( log(ten) ) ); ok &= NearEqual( one, y, small, small ); return ok; } cppad-20160000.1/test_more/div_zero_one.cpp0000644000175200017650000000436212656321774017630 0ustar coincoin-web// $Id: div_zero_one.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test the use of the special parameters zero and one with the multiply operator */ # include typedef CppAD::AD ADdouble; typedef CppAD::AD< ADdouble > ADDdouble; bool DivZeroOne(void) { using namespace CppAD; 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); 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, 1e-10, 1e-10 ); check = 1. / double(i * i); if( i != 0 ) ok &= NearEqual( v[1], check, 1e-10, 1e-10); // 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), 1e-10, 1e-10 ); if( i != 0 ) ok &= NearEqual( b[1], -2./double(i*i*i), 1e-10, 1e-10); } } return ok; } cppad-20160000.1/test_more/to_string.cpp0000644000175200017650000000276312656321774017161 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // check complex case # include namespace { template bool test(void) { bool ok = true; Float eps = std::numeric_limits::epsilon(); Float pi = 4.0 * std::atan(1.0); Float e = std::exp(1.0); typedef std::complex Base; Base c = Base(pi, e); std::string s = CppAD::to_string( CppAD::AD(c) ); // // get strings corresponding to real and imaginary parts std::string real = ""; std::string imag = ""; size_t index = 1; // skip ( at front while( s[index] != ',' ) real += s[index++]; index++; while( s[index] != ')' ) imag += s[index++]; // Float check = std::atof( real.c_str() ); ok &= std::fabs( check - pi ) <= 2.0 * eps; // check = std::atof( imag.c_str() ); ok &= std::fabs( check - e ) <= 2.0 * eps; // return ok; } } bool to_string(void) { bool ok = true; ok &= test(); ok &= test(); return ok; } // END C++ cppad-20160000.1/test_more/log10.cpp0000644000175200017650000000342312656321774016065 0ustar coincoin-web/* $Id: log10.cpp 3684 2015-05-10 14:01:21Z 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. -------------------------------------------------------------------------- */ /* Old example now used just for validation testing. */ # include bool log10(void) { bool ok = true; using CppAD::log10; using CppAD::log; using namespace CppAD; // 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., 1e-10 , 1e-10); ok &= NearEqual(Z[y] , 0., 1e-10 , 1e-10); // 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) , 1e-10 , 1e-10); // dx/ds ok &= NearEqual(w[y], 1./(U[s]*Z[x]*l10*l10), 1e-10 , 1e-10); // 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), 1e-10 , 1e-10); // dy/ds return ok; } cppad-20160000.1/test_more/omp_alloc.cpp0000644000175200017650000001263212656321774017112 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin omp_alloc.cpp$$ $spell openmp $$ $section OpenMP Memory Allocator: Example and Test$$ $mindex allocation multi thread$$ $head Deprecated 2011-08-31$$ This example is only intended to help convert calls to $cref omp_alloc$$ to calls to $cref thread_alloc$$. $code $verbatim%test_more/omp_alloc.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include # include # include namespace { // Begin empty namespace bool omp_alloc_bytes(void) { bool ok = true; using CppAD::omp_alloc; size_t thread; // check initial memory values ok &= ! CppAD::memory_leak(); // amount of static memory used by thread zero size_t static_inuse = omp_alloc::inuse(0); // determine the currently executing thread // (should be zero because not in parallel mode) thread = omp_alloc::get_thread_num(); // repeatedly allocate enough memory for at least two size_t values. size_t min_size_t = 2; size_t min_bytes = min_size_t * sizeof(size_t); size_t n_outter = 10; size_t n_inner = 5; size_t cap_bytes(0), i, j, k; for(i = 0; i < n_outter; i++) { // Do not use CppAD::vector here because its use of omp_alloc // complicates the inuse and avaialble results. std::vector v_ptr(n_inner); for( j = 0; j < n_inner; j++) { // allocate enough memory for min_size_t size_t objects v_ptr[j] = omp_alloc::get_memory(min_bytes, cap_bytes); size_t* ptr = reinterpret_cast(v_ptr[j]); // determine the number of size_t values we have obtained size_t cap_size_t = cap_bytes / sizeof(size_t); ok &= min_size_t <= cap_size_t; // use placement new to call the size_t copy constructor for(k = 0; k < cap_size_t; k++) new(ptr + k) size_t(i + j + k); // check that the constructor worked for(k = 0; k < cap_size_t; k++) ok &= ptr[k] == (i + j + k); } // check that n_inner * cap_bytes are inuse and none are available ok &= omp_alloc::inuse(thread) == n_inner*cap_bytes + static_inuse; ok &= omp_alloc::available(thread) == 0; // return the memrory to omp_alloc for(j = 0; j < n_inner; j++) omp_alloc::return_memory(v_ptr[j]); // check that now n_inner * cap_bytes are now available // and none are in use ok &= omp_alloc::inuse(thread) == static_inuse; ok &= omp_alloc::available(thread) == n_inner * cap_bytes; } // return all the available memory to the system omp_alloc::free_available(thread); ok &= ! CppAD::memory_leak(); return ok; } class my_char { public: char ch_ ; my_char(void) : ch_(' ') { } my_char(const my_char& my_ch) : ch_(my_ch.ch_) { } }; bool omp_alloc_array(void) { bool ok = true; using CppAD::omp_alloc; size_t i; // check initial memory values size_t thread = omp_alloc::get_thread_num(); ok &= thread == 0; ok &= ! CppAD::memory_leak(); size_t static_inuse = omp_alloc::inuse(0); // initial allocation of an array size_t size_min = 3; size_t size_one; my_char *array_one = omp_alloc::create_array(size_min, size_one); // check the values and change them to null 'x' for(i = 0; i < size_one; i++) { ok &= array_one[i].ch_ == ' '; array_one[i].ch_ = 'x'; } // now create a longer array size_t size_two; my_char *array_two = omp_alloc::create_array(2 * size_min, size_two); // check the values in array one for(i = 0; i < size_one; i++) ok &= array_one[i].ch_ == 'x'; // check the values in array two for(i = 0; i < size_two; i++) ok &= array_two[i].ch_ == ' '; // check the amount of inuse and available memory // (an extra size_t value is used for each memory block). size_t check = static_inuse + sizeof(my_char)*(size_one + size_two); ok &= omp_alloc::inuse(thread) - check < sizeof(my_char); ok &= omp_alloc::available(thread) == 0; // delete the arrays omp_alloc::delete_array(array_one); omp_alloc::delete_array(array_two); ok &= omp_alloc::inuse(thread) == static_inuse; check = sizeof(my_char)*(size_one + size_two); ok &= omp_alloc::available(thread) - check < sizeof(my_char); // free the memory for use by this thread omp_alloc::free_available(thread); ok &= ! CppAD::memory_leak(); return ok; } } // End empty namespace bool omp_alloc(void) { bool ok = true; using CppAD::omp_alloc; // check initial state of allocator ok &= omp_alloc::get_max_num_threads() == 1; // set the maximum number of threads greater than one // so that omp_alloc holds onto memory CppAD::omp_alloc::set_max_num_threads(2); ok &= omp_alloc::get_max_num_threads() == 2; ok &= ! CppAD::memory_leak(); // now use memory allocator in state where it holds onto memory ok &= omp_alloc_bytes(); ok &= omp_alloc_array(); // check that the tests have not held onto memory ok &= ! CppAD::memory_leak(); // set the maximum number of threads back to one // so that omp_alloc no longer holds onto memory CppAD::omp_alloc::set_max_num_threads(1); return ok; } // END C++ cppad-20160000.1/test_more/base_alloc.cpp0000644000175200017650000000211612656321774017225 0ustar coincoin-web// $Id: base_alloc.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 "../example/base_alloc.hpp" # include bool base_alloc_test(void) { bool ok = true; using CppAD::thread_alloc; typedef CppAD::AD my_ad; // y = x^2 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); return ok; } cppad-20160000.1/test_more/div_eq.cpp0000644000175200017650000000766112656321774016422 0ustar coincoin-web// $Id: div_eq.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. -------------------------------------------------------------------------- */ /* Old DivEq example now used just for valiadation testing */ # include namespace { // BEGIN empty namespace bool DivEqTestOne(void) { bool ok = true; 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 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. , 1e-10, 1e-10); ok &= NearEqual(Z[y] , 2. / 5. , 1e-10, 1e-10); // 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]) , 1e-10, 1e-10); // dx/dt ok &= NearEqual(w[y] , 1. / 5. , 1e-10, 1e-10); // 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]) , 1e-10 , 1e-10 ); ok &= NearEqual(r[2 * t + 1] // d^2 x / (dt dt) , 2. * U[s] / (U[t] * U[t] * U[t]) , 1e-10 , 1e-10 ); return ok; } bool DivEqTestTwo(void) { bool ok = true; using namespace CppAD; // 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), 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = 1./8.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } } // END empty namespace bool DivEq(void) { bool ok = true; ok &= DivEqTestOne(); ok &= DivEqTestTwo(); return ok; } cppad-20160000.1/test_more/assign.cpp0000644000175200017650000000467312656321774016437 0ustar coincoin-web// $Id: assign.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old example, now used just for validation testing */ # include bool assign(void) { 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.); return ok; } cppad-20160000.1/test_more/atan2.cpp0000644000175200017650000000520512656321774016150 0ustar coincoin-web// $Id: atan2.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old example and test now just used for validation testing. */ # include # include namespace { // begin empty namespace bool ad_ad(void) { bool ok = true; using CppAD::AD; AD< AD > x(2.), y(2.); AD< AD > z = atan2(y, x); CppAD::NearEqual( Value( Value(z) ), atan(1.), 1e-10, 1e-10 ); return ok; } bool general(void) { bool ok = true; using CppAD::atan; using CppAD::sin; using CppAD::cos; using namespace CppAD; // 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], 1e-10 , 1e-10); // check case where u is in second quadrant v[0] = 3.; w = f.Forward(0, v); ok &= NearEqual(w[0] , v[0], 1e-10 , 1e-10); // check case where u is in third quadrant v[0] = -3.; w = f.Forward(0, v); ok &= NearEqual(w[0] , v[0], 1e-10 , 1e-10); // check case where u is in fourth quadrant v[0] = -1.; w = f.Forward(0, v); ok &= NearEqual(w[0] , v[0], 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = 1.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } } // end empty namespace bool atan2(void) { bool ok = true; ok &= ad_ad(); ok &= general(); return ok; } cppad-20160000.1/test_more/rev_two.cpp0000644000175200017650000000247412656321774016635 0ustar coincoin-web// $Id: rev_two.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. -------------------------------------------------------------------------- */ # include bool RevTwo() { bool ok = true; using CppAD::AD; using CppAD::vector; using CppAD::NearEqual; 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., 1e-10, 1e-10); ok &= NearEqual(H[1], 1., 1e-10, 1e-10); J[0] = 1; H = F.RevTwo(x, I, J); ok &= NearEqual(H[0], 1., 1e-10, 1e-10); ok &= NearEqual(H[1], 4., 1e-10, 1e-10); return ok; } cppad-20160000.1/test_more/old_tan.cpp0000644000175200017650000002741412656321774016571 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin old_tan.cpp$$ $spell Tanh $$ $section Old Tan and Tanh as User Atomic Operations: Example and Test$$ $head Deprecated 2013-05-27$$ This example has not deprecated; see $cref atomic_tangent.cpp$$ instead. $head Theory$$ The code below uses the $cref tan_forward$$ and $cref tan_reverse$$ to implement the tangent ($icode%id% == 0%$$) and hyperbolic tangent ($icode%id% == 1%$$) functions as user atomic operations. $code $verbatim%test_more/old_tan.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // Begin empty namespace using CppAD::vector; // a utility to compute the union of two sets. void my_union( std::set& result , const std::set& left , const std::set& right ) { std::set temp; std::set_union( left.begin() , left.end() , right.begin() , right.end() , std::inserter(temp, temp.begin()) ); result.swap(temp); } // ---------------------------------------------------------------------- // forward mode routine called by CppAD bool old_tan_forward( size_t id , size_t order , size_t n , size_t m , const vector& vx , vector& vzy , const vector& tx , vector& tzy ) { assert( id == 0 || id == 1 ); assert( n == 1 ); assert( m == 2 ); assert( tx.size() >= (order+1) * n ); assert( tzy.size() >= (order+1) * m ); size_t n_order = order + 1; size_t j = order; size_t k; // check if this is during the call to old_tan(id, ax, ay) if( vx.size() > 0 ) { assert( vx.size() >= n ); assert( vzy.size() >= m ); // now setvzy vzy[0] = vx[0]; vzy[1] = vx[0]; } if( j == 0 ) { // z^{(0)} = tan( x^{(0)} ) or tanh( x^{(0)} ) if( id == 0 ) tzy[0] = tan( tx[0] ); else tzy[0] = tanh( tx[0] ); // y^{(0)} = z^{(0)} * z^{(0)} tzy[n_order + 0] = tzy[0] * tzy[0]; } else { float j_inv = 1.f / float(j); if( id == 1 ) j_inv = - j_inv; // z^{(j)} = x^{(j)} +- sum_{k=1}^j k x^{(k)} y^{(j-k)} / j tzy[j] = tx[j]; for(k = 1; k <= j; k++) tzy[j] += tx[k] * tzy[n_order + j-k] * k * j_inv; // y^{(j)} = sum_{k=0}^j z^{(k)} z^{(j-k)} tzy[n_order + j] = 0.; for(k = 0; k <= j; k++) tzy[n_order + j] += tzy[k] * tzy[j-k]; } // All orders are implemented and there are no possible errors return true; } // ---------------------------------------------------------------------- // reverse mode routine called by CppAD bool old_tan_reverse( size_t id , size_t order , size_t n , size_t m , const vector& tx , const vector& tzy , vector& px , const vector& pzy ) { assert( id == 0 || id == 1 ); assert( n == 1 ); assert( m == 2 ); assert( tx.size() >= (order+1) * n ); assert( tzy.size() >= (order+1) * m ); assert( px.size() >= (order+1) * n ); assert( pzy.size() >= (order+1) * m ); size_t n_order = order + 1; size_t j, k; // copy because partials w.r.t. y and z need to change vector qzy = pzy; // initialize accumultion of reverse mode partials for(k = 0; k < n_order; k++) px[k] = 0.; // eliminate positive orders for(j = order; j > 0; j--) { float j_inv = 1.f / float(j); if( id == 1 ) j_inv = - j_inv; // H_{x^{(k)}} += delta(j-k) +- H_{z^{(j)} y^{(j-k)} * k / j px[j] += qzy[j]; for(k = 1; k <= j; k++) px[k] += qzy[j] * tzy[n_order + j-k] * k * j_inv; // H_{y^{j-k)} += +- H_{z^{(j)} x^{(k)} * k / j for(k = 1; k <= j; k++) qzy[n_order + j-k] += qzy[j] * tx[k] * k * j_inv; // H_{z^{(k)}} += H_{y^{(j-1)}} * z^{(j-k-1)} * 2. for(k = 0; k < j; k++) qzy[k] += qzy[n_order + j-1] * tzy[j-k-1] * 2.f; } // eliminate order zero if( id == 0 ) px[0] += qzy[0] * (1.f + tzy[n_order + 0]); else px[0] += qzy[0] * (1.f - tzy[n_order + 0]); return true; } // ---------------------------------------------------------------------- // forward Jacobian sparsity routine called by CppAD bool old_tan_for_jac_sparse( size_t id , size_t n , size_t m , size_t p , const vector< std::set >& r , vector< std::set >& s ) { assert( n == 1 ); assert( m == 2 ); assert( id == 0 || id == 1 ); assert( r.size() >= n ); assert( s.size() >= m ); // sparsity for z and y are the same as for x s[0] = r[0]; s[1] = r[0]; return true; } // ---------------------------------------------------------------------- // reverse Jacobian sparsity routine called by CppAD bool old_tan_rev_jac_sparse( size_t id , size_t n , size_t m , size_t p , vector< std::set >& r , const vector< std::set >& s ) { assert( n == 1 ); assert( m == 2 ); assert( id == 0 || id == 1 ); assert( r.size() >= n ); assert( s.size() >= m ); // note that, if the users code only uses z, and not y, // we could just set r[0] = s[0] my_union(r[0], s[0], s[1]); return true; } // ---------------------------------------------------------------------- // reverse Hessian sparsity routine called by CppAD bool old_tan_rev_hes_sparse( size_t id , size_t n , size_t m , size_t p , const vector< std::set >& r , const vector& s , vector& t , const vector< std::set >& u , vector< std::set >& v ) { assert( n == 1 ); assert( m == 2 ); assert( id == 0 || id == 1 ); assert( r.size() >= n ); assert( s.size() >= m ); assert( t.size() >= n ); assert( u.size() >= m ); assert( v.size() >= n ); // back propagate Jacobian sparsity. If users code only uses z, // we could just set t[0] = s[0]; t[0] = s[0] | s[1]; // back propagate Hessian sparsity, ... my_union(v[0], u[0], u[1]); // convert forward Jacobian sparsity to Hessian sparsity // because tan and tanh are nonlinear if( t[0] ) my_union(v[0], v[0], r[0]); return true; } // --------------------------------------------------------------------- // Declare the AD routine old_tan(id, ax, ay) CPPAD_USER_ATOMIC( old_tan , CppAD::vector , float , old_tan_forward , old_tan_reverse , old_tan_for_jac_sparse , old_tan_rev_jac_sparse , old_tan_rev_hes_sparse ) } // End empty namespace bool old_tan(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; float eps = 10.f * CppAD::numeric_limits::epsilon(); // domain space vector size_t n = 1; float x0 = 0.5; CppAD::vector< AD > ax(n); ax[0] = x0; // declare independent variables and start tape recording CppAD::Independent(ax); // range space vector size_t m = 3; CppAD::vector< AD > af(m); // temporary vector for old_tan computations // (old_tan computes tan or tanh and its square) CppAD::vector< AD > az(2); // call user tan function and store tan(x) in f[0] (ignore tan(x)^2) size_t id = 0; old_tan(id, ax, az); af[0] = az[0]; // call user tanh function and store tanh(x) in f[1] (ignore tanh(x)^2) id = 1; old_tan(id, ax, az); af[1] = az[0]; // put a constant in f[2] = tanh(1.) (for sparsity pattern testing) CppAD::vector< AD > one(1); one[0] = 1.; old_tan(id, one, az); af[2] = az[0]; // create f: x -> f and stop tape recording CppAD::ADFun F; F.Dependent(ax, af); // check function value float tan = std::tan(x0); ok &= NearEqual(af[0] , tan, eps, eps); float tanh = std::tanh(x0); ok &= NearEqual(af[1] , tanh, eps, eps); // check zero order forward CppAD::vector x(n), f(m); x[0] = x0; f = F.Forward(0, x); ok &= NearEqual(f[0] , tan, eps, eps); ok &= NearEqual(f[1] , tanh, eps, eps); // compute first partial of f w.r.t. x[0] using forward mode CppAD::vector dx(n), df(m); dx[0] = 1.; df = F.Forward(1, dx); // compute derivative of tan - tanh using reverse mode CppAD::vector w(m), dw(n); w[0] = 1.; w[1] = 1.; w[2] = 0.; dw = F.Reverse(1, w); // tan'(x) = 1 + tan(x) * tan(x) // tanh'(x) = 1 - tanh(x) * tanh(x) float tanp = 1.f + tan * tan; float tanhp = 1.f - tanh * tanh; ok &= NearEqual(df[0], tanp, eps, eps); ok &= NearEqual(df[1], tanhp, eps, eps); ok &= NearEqual(dw[0], w[0]*tanp + w[1]*tanhp, eps, eps); // compute second partial of f w.r.t. x[0] using forward mode CppAD::vector ddx(n), ddf(m); ddx[0] = 0.; ddf = F.Forward(2, ddx); // compute second derivative of tan - tanh using reverse mode CppAD::vector ddw(2); ddw = F.Reverse(2, w); // tan''(x) = 2 * tan(x) * tan'(x) // tanh''(x) = - 2 * tanh(x) * tanh'(x) // Note that second order Taylor coefficient for u half the // corresponding second derivative. float two = 2; float tanpp = two * tan * tanp; float tanhpp = - two * tanh * tanhp; ok &= NearEqual(two * ddf[0], tanpp, eps, eps); ok &= NearEqual(two * ddf[1], tanhpp, eps, eps); ok &= NearEqual(ddw[0], w[0]*tanp + w[1]*tanhp , eps, eps); ok &= NearEqual(ddw[1], w[0]*tanpp + w[1]*tanhpp, eps, eps); // Forward mode computation of sparsity pattern for F. size_t p = n; // user vectorBool because m and n are small CppAD::vectorBool r1(p), s1(m * p); r1[0] = true; // propagate sparsity for x[0] s1 = F.ForSparseJac(p, r1); ok &= (s1[0] == true); // f[0] depends on x[0] ok &= (s1[1] == true); // f[1] depends on x[0] ok &= (s1[2] == false); // f[2] does not depend on x[0] // Reverse mode computation of sparsity pattern for F. size_t q = m; CppAD::vectorBool s2(q * m), r2(q * n); // Sparsity pattern for identity matrix size_t i, j; for(i = 0; i < q; i++) { for(j = 0; j < m; j++) s2[i * q + j] = (i == j); } r2 = F.RevSparseJac(q, s2); ok &= (r2[0] == true); // f[0] depends on x[0] ok &= (r2[1] == true); // f[1] depends on x[0] ok &= (r2[2] == false); // f[2] does not depend on x[0] // Hessian sparsity for f[0] CppAD::vectorBool s3(m), h(p * n); s3[0] = true; s3[1] = false; s3[2] = false; h = F.RevSparseHes(p, s3); ok &= (h[0] == true); // Hessian is non-zero // Hessian sparsity for f[2] s3[0] = false; s3[2] = true; h = F.RevSparseHes(p, s3); ok &= (h[0] == false); // Hessian is zero // check tanh results for a large value of x x[0] = std::numeric_limits::max() / two; f = F.Forward(0, x); tanh = 1.; ok &= NearEqual(f[1], tanh, eps, eps); df = F.Forward(1, dx); tanhp = 0.; ok &= NearEqual(df[1], tanhp, eps, eps); // -------------------------------------------------------------------- // Free all temporary work space associated with old_atomic objects. // (If there are future calls to user atomic functions, they will // create new temporary work space.) CppAD::user_atomic::clear(); return ok; } // END C++ cppad-20160000.1/test_more/rev_sparse_jac.cpp0000644000175200017650000003005112656321774020126 0ustar coincoin-web// $Id: rev_sparse_jac.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # 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++; # 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++; # 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++; namespace { // BEGIN empty namespace bool case_one() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 3; // 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]); } } return ok; } bool case_two() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 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]); } } return ok; } bool case_three() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 2; // 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]); } } return ok; } // case where s is not identity matrix bool case_four() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 2; // 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; return ok; } bool case_five() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 2; // 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]); } } return ok; } } // END empty namespace bool rev_sparse_jac(void) { bool ok = true; ok &= case_one(); ok &= case_two(); ok &= case_three(); ok &= case_four(); ok &= case_five(); return ok; } cppad-20160000.1/test_more/alloc_openmp.cpp0000644000175200017650000000466612656321774017625 0ustar coincoin-web// $Id: alloc_openmp.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 C++ # include # include # define NUMBER_THREADS 2 namespace { 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); } } // Test routine called by the master thread (thread_num = 0). bool alloc_openmp(void) { bool ok = true; int num_threads = NUMBER_THREADS; // call setup for using thread_alloc in parallel mode. thread_alloc::parallel_setup( size_t(num_threads), in_parallel, thread_number ); // Execute the worker function in parallel int thread_num; # pragma omp parallel for for(thread_num = 0; thread_num < num_threads; thread_num++) worker(); // end omp parallel for // now inform CppAD that there is only one thread thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL); 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; } cppad-20160000.1/test_more/adfun_copy.cpp0000644000175200017650000000265612656321774017301 0ustar coincoin-web// $Id: adfun_copy.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test that ADFun copy constructor generates an error message. */ # include # include 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"); } } 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; } cppad-20160000.1/test_more/check_simple_vector.cpp0000644000175200017650000000247612656321774021162 0ustar coincoin-web// $Id: check_simple_vector.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include # include # include # include namespace { 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); } } 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; } cppad-20160000.1/test_more/add_zero.cpp0000644000175200017650000000360412656321774016733 0ustar coincoin-web// $Id: add_zero.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test the use of the special parameters zero and one with the multiply operator */ # include typedef CppAD::AD ADdouble; typedef CppAD::AD< ADdouble > ADDdouble; bool AddZero(void) { using namespace CppAD; bool ok = true; 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 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(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]; // 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); // check derivatives of g ok &= (b[0] == 1.); ok &= (b[1] == 2.); } } return ok; } cppad-20160000.1/test_more/neg.cpp0000644000175200017650000000344312656321774015716 0ustar coincoin-web// $Id: neg.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* old example and test now only used for testing */ // BEGIN C++ # include bool Neg(void) { bool ok = true; 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) return ok; } // END C++ cppad-20160000.1/test_more/makefile.am0000644000175200017650000001055212656321775016535 0ustar coincoin-web# $Id: makefile.am 3769 2015-12-29 16:13:16Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # automake input file # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # # ------------------------------------------------------------------------- if CppAD_OPENMP OPENMP_SRC_FILES = alloc_openmp.cpp else OPENMP_SRC_FILES = endif # ------------------------------------------------------------------------- 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 = -DCPPAD_ADOLC_TEST -I$(ADOLC_DIR)/include else ADOLC_EXTRA_FILES = base_adolc.cpp ADOLC_SRC_FILES = ADOLC_LIB = ADOLC_FLAGS = endif # ------------------------------------------------------------------------- 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 = -DCPPAD_IPOPT_TEST -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_LIB = -L. -leigen libeigen_a_CXXFLAGS = \ -g \ $(CXX_FLAGS_EIGEN) \ -DCPPAD_EIGEN_TEST \ -I$(EIGEN_DIR)/include else EIGEN_EXTRA_FILES = cppad_eigen.cpp EIGEN_LIB = endif # ------------------------------------------------------------------------- # Microsoft project files and script to run a single test EXTRA_DIST = \ test_one.sh.in \ $(ADOLC_EXTRA_FILES) \ $(IPOPT_EXTRA_FILES) \ $(EIGEN_EXTRA_FILES) # check_PROGRAMS = test_more # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ $(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) # test_more_SOURCES = \ $(ADOLC_SRC_FILES) \ $(IPOPT_SRC_FILES) \ $(OPENMP_SRC_FILES) \ test_more.cpp \ abs.cpp \ acos.cpp \ acosh.cpp \ adfun_copy.cpp \ asin.cpp \ asinh.cpp \ assign.cpp \ add.cpp \ add_eq.cpp \ add_zero.cpp \ atan.cpp \ atanh.cpp \ atan2.cpp \ azmul.cpp \ base_alloc.cpp \ check_simple_vector.cpp \ checkpoint.cpp \ compare.cpp \ compare_change.cpp \ cond_exp.cpp \ cond_exp_ad.cpp \ cond_exp_rev.cpp \ copy.cpp \ cos.cpp \ cosh.cpp \ dbl_epsilon.cpp \ div.cpp \ div_eq.cpp \ div_zero_one.cpp \ erf.cpp \ exp.cpp \ expm1.cpp \ extern_value.cpp \ extern_value.hpp \ for_hess.cpp \ for_sparse_jac.cpp \ forward.cpp \ forward_dir.cpp \ forward_order.cpp \ from_base.cpp \ fun_check.cpp \ jacobian.cpp \ num_limits.cpp \ log.cpp \ log1p.cpp \ log10.cpp \ mul.cpp \ mul_cskip.cpp \ mul_eq.cpp \ mul_level.cpp \ mul_cond_rev.cpp \ mul_zdouble.cpp \ mul_zero_one.cpp \ near_equal_ext.cpp \ neg.cpp \ ode_err_control.cpp \ old_usead_2.cpp \ old_usead_1.cpp \ old_tan.cpp \ old_reciprocal.cpp \ old_mat_mul.cpp \ old_mat_mul.hpp \ omp_alloc.cpp \ optimize.cpp \ parameter.cpp \ poly.cpp \ pow.cpp \ pow_int.cpp \ print_for.cpp \ romberg_one.cpp \ rosen_34.cpp \ runge_45.cpp \ reverse.cpp \ rev_sparse_hes.cpp \ rev_sparse_jac.cpp \ rev_two.cpp \ simple_vector.cpp \ sin.cpp \ sin_cos.cpp \ sinh.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp \ sparse_vec_ad.cpp \ sqrt.cpp \ std_math.cpp \ sub.cpp \ sub_eq.cpp \ sub_zero.cpp \ tan.cpp \ test_vector.cpp \ to_string.cpp \ track_new_del.cpp \ value.cpp \ vec_ad.cpp \ vec_ad_par.cpp \ vec_unary.cpp \ zdouble.cpp test: check ./test_more cppad-20160000.1/test_more/copy.cpp0000644000175200017650000001020712656321775016114 0ustar coincoin-web// $Id: copy.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. -------------------------------------------------------------------------- */ /* Old Copy example now used just for valiadation testing */ # include namespace { // begin empty namespace bool copy_older(void) { bool ok = true; 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 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 // 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; } bool copy_base(void) { 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 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); // 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.); // 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. ); return ok; } bool default_ctor(void) { bool ok = true; using CppAD::AD; // default AD constructor AD x, y; // check that they are parameters ok &= Parameter(x); ok &= Parameter(y); // assign them values x = 3.; y = 4.; // just check a simple operation ok &= (x + y == 7.); 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; } cppad-20160000.1/test_more/sub.cpp0000644000175200017650000001076512656321775015744 0ustar coincoin-web// $Id: sub.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Two old Sub examples now used just for valiadation testing */ # include namespace { // BEGIN empty namespace bool One(void) { bool ok = true; 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) return ok; } bool Two(void) { bool ok = true; using namespace CppAD; // 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, 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = -1.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } bool Three(void) { 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.); return ok; } bool Four(void) { 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.); return ok; } } // END empty namespace bool Sub(void) { bool ok = true; ok &= One(); ok &= Two(); ok &= Three(); ok &= Four(); return ok; } cppad-20160000.1/test_more/reverse.cpp0000644000175200017650000003256212656321775016625 0ustar coincoin-web// $Id: reverse.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old Reverse example now used just for valiadation testing */ # include namespace { // ---------------------------------------------------------- bool reverse_one(void) { bool ok = true; using namespace CppAD; // 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], 1e-10, 1e-10); } // ------------------------------------------------------------------- // 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], 1e-10, 1e-10); } /* 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, 1e-10, 1e-10); } return ok; } // define the template function reverse_any_cases in empty namespace template bool reverse_any_cases(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10, 1e-10); // 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, 1e-10, 1e-10); // 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, 1e-10, 1e-10); // 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], 1e-10, 1e-10); ok &= NearEqual(dw[1*p+0], u[0]*u[2], 1e-10, 1e-10); ok &= NearEqual(dw[2*p+0], u[0]*u[1], 1e-10, 1e-10); // check derivative of W1(u) w.r.t. u ok &= NearEqual(dw[0*p+1], u[1]*dx[2] + u[2]*dx[1], 1e-10, 1e-10); ok &= NearEqual(dw[1*p+1], u[0]*dx[2] + u[2]*dx[0], 1e-10, 1e-10); ok &= NearEqual(dw[2*p+1], u[0]*dx[1] + u[1]*dx[0], 1e-10, 1e-10); // check derivative of W2(u) w.r.t u ok &= NearEqual(dw[0*p+2], dx[1]*dx[2], 1e-10, 1e-10); ok &= NearEqual(dw[1*p+2], dx[0]*dx[2], 1e-10, 1e-10); ok &= NearEqual(dw[2*p+2], dx[0]*dx[1], 1e-10, 1e-10); return ok; } /* $comment reverse_any.cpp$$ $spell Taylor $$ $section Reverse Mode General Case: Example and Test$$ $index general, reverse example$$ $index reverse, general example$$ $index example, general reverse$$ $index test, general reverse$$ $index composition, example$$ $index example, composition$$ $index test, composition$$ $head Purpose$$ Break a derivative computation into pieces and only store values at the interface of the pieces. In actual applications, there may be many functions, but 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(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$$). $head Processing Steps$$ We apply reverse mode to compute the derivative of $latex H : \B{R}^2 \rightarrow \B{R}$$ 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 \end{array} \] $$ Given the zero and first order Taylor coefficients $latex x^{(0)} $$ and $latex x^{(1)}$$, we use $latex X(t)$$, $latex Y(t)$$ and $latex Z(t)$$ for the corresponding functions; i.e., $latex \[ \begin{array}{rcl} X(t) & = & x^{(0)} + x^{(1)} t \\ 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: $list number$$ Use forward mode on $latex F(x)$$ to compute $latex y^{(0)}$$ and $latex y^{(1)}$$ $lnext Use forward mode on $latex G(y)$$ to compute $latex z^{(0)}$$ and $latex z^{(1)}$$ $lnext Use reverse mode on $latex G(y)$$ to compute the derivative of $latex h^{(k)}$$ with respect to $latex y^{(0)}$$ and $latex y^{(1)}$$. $lnext Use reverse mode on $latex F(x)$$ to compute the derivative of $latex h^{(k)}$$ with respect to $latex x^{(0)}$$ and $latex x^{(1)}$$. $lend 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)} ] \end{array} \] $$ where $latex \partial_{x(0)}$$ denotes the partial with respect to $latex x^{(0)}$$. $code $comment%example/reverse_any.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ 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; } 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; } bool reverse_mul(void) { 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); return ok; } // ---------------------------------------------------------------------------- } // End empty namespace # 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; } cppad-20160000.1/test_more/sin.cpp0000644000175200017650000000411312656321775015732 0ustar coincoin-web// $Id: sin.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old example now just used for validation testing. */ # include bool Sin(void) { bool ok = true; using CppAD::sin; using CppAD::cos; using namespace CppAD; // 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]), 1e-10 , 1e-10); // 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 *= j; ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); 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(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); } return ok; } cppad-20160000.1/test_more/log1p.cpp0000644000175200017650000000374612656321775016176 0ustar coincoin-web/* $Id$ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include bool log1p(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 10 times machine epsilon double eps = 10. * std::numeric_limits::epsilon(); // domain space vector size_t n = 1; double x0 = 0.5; CPPAD_TESTVECTOR(AD) ax(n); ax[0] = x0; // declare independent variables and start tape recording CppAD::Independent(ax); // a temporary value AD expm1_of_x0 = CppAD::expm1(ax[0]); // range space vector size_t m = 1; CPPAD_TESTVECTOR(AD) ay(m); ay[0] = CppAD::log1p(expm1_of_x0); // create f: x -> y and stop tape recording CppAD::ADFun f(ax, ay); // check value ok &= NearEqual(ay[0] , x0, eps, eps); // forward computation of first partial w.r.t. x[0] CPPAD_TESTVECTOR(double) dx(n); CPPAD_TESTVECTOR(double) dy(m); dx[0] = 1.; dy = f.Forward(1, dx); ok &= NearEqual(dy[0], 1., eps, eps); // forward computation of higher order partials w.r.t. x[0] size_t n_order = 5; for(size_t order = 2; order < n_order; order++) { dx[0] = 0.; dy = f.Forward(order, dx); ok &= NearEqual(dy[0], 0., eps, eps); } // reverse computation of derivatives CPPAD_TESTVECTOR(double) w(m); CPPAD_TESTVECTOR(double) dw(n_order * n); w[0] = 1.; dw = f.Reverse(n_order, w); ok &= NearEqual(dw[0], 1., eps, eps); for(size_t order = 1; order < n_order; order++) ok &= NearEqual(dw[order * n + 0], 0., eps, eps); return ok; } // END C++ cppad-20160000.1/test_more/sqrt.cpp0000644000175200017650000001217612656321775016142 0ustar coincoin-web// $Id: sqrt.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Two old sqrt examples now used just for validation testing. */ # include # include namespace { // BEGIN empty namespace bool SqrtTestOne(void) { bool ok = true; using CppAD::sqrt; using CppAD::pow; using namespace CppAD; // 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., 1e-10 , 1e-10); ok &= NearEqual(Z[y] , sqrt(2.), 1e-10 , 1e-10); // forward computation of partials w.r.t. s v[s] = 1.; w = f.Forward(1, v); ok &= NearEqual(w[x], .5 * pow(4., -.5), 1e-10 , 1e-10); // dx/ds ok &= NearEqual(w[y], .25 * pow(4., -.75), 1e-10 , 1e-10); // 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), 1e-10 , 1e-10); // 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), 1e-10 , 1e-10 ); // 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), 1e-10 , 1e-10 ); return ok; } bool SqrtTestTwo(void) { bool ok = true; using namespace CppAD; // 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], 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = 1.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } bool SqrtTestThree(void) { bool ok = true; using CppAD::sqrt; using CppAD::exp; using namespace CppAD; // 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., 1e-10 , 1e-10); // forward computation of second Taylor coefficient CPPAD_TESTVECTOR(double) x2( f.Domain() ); CPPAD_TESTVECTOR(double) y2( f.Range() ); x2[0] = 0.; y2 = f.Forward(2, x2); ok &= NearEqual(2.*y2[0] , exp(x/2.)/4., 1e-10 , 1e-10 ); // forward computation of third Taylor coefficient CPPAD_TESTVECTOR(double) x3( f.Domain() ); CPPAD_TESTVECTOR(double) y3( f.Range() ); x3[0] = 0.; y3 = f.Forward(3, x3); ok &= NearEqual(6.*y3[0] , exp(x/2.)/8., 1e-10 , 1e-10 ); // reverse computation of deritavitve of Taylor coefficients CPPAD_TESTVECTOR(double) r( f.Domain() * 4 ); CPPAD_TESTVECTOR(double) w(1); w[0] = 1.; r = f.Reverse(4, w); ok &= NearEqual(r[0], exp(x/2.)/2., 1e-10 , 1e-10); ok &= NearEqual(r[1], exp(x/2.)/4., 1e-10 , 1e-10 ); ok &= NearEqual(2.*r[2], exp(x/2.)/8., 1e-10 , 1e-10 ); ok &= NearEqual(6.*r[3], exp(x/2.)/16., 1e-10 , 1e-10 ); return ok; } } // END empty namespace bool Sqrt(void) { bool ok = true; ok &= SqrtTestOne(); ok &= SqrtTestTwo(); ok &= SqrtTestThree(); return ok; } cppad-20160000.1/test_more/tan.cpp0000644000175200017650000001114312656321775015724 0ustar coincoin-web/* $Id: tan.cpp 3683 2015-05-10 02:24:16Z bradbell $ */ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test higher order derivatives for tan(x) function. */ # 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); 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; } cppad-20160000.1/test_more/asin.cpp0000644000175200017650000000344712656321775016104 0ustar coincoin-web/* $Id: asin.cpp 3675 2015-05-05 14:26:18Z 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. -------------------------------------------------------------------------- */ /* Old example now only used for validation testing. */ # include bool asin(void) { bool ok = true; using CppAD::asin; using namespace CppAD; // 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], 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = 1.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } cppad-20160000.1/test_more/vec_ad.cpp0000644000175200017650000001460312656321775016367 0ustar coincoin-web// $Id: vec_ad.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old examples now only used for validation testing */ // BEGIN C++ # include # include namespace { // Begin empty namespace bool VecADTestOne(void) { bool ok = true; using namespace CppAD; using CppAD::sin; using CppAD::cos; 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, 1e-10, 1e-10); // note that derivative of v[x] w.r.t. x is zero dx[0] = 1.; dz = f.Forward(1, dx); ok &= NearEqual(dz[0], cos(x[0]) * vx, 1e-10, 1e-10); // reverse mode calculation of same value dz[0] = 1.; dx = f.Reverse(1, dz); ok &= NearEqual(dx[0], cos(x[0]) * vx, 1e-10, 1e-10); } return ok; } // create the discrete function AD Floor(const AD &X) double Floor(const double &x) { return std::floor(x); } CPPAD_DISCRETE_FUNCTION(double, Floor) bool VecADTestTwo(void) { bool ok = true; using namespace CppAD; double pi = 4. * CppAD::atan(1.); size_t nx = 10; // number of x grid point double xLow = 0; // minimum value for x double xUp = 2 * pi; // maximum value for x double xStep = (xUp - xLow) / (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., 1e-10, 1e-10); // 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, 1e-10, 1e-10); 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); return ok; } } // END empty namespace bool VecAD(void) { bool ok = true; ok &= VecADTestOne(); ok &= VecADTestTwo(); ok &= SecondOrderReverse(); return ok; } cppad-20160000.1/test_more/near_equal_ext.cpp0000644000175200017650000000347512656321775020147 0ustar coincoin-web// $Id: near_equal_ext.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old example now just used for validation testing */ # include # 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); return ok; } cppad-20160000.1/test_more/div.cpp0000644000175200017650000001254012656321775015726 0ustar coincoin-web// $Id: div.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. -------------------------------------------------------------------------- */ /* Two old Div examples now used just for valiadation testing */ # include namespace { // BEGIN empty namespace bool DivTestOne(void) { bool ok = true; using namespace CppAD; // 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. , 1e-10 , 1e-10); ok &= NearEqual( Z[y] , 2. / ( 3. * 4. ) , 1e-10 , 1e-10); ok &= NearEqual( Z[z] , 5. * 3. * 4. / 2. , 1e-10 , 1e-10); 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], 1e-10 , 1e-10); // dx/ds ok &= NearEqual(r[y], 1./(U[t]*4.), 1e-10 , 1e-10); // dy/ds ok &= NearEqual(r[z], -5.*U[t]*4./(U[s]*U[s]),1e-10 , 1e-10); // 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]), 1e-10, 1e-10); // 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]), 1e-10, 1e-10 ); return ok; } bool DivTestTwo(void) { bool ok = true; using namespace CppAD; // 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))), 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = 6. / 4.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } bool DivTestThree(void) { bool ok = true; using namespace CppAD; // 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, 1e-10 , 1e-10); CPPAD_TESTVECTOR(double) w(m), dw(n); w[0] = 1.; dw = f.Reverse(1, w); check = 1. / x1; ok &= NearEqual(dw[0], check, 1e-10 , 1e-10); check = - x0 / (x1 * x1); ok &= NearEqual(dw[1], check, 1e-10 , 1e-10); return ok; } } // END empty namespace bool Div(void) { bool ok = true; ok &= DivTestOne(); ok &= DivTestTwo(); ok &= DivTestThree(); return ok; } cppad-20160000.1/test_more/CMakeLists.txt0000644000175200017650000000750412656321775017204 0ustar coincoin-web# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the test_more directory tests # Inherit environment from ../CMakeList.txt # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # This directory now contains omp_alloc.cpp which uses multi-threading, so # so no longer can set CPPAD_MAX_NUM_THREADS equal to one (its smallest value) # ADD_DEFINITIONS("-DCPPAD_MAX_NUM_THREADS=1") # adolc_prefix SET(sources base_adolc.cpp) sources_libs_define(adolc "${sources}" adolc ADOLC_TEST) # ipopt_prefix SET(sources ipopt_solve.cpp) sources_libs_define(ipopt "${sources}" "${ipopt_LIBRARIES}" IPOPT_TEST) # sources that use eigen IF ( eigen_prefix ) # compile eigen library separately so can use different compiler flags ADD_LIBRARY(test_more_eigen_lib EXCLUDE_FROM_ALL cppad_eigen.cpp ) # Adds -D define flags to the compilation of source files. ADD_DEFINITIONS("-DCPPAD_EIGEN_TEST") # Add other compiler flags add_cppad_cxx_flags(test_more_eigen_lib) # # Add eigen to list of libraries SET(eigen_libs test_more_eigen_lib) ELSE ( eigen_prefix ) SET(eigen_sources "") SET(eigen_libs "") ENDIF ( eigen_prefix ) # Copy a file to another location and modify its contents. # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/test_one.sh ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(test_more EXCLUDE_FROM_ALL test_more.cpp old_usead_2.cpp old_usead_1.cpp old_tan.cpp old_reciprocal.cpp old_mat_mul.cpp ${adolc_sources} ${ipopt_sources} abs.cpp acos.cpp acosh.cpp adfun_copy.cpp asin.cpp asinh.cpp assign.cpp add.cpp add_eq.cpp add_zero.cpp atan.cpp atanh.cpp atan2.cpp azmul.cpp base_alloc.cpp check_simple_vector.cpp checkpoint.cpp compare.cpp compare_change.cpp cond_exp.cpp cond_exp_ad.cpp cond_exp_rev.cpp copy.cpp cos.cpp cosh.cpp dbl_epsilon.cpp div.cpp div_eq.cpp div_zero_one.cpp erf.cpp exp.cpp expm1.cpp extern_value.cpp for_hess.cpp for_sparse_jac.cpp forward.cpp forward_dir.cpp forward_order.cpp from_base.cpp fun_check.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 omp_alloc.cpp optimize.cpp parameter.cpp poly.cpp pow.cpp pow_int.cpp print_for.cpp romberg_one.cpp rosen_34.cpp runge_45.cpp reverse.cpp rev_sparse_hes.cpp rev_sparse_jac.cpp rev_two.cpp simple_vector.cpp sin.cpp sin_cos.cpp sinh.cpp sparse_hessian.cpp sparse_jacobian.cpp sparse_vec_ad.cpp sqrt.cpp std_math.cpp sub.cpp sub_eq.cpp sub_zero.cpp tan.cpp test_vector.cpp to_string.cpp track_new_del.cpp value.cpp vec_ad.cpp vec_ad_par.cpp vec_unary.cpp zdouble.cpp ) # Compiler flags for cppad source add_cppad_cxx_flags(test_more) # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(test_more ${cppad_lib} ${adolc_libs} ${ipopt_libs} ${eigen_libs} ${colpack_libs} ) # Add the check_test_more target ADD_CUSTOM_TARGET( check_test_more test_more DEPENDS test_more ) cppad-20160000.1/test_more/ipopt_solve.cpp0000644000175200017650000000715512656321775017515 0ustar coincoin-web// $Id: ipopt_solve.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. -------------------------------------------------------------------------- */ /* Testing ipopt::solve */ # ifdef CPPAD_IPOPT_TEST # include namespace { 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; } }; } 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 ); } } return ok; } # endif cppad-20160000.1/test_more/abs.cpp0000644000175200017650000000375012656321775015714 0ustar coincoin-web// $Id: abs.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test of directional derivative in AD< AD< double > > case. */ # include bool abs(void) { // 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] = CppAD::abs(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; } cppad-20160000.1/test_more/pow.cpp0000644000175200017650000002411712656321775015754 0ustar coincoin-web// $Id: pow.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old examples now just used for validation testing. */ # include namespace { // BEGIN empty namespace bool PowTestOne(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10 , 1e-10); // 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, 1e-10, 1e-10); ok &= NearEqual(dz[1], check, 1e-10, 1e-10); ok &= NearEqual(dz[2], 0., 1e-10, 1e-10); // forward computation of first partial w.r.t. y dxy[0] = 0.; dxy[1] = 1.; dz = f.Forward(1, dxy); check = std::log(x) * std::pow(x, y); ok &= NearEqual(dz[0], check, 1e-10, 1e-10); ok &= NearEqual(dz[1], 0., 1e-10, 1e-10); ok &= NearEqual(dz[2], check, 1e-10, 1e-10); // 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, 1e-10, 1e-10); check = std::log(x) * std::pow(x, y); ok &= NearEqual(dw[1], 2. * check, 1e-10, 1e-10); // 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], 1e-10, 1e-10); return ok; } bool PowTestTwo(void) { bool ok = true; using CppAD::pow; using CppAD::exp; 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] = 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.), 1e-10 , 1e-10); ok &= NearEqual(Z[y] , exp( 2. * 3. * exp(2.) ), 1e-10 , 1e-10); // 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], 1e-10 , 1e-10 ); return ok; } bool PowTestThree(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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., 1e-10, 1e-10); 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., 1e-10, 1e-10); return ok; } bool PowTestFour(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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] = pow(x[0], 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, 1e-10, 1e-10); } // 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, 1e-10, 1e-10); 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, 1e-10, 1e-10); return ok; } bool PowTestFive(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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, 1e-10, 1e-10); // 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, 1e-10, 1e-10); ok &= NearEqual(ddw[1], d2, 1e-10, 1e-10); return ok; } bool PowTestSix(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; // 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 &= (Value( 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(AD) dx(n); CPPAD_TESTVECTOR(AD) dy(m); dx[0] = 1.; dy = F.Forward(1, dx); ok &= NearEqual(dy[0], d1, 1e-10, 1e-10); // 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, 1e-10, 1e-10); ok &= NearEqual(ddw[1], d2, 1e-10, 1e-10); 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; } cppad-20160000.1/test_more/atan.cpp0000644000175200017650000000667212656321775016100 0ustar coincoin-web/* $Id: atan.cpp 3682 2015-05-08 21:59:05Z 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. -------------------------------------------------------------------------- */ /* Two old atan examples now used just for validation testing. */ # include namespace { // BEGIN empty namespace bool AtanTestOne(void) { bool ok = true; using CppAD::atan; using namespace CppAD; // 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], 1e-10 , 1e-10); // forward computation of partials w.r.t. s v[s] = 1.; w = f.Forward(1, v); ok &= NearEqual(w[a], 1e0, 1e-10 , 1e-10); // da/ds // reverse computation of first order partial of a w[a] = 1.; v = f.Reverse(1, w); ok &= NearEqual(v[s], 1e0, 1e-10 , 1e-10); // 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, 1e-10 , 1e-10); // 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, 1e-10 , 1e-10 ); // d^2 a / (ds ds) return ok; } bool AtanTestTwo(void) { bool ok = true; using CppAD::atan; using CppAD::sin; using CppAD::cos; using namespace CppAD; // 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], 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = 1.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } } // END empty namespace bool atan(void) { bool ok = true; ok &= AtanTestOne(); ok &= AtanTestTwo(); return ok; } cppad-20160000.1/test_more/rev_sparse_hes.cpp0000644000175200017650000003234412656321775020160 0ustar coincoin-web// $Id: rev_sparse_hes.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 { // Begin empty namespace bool case_one() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 10; // dimension of the range space size_t m = 2; // temporary indices size_t i, j; // 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) X(n); for(j = 0; j < n; j++) X[j] = AD(j); Independent(X); // 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[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; // 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; // variable - variable Y[1] = X[0] - X[1]; // create function object F : X -> Y ADFun F(X, Y); // ------------------------------------------------------------------ // sparsity pattern for the identity function U(x) = x 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; } // compute sparsity pattern for Jacobian of F(U(x)) F.ForSparseJac(n, Px); // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(bool) Py(m); Py[0] = true; Py[1] = false; CPPAD_TESTVECTOR(bool) Pxx(n * n); Pxx = F.RevSparseHes(n, Py); // check values for(j = 0; j < n * n; j++) ok &= (Pxx[j] == Check[j]); // compute sparsity pattern for Hessian of F_1 ( U(x) ) Py[0] = false; Py[1] = true; Pxx = F.RevSparseHes(n, Py); for(j = 0; j < n * n; j++) ok &= (! Pxx[j]); // Hessian is identically zero // ------------------------------------------------------------------ // sparsity pattern for the identity function U(x) = x CPPAD_TESTVECTOR(std::set) Sx(n); for(i = 0; i < n; i++) Sx[i].insert(i); // compute sparsity pattern for Jacobian of F(U(x)) F.ForSparseJac(n, Sx); // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(std::set) Sy(1); Sy[0].insert(0); CPPAD_TESTVECTOR(std::set) Sxx(n); Sxx = F.RevSparseHes(n, Sy); // check values for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { bool found = Sxx[i].find(j) != Sxx[i].end(); ok &= (found == Check[i * n + j]); } } // compute sparsity pattern for Hessian of F_1 ( U(x) ) Sy[0].clear(); Sy[0].insert(1); Sxx = F.RevSparseHes(n, Sy); for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { bool found = Sxx[i].find(j) != Sxx[i].end(); ok &= ! found; } } return ok; } bool case_two() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 4; // dimension of the range space size_t m = 1; // temporary indices size_t i, j; // 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) X(n); for(j = 0; j < n; j++) X[j] = AD(j); Independent(X); // Test the case where dependent variable is a non-linear function // of the result of a conditional expression. 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); // ----------------------------------------------------------------- // sparsity pattern for the identity function U(x) = x 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; } // compute sparsity pattern for Jacobian of F(U(x)) F.ForSparseJac(n, Px); // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(bool) Py(m); Py[0] = true; CPPAD_TESTVECTOR(bool) Pxx(n * n); Pxx = F.RevSparseHes(n, Py); // check values for(j = 0; j < n * n; j++) ok &= (Pxx[j] == Check[j]); // ------------------------------------------------------------------ // sparsity pattern for the identity function U(x) = x CPPAD_TESTVECTOR(std::set) Sx(n); for(i = 0; i < n; i++) Sx[i].insert(i); // compute sparsity pattern for Jacobian of F(U(x)) F.ForSparseJac(n, Sx); // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(std::set) Sy(1); Sy[0].insert(0); CPPAD_TESTVECTOR(std::set) Sxx(n); Sxx = F.RevSparseHes(n, Sy); // check values for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { bool found = Sxx[i].find(j) != Sxx[i].end(); ok &= (found == Check[i * n + j]); } } return ok; } bool case_three() { 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); // ------------------------------------------------------------------ // sparsity pattern for the identity matrix CppAD::vector r(n * n); size_t i, j; for(i = 0; i < n; i++) { for(j = 0; j < n; j++) r[ i * n + j ] = false; r[ i * n + i ] = true; } // compute sparsity pattern for J(x) = F^{(1)} (x) f.ForSparseJac(n, r); // compute sparsity pattern for H(x) = F_0^{(2)} (x) CppAD::vector s(m); for(i = 0; i < m; i++) s[i] = false; s[0] = true; CppAD::vector h(n * n); h = f.RevSparseHes(n, s); // check values ok &= (h[ 0 * n + 0 ] == true); // second partial w.r.t x[0], x[0] // ------------------------------------------------------------------ // sparsity pattern for the identity function U(x) = x CPPAD_TESTVECTOR(std::set) Sx(n); for(i = 0; i < n; i++) Sx[i].insert(i); // compute sparsity pattern for Jacobian of F(U(x)) f.ForSparseJac(n, Sx); // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(std::set) Sy(1); Sy[0].insert(0); CPPAD_TESTVECTOR(std::set) Sxx(n); Sxx = f.RevSparseHes(n, Sy); // check value bool found = Sxx[0].find(0) != Sxx[0].end(); ok &= (found == true); return ok; } bool case_four() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 3; // 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); // ----------------------------------------------------- // compute the forward Jacobian sparsity pattern for F CPPAD_TESTVECTOR( bool ) r(n * n); size_t i, j; for(i = 0; i < n; i++) { for(j = 0; j < n; j++) r[ i * n + j ] = false; r[ i * n + i ] = true; } F.ForSparseJac(n, r); // compute the reverse Hessian sparsity pattern for F CPPAD_TESTVECTOR( bool ) s(m), h(n * n); s[0] = 1.; 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[i * n + j]); } // ------------------------------------------------------------------ // sparsity pattern for the identity function U(x) = x CPPAD_TESTVECTOR(std::set) Sx(n); for(i = 0; i < n; i++) Sx[i].insert(i); // compute sparsity pattern for Jacobian of F(U(x)) F.ForSparseJac(n, Sx); // compute sparsity pattern for Hessian of F_0 ( U(x) ) CPPAD_TESTVECTOR(std::set) Sy(1); Sy[0].insert(0); CPPAD_TESTVECTOR(std::set) Sxx(n); Sxx = F.RevSparseHes(n, Sy); // check values for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { bool found = Sxx[i].find(j) != Sxx[i].end(); ok &= (found == Check[i * n + j]); } } return ok; } bool case_five(void) { bool ok = true; using CppAD::AD; size_t i, j, k; 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); // sparsity pattern for the identity function U(x) = x CPPAD_TESTVECTOR(bool) 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)) F.ForSparseJac(n, Px); // compute sparsity pattern for Hessian of F_k ( U(x) ) CPPAD_TESTVECTOR(bool) Py(m); CPPAD_TESTVECTOR(bool) Pxx(n * n); for(k = 0; k < m; k++) { for(i = 0; i < m; i++) Py[i] = (i == k); Pxx = F.RevSparseHes(n, Py); // check values for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { bool check = (i == k) & (j == k); ok &= Pxx[i * n + j] == check; } } } return ok; } bool case_six() { bool ok = true; using namespace CppAD; // dimension of the domain space size_t n = 3; // 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 patter 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; } } // End of empty namespace bool rev_sparse_hes(void) { bool ok = true; ok &= case_one(); ok &= case_two(); ok &= case_three(); ok &= case_four(); ok &= case_five(); ok &= case_six(); return ok; } cppad-20160000.1/test_more/cos.cpp0000644000175200017650000000411212656321775015724 0ustar coincoin-web// $Id: cos.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Old example now just used for validation testing */ # include bool Cos(void) { bool ok = true; using CppAD::sin; using CppAD::cos; using namespace CppAD; // 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]), 1e-10 , 1e-10); // 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 *= j; ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); 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(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); } return ok; } cppad-20160000.1/test_more/erf.cpp0000644000175200017650000001061612656321775015722 0ustar coincoin-web/* $Id: erf.cpp 3685 2015-05-10 23:17: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. A copy of 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 { 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; } # endif } bool erf(void) { bool ok = true; ok &= old_example(); # if CPPAD_USE_CPLUSPLUS_2011 ok &= hessian(); # endif return ok; } cppad-20160000.1/test_more/mul_cond_rev.cpp0000644000175200017650000001615612656321775017627 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Test of multi-level conditional expressions reverse mode */ # include bool mul_cond_rev(void) { bool ok = true; using CppAD::vector; using CppAD::NearEqual; double eps = 10. * std::numeric_limits::epsilon(); // typedef CppAD::AD a1double; typedef CppAD::AD a2double; // a1double a1zero = 0.0; a2double a2zero = a1zero; a1double a1one = 1.0; a2double a2one = a1one; // // -------------------------------------------------------------------- // create a1f = f(x) size_t n = 1; size_t m = 25; // vector a2x(n), a2y(m); a2x[0] = a2double( 5.0 ); Independent(a2x); // size_t i = 0; // variable that is greater than one when x[0] is zero // and less than one when x[0] is 1.0 or greater a2double a2switch = a2one / (a2x[0] + a2double(0.5)); // variable that is infinity when x[0] is zero // and a normal number when x[0] is 1.0 or greater a2double a2inf_var = a2one / a2x[0]; // variable that is nan when x[0] is zero // and a normal number when x[0] is 1.0 or greater a2double a2nan_var = ( a2one / a2inf_var ) / a2x[0]; // variable that is one when x[0] is zero // and less then one when x[0] is 1.0 or greater a2double a2one_var = a2one / ( a2one + a2x[0] ); // div a2y[i++] = CondExpGt(a2x[0], a2zero, a2nan_var, a2zero); // abs a2y[i++] = CondExpGt(a2x[0], a2zero, abs( a2y[0] ), a2zero); // add a2y[i++] = CondExpGt(a2x[0], a2zero, a2nan_var + a2nan_var, a2zero); // acos a2y[i++] = CondExpGt(a2x[0], a2zero, acos(a2switch), a2zero); // asin a2y[i++] = CondExpGt(a2x[0], a2zero, asin(a2switch), a2zero); // atan a2y[i++] = CondExpGt(a2x[0], a2zero, atan(a2nan_var), a2zero); // cos a2y[i++] = CondExpGt(a2x[0], a2zero, cos(a2nan_var), a2zero); // cosh a2y[i++] = CondExpGt(a2x[0], a2zero, cosh(a2nan_var), a2zero); // exp a2y[i++] = CondExpGt(a2x[0], a2zero, exp(a2nan_var), a2zero); // log a2y[i++] = CondExpGt(a2x[0], a2zero, log(a2x[0]), a2zero); // mul a2y[i++] = CondExpGt(a2x[0], a2zero, a2x[0] * a2inf_var, a2zero); // pow a2y[i++] = CondExpGt(a2x[0], a2zero, pow(a2inf_var, a2x[0]), a2zero); // sin a2y[i++] = CondExpGt(a2x[0], a2zero, sin(a2nan_var), a2zero); // sinh a2y[i++] = CondExpGt(a2x[0], a2zero, sinh(a2nan_var), a2zero); // sqrt a2y[i++] = CondExpGt(a2x[0], a2zero, sqrt(a2x[0]), a2zero); // sub a2y[i++] = CondExpGt(a2x[0], a2zero, a2inf_var - a2nan_var, a2zero); // tan a2y[i++] = CondExpGt(a2x[0], a2zero, tan(a2nan_var), a2zero); // tanh a2y[i++] = CondExpGt(a2x[0], a2zero, tanh(a2nan_var), a2zero); // azmul a2y[i++] = CondExpGt(a2x[0], a2zero, azmul(a2x[0], a2inf_var), a2zero); // // Operations that are C+11 atomic // // acosh a2y[i++] = CondExpGt(a2x[0], a2zero, acosh( a2x[0] ), a2zero); // asinh a2y[i++] = CondExpGt(a2x[0], a2zero, asinh( a2nan_var ), a2zero); // atanh a2y[i++] = CondExpGt(a2x[0], a2zero, atanh( a2one_var ), a2zero); // erf a2y[i++] = CondExpGt(a2x[0], a2zero, erf( a2nan_var ), a2zero); // expm1 a2y[i++] = CondExpGt(a2x[0], a2zero, expm1(a2nan_var), a2zero); // log1p a2y[i++] = CondExpGt(a2x[0], a2zero, log1p(- a2one_var ), a2zero); // ok &= i == m; CppAD::ADFun a1f; a1f.Dependent(a2x, a2y); // -------------------------------------------------------------------- // create h = f(x) vector a1x(n), a1y(m); a1x[0] = 5.0; // Independent(a1x); i = 0; a1double a1switch = a1one / (a1x[0] + a1double(0.5)); a1double a1inf_var = a1one / a1x[0]; a1double a1nan_var = ( a1one / a1inf_var ) / a1x[0]; a1double a1one_var = a1one / ( a1one + a1x[0] ); // div a1y[i++] = CondExpGt(a1x[0], a1zero, a1nan_var, a1zero); // abs a1y[i++] = CondExpGt(a1x[0], a1zero, abs( a1y[0] ), a1zero); // add a1y[i++] = CondExpGt(a1x[0], a1zero, a1nan_var + a1nan_var, a1zero); // acos a1y[i++] = CondExpGt(a1x[0], a1zero, acos(a1switch), a1zero); // asin a1y[i++] = CondExpGt(a1x[0], a1zero, asin(a1switch), a1zero); // atan a1y[i++] = CondExpGt(a1x[0], a1zero, atan(a1nan_var), a1zero); // cos a1y[i++] = CondExpGt(a1x[0], a1zero, cos(a1nan_var), a1zero); // cosh a1y[i++] = CondExpGt(a1x[0], a1zero, cosh(a1nan_var), a1zero); // exp a1y[i++] = CondExpGt(a1x[0], a1zero, exp(a1nan_var), a1zero); // log a1y[i++] = CondExpGt(a1x[0], a1zero, log(a1x[0]), a1zero); // mul a1y[i++] = CondExpGt(a1x[0], a1zero, a1x[0] * a1inf_var, a1zero); // pow a1y[i++] = CondExpGt(a1x[0], a1zero, pow(a1inf_var, a1x[0]), a1zero); // sin a1y[i++] = CondExpGt(a1x[0], a1zero, sin(a1nan_var), a1zero); // sinh a1y[i++] = CondExpGt(a1x[0], a1zero, sinh(a1nan_var), a1zero); // sqrt a1y[i++] = CondExpGt(a1x[0], a1zero, sqrt(a1x[0]), a1zero); // sub a1y[i++] = CondExpGt(a1x[0], a1zero, a1inf_var - a1nan_var, a1zero); // tan a1y[i++] = CondExpGt(a1x[0], a1zero, tan(a1nan_var), a1zero); // tanh a1y[i++] = CondExpGt(a1x[0], a1zero, tanh(a1nan_var), a1zero); // azmul a1y[i++] = CondExpGt(a1x[0], a1zero, azmul(a1x[0], a1inf_var), a1zero); // // Operations that are C+11 atomic // // acosh a1y[i++] = CondExpGt(a1x[0], a1zero, acosh( a1x[0] ), a1zero); // asinh a1y[i++] = CondExpGt(a1x[0], a1zero, asinh( a1nan_var ), a1zero); // atanh a1y[i++] = CondExpGt(a1x[0], a1zero, atanh( a1one_var ), a1zero); // erf a1y[i++] = CondExpGt(a1x[0], a1zero, erf( a1nan_var ), a1zero); // expm1 a1y[i++] = CondExpGt(a1x[0], a1zero, expm1(a1nan_var), a1zero); // log1p a1y[i++] = CondExpGt(a1x[0], a1zero, log1p(- a1one_var ), a1zero); // ok &= i == m; CppAD::ADFun h; h.Dependent(a1x, a1y); // -------------------------------------------------------------------- // create g = f'(x) vector a1dy(m), a1w(m); a1x[0] = 2.0; for(i = 0; i < m; i++) a1w[i] = 0.0; // Independent(a1x); a1f.Forward(0, a1x); // for(i = 0; i < m; i++) { a1w[i] = 1.0; vector dyi_dx = a1f.Reverse(1, a1w); a1dy[i] = dyi_dx[0]; a1w[i] = 0.0; } CppAD::ADFun g; // g uses reverse mode derivatives g.Dependent(a1x, a1dy); // -------------------------------------------------------------------- // check case where x[0] > 0 vector x(1), dx(1), dg(m), dh(m); x[0] = 2.0; dx[0] = 1.0; h.Forward(0, x); dh = h.Forward(1, dx); // dh uses forward mode derivatives dg = g.Forward(0, x); for(i = 0; i < m; i++) ok &= NearEqual(dg[i], dh[i], eps, eps); // -------------------------------------------------------------------- // check case where x[0] = 0 x[0] = 0.0; dg = g.Forward(0, x); h.Forward(0, x); dh = h.Forward(1, dx); for(i = 0; i < m; i++) { ok &= dg[i] == 0.0; ok &= dh[i] == 0.0; } // -------------------------------------------------------------------- return ok; } cppad-20160000.1/test_more/old_reciprocal.cpp0000644000175200017650000002510012656321775020121 0ustar coincoin-web// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin old_reciprocal.cpp$$ $section Old Atomic Operation Reciprocal: Example and Test$$ $head Deprecated 2013-05-27$$ This example has been deprecated; see $cref atomic_reciprocal.cpp$$ instead. $head Theory$$ The example below defines the user atomic function $latex f : \B{R}^n \rightarrow \B{R}^m$$ where $latex n = 1$$, $latex m = 1$$, and $latex f(x) = 1 / x$$. $code $verbatim%test_more/old_reciprocal.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include namespace { // Begin empty namespace using CppAD::vector; // ---------------------------------------------------------------------- // a utility to compute the union of two sets. void my_union( std::set& result , const std::set& left , const std::set& right ) { std::set temp; std::set_union( left.begin() , left.end() , right.begin() , right.end() , std::inserter(temp, temp.begin()) ); result.swap(temp); } // ---------------------------------------------------------------------- // forward mode routine called by CppAD bool reciprocal_forward( size_t id , size_t k , size_t n , size_t m , const vector& vx , vector& vy , const vector& tx , vector& ty ) { assert( id == 0 ); assert( n == 1 ); assert( m == 1 ); assert( k == 0 || vx.size() == 0 ); bool ok = false; double f, fp, fpp; // Must always define the case k = 0. // Do not need case k if not using f.Forward(q, xp) for q >= k. switch(k) { case 0: // this case must be implemented if( vx.size() > 0 ) vy[0] = vx[0]; // y^0 = f( x^0 ) = 1 / x^0 ty[0] = 1. / tx[0]; ok = true; break; case 1: // needed if first order forward mode is used assert( vx.size() == 0 ); // y^1 = f'( x^0 ) x^1 f = ty[0]; fp = - f / tx[0]; ty[1] = fp * tx[1]; ok = true; break; case 2: // needed if second order forward mode is used assert( vx.size() == 0 ); // Y''(t) = X'(t)^\R{T} f''[X(t)] X'(t) + f'[X(t)] X''(t) // 2 y^2 = x^1 * f''( x^0 ) x^1 + 2 f'( x^0 ) x^2 f = ty[0]; fp = - f / tx[0]; fpp = - 2.0 * fp / tx[0]; ty[2] = tx[1] * fpp * tx[1] / 2.0 + fp * tx[2]; ok = true; break; } return ok; } // ---------------------------------------------------------------------- // reverse mode routine called by CppAD bool reciprocal_reverse( size_t id , size_t k , size_t n , size_t m , const vector& tx , const vector& ty , vector& px , const vector& py ) { // Do not need case k if not using f.Reverse(k+1, w). assert( id == 0 ); assert( n == 1 ); assert( m == 1 ); bool ok = false; double f, fp, fpp, fppp; switch(k) { case 0: // needed if first order reverse mode is used // reverse: F^0 ( tx ) = y^0 = f( x^0 ) f = ty[0]; fp = - f / tx[0]; px[0] = py[0] * fp;; ok = true; break; case 1: // needed if second order reverse mode is used // reverse: F^1 ( tx ) = y^1 = f'( x^0 ) x^1 f = ty[0]; fp = - f / tx[0]; fpp = - 2.0 * fp / tx[0]; px[1] = py[1] * fp; px[0] = py[1] * fpp * tx[1]; // reverse: F^0 ( tx ) = y^0 = f( x^0 ); px[0] += py[0] * fp; ok = true; break; case 2: // needed if third order reverse mode is used // reverse: F^2 ( tx ) = y^2 = // = x^1 * f''( x^0 ) x^1 / 2 + f'( x^0 ) x^2 f = ty[0]; fp = - f / tx[0]; fpp = - 2.0 * fp / tx[0]; fppp = - 3.0 * fpp / tx[0]; px[2] = py[2] * fp; px[1] = py[2] * fpp * tx[1]; px[0] = py[2] * tx[1] * fppp * tx[1] / 2.0 + fpp * tx[2]; // reverse: F^1 ( tx ) = y^1 = f'( x^0 ) x^1 px[1] += py[1] * fp; px[0] += py[1] * fpp * tx[1]; // reverse: F^0 ( tx ) = y^0 = f( x^0 ); px[0] += py[0] * fp; ok = true; break; } return ok; } // ---------------------------------------------------------------------- // forward Jacobian sparsity routine called by CppAD bool reciprocal_for_jac_sparse( size_t id , size_t n , size_t m , size_t p , const vector< std::set >& r , vector< std::set >& s ) { // Can just return false if not using f.ForSparseJac assert( id == 0 ); assert( n == 1 ); assert( m == 1 ); // sparsity for S(x) = f'(x) * R is same as sparsity for R s[0] = r[0]; return true; } // ---------------------------------------------------------------------- // reverse Jacobian sparsity routine called by CppAD bool reciprocal_rev_jac_sparse( size_t id , size_t n , size_t m , size_t p , vector< std::set >& r , const vector< std::set >& s ) { // Can just return false if not using RevSparseJac. assert( id == 0 ); assert( n == 1 ); assert( m == 1 ); // sparsity for R(x) = S * f'(x) is same as sparsity for S for(size_t q = 0; q < p; q++) r[q] = s[q]; return true; } // ---------------------------------------------------------------------- // reverse Hessian sparsity routine called by CppAD bool reciprocal_rev_hes_sparse( size_t id , size_t n , size_t m , size_t p , const vector< std::set >& r , const vector& s , vector& t , const vector< std::set >& u , vector< std::set >& v ) { // Can just return false if not use RevSparseHes. assert( id == 0 ); assert( n == 1 ); assert( m == 1 ); // sparsity for T(x) = S(x) * f'(x) is same as sparsity for S t[0] = s[0]; // V(x) = [ f'(x)^T * g''(y) * f'(x) + g'(y) * f''(x) ] * R // U(x) = g''(y) * f'(x) * R // S(x) = g'(y) // back propagate the sparsity for U because derivative of // reciprocal may be non-zero v[0] = u[0]; // convert forward Jacobian sparsity to Hessian sparsity // because second derivative of reciprocal may be non-zero if( s[0] ) my_union(v[0], v[0], r[0] ); return true; } // --------------------------------------------------------------------- // Declare the AD routine reciprocal(id, ax, ay) CPPAD_USER_ATOMIC( reciprocal , CppAD::vector , double , reciprocal_forward , reciprocal_reverse , reciprocal_for_jac_sparse , reciprocal_rev_jac_sparse , reciprocal_rev_hes_sparse ) } // End empty namespace bool old_reciprocal(void) { bool ok = true; using CppAD::AD; using CppAD::NearEqual; double eps = 10. * CppAD::numeric_limits::epsilon(); // -------------------------------------------------------------------- // Create the function f(x) // // domain space vector size_t n = 1; double x0 = 0.5; vector< AD > ax(n); ax[0] = x0; // declare independent variables and start tape recording CppAD::Independent(ax); // range space vector size_t m = 1; vector< AD > ay(m); // call user function and store reciprocal(x) in au[0] vector< AD > au(m); size_t id = 0; // not used reciprocal(id, ax, au); // u = 1 / x // call user function and store reciprocal(u) in ay[0] reciprocal(id, au, ay); // y = 1 / u = x // create f: x -> y and stop tape recording CppAD::ADFun f; f.Dependent (ax, ay); // f(x) = x // -------------------------------------------------------------------- // Check forward mode results // // check function value double check = x0; ok &= NearEqual( Value(ay[0]) , check, eps, eps); // check zero order forward mode size_t q; vector x_q(n), y_q(m); q = 0; x_q[0] = x0; y_q = f.Forward(q, x_q); ok &= NearEqual(y_q[0] , check, eps, eps); // check first order forward mode q = 1; x_q[0] = 1; y_q = f.Forward(q, x_q); check = 1.; ok &= NearEqual(y_q[0] , check, eps, eps); // check second order forward mode q = 2; x_q[0] = 0; y_q = f.Forward(q, x_q); check = 0.; ok &= NearEqual(y_q[0] , check, eps, eps); // -------------------------------------------------------------------- // Check reverse mode results // // third order reverse mode q = 3; vector w(m), dw(n * q); w[0] = 1.; dw = f.Reverse(q, w); check = 1.; ok &= NearEqual(dw[0] , check, eps, eps); check = 0.; ok &= NearEqual(dw[1] , check, eps, eps); ok &= NearEqual(dw[2] , check, eps, eps); // -------------------------------------------------------------------- // forward mode sparstiy pattern size_t p = n; CppAD::vectorBool r1(n * p), s1(m * p); r1[0] = true; // compute sparsity pattern for x[0] s1 = f.ForSparseJac(p, r1); ok &= s1[0] == true; // f[0] depends on x[0] // -------------------------------------------------------------------- // reverse mode sparstiy pattern q = m; CppAD::vectorBool s2(q * m), r2(q * n); s2[0] = true; // compute sparsity pattern for f[0] r2 = f.RevSparseJac(q, s2); ok &= r2[0] == true; // f[0] depends on x[0] // -------------------------------------------------------------------- // Hessian sparsity (using previous ForSparseJac call) CppAD::vectorBool s3(m), h(p * n); s3[0] = true; // compute sparsity pattern for f[0] h = f.RevSparseHes(p, s3); ok &= h[0] == true; // second partial of f[0] w.r.t. x[0] may be non-zero // ----------------------------------------------------------------- // Free all temporary work space associated with old_atomic objects. // (If there are future calls to user atomic functions, they will // create new temporary work space.) CppAD::user_atomic::clear(); return ok; } // END C++ cppad-20160000.1/test_more/acos.cpp0000644000175200017650000000345412656321775016075 0ustar coincoin-web/* $Id: acos.cpp 3680 2015-05-07 19:17:37Z 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. -------------------------------------------------------------------------- */ /* Old acos examples now used just for valiadation testing */ # include bool acos(void) { bool ok = true; using CppAD::acos; using namespace CppAD; // 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], 1e-10 , 1e-10); // 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 *= j; w = f.Forward(j, v); ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j v[0] = 0.; value = 0.; } // reverse computation of partials of Taylor coefficients CPPAD_TESTVECTOR(double) r(p); w[0] = 1.; r = f.Reverse(p, w); jfac = 1.; value = 1.; for(j = 0; j < p; j++) { ok &= NearEqual(jfac*r[j], value, 1e-10 , 1e-10); // d^jz/du^j jfac *= (j + 1); value = 0.; } return ok; } cppad-20160000.1/test_more/checkpoint.cpp0000644000175200017650000001214612656321775017275 0ustar coincoin-web/* $Id: checkpoint.cpp 3718 2015-09-01 17:38:39Z 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. -------------------------------------------------------------------------- */ # include namespace { using CppAD::AD; typedef CPPAD_TESTVECTOR(AD) ADVector; bool f_algo(const ADVector& x, ADVector& y) { size_t n = x.size(); size_t m = y.size(); assert( n == 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 n = y.size(); size_t m = z.size(); assert( n + 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 / (p + 1 - k); } z_not = check_not.Forward(p, x_p); z_yes = check_yes.Forward(p, x_p); for(i = 0; i < m; i++) { for(k = 0; k <= p; k++) { double zik_not = z_not[ i * (p+1) + k]; double zik_yes = z_yes[ i * (p+1) + k]; ok &= NearEqual(zik_not, zik_yes, eps, eps); } } // compare reverse mode results CPPAD_TESTVECTOR(double) w(m*(p+1)), dw_not(n*(p+1)), dw_yes(n*(p+1)); dw_not = check_not.Reverse(p+1, w); dw_yes = check_yes.Reverse(p+1, w); for(j = 0; j < n; j++) { for(k = 0; k <= p; k++) { double dwjk_not = dw_not[ j * (p+1) + k]; double dwjk_yes = dw_yes[ j * (p+1) + k]; ok &= NearEqual(dwjk_not, dwjk_yes, eps, eps); } } // 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++ cppad-20160000.1/test_more/dbl_epsilon.cpp0000644000175200017650000000164612656321775017443 0ustar coincoin-web// $Id: dbl_epsilon.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* Check the value of machine epsilon is accurate enough for the correctness tests */ # include # include bool dbl_epsilon(void) { 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; return ok; } cppad-20160000.1/test_more/forward_order.cpp0000644000175200017650000001246312656321775020007 0ustar coincoin-web// $Id: forward_order.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 C++ # include namespace { 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] = abs( 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 = abs( x_i ) y[0] = CppAD::abs( 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; } // END C++ cppad-20160000.1/cppad_ipopt/0002755000175200017650000000000012656321775014741 5ustar coincoin-webcppad-20160000.1/cppad_ipopt/test/0002755000175200017650000000000012656321775015720 5ustar coincoin-webcppad-20160000.1/cppad_ipopt/test/CMakeLists.txt0000644000175200017650000000327012656321775020460 0ustar coincoin-web# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the cppad_ipopt/test directory tests # Inherit environment from ../CMakeList.txt # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # Local include directories to search (not in package_prefix/include) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) # Local link directories to search (not in external packages) LINK_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}/../src ${ipopt_LIBRARY_DIRS} ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(cppad_ipopt_test EXCLUDE_FROM_ALL test_more.cpp k_gt_one.cpp multiple_solution.cpp retape_k1_l1.cpp retape_k1_l2.cpp ) add_cppad_cxx_flags(cppad_ipopt_test) # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(cppad_ipopt_test cppad_ipopt ${cppad_lib} ${ipopt_LIBRARIES} ${colpack_libs} ) # Add the check_cppad_ipopt_test target ADD_CUSTOM_TARGET(check_cppad_ipopt_test cppad_ipopt_test DEPENDS cppad_ipopt_test cppad_ipopt ) cppad-20160000.1/cppad_ipopt/test/test.sh.in0000644000175200017650000000125612656321775017642 0ustar coincoin-web#! /bin/bash -e # $Id: test.sh.in 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. # ----------------------------------------------------------------------------- export LD_LIBRARY_PATH=@CPPAD_IPOPT_LD_PATH@ ./test_more cppad-20160000.1/cppad_ipopt/test/makefile.in0000644000175200017650000004677012656321775020041 0ustar coincoin-web# 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 = test_more$(EXEEXT) subdir = cppad_ipopt/test ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test.sh CONFIG_CLEAN_VPATH_FILES = am_test_more_OBJECTS = test_more.$(OBJEXT) k_gt_one.$(OBJEXT) \ multiple_solution.$(OBJEXT) retape_k1_l1.$(OBJEXT) \ retape_k1_l2.$(OBJEXT) test_more_OBJECTS = $(am_test_more_OBJECTS) test_more_LDADD = $(LDADD) am__DEPENDENCIES_1 = test_more_DEPENDENCIES = $(am__DEPENDENCIES_1) $(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 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 = $(test_more_SOURCES) DIST_SOURCES = $(test_more_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 $(srcdir)/test.sh.in \ $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ 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 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # EXTRA_DIST = test.sh.in # AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ -I$(top_srcdir)/cppad_ipopt/src \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # LDADD = \ -lcppad_ipopt \ $(CPPAD_IPOPT_LIBS) \ $(FCLIBS) \ $(PTHREAD_LIB) \ $(DL_LIB) AM_LDFLAGS = -L../src # test_more_SOURCES = \ test_more.cpp \ k_gt_one.cpp \ multiple_solution.cpp \ retape_k1_l1.cpp \ retape_k1_l2.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) --gnu cppad_ipopt/test/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu cppad_ipopt/test/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): test.sh: $(top_builddir)/config.status $(srcdir)/test.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ clean-checkPROGRAMS: -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) test_more$(EXEEXT): $(test_more_OBJECTS) $(test_more_DEPENDENCIES) $(EXTRA_test_more_DEPENDENCIES) @rm -f test_more$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(test_more_OBJECTS) $(test_more_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/k_gt_one.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multiple_solution.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/retape_k1_l1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/retape_k1_l2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_more.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 ./test.sh # 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: cppad-20160000.1/cppad_ipopt/test/test_more.cpp0000644000175200017650000000420112656321775020420 0ustar coincoin-web// $Id: test_more.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // system include files used for I/O # include // C style asserts # include // CppAD include file # include // external complied tests extern bool k_gt_one(void); extern bool multiple_solution(void); extern bool retape_k1_l1(void); extern bool retape_k1_l2(void); namespace { // function that runs one test static size_t Run_ok_count = 0; static size_t Run_error_count = 0; bool Run(bool TestOk(void), const char *name) { bool ok = true; ok &= TestOk(); if( ok ) { std::cout << "OK: " << name << std::endl; Run_ok_count++; } else { std::cout << "Error: " << name << std::endl; Run_error_count++; } return ok; } } // main program that runs all the tests int main(void) { bool ok = true; // external compiled tests ok &= Run( k_gt_one, "k_get_one" ); ok &= Run( multiple_solution, "multiple_solution" ); ok &= Run( retape_k1_l1, "retape_k1_l1" ); ok &= Run( retape_k1_l2, "retape_k1_l2" ); // check for errors using std::cout; using std::endl; assert( ok || (Run_error_count > 0) ); if( CppAD::thread_alloc::free_all() ) { Run_ok_count++; cout << "OK: " << "No memory leak detected" << endl; } else { ok = false; Run_error_count++; cout << "Error: " << "memory leak detected" << endl; } // convert int(size_t) to avoid warning on _MSC_VER systems if( ok ) cout << "All " << int(Run_ok_count) << " tests passed." << endl; else cout << int(Run_error_count) << " tests failed." << endl; return static_cast( ! ok ); } cppad-20160000.1/cppad_ipopt/test/k_gt_one.cpp0000644000175200017650000001205112656321775020206 0ustar coincoin-web// $Id: k_gt_one.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. -------------------------------------------------------------------------- */ # include namespace { // Begin empty namespace using namespace cppad_ipopt; // --------------------------------------------------------------------------- /* This solve the same problem as ../cppad_ipopt/cppad_ipopt_simple.cpp (repository revision 1276) in a convoluted way in order to test the representation code. */ class FG_K_gt_one : public cppad_ipopt_fg_info { private: bool retape_; public: // derived class part of constructor FG_K_gt_one(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& u) { // Fortran style indexing ADNumber x1 = u[3]; ADNumber x2 = u[2]; ADNumber x3 = u[1]; ADNumber x4 = u[0]; if( k == 0 ) { ADVector r(1); // f(x) r[0] = x1 * x4 * (x1 + x2 + x3) + x3; return r; } ADVector r(2); // g_1 (x) r[0] = x1 * x2 * x3 * x4; // g_2 (x) r[1] = x1 * x1 + x2 * x2 + x3 * x3 + x4 * x4; return r; } bool retape(size_t k) { return retape_; } size_t number_functions(void) { return 2; } size_t domain_size(size_t k) { return 4; } size_t range_size(size_t k) { if( k == 0 ) return 1; return 2; } size_t number_terms(size_t k) { return 1; } void index(size_t k, size_t ell, SizeVector& I, SizeVector& J) { if( k == 0 ) I[0] = 0; else { I[0] = 1; I[1] = 2; } // reverse the order of the variables in u from that in x for(size_t j = 0; j < 4; j++) J[j] = 3-j; } }; } // end empty namespace bool k_gt_one(void) { bool ok = true; size_t j; // number of independent variables (domain dimension for f and g) size_t n = 4; // 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; // known solution to check against double check_x[] = { 1.000000, 4.743000, 3.82115, 1.379408 }; 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 = bool(icase); // check case where upper and lower limits are equal if( icase == 1 ) { x_l[2] = check_x[2]; x_u[2] = check_x[2]; } // object in derived class FG_K_gt_one my_fg_info(retape); cppad_ipopt_fg_info *fg_info = &my_fg_info; // create the Ipopt interface cppad_ipopt_solution solution; Ipopt::SmartPtr 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 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"); // 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_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; } cppad-20160000.1/cppad_ipopt/test/multiple_solution.cpp0000644000175200017650000000742412656321775022220 0ustar coincoin-web// $Id: multiple_solution.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 { // Begin empty namespace using namespace cppad_ipopt; // --------------------------------------------------------------------------- /* f(x) = x[1]; k=0, ell=0, I[0] = 0, J[0] = 1 g_0 (x) = x[0]; k=0, ell=1, I[0] = 1, J[0] = 0 g_1 (x) = x[1]; k=0, ell=2, I[0] = 2, J[0] = 1 minimize f(x) subject to -1 <= g_0(x) <= 0 0 <= g_1 (x) <= 1 The solution is x[1] = 0 and x[0] arbitrary. */ class FG_J_changes : public cppad_ipopt_fg_info { private: bool retape_; public: // constructor FG_J_changes(bool retape_in) : retape_ (retape_in) { } size_t number_functions(void) { return 1; } size_t domain_size(size_t k) { size_t q; switch(k) { case 0: q = 1; break; default: assert(0); } return q; } size_t range_size(size_t k) { size_t p; switch(k) { case 0: p = 1; break; default: assert(0); } return p; } size_t number_terms(size_t k) { size_t L; switch(k) { case 0: L = 3; break; default: assert(0); } return L; } void index(size_t k, size_t ell, SizeVector&I, SizeVector& J) { assert( I.size() >= 1 ); assert( J.size() >= 1 ); I[0] = ell; if( ell == 0 ) { J[0] = 1; return; } J[0] = ell - 1; return; } // retape function bool retape(size_t k) { return retape_; } ADVector eval_r(size_t k, const ADVector& u) { assert( u.size() == 1 ); ADVector r(1); r[0] = u[0] ; return r; } }; } // end empty namespace bool multiple_solution(void) { bool ok = true; // number of independent variables (domain dimension for f and g) size_t n = 2; // number of constraints (range dimension for g) size_t m = 2; // initial value of the independent variables NumberVector x_i(n); NumberVector x_l(n); NumberVector x_u(n); size_t i = 0; for(i = 0; i < n; i++) { x_i[i] = 0.; x_l[i] = -1.0; x_u[i] = +1.0; } // lower and upper limits for g NumberVector g_l(m); NumberVector g_u(m); g_l[0] = -1; g_u[0] = 0.; g_l[1] = 0.; g_u[1] = 1.; // object for evaluating function bool retape = false; FG_J_changes my_fg_info(retape); cppad_ipopt_fg_info *fg_info = &my_fg_info; cppad_ipopt_solution solution; Ipopt::SmartPtr 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 app = new IpoptApplication(); // turn off any printing app->Options()->SetIntegerValue("print_level", 0); app->Options()->SetStringValue("sb", "yes"); // 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); app->Options()-> SetStringValue("derivative_test", "second-order"); // 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 solution status */ ok &= solution.status == cppad_ipopt_solution::success; ok &= CppAD::NearEqual(solution.x[1], 0., 1e-6, 1e-6); return ok; } cppad-20160000.1/cppad_ipopt/test/retape_k1_l1.cpp0000644000175200017650000000654112656321775020677 0ustar coincoin-web// $Id: retape_k1_l1.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. -------------------------------------------------------------------------- */ # include namespace { // Begin empty namespace using namespace cppad_ipopt; // --------------------------------------------------------------------------- class FG_retape : public cppad_ipopt_fg_info { public: // derived class part of constructor FG_retape(void) { } // 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(2); // f(x) if( x[0] >= 1. ) fg[0] = .5 * (x[0] * x[0] + x[1] * x[1]); else fg[0] = x[0] + .5 * x[1] * x[1]; // g (x) fg[1] = x[0]; return fg; } bool retape(size_t k) { return true; } }; } // end of empty namespace bool retape_k1_l1(void) { bool ok = true; size_t j; // number of independent variables (domain dimension for f and g) size_t n = 2; // number of constraints (range dimension for g) size_t m = 1; // initial value of the independent variables NumberVector x_i(n); x_i[0] = 2.0; x_i[1] = 2.0; // lower and upper limits for x NumberVector x_l(n); NumberVector x_u(n); for(j = 0; j < n; j++) { x_l[j] = -10.; x_u[j] = +10.; } // lower and upper limits for g NumberVector g_l(m); NumberVector g_u(m); g_l[0] = -1.; g_u[0] = 1.0e19; // object in derived class FG_retape fg_retape; cppad_ipopt_fg_info *fg_info = &fg_retape; // create the Ipopt interface cppad_ipopt_solution solution; Ipopt::SmartPtr 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 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"); // 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., 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 ); } return ok; } cppad-20160000.1/cppad_ipopt/test/makefile.am0000644000175200017650000000250212656321775020011 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 = # EXTRA_DIST = test.sh.in # check_PROGRAMS = test_more # AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ -I$(top_srcdir)/cppad_ipopt/src \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # LDADD = \ -lcppad_ipopt \ $(CPPAD_IPOPT_LIBS) \ $(FCLIBS) \ $(PTHREAD_LIB) \ $(DL_LIB) AM_LDFLAGS = -L../src # test_more_SOURCES = \ test_more.cpp \ k_gt_one.cpp \ multiple_solution.cpp \ retape_k1_l1.cpp \ retape_k1_l2.cpp test: check ./test.sh cppad-20160000.1/cppad_ipopt/test/retape_k1_l2.cpp0000644000175200017650000000735712656321775020706 0ustar coincoin-web// $Id: retape_k1_l2.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. -------------------------------------------------------------------------- */ # include namespace { // Begin empty namespace using namespace cppad_ipopt; // --------------------------------------------------------------------------- /* A test case were retaping is required, no constraints, and L[0] > 1. */ class FG_info : public cppad_ipopt_fg_info { public: // derived class part of constructor FG_info (void) { } // r_0 (u) = u if u > 1 and u^2 otherwise. ADVector eval_r(size_t k, const ADVector& u) { ADVector r(1); if( u[0] > 1 ) r[0] = u[0]; else r[0] = u[0] * u[0]; return r; } // operation sequence depends on u bool retape(size_t k) { return true; } // K = 1 size_t number_functions(void) { return 1; } // q[k] = 1 size_t domain_size(size_t k) { return 1; } // p[k] = 1 size_t range_size(size_t k) { return 1; } // L[k] = 2 size_t number_terms(size_t k) { return 2; } // I_{k,ell} = 0 // objective function index // J_{k,ell} = ell // argument index void index(size_t k, size_t ell, SizeVector& I, SizeVector& J) { I[0] = 0; J[0] = ell; } }; } // end empty namespace bool retape_k1_l2(void) { bool ok = true; size_t j; // number of independent variables (domain dimension for f and g) size_t n = 2; // no constraints (range dimension for g) size_t m = 0; // initial value of the independent variables NumberVector x_i(n); x_i[0] = 0.0; // below break in eval_r definition x_i[1] = 2.0; // above break in eval_r definition // lower and upper limits for x NumberVector x_l(n); NumberVector x_u(n); for(j = 0; j < n; j++) { x_l[j] = -5.0; x_u[j] = +5.0; } // lower and upper limits for g NumberVector g_l; NumberVector g_u; // object in derived class FG_info my_fg_info; cppad_ipopt_fg_info *fg_info = &my_fg_info; // create the Ipopt interface cppad_ipopt_solution solution; Ipopt::SmartPtr 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 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 the solution values */ ok &= solution.status == cppad_ipopt_solution::success; // double rel_tol = 1e-6; // relative tolerance double abs_tol = 1e-6; // absolute tolerance for(j = 0; j < n; j++) ok &= CppAD::NearEqual( 0., solution.x[j], rel_tol, abs_tol); return ok; } cppad-20160000.1/cppad_ipopt/speed/0002755000175200017650000000000012656321775016041 5ustar coincoin-webcppad-20160000.1/cppad_ipopt/speed/CMakeLists.txt0000644000175200017650000000366012656321775020604 0ustar coincoin-web# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the cppad_ipopt/speed directory tests # Inherit environment from ../CMakeList.txt # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE RELEASE) # Local include directories to search (not in package_prefix/include) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) # Local link directories to search (not in external packages) # (cannot use ../src/cppad_ipopt library because it is linke with debugging) LINK_DIRECTORIES( ${ipopt_LIBRARY_DIRS} ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) # Include source for cppad_ipopt library so we build it without debugging ADD_EXECUTABLE(cppad_ipopt_speed EXCLUDE_FROM_ALL speed.cpp ../src/cppad_ipopt_nlp.cpp ../src/fun_record.hpp ../src/hes_fg_map.cpp ../src/jac_g_map.cpp ../src/sparse_map2vec.cpp ../src/vec_fun_pattern.cpp ode_speed.cpp ) # Add extra compiler flags add_cppad_cxx_flags( cppad_ipopt_speed ) # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES( cppad_ipopt_speed cppad_ipopt ${cppad_lib} ${ipopt_LIBRARIES} ${colpack_libs} ) # Add the check_cppad_ipopt_speed target ADD_CUSTOM_TARGET(check_cppad_ipopt_speed cppad_ipopt_speed DEPENDS cppad_ipopt_speed cppad_ipopt ) cppad-20160000.1/cppad_ipopt/speed/test.sh.in0000644000175200017650000000125212656321775017757 0ustar coincoin-web#! /bin/bash -e # $Id: test.sh.in 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. # ----------------------------------------------------------------------------- export LD_LIBRARY_PATH=@CPPAD_IPOPT_LD_PATH@ ./speed cppad-20160000.1/cppad_ipopt/speed/speed.cpp0000644000175200017650000000303512656321775017644 0ustar coincoin-web// $Id: speed.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 // system include files used for I/O # include // std::string // external complied tests extern double ode_speed(const char* name, size_t& count); // main program that runs all the cppad_ipopt speed tests int main(void) { using std::printf; const char* name; double seconds; size_t count; name = "simple_retape_yes"; seconds = ode_speed(name, count); printf("ode %20s: seconds = %5.2f: eval_r_count = %d\n", name, seconds, int(count) ); name = "simple_retape_no"; seconds = ode_speed(name, count); printf("ode %20s: seconds = %5.2f: eval_r_count = %d\n", name, seconds, int(count) ); name = "fast_retape_yes"; seconds = ode_speed(name, count); printf("ode %20s: seconds = %5.2f: eval_r_count = %d\n", name, seconds, int(count) ); name = "fast_retape_no"; seconds = ode_speed(name, count); printf("ode %20s: seconds = %5.2f: eval_r_count = %d\n", name, seconds, int(count) ); return 0; } cppad-20160000.1/cppad_ipopt/speed/makefile.in0000644000175200017650000005226312656321775020154 0ustar coincoin-web# 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 = speed$(EXEEXT) subdir = cppad_ipopt/speed ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test.sh CONFIG_CLEAN_VPATH_FILES = am__dirstamp = $(am__leading_dot)dirstamp am_speed_OBJECTS = speed.$(OBJEXT) ../src/cppad_ipopt_nlp.$(OBJEXT) \ ../src/hes_fg_map.$(OBJEXT) ../src/jac_g_map.$(OBJEXT) \ ../src/sparse_map2vec.$(OBJEXT) \ ../src/vec_fun_pattern.$(OBJEXT) ode_speed.$(OBJEXT) speed_OBJECTS = $(am_speed_OBJECTS) speed_LDADD = $(LDADD) am__DEPENDENCIES_1 = speed_DEPENDENCIES = $(am__DEPENDENCIES_1) $(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 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 = $(speed_SOURCES) DIST_SOURCES = $(speed_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 $(srcdir)/test.sh.in \ $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ 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 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # EXTRA_DIST = test.sh.in # # 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) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # LDADD = \ -lcppad_ipopt \ $(CPPAD_IPOPT_LIBS) \ $(FCLIBS) \ $(PTHREAD_LIB) \ $(DL_LIB) AM_LDFLAGS = -L../src # # Cannot use ../src/libcppad_ipopt.a becasue it is compiled for debugging # so build an optimized version here to use here. speed_SOURCES = \ speed.cpp \ ../src/cppad_ipopt_nlp.cpp \ ../src/fun_record.hpp \ ../src/hes_fg_map.cpp \ ../src/jac_g_map.cpp \ ../src/sparse_map2vec.cpp \ ../src/vec_fun_pattern.cpp \ ode_speed.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) --gnu cppad_ipopt/speed/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu cppad_ipopt/speed/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): test.sh: $(top_builddir)/config.status $(srcdir)/test.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 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/cppad_ipopt_nlp.$(OBJEXT): ../src/$(am__dirstamp) \ ../src/$(DEPDIR)/$(am__dirstamp) ../src/hes_fg_map.$(OBJEXT): ../src/$(am__dirstamp) \ ../src/$(DEPDIR)/$(am__dirstamp) ../src/jac_g_map.$(OBJEXT): ../src/$(am__dirstamp) \ ../src/$(DEPDIR)/$(am__dirstamp) ../src/sparse_map2vec.$(OBJEXT): ../src/$(am__dirstamp) \ ../src/$(DEPDIR)/$(am__dirstamp) ../src/vec_fun_pattern.$(OBJEXT): ../src/$(am__dirstamp) \ ../src/$(DEPDIR)/$(am__dirstamp) speed$(EXEEXT): $(speed_OBJECTS) $(speed_DEPENDENCIES) $(EXTRA_speed_DEPENDENCIES) @rm -f speed$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(speed_OBJECTS) $(speed_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f ../src/*.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@../src/$(DEPDIR)/cppad_ipopt_nlp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@../src/$(DEPDIR)/hes_fg_map.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@../src/$(DEPDIR)/jac_g_map.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@../src/$(DEPDIR)/sparse_map2vec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@../src/$(DEPDIR)/vec_fun_pattern.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_speed.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/speed.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) -rm -f ../src/$(DEPDIR)/$(am__dirstamp) -rm -f ../src/$(am__dirstamp) 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 ../src/$(DEPDIR) ./$(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 ../src/$(DEPDIR) ./$(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 ./test.sh # 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: cppad-20160000.1/cppad_ipopt/speed/ode_speed.cpp0000644000175200017650000000456012656321775020477 0ustar coincoin-web// $Id: ode_speed.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 ipopt_ode_speed.cpp$$ $section Speed Test for Both Simple and Fast Representations$$ $code $verbatim%cppad_ipopt/speed/ode_speed.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include "../example/ode_run.hpp" # include "../example/ode_simple.hpp" # include "../example/ode_fast.hpp" # include # include # if CPPAD_HAS_GETTIMEOFDAY & CPPAD_NO_MICROSOFT # include # else # include # 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(retape, N, x); else ipopt_ode_case(retape, N, x); s1 = current_second(); c1 = count_eval_r(); count = c1 - c0 - 1; return s1 - s0; } // END C++ cppad-20160000.1/cppad_ipopt/speed/makefile.am0000644000175200017650000000313412656321775020134 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 = # EXTRA_DIST = test.sh.in # check_PROGRAMS = speed # # 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) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # LDADD = \ -lcppad_ipopt \ $(CPPAD_IPOPT_LIBS) \ $(FCLIBS) \ $(PTHREAD_LIB) \ $(DL_LIB) AM_LDFLAGS = -L../src # # Cannot use ../src/libcppad_ipopt.a becasue it is compiled for debugging # so build an optimized version here to use here. speed_SOURCES = \ speed.cpp \ ../src/cppad_ipopt_nlp.cpp \ ../src/fun_record.hpp \ ../src/hes_fg_map.cpp \ ../src/jac_g_map.cpp \ ../src/sparse_map2vec.cpp \ ../src/vec_fun_pattern.cpp \ ode_speed.cpp test: check ./test.sh cppad-20160000.1/cppad_ipopt/src/0002755000175200017650000000000012656321775015530 5ustar coincoin-webcppad-20160000.1/cppad_ipopt/src/CMakeLists.txt0000644000175200017650000000303612656321775020270 0ustar coincoin-web# $Id: CMakeLists.txt 3754 2015-11-26 22:23:05Z 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. # ----------------------------------------------------------------------------- # Build the cppad_ipopt/src library # Inherit environment from ../CMakeList.txt # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # add_library( [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN) # ) ADD_LIBRARY(cppad_ipopt cppad_ipopt_nlp.cpp hes_fg_map.cpp jac_g_map.cpp sparse_map2vec.cpp vec_fun_pattern.cpp ) # Add extra compiler flags add_cppad_cxx_flags( cppad_ipopt ) # install(FILES files... DESTINATION # [PERMISSIONS permissions...] # [CONFIGURATIONS [Debug|Release|...]] # [COMPONENT ] # [RENAME ] [OPTIONAL]) INSTALL(FILES cppad_ipopt_nlp.hpp DESTINATION ${cppad_abs_includedir}) # install(TARGETS myExe mySharedLib myStaticLib # RUNTIME DESTINATION bin # LIBRARY DESTINATION lib # ARCHIVE DESTINATION lib/static) INSTALL(TARGETS cppad_ipopt DESTINATION ${cppad_abs_libdir}) cppad-20160000.1/cppad_ipopt/src/hes_fg_map.hpp0000644000175200017650000000363312656321775020334 0ustar coincoin-web// $Id: hes_fg_map.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_HES_FG_MAP_HPP # define CPPAD_HES_FG_MAP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include "cppad_ipopt_nlp.hpp" /*! \file hes_fg_map.hpp \brief Create a mapping between two representations for Hessian of fg. \ingroup hes_fg_map_cpp */ // --------------------------------------------------------------------------- namespace cppad_ipopt { // --------------------------------------------------------------------------- extern void hes_fg_map( cppad_ipopt_fg_info* fg_info , size_t m , size_t n , size_t K , const CppAD::vector& L , const CppAD::vector& p , const CppAD::vector& q , const CppAD::vector& pattern_hes_r , CppAD::vector& I , CppAD::vector& J , CppAD::vector< std::map >& index_hes_fg ); // --------------------------------------------------------------------------- } // end namespace cppad_ipopt // --------------------------------------------------------------------------- # endif cppad-20160000.1/cppad_ipopt/src/sparse_map2vec.hpp0000644000175200017650000000264512656321775021160 0ustar coincoin-web// $Id: sparse_map2vec.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_SPARSE_MAP2VEC_HPP # define CPPAD_SPARSE_MAP2VEC_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // --------------------------------------------------------------------------- namespace cppad_ipopt { // --------------------------------------------------------------------------- /*! \file sparse_map2vec.hpp \brief Create a two vector sparsity representation from a vector of maps. \ingroup sparese_map2vec_cpp */ extern void sparse_map2vec( const CppAD::vector< std::map > sparse, size_t& n_nz , CppAD::vector& i_row , CppAD::vector& j_col ); // --------------------------------------------------------------------------- } // end namespace cppad_ipopt // --------------------------------------------------------------------------- # endif cppad-20160000.1/cppad_ipopt/src/cppad_ipopt_nlp.hpp0000644000175200017650000010221312656321775021411 0ustar coincoin-web// $Id: cppad_ipopt_nlp.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_CPPAD_IPOPT_NLP_HPP # define CPPAD_CPPAD_IPOPT_NLP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin cppad_ipopt_nlp$$ $dollar @$$ $spell libipopt namespace dir cppad bool doesn't nan inf naninf std maxiter infeasibility obj const optimizer cppad_ipopt_nlp.hpp fg_info.eval retape CppAD $$ $section Nonlinear Programming Using the CppAD Interface to Ipopt$$ $mindex AD$$ $head Deprecated 2012-11-28$$ This interface to Ipopt is deprecated, use $cref ipopt_solve$$ instead. $head Syntax$$ $codei%# include "cppad_ipopt_nlp.hpp" %$$ $codei%cppad_ipopt_solution %solution%; %$$ $codei%cppad_ipopt_nlp %cppad_nlp%( %n%, %m%, %x_i%, %x_l%, %x_u%, %g_l%, %g_u%, &%fg_info%, &%solution% )%$$ $codei% export LD_LIBRARY_PATH=@LD_LIBRARY_PATH:%ipopt_library_paths%$$ $head Purpose$$ The class $code cppad_ipopt_nlp$$ is used to solve nonlinear programming problems of the form $latex \[ \begin{array}{rll} {\rm minimize} & f(x) \\ {\rm subject \; to} & g^l \leq g(x) \leq g^u \\ & x^l \leq x \leq x^u \end{array} \] $$ This is done using $href% http://www.coin-or.org/projects/Ipopt.xml% Ipopt %$$ optimizer and $href% http://www.coin-or.org/CppAD/% CppAD %$$ Algorithmic Differentiation package. $head cppad_ipopt namespace$$ All of the declarations for these routines are in the $code cppad_ipopt$$ namespace (not the $code CppAD$$ namespace). For example; $cref/SizeVector/cppad_ipopt_nlp/SizeVector/$$ below actually denotes the type $code cppad_ipopt::SizeVector$$. $head ipopt_library_paths$$ If you are linking to a shared version of the Ipopt library, you may have to add some paths the $code LD_LIBRARY_PATH$$ shell variable using the $code export$$ command in the syntax above. For example, if the file the ipopt library is $codei% %ipopt_prefix%/lib64/libipopt.a %$$ you will need to add the corresponding directory; e.g., $codei% export LD_LIBRARY_PATH="%ipopt_prefix%/lib64%:@LD_LIBRARY_PATH" %$$ see $cref ipopt_prefix$$. $head fg(x)$$ The function $latex fg : \B{R}^n \rightarrow \B{R}^{m+1}$$ is defined by $latex \[ \begin{array}{rcl} fg_0 (x) & = & f(x) \\ fg_1 (x) & = & g_0 (x) \\ & \vdots & \\ fg_m (x) & = & g_{m-1} (x) \end{array} \] $$ $subhead Index Vector$$ We define an $icode 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 $latex I$$ is an index vector $latex |I|$$ is used to denote the number of elements in $latex I$$ and $latex \| I \|$$ is used to denote the value of the maximum element in $latex I$$. $subhead Projection$$ Given an index vector $latex J$$ and a positive integer $latex n$$ where $latex n > \| J \|$$, we use $latex J \otimes n $$ for the mapping $latex ( J \otimes n ) : \B{R}^n \rightarrow \B{R}^{|J|}$$ defined by $latex \[ [ J \otimes n ] (x)_j = x_{J(j)} \] $$ for $latex j = 0 , \ldots |J| - 1$$. $subhead Injection$$ Given an index vector $latex I$$ and a positive integer $latex m$$ where $latex m > \| I \|$$, we use $latex m \otimes I$$ for the mapping $latex ( m \otimes I ): \B{R}^{|I|} \rightarrow \B{R}^m$$ defined by $latex \[ [ m \otimes I ] (y)_i = \left\{ \begin{array}{ll} y_k & {\rm if} \; i = I(k) \; {\rm for \; some} \; k \in \{ 0 , \cdots, |I|-1 \} \\ 0 & {\rm otherwise} \end{array} \right. \] $$ $subhead Representation$$ In many applications, each of the component functions of $latex fg(x)$$ only depend on a few of the components of $latex x$$. In this case, expressing $latex fg(x)$$ in terms of simpler functions with fewer arguments can greatly reduce the amount of work required to compute its derivatives. $pre $$ We use the functions $latex r_k : \B{R}^{q(k)} \rightarrow \B{R}^{p(k)}$$ for $latex k = 0 , \ldots , K$$ to express our representation of $latex fg(x)$$ in terms of simpler functions as follows $latex \[ fg(x) = \sum_{k=0}^{K-1} \; \sum_{\ell=0}^{L(k) - 1} [ (m+1) \otimes I_{k,\ell} ] \; \circ \; r_k \; \circ \; [ J_{k,\ell} \otimes n ] \; (x) \] $$ where $latex \circ$$ represents function composition, for $latex k = 0 , \ldots , K - 1$$, and $latex \ell = 0 , \ldots , L(k)$$, $latex I_{k,\ell}$$ and $latex J_{k,\ell}$$ are index vectors with $latex | J_{k,\ell} | = q(k)$$, $latex \| J_{k,\ell} \| < n$$, $latex | I_{k,\ell} | = p(k)$$, and $latex \| I_{k,\ell} \| \leq m$$. $head Simple Representation$$ In the simple representation, $latex r_0 (x) = fg(x)$$, $latex K = 1$$, $latex q(0) = n$$, $latex p(0) = m+1$$, $latex L(0) = 1$$, $latex I_{0,0} = (0 , \ldots , m)$$, and $latex J_{0,0} = (0 , \ldots , n-1)$$. $head SizeVector$$ The type $codei SizeVector$$ is defined by the $codei cppad_ipopt_nlp.hpp$$ include file to be a $cref SimpleVector$$ class with elements of type $code size_t$$. $head NumberVector$$ The type $codei NumberVector$$ is defined by the $codei cppad_ipopt_nlp.hpp$$ include file to be a $cref SimpleVector$$ class with elements of type $code Ipopt::Number$$. $head ADNumber$$ The type $codei ADNumber$$ is defined by the $codei cppad_ipopt_nlp.hpp$$ include file to be a an AD type that can be used to compute derivatives. $head ADVector$$ The type $codei ADVector$$ is defined by the $codei cppad_ipopt_nlp.hpp$$ include file to be a $cref SimpleVector$$ class with elements of type $code ADNumber$$. $head n$$ The argument $icode n$$ has prototype $codei% size_t %n% %$$ It specifies the dimension of the argument space; i.e., $latex x \in \B{R}^n$$. $head m$$ The argument $icode m$$ has prototype $codei% size_t %m% %$$ It specifies the dimension of the range space for $latex g$$; i.e., $latex g : \B{R}^n \rightarrow \B{R}^m$$. $head x_i$$ The argument $icode x_i$$ has prototype $codei% const NumberVector& %x_i% %$$ and its size is equal to $latex n$$. It specifies the initial point where Ipopt starts the optimization process. $head x_l$$ The argument $icode x_l$$ has prototype $codei% const NumberVector& %x_l% %$$ and its size is equal to $latex n$$. It specifies the lower limits for the argument in the optimization problem; i.e., $latex x^l$$. $head x_u$$ The argument $icode x_u$$ has prototype $codei% const NumberVector& %x_u% %$$ and its size is equal to $latex n$$. It specifies the upper limits for the argument in the optimization problem; i.e., $latex x^u$$. $head g_l$$ The argument $icode g_l$$ has prototype $codei% const NumberVector& %g_l% %$$ and its size is equal to $latex m$$. It specifies the lower limits for the constraints in the optimization problem; i.e., $latex g^l$$. $head g_u$$ The argument $icode g_u$$ has prototype $codei% const NumberVector& %g_u% %$$ and its size is equal to $latex n$$. It specifies the upper limits for the constraints in the optimization problem; i.e., $latex g^u$$. $head fg_info$$ The argument $icode fg_info$$ has prototype $codei% %FG_info fg_info% %$$ where the class $icode FG_info$$ is derived from the base class $code cppad_ipopt_fg_info$$. Certain virtual member functions of $icode fg_info$$ are used to compute the value of $latex fg(x)$$. The specifications for these member functions are given below: $subhead fg_info.number_functions$$ This member function has prototype $codei% virtual size_t cppad_ipopt_fg_info::number_functions(void) %$$ If $icode K$$ has type $code size_t$$, the syntax $codei% %K% = %fg_info%.number_functions() %$$ sets $icode K$$ to the number of functions used in the representation of $latex fg(x)$$; i.e., $latex K$$ in the $cref/representation/cppad_ipopt_nlp/fg(x)/Representation/$$ above. $pre $$ The $code cppad_ipopt_fg_info$$ implementation of this function corresponds to the simple representation mentioned above; i.e. $icode%K% = 1%$$. $subhead fg_info.eval_r$$ This member function has the prototype $codei% virtual ADVector cppad_ipopt_fg_info::eval_r(size_t %k%, const ADVector& %u%) = 0; %$$ Thus it is a pure virtual function and must be defined in the derived class $icode FG_info$$. $pre $$ This function computes the value of $latex r_k (u)$$ used in the $cref/representation/cppad_ipopt_nlp/fg(x)/Representation/$$ for $latex fg(x)$$. If $icode k$$ in $latex \{0 , \ldots , K-1 \}$$ has type $code size_t$$, $icode u$$ is an $code ADVector$$ of size $icode q(k)$$ and $icode r$$ is an $code ADVector$$ of size $icode p(k)$$ the syntax $codei% %r% = %fg_info%.eval_r(%k%, %u%) %$$ set $icode r$$ to the vector $latex r_k (u)$$. $subhead fg_info.retape$$ This member function has the prototype $codei% virtual bool cppad_ipopt_fg_info::retape(size_t %k%) %$$ If $icode k$$ in $latex \{0 , \ldots , K-1 \}$$ has type $code size_t$$, and $icode retape$$ has type $code bool$$, the syntax $codei% %retape% = %fg_info%.retape(%k%) %$$ sets $icode retape$$ to true or false. If $icode retape$$ is true, $code cppad_ipopt_nlp$$ will retape the operation sequence corresponding to $latex r_k (u)$$ for every value of $icode u$$. An $code cppad_ipopt_nlp$$ object should use much less memory and run faster if $icode retape$$ is false. You can test both the true and false cases to make sure the operation sequence does not depend on $icode u$$. $pre $$ The $code cppad_ipopt_fg_info$$ implementation of this function sets $icode retape$$ to true (while slower it is also safer to always retape). $subhead fg_info.domain_size$$ This member function has prototype $codei% virtual size_t cppad_ipopt_fg_info::domain_size(size_t %k%) %$$ If $icode k$$ in $latex \{0 , \ldots , K-1 \}$$ has type $code size_t$$, and $icode q$$ has type $code size_t$$, the syntax $codei% %q% = %fg_info%.domain_size(%k%) %$$ sets $icode q$$ to the dimension of the domain space for $latex r_k (u)$$; i.e., $latex q(k)$$ in the $cref/representation/cppad_ipopt_nlp/fg(x)/Representation/$$ above. $pre $$ The $code cppad_ipopt_h_base$$ implementation of this function corresponds to the simple representation mentioned above; i.e., $latex q = n$$. $subhead fg_info.range_size$$ This member function has prototype $codei% virtual size_t cppad_ipopt_fg_info::range_size(size_t %k%) %$$ If $icode k$$ in $latex \{0 , \ldots , K-1 \}$$ has type $code size_t$$, and $icode p$$ has type $code size_t$$, the syntax $codei% %p% = %fg_info%.range_size(%k%) %$$ sets $icode p$$ to the dimension of the range space for $latex r_k (u)$$; i.e., $latex p(k)$$ in the $cref/representation/cppad_ipopt_nlp/fg(x)/Representation/$$ above. $pre $$ The $code cppad_ipopt_h_base$$ implementation of this function corresponds to the simple representation mentioned above; i.e., $latex p = m+1$$. $subhead fg_info.number_terms$$ This member function has prototype $codei% virtual size_t cppad_ipopt_fg_info::number_terms(size_t %k%) %$$ If $icode k$$ in $latex \{0 , \ldots , K-1 \}$$ has type $code size_t$$, and $icode L$$ has type $code size_t$$, the syntax $codei% %L% = %fg_info%.number_terms(%k%) %$$ sets $icode L$$ to the number of terms in representation for this value of $icode k$$; i.e., $latex L(k)$$ in the $cref/representation/cppad_ipopt_nlp/fg(x)/Representation/$$ above. $pre $$ The $code cppad_ipopt_h_base$$ implementation of this function corresponds to the simple representation mentioned above; i.e., $latex L = 1$$. $subhead fg_info.index$$ This member function has prototype $codei% virtual void cppad_ipopt_fg_info::index( size_t %k%, size_t %ell%, SizeVector& %I%, SizeVector& %J% ) %$$ The argument $icode% k %$$ has type $codei size_t$$ and is a value between zero and $latex K-1$$ inclusive. The argument $icode% ell %$$ has type $codei size_t$$ and is a value between zero and $latex L(k)-1$$ inclusive. The argument $icode% I %$$ is a $cref SimpleVector$$ with elements of type $code size_t$$ and size greater than or equal to $latex p(k)$$. The input value of the elements of $icode I$$ does not matter. The output value of the first $latex p(k)$$ elements of $icode I$$ must be the corresponding elements of $latex I_{k,ell}$$ in the $cref/representation/cppad_ipopt_nlp/fg(x)/Representation/$$ above. The argument $icode% J %$$ is a $cref SimpleVector$$ with elements of type $code size_t$$ and size greater than or equal to $latex q(k)$$. The input value of the elements of $icode J$$ does not matter. The output value of the first $latex q(k)$$ elements of $icode J$$ must be the corresponding elements of $latex J_{k,ell}$$ in the $cref/representation/cppad_ipopt_nlp/fg(x)/Representation/$$ above. $pre $$ The $code cppad_ipopt_h_base$$ implementation of this function corresponds to the simple representation mentioned above; i.e., for $latex i = 0 , \ldots , m$$, $icode%I%[%i%] = %i%$$, and for $latex j = 0 , \ldots , n-1$$, $icode%J%[%j%] = %j%$$. $head 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% 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: $table $icode status$$ $cnext Meaning $rnext not_defined $cnext The optimizer did not return a final status to this $code cppad_ipopt_nlp$$ object. $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% NumberVector %solution%.x %$$ and its size is equal to $latex n$$. It is the final $latex x$$ value for the optimizer. $subhead z_l$$ The $code z_l$$ field of $icode solution$$ has prototype $codei% NumberVector %solution%.z_l %$$ and its size is equal to $latex n$$. It is the final Lagrange multipliers for the lower bounds on $latex x$$. $subhead z_u$$ The $code z_u$$ field of $icode solution$$ has prototype $codei% NumberVector %solution%.z_u %$$ and its size is equal to $latex n$$. 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% NumberVector %solution%.g %$$ and its size is equal to $latex m$$. It is the final value for the constraint function $latex g(x)$$. $subhead lambda$$ The $code lambda$$ field of $icode solution$$ has prototype $codei% NumberVector %solution%.lambda %$$ and its size is equal to $latex m$$. 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% Number %solution%.obj_value %$$ It is the final value of the objective function $latex f(x)$$. $children% cppad_ipopt/example/get_started.cpp% cppad_ipopt/example/ode1.omh% cppad_ipopt/speed/ode_speed.cpp %$$ $head Example$$ The file $cref ipopt_nlp_get_started.cpp$$ is an example and test of $code cppad_ipopt_nlp$$ that uses the $cref/simple representation/cppad_ipopt_nlp/Simple Representation/$$. It returns true if it succeeds and false otherwise. The section $cref ipopt_nlp_ode$$ discusses an example that uses a more complex representation. $head Wish List$$ This is a list of possible future improvements to $code cppad_ipopt_nlp$$ that would require changed to the user interface: $list number$$ The routine $codei%fg_info.eval_r(%k%, %u%)%$$ should also support $codei NumberVector$$ for the type of the argument $code u$$ (this would certainly be more efficient when $codei%fg_info.retape(%k%)%$$ is true and $latex L(k) > 1$$). It could be an option for the user to provide this as well as the necessary $code ADVector$$ definition. $lnext There should a $cref Discrete$$ routine that the user can call to determine the value of $latex \ell$$ during the evaluation of $codei%fg_info.eval_r(%k%, %u%)%$$. This way data, which does not affect the derivative values, can be included in the function recording and evaluation. $lend $end ----------------------------------------------------------------------------- */ # include # include # include /*! \file cppad_ipopt_nlp.hpp \brief CppAD interface to Ipopt \ingroup cppad_ipopt_nlp_cpp */ // --------------------------------------------------------------------------- namespace cppad_ipopt { // --------------------------------------------------------------------------- /// A scalar value used to record operation sequence. typedef CppAD::AD ADNumber; /// A simple vector of values used to record operation sequence typedef CppAD::vector ADVector; /// A simple vector of size_t values. typedef CppAD::vector SizeVector; /// A simple vector of values used by Ipopt typedef CppAD::vector NumberVector; /*! Abstract base class user derives from to define the funcitons in the problem. */ class cppad_ipopt_fg_info { /// allow cppad_ipopt_nlp class complete access to this class friend class cppad_ipopt_nlp; private: /// domain space dimension for the functions f(x), g(x) size_t n_; /// range space dimension for the function g(x) size_t m_; /// the cppad_ipopt_nlp constructor uses this method to set n_ void set_n(size_t n) { n_ = n; } /// the cppad_ipopt_nlp constructor uses this method to set m_ void set_m(size_t m) { m_ = m; } public: /// destructor virtual so user derived class destructor gets called virtual ~cppad_ipopt_fg_info(void) { } /// number_functions; i.e. K (simple representation uses 1) virtual size_t number_functions(void) { return 1; } /// function that evaluates the users representation for f(x) and /// and g(x) is pure virtual so user must define it in derived class virtual ADVector eval_r(size_t k, const ADVector& u) = 0; /// should the function r_k (u) be retaped when ever the arguemnt /// u changes (default is true which is safe but slow) virtual bool retape(size_t k) { return true; } /// domain_size q[k] for r_k (u) (simple representation uses n) virtual size_t domain_size(size_t k) { return n_; } /// range_size p[k] for r_k (u) (simple representation uses m+1) virtual size_t range_size(size_t k) { return m_ + 1; } /// number_terms that use r_k (u) (simple represenation uses 1) virtual size_t number_terms(size_t k) { return 1; } /// return the index vectors I_{k,ell} and J_{k,ell} /// (simple representation uses I[i] = i and J[j] = j) virtual void index(size_t k, size_t ell, SizeVector& I, SizeVector& J) { assert( I.size() >= m_ + 1 ); assert( J.size() >= n_ ); for(size_t i = 0; i <= m_; i++) I[i] = i; for(size_t j = 0; j < n_; j++) J[j] = j; } }; /*! Class that contains information about the problem solution \section Nonlinear_Programming_Problem Nonlinear Programming Problem We are give smooth functions \f$ f : {\bf R}^n \rightarrow {\bf R} \f$ and \f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ and wish to solve the problem \f[ \begin{array}{rcl} {\rm minimize} & f(x) & {\rm w.r.t.} \; x \in {\bf R}^n \\ {\rm subject \; to} & g^l \leq g(x) \leq g^u \\ & x^l \leq x \leq x^u \end{array} \f] \section Users_Representation Users Representation The functions \f$ f : {\bf R}^n \rightarrow {\bf R} \f$ and \f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ are defined by \f[ \left( \begin{array}{c} f(x) \\ g(x) \end{array} \right) = \sum_{k=0}^{K-1} \; \sum_{\ell=0}^{L(k) - 1} [ (m+1) \otimes I_{k,\ell} ] \; \circ \; r_k \; \circ \; [ J_{k,\ell} \otimes n ] \; (x) \f] where for \f$ k = 0 , \ldots , K-1\f$, \f$ r_k : {\bf R}^{q(k)} \rightarrow {\bf R}^{p(k)} \f$. \section Deprecated_Evaluation_Methods Evaluation Methods The set of evaluation methods for this class is \verbatim { eval_f, eval_grad_f, eval_g, eval_jac_g, eval_h } \endverbatim Note that the \c bool return flag for the evaluations methods does not appear in the Ipopt documentation. Looking at the code, it seems to be a flag telling Ipopt to abort when the flag is false. */ class cppad_ipopt_solution { public: /// possible values for he solution status enum solution_status { 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 } status; /// the approximation solution NumberVector x; /// Lagrange multipliers corresponding to lower bounds on x NumberVector z_l; /// Lagrange multipliers corresponding to upper bounds on x NumberVector z_u; /// value of g(x) NumberVector g; /// Lagrange multipliers correspondiing constraints on g(x) NumberVector lambda; /// value of f(x) Ipopt::Number obj_value; /// constructor initializes solution status as not yet defined cppad_ipopt_solution(void) { status = not_defined; } }; /*! Class connects Ipopt to CppAD for derivative and sparsity pattern calculations. */ class cppad_ipopt_nlp : public Ipopt::TNLP { private: /// 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; /// A simple vector of boolean values typedef CppAD::vectorBool BoolVector; /// A simple vector of AD function objects typedef CppAD::vector< CppAD::ADFun > ADFunVector; /// A simple vector of simple vectors of boolean values typedef CppAD::vector BoolVectorVector; /// A mapping that is dense in i, sparse in j, and maps (i, j) /// to the corresponding sparsity index in Ipopt. typedef CppAD::vector< std::map > IndexMap; // ------------------------------------------------------------------ // Values directly passed in to constuctor // ------------------------------------------------------------------ /// dimension of the domain space for f(x) and g(x) /// (passed to ctor) const size_t n_; /// dimension of the range space for g(x) /// (passed to ctor) const size_t m_; /// dimension of the range space for g(x) /// (passed to ctor) const NumberVector x_i_; /// lower limit for x /// (size n_), (passed to ctor) const NumberVector x_l_; /// upper limit for x /// (size n_) (passed to ctor) const NumberVector x_u_; /// lower limit for g(x) /// (size m_) (passed to ctor) const NumberVector g_l_; /// upper limit for g(x) /// (size m_) (passed to ctor) const NumberVector g_u_; /// pointer to base class version of derived class object used to get /// information about the user's representation for f(x) and g(x) /// (passed to ctor) cppad_ipopt_fg_info* const fg_info_; /// pointer to object where final results are stored /// (passed to ctor) cppad_ipopt_solution* const solution_; /// plus infinity as a value of type Number const Number infinity_; // ------------------------------------------------------------------ // Effectively const values determined during constructor using calls // to fg_info: // ------------------------------------------------------------------ /// The value of \f$ K \f$ in the representation. /// (effectively const) size_t K_; /// Does operation sequence for \f$ r_k (u) \f$ depend on \f$ u \f$. /// (size K_) (effectively const) BoolVector retape_; /// q_[k] is the domain space dimension for \f$ r_k (u) \f$ /// (size K_) (effectively const) SizeVector q_; /// p_[k] is the range space dimension for \f$ r_k (u) \f$ /// (size K_) (effectively const) SizeVector p_; /// L_[k] is number of times \f$ r_k (u) \f$ appears in /// the representation summation /// (size K_) (effectively const) SizeVector L_; // ------------------------------------------------------------------- // Other effectively const values determined by the constructor: // ------------------------------------------------------------------- /*! CppAD sparsity patterns for \f$ \{ r_k^{(1)} (u) \} \f$ (set by ctor). For k = 0 , ... , K_-1, pattern_jac_r_[k] is a CppAD sparsity pattern for the Jacobian of \f$ r_k (u) \f$ and as such it has size p_[k]*q_[k]. (effectively const) */ BoolVectorVector pattern_jac_r_; /*! CppAD sparsity patterns for \f$ \{ r_k^{(2)} (u) \} \f$ (set by ctor). For k = 0 , ... , K_-1, pattern_jac_r_[k] is a CppAD sparsity pattern for the Hessian of \f[ R(u) = \sum_{i=0}^{p[k]-1} r_k (u)_i \f] and as such it has size q_[k]*q_[k]. (effectively const) */ BoolVectorVector pattern_hes_r_; /// number non-zero is Ipopt sparsity structor for Jacobian of g(x) /// (effectively const) size_t nnz_jac_g_; /// row indices in Ipopt sparsity structor for Jacobian of g(x) /// (effectively const) SizeVector iRow_jac_g_; /// column indices in Ipopt sparsity structor for Jacobian of g(x) /// (effectively const) SizeVector jCol_jac_g_; /// number non-zero is Ipopt sparsity structor for Hessian of Lagragian /// (effectively const) size_t nnz_h_lag_; /// row indices in Ipopt sparsity structor for Hessian of Lagragian /// (effectively const) SizeVector iRow_h_lag_; /// column indices in Ipopt sparsity structor for Hessian of Lagragian /// (effectively const) SizeVector jCol_h_lag_; /*! Mapping from (i, j) in Jacobian of g(x) to Ipopt sparsity structure For i = 0 , ... , m_-1, index_jac_g_[i] is a standard map from column index values \c j to the corresponding index in the Ipopt sparsity structure for the Jacobian of g(x). */ IndexMap index_jac_g_; /*! Mapping from (i, j) in Hessian of fg(x) to Ipopt sparsity structure For i = 0 , ... , n_-1, index_hes_fg_[i] is a standard map from column index values \c j to the corresponding index in the Ipopt sparsity structure for the Hessian of the Lagragian. */ IndexMap index_hes_fg_; // ----------------------------------------------------------------- // Values that are changed by routine other than the constructor: // ----------------------------------------------------------------- /// For k = 0 , ... , K_-1, r_fun_[k] /// is a the CppAD function object corresponding to \f$ r_k (u) \f$. ADFunVector r_fun_; /*! Is r_fun[k] OK for current x. For k = 0 , ... , K_-1, tape_ok_[k] is true if current operations sequence in r_fun_[k] OK for this value of \f$ x \f$. Note that \f$ u = [ J_{k,\ell} \otimes n ] (x) \f$ may depend on the value of \f$ \ell \f$. */ BoolVector tape_ok_; /// work space of size equal maximum of q[k] w.r.t \c k. SizeVector J_; /// work space of size equal maximum of p[k] w.r.t \c k. SizeVector I_; // ------------------------------------------------------------ // Private Methods // ------------------------------------------------------------ /// block the default constructor from use cppad_ipopt_nlp(const cppad_ipopt_nlp&); /// blocks the assignment operator from use cppad_ipopt_nlp& operator=(const cppad_ipopt_nlp&); public: // ---------------------------------------------------------------- // See cppad_ipopt_nlp.cpp for doxygen documentation of these methods // ---------------------------------------------------------------- /// only constructor for cppad_ipopot_nlp cppad_ipopt_nlp( size_t n , size_t m , const NumberVector &x_i , const NumberVector &x_l , const NumberVector &x_u , const NumberVector &g_l , const NumberVector &g_u , cppad_ipopt_fg_info* fg_info , cppad_ipopt_solution* solution ); // use virtual so that derived class destructor gets called. virtual ~cppad_ipopt_nlp(); // return info about the nlp virtual bool get_nlp_info( Index& n , Index& m , Index& nnz_jac_g , Index& nnz_h_lag , IndexStyleEnum& index_style ); // return bounds for my problem virtual bool get_bounds_info( Index n , Number* x_l , Number* x_u , Index m , Number* g_l , Number* g_u ); // return the starting point for the algorithm 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 ); // return the objective value virtual bool eval_f( Index n , const Number* x , bool new_x , Number& obj_value ); // Method to return the gradient of the objective virtual bool eval_grad_f( Index n , const Number* x , bool new_x , Number* grad_f ); // return the constraint residuals virtual bool eval_g( Index n , const Number* x , bool new_x , Index m , Number* g ); // Method to return: // 1) The structure of the jacobian (if "values" is NULL) // 2) The values of the jacobian (if "values" is not NULL) virtual bool eval_jac_g( Index n , const Number* x , bool new_x , Index m , Index nele_jac , Index* iRow , Index* jCol , Number* values ); // Method to return: // 1) structure of hessian of the lagrangian (if "values" is NULL) // 2) values of hessian of the lagrangian (if "values" is not NULL) virtual bool eval_h( Index n , const Number* x , bool new_x , Number obj_factor , Index m , const Number* lambda , bool new_lambda , Index nele_hess , Index* iRow , Index* jCol , Number* values ); // called when the algorithm is completed so the TNLP can // store/write the solution virtual void finalize_solution( Ipopt::SolverReturn status , Index n , const Number* x , const Number* z_L , const Number* z_U , Index m , const Number* g , const Number* lambda , Number obj_value , const Ipopt::IpoptData* ip_data , Ipopt::IpoptCalculatedQuantities* ip_cq ); virtual bool intermediate_callback( Ipopt::AlgorithmMode mode, Index iter, Number obj_value, Number inf_pr, Number inf_du, Number mu, Number d_norm, Number regularization_size, Number alpha_du, Number alpha_pr, Index ls_trials, const Ipopt::IpoptData* ip_data, Ipopt::IpoptCalculatedQuantities* ip_cq ); }; // --------------------------------------------------------------------------- } // end namespace cppad_ipopt // --------------------------------------------------------------------------- # endif cppad-20160000.1/cppad_ipopt/src/jac_g_map.cpp0000644000175200017650000001336012656321775020135 0ustar coincoin-web// $Id: jac_g_map.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 "cppad_ipopt_nlp.hpp" # include "jac_g_map.hpp" // --------------------------------------------------------------------------- namespace cppad_ipopt { // --------------------------------------------------------------------------- /*! \{ \file jac_g_map.cpp \brief Creates a mapping between two representations for Jacobian of g. */ /*! Create mapping from CppAD to Ipopt sparse representations of Jacobian of g. The functions \f$ f : {\bf R}^n \rightarrow {\bf R} \f$ and \f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ are defined by the \ref Users_Representation. \param fg_info For k = 0 , ... , K-1, for ell = 0 , ... , L[k], the function call \verbatim fg_info->index(k, ell, I, J); \endverbatim is made by \c jac_g_map. The values \c k and \c ell are inputs. The input size of \c I ( \c J ) is greater than or equal p[k] ( q[k] ) and this size is not changed. The input values of the elements of \c I and \c J are not specified. The output value of the elements of \c I define \f[ I_{k, \ell} = ( {\rm I[0]} , \cdots , {\rm I[p[k]-1]} ) \f] The output value of the elements of \c J define \f[ J_{k, \ell} = ( {\rm J[0]} , \cdots , {\rm J[q[k]-1]} ) \f] \param m is the dimension of the range space for \f$ g(x) \f$; i.e., \f$ g(x) \in {\bf R}^m \f$. \param n is the dimension of the domain space for \f$ f(x) \f$ and \f$ g(x) \f$; i.e., \f$ x \in {\bf R}^n \f$. \param K is the number of functions \f$ r_k ( u ) \f$ used for the representation of \f$ f(x) \f$ and \f$ g(x) \f$. \param L is a vector with size \c K. For k = 0 , ... , K-1, L[k] is the number of terms that use \f$ r_k (u) \f$ in the representation of \f$ f(x) \f$ and \f$ g(x) \f$. \param p is a vector with size \c K. For k = 0 , ... , K-1, p[k] is dimension of the range space for \f$ r_k (u) \f$; i.e., \f$ r_k (u) \in {\bf R}^{p(k)} \f$. \param q is a vector with size \c K. For k = 0 , ... , K-1, q[k] is dimension of the domain space for \f$ r_k (u) \f$; i.e., \f$ u \in {\bf R}^{q(k)} \f$. \param pattern_jac_r is a vector with size \c K. For k = 0 , ... , K-1, pattern_jac_r[k] is a CppAD sparsity pattern for the Jacobian of the function \f$ r_k : {\bf R}^{q(k)} \rightarrow {\bf R}^{p(k)} \f$. As such, pattern_jac_r[k].size() == p[k] * q[k]. \param I is a work vector of length greater than or equal p[k] for all \c k. The input and output value of its elements are unspecified. The size of \c I is not changed. \param J is a work vector of length greater than or equal q[k] for all \c k. The input and output value of its elements are unspecified. The size of \c J is not changed. \param index_jac_g: On input, this is empty; i.e., index_jac_g.size() == 0. On output, it is the index mapping from \f$ (i, j) \f$ in the Jacobian of \f$ g(x) \f$ to the corresponding index value used by Ipopt to represent the Jacobian. Furthermore, if index_jac_g[i].find(j) == index_jac_g[i].end(), then the \f$ (i, j)\f$ entry in the Jacobian of \f$ g(x) \f$ is always zero. */ void jac_g_map( cppad_ipopt_fg_info* fg_info , size_t m , size_t n , size_t K , const CppAD::vector& L , const CppAD::vector& p , const CppAD::vector& q , const CppAD::vector& pattern_jac_r , CppAD::vector& I , CppAD::vector& J , CppAD::vector< std::map >& index_jac_g ) { using CppAD::vectorBool; size_t i, j, ij, k, ell; CPPAD_ASSERT_UNKNOWN( K == L.size() ); CPPAD_ASSERT_UNKNOWN( K == p.size() ); CPPAD_ASSERT_UNKNOWN( K == q.size() ); CPPAD_ASSERT_UNKNOWN( K == pattern_jac_r.size() ); # ifndef NDEBUG for(k = 0; k < K; k++) { CPPAD_ASSERT_UNKNOWN( p[k] <= I.size() ); CPPAD_ASSERT_UNKNOWN( q[k] <= J.size() ); CPPAD_ASSERT_UNKNOWN( p[k]*q[k] == pattern_jac_r[k].size() ); } # endif // Now compute pattern for g // (use standard set representation because can be huge). CppAD::vector< std::set > pattern_jac_g(m); for(k = 0; k < K; k++) for(ell = 0; ell < L[k]; ell++) { fg_info->index(k, ell, I, J); for(i = 0; i < p[k]; i++) if( I[i] != 0 ) { for(j = 0; j < q[k]; j++) { ij = i * q[k] + j; if( pattern_jac_r[k][ij] ) pattern_jac_g[I[i]-1].insert(J[j]); } } } // Now compute the mapping from (i, j) in the Jacobian of g to the // corresponding index value used by Ipopt to represent the Jacobian. CPPAD_ASSERT_UNKNOWN( index_jac_g.size() == 0 ); index_jac_g.resize(m); std::set::const_iterator itr; ell = 0; for(i = 0; i < m; i++) { for( itr = pattern_jac_g[i].begin(); itr != pattern_jac_g[i].end(); itr++) { index_jac_g[i][*itr] = ell++; } } return; } // --------------------------------------------------------------------------- } // end namespace cppad_ipopt // --------------------------------------------------------------------------- cppad-20160000.1/cppad_ipopt/src/makefile.in0000644000175200017650000005542112656321775017642 0ustar coincoin-web# 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@ subdir = cppad_ipopt/src 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__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LIBRARIES = $(lib_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 = libcppad_ipopt_a_AR = $(AR) $(ARFLAGS) libcppad_ipopt_a_LIBADD = am__libcppad_ipopt_a_SOURCES_DIST = cppad_ipopt_nlp.cpp \ cppad_ipopt_nlp.hpp fun_record.hpp hes_fg_map.cpp \ hes_fg_map.hpp jac_g_map.cpp jac_g_map.hpp sparse_map2vec.cpp \ sparse_map2vec.hpp vec_fun_pattern.cpp vec_fun_pattern.hpp @CppAD_IPOPT_TRUE@am_libcppad_ipopt_a_OBJECTS = \ @CppAD_IPOPT_TRUE@ cppad_ipopt_nlp.$(OBJEXT) \ @CppAD_IPOPT_TRUE@ hes_fg_map.$(OBJEXT) jac_g_map.$(OBJEXT) \ @CppAD_IPOPT_TRUE@ sparse_map2vec.$(OBJEXT) \ @CppAD_IPOPT_TRUE@ vec_fun_pattern.$(OBJEXT) libcppad_ipopt_a_OBJECTS = $(am_libcppad_ipopt_a_OBJECTS) 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 = $(libcppad_ipopt_a_SOURCES) DIST_SOURCES = $(am__libcppad_ipopt_a_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 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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 = -g $(CXX_FLAGS) # AM_CPPFLAGS = \ -I. \ -I$(top_srcdir) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # # make building the library conditional on having IPOPT_DIR specified @CppAD_IPOPT_TRUE@lib_LIBRARIES = libcppad_ipopt.a @CppAD_IPOPT_TRUE@libcppad_ipopt_a_SOURCES = \ @CppAD_IPOPT_TRUE@ cppad_ipopt_nlp.cpp \ @CppAD_IPOPT_TRUE@ cppad_ipopt_nlp.hpp \ @CppAD_IPOPT_TRUE@ fun_record.hpp \ @CppAD_IPOPT_TRUE@ hes_fg_map.cpp \ @CppAD_IPOPT_TRUE@ hes_fg_map.hpp \ @CppAD_IPOPT_TRUE@ jac_g_map.cpp \ @CppAD_IPOPT_TRUE@ jac_g_map.hpp \ @CppAD_IPOPT_TRUE@ sparse_map2vec.cpp \ @CppAD_IPOPT_TRUE@ sparse_map2vec.hpp \ @CppAD_IPOPT_TRUE@ vec_fun_pattern.cpp \ @CppAD_IPOPT_TRUE@ vec_fun_pattern.hpp 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) --gnu cppad_ipopt/src/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu cppad_ipopt/src/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): install-libLIBRARIES: $(lib_LIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(INSTALL_DATA) $$list2 '$(DESTDIR)$(libdir)'"; \ $(INSTALL_DATA) $$list2 "$(DESTDIR)$(libdir)" || exit $$?; } @$(POST_INSTALL) @list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ if test -f $$p; then \ $(am__strip_dir) \ echo " ( cd '$(DESTDIR)$(libdir)' && $(RANLIB) $$f )"; \ ( cd "$(DESTDIR)$(libdir)" && $(RANLIB) $$f ) || exit $$?; \ else :; fi; \ done uninstall-libLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(libdir)'; $(am__uninstall_files_from_dir) clean-libLIBRARIES: -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) libcppad_ipopt.a: $(libcppad_ipopt_a_OBJECTS) $(libcppad_ipopt_a_DEPENDENCIES) $(EXTRA_libcppad_ipopt_a_DEPENDENCIES) $(AM_V_at)-rm -f libcppad_ipopt.a $(AM_V_AR)$(libcppad_ipopt_a_AR) libcppad_ipopt.a $(libcppad_ipopt_a_OBJECTS) $(libcppad_ipopt_a_LIBADD) $(AM_V_at)$(RANLIB) libcppad_ipopt.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppad_ipopt_nlp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hes_fg_map.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jac_g_map.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_map2vec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vec_fun_pattern.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 check: check-am all-am: makefile $(LIBRARIES) installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done 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-generic clean-libLIBRARIES 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-libLIBRARIES 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: uninstall-libLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libLIBRARIES 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-libLIBRARIES 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 uninstall-libLIBRARIES .PRECIOUS: makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: cppad-20160000.1/cppad_ipopt/src/vec_fun_pattern.cpp0000644000175200017650000001207512656321775021421 0ustar coincoin-web// $Id: vec_fun_pattern.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 "cppad_ipopt_nlp.hpp" # include "vec_fun_pattern.hpp" // --------------------------------------------------------------------------- namespace cppad_ipopt { // --------------------------------------------------------------------------- /*! \{ \file vec_fun_pattern.cpp \brief Determine a sparsity pattern for a vector of AD function objects. */ /*! Determine a sparsity patterns for each function in a vector of functions. \param K is the number of functions that we are computing the sparsity pattern for. \param p is a vector with size \c K. For k = 0 , ... , K-1, p[k] is dimension of the range space for \f$ r_k (u) \f$; i.e., \f$ r_k (u) \in {\bf R}^{p(k)} \f$. \param q is a vector with size \c K. For k = 0 , ... , K-1, q[k] is dimension of the domain space for \f$ r_k (u) \f$; i.e., \f$ u \in {\bf R}^{q(k)} \f$. \param retape is a vector with size \c K. For k = 0 , ... , K-1, if retape[k] is true, the function object r[k] is a valid representation for \f$ r_k (u) \f$ for all \f$ u \in {\bf R}^{q(k)} \f$. Otherwise, the function object must be retaped for each value of \f$ u \f$. \param r_fun is the vector of AD function objects which has size size \c K. For k = 0 , ... , K-1, if retape[k] is true, r_fun[k] is not used. If retape[k] is false, r_fun[k] is not used. is a CppAD function object correspopnding to the function \f$ r_k : {\bf R}^{q[k]} \rightarrow {\bf R}^{p[k]} \f$. The following non-constant member functions will be called: \verbatim r_fun[k].ForSparseJac(q[k], pattern_domain) r_fun[k].RevSparseHes(p[k], pattern_range) \endverbatim The following \c const member functions r_fun[k].Range() and r_fun[k].Domain() may also be called. \param pattern_jac_r is a vector with size \c K. On input, For k = 0 , ... , K-1, pattern_jac_r[k] is a vector of length p[k] * q[k] and the value of its elements does not matter. On output it is a CppAD sparsity pattern for the Jacobian of \f$ r_k (u) \f$. \param pattern_hes_r is a vector with size \c K. On input, For k = 0 , ... , K-1, pattern_hes_r[k] is a vector of length q[k] * q[k] and the value of its elements does not matter. On output it is a CppAD sparsity pattern for the Hessian of \f$ R : {\bf R}^{q[k]} \rightarrow {\bf R} \f$ which is defined by \f[ R(u) = \sum_{i=0}^{p[k]-1} r_k (u)_i \f] */ void vec_fun_pattern( size_t K , const CppAD::vector& p , const CppAD::vector& q , const CppAD::vectorBool& retape , CppAD::vector< CppAD::ADFun >& r_fun , CppAD::vector& pattern_jac_r , CppAD::vector& pattern_hes_r ) { // check some assumptions CPPAD_ASSERT_UNKNOWN( K == p.size() ); CPPAD_ASSERT_UNKNOWN( K == q.size() ); CPPAD_ASSERT_UNKNOWN( K == retape.size() ); CPPAD_ASSERT_UNKNOWN( K == r_fun.size() ); CPPAD_ASSERT_UNKNOWN( K == pattern_jac_r.size() ); CPPAD_ASSERT_UNKNOWN( K == pattern_hes_r.size() ); using CppAD::vectorBool; size_t i, j, k; for(k = 0; k < K; k++) { // check some k specific assumptions CPPAD_ASSERT_UNKNOWN( pattern_jac_r[k].size() == p[k] * q[k] ); CPPAD_ASSERT_UNKNOWN( pattern_hes_r[k].size() == q[k] * q[k] ); if( retape[k] ) { for(i = 0; i < p[k]; i++) { for(j = 0; j < q[k]; j++) pattern_jac_r[k][i*q[k] + j] = true; } for(i = 0; i < q[k]; i++) { for(j = 0; j < q[k]; j++) pattern_hes_r[k][i*q[k] + j] = true; } } else { // check assumptions about r_k CPPAD_ASSERT_UNKNOWN( r_fun[k].Range() == p[k] ); CPPAD_ASSERT_UNKNOWN( r_fun[k].Domain() == q[k] ); // pattern for the identity matrix CppAD::vectorBool pattern_domain(q[k] * q[k]); for(i = 0; i < q[k]; i++) { for(j = 0; j < q[k]; j++) pattern_domain[i*q[k] + j] = (i == j); } // use forward mode to compute Jacobian sparsity pattern_jac_r[k] = r_fun[k].ForSparseJac(q[k], pattern_domain); // user reverse mode to compute Hessian sparsity CppAD::vectorBool pattern_ones(p[k]); for(i = 0; i < p[k]; i++) pattern_ones[i] = true; pattern_hes_r[k] = r_fun[k].RevSparseHes(q[k], pattern_ones); } } } // --------------------------------------------------------------------------- } // end namespace cppad_ipopt // --------------------------------------------------------------------------- cppad-20160000.1/cppad_ipopt/src/jac_g_map.hpp0000644000175200017650000000362412656321775020144 0ustar coincoin-web// $Id: jac_g_map.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_JAC_G_MAP_HPP # define CPPAD_JAC_G_MAP_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include "cppad_ipopt_nlp.hpp" /*! \file jac_g_map.hpp \brief Create a mapping between two representations for Jacobian of g. \ingroup jac_g_map_cpp */ // --------------------------------------------------------------------------- namespace cppad_ipopt { // --------------------------------------------------------------------------- extern void jac_g_map( cppad_ipopt_fg_info* fg_info , size_t m , size_t n , size_t K , const CppAD::vector& L , const CppAD::vector& p , const CppAD::vector& q , const CppAD::vector& pattern_jac_r , CppAD::vector& I , CppAD::vector& J , CppAD::vector< std::map >& index_jac_g ); // --------------------------------------------------------------------------- } // end namespace cppad_ipopt // --------------------------------------------------------------------------- # endif cppad-20160000.1/cppad_ipopt/src/vec_fun_pattern.hpp0000644000175200017650000000325712656321775021430 0ustar coincoin-web// $Id: vec_fun_pattern.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_VEC_FUN_PATTERN_HPP # define CPPAD_VEC_FUN_PATTERN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include "cppad_ipopt_nlp.hpp" // --------------------------------------------------------------------------- namespace cppad_ipopt { // --------------------------------------------------------------------------- /*! \file vec_fun_pattern.hpp \brief Determine sparsity pattern for a vector of AD fuction objects. \ingroup vec_fun_pattern_cpp */ extern void vec_fun_pattern( size_t K , const CppAD::vector& p , const CppAD::vector& q , const CppAD::vectorBool& retape , CppAD::vector< CppAD::ADFun >& r_fun , CppAD::vector& pattern_jac_r , CppAD::vector& pattern_hes_r ); // --------------------------------------------------------------------------- } // end namespace cppad_ipopt // --------------------------------------------------------------------------- # endif cppad-20160000.1/cppad_ipopt/src/hes_fg_map.cpp0000644000175200017650000001351712656321775020331 0ustar coincoin-web// $Id: hes_fg_map.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 "cppad_ipopt_nlp.hpp" # include "hes_fg_map.hpp" // --------------------------------------------------------------------------- namespace cppad_ipopt { // --------------------------------------------------------------------------- /*! \{ \file hes_fg_map.cpp \brief Creates a mapping between two representations for Hessian of fg. */ /*! Create mapping from CppAD to Ipopt sparse representations of Hessian of F(x). The functions \f$ f : {\bf R}^n \rightarrow {\bf R} \f$ and \f$ g : {\bf R}^n \rightarrow {\bf R}^m \f$ are defined by the \ref Users_Representation. We define the function \f$ F : {\bf R}^n \rightarrow {\bf R} \f$ by \f[ F(x) = \sum_{i=0}^m fg(x)_i \f] \param fg_info For k = 0 , ... , K-1, for ell = 0 , ... , L[k], the function call \verbatim fg_info->index(k, ell, I, J); \endverbatim is made by \c hes_fg_map. The values \c k and \c ell are inputs. The input size of \c I ( \c J ) is greater than or equal p[k] ( q[k] ) and this size is not changed. The input values of the elements of \c I and \c J are not specified. The output value of the elements of \c I define \f[ I_{k, \ell} = ( {\rm I[0]} , \cdots , {\rm I[p[k]-1]} ) \f] The output value of the elements of \c J define \f[ J_{k, \ell} = ( {\rm J[0]} , \cdots , {\rm J[q[k]-1]} ) \f] \param m is the dimension of the range space for \f$ g(x) \f$; i.e., \f$ g(x) \in {\bf R}^m \f$. \param n is the dimension of the domain space for \f$ f(x) \f$ and \f$ g(x) \f$; i.e., \f$ x \in {\bf R}^n \f$. \param K is the number of functions \f$ r_k ( u ) \f$ used for the representation of \f$ f(x) \f$ and \f$ g(x) \f$. \param L is a vector with size \c K. For k = 0 , ... , K-1, L[k] is the number of terms that use \f$ r_k (u) \f$ in the representation of \f$ f(x) \f$ and \f$ g(x) \f$. \param p is a vector with size \c K. For k = 0 , ... , K-1, p[k] is dimension of the range space for \f$ r_k (u) \f$; i.e., \f$ r_k (u) \in {\bf R}^{p(k)} \f$. \param q is a vector with size \c K. For k = 0 , ... , K-1, q[k] is dimension of the domain space for \f$ r_k (u) \f$; i.e., \f$ u \in {\bf R}^{q(k)} \f$. \param pattern_hes_r is a vector with size \c K. For k = 0 , ... , K-1, pattern_jac_r[k] is a CppAD sparsity pattern for the Hessian of the function \f[ R(u) = \sum_{i=0}^{p[k]-1} r_k (u)_i \f] As such, pattern_hes_r[k].size() == q[k] * q[k]. \param I is a work vector of length greater than or equal p[k] for all \c k. The input and output value of its elements are unspecified. The size of \c I is not changed. \param J is a work vector of length greater than or equal q[k] for all \c k. The input and output value of its elements are unspecified. The size of \c J is not changed. \param index_hes_fg: On input, this is empty; i.e., index_jac_g.size() == 0. On output, it is the index mapping from \f$ (i, j) \f$ in the Jacobian of \f$ g(x) \f$ to the corresponding index value used by Ipopt to represent the Jacobian. Furthermore, if index_jac_g[i].find(j) == index_jac_g[i].end(), then the \f$ (i, j)\f$ entry in the Jacobian of \f$ g(x) \f$ is always zero. */ void hes_fg_map( cppad_ipopt_fg_info* fg_info , size_t m , size_t n , size_t K , const CppAD::vector& L , const CppAD::vector& p , const CppAD::vector& q , const CppAD::vector& pattern_hes_r , CppAD::vector& I , CppAD::vector& J , CppAD::vector< std::map >& index_hes_fg ) { using CppAD::vectorBool; size_t i, j, ij, k, ell; CPPAD_ASSERT_UNKNOWN( K == L.size() ); CPPAD_ASSERT_UNKNOWN( K == p.size() ); CPPAD_ASSERT_UNKNOWN( K == q.size() ); CPPAD_ASSERT_UNKNOWN( K == pattern_hes_r.size() ); # ifndef NDEBUG for(k = 0; k < K; k++) { CPPAD_ASSERT_UNKNOWN( p[k] <= I.size() ); CPPAD_ASSERT_UNKNOWN( q[k] <= J.size() ); CPPAD_ASSERT_UNKNOWN( q[k]*q[k] == pattern_hes_r[k].size() ); } # endif // Now compute pattern for fg // (use standard set representation because can be huge). CppAD::vector< std::set > pattern_hes_fg(n); for(k = 0; k < K; k++) for(ell = 0; ell < L[k]; ell++) { fg_info->index(k, ell, I, J); for(i = 0; i < q[k]; i++) { for(j = 0; j < q[k]; j++) { ij = i * q[k] + j; if( pattern_hes_r[k][ij] ) pattern_hes_fg[J[i]].insert(J[j]); } } } // Now compute the mapping from (i, j) in the Hessian of fg to the // corresponding index value used by Ipopt to represent the Hessian. CPPAD_ASSERT_UNKNOWN( index_hes_fg.size() == 0 ); index_hes_fg.resize(n); std::set::const_iterator itr; ell = 0; for(i = 0; i < n; i++) { for( itr = pattern_hes_fg[i].begin(); itr != pattern_hes_fg[i].end(); itr++) { index_hes_fg[i][*itr] = ell++; } } return; } // --------------------------------------------------------------------------- } // end namespace cppad_ipopt // --------------------------------------------------------------------------- cppad-20160000.1/cppad_ipopt/src/makefile.am0000644000175200017650000000240712656321775017625 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 = # # AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = \ -I. \ -I$(top_srcdir) \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # # make building the library conditional on having IPOPT_DIR specified if CppAD_IPOPT lib_LIBRARIES = libcppad_ipopt.a libcppad_ipopt_a_SOURCES = \ cppad_ipopt_nlp.cpp \ cppad_ipopt_nlp.hpp \ fun_record.hpp \ hes_fg_map.cpp \ hes_fg_map.hpp \ jac_g_map.cpp \ jac_g_map.hpp \ sparse_map2vec.cpp \ sparse_map2vec.hpp \ vec_fun_pattern.cpp \ vec_fun_pattern.hpp endif cppad-20160000.1/cppad_ipopt/src/sparse_map2vec.cpp0000644000175200017650000000576712656321775021163 0ustar coincoin-web// $Id: sparse_map2vec.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 "cppad_ipopt_nlp.hpp" # include "sparse_map2vec.hpp" // --------------------------------------------------------------------------- namespace cppad_ipopt { // --------------------------------------------------------------------------- /*! \{ \file sparse_map2vec.cpp \brief Create a two vector sparsity representation from a vector of maps. */ /*! Create a two vector sparsity representation from a vector of maps. \param sparse Is a vector of maps representation of sparsity as well as the index in the two vector representation. To be specific; \verbatim for(i = 0; i < sparse.size(); i++) { for(itr = sparse[i].begin(); itr != sparse[i].end(); itr++) { j = itr->first; // (i, j) is a possibly non-zero entry in sparsity pattern // k == itr->second, is corresponding index in i_row and j_col k++; } } \endverbatim \param n_nz is the total number of possibly non-zero entries. \param i_row The input size and element values for \c i_row do not matter. On output, it has size \c n_nz and i_row[k] contains the row index corresponding to the \c k-th possibly non-zero entry. \param j_col The input size and element values for \c j_col do not matter. On output, it has size \c n_nz and j_col[k] contains the column index corresponding to the \c k-th possibly non-zero entry. */ void sparse_map2vec( const CppAD::vector< std::map > sparse, size_t& n_nz , CppAD::vector& i_row , CppAD::vector& j_col ) { size_t i, j, k, m; // number of rows in sparse m = sparse.size(); // itererator for one row std::map::const_iterator itr; // count the number of possibly non-zeros in sparse n_nz = 0; for(i = 0; i < m; i++) for(itr = sparse[i].begin(); itr != sparse[i].end(); itr++) ++n_nz; // resize the return vectors to accomidate n_nz entries i_row.resize(n_nz); j_col.resize(n_nz); // set the row and column indices and check assumptions on sparse k = 0; for(i = 0; i < m; i++) { for(itr = sparse[i].begin(); itr != sparse[i].end(); itr++) { j = itr->first; CPPAD_ASSERT_UNKNOWN( k == itr->second ); i_row[k] = i; j_col[k] = j; ++k; } } return; } // --------------------------------------------------------------------------- } // end namespace cppad_ipopt // --------------------------------------------------------------------------- cppad-20160000.1/cppad_ipopt/src/cppad_ipopt_nlp.cpp0000644000175200017650000007514612656321775021422 0ustar coincoin-web// $Id: cppad_ipopt_nlp.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. -------------------------------------------------------------------------- */ # include # include "cppad_ipopt_nlp.hpp" # include "sparse_map2vec.hpp" # include "jac_g_map.hpp" # include "hes_fg_map.hpp" # include "vec_fun_pattern.hpp" # include "fun_record.hpp" /// If 0 tracing is off, otherwise tracing is on. # define CPPAD_IPOPT_NLP_TRACE 0 # if CPPAD_IPOPT_NLP_TRACE # include # endif // --------------------------------------------------------------------------- namespace cppad_ipopt { // --------------------------------------------------------------------------- /*! \{ \file cppad_ipopt_nlp.cpp \brief Member functions for the cppad_ipopt_nlp class. */ /*! Constructor for the \ref Nonlinear_Programming_Problem. \param n dimension of the domain space for f(x) and g(x). \param m dimension of the range space for g(x) \param x_i initial value of x during the optimization procedure (size n). \param x_l lower limit for x (size n). \param x_u upper limit for x (size n). \param g_l lower limit for g(x) (size m). \param g_u upper limit for g(x) (size m). \param fg_info pointer to base class version of derived class object used to get information about the user's representation for f(x) and g(x). (The object pointed to must not be deleted before this cppad_ipopt_nlp object). \param solution pointer to object where final results are stored. (The object pointed to must not be deleted before this cppad_ipopt_nlp object). \par Constants The following values are set by the constructor and are \c const or effectively \c const; i.e., they are set by the constructor and should not be changed: \verbatim n_, m_, x_i_, x_l_, x_u_, g_l_, g_u_, K_, L_, p_, q_, retape_, pattern_jac_r_, pattern_hes_r_, index_jac_g_, index_hes_fg_, nnz_jac_g_, iRow_jac_g_, jCol_jac_g_, nnz_h_lag_, iRow_h_lag_, jCol_h_lag_, \endverbatim In addition, the function calls fg_info->set_n(n) and fg_info->set_m(m) are used to set the values of \c n and \c m in \c fg_info. \par Variables The following arrays have fixed size which is set during this constructor: \li \c tape_ok_ has size \c K_. It is initialized as true for indices \c k such that retape[k] is false. \li \c r_fun_ has size \c K_. It is initilaize with the default \c ADFun constructor. Then, for indices \c k such that retape[k] is false, the operation sequence corresponding to \f$ r_k (u) \f$ is stored in r_fun_[k]. \li \c I_ has size equal to the maximum of p[k] w.r.t \c k. \li \c J_ has size equal to the maximum of q[k] w.r.t \c k. \par NDEBUG If the preprocessor symbol \c NEBUG is not defined, certain of the assumptions about the function calls of the form \verbatim fg_info->index(k, ell, I, J) \endverbatim are checked to make sure they hold. */ cppad_ipopt_nlp::cppad_ipopt_nlp( size_t n , size_t m , const NumberVector &x_i , const NumberVector &x_l , const NumberVector &x_u , const NumberVector &g_l , const NumberVector &g_u , cppad_ipopt_fg_info* fg_info , cppad_ipopt_solution* solution ) : n_ ( n ), m_ ( m ), x_i_ ( x_i ), x_l_ ( x_l ), x_u_ ( x_u ), g_l_ ( g_l ), g_u_ ( g_u ), fg_info_ ( fg_info ) , solution_ (solution) , infinity_ ( std::numeric_limits::infinity() ) { size_t k; // set information needed in cppad_ipopt_fg_info fg_info_->set_n(n); fg_info_->set_m(m); // get information from derived class version of fg_info K_ = fg_info_->number_functions(); L_.resize(K_); p_.resize(K_); q_.resize(K_); r_fun_.resize(K_); retape_.resize(K_); tape_ok_.resize(K_); pattern_jac_r_.resize(K_); pattern_hes_r_.resize(K_); size_t max_p = 0; size_t max_q = 0; for(k = 0; k < K_; k++) { L_[k] = fg_info_->number_terms(k); p_[k] = fg_info_->range_size(k); q_[k] = fg_info_->domain_size(k); retape_[k] = fg_info_->retape(k); max_p = std::max(max_p, p_[k]); max_q = std::max(max_q, q_[k]); pattern_jac_r_[k].resize( p_[k] * q_[k] ); pattern_hes_r_[k].resize( q_[k] * q_[k] ); } I_.resize(max_p); J_.resize(max_q); # ifndef NDEBUG size_t i, j, ell; // check for valid range and domain indices for(k = 0; k < K_; k++) for(ell = 0; ell < L_[k]; ell++) { for( i = 0; i < p_[k]; i++) I_[i] = m+1; // an invalid range index for( j = 0; j < q_[k]; j++) J_[j] = n; // an invalid domain index fg_info_->index(k, ell, I_, J_); for( i = 0; i < p_[k]; i++) if( I_[i] > m ) { std::cerr << "k=" << k << ", ell=" << ell << ", I[" << i << "]=" << I_[i] << std::endl; CPPAD_ASSERT_KNOWN( I_[i] <= m, "cppad_ipopt_nlp: invalid value in index vector I" ); } for( j = 0; j < q_[k]; j++) if( J_[j] >= n ) { std::cerr << "k=" << k << ", ell=" << ell << ", J[" << j << "]=" << J_[j] << std::endl; CPPAD_ASSERT_KNOWN( J_[j] < n, "cppad_ipopt_nlp: invalid value in index vector J" ); } } # endif // record r[k] for functions that do not need retaping for(k = 0; k < K_; k++) { tape_ok_[k] = false; if( ! retape_[k] ) { // Operation sequence does not depend on value // of u so record it once here in the constructor. fg_info_->index(k, 0, I_, J_); fun_record( fg_info_ , // inputs k , p_ , q_ , n_ , x_i_ , J_ , r_fun_ // output ); // take time to optimize because only recording once r_fun_[k].optimize(); // ok and will stay that way tape_ok_[k] = true; } } // compute a sparsity patterns for each r_k (u) vec_fun_pattern( K_, p_, q_, retape_, r_fun_, // inputs pattern_jac_r_, pattern_hes_r_ // outputs ); // mapping from (i,j) to Ipopt sparsity index for Jacobian of g jac_g_map( fg_info_, m_, n_, K_, L_, p_, q_, pattern_jac_r_, // inputs I_, J_, // work index_jac_g_ // outputs ); // mapping from (i,j) to Ipopt sparsity index for Hessian of Lagragian hes_fg_map( fg_info_, m_, n_, K_, L_, p_, q_, pattern_hes_r_, // inputs I_, J_, // work index_hes_fg_ // outputs ); // Compute Ipopt sparsity structure for Jacobian of g sparse_map2vec( index_jac_g_, // inputs nnz_jac_g_, iRow_jac_g_, jCol_jac_g_ // outputs ); // Compute Ipopt sparsity structure for Hessian of Lagragian sparse_map2vec( index_hes_fg_, // inputs nnz_h_lag_, iRow_h_lag_, jCol_h_lag_ // outputs ); } /// The destructor takes no special action. cppad_ipopt_nlp::~cppad_ipopt_nlp() {} /*! Return dimension information about optimization problem. \param[out] n is set to the value \c n_. \param[out] m is set to the value \c m_. \param[out] nnz_jac_g is set to the value of \c nnz_jac_g_. \param[out] nnz_h_lag is set to the vlaue of \c nnz_h_lag_. \param[out] index_style is set to C_STYLE; i.e., zeoro based indexing is used in the information passed to Ipopt. */ bool cppad_ipopt_nlp::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, IndexStyleEnum& index_style) { n = n_; m = m_; nnz_jac_g = nnz_jac_g_; nnz_h_lag = nnz_h_lag_; // 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 \c n_. \param[out] x_l is a vector of size \c n. 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., \c x_l_. \param[out] x_u is a vector of size \c n. 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., \c x_u_. \param[in] m is the dimension of the range space for g(x). i.e., it must be equal to \c m_. \param[out] g_l is a vector of size \c m. 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., \c g_l_. \param[out] g_u is a vector of size \c m. 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, \c g_u_. */ bool cppad_ipopt_nlp::get_bounds_info(Index n, Number* x_l, Number* x_u, Index m, Number* g_l, Number* g_u) { size_t i, j; // here, the n and m we gave IPOPT in get_nlp_info are passed back CPPAD_ASSERT_UNKNOWN(size_t(n) == n_); CPPAD_ASSERT_UNKNOWN(size_t(m) == m_); // pass back bounds for(j = 0; j < n_; j++) { x_l[j] = x_l_[j]; x_u[j] = x_u_[j]; } for(i = 0; i < m_; i++) { g_l[i] = g_l_[i]; g_u[i] = g_u_[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 \c n_. \param[in] init_x must be equal to true. \param[out] x is a vector of size \c n. 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. \c x_i_. \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 range dimension for g(x); i.e., it must be equal to \c m_. \param init_lambda must be equal to false. \param lambda is not used. */ bool cppad_ipopt_nlp::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(size_t(n) == n_ ); CPPAD_ASSERT_UNKNOWN(size_t(m) == m_ ); CPPAD_ASSERT_UNKNOWN(init_x == true); CPPAD_ASSERT_UNKNOWN(init_z == false); CPPAD_ASSERT_UNKNOWN(init_lambda == false); for(j = 0; j < n_; j++) x[j] = x_i_[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 \c n_. \param[in] x is a vector of size \c n containing the point at which to evaluate the function f(x). \param[in] new_x is false if the previous call to any one of the \ref Deprecated_Evaluation_Methods used the same value for \c x. \param[out] obj_value is the value of the objective f(x) at this value of \c x. \return The return value is always true; see \ref Deprecated_Evaluation_Methods. \par Efficiency This routine could be more efficient (for certain when when L[k] > 1 and retape[k] is true) if the users also provided a version of the function fg_info->eval_r(k, u) where \c u was of type \c NumberVector. */ bool cppad_ipopt_nlp::eval_f( Index n, const Number* x, bool new_x, Number& obj_value ) { CPPAD_ASSERT_UNKNOWN(size_t(n) == n_ ); size_t iobj, j, k, ell; // initialize summation obj_value = 0.; // update tape_ok_ flag for(k = 0; k < K_; k++) { if( retape_[k] && (new_x || L_[k] > 1) ) tape_ok_[k] = false; } for(k = 0; k < K_; k++) for(ell = 0; ell < L_[k]; ell++) { fg_info_->index(k, ell, I_, J_); for(iobj = 0; iobj < p_[k]; iobj++) if( I_[iobj] == 0 ) { if( ! tape_ok_[k] ) { // Record r_k for value of u corresponding to x fun_record( fg_info_ , // inputs k , p_ , q_ , n_ , x , J_ , r_fun_ // output ); tape_ok_[k] = ! (retape_[k] || L_[k] > 1); } NumberVector u(q_[k]); NumberVector r(p_[k]); for(j = 0; j < q_[k]; j++) { CPPAD_ASSERT_UNKNOWN( J_[j] < n_ ); u[j] = x[ J_[j] ]; } r = r_fun_[k].Forward(0, u); obj_value += r[iobj]; } } # if CPPAD_IPOPT_NLP_TRACE using std::printf; for(j = 0; j < n_; j++) printf("cppad_ipopt_nlp::eval_f::x[%d] = %20.14g\n", j, x[j]); printf("cppad_ipopt_nlp::eval_f::obj_value = %20.14g\n", obj_value); # endif # ifndef NDEBUG CPPAD_ASSERT_KNOWN( (-infinity_ < obj_value) && (obj_value < infinity_), "cppad_ipopt_nlp::eval_f:: objective value is not finite" ); # endif 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 \c n_. \param[in] x has a vector of size \c n 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 Deprecated_Evaluation_Methods used the same value for \c x. \param[out] grad_f is a vector of size \c n. The input value of its elements does not matter. The output value of its elements is the gradient of f(x) at this value of. \return The return value is always true; see \ref Deprecated_Evaluation_Methods. */ bool cppad_ipopt_nlp::eval_grad_f( Index n, const Number* x, bool new_x, Number* grad_f ) { CPPAD_ASSERT_UNKNOWN(size_t(n) == n_ ); size_t iobj, i, j, k, ell; // initialize summation for(j = 0; j < n_; j++) grad_f[j] = 0.; // update tape_ok_ flag for(k = 0; k < K_; k++) { if( retape_[k] && (new_x || L_[k] > 1) ) tape_ok_[k] = false; } for(k = 0; k < K_; k++) for(ell = 0; ell < L_[k]; ell++) { fg_info_->index(k, ell, I_, J_); for(iobj = 0; iobj < p_[k]; iobj++) if( I_[iobj] == 0 ) { if( ! tape_ok_[k] ) { // Record r_k for value of u corresponding to x fun_record( fg_info_ , // inputs k , p_ , q_ , n_ , x , J_ , r_fun_ // output ); tape_ok_[k] = ! (retape_[k] || L_[k] > 1); } NumberVector u(q_[k]); NumberVector w(p_[k]); NumberVector r_grad(q_[k]); for(j = 0; j < q_[k]; j++) { CPPAD_ASSERT_UNKNOWN( J_[j] < n_ ); u[j] = x[ J_[j] ]; } r_fun_[k].Forward(0, u); for(i = 0; i < p_[k]; i++) w[i] = 0.; w[iobj] = 1.; r_grad = r_fun_[k].Reverse(1, w); for(j = 0; j < q_[k]; j++) { CPPAD_ASSERT_UNKNOWN( J_[j] < n_ ); grad_f[ J_[j] ] += r_grad[j]; } } } # if CPPAD_IPOPT_NLP_TRACE using std::printf; for(j = 0; j < n_; j++) printf( "cppad_ipopt_nlp::eval_grad_f::x[%d] = %20.14g\n", j, x[j] ); for(j = 0; j < n_; j++) printf( "cppad_ipopt_nlp::eval_grad_f::grad_f[%d] = %20.14g\n", j, grad_f[j] ); # endif # ifndef NDEBUG for(j = 0; j < n_; j++) CPPAD_ASSERT_KNOWN( (-infinity_ < grad_f[j]) && (grad_f[j] < infinity_), "cppad_ipopt_nlp::grad_f:: gradient of objective is not finite" ); # endif 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 \c n_. \param[in] x has a vector of size \c n containing the point at which to evaluate the constraint function g(x). \param[in] new_x is false if the previous call to any one of the \ref Deprecated_Evaluation_Methods used the same value for \c x. \param[in] m is the dimension of the range space for g(x); i.e., must be equal to \c m_. \param[out] g is a vector of size \c m. The input value of its elements does not matter. The output value of its elements is the value of the function g(x) at this value of \c x. \return The return value is always true; see \ref Deprecated_Evaluation_Methods. */ bool cppad_ipopt_nlp::eval_g( Index n, const Number* x, bool new_x, Index m, Number* g ) { CPPAD_ASSERT_UNKNOWN(size_t(n) == n_ ); size_t i, j, k, ell; // initialize summation for(i = 0; i < m_; i++) g[i] = 0.; // update tape_ok_ flag for(k = 0; k < K_; k++) { if( retape_[k] && (new_x || L_[k] > 1) ) tape_ok_[k] = false; } for(k = 0; k < K_; k++) for(ell = 0; ell < L_[k]; ell++) { fg_info_->index(k, ell, I_, J_); if( ! tape_ok_[k] ) { // Record r_k for value of u corresponding to x fun_record( fg_info_ , // inputs k , p_ , q_ , n_ , x , J_ , r_fun_ // output ); } tape_ok_[k] = ! (retape_[k] || L_[k] > 1); NumberVector u(q_[k]); NumberVector r(p_[k]); for(j = 0; j < q_[k]; j++) { CPPAD_ASSERT_UNKNOWN( J_[j] < n_ ); u[j] = x[ J_[j] ]; } r = r_fun_[k].Forward(0, u); for(i = 0; i < p_[k]; i++) { CPPAD_ASSERT_UNKNOWN( I_[i] <= m_ ); if( I_[i] >= 1 ) g[ I_[i] - 1 ] += r[i]; } } # if CPPAD_IPOPT_NLP_TRACE using std::printf; for(j = 0; j < n_; j++) printf("cppad_ipopt_nlp::eval_g::x[%d] = %20.14g\n", j, x[j]); for(i = 0; i < m_; i++) printf("cppad_ipopt_nlp::eval_g::g[%d] = %20.14g\n", i, g[i]); # endif # ifndef NDEBUG for(i = 0; i < m_; i++) CPPAD_ASSERT_KNOWN( (-infinity_ < g[i]) && (g[i] < infinity_), "cppad_ipopt_nlp::eval_g:: not all constraints are not finite" ); # endif 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 \c n_. \param x if \c values is not \c NULL, \c x is a vector of size \c 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 Deprecated_Evaluation_Methods used the same value for \c x. \param[in] m is the dimension of the range space for g(x); i.e., must be equal to \c m_. \param[in] nele_jac is the number of possibly non-zero elements in the Jacobian of g(x); i.e., must be equal to \c nnz_jac_g_. \param iRow if \c values is not \c NULL, \c iRow is not defined. if \c values is \c NULL, \c iRow is a vector with size \c nele_jac. The input value of its elements does not matter. On output, For k = 0 , ... , nele_jac-1, iRow[k] is the base zero row index for the k-th possibly non-zero entry in the Jacobian of g(x). \param jCol if \c values is not \c NULL, \c jCol is not defined. if \c values is \c NULL, \c jCol is a vector with size \c nele_jac. The input value of its elements does not matter. On output, For k = 0 , ... , nele_jac-1, jCol[k] is the base zero column index for the k-th possibly non-zero entry in the Jacobian of g(x). \param values if \c values is not \c NULL, \c values is a vector with size \c nele_jac. The input value of its elements does not matter. On output, For k = 0 , ... , nele_jac-1, values[k] is the value for the k-th possibly non-zero entry in the Jacobian of g(x). \return The return value is always true; see \ref Deprecated_Evaluation_Methods. */ bool cppad_ipopt_nlp::eval_jac_g(Index n, const Number* x, bool new_x, Index m, Index nele_jac, Index* iRow, Index *jCol, Number* values) { CPPAD_ASSERT_UNKNOWN(size_t(m) == m_ ); CPPAD_ASSERT_UNKNOWN(size_t(n) == n_ ); CPPAD_ASSERT_UNKNOWN( size_t(nele_jac) == nnz_jac_g_ ); size_t i, j, k, ell, l; std::map::iterator index_ij; if (values == NULL) { for(k = 0; k < nnz_jac_g_; k++) { iRow[k] = iRow_jac_g_[k]; jCol[k] = jCol_jac_g_[k]; } return true; } // initialize summation l = nnz_jac_g_; while(l--) values[l] = 0.; // update tape_ok_ flag for(k = 0; k < K_; k++) { if( retape_[k] && (new_x || L_[k] > 1) ) tape_ok_[k] = false; } for(k = 0; k < K_; k++) for(ell = 0; ell < L_[k]; ell++) { fg_info_->index(k, ell, I_, J_); if( ! tape_ok_[k] ) { // Record r_k for value of u corresponding to x fun_record( fg_info_ , // inputs k , p_ , q_ , n_ , x , J_ , r_fun_ // output ); } tape_ok_[k] = ! (retape_[k] || L_[k] > 1); NumberVector u(q_[k]); NumberVector jac_r(p_[k] * q_[k]); for(j = 0; j < q_[k]; j++) { CPPAD_ASSERT_UNKNOWN( J_[j] < n_ ); u[j] = x[ J_[j] ]; } if( retape_[k] ) jac_r = r_fun_[k].Jacobian(u); else jac_r = r_fun_[k].SparseJacobian(u, pattern_jac_r_[k]); for(i = 0; i < p_[k]; i++) if( I_[i] != 0 ) { CPPAD_ASSERT_UNKNOWN( I_[i] <= m_ ); for(j = 0; j < q_[k]; j++) { index_ij = index_jac_g_[I_[i]-1].find(J_[j]); if( index_ij != index_jac_g_[I_[i]-1].end() ) { l = index_ij->second; values[l] += jac_r[i * q_[k] + j]; } else CPPAD_ASSERT_UNKNOWN( jac_r[i * q_[k] + j] == 0. ); } } } # ifndef NDEBUG for(l = 0; l < nnz_jac_g_; l++) CPPAD_ASSERT_KNOWN( (-infinity_ < values[l]) && (values[l] < infinity_), "cppad_ipopt_nlp::eval_jac_g:: a component of " "gradient of g is not finite" ); # endif return true; } /*! Evaluate the Hessian of the Lagragian \section Deprecated_Hessian_of_the_Lagragian The Hessian of the Lagragian The Hessian of the Lagragian is defined as \f[ H(x, \sigma, \lambda ) = \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 \c n_. \param x if \c values is not \c NULL, \c x is a vector of size \c n containing the point at which to evaluate the Hessian of the Lagrangian. \param[in] new_x is false if the previous call to any one of the \ref Deprecated_Evaluation_Methods used the same value for \c x. \param[in] obj_factor the value \f$ \sigma \f$ multiplying the Hessian of f(x) in the expression for \ref Deprecated_Hessian_of_the_Lagragian. \param[in] m is the dimension of the range space for g(x); i.e., must be equal to \c m_. \param[in] lambda if \c values is not \c NULL, \c lambda is a vector of size \c m specifing the value of \f$ \lambda \f$ in the expression for \ref Deprecated_Hessian_of_the_Lagragian. \param[in] new_lambda is true if the previous call to \c eval_h had the same value for \c 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 \c nnz_h_lag_. \param iRow if \c values is not \c NULL, \c iRow is not defined. if \c values is \c NULL, \c iRow is a vector with size \c nele_jac. The input value of its elements does not matter. On output, For k = 0 , ... , nele_jac-1, iRow[k] is the base zero row index for the k-th possibly non-zero entry in the Hessian of the Lagragian. \param jCol if \c values is not \c NULL, \c jCol is not defined. if \c values is \c NULL, \c jCol is a vector with size \c nele_jac. The input value of its elements does not matter. On output, For k = 0 , ... , nele_jac-1, jCol[k] is the base zero column index for the k-th possibly non-zero entry in the Hessian of the Lagragian. \param values if \c values is not \c NULL, it is a vector with size \c nele_jac. The input value of its elements does not matter. On output, For k = 0 , ... , nele_jac-1, values[k] is the value for the k-th possibly non-zero entry in the Hessian of the Lagragian. \return The return value is always true; see \ref Deprecated_Evaluation_Methods. */ bool cppad_ipopt_nlp::eval_h(Index n, const Number* x, bool new_x, Number obj_factor, Index m, const Number* lambda, bool new_lambda, Index nele_hess, Index* iRow, Index* jCol, Number* values) { CPPAD_ASSERT_UNKNOWN(size_t(m) == m_ ); CPPAD_ASSERT_UNKNOWN(size_t(n) == n_ ); size_t i, j, k, ell, l; std::map::iterator index_ij; if (values == NULL) { for(k = 0; k < nnz_h_lag_; k++) { iRow[k] = iRow_h_lag_[k]; jCol[k] = jCol_h_lag_[k]; } return true; } // initialize summation l = nnz_h_lag_; while(l--) values[l] = 0.; // update tape_ok_ flag for(k = 0; k < K_; k++) { if( retape_[k] && (new_x || L_[k] > 1) ) tape_ok_[k] = false; } for(k = 0; k < K_; k++) for(ell = 0; ell < L_[k]; ell++) { fg_info_->index(k, ell, I_, J_); bool in_use = false; for(i = 0; i < p_[k]; i++) { if( I_[i] == 0 ) in_use |= obj_factor > 0.; else in_use |= lambda[ I_[i] - 1 ] > 0; } if( in_use ) { if( ! tape_ok_[k] ) { // Record r_k for value of u corresponding to x fun_record( fg_info_ , // inputs k , p_ , q_ , n_ , x , J_ , r_fun_ // output ); tape_ok_[k] = ! (retape_[k] || L_[k] > 1); } NumberVector w(p_[k]); NumberVector r_hes(q_[k] * q_[k]); NumberVector u(q_[k]); for(j = 0; j < q_[k]; j++) { CPPAD_ASSERT_UNKNOWN( J_[j] < n_ ); u[j] = x[ J_[j] ]; } for(i = 0; i < p_[k]; i++) { CPPAD_ASSERT_UNKNOWN( I_[i] <= m_ ); if( I_[i] == 0 ) w[i] = obj_factor; else w[i] = lambda[ I_[i] - 1 ]; } if( retape_[k] ) r_hes = r_fun_[k].Hessian(u, w); else r_hes = r_fun_[k].SparseHessian( u, w, pattern_hes_r_[k] ); for(i = 0; i < q_[k]; i++) for(j = 0; j < q_[k]; j++) if( J_[j] <= J_[i] ) { index_ij = index_hes_fg_[J_[i]].find(J_[j]); if( index_ij != index_hes_fg_[J_[i]].end() ) { l = index_ij->second; values[l] += r_hes[i * q_[k] + j]; } else CPPAD_ASSERT_UNKNOWN( r_hes[i * q_[k] + j] == 0. ); } } } # ifndef NDEBUG for(l = 0; l < nnz_h_lag_; l++) CPPAD_ASSERT_KNOWN( (-infinity_ < values[l]) && (values[l] < infinity_), "cppad_ipopt_nlp::eval_h:: a component of " "Hessian of Lagragian is not finite" ); # endif 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 \c n_. \param[in] x is a vector with size \c n specifing the final solution. \n solution_->x is set to be a vector with size \c n and to have the same element values. \param[in] z_L is a vector with size \c n specifing the Lagragian multipliers for the constraint \f$ x^l \leq x \f$. \n solution_->z_l is set to be a vector with size \c n and to have the same element values. \param[in] z_U is a vector with size \c n specifing the Lagragian multipliers for the constraint \f$ x \leq x^u \f$. \n solution_->z_u is set to be a vector with size \c n and to have the same element values. \param[in] m is the dimension of the range space for g(x). i.e., it must be equal to \c m_. \param[in] g is a vector with size \c m containing the value of the constraint function g(x) at the final solution for \c x. \n solution_->g is set to be a vector with size \c m and to have the same element values. \param[in] lambda is a vector with size \c m specifing the Lagragian multipliers for the constraints \f$ g^l \leq g(x) \leq g^u \f$. \n solution_->lambda is set to be a vector with size \c m and to have the same element values. \param[in] obj_value is the value of the objective function f(x) at the final solution for \c x. \n solution_->obj_value is set to have the same 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] the pointer \c solution_ , which is equal to the pointer \c solution in the constructor for \c cppad_ipopt_nlp, is used to set output values (see documentation above). */ void cppad_ipopt_nlp::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(size_t(n) == n_ ); CPPAD_ASSERT_UNKNOWN(size_t(m) == m_ ); switch(status) { // convert status from Ipopt enum to cppad_ipopt_solution enum case Ipopt::SUCCESS: solution_->status = cppad_ipopt_solution::success; break; case Ipopt::MAXITER_EXCEEDED: solution_->status = cppad_ipopt_solution::maxiter_exceeded; break; case Ipopt::STOP_AT_TINY_STEP: solution_->status = cppad_ipopt_solution::stop_at_tiny_step; break; case Ipopt::STOP_AT_ACCEPTABLE_POINT: solution_->status = cppad_ipopt_solution::stop_at_acceptable_point; break; case Ipopt::LOCAL_INFEASIBILITY: solution_->status = cppad_ipopt_solution::local_infeasibility; break; case Ipopt::USER_REQUESTED_STOP: solution_->status = cppad_ipopt_solution::user_requested_stop; break; case Ipopt::DIVERGING_ITERATES: solution_->status = cppad_ipopt_solution::diverging_iterates; break; case Ipopt::RESTORATION_FAILURE: solution_->status = cppad_ipopt_solution::restoration_failure; break; case Ipopt::ERROR_IN_STEP_COMPUTATION: solution_->status = cppad_ipopt_solution::error_in_step_computation; break; case Ipopt::INVALID_NUMBER_DETECTED: solution_->status = cppad_ipopt_solution::invalid_number_detected; break; case Ipopt::INTERNAL_ERROR: solution_->status = cppad_ipopt_solution::internal_error; break; default: solution_->status = cppad_ipopt_solution::unknown; } solution_->x.resize(n_); solution_->z_l.resize(n_); solution_->z_u.resize(n_); for(j = 0; j < n_; j++) { solution_->x[j] = x[j]; solution_->z_l[j] = z_L[j]; solution_->z_u[j] = z_U[j]; } solution_->g.resize(m_); solution_->lambda.resize(m_); for(i = 0; i < m_; i++) { solution_->g[i] = g[i]; solution_->lambda[i] = lambda[i]; } solution_->obj_value = obj_value; return; } // This routine is defined, but not yet used // (trying to figure out a problem with Ipopt-3.9.1 and dismod4). bool cppad_ipopt_nlp::intermediate_callback( Ipopt::AlgorithmMode mode, Index iter, Number obj_value, Number inf_pr, Number inf_du, Number mu, Number d_norm, Number regularization_size, Number alpha_du, Number alpha_pr, Index ls_trials, const Ipopt::IpoptData* ip_data, Ipopt::IpoptCalculatedQuantities* ip_cq ) { // std::cout << "intermediate_callback called" << std::endl; return true; } // --------------------------------------------------------------------------- } // end namespace cppad_ipopt // --------------------------------------------------------------------------- cppad-20160000.1/cppad_ipopt/src/fun_record.hpp0000644000175200017650000000742112656321775020371 0ustar coincoin-web// $Id: fun_record.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_FUN_RECORD_HPP # define CPPAD_FUN_RECORD_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ # include "cppad_ipopt_nlp.hpp" // --------------------------------------------------------------------------- namespace cppad_ipopt { // --------------------------------------------------------------------------- /*! \{ \file fun_record.hpp \brief Records operation sequence for r_k (u) */ /*! Records operation sequence for \f$ r_k (u) \f$ at \f$u = [ J \circ n ] (x)\f$. \tparam NumVector is the type of the argumen \c x. It can either be Ipopt::Number* or CppAD::vector; i.e., NumberVector. \param fg_info Given a value \f$ u \in {\bf R}^{q[k]} \f$, \c fg_info returns the value \f$ r_k (u) \in {\bf R}^{p[k]} \f$. using the syntax \verbatim fg_info->eval_r(k, u); \endverbatim No other use is made of \c fg_info. \param k is a value less that \c K specifying the index value for \c k in the evaluation eval_r. \param p p[k] is dimension of the range space for \f$ r_k (u) \f$; i.e., \f$ r_k (u) \in {\bf R}^{p(k)} \f$. \param q q[k] is dimension of the domain space for \f$ r_k (u) \f$; i.e., \f$ u \in {\bf R}^{q(k)} \f$. \param n is the lenght of the vector \c x. \param x the length of \c x is equal to \c n and the point \f[ u = [ J \circ n ] (x) \f] is the point at which the operation sequence for \f$ r_k \f$ is recorded. \param J is a vector with lenght q[k] that projects from \f$ {\bf R}^n \f$ to \f$ {\bf R}^{q[k]} \f$ by selecting an ordered subset of the possible indices \f$ \{ 0 , \ldots , n-1 \} \f$. Hence, 0 <= J[j] < n for j = 0 , ... , q[k]-1. \param r_fun is the vector of AD function objects which has size size greater than \c k. Only the function object r_fun[k] is referenced. The input value of this function object does not matter. On output it is a recording of the function \f$ r_k (u) \f$ at the value of \f$ u \f$ specified by \c x and \c J. */ template void fun_record( cppad_ipopt_fg_info* fg_info , size_t k , const SizeVector& p , const SizeVector& q , size_t n , const NumVector& x , const SizeVector& J , CppAD::vector< CppAD::ADFun >& r_fun ) { size_t j; // extract u from x ADVector u(q[k]); for(j = 0; j < q[k]; j++) { // when NDEBUG is not defined, this error should be caught // during the cppad_ipopt_nlp constructor. CPPAD_ASSERT_UNKNOWN( J[j] < n ); u[j] = x[ J[j] ]; } // start the recording CppAD::Independent(u); // record the evaulation of r_k (u) ADVector r_k = fg_info->eval_r(k, u); CPPAD_ASSERT_KNOWN( r_k.size() == p[k] , "cppad_ipopt_nlp: eval_r return value size not equal to p[k]." ); // stop the recording and store operation sequence in r_fun[k].Dependent(u, r_k); } // --------------------------------------------------------------------------- } // end namespace cppad_ipopt // --------------------------------------------------------------------------- # endif cppad-20160000.1/cppad_ipopt/example/0002755000175200017650000000000012656321775016374 5ustar coincoin-webcppad-20160000.1/cppad_ipopt/example/makefile.am0000644000175200017650000000264712656321775020477 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 = # EXTRA_DIST = \ ode1.omh \ ode2.omh # check_PROGRAMS = example # AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ -I$(top_srcdir)/cppad_ipopt/src \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # LDADD = \ -lcppad_ipopt \ $(CPPAD_IPOPT_LIBS) \ $(FCLIBS) \ $(PTHREAD_LIB) \ $(DL_LIB) AM_LDFLAGS = -L../src # example_SOURCES = \ example.cpp \ get_started.cpp \ ode_check.cpp \ ode_check.hpp \ ode_fast_check.cpp \ ode_fast.hpp \ ode_problem.hpp \ ode_run.hpp \ ode_simple_check.cpp \ ode_simple.hpp test: check ./test.sh cppad-20160000.1/cppad_ipopt/example/ode1.omh0000644000175200017650000000145112656321775017730 0ustar coincoin-web$Id: ode1.omh 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 ipopt_nlp_ode$$ $section Example Simultaneous Solution of Forward and Inverse Problem$$ $contents% cppad_ipopt/example/ode2.omh% cppad_ipopt/example/ode_run.hpp% cppad_ipopt/example/ode_check.cpp %$$ $end cppad-20160000.1/cppad_ipopt/example/ode_fast.hpp0000644000175200017650000001244512656321775020675 0ustar coincoin-web// $Id: ode_fast.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ODE_FAST_HPP # define CPPAD_ODE_FAST_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ipopt_nlp_ode_fast.hpp$$ $spell cppad_ipopt_nlp $$ $section ODE Fitting Using Fast Representation$$ $mindex cppad_ipopt_nlp example source$$ $code $verbatim%cppad_ipopt/example/ode_fast.hpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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(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 } }; } // END C++ # endif cppad-20160000.1/cppad_ipopt/example/ode2.omh0000644000175200017650000003706612656321775017744 0ustar coincoin-web$Id: ode2.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin ipopt_nlp_ode_problem$$ $section An ODE Inverse Problem Example$$ $head 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 $cref ipopt_nlp_ode_problem.hpp$$ can be changed and the example should still run (with no other changes). $table $bold Name$$ $cnext $bold Meaning$$ $cnext $bold Value$$ $rnext $latex Na$$ $cnext number of parameters to fit $cnext 3 $rnext $latex Ny$$ $cnext number components in ODE $cnext 2 $rnext $latex Nz$$ $cnext number of measurements $cnext 4 $rnext $latex N(i)$$ $cnext number of grid points between $th i-1$$ and $th i$$ measurement $rnext $latex S(i)$$ $cnext number of grid points up to an including the $th i$$ measurement $tend $head Forward Problem$$ 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 ) \end{array} \] $$ with the initial conditions $latex \[ y_0 (0 , a) = F(a) = \left( \begin{array}{c} a_0 \\ 0 \end{array} \right) \] $$ where $latex Na$$ is the number of parameters, $latex a \in \B{R}^{Na} $$ is an unknown parameter vector. The function and $latex F : \B{R}^{Na} \rightarrow \B{R}^{Ny} $$ is defined by the equation above where $latex Ny$$ is the number of components in $latex y(t, a)$$. Our forward problem is stated as follows: Given $latex a \in \B{R}^{Na}$$ determine the value of $latex y ( t , a ) $$, for $latex t \in R$$, that solves the initial value problem above. $head Measurements$$ We use $latex Nz$$ to denote the number of measurements. Suppose we are also given a measurement vector $latex z \in \B{R}^{Nz}$$ and for $latex i = 1, \ldots, Nz$$, we model $latex z_i$$ by $latex \[ z_i = y_1 ( s_i , a) + e_i \] $$ where $latex s_i \in \B{R}$$ is the time for the $th i$$ measurement, $latex e_i \sim {\bf N} (0 , \sigma^2 ) $$ is the corresponding noise, and $latex \sigma \in \B{R}_+$$ is the corresponding standard deviation. $subhead Simulation Analytic Solution$$ The following analytic solution to the forward problem is used 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 } \end{array} \] $$ $subhead Simulation Parameter Values$$ $table $latex \bar{a}_0 = 1$$ $pre $$ $cnext initial value of $latex y_0 (t, a)$$ $rnext $latex \bar{a}_1 = 2$$ $pre $$ $cnext transfer rate from compartment zero to compartment one $rnext $latex \bar{a}_2 = 1$$ $pre $$ $cnext transfer rate from compartment one to outside world $rnext $latex \sigma = 0$$ $pre $$ $cnext standard deviation of measurement noise $rnext $latex e_i = 0$$ $pre $$ $cnext simulated measurement noise, $latex i = 1 , \ldots , Nz$$ $rnext $latex s_i = i * .5$$ $pre $$ $cnext time corresponding to the $th i$$ measurement, $latex i = 1 , \ldots , Nz$$ $tend $subhead Simulated Measurement Values$$ The simulated measurement values are given by the equation $latex \[ \begin{array}{rcl} z_i & = & e_i + y_1 ( s_i , \bar{a} ) \\ & = & e_i + \bar{a}_0 * \bar{a}_1 * \frac{\exp( - \bar{a}_2 * s_i ) - \exp( -\bar{a}_1 * s_i )} { \bar{a}_1 - \bar{a}_2 } \end{array} \] $$ for $latex k = 1, \ldots , Nz$$. $head Inverse Problem$$ The maximum likelihood estimate for $latex a$$ given $latex z$$ solves the following inverse problem $latex \[ \begin{array}{rcl} {\rm minimize} \; & \sum_{i=1}^{Nz} H_i [ y( s_i , a ) , a ] & \;{\rm w.r.t} \; a \in \B{R}^{Na} \end{array} \] $$ where the functions $latex H_i : \B{R}^{Ny} \times \B{R}^{Na} \rightarrow \B{R}$$ is defined by $latex \[ H_i (y, a) = ( z_i - y_1 )^2 \] $$ $head Trapezoidal Approximation$$ This example uses a trapezoidal approximation to solve the ODE. This approximation procedures starts with $latex \[ y^0 = y(0, a) = \left( \begin{array}{c} a_0 \\ 0 \end{array} \right) \] $$ Given a time grid $latex \{ t_i \}$$ and an approximate value $latex y^{i-1} $$ for $latex y ( t_{i-1} , a )$$, the a trapezoidal method approximates $latex y ( t_i , a )$$ (denoted by $latex y^i$$ ) by solving the equation $latex \[ y^i = y^{i-1} + \left[ G( y^i , a ) + G( y^{i-1} , a ) \right] * \frac{t_i - t_{i-1} }{ 2 } \] $$ where $latex G : \B{R}^{Ny} \times \B{R}^{Na} \rightarrow \B{R}^{Ny}$$ is the function representing this ODE; i.e. $latex \[ G(y, a) = \left( \begin{array}{c} - a_1 * y_0 \\ + a_1 * y_0 - a_2 * y_1 \end{array} \right) \] $$ This $latex G(y, a)$$ is linear with respect to $latex y$$, hence the implicit equation defining $latex y^i $$ can be solved inverting the a set of linear equations. In the general case, where $latex G(y, a)$$ is non-linear with respect to $latex y$$, an iterative procedure is used to calculate $latex y^i$$ from $latex y^{i-1}$$. $subhead Trapezoidal Time Grid$$ The discrete time grid, used for the trapezoidal approximation, is denoted by $latex \{ t_i \} $$ which is defined by: $latex t_0 = 0$$ and for $latex i = 1 , \ldots , Nz$$ and for $latex j = 1 , \ldots , N(i)$$, $latex \[ \begin{array}{rcl} \Delta t_i & = & ( s_i - s_{i-1} ) / N(i) \\ t_{S(i-1)+j} & = & s_{i-1} + \Delta t_i * j \end{array} \] $$ where $latex s_0 = 0$$, $latex N(i)$$ is the number of time grid points between $latex s_{i-1}$$ and $latex s_i$$, $latex S(0) = 0$$, and $latex S(i) = N(1) + \ldots + N(i)$$. Note that for $latex i = 0 , \ldots , S(Nz) $$, $latex y^i$$ denotes our approximation for $latex y( t_i , a )$$ and $latex t_{S(i)}$$ is equal to $latex s_i$$. $head 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 $latex a$$ one uses the $cref/trapezoidal approximation/ipopt_nlp_ode_problem/Trapezoidal Approximation/$$ (on a finer grid that $latex \{ s_i \}$$) to solve for $latex y_1 ( s_i , a )$$ for $latex i = 1 , \ldots , Nz$$. $subhead 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. $subhead Derivatives$$ In addition, in the black box approach, differentiating the ODE solution often involves differentiating an iterative procedure. Direct application of AD to compute these derivatives requires a huge amount of memory and calculations to differentiate the iterative procedure. (There are special techniques for applying AD to the solutions of iterative procedures, but that is outside the scope of this presentation). $head Simultaneous Method$$ The simultaneous forward and inverse method uses constraints to include the solution of the forward problem in the inverse problem. To be specific for our example, $latex \[ \begin{array}{rcl} {\rm minimize} & \sum_{i=1}^{Nz} H_i ( y^{N(i)} , a ) & \; {\rm w.r.t} \; y^1 \in \B{R}^{Ny} , \ldots , y^{S(Nz)} \in \B{R}^{Ny} , \; a \in \B{R}^{Na} \\ {\rm subject \; to} & y^j = y^{j-1} + \left[ G( y^{j-1} , a ) + G( y^j , a ) \right] * \frac{ t_j - t_{j-1} }{ 2 } & \; {\rm for} \; j = 1 , \ldots , S(Nz) \\ & y^0 = F(a) \end{array} \] $$ where for $latex i = 1, \ldots , Nz$$, $latex N(i)$$ is the number of time intervals between $latex s_{i-1}$$ and $latex s_i$$ (with $latex s_0 = 0$$) and $latex S(i) = N(1) + \ldots + 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. $children% cppad_ipopt/example/ode_problem.hpp %$$ $head Source$$ The file $cref ipopt_nlp_ode_problem.hpp$$ contains source code that defines the example values and functions defined above. $end ----------------------------------------------------------------------------- $begin ipopt_nlp_ode_simple$$ $spell cppad_ipopt_nlp $$ $section ODE Fitting Using Simple Representation$$ $mindex cppad_ipopt_nlp$$ $head Purpose$$ In this section we represent the objective and constraint functions, (in the simultaneous forward and reverse optimization problem) using the $cref/simple representation/cppad_ipopt_nlp/Simple Representation/$$ in the sense of $code cppad_ipopt_nlp$$. $head Argument Vector$$ The argument vector that we are optimizing with respect to ( $latex x$$ in $cref cppad_ipopt_nlp$$ ) has the following structure $latex \[ x = ( y^0 , \cdots , y^{S(Nz)} , a ) \] $$ Note that $latex x \in \B{R}^{S(Nz) + Na}$$ and $latex \[ \begin{array}{rcl} y^i & = & ( x_{Ny * i} , \ldots , x_{Ny * i + Ny - 1} ) \\ a & = & ( x_{Ny *S(Nz) + Ny} , \ldots , x_{Ny * S(Nz) + Na - 1} ) \end{array} \] $$ $head Objective Function$$ The objective function ( $latex fg_0 (x)$$ in $cref cppad_ipopt_nlp$$ ) has the following representation, $latex \[ fg_0 (x) = \sum_{i=1}^{Nz} H_i ( y^{S(i)} , a ) \] $$ $head Initial Condition Constraint$$ For $latex i = 1 , \ldots , Ny$$, we define the component functions $latex fg_i (x)$$, and corresponding constraint equations, by $latex \[ 0 = fg_i ( x ) = y_i^0 - F_i (a) \] $$ $head Trapezoidal Approximation Constraint$$ For $latex i = 1, \ldots , S(Nz)$$, and for $latex j = 1 , \ldots , Ny$$, we define the component functions $latex fg_{Ny*i + j} (x)$$, and corresponding constraint equations, by $latex \[ 0 = fg_{Ny*i + j } = y_j^{i} - y_j^{i-1} - \left[ G_j ( y^i , a ) + G_j ( y^{i-1} , a ) \right] * \frac{t_i - t_{i-1} }{ 2 } \] $$ $children% cppad_ipopt/example/ode_simple.hpp %$$ $head Source$$ The file $cref ipopt_nlp_ode_simple.hpp$$ contains source code for this representation of the objective and constraints. $end ----------------------------------------------------------------------------- $begin ipopt_nlp_ode_fast$$ $spell cppad_ipopt_nlp $$ $section ODE Fitting Using Fast Representation$$ $head 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). $head Objective Function$$ We use the following representation for the $cref/objective function/ipopt_nlp_ode_simple/Objective Function/$$: For $latex k = 0 , \ldots , Nz - 1$$, we define the function $latex r^k : \B{R}^{Ny+Na} \rightarrow \B{R}$$ by $latex \[ \begin{array}{rcl} fg_0 (x) & = & \sum_{i=1}^{Nz} H_i ( y^{S(i)} , a ) \\ fg_0 (x) & = & \sum_{k=0}^{Nz-1} r^k ( u^{k,0} ) \end{array} \] $$ where for $latex k = 0 , \ldots , Nz-1$$, $latex u^{k,0} \in \B{R}^{Ny + Na}$$ is defined by $latex u^{k,0} = ( y^{S(k+1)} , a )$$ $subhead Range Indices I(k,0)$$ For $latex k = 0 , \ldots , Nz - 1$$, the range index in the vector $latex fg (x)$$ corresponding to $latex r^k ( u^{k,0} ) $$ is 0. Thus, the range indices are given by $latex I(k,0) = \{ 0 \}$$ for $latex k = 0 , \ldots , Nz-1$$. $subhead Domain Indices J(k,0)$$ For $latex k = 0 , \ldots , Nz - 1$$, the components of the vector $latex x$$ corresponding to the vector $latex u^{k,0}$$ are $latex \[ \begin{array}{rcl} u^{k,0} & = & ( y^{S(k+1} , a ) \\ & = & ( x_{Ny * S(k+1)} \; , \; \ldots \; , \; x_{Ny * S(k+1) + Ny - 1} \; , \; x_{Ny * S(Nz) + Ny } \; , \; \ldots \; , \; x_{Ny * S(Nz) + Ny + Na - 1} ) \end{array} \] $$ Thus, the domain indices are given by $latex \[ J(k,0) = \{ Ny * S(k+1) \; , \; \ldots \; , \; Ny * S(k+1) + Ny - 1 \; , \; Ny * S(Nz) + Ny \; , \; \ldots \; , \; Ny * S(Nz) + Ny + Na - 1 \} \] $$ $head Initial Condition$$ We use the following representation for the $cref/initial condition constraint/ ipopt_nlp_ode_simple/Initial Condition Constraint/$$: For $latex k = Nz$$ we define the function $latex r^k : \B{R}^{Ny} \times \B{R}^{Na + Ny}$$ by $latex \[ \begin{array}{rcl} 0 & = & fg_i ( x ) = y_i^0 - F_i (a) \\ 0 & = & r_{i-1}^k ( u^{k,0} ) = y_i^0 - F_i(a) \end{array} \] $$ where $latex i = 1 , \ldots , Ny$$ and where $latex u^{k,0} \in \B{R}^{Ny + Na}$$ is defined by $latex u^{k,0} = ( y^0 , a)$$. $subhead Range Indices I(k,0)$$ For $latex k = Nz$$, the range index in the vector $latex fg (x)$$ corresponding to $latex r^k ( u^{k,0} ) $$ are $latex I(k,0) = \{ 1 , \ldots , Ny \}$$. $subhead Domain Indices J(k,0)$$ For $latex k = Nz$$, the components of the vector $latex x$$ corresponding to the vector $latex u^{k,0}$$ are $latex \[ \begin{array}{rcl} u^{k,0} & = & ( y^0 , a) \\ & = & ( x_0 \; , \; \ldots \; , \; x_{Ny-1} \; , \; x_{Ny * S(Nz) + Ny } \; , \; \ldots \; , \; x_{Ny * S(Nz) + Ny + Na - 1} ) \end{array} \] $$ Thus, the domain indices are given by $latex \[ J(k,0) = \{ 0 \; , \; \ldots \; , \; Ny - 1 \; , \; Ny * S(Nz) + Ny \; , \; \ldots \; , \; Ny * S(Nz) + Ny + Na - 1 \} \] $$ $head Trapezoidal Approximation$$ We use the following representation for the $cref/trapezoidal approximation constraint/ ipopt_nlp_ode_simple/Trapezoidal Approximation Constraint/$$: For $latex k = 1 , \ldots , Nz$$, we define the function $latex r^{Nz+k} : \B{R}^{2*Ny+Na} \rightarrow \B{R}^{Ny}$$ by $latex \[ r^{Nz+k} ( y , w , a ) = y - w - [ G( y , a ) + G( w , a ) ] * \frac{ \Delta t_k }{ 2 } \] $$ For $latex \ell = 0 , \ldots , N(k)-1$$, using the notation $latex i = Ny * S(k-1) + \ell + 1$$, the corresponding trapezoidal approximation is represented by $latex \[ \begin{array}{rcl} 0 & = & fg_{Ny+i} (x) \\ & = & y^i - y^{i-1} - \left[ G( y^i , a ) + G( y^{i-1} , a ) \right] * \frac{\Delta t_k }{ 2 } \\ & = & r^{Nz+k} ( u^{Nz+k , \ell} ) \end{array} \] $$ where $latex u^{Nz+k,\ell} \in \B{R}^{2*Ny + Na}$$ is defined by $latex u^{Nz+k,\ell} = ( y^{i-1} , y^i , a)$$. $subhead Range Indices I(k,0)$$ For $latex k = Nz + 1, \ldots , 2*Nz$$, and $latex \ell = 0 , \ldots , N(k)-1$$, the range index in the vector $latex fg (x)$$ corresponding to $latex r^k ( u^{k,\ell} ) $$ are $latex I(k,\ell) = \{ Ny + i , \ldots , 2*Ny + i - 1 \}$$ where $latex i = Ny * S(k-1) + \ell + 1$$. $subhead Domain Indices J(k,0)$$ For $latex k = Nz + 1, \ldots , 2*Nz$$, and $latex \ell = 0 , \ldots , N(k)-1$$, define $latex i = Ny * S(k-1) + \ell + 1$$. The components of the vector $latex x$$ corresponding to the vector $latex u^{k,\ell}$$ are (and the function $latex fg (x) $$ in $cref cppad_ipopt_nlp$$ ) $latex \[ \begin{array}{rcl} u^{k, \ell} & = & ( y^{i-1} , y^i , a ) \\ & = & ( x_{Ny * (i-1)} \; , \; \ldots \; , \; x_{Ny * (i+1) - 1} \; , \; x_{Ny * S(Nz) + Ny } \; , \; \ldots \; , \; x_{Ny * S(Nz) + Ny + Na - 1} ) \end{array} \] $$ Thus, the domain indices are given by $latex \[ J(k,\ell) = \{ Ny * (i-1) \; , \; \ldots \; , \; Ny * (i+1) - 1 \; , \; Ny * S(Nz) + Ny \; , \; \ldots \; , \; Ny * S(Nz) + Ny + Na - 1 \} \] $$ $children% cppad_ipopt/example/ode_fast.hpp %$$ $head Source$$ The file $cref ipopt_nlp_ode_fast.hpp$$ contains source code for this representation of the objective and constraints. $end ------------------------------------------------------------------------------ cppad-20160000.1/cppad_ipopt/example/example.cpp0000644000175200017650000000405712656321775020537 0ustar coincoin-web// $Id: example.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ // system include files used for I/O # include // C style asserts # include // CppAD include file # include // external complied tests extern bool ipopt_get_started(void); extern bool ode_simple_check(void); extern bool ode_fast_check(void); namespace { // function that runs one test static size_t Run_ok_count = 0; static size_t Run_error_count = 0; bool Run(bool TestOk(void), const char *name) { bool ok = true; ok &= TestOk(); if( ok ) { std::cout << "OK: " << name << std::endl; Run_ok_count++; } else { std::cout << "Error: " << name << std::endl; Run_error_count++; } return ok; } } // main program that runs all the tests int main(void) { bool ok = true; // external compiled tests ok &= Run( ipopt_get_started, "ipopt_get_started" ); ok &= Run( ode_simple_check, "ode_simple_check" ); ok &= Run( ode_fast_check, "ode_fast_check" ); // check for errors using std::cout; using std::endl; assert( ok || (Run_error_count > 0) ); if( CppAD::thread_alloc::free_all() ) { Run_ok_count++; cout << "OK: " << "No memory leak detected" << endl; } else { ok = false; Run_error_count++; cout << "Error: " << "memory leak detected" << endl; } // convert int(size_t) to avoid warning on _MSC_VER systems if( ok ) cout << "All " << int(Run_ok_count) << " tests passed." << endl; else cout << int(Run_error_count) << " tests failed." << endl; return static_cast( ! ok ); } cppad-20160000.1/cppad_ipopt/example/CMakeLists.txt0000644000175200017650000000346512656321775021142 0ustar coincoin-web# $Id: CMakeLists.txt 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Build the cppad_ipopt/example directory tests # Inherit environment from ../CMakeList.txt # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # Local include directories to search (not in package_prefix/include) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) # Local link directories to search (not in external packages) LINK_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}/../src ${ipopt_LIBRARY_DIRS} ) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(cppad_ipopt_example EXCLUDE_FROM_ALL example.cpp get_started.cpp ode_check.cpp ode_check.hpp ode_fast_check.cpp ode_fast.hpp ode_problem.hpp ode_run.hpp ode_simple_check.cpp ode_simple.hpp ) # Extra compiler flags add_cppad_cxx_flags( cppad_ipopt_example ) # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(cppad_ipopt_example cppad_ipopt ${cppad_lib} ${ipopt_LIBRARIES} ${colpack_libs} ) # Add the check_cppad_ipopt_example target ADD_CUSTOM_TARGET(check_cppad_ipopt_example cppad_ipopt_example DEPENDS cppad_ipopt_example cppad_ipopt ) cppad-20160000.1/cppad_ipopt/example/ode_problem.hpp0000644000175200017650000000602012656321775021370 0ustar coincoin-web// $Id: ode_problem.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ODE_PROBLEM_HPP # define CPPAD_ODE_PROBLEM_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ipopt_nlp_ode_problem.hpp$$ $spell cppad_ipopt_nlp Nz Ny Na $$ $section ODE Inverse Problem Definitions: Source Code$$ $mindex example$$ $code $verbatim%cppad_ipopt/example/ode_problem.hpp%0%// BEGIN C++%// END C++%1%$$ $$ $end ------------------------------------------------------------------------------ */ // BEGIN C++ # 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 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 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 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; } } // END C++ # endif cppad-20160000.1/cppad_ipopt/example/ode_run.hpp0000644000175200017650000000733212656321775020543 0ustar coincoin-web// $Id: ode_run.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ODE_RUN_HPP # define CPPAD_ODE_RUN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ipopt_nlp_ode_run.hpp$$ $spell Ipopt $$ $section Driver for Running the Ipopt ODE Example$$ $code $verbatim%cppad_ipopt/example/ode_run.hpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include "ode_problem.hpp" namespace { // BEGIN empty namespace ----------------------------------------- using namespace cppad_ipopt; template 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 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 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 ---------------------------------------------------- // END C++ # endif cppad-20160000.1/cppad_ipopt/example/makefile.in0000644000175200017650000004777012656321775020516 0ustar coincoin-web# 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 = example$(EXEEXT) subdir = cppad_ipopt/example ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = test.sh CONFIG_CLEAN_VPATH_FILES = am_example_OBJECTS = example.$(OBJEXT) get_started.$(OBJEXT) \ ode_check.$(OBJEXT) ode_fast_check.$(OBJEXT) \ ode_simple_check.$(OBJEXT) example_OBJECTS = $(am_example_OBJECTS) example_LDADD = $(LDADD) am__DEPENDENCIES_1 = example_DEPENDENCIES = $(am__DEPENDENCIES_1) $(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 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 = $(example_SOURCES) DIST_SOURCES = $(example_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 $(srcdir)/test.sh.in \ $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@ ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@ 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 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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@ # EXTRA_DIST = \ ode1.omh \ ode2.omh # AM_CXXFLAGS = -g $(CXX_FLAGS) # AM_CPPFLAGS = -I. \ -I$(top_srcdir) \ -I$(top_srcdir)/cppad_ipopt/src \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # LDADD = \ -lcppad_ipopt \ $(CPPAD_IPOPT_LIBS) \ $(FCLIBS) \ $(PTHREAD_LIB) \ $(DL_LIB) AM_LDFLAGS = -L../src # example_SOURCES = \ example.cpp \ get_started.cpp \ ode_check.cpp \ ode_check.hpp \ ode_fast_check.cpp \ ode_fast.hpp \ ode_problem.hpp \ ode_run.hpp \ ode_simple_check.cpp \ ode_simple.hpp 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) --gnu cppad_ipopt/example/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu cppad_ipopt/example/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): test.sh: $(top_builddir)/config.status $(srcdir)/test.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ clean-checkPROGRAMS: -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) example$(EXEEXT): $(example_OBJECTS) $(example_DEPENDENCIES) $(EXTRA_example_DEPENDENCIES) @rm -f example$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(example_OBJECTS) $(example_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_started.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_check.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_fast_check.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_simple_check.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 ./test.sh # 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: cppad-20160000.1/cppad_ipopt/example/ode_check.cpp0000644000175200017650000000613712656321775021011 0ustar coincoin-web// $Id: ode_check.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 ipopt_nlp_ode_check.cpp$$ $section Correctness Check for Both Simple and Fast Representations$$ $code $verbatim%cppad_ipopt/example/ode_check.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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; double max_step = 0.; for(i = 1; i <= Nz; i++) { S[i] = S[i-1] + N[i]; max_step = std::max(max_step, (s[i] - s[i-1]) / 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(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; } // END C++ cppad-20160000.1/cppad_ipopt/example/get_started.cpp0000644000175200017650000001210212656321775021377 0ustar coincoin-web// $Id: get_started.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ipopt_nlp_get_started.cpp$$ $spell 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 the class cppad_ipopt_nlp to solve the example problem in the Ipopt documentation; i.e., the problem $latex \[ \begin{array}{lc} {\rm minimize \; } & x_1 * x_4 * (x_1 + x_2 + x_3) + x_3 \\ {\rm subject \; to \; } & x_1 * x_2 * x_3 * x_4 \geq 25 \\ & x_1^2 + x_2^2 + x_3^2 + x_4^2 = 40 \\ & 1 \leq x_1, x_2, x_3, x_4 \leq 5 \end{array} \] $$ $head Configuration Requirement$$ This example will be compiled and tested provided that a value for $icode ipopt_prefix$$ is specified on the $cref cmake$$ command line. $code $verbatim%cppad_ipopt/example/get_started.cpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # include 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 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 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; } // END C++ cppad-20160000.1/cppad_ipopt/example/ode_check.hpp0000644000175200017650000000133512656321775021011 0ustar coincoin-web// $Id: ode_check.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ODE_CHECK_HPP # define CPPAD_ODE_CHECK_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-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. -------------------------------------------------------------------------- */ extern bool ode_check(const SizeVector& N, const NumberVector& x); # endif cppad-20160000.1/cppad_ipopt/example/test.sh.in0000644000175200017650000000125412656321775020314 0ustar coincoin-web#! /bin/bash -e # $Id: test.sh.in 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. # ----------------------------------------------------------------------------- export LD_LIBRARY_PATH=@CPPAD_IPOPT_LD_PATH@ ./example cppad-20160000.1/cppad_ipopt/example/ode_simple_check.cpp0000644000175200017650000000204212656321775022351 0ustar coincoin-web// $Id: ode_simple_check.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 "ode_run.hpp" # include "ode_simple.hpp" # include "ode_check.hpp" bool ode_simple_check(void) { bool ok = true; bool retape; size_t i; // 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] = 4; for(i = 0; i < 2; i++) { retape = bool(i); ipopt_ode_case(retape, N, x); ok &= ode_check(N, x); } return ok; } cppad-20160000.1/cppad_ipopt/example/ode_fast_check.cpp0000644000175200017650000000203212656321775022014 0ustar coincoin-web// $Id: ode_fast_check.cpp 3785 2016-02-08 12:53:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of 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 "ode_run.hpp" # include "ode_fast.hpp" # include "ode_check.hpp" bool ode_fast_check(void) { bool ok = true; bool retape; size_t i; // 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] = 5; for(i = 0; i < 2; i++) { retape = bool(i); ipopt_ode_case(retape, N, x); ok &= ode_check(N, x); } return ok; } cppad-20160000.1/cppad_ipopt/example/ode_simple.hpp0000644000175200017650000000665312656321775021235 0ustar coincoin-web// $Id: ode_simple.hpp 3757 2015-11-30 12:03:07Z bradbell $ # ifndef CPPAD_ODE_SIMPLE_HPP # define CPPAD_ODE_SIMPLE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin ipopt_nlp_ode_simple.hpp$$ $spell cppad_ipopt_nlp Nz Ny Na $$ $section ODE Fitting Using Simple Representation$$ $mindex cppad_ipopt_nlp example source$$ $code $verbatim%cppad_ipopt/example/ode_simple.hpp%0%// BEGIN C++%// END C++%1%$$ $$ $end */ // BEGIN C++ # 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(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_; } }; } // END C++ # endif cppad-20160000.1/cppad_ipopt/CMakeLists.txt0000644000175200017650000000271712656321775017506 0ustar coincoin-web# $Id: CMakeLists.txt 3754 2015-11-26 22:23:05Z 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. # ----------------------------------------------------------------------------- # Build the cppad_ipopt/* directory tests # Inherit environment from ../CMakeList.txt # Initialize list of tests as empty SET(check_depends "") # assert ipopt_prefix is defined IF ( NOT ipopt_prefix ) MESSAGE(FATAL_ERROR "cppad_ipopt/CMakeLists.txt: ipopt_prefix = ${ipopt_prefix}" ) ENDIF ( NOT ipopt_prefix ) # The CMakeLists.txt file in the specified source directory is processed # before the current input file continues beyond this command. # add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL]) ADD_SUBDIRECTORY(src) # ADD_SUBDIRECTORY(example) add_to_list(check_depends check_cppad_ipopt_example) # ADD_SUBDIRECTORY(speed) add_to_list(check_depends check_cppad_ipopt_speed) # ADD_SUBDIRECTORY(test) add_to_list(check_depends check_cppad_ipopt_test) # Add the check_cppad_ipopt target ADD_CUSTOM_TARGET(check_cppad_ipopt DEPENDS ${check_depends} ) cppad-20160000.1/print_for/0002755000175200017650000000000012656321775014441 5ustar coincoin-webcppad-20160000.1/print_for/makefile.in0000644000175200017650000004544512656321775016560 0ustar coincoin-web# 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 = print_for$(EXEEXT) subdir = print_for 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_print_for_OBJECTS = print_for.$(OBJEXT) print_for_OBJECTS = $(am_print_for_OBJECTS) print_for_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 = $(print_for_SOURCES) DIST_SOURCES = $(print_for_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@ # $Id: makefile.in 3762 2015-12-01 14:35:37Z 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. # ----------------------------------------------------------------------------- # 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@ EGREP = @EGREP@ EIGEN_DIR = @EIGEN_DIR@ EIGEN_INCLUDE = @EIGEN_INCLUDE@ EXEEXT = @EXEEXT@ FADBAD_DIR = @FADBAD_DIR@ FC = @FC@ FCFLAGS = @FCFLAGS@ FCLIBS = @FCLIBS@ GREP = @GREP@ 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_boostvector = @cppad_boostvector@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ cppad_deprecated = @cppad_deprecated@ cppad_description = @cppad_description@ cppad_eigenvector = @cppad_eigenvector@ cppad_has_colpack = @cppad_has_colpack@ cppad_has_cstdint_8_to_64 = @cppad_has_cstdint_8_to_64@ cppad_has_gettimeofday = @cppad_has_gettimeofday@ cppad_has_high_resolution_clock = @cppad_has_high_resolution_clock@ cppad_has_mkstemp = @cppad_has_mkstemp@ cppad_has_nullptr = @cppad_has_nullptr@ cppad_has_rvalue = @cppad_has_rvalue@ cppad_internal_sparse_set = @cppad_internal_sparse_set@ 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_size_t_not_unsigned_int = @cppad_size_t_not_unsigned_int@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ cppad_url = @cppad_url@ cppad_use_cplusplus_2011 = @cppad_use_cplusplus_2011@ cppad_version = @cppad_version@ datadir = @datadir@ datarootdir = @datarootdir@ 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_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 # AM_CPPFLAGS = -I. $(CPPAD_INCLUDE) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # AM_CXXFLAGS = -g $(CXX_FLAGS) # print_for_SOURCES = print_for.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) --gnu print_for/makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu print_for/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) print_for$(EXEEXT): $(print_for_OBJECTS) $(print_for_DEPENDENCIES) $(EXTRA_print_for_DEPENDENCIES) @rm -f print_for$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(print_for_OBJECTS) $(print_for_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print_for.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 $(srcdir)/test.sh # 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: cppad-20160000.1/print_for/print_for.cpp0000644000175200017650000000637612656321775017161 0ustar coincoin-web// $Id: print_for.cpp 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ /* $begin print_for_cout.cpp$$ $spell const var av num inuse omp_alloc 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$$ To build this program and run its correctness test see $cref cmake_check$$. $head Source Code$$ $codep */ # 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; // 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) 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; } int main(void) { bool ok = true; print_for(); size_t thread; for(thread = 0; thread < 2; thread++) { ok &= CppAD::omp_alloc::inuse(thread) == 0; ok &= CppAD::omp_alloc::available(thread) == 0; } if( ! ok ) return 1; 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 $$ $end */ cppad-20160000.1/print_for/test.sh0000755000175200017650000000143212656321775015755 0ustar coincoin-web#! /bin/bash -e # $Id: 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. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- ./print_for | tee test.log sed -e '/^Test passes/,\$$d' < test.log > test.1 sed -e '1,/^Test passes/d' < test.log > test.2 if ! diff test.1 test.2 ; then exit 1 ; fi cppad-20160000.1/print_for/makefile.am0000644000175200017650000000233212656321775016533 0ustar coincoin-web# $Id: makefile.am 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 = # # 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 # # 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) # print_for_SOURCES = print_for.cpp test: check $(srcdir)/test.sh cppad-20160000.1/print_for/CMakeLists.txt0000644000175200017650000000223312656321775017177 0ustar coincoin-web# $Id: CMakeLists.txt 2564 2012-11-12 21:55:25Z 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. # ----------------------------------------------------------------------------- # Build the print_for directory tests # Inherit environment from ../CMakeList.txt # Specifies build type for this directory. Possible values are # empty, Debug, Release, RelWithDebInfo and MinSizeRel SET(CMAKE_BUILD_TYPE DEBUG) # add_executable( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] # source1 source2 ... sourceN # ) ADD_EXECUTABLE(print_for EXCLUDE_FROM_ALL print_for.cpp) # Add extra compiler flags add_cppad_cxx_flags(print_for) # Add the check_print_for target ADD_CUSTOM_TARGET(check_print_for print_for DEPENDS print_for) cppad-20160000.1/.gitignore0000644000175200017650000000115512611022441014402 0ustar coincoin-web# top directory only git_commit.sh aclocal.m4 ar-lib autom4te.cache build commit.sh.old doc doxydoc cppad/configure.hpp # all directories *.err */*.err */*/*.err *.log */*.log */*/*.log *.swp */*.swp */*/*.swp *.tmp */*.tmp */*/*.tmp build */build */*/build new */new */*/new test_one.exe */test_one.exe */*/test_one.exe test_one.sh */test_one.sh */*/test_one.sh test_one.cpp */test_one.cpp */*/test_one.cpp # all directories with and without extension doxyfile doxyfile.* */doxyfile */doxyfile.* */*/doxyfile */*/doxyfile.* junk junk.* */junk */junk.* */*/junk */*/junk.* temp temp.* */temp */temp.* */*/temp */*/temp.* cppad-20160000.1/INSTALL0000644000175200017650000000006112450414402013441 0ustar coincoin-webSee http://www.coin-or.org/CppAD/Doc/install.htm cppad-20160000.1/pkgconfig/0002755000175200017650000000000012656321775014406 5ustar coincoin-webcppad-20160000.1/pkgconfig/CMakeLists.txt0000644000175200017650000000530112656321775017143 0ustar coincoin-web# $Id: CMakeLists.txt 3608 2015-01-23 12:20:38Z 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. # ----------------------------------------------------------------------------- # 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 "") # # Settings that are only included if cppad is configured with ipopt. # (Note that ipopt has a pkgconfig file.) IF( ipopt_prefix ) SET(cppad_pkgconfig_requires "ipopt") SET(cppad_pkgconfig_libs "-L${cppad_abs_libdir} -lcppad_ipopt") ENDIF( ipopt_prefix ) # # Settings that are only included if cppad is configured with colpack # (Note that colpack does not have a pkgconfig file.) IF( colpack_prefix ) 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) ENDIF( colpack_prefix ) # MESSAGE(STATUS "cppad_pkgconfig_cflags = ${cppad_pkgconfig_cflags}") MESSAGE(STATUS "cppad_pkgconfig_libs = ${cppad_pkgconfig_libs}") MESSAGE(STATUS "cppad_pkgconfig_requires = ${cppad_pkgconfig_requires}") # # Copy a file to another location and modify its contents. # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) CONFIGURE_FILE( ${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 ) # 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 ) cppad-20160000.1/pkgconfig/cppad-uninstalled.pc.in0000644000175200017650000000161512656321775020747 0ustar coincoin-web# $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 is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 file is used with pkg-config to include CppAD before it is installed. 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: cppad-20160000.1/pkgconfig/cppad.pc.in0000644000175200017650000000257612656321775016436 0ustar coincoin-web# $Id: cppad.pc.in 3760 2015-12-01 04:12: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. # # A copy of 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 file is used with pkg-config to include CppAD after it is installed # ------------------------------------------------------------------------- # HACK: With no specifications as to what will work in the future, set the # values 'includedir' and 'prefix' so cppad.pc works with the 2015-01-21 # verison of https://build.opensuse.org/package/view_file/ # windows:mingw:win32/mingw32-filesystem/mingw32-install-post.sh?expand=1 prefix=@cppad_prefix@ includedir=@cppad_abs_includedir@ # ------------------------------------------------------------------------- Name: cppad Description: @cppad_description@ Version: @cppad_version@ URL: @cppad_url@ Cflags: @cppad_pkgconfig_cflags@ Libs: @cppad_pkgconfig_libs@ Requires: @cppad_pkgconfig_requires@ cppad-20160000.1/COPYING0000644000175200017650000010554512656321777013504 0ustar coincoin-web/* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-09 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the Eclipse Public License Version 1.0. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ 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 . cppad-20160000.1/bin/0002755000175200017650000000000012656321776013210 5ustar coincoin-webcppad-20160000.1/bin/check_user_def.sh0000755000175200017650000000414612656321776016503 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ $0 != "bin/check_user_def.sh" ] then echo "bin/check_user_def.sh: must be executed from its parent directory" exit 1 fi # --------------------------------------------------------------------------- echo 'Check user API preprocessor define symbols' echo '-----------------------------------------------------------------------' file_list=`bin/search.sh 'head CPPAD' | sed -e '/bin\/check_user_def.sh/d'` symbol_list='' for file in $file_list do symbol=`sed -n -e '/$head CPPAD/p' -e '/$subhead CPPAD/p' $file | sed \ -e 's/^.*head \(CPPAD[a-zA-Z0-9_]*\).*/\1/'` symbol_list="$symbol_list $symbol:$file" done for symbol_file in $symbol_list do symbol=`echo $symbol_file | sed -e 's|:.*||'` file=`echo $symbol_file | sed -e 's|.*:||'` if ! grep $symbol omh/preprocessor.omh > /dev/null then echo "The symbol $symbol" echo "appears in $file omhelp documentation" echo 'but does not appear in omh/preprocessor.omh' exit 1 fi done for symbol_file in $symbol_list do symbol=`echo $symbol_file | sed -e 's|:.*||'` file=`echo $symbol_file | sed -e 's|.*:||'` ok='false' if grep "$symbol *in user api" cppad/local/undef.hpp > /dev/null then ok='true' fi if grep "$symbol *in deprecated api" cppad/local/undef.hpp > /dev/null then ok='true' fi if [ "$ok" == 'false' ] then echo "The symbol $symbol" echo "appears in $file omhelp documentation" echo "but is not listed as in user api in cppad/local/undef.hpp" exit 1 fi done echo '-----------------------------------------------------------------------' echo "check_user_def.sh: OK" cppad-20160000.1/bin/search.sh0000755000175200017650000000225412656321776015015 0ustar coincoin-web#! /bin/bash -e # $Id: search.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 [ ! -e "bin/search.sh" ] then echo "bin/search.sh: must be executed from its parent directory" exit 1 fi if [ "$1" == "" ] then echo 'usage: bin/search.sh pattern' echo ' Search for pattern in the cppad source code' exit 1 fi pattern="$1" # ----------------------------------------------------------------------------- list=`bin/list_files.sh | sed \ -e '/^configure$/d' \ -e '/^makefile.in$/d' \ -e '/\/makefile.in$/d' \ -e '/^compile/d'` grep -l "$pattern" $list # ---------------------------------------------------------------------------- exit 0 cppad-20160000.1/bin/new_branch.sh0000755000175200017650000000746712656321776015671 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ "$0" != "bin/new_branch.sh" ] then echo 'bin/new_branch.sh: must be executed from its parent directory' exit 1 fi if [ "$1" == '' ] || [ "$2" == 'trunk' ] then echo 'usage: bin/new_branch.sh svn_branch_path' echo 'copies the current trunk to svn_branch_path' exit 1 fi svn_branch_path="$1" # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { echo $* eval $* } # ----------------------------------------------------------------------------- # some settings svn_repository='https://projects.coin-or.org/svn/CppAD' work_directory='build/work' # ----------------------------------------------------------------------------- # check that remote master is in sync hash_origin=`git show-ref origin/master | sed -e 's|^\([0-9a-f]*\).*|\1|'` hash_list=`git show-ref master | sed -e 's|^\([0-9a-f]*\).*|\1|'` for hash in $hash_list do if [ "$hash" != "$hash_origin" ] then echo_eval git show-ref master echo 'exiting because hash codes are different' exit 1 fi done # ----------------------------------------------------------------------------- # make sure work directory exists if [ ! -d "$work_directory" ] then echo_eval mkdir -p "$work_directory" fi # ----------------------------------------------------------------------------- # checkout svn version of directory svn_directory="$work_directory/svn" if [ -e "$svn_directory" ] then echo 'Use existing svn direcory' echo " $svn_directory" read -p '? [y/n] ' response if [ "$response" != 'y' ] then echo_eval rm -r $svn_directory else echo_eval svn revert --recursive $svn_directory echo_eval svn update $svn_directory svn_status=`svn status $svn_directory | \ sed -n -e '/^\?/p' | sed -e 's|^\? *||'` for file_name in $svn_status do echo_eval rm $file_name done fi fi if [ ! -e "$svn_directory" ] then echo_eval svn checkout $svn_repository/trunk $svn_directory fi # ---------------------------------------------------------------------------- # git hash code corresponding to current version of trunk svn_revision=`svn info $svn_directory | \ sed -n -e '/^Last Changed Rev:/p' | sed -e 's|^Last Changed Rev: *||'` hash_svn=`svn log -r $svn_revision $svn_directory | \ sed -n -e '/^end *hash *code:/p' | sed -e 's|^end *hash *code: *||'` if [ "$hash_origin" != "$hash_svn" ] then echo "$hash_origin hash code for master" echo "$hash_svn hash code for trunk" echo 'Exiting because hash codes are different.' echo 'Use the following command to fix this' echo ' bin/push_git2svn.py trunk' exit 1 fi # ----------------------------------------------------------------------------- echo_eval git checkout master git_branch_name=`echo $svn_branch_path | sed -e 's|^branches/||'` echo_eval git branch $git_branch_name echo_eval git checkout $git_branch_name git push --set-upstream origin $git_branch_name # ----------------------------------------------------------------------------- cat << EOF > $svn_directory/new_branch.log copy trunk to: $svn_branch_path start hash code: $hash_origin end hash code: $hash_origin EOF echo_eval svn copy --file new_branch.log \ $svn_repository/trunk $svn_repository/$svn_branch_path # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/new_test.sh0000755000175200017650000000615212656321776015401 0ustar coincoin-web#! /bin/bash -e # $Id: new_test.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 [ ! -e "bin/new_test.sh" ] then echo "bin/new_test.sh: must be executed from its parent directory" exit 1 fi change_list="" file_path="$1" # vim bash highlighting has an error so cannot use # ext="${file_path: -4}" ext=`echo $file_path | sed -e 's|.*\(....\)$|\1|'` if [ "$ext" != ".cpp" ] || [ ! -e $file_path ] then echo "usage: bin/new_test.sh file_path" echo "where file_path is the new test which must have .cpp extension" exit 1 fi # extract the directory and file name dir=`echo $file_path | sed -e 's|/[^/]*||'` file=`echo $file_path | sed -e 's|.*/||'` # echo "cd $dir" cd $dir # # extract the program that runs all tests and name of this new test program=`sed -n -e '/_SOURCES/p' makefile.am | sed -e 's|^\t*\(.*\)_SOURCE.*|\1|'` name=`grep '^bool *[a-zA-Z0-9_]*( *void *)' $file | tail -1 | \ sed -e 's|^bool *\([a-zA-Z0-9_]*\)( *void *)|\1|'` # --------------------------------------------------------------------------- echo "add $file to $program.cpp" change_list="$program.cpp" svn revert $program.cpp comment="// prototype external compiled tests" if ! grep "$comment" $program.cpp > /dev/null then echo "$comment missing in $program.cpp" exit 1 fi sed -i -e "s|$comment.*|&\nextern bool $name(void);|" $program.cpp comment="// run external compiled tests" if ! grep "$comment" $program.cpp > /dev/null then echo "$comment missing in $program.cpp" exit 1 fi sed -i -e "s|$comment.*|&\n\tok \&= Run( $name, \"$name\" );|" $program.cpp # # --------------------------------------------------------------------------- echo "add $file to $dir/makefile.am" change_list="$change_list makefile.am" svn revert makefile.am sed -i -e "/_SOURCES/s|.*|&\n\t$file|" -e '/_SOURCES/s|$| \\|' makefile.am # --------------------------------------------------------------------------- # only MS project file is left to do if ! ls *.vcproj >& /dev/null then # no MS project file in this directory echo echo "Should hand edit to sort new entries in following files in $dir:" echo "$change_list" exit 0 fi project=`ls *.vcproj` echo "add $file to $dir/$project" change_list="$change_list $project" cat << EOF > new_test.sed /Name="Source Files"/b join b end :join N / \r\n\ \r\n\ &| :end EOF svn revert $project sed -i -f new_test.sed $project # echo echo "Should hand edit to sort new entries in following files:" echo "$change_list" # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/dir_copy.sh0000755000175200017650000000437012656321776015361 0ustar coincoin-web#! /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 cppad-20160000.1/bin/check_makefile.sh0000755000175200017650000000724412656321776016466 0ustar coincoin-web#! /bin/bash -e # $Id: check_makefile.sh 3762 2015-12-01 14:35:37Z 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 [ ! -e "bin/check_makefile.sh" ] then echo "bin/check_makefile.sh: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- echo "Checking include files listed in makefile.am" echo "-------------------------------------------------------" bin/list_files.sh .h .hpp | sed -n \ -e '/^cppad\/deprecated\//d' \ -e '/cppad\/.*\.h$/p' \ -e '/cppad\/.*\.hpp$/p' \ > check_makefile.1.$$ echo 'cppad/configure.hpp' >> check_makefile.1.$$ sort -u check_makefile.1.$$ > check_makefile.2.$$ # 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=`find . -name makefile.am | \ sed -e '/\/build\//d' -e'/\/work\//d' -e 's|\./||'` ok="yes" for file in $list do case $file in ( makefile.am | work/* | svn_dist/* ) ;; (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 ;; (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 cppad-20160000.1/bin/get_ipopt.sh0000755000175200017650000001002112656321776015531 0ustar coincoin-web#! /bin/bash -e # $Id: get_ipopt.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. # # A copy of 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 get_ipopt.sh$$ $newlinech #$$ # $spell # tgz # Ipopt # CppAD # $$ # # $section Download and Install Ipopt in Build Directory$$ # $index ipopt, download and install$$ # $index download, install ipopt$$ # $index install, ipopt$$ # # $head Syntax$$ # $code bin/get_ipopt.sh$$ # # $head Purpose$$ # If you are using Unix, this command will download and install # $href%http://www.coin-or.org/projects/Ipopt.xml%Ipopt%$$ in the # CppAD $code build$$ directory. # # $head Distribution Directory$$ # This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ # The Ipopt source code is downloaded and compiled in the sub-directory # $code build/external$$ below the distribution directory. # # $head Prefix Directory$$ # The Ipopt libraries and include files are installed in the sub-directory # $code build/prefix$$ below the distribution directory. # # $head Reuse$$ # The file $codei%build/external/Ipopt-%version%.tgz%$$ # and the directory $codei%build/external/Ipopt-%version%$$ # will be reused if they exist. Delete this file and directory # to get a complete rebuild. # # $end # ----------------------------------------------------------------------------- if [ $0 != "bin/get_ipopt.sh" ] then 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 'Download ipopt to build/external and install it to build/prefix' version='3.11.9' web_page='http://www.coin-or.org/download/source/Ipopt' cppad_dir=`pwd` prefix="$cppad_dir/build/prefix" installed_flag="build/external/ipopt-${version}.installed" if [ -e "$installed_flag" ] then echo "$installed_flag exists: Skipping get_ipopt.sh" exit 0 fi # ----------------------------------------------------------------------------- if [ ! -d build/external ] then 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" fi if [ ! -e "Ipopt-$version" ] then 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 done # ----------------------------------------------------------------------------- if [ -e ThirdParty/HSL ] then 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 done # ----------------------------------------------------------------------------- if [ -e /usr/lib64 ] then libdir='lib64' else libdir='lib' fi export PKG_CONFIG_PATH="$prefix/$libdir/pkgconfig" echo_eval ./configure \ --enable-debug \ --prefix="$prefix" \ --libdir="$prefix/$libdir" echo_eval make install # ----------------------------------------------------------------------------- echo_eval touch $cppad_dir/$installed_flag echo "get_ipopt.sh: OK" cppad-20160000.1/bin/get_colpack.sh0000755000175200017650000000767312656321776016035 0ustar coincoin-web#! /bin/bash -e # $Id: get_colpack.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. # # A copy of 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 get_colpack.sh$$ $newlinech #$$ # $spell # colpack # gz # Col # CppAD # $$ # # $section Download and Install ColPack in Build Directory$$ # # $head Syntax$$ # $code bin/get_colpack.sh$$ # # $head Purpose$$ # If you are using Unix, this command will download and install # $href%http://cscapes.cs.purdue.edu/dox/ColPack/html/%ColPack%$$ in the # CppAD $code build$$ directory. # # $head Distribution Directory$$ # This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ # The ColPack source code is downloaded into the sub-directory # $code build/external$$ below the distribution directory. # # $head Prefix Directory$$ # The ColPack include files are installed in the sub-directory # $code build/prefix/include/ColPack$$ below the distribution directory. # # $head Reuse$$ # The file $codei%build/external/ColPack-%version%.tar.gz%$$ # and the directory $codei%build/external/ColPack-%version%$$ # will be reused if they exist. Delete this file and directory # to get a complete rebuild. # # $end # ----------------------------------------------------------------------------- if [ $0 != "bin/get_colpack.sh" ] then 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 'Download colpack to build/external and install it to build/prefix' version='1.0.9' web_page='http://cscapes.cs.purdue.edu/download/ColPack' cppad_dir=`pwd` prefix="$cppad_dir/build/prefix" installed_flag="build/external/colpack-${version}.installed" if [ -e "$installed_flag" ] then echo "$installed_flag exists: Skipping get_colpack.sh" exit 0 fi # -------------------------------------------------------------------------- if [ -e /usr/lib64 ] then libdir='lib64' else libdir='lib' fi # ----------------------------------------------------------------------------- if [ ! -d build/external ] then echo_eval mkdir -p build/external fi echo_eval cd build/external # ----------------------------------------------------------------------------- if [ ! -e "ColPack-$version.tar.gz" ] then echo_eval wget --no-check-certificate $web_page/ColPack-$version.tar.gz fi # ----------------------------------------------------------------------------- if [ ! -e ColPack-$version ] then echo_eval tar -xzf ColPack-$version.tar.gz fi echo_eval cd ColPack-$version # ----------------------------------------------------------------------------- if which autoconf >& /dev/null then echo_eval rm aclocal.m4 ltmain.sh 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 else lib_type='--enable-static --enable-shared' fi echo_eval ./configure \ --prefix=$prefix \ --libdir=$prefix/$libdir \ $lib_type # echo_eval make install # ----------------------------------------------------------------------------- echo_eval touch $cppad_dir/$installed_flag echo "get_colpack: OK" cppad-20160000.1/bin/new_release.sh0000755000175200017650000001127312656321776016042 0ustar coincoin-web#! /bin/bash -e # $Id: new_release.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 [ ! -e "bin/new_release.sh" ] then 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 $* } # ----------------------------------------------------------------------------- svn_repository="https://projects.coin-or.org/svn/CppAD" stable_version="20150000" release='4' release_version="$stable_version.$release" # ----------------------------------------------------------------------------- # Check release version if svn list $svn_repository/releases | grep "$release_version" > /dev/null then echo bin/"new_release.sh: Release number $release_version already exists." echo "You must first change the assigment" echo " release=$release" echo "in file bin/new_release.sh to a higher release number." exit 1 fi # ----------------------------------------------------------------------------- echo_eval git checkout stable/$stable_version # ----------------------------------------------------------------------------- # check that local branch is up to date list=`git status -s` if [ "$list" != '' ] then echo "new_release.sh: 'git status -s' is not empty" exit 1 fi # ----------------------------------------------------------------------------- # check that remote branch agrees with local branch local_hash=`git show-ref stable/$stable_version | \ grep "refs/heads/stable/$stable_version" | \ sed -e "s| *refs/heads/stable/$stable_version||"` remote_hash=`git show-ref stable/$stable_version | \ grep "refs/remotes/origin/stable/$stable_version" | \ sed -e "s| *refs/remotes/origin/stable/$stable_version||"` if [ "$local_hash" != "$remote_hash" ] then echo_eval git show-ref stable/$stable_version echo 'new_release.sh: exiting because local and remote branch differ' exit 1 fi # ----------------------------------------------------------------------------- check_one=`bin/version.sh get` echo_eval git checkout doc.omh check_two=`grep "cppad-$stable_version" doc.omh \ | sed -e 's|cppad-\([0-9.]*\):.*|\1|'` if [ "$check_one" != "$release_version" ] || [ "$check_one" != "$check_two" ] then echo 'bin/new_release.sh:' echo 'Set new version number with following commands:' echo " bin/version.sh set $release_version" echo ' bin/version.sh copy' echo 'Then test and then commit the changes.' fi # ----------------------------------------------------------------------------- svn_hash=`svn log $svn_repository/stable/$stable_version --stop-on-copy | \ grep 'end *hash *code:' | head -1 | sed -e 's|end *hash *code: *||'` if [ "$svn_hash" != "$remote_hash" ] then echo "svn hash code = $svn_hash" echo "git hash code = $remote_hash" echo 'Then execute the following command:' echo " bin/push_git2svn.py stable/$stable_version" exit 1 fi # ----------------------------------------------------------------------------- # tag this version of the repository if git tag --list | grep "$release_version" then git tag -d $release_version git push --delete origin $release_version fi # git tag -a \ -m "corresponds $svn_repository/releases/$release_version" \ $release_version # git push origin $release_version # ----------------------------------------------------------------------------- msg="Creating releases/$release_version" rep_stable="$svn_repository/stable/$stable_version" rep_release="$svn_repository/releases/$release_version" 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_repository/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 "/^ * y'(3)" echo "change: introduction/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/introduction/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/introduction/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 cppad-20160000.1/bin/package.sh0000755000175200017650000001202712656321776015142 0ustar coincoin-web#! /bin/bash -e # $Id: package.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/package.sh" ] then echo "bin/package.sh: must be executed from its parent directory" exit 1 fi echo_log_eval() { echo $* echo $* >> $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 } if [ -e package.log ] then echo "rm package.log" rm package.log fi top_srcdir=`pwd` # ---------------------------------------------------------------------------- this_license=`\ grep '$verbatim%' omh/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/license.omh' exit 1 fi # ---------------------------------------------------------------------------- # Automated updates to source directory # # Get version number and make sure all copies of it are up to date. version=`bin/version.sh get` echo_log_eval bin/version.sh get echo_log_eval bin/version.sh copy # ---------------------------------------------------------------------------- # Run automated checks for the form bin/check_*.sh with a few exceptions. # Note that check_include_omh.sh uses files built by cmake. list=`ls bin/check_* | sed \ -e '/check_all.sh/d' \ -e '/check_jenkins.sh/d' \ -e '/check_svn_dist.sh/d'` for check in $list do echo_log_eval $check done # ---------------------------------------------------------------------------- # Check for doxygen errors echo_log_eval bin/run_doxygen.sh # ---------------------------------------------------------------------------- # Create the package directory package_dir="build/cppad-$version" if [ -e "$package_dir" ] then echo_log_eval rm -r $package_dir fi for lic in epl gpl do if [ -e "$package_dir.epl.tgz" ] then echo_log_eval rm $package_dir.$lic.tgz fi done echo_log_eval mkdir -p $package_dir # ----------------------------------------------------------------------------- # Source file that are coppied to the package directory file_list=`bin/list_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 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 fi # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/colpack.sh0000755000175200017650000001073212656321776015164 0ustar coincoin-web#! /bin/bash -e # $Id: colpack.sh 3768 2015-12-28 18:58:35Z bradbell $ if [ "$1" != 'forward' ] && [ "$1" != 'reverse' ] then echo 'usage: ./colpack.sh option' echo 'where option is "forward" or "reverse"' exit 1 fi if [ "$1" == 'forward' ] then color_variant="COLUMN_PARTIAL_DISTANCE_TWO" else color_variant="ROW_PARTIAL_DISTANCE_TWO" fi # ---------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { echo $* eval $* } # ----------------------------------------------- if [ ! -e 'build/colpack' ] then echo_eval mkdir -p build/colpack fi echo 'create: build/colpack/colpack.cpp' cat<< EOF > build/colpack/colpack.cpp // Example using BipartiteGraphPartialColoringInterface // to generate the seed matrix for Jacobian #include "ColPackHeaders.h" int main() { size_t i, j, k; 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; } 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 # echo_eval valgrind --leak-check=yes ./colpack # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/reduce_index.py0000755000175200017650000001216012656321776016221 0ustar coincoin-web#! /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) cppad-20160000.1/bin/check_include_def.sh0000755000175200017650000000342412656321776017146 0ustar coincoin-web#! /bin/bash -e # $Id: check_include_def.sh 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. # ----------------------------------------------------------------------------- if [ ! -e "bin/check_include_def.sh" ] then 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/list_files.sh | sed -n -e '/\.hpp$/p'` # grep '^# *ifndef *CPPAD_[0-9a-zA-Z_]*_HPP$' $list \ | sed -e 's|.*# *ifndef *CPPAD_\([0-9a-zA-Z_]*\)_HPP$|\1.HPP|' \ | tr [a-zA-Z] [A-Za-z] \ | sort \ > bin/check_include_def.1.$$ # echo "$list" | sed -e 's|\([^ ]*\)/||g' | sort -u > bin/check_include_def.2.$$ # if diff bin/check_include_def.1.$$ bin/check_include_def.2.$$ then different="no" else different="yes" fi rm bin/check_include_def.1.$$ rm bin/check_include_def.2.$$ # echo "-------------------------------------------------------------------" if [ $different = "yes" ] then 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 fi cppad-20160000.1/bin/grep_source.sh0000755000175200017650000000266012656321776016066 0ustar coincoin-web#! /bin/bash -e # \$Id:\$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ ! -e "bin/grep_source.sh" ] then echo "bin/grep_source.sh: must be executed from its parent directory" exit 1 fi if [ "$1" == "" ] then echo "bin/grep_source.sh [-i] pattern" exit 1 else if [ "$1" == "-i" ] && [ "$2" == "" ] then echo "bin/grep_source.sh [-i] pattern" exit 1 fi fi list=`find . \ \( -name '*.am' \) -or \ \( -name '*.cpp' \) -or \ \( -name '*.hpp' \) -or \ \( -name '*.omh' \) -or \ \( -name '*.sh' \) | \ sed -e 's|\./||' -e '/^work\//d' -e '/^svn_dist\//d' ` # list="$list configure.ac " if [ "$1" == "-i" ] then flag="-i" pattern="$2" else flag="" pattern="$1" fi for file in $list do if grep "$pattern" $file > /dev/null then echo echo "$file" grep $flag "$pattern" $file fi done # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/speed_branch.sh0000755000175200017650000000462312656321776016167 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ ! -e "bin/speed_branch.sh" ] then echo "bin/speed_branch.sh: must be executed from its parent directory" exit 1 fi if [ "$2" == '' ] then cat << EOF usage: bin/speed_branch.sh branch_one branch_two [option_1 [option_2 ...] ] where the possible options are: onetape, colpack, optimize, atomic, memory, boolsparsity, colpack EOF exit 1 fi branch_one="$1" branch_two="$2" # ---------------------------------------------------------------------------- shift shift option_list='none' for option in $* do if [ "$option_list" == 'none' ] then option_list="$option" else option_list="${option_list}_$option" fi done # ---------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { echo $* eval $* } # ----------------------------------------------------------------------------- if [ ! -d '.git' ] then echo 'speed_branch.sh: only implemented for git repository' exit 1 fi # ----------------------------------------------------------------------------- dir='build/speed/cppad' for branch in $branch_one $branch_two do if [ -e "build/speed/cppad/$branch.$option_list.out" ] then echo "Using existing build/speed/cppad/$branch.$option_list.out" else echo_eval git checkout $branch # echo "bin/run_cmake.sh > $branch.log" bin/run_cmake.sh > $branch.log # cd $dir # echo "make check_speed_cppad >> $branch.log" make check_speed_cppad >> ../../../$branch.log # echo "./speed_cppad speed 123 $* > $branch.$option_list.out" ./speed_cppad speed 123 $* > $branch.$option_list.out # cd ../../.. fi done # compare the results echo " one=$branch_one , two=$branch_two" bin/speed_diff.sh \ $dir/$branch_one.$option_list.out $dir/$branch_two.$option_list.out # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/check_include_file.sh0000755000175200017650000000442412656321776017330 0ustar coincoin-web#! /bin/bash -e # $Id: check_include_file.sh 3762 2015-12-01 14:35:37Z 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 [ ! -e "bin/check_include_file.sh" ] then msg="must be executed from its parent directory" echo "bin/check_include_file.sh: $msg" exit 1 fi # ----------------------------------------------------------------------------- # echo "Checking difference between C++ include directives and file names." echo "-------------------------------------------------------------------" if [ -e check_include_file.1.$$ ] then echo "bin/check_include_file.sh: unexpected bin/check_include_file.1.$$" exit 1 fi list=`bin/list_files.sh | sed -n \ -e '/\.cpp$/p' \ -e '/\.hpp$/p'` for file in $list do sed -n -e '/^# *include *> bin/check_include_file.1.$$ done # cat bin/check_include_file.1.$$ | \ sed -e 's%[^<]*<%%' -e 's%>.*$%%' | \ sort -u > bin/check_include_file.2.$$ # # The following files should never be included: # cppad/local/prototype_op.hpp # cppad/example/eigen_plugin.hpp # All other files should. # The file cppad/configure.hpp may not yet be created. bin/list_files.sh | sed -n -e '/cppad\/.*\.hpp$/p' | \ sed \ -e '1,1s|^|cppad/configure.hpp\n|' \ -e '/cppad\/local\/prototype_op.hpp/d' \ -e '/cppad\/example\/eigen_plugin.hpp/d' \ -e '/cppad\/deprecated\//d' | \ sort -u > bin/check_include_file.3.$$ # if diff bin/check_include_file.2.$$ bin/check_include_file.3.$$ then different="no" else different="yes" fi for index in 1 2 3 do rm bin/check_include_file.$index.$$ done # echo "-------------------------------------------------------------------" if [ $different = "yes" ] then 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 fi cppad-20160000.1/bin/add_copyright.sh0000755000175200017650000000742412656321776016374 0ustar coincoin-web#! /bin/bash -e # $Id: add_copyright.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ ! -e "bin/add_copyright.sh" ] then echo "bin/add_copyright.sh: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- if [ "$1" == "" ] then echo "bin/add_copyright.sh: file_name" exit 1 fi file_name="$1" if [ ! -e "$file_name" ] then echo "$file_name does not exist" exit 1 fi ext=`echo $file_name | sed -e 's/.*\.//'` if [ "$ext" == "" ] then echo "bin/add_copyright.sh: file_name does not have an extension" exit 1 fi # echo "write copyright message to bin/add_copyright.$$" case $ext in cpp | hpp | omh) cat << EOF > bin/add_copyright.$$ // \$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. -------------------------------------------------------------------------- */ EOF ;; cmake | txt) cat << EOF > bin/add_copyright.$$ # \$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. # ----------------------------------------------------------------------------- EOF ;; sh) cat << EOF > bin/add_copyright.$$ #! /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. # ----------------------------------------------------------------------------- EOF echo "chmod +x bin/add_copyright.$$" chmod +x bin/add_copyright.$$ ;; *) echo bin/"add_copyright.sh: extension $ext is not yet supported" exit 1 esac # # Add check for exection directory to scripts in bin/*.sh files if ( echo $file_name | grep 'bin/[^.]*\.sh$' > /dev/null ) then cat << EOF >> bin/add_copyright.$$ if [ \$0 != "$file_name" ] then echo "$file_name: must be executed from its parent directory" exit 1 fi EOF fi # echo "cat $file_name >> bin/add_copyright.$$" cat $file_name >> bin/add_copyright.$$ # echo "mv $file_name ~/trash" mv $file_name ~/trash # echo "mv bin/add_copyright.$$ $file_name" mv bin/add_copyright.$$ $file_name # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/tag_month.sh0000755000175200017650000000666212656321776015537 0ustar coincoin-web#! /bin/bash -e # $Id:$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ $0 != "bin/tag_month.sh" ] then echo "bin/tag_month.sh: must be executed from its parent directory" exit 1 fi svn_repository="https://projects.coin-or.org/svn/CppAD" # -------------------------------------------------------------------------- # make sure that master is currently checked out git_branch=`git branch | sed -e '/^\*/! d' -e 's|^\* *||'` if [ "$git_branch" != 'master' ] then echo 'tag_month.sh: master is not currently checkout out' exit 1 fi # -------------------------------------------------------------------------- # make sure that version is consistent and all changes are checked in bin/version.sh copy > /dev/null git_status=`git status -s` if [ "$git_status" != '' ] then echo 'tag_month.sh: master has changes that are not checked in' exit 1 fi # -------------------------------------------------------------------------- # check that version corresponds to first of a month dd=`bin/version.sh get | sed -e 's|......\([0-9][0-9]\)|\1|' ` if [ "$dd" != '01' ] then echo 'tag_month.sh: verison does not correspond to first day of a month' exit 1 fi # -------------------------------------------------------------------------- # date of last change to svn repository svn_date=`svn log $svn_repository/trunk --limit 1 | grep '^r[0-9]* *|' | \ sed -e 's/^[^|]*|[^|]*| *\([0-9-]*\).*/\1/' -e 's|-||g'` # -------------------------------------------------------------------------- # get and check hash codes # local_hash=`git show-ref master | sed -e '/\/origin\//d' -e 's| refs.*||'` remote_hash=`git show-ref master | sed -e '/\/origin\//! d' -e 's| refs.*||'` svn_hash=`svn log $svn_repository/trunk --limit 1 | \ grep 'end *hash *code:' | sed -e 's|end *hash *code: *||'` # if [ "$local_hash" != "$remote_hash" ] then echo "tag_month.sh: master changes haven't been pushed to git repository" echo "local_hash = $local_hash" echo "remote_hash = $remote_hash" exit 1 fi if [ "$remote_hash" != "$svn_hash" ] then echo "tag_month.sh: master changes haven't been pushed to svn repository" echo "remote_hash = $remote_hash" echo "svn_hash = $svn_hash" exit 1 fi # ----------------------------------------------------------------------------- # If this version has already been tagged, delete the tag version=`bin/version.sh get` if git tag --list | grep "$version" then read -p "Delete preious tag for version $version [y/n] ?" response if [ "$response" != 'y' ] then echo 'tag_month.sh: aborting because tag already exists' exit 1 fi git tag -d $version git push --delete origin $version fi # echo "git tag -a \\" echo "-m \"Last changes copied to $svn_repository/trunk on $svn_date\" \\" echo "$version $svn_hash" git tag -a \ -m "Last changes copied to $svn_repository/trunk on $svn_date" \ $version $svn_hash # echo "git push origin $version" git push origin $version # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/doxyfile.sh0000755000175200017650000000602012656321776015366 0ustar coincoin-web#! /bin/bash -e # $Id: doxyfile.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 [ ! -e "bin/doxyfile.sh" ] then 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 fi version="$1" error_file="$2" output_directory="$3" # PREDEFINED:see http://www.stack.nl/~dimitri/doxygen/manual/preprocessing.html # 2DO: change EXTRACT_ALL to NO so get warnings for undocumented functions. echo "create bin/doxyfile.$$" cat << EOF > bin/doxyfile.$$ ALWAYS_DETAILED_SEC = YES BUILTIN_STL_SUPPORT = YES ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES EXTRACT_ALL = YES EXTRACT_LOCAL_CLASSES = YES EXTRACT_PRIVATE = YES EXTRACT_STATIC = YES EXTRACT_ANON_NSPACES = YES FILE_PATTERNS = *.hpp *.cpp FULL_PATH_NAMES = NO GENERATE_HTML = YES GENERATE_LATEX = NO GENERATE_TREEVIEW = YES INHERIT_DOCS = NO INLINE_INHERITED_MEMB = YES INPUT = \ ./cppad \ ./cppad/local \ ./cppad/ipopt \ ./cppad_ipopt/src \ ./cppad_lib \ ./cppad/utility \ ./speed/src LATEX_BATCHMODE = YES MACRO_EXPANSION = YES MULTILINE_CPP_IS_BRIEF = YES OUTPUT_DIRECTORY = $output_directory PREDEFINED = "__cplusplus=201103" "CPPAD_USE_CPLUSPLUS_2011=1" PROJECT_NAME = "CppAD: A C++ Algorithmic Differentiation Package" PROJECT_NUMBER = $version QT_AUTOBRIEF = YES REFERENCED_BY_RELATION = YES REFERENCES_LINK_SOURCE = NO SEPARATE_MEMBER_PAGES = YES SHOW_DIRECTORIES = YES SHOW_INCLUDE_FILES = NO SORT_GROUP_NAMES = YES SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = YES SOURCE_BROWSER = YES STRIP_CODE_COMMENTS = NO SUBGROUPING = NO TAB_SIZE = 5 VERBATIM_HEADERS = NO WARN_LOGFILE = $error_file WARN_NO_PARAMDOC = YES EOF sed \ -e 's/\t/ /g' \ -e 's/^/s|^\\(/' \ -e 's/ *=/ *=\\).*|\\1/' \ -e 's/$/|/' \ -i bin/doxyfile.$$ # echo "doxygen -g doxyfile > /dev/null" doxygen -g doxyfile > /dev/null # echo "sed -f bin/doxyfile.$$ -i doxyfile" sed -f bin/doxyfile.$$ -i doxyfile # echo "rm bin/doxyfile.$$" rm bin/doxyfile.$$ # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/special_version.sh0000755000175200017650000000636212656321776016741 0ustar coincoin-web#! /bin/bash -e # $Id: special_version.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/special_version.sh" ] then echo "bin/special_version.sh: must be executed from its parent directory" exit 1 fi # ---------------------------------------------------------------------------- version="$1" case "$version" in 2011 | 2012_0 | 2012_1 ) subversion_revision='2279' ;; 2012_2 ) subversion_revision='2347' ;; *) cat << EOF usage: bin/special_version.sh version where version is one of the following: 2011, 2012_0 2012_1 2012_2 EOF exit 1 ;; esac url='https://projects.coin-or.org/svn/CppAD/trunk' # ---------------------------------------------------------------------------- if [ -e "../special-$version" ] then echo "Using the existing directory ../special-$version" if [ -e ../special-$version/work ] then echo "rm -r ../special-$version/work" rm -r ../special-$version/work fi else echo "svn checkout -r $subversion_revision $url ../special-$version" svn checkout -r $subversion_revision $url ../special-$version fi echo "cd ../special-$version" cd ../special-$version # case "$1" in 2011) list="bthread openmp pthread" for threading in $list do file="multi_thread/$threading/team_$threading.cpp" svn revert $file # echo "sed -e 's|hold_memory(true)|hold_memory(false)|;' -i $file" sed -e 's|hold_memory(true)|hold_memory(false)|;' -i $file done ;; 2012_0) file='cppad/thread_alloc.hpp' thread_alloc_revision='2249' echo "svn cat $url/$file@$thread_alloc_revision > $file" svn cat $url/$file@$thread_alloc_revision > $file # # Always hold onto memory echo "sed -e 's/if( num_threads() == 1 )/if(false)/' -i $file" sed -e 's/if( num_threads() == 1 )/if(false)/' -i $file # # No hold_memory function echo "sed -e 's|^.*void parallel_|\tstatic void hold_memory(bool) {}\n&|'" echo " -i $file" sed -e 's|^.*void parallel_|\tstatic void hold_memory(bool) {}\n&|' \ -i $file ;; 2012_1 | 2012_2 ) ;; *) echo "bin/special_version.sh: program error" exit 1 ;; esac # file='cppad/configure.hpp' text="# define CPPAD_PACKAGE_STRING" svn revert $file echo "sed -i $file -e \"s|^$text.*|\1 \"cppad-$version\"|\"" sed -i $file -e "s|^\($text\) .*|\1 \"cppad-$version\"|" # echo "mkdir work ; cd work" mkdir work ; cd work # response='n' while [ "$response" != 'y' ] do dir=`pwd` echo "current working: $dir" echo "Enter configure options on next line (no options is default)" read -p "options: " options echo "../configure $options" read -p "Is this ok [y/n] ?" response done echo "../configure $options" ../configure $options # echo "cd multi_thread ; make test" cd multi_thread ; make test # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/batch_edit.sh0000755000175200017650000000422412656321776015635 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- move_sed='s|list_files.sh|ls_files.sh|' move_list=' ' cat << EOF > junk.sed s|^# cppad_has_colpack, colpack_libs|&, cppad_lib| s|^\\tSET( colpack_libs "ColPack" )|&\\ SET( cppad_lib "cppad_lib" )| s|^\\tSET( colpack_libs "" )|&\\ SET( cppad_lib "" )| s|^\\tcppad_lib\$|\\t\${cppad_lib}| # s|^ADD_SUBDIRECTORY(cppad_lib)|IF( colpack_prefix )\\ &\\ ENDIF( colpack_prefix)| EOF # ----------------------------------------------------------------------------- if [ $0 != "bin/batch_edit.sh" ] then echo "bin/batch_edit.sh: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { echo $* eval $* } # ----------------------------------------------------------------------------- cp bin/batch_edit.sh $HOME/trash/batch_edit.sh git reset --hard cp $HOME/trash/batch_edit.sh bin/batch_edit.sh # --------------------------------------------------------------------------- list_all=`git ls-files` for file in $list_all do if [ "$file" != 'bin/batch_edit.sh' ] then echo_eval sed -f junk.sed -i $file fi done # ---------------------------------------------------------------------------- for old in $move_list do new=`echo $old | sed -e "$move_sed"` echo_eval git mv $old $new done # ---------------------------------------------------------------------------- # files that were hand edited and cached using 'git_new.sh to' if [ -e new ] then echo_eval git_new.sh from fi # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/get_eigen.sh0000755000175200017650000001061312656321776015474 0ustar coincoin-web#! /bin/bash -e # $Id: get_eigen.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. # # A copy of 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 get_eigen.sh$$ $newlinech #$$ # $spell # gz # Eigen # CppAD # $$ # # $section Download and Install Eigen in Build Directory$$ # $index eigen, download and install$$ # $index download, install eigen$$ # $index install, eigen$$ # # $head Syntax$$ # $code bin/get_eigen.sh$$ # # $head Purpose$$ # If you are using Unix, this command will download and install # $href%http://eigen.tuxfamily.org%Eigen%$$ in the # CppAD $code build$$ directory. # # $head Distribution Directory$$ # This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ # The Eigen source code is downloaded into the sub-directory # $code build/external$$ below the distribution directory. # # $head Prefix Directory$$ # The Eigen include files are installed in the sub-directory # $code build/prefix/include/Eigen$$ below the distribution directory. # # $head Reuse$$ # The file $codei%build/external/eigen-%version%.tar.gz%$$ # and the directory $codei%build/external/eigen-%version%$$ # will be reused if they exist. Delete this file and directory # to get a complete rebuild. # # $end # ----------------------------------------------------------------------------- if [ $0 != "bin/get_eigen.sh" ] then 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 'Download eigen to build/external and install it to build/prefix' version='3.2.0' web_page='https://bitbucket.org/eigen/eigen/get' cppad_dir=`pwd` prefix="$cppad_dir/build/prefix" installed_flag="build/external/eigen-${version}.installed" if [ -e "$installed_flag" ] then echo "$installed_flag exists: Skipping get_eigen.sh" exit 0 fi # ----------------------------------------------------------------------------- # determine which version of cmake to use cmake --version | sed -n \ -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" # cmake_program='' if [ "$cmake_version" -ge '28' ] then 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 fi if [ "$cmake_program" == '' ] then 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 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 fi # ----------------------------------------------------------------------------- if [ -e eigen-eigen-* ] then echo_eval rm -r eigen-eigen-* fi if [ -e "$prefix/include/Eigen" ] then 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 fi # ----------------------------------------------------------------------------- echo_eval cd eigen-$version if [ ! -e build ] then echo_eval mkdir build fi echo_eval cd build echo_eval $cmake_program .. -DCMAKE_INSTALL_PREFIX=$prefix echo_eval make install echo_eval ln -s $prefix/include/eigen3/Eigen $prefix/include/Eigen # ----------------------------------------------------------------------------- echo_eval touch $cppad_dir/$installed_flag echo "get_eigen.sh: OK" cppad-20160000.1/bin/check_define.sh0000755000175200017650000000313412656321776016135 0ustar coincoin-web#! /bin/bash -e # $Id: check_define.sh 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. # ----------------------------------------------------------------------------- if [ $0 != "bin/check_define.sh" ] then echo "bin/check_define.sh: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- echo "Difference between '# define' names and '# undef' names" echo '-----------------------------------------------------------------------' list=`bin/list_files.sh | sed -n \ -e '/^cppad\/.*\.hpp$/p' \ -e '/^cppad\/.*\.hpp\.in$/p'` # for cmd in define undef do for file in $list do if [ ! -e $file.in ] then sed -n -e "/^# *$cmd /p" $file | \ sed -e "s/^# *$cmd *\([A-Za-z0-9_]*\).*/\1/" >> tmp.$$ fi done if [ "$cmd" == 'define' ] then sed -e '/_HPP$/d' -i tmp.$$ fi sort -u tmp.$$ > $cmd.$$ rm tmp.$$ done if ! diff define.$$ undef.$$ then echo "check_define.sh: exiting because defines and undefs do not match" rm undef.$$ rm define.$$ exit 1 fi echo '-----------------------------------------------------------------------' rm undef.$$ rm define.$$ exit 0 cppad-20160000.1/bin/speed_diff.sh0000755000175200017650000000317412656321776015642 0ustar coincoin-web#! /bin/bash -e # $Id: speed_diff.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/speed_diff.sh' ] then echo 'bin/speed_diff.sh: must be executed from its parent directory' exit 1 fi if [ "$2" == '' ] then cat << EOF usage: bin/speed_diff.sh speed_one.out speed_two.out where speed_one.out and speed_two.out are outputs from the speed_cppad program runing its 'speed' test. EOF exit 1 fi speed_one="$1" speed_two="$2" if [ ! -f "$speed_one" ] then echo "speed_diff.sh: the file $speed_one does not exist." exit 1 fi if [ ! -f "$speed_two" ] then echo "speed_diff.sh: the file $speed_two does not exist." exit 1 fi # sed -n \ -e 's|^[a-z]*_||' \ -e 's|_rate|_rate_one|' -e '/_rate_one/p' \ -e 's|available|available_one|' -e '/available_one/p' \ $speed_one > speed_diff.$$ # sed -n \ -e 's|^[a-z]*_||' \ -e 's|_rate|_rate_two|' -e '/_rate_two/p' \ -e 's|available|available_two|' -e '/available_two/p' \ $speed_two >> speed_diff.$$ # cat speed_diff.$$ | sort -u rm speed_diff.$$ # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/check_example.sh0000755000175200017650000000326312656321776016341 0ustar coincoin-web#! /bin/bash -e # $Id: check_example.sh 3689 2015-05-27 05:59:24Z 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 [ ! -e "bin/check_example.sh" ] then 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/list_files.sh | sed -n \ -e '/cppad_ipopt/d' \ -e '/example\//p' \ -e '/multi_thread\//p'` # sed < omh/example_list.omh > bin/check_example.$$ \ -n -e '/\$begin ListAllExamples\$\$/,/\$end/p' ok="yes" for file in $file_list do name=`grep '$begin' $file | sed -e 's/.*$begin *//' -e 's/ *$$.*//'` if [ "$name" != "" ] then if ! grep "$name" bin/check_example.$$ > /dev/null then echo "$name is missing from omh/example_list.omh" ok="no" fi fi done rm bin/check_example.$$ 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 cppad-20160000.1/bin/get_sacado.sh0000755000175200017650000001417412656321776015645 0ustar coincoin-web#! /bin/bash -e # $Id: get_sacado.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. # # A copy of 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 get_sacado.sh$$ $newlinech #$$ # $spell # trilinos # gz # Sacado # CppAD # $$ # # $section Download and Install Sacado in Build Directory$$ # $index sacado, download and install$$ # $index download, install sacado$$ # $index install, sacado$$ # # $head Syntax$$ # $code bin/get_sacado.sh$$ # # $head Purpose$$ # If you are using Unix, this command will download and install # $href%http://trilinos.sandia.gov/packages/sacado%Sacado%$$ in the # CppAD $code build$$ directory. # # $head Distribution Directory$$ # This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ # The Sacado source code is downloaded into the sub-directory # $code build/external$$ below the distribution directory. # # $head Prefix Directory$$ # The Sacado libraries and include files are installed in the sub-directory # $code build/prefix$$ below the distribution directory. # # $head Reuse$$ # The file $codei%build/external/trilinos-%version%-Source.tar.gz%$$ # and the directory $codei%build/external/trilinos-%version%-Source%$$ # will be reused if they exist. Delete this file and directory # to get a complete rebuild. # # $end # ----------------------------------------------------------------------------- if [ $0 != "bin/get_sacado.sh" ] then 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 'Download sacado to build/external and install it to build/prefix' version="11.12.1" trilinos_dir="trilinos-$version-Source" web_page="http://trilinos.org/oldsite/download/files" cppad_dir=`pwd` prefix="$cppad_dir/build/prefix" installed_flag="build/external/trilinos-${version}.installed" if [ -e "$installed_flag" ] then echo "$installed_flag exists: Skipping get_sacado.sh" exit 0 fi # ----------------------------------------------------------------------------- # determine which version of cmake to use cmake --version | sed -n \ -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" # cmake_program='' if [ "$cmake_version" -ge '27' ] then 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 fi if [ "$cmake_program" == '' ] then echo 'cannot find a verison of cmake that is 2.7 or higher' exit 1 fi # ----------------------------------------------------------------------------- # libdir if [ -e /usr/lib64 ] then libdir='lib64' else 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 fi echo "coin_lapack_blas=$coin_lapack_blas" # ----------------------------------------------------------------------------- # change into build/external directory if [ ! -d build/external ] then echo_eval mkdir -p build/external fi echo_eval cd build/external # ----------------------------------------------------------------------------- # 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 fi for package in Sacado Teuchos Trilinois do 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 # ------------------------------------------------------------------------ fi echo_eval cd $trilinos_dir # ----------------------------------------------------------------------------- # change into build sub-directory if [ ! -e build ] then echo_eval mkdir build fi echo_eval cd build # ----------------------------------------------------------------------------- # cmake command and install if [ "$coin_lapack_blas" == 'yes' ] then echo_eval $cmake_program \ -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 \ ../ fi echo_eval make install # ----------------------------------------------------------------------------- echo_eval touch $cppad_dir/$installed_flag echo "get_sacado.sh: OK" cppad-20160000.1/bin/check_if.sh0000755000175200017650000000327212656321776015304 0ustar coincoin-web#! /bin/bash -e # $Id: check_if.sh 3689 2015-05-27 05:59:24Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ "$0" != 'bin/check_if.sh' ] then echo "bin/check_if: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- # CppAD uses preprocessor '# if 0' comment blocks for temporary changes # that will to be removed before testing for check in. echo "Checking for '# if 0' and '# if NDEBUG' commands in source code" echo "-------------------------------------------------------" ok="yes" list=`bin/list_files.sh | sed -n \ -e '/\.cpp$/p' \ -e '/\.hpp$/p' \ -e '/\.hpp.in$/p'` for file in $list do if grep '^# *if *0 *$' $file > /dev/null 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 else echo 'bin/check_if.sh: OK' exit 0 fi cppad-20160000.1/bin/list_files.sh0000755000175200017650000000226012656321776015702 0ustar coincoin-web#! /bin/bash -e # $Id: list_files.sh 3770 2015-12-31 12:28:29Z 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. # ----------------------------------------------------------------------------- # list files in repository (not deleted) # ----------------------------------------------------------------------------- if [ $0 != "bin/list_files.sh" ] then echo "bin/list_files.sh: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- 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 cppad-20160000.1/bin/trace.sh0000755000175200017650000000250312656321776014643 0ustar coincoin-web#! /bin/bash -e # $Id: trace.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/trace.sh" ] then echo "bin/trace.sh: must be executed from its parent directory" exit 1 fi name="$1" option="$2" file="cppad/local/$name.hpp" # ok='yes' if [ "$option" != '0' ] && [ "$option" != '1' ] then ok='no' fi echo "grep '_TRACE [01]' $file" if ! grep '_TRACE [01]' $file > /dev/null then ok='no' fi if [ "$ok" == 'no' ] then echo 'usage: bin/trace.sh name (0|1)' echo ' where the file cppad/local/name.hpp has a defined TRACE option' exit 1 fi old=`grep '_TRACE [01]' $file` sed -e "s|TRACE [01]|TRACE $option|" -i $file new=`grep '_TRACE [01]' $file` # echo "old: $old" echo "new: $new" # # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/reduce_index.sh0000755000175200017650000000247012656321776016206 0ustar coincoin-web#! /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 cppad-20160000.1/bin/run_doxygen.sh0000755000175200017650000000246412656321776016114 0ustar coincoin-web#! /bin/bash -e # $Id: run_doxygen.sh 2722 2013-01-06 16:52:46Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ $0 != 'bin/run_doxygen.sh' ] then echo 'bin/run_doxygen.sh: must be executed from its parent directory' exit 1 fi echo_eval() { echo $* eval $* } # ----------------------------------------------------------------------------- version=`bin/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 done echo_eval mkdir doxydoc echo_eval bin/doxyfile.sh $version $error_file $output_directory # echo 'doxygen doxyfile > doxygen.log' doxygen doxyfile > doxygen.log # echo_eval cat doxygen.err echo_eval bin/check_doxygen.sh # echo 'OK: bin/run_doxygen.sh' exit 0 cppad-20160000.1/bin/run_cmake.sh0000755000175200017650000001307312656321776015515 0ustar coincoin-web#! /bin/bash -e # $Id: run_cmake.sh 3769 2015-12-29 16:13:16Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ ! -e "bin/run_cmake.sh" ] then 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 $* } # ----------------------------------------------- verbose='no' standard='c++11' debug_speed='no' deprecated='no' profile_speed='no' clang='no' no_colpack='no' no_ipopt='no' no_sparse_list='no' no_documentation='no' testvector='boost' while [ "$1" != "" ] do if [ "$1" == '--help' ] then cat << EOF usage: bin/run_cmake.sh: \\ [--help] \\ [--verbose] \\ [--c++98] \\ [--debug_speed] \\ [--deprecated] \\ [--profile_speed] \\ [--clang ] \\ [--no_colpack] \\ [--no_ipopt] \\ [--no_sparse_list] \\ [--no_documentation] \\ [--_vector] The --help option just prints this message and exits. The value above must be one of: cppad, boost, or eigen. EOF exit 0 elif [ "$1" == '--verbose' ] then verbose='yes' elif [ "$1" == '--c++98' ] then standard='c++98' elif [ "$1" == '--debug_speed' ] then debug_speed='yes' profile_speed='no' elif [ "$1" == '--deprecated' ] then deprecated='yes' elif [ "$1" == '--profile_speed' ] then profile_speed='yes' debug_speed='no' elif [ "$1" == '--clang' ] then clang='yes' elif [ "$1" == '--no_colpack' ] then no_colpack='yes' elif [ "$1" == '--no_ipopt' ] then no_ipopt='yes' elif [ "$1" == '--no_sparse_list' ] then no_sparse_list='yes' elif [ "$1" == '--no_documentation' ] then no_documentation='yes' elif [ "$1" == '--cppad_vector' ] then testvector='cppad' elif [ "$1" == '--boost_vector' ] then testvector='boost' elif [ "$1" == '--eigen_vector' ] then testvector='eigen' else echo "$1 is an invalid option, try bin/run_cmake.sh --help" exit 1 fi shift done # --------------------------------------------------------------------------- if [ "$debug_speed" == 'yes' ] then sed -e 's|^SET(CMAKE_BUILD_TYPE .*|SET(CMAKE_BUILD_TYPE DEBUG)|' \ -e 's|^# SET(CMAKE_CXX_FLAGS_DEBUG|SET(CMAKE_CXX_FLAGS_DEBUG|' \ -i speed/CMakeLists.txt else sed -e 's|^SET(CMAKE_BUILD_TYPE .*|SET(CMAKE_BUILD_TYPE RELEASE)|' \ -e 's|^SET(CMAKE_CXX_FLAGS_DEBUG|# SET(CMAKE_CXX_FLAGS_DEBUG|' \ -i speed/CMakeLists.txt fi # --------------------------------------------------------------------------- if [ ! -e build ] then echo_eval mkdir build fi echo_eval cd build if [ -e CMakeCache.txt ] then echo_eval rm CMakeCache.txt fi # --------------------------------------------------------------------------- # clean all variables in cmake cache cmake_args='-U .+' # if [ "$verbose" == 'yes' ] then # echo each command that make executes cmake_args="$cmake_args -D CMAKE_VERBOSE_MAKEFILE=YES" fi # ----------------------------------------------------------------------------- # cppad_prefix cmake_args="$cmake_args -D cppad_prefix=$HOME/prefix/cppad" # # cmake_install_includedirs if [ -d '/usr/include' ] then 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" fi # # cmake_install_docdir if [ -d '/usr/share' ] && [ "$no_documentation" == 'no' ] then 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'" elif [ -d '/usr/lib' ] then cmake_args="$cmake_args -D cmake_install_libdirs='lib;lib64'" fi # # {package}_prefix package_list='fadbad adolc eigen sacado' if [ "$no_colpack" == 'no' ] then package_list="$package_list colpack" fi if [ "$no_ipopt" == 'no' ] then package_list="$package_list ipopt" fi for package in $package_list do dir=$HOME/prefix/$package if [ -d "$dir" ] then cmake_args="$cmake_args -D ${package}_prefix=$dir" fi done # # sparse_list if [ "$no_sparse_list" == 'yes' ] then cmake_args="$cmake_args -D cppad_sparse_list=NO" else cmake_args="$cmake_args -D cppad_sparse_list=YES" fi # # cppad_cxx_flags cppad_cxx_flags="-Wall -pedantic-errors -std=$standard" if [ "$testvector" != 'eigen' ] then cppad_cxx_flags="$cppad_cxx_flags -Wshadow" 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++" fi # # profile if [ "$profile_speed" == 'yes' ] then cmake_args="$cmake_args -D cppad_profile_flag=-pg" fi # # deprecated if [ "$deprecated" == 'yes' ] then cmake_args="$cmake_args -D cppad_deprecated=YES" else cmake_args="$cmake_args -D cppad_deprecated=NO" fi # # simple options cmake_args="$cmake_args -D cppad_testvector=$testvector" 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" # echo_eval cmake $cmake_args .. # # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/epl_html2txt.py0000755000175200017650000000501112656321776016206 0ustar coincoin-web#! /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() cppad-20160000.1/bin/check_op_code.sh0000755000175200017650000000602412656321776016314 0ustar coincoin-web#! /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 is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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_op_code.sh" ] then 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:" # --------------------------------------------------------------------------- # 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.$$ # sort --ignore-case bin/op_code.1.$$ > bin/op_code.2.$$ if ! diff bin/op_code.1.$$ bin/op_code.2.$$ then echo "check_op_code.sh: enum list is not in alphabetical order" rm bin/op_code.*.$$ 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.$$ # if ! diff bin/op_code.1.$$ bin/op_code.3.$$ then echo "check_op_code.sh: NumArgTable list is not in alphabetical order" rm bin/op_code.*.$$ 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.$$ # if ! diff bin/op_code.1.$$ bin/op_code.4.$$ then echo "check_op_code.sh: NumResTable list is not in alphabetical order" echo "(or missing last line)" rm bin/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.$$ # if ! diff bin/op_code.1.$$ bin/op_code.5.$$ then echo "check_op_code.sh: OpName list is not in alphabetical order" rm bin/op_code.*.$$ exit 1 fi # ----------------------------------------------------------------------------- # clean up rm bin/op_code.*.$$ # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/check_copyright.sh0000755000175200017650000000432612656321776016717 0ustar coincoin-web#! /bin/bash -e # $Id: check_copyright.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ $0 != "bin/check_copyright.sh" ] then echo "bin/check_copyright.sh: must be executed from its parent directory" exit 1 fi if [ ! -e .git ] then echo 'This is not a git repository so cannot check copyright.' echo 'check_copyright.sh: skipped' exit 0 fi list=`git status | sed -n \ -e '/^[#\t ]*deleted:/p' \ -e '/^[#\t ]*modified:/p' \ -e '/^[#\t ]*both modified:/p' \ -e '/^[#\t ]*renamed:/p' \ -e '/^[#\t ]*new file:/p' | \ sed -e 's/^.*: *//' -e 's/ -> /\n/' | \ sed -e '/makefile.in$/d' | sort -u` cat << EOF > check_copyright.1.$$ # Change copyright second year to current year s/Copyright (C) \\([0-9]*\\)-[0-9][0-9] Bradley M. Bell/Copyright (C) \\1-15 Bradley M. Bell/ s/Copyright (C) \\([0-9]*\\)-20[0-9][0-9] Bradley M. Bell/Copyright (C) \\1-15 Bradley M. Bell/ EOF ok=true for file in $list do if [ -e $file ] then sed -f check_copyright.1.$$ $file > check_copyright.2.$$ if ! diff $file check_copyright.2.$$ > /dev/null then echo '----------------------------------------------------' echo "check_copyright.sh: automatic changes to $file:" if diff $file check_copyright.2.$$ then echo 'bin/check_copyright.sh: program error' rm check_copyright.*.$$ exit 1 fi ok='no' if [ -x $file ] then mv check_copyright.2.$$ $file chmod +x $file else mv check_copyright.2.$$ $file fi fi fi done if [ "$ok" == 'no' ] then rm check_copyright.*.$$ exit 1 fi rm check_copyright.*.$$ # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/check_all.sh0000755000175200017650000001212412656321776015452 0ustar coincoin-web#! /bin/bash -e # $Id: check_all.sh 3785 2016-02-08 12:53:06Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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_all.sh" ] then echo "bin/check_all.sh: must be executed from its parent directory" exit 1 fi echo_log_eval() { echo $* echo $* >> $top_srcdir/check_all.log 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 msg=`cat $top_srcdir/check_all.err` if [ "$msg" != '' ] then echo "$msg" 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 } if [ -e check_all.log ] then echo "rm check_all.log" rm check_all.log fi top_srcdir=`pwd` echo "top_srcdir = $top_srcdir" # if ! random_zero_one=`expr $RANDOM % 2` then # expr exit status is 1 when the expression result is zero # supress shell exit in this case : fi echo "random_zero_one = $random_zero_one" # --------------------------------------------------------------------------- # circular shift program list and set program to first entry in list next_program() { 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 fi # --------------------------------------------------------------------------- # Create package to run test in echo "bin/package.sh" 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 [ "$random_zero_one" == '0' ] then echo_log_eval bin/run_cmake.sh --boost_vector else echo_log_eval bin/run_cmake.sh --deprecated fi echo_log_eval cd build # ----------------------------------------------------------------------------- echo_log_eval make check # ----------------------------------------------------------------------------- for package in adolc eigen ipopt fadbad sacado do dir=$HOME/prefix/$package if [ ! -d "$dir" ] 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 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 # # ---------------------------------------------------------------------------- # extra multi_thread tests program_list='' for threading in bthread openmp pthread do program="multi_thread/${threading}/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=2,max_thread=4,num_zero=20,num_sub=30,num_sum=500,use_ad=true next_program echo_log_eval ./$program multi_newton 2 4 20 30 500 true # # case that failed in the past next_program echo_log_eval ./$program multi_newton 1 1 100 700 1 true # # case that failed in the past next_program echo_log_eval ./$program multi_newton 1 2 3 12 1 true fi # # print_for test if [ ! -e 'print_for/print_for' ] then skip="$skip print_for/print_for" else echo_log_eval print_for/print_for print_for/print_for | sed -e '/^Test passes/,$d' > junk.1.$$ print_for/print_for | sed -e '1,/^Test passes/d' > junk.2.$$ if diff junk.1.$$ junk.2.$$ then rm junk.1.$$ junk.2.$$ echo_log_eval echo "print_for: OK" else echo_log_eval echo "print_for: Error" exit 1 fi fi # echo_log_eval make install # if [ "$skip" != '' ] then echo_log_eval echo "check_all.sh: skip = $skip" exit 1 fi # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/check_verbatim.sh0000755000175200017650000000456112656321776016521 0ustar coincoin-web#! /bin/bash -e # $Id: check_verbatim.sh 3770 2015-12-31 12:28:29Z 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 [ ! -e "bin/check_verbatim.sh" ] then echo "bin/check_verbatim.sh: must be executed from its parent directory" exit 1 fi cat << EOF > junk.sed /\$verbatim[^a-z]/! b skip N s/^#[ \\t]// s/^[ \\t]// s/\\n#[ \\t]// s/\\n[ \\t]// s/\$verbatim%// s/%.*// p : skip EOF special_case=' bin/check_include_omh.sh bin/check_verbatim.sh bin/package.sh cppad/local/cond_exp.hpp introduction/exp_apx/exp_2.omh introduction/exp_apx/exp_eps.omh omh/license.omh ' # ----------------------------------------------------------------------------- # Make sure that OMhelp verbatim commands referr to same file as command echo "Checking that OMhelp verbatim commands include from file they appear in." echo "----------------------------------------------------------------------" list=`bin/list_files.sh` different="no" for file in $list do ok='no' for name in $special_case do if [ "$file" == "$name" ] then ok='yes' fi done # reference=`sed -n -f junk.sed $file` if [ "$reference" == '' ] || [ "$reference" == "$file" ] then ok='yes' fi # ext=`echo $file | sed -e 's|.*\.||'` if [ "$ext" == 'omh' ] then 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 ok='yes' fi file_root=`echo $file | sed -e 's|.*/||' -e 's|\.omh|.hpp|'` if [ "$file_root" == "$ref_root" ] then ok='yes' fi fi # if [ "$ok" == 'no' ] then echo "\$verbatim in $file references $reference" different="yes" fi done echo "-------------------------------------------------------------------" if [ $different = "yes" ] then 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 fi cppad-20160000.1/bin/check_replace.sh0000755000175200017650000000322712656321776016321 0ustar coincoin-web#! /bin/bash -e # $Id: check_replace.sh 3214 2014-03-18 20:50:38Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ $0 != "bin/check_replace.sh" ] then 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 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 EOF 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 optimize.hpp optimize.hpp check_replace forward0sweep.hpp forward1sweep.hpp # ----------------------------------------------------------------------------- echo "replace_html.sh: OK" exit 0 cppad-20160000.1/bin/run_omhelp.sh0000755000175200017650000000456112656321776015723 0ustar coincoin-web#! /bin/bash -e # $Id: run_omhelp.sh 3405 2014-11-26 14:20:55Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ ! -e "bin/run_omhelp.sh" ] then 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 $* } # ----------------------------------------------------------------------------- # if [ "$1" != "htm" ] && [ "$1" != "xml" ] && [ "$1" != "clean" ] then echo "usage: bin/run_omhelp.sh (htm|xml|clean) [printable]" exit 1 fi if [ "$2" != "" ] && [ "$2" != "printable" ] then echo "usage: bin/run_omhelp.sh (htm|xml|clean) [printable]" exit 1 fi if [ "$1" == "clean" ] then echo_eval rm -rf doc exit 0 fi ext="$1" if [ "$2" == 'printable' ] then printable="yes" else printable='no' fi # echo "Building doc/*.$ext printable=$printable" if [ ! -e doc ] then echo_eval mkdir doc fi echo_eval cd doc cmd="omhelp ../doc.omh -noframe -debug -l http://www.coin-or.org/CppAD/" if [ "$ext" == "xml" ] then cmd="$cmd -xml" fi if [ $printable == 'yes' ] then 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 fi if grep "^OMhelp Warning:" ../omhelp.$ext.log then echo "See the complete warning messages in omhelp.$ext.log." exit 1 fi if [ "$printable" == 'yes' ] then root_name='_printable' else 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 fi if [ -e 'index.htm' ] then echo_eval rm index.htm fi cat << EOF > index.html EOF # echo "OK: omhelp $*" exit 0 cppad-20160000.1/bin/push_git2svn.py0000755000175200017650000002620512656321776016223 0ustar coincoin-web#! /bin/python # $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. # ----------------------------------------------------------------------------- from __future__ import print_function # ----------------------------------------------------------------------------- # list of svn commands to execute in the svn directory before make changes # indicated by git directory; some example commands are included below svn_commands = [ # 'svn mkdir cppad/utility', # 'svn move cppad/*.hpp cppad/utility', # 'svn move cppad/utility/cppad.hpp cppad/cppad.hpp', # 'svn move cppad/utility/base_require.hpp cppad/base_require.hpp', # 'svn move omh/library.omh omh/utility.omh' ] # ----------------------------------------------------------------------------- # imports import sys import os import re import subprocess import pdb # ----------------------------------------------------------------------------- # command line arguments usage = '\tbin/push_git2svn.py svn_branch_path\n' 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) if narg != 2 : 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) # ----------------------------------------------------------------------------- # some settings svn_repository = 'https://projects.coin-or.org/svn/CppAD' git_repository = 'https://github.com/coin-or/CppAD' work_directory = 'build/work' # ----------------------------------------------------------------------------- # 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 # 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 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 id_pattern = re.compile(r'^.*\$Id.*$', re.MULTILINE) white_pattern = re.compile(r'[ \t]+$', re.MULTILINE) date_pattern = re.compile(r'2003-[0-9][0-9]', re.MULTILINE) def ignore_data(data) : data = re.sub(id_pattern, '', data) data = re.sub(white_pattern, '', data) data = re.sub(date_pattern, '', data) return data # ----------------------------------------------------------------------------- # determine git_branch_name if svn_branch_path == 'trunk' : 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 else : 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 git_hash_code = system(cmd) pattern = ' refs/remotes/origin/' + git_branch_name git_hash_code = git_hash_code.replace(pattern, '') # ----------------------------------------------------------------------------- # make sure work directory exists if not os.path.isdir(work_directory) : os.makedirs(work_directory) # ----------------------------------------------------------------------------- # checkout svn version of directory svn_directory = work_directory + '/svn' if os.path.isdir(svn_directory) : question = 'Use existing svn directory:\n\t' question += svn_directory + '\n' question += 'or remove it and check out a new copy ? [use/new] ' choice_list = [ 'use' , 'new' ] choice = pause(question, choice_list) if choice == 'new' : cmd = 'rm -r ' + svn_directory print_system(cmd) else : choice = 'new' if choice == 'use' : cmd = 'svn revert --recursive ' + svn_directory print_system(cmd) cmd = 'svn update ' + svn_directory print_system(cmd) cmd = 'svn status ' + svn_directory svn_status = system(cmd) svn_status = svn_status.split('\n') for entry in svn_status : if entry.startswith('? ') : file_name = entry[8:] cmd = 'rm ' + file_name system(cmd) else : cmd = 'svn checkout ' cmd += svn_repository + '/' + svn_branch_path + ' ' + svn_directory print_system(cmd) # ---------------------------------------------------------------------------- tmp = os.getcwd() os.chdir( svn_directory ) for cmd in svn_commands : assert cmd.startswith('svn') print_system(cmd) os.chdir( tmp ) # ---------------------------------------------------------------------------- # git hash code corresponding to verison in svn directory cmd = 'svn info ' + svn_directory svn_info = system(cmd) rev_pattern = re.compile('Last Changed Rev: *([0-9]+)') match = re.search(rev_pattern, svn_info) svn_revision = match.group(1) cmd = 'svn log -r ' + svn_revision + ' ' + svn_directory svn_log = system(cmd) 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) else : svn_hash_code = None # ----------------------------------------------------------------------------- # export the git verison of the directory git_directory = work_directory + '/git' if os.path.isdir(git_directory) : cmd = 'rm -r ' + git_directory print_system(cmd) cmd = 'svn export ' cmd += git_repository + '/' + git_branch_path + ' ' + git_directory print_system(cmd) # ----------------------------------------------------------------------------- # list of files for the svn and git directories svn_pattern = re.compile(svn_directory + '/') svn_file_list = [] svn_dir_list = [] for directory, dir_list, file_list in os.walk(svn_directory) : ok = ( directory.find('/.svn/') == -1 ) ok = ok and ( not directory.endswith('/.svn') ) if ok : if directory != svn_directory : local_name = re.sub(svn_pattern, '', directory) svn_dir_list.append(local_name) for name in file_list : local_name = directory + '/' + name local_name = re.sub(svn_pattern, '', local_name) 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 ) # ----------------------------------------------------------------------------- # 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) # deleted_file_list=[] for name in svn_file_list : 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) # deleted_dir_list=[] for name in svn_dir_list : 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) # for git_file in created_file_list : git_f = open(git_directory + '/' + git_file, 'rb') git_data = git_f.read() git_f.close() git_data = ignore_data(git_data) # found = False 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 : assert not found cmd = 'svn copy ' + svn_directory + '/' + svn_file + ' \\\n\t' cmd += svn_directory + '/' + git_file print_system(cmd) cmd = 'cp ' + git_directory + '/' + git_file + ' \\\n\t' cmd += svn_directory + '/' + git_file system(cmd) found = True if not found : cmd = 'cp ' + git_directory + '/' + git_file + ' \\\n\t' cmd += svn_directory + '/' + git_file system(cmd) cmd = 'svn add ' + svn_directory + '/' + git_file print_system(cmd) # 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) # 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) # for svn_dir in deleted_dir_list : cmd = 'svn rm ' + svn_directory + '/' + svn_dir print_system(cmd) # ----------------------------------------------------------------------------- data = 'merge to branch: ' + svn_branch_path + '\n' data += 'from repository: ' + git_repository + '\n' if svn_hash_code != None : data += 'start hash code: ' + svn_hash_code + '\n' else : 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 log_f = open( svn_directory + '/push_git2svn.log' , 'wb') log_f.write(data) log_f.close() # msg = '\nChange into svn directory with the command\n\t' msg += 'cd ' + svn_directory + '\n' 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' else : msg += 'The start hash code could not be automatically determined.\n' msg += 'You should edit push_git2svn.log to describe the changes.' print(msg) cppad-20160000.1/bin/speed_new.sh0000755000175200017650000001050612656321776015520 0ustar coincoin-web#! /bin/bash -e # $Id: speed_new.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 [ ! -e "bin/speed_new.sh" ] then echo "bin/speed_new.sh: must be executed from its parent directory" exit 1 fi if [ "$1" == '' ] then cat << EOF usage: bin/speed_new.sh option_1 option_2 ... where the possible options are: onetape, colpack, optimize, atomic, memory, boolsparsity, colpack Use the special value 'none' for no options EOF exit 1 fi if [ "$1" == 'none' ] then shift fi if [ ! -d cppad/new ] then echo "speed_new.sh: the directory cppad/new does not exist." echo "It contains new source code for the cppad directory (can be empty)." exit 1 fi if [ ! -d cppad/local/new ] then echo "speed_new.sh: the directory cppad/local/new does not exist" echo "It contains new source code for the cppad/local (can be empty)." exit 1 fi # ----------------------------------------------------------------------------- if [ -d '.git' ] then revert_cmd='git checkout' elif [ -d .svn ] then revert_cmd='svn revert' else echo 'speed_new.sh: Cannot find ./.git or ./.svn' exit 1 fi # ----------------------------------------------------------------------------- # Source code files that are changing new_cppad=`cd cppad/new ; ls` new_local=`cd cppad/local/new ; ls` if [ "$new_cppad" == "" ] && [ "$new_local" == "" ] then echo "speed_new.sh: both cppad/new and cppad/local/new are empty" exit 1 fi # ------------------------------------------------------------------------- # if [ ! -e build/speed/cppad/cur_speed.out ] then # revert cppad source code to the current version if [ "$new_cppad" != "" ] then for file in $new_cppad do echo "$revert_cmd cppad/$file" if ! $revert_cmd cppad/$file then echo "assuming cppad/$file not in repository" fi done fi # revert cppad/local source code to the current version if [ "$new_local" != "" ] then for file in $new_local do echo "$revert_cmd cppad/local/$file" if ! $revert_cmd cppad/local/$file then echo "assuming cppad/local/$file not in repository" fi done fi # # compile and link the current version echo "cd build; make check_speed_cppad; cd speed/cppad" cd build; make check_speed_cppad; cd speed/cppad # # run speed test for the current version echo "./speed_cppad speed 123 $* > cur_speed.out" ./speed_cppad speed 123 $* > cur_speed.out # echo "cd ../../.." cd ../../.. fi # # Convert cppad source to the new version for file in $new_cppad do echo "cp cppad/new/$file cppad/$file" cp cppad/new/$file cppad/$file done # # Convert local source to the new version for file in $new_local do echo "cp cppad/local/new/$file cppad/local/$file" cp cppad/local/new/$file cppad/local/$file done # if [ ! -e build/speed/cppad/new_speed.out ] then # compile and link the new version echo "cd build; make check_speed_cppad; cd speed/cppad" cd build; make check_speed_cppad; cd speed/cppad # # run speed test for the new version echo "./speed_cppad speed 123 $* > new_speed.out" ./speed_cppad speed 123 $* > new_speed.out # echo "cd ../../.." cd ../../.. fi # compare versions echo "cd build/speed/cppad" cd build/speed/cppad # echo "sed -n -e 's|_rate|_rate_cur|' -e '/_rate_/p' \\" echo " -e 's|available|available_cur|' -e '/available_cur/p' \\" echo " cur_speed.out > run.out" sed -n -e 's|_rate|_rate_cur|' -e '/_rate_/p' \ -e 's|available|available_cur|' -e '/available_cur/p' \ cur_speed.out > run.out # echo "sed -n -e 's|_rate|_rate_new|' -e '/_rate_/p' \\" echo " -e 's|available|available_new|' -e '/available_new/p' \\" echo " new_speed.out >> run.out" sed -n -e 's|_rate|_rate_new|' -e '/_rate_/p' \ -e 's|available|available_new|' -e '/available_new/p' \ new_speed.out >> run.out # echo "cat run.out | sort -u" cat run.out | sort -u # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/svn_ignore.sh0000755000175200017650000000234212656321776015717 0ustar coincoin-web#! /bin/bash -e # $Id: svn_ignore.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/svn_ignore.sh" ] then echo "bin/svn_ignore.sh: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- cat << EOF > bin/svn_ignore.$$ aclocal.m4 ar-lib autom4te.cache build check_all.err commit.sh.old configure.hpp doc doxydoc doxyfile doxyfile.* doxygen.err junk junk.* *.log new temp temp.sh test_one.exe test_one.sh test_one.cpp *.tmp EOF svn propset svn:ignore --recursive -F bin/svn_ignore.$$ . rm bin/svn_ignore.$$ # # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/check_doxygen.sh0000755000175200017650000000326412656321776016364 0ustar coincoin-web#! /bin/bash -e # $Id: check_doxygen.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 [ ! -e "bin/check_doxygen.sh" ] then echo "bin/check_doxygen.sh: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- if [ ! -e "doxygen.err" ] then bin/run_doxygen.sh fi doxygen_version=`doxygen --version | 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 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 fi list=`head doxygen.err` if [ "$list" == "" ] then echo "$O: OK" exit 0 fi echo bin/"check_doxygen.sh: Doxygen errors or warnings; see doxygen.err" if [ "$USER" != "bradbell" ] then exit 0 fi echo "$O: Error" exit 1 cppad-20160000.1/bin/replace_html.py0000755000175200017650000001107712656321776016230 0ustar coincoin-web#! /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. # # A copy of 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 # ----------------------------------------------------------------------------- if sys.argv[0] != 'bin/replace_html.py' : 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 define_file: contains the define commands replace_file: contains the replace commands (many be same as define_file) new_file: is a copy of replace file with the replacements. The definitions are specified by: 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 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) 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) if not os.path.exists(replace_file) : 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) f_in = open(define_file, 'rb') define_data = f_in.read() f_in.close() f_in = open(replace_file, 'rb') replace_data = f_in.read() f_in.close() # ----------------------------------------------------------------------------- # create define: a dictionary with replacement text definitions define = {} p_define = re.compile('') 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) # ----------------------------------------------------------------------------- # 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) # ----------------------------------------------------------------------------- f_out = open(new_file, 'wb') f_out.write(new_data) f_out.close() # ----------------------------------------------------------------------------- sys.exit(0) cppad-20160000.1/bin/check_svn_id.sh0000755000175200017650000000343312656321776016167 0ustar coincoin-web#! /bin/bash -e # $Id: check_svn_id.sh 3762 2015-12-01 14:35:37Z 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 [ ! -e "bin/check_svn_id.sh" ] then echo "bin/check_svn_id.sh: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- echo "Checking for \$Id.*\$ in beginning of source code" echo "-------------------------------------------------------" ok="yes" list=`bin/list_files.sh | sed -n \ -e '/^gpl-3.0.txt$/d' \ -e '/^epl-v10.txt$/d' \ -e '/cppad\/local\/config.h.in$/d' \ -e '/^makefile.in$/d' \ -e '/^svn_commit.sh$/d' \ -e '/^git_commit.sh$/d' \ -e '/\/makefile.in$/d' \ -e '/\.hpp$/p' \ -e '/\.cpp$/p' \ -e '/\.omh$/p' \ -e '/\.txt$/p' \ -e '/\.sh$/p' \ -e '/\.in$/p' \ -e '/\.am$/p'` # for file in $list do # deprecated link files have just one line lines=`cat $file | wc -l` if [ "$lines" != 1 ] then if ! head -2 $file | grep '$Id.*\$' > /dev/null then echo "$file does not have '\$Id.*\$' in first two lines" ok="no" fi fi done echo "-------------------------------------------------------" if [ "$ok" = "no" ] then 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 fi cppad-20160000.1/bin/get_adolc.sh0000755000175200017650000001111712656321776015467 0ustar coincoin-web#! /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 is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of 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 get_adolc.sh$$ $newlinech #$$ # $spell # tgz # Adolc # gz # CppAD # $$ # # $section Download and Install Adolc in Build Directory$$ # # $head Syntax$$ # $code bin/get_adolc.sh$$ # # $head Purpose$$ # If you are using Unix, this command will download and install # $href%https://projects.coin-or.org/ADOL-C%ADOL-C%$$ in the # CppAD $code build$$ directory. # # $head Requirements$$ # You must first use $cref get_colpack.sh$$ to download and install # $code ColPack$$ (coloring algorithms used for sparse matrix derivatives). # # $head Distribution Directory$$ # This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ # The Adolc source code is downloaded into the sub-directory # $code build/external$$ below the distribution directory. # # $head Prefix Directory$$ # The Adolc include files are installed in the sub-directory # $code build/prefix/include/adolc$$ below the distribution directory. # # $head Reuse$$ # The files $codei%build/external/ADOL-C-%version%.tgz%$$ # and the directory $codei%build/external/ADOL-C-%version%$$ # will be reused if they exist. Delete this file and directory # to get a complete rebuild. # # $end # ----------------------------------------------------------------------------- if [ $0 != "bin/get_adolc.sh" ] then 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 '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' 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 fi # -------------------------------------------------------------------------- if [ -e /usr/lib64 ] then libdir='lib64' else libdir='lib' fi # ----------------------------------------------------------------------------- if [ ! -d build/external ] then 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 fi # ----------------------------------------------------------------------------- if [ -e "$prefix/include/adolc" ] then echo_eval rm -r "$prefix/include/adolc" fi # ----------------------------------------------------------------------------- if [ ! -e ADOL-C-$version ] then echo_eval tar -xzf ADOL-C-$version.tgz fi echo_eval cd ADOL-C-$version # ----------------------------------------------------------------------------- system=`uname | tr [A-Z] [a-z] | sed -e 's|\([a-z][a-z]*\).*|\1|'` # ----------------------------------------------------------------------------- if which autoconf >& /dev/null then echo_eval autoreconf --install --force fi # ----------------------------------------------------------------------------- if [ ! -e build ] then 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" else flags="$flags --enable-static --enable-shared" fi # echo_eval ../configure $flags echo_eval make install # ----------------------------------------------------------------------------- echo_eval touch $cppad_dir/$installed_flag echo "get_adolc: OK" cppad-20160000.1/bin/check_include_omh.sh0000755000175200017650000000515712656321776017200 0ustar coincoin-web#! /bin/bash -e # $Id: check_include_omh.sh 3711 2015-08-20 14:57:57Z 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 [ ! -e "bin/check_include_omh.sh" ] then echo "bin/check_include_omh.sh: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- # Make sure omhelp, under cygwin, has not matched file names with wrong case. echo "Checking difference between OMhelp include directives and file names." echo "----------------------------------------------------------------------" # super list of file names that are referenced by omhelp commands bin/list_files.sh | sed -n \ -e '/\.c$/p' \ -e '/\.cpp$/p' \ -e '/\.hpp$/p' \ -e '/\.omh$/p' \ -e '/\.txt$/p' \ -e '/\.am$/p' \ > bin/check_include_omh.1.$$ # # add *.sh files with omhelp documentation ls bin/get_*.sh >> bin/check_include_omh.1.$$ # for file in `cat bin/check_include_omh.1.$$` do # 1. assume $childtable, ... , $verbatim use % for delimiter # 2. assume verbatim commands use one line. # 3. assume $childtable, $children, $contents use multiple lines. # multiple line verbatim commands). sed -n < $file >> bin/check_include_omh.2.$$ \ -e 's/^#[ \t][ \t]*//' \ -e '/$childtable%/,/%$\$/p' \ -e '/$children%/,/%$\$/p' \ -e '/$contents%/,/%$\$/p' \ -e '/$verbatim%/p' done sed < bin/check_include_omh.2.$$ > bin/check_include_omh.3.$$ \ -e 's/$childtable//' \ -e 's/$children//' \ -e 's/$contents//' \ -e 's/$verbatim%\([^%]*\)%.*/\1/' \ -e 's/%//' \ -e 's/$\$//' \ -e '/^ *$/d' \ -e 's/^[ ]*//' \ -e 's|\\|/|g' # different="no" for file in `cat bin/check_include_omh.3.$$` do if [ "`grep $file bin/check_include_omh.1.$$`" == "" ] then echo $file different="yes" fi done for index in 1 2 3 do rm bin/check_include_omh.$index.$$ done # echo "-------------------------------------------------------------------" if [ $different = "yes" ] then echo "Error: nothing should be between the two dashed lines above." echo 'Perhaps this file is not and has not yet been added to repository ?' exit 1 else echo "Ok: nothing is between the two dashed lines above" exit 0 fi cppad-20160000.1/bin/new_stable.sh0000755000175200017650000001077412656321776015701 0ustar coincoin-web#! /bin/bash -e # $Id: new_stable.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. # ----------------------------------------------------------------------------- echo 'Need to change this from using git-svn to using push_git2svn.sh' echo 'See bin/new_release.sh.' exit 1 if [ "$0" != "bin/new_stable.sh" ] then echo "bin/new_stable.sh: must be executed from its parent directory" exit 1 fi # bash function that echos and executes a command echo_eval() { echo $* eval $* } # ----------------------------------------------------------------------------- copy_from_trunk='keep' # do (frist time), keep (use current) trunk_revision='3507' # trunk revision number that stable corresponds to yyyy_mm_dd='2015-00-00' # Date corresponding to this trunk revision # ----------------------------------------------------------------------------- echo "copy_from_trunk=$copy_from_trunk" echo "trunk_revision=$trunk_revision" echo "yyyy_mm_dd=$yyyy_mm_dd" echo '------------------------------------------------------------------------' stable_version=`echo $yyyy_mm_dd | sed -e 's/-//g'` release_version="$stable_version.0" repository="https://projects.coin-or.org/svn/CppAD" rep_trunk="$repository/trunk" rep_stable="$repository/stable/$stable_version" # ----------------------------------------------------------------------------- if [ "$copy_from_trunk" = "redo" ] then # delete old stable copy msg="Replacing old stable/$stable_version." echo "svn delete $rep_stable -m \"$msg\"" svn delete $rep_stable -m "$msg" fi # ----------------------------------------------------------------------------- if [ "$copy_from_trunk" = "do" ] || [ "$copy_from_trunk" = "redo" ] then # # create the new stable copy temp_1="Create stable/$stable_version" temp_2="from trunk at revision $trunk_revision." msg="$temp_1 $temp_2" echo "svn copy -r $trunk_revision $rep_trunk $rep_stable -m \"$msg\"" svn copy -r $trunk_revision $rep_trunk $rep_stable -m "$msg" fi # ----------------------------------------------------------------------------- echo 'Use git-svn to fetch the new stable version' fetch="stable/$stable_version:refs/remotes/svn/stable/$stable_version" if ! grep "fetch *= *$fetch" .git/config > /dev/null then sed -e "s|^\turl *=.*|&\n\tfetch = $fetch|" -i .git/config fi # # fetch the branch echo_eval git svn fetch # ----------------------------------------------------------------------------- # checkout the new stable version if git branch | grep "$stable_version" then git checkout $stable_version else echo_eval git checkout -b $stable_version svn/stable/$stable_version fi # make sure that bin/new_stable.sh corresponds to current master version # (may not be same as version in repository that was copied). echo_eval git show master:bin/new_stable.sh > bin/new_stable.sh # # set the version number in root CMakeLists.txt to $stable_version echo_eval bin/version.sh set $release_version # # copy version number to other files echo_eval bin/version.sh copy # # set the value of stable version in corresponding new_release.sh echo "automatic editing: $stable_version/bin/new_release.sh" sed -i bin/new_release.sh \ -e "s/stable_version=.*/stable_version=\"$stable_version\"/" # # Inform build.sh that this is a stable version echo "automatic editing: $stable_version/build.sh" sed -i build.sh -e 's/^version_type=.*/version_type="stable"/' # # Set download documentation to use web version of corresponding release echo "automatic editing of omh/install/download.omh" dir="http://www.coin-or.org/download/source/CppAD" sed -i omh/install/download.omh \ -e "s|cppad-$release_version.[eg]pl.tgz|\n$dir/&%\n&|" # # Instructions -------------------------------------------------------------- cat << EOF 1: Review differences using git. If you find problems, fix both master and $new_stable versions of bin/new_stable.sh. 3: Run the following commands: bin/check_all.sh 4: If errors occur, fix both master and $new_stable version of bin/new_stable.sh and goto 3. 5: Run the script bin/new_release.sh EOF # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/svn_merge.sh0000755000175200017650000000361612656321776015540 0ustar coincoin-web#! /bin/bash -e # $Id: svn_merge.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/svn_merge.sh" ] then echo "bin/svn_merge.sh: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- # Merge the changes that occurred in from_branch into the current directory # # backup this file (incase it gets overwritten by merge) cp bin/svn_merge.sh bin/svn_merge.sh.$$ # # make sure current direction is up to date svn update # # dry_run='--dry-run' # dry_run='' dry_run='' # # accept='--accept theirs-full' # accept='' accept='--accept theirs-full' # # Location of the repository repository='https://projects.coin-or.org/svn/CppAD' # # Name of the directory where the changes have been committed from_branch='branches/forward_dir' # # Version of the repository corresponding to from_branch just before changes Start=3219 # # Version of the repository corresponding to from_branch after the changes End=3300 # # the svn merge command cmd="svn merge $accept $dry_run -r $Start:$End $repository/$from_branch" echo "$cmd" eval $cmd # # restore original version of this file mv bin/svn_merge.sh.$$ bin/svn_merge.sh # # get the current status echo "svn status > svn_merge.log" svn status > svn_merge.log # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/version.sh0000755000175200017650000000704012656321776015233 0ustar coincoin-web#! /bin/bash -e # $Id: version.sh 3693 2015-06-01 13:55:14Z 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/version.sh' ] then echo 'bin/version.sh: must be executed from its parent directory' exit 1 fi if [ "$1" != 'get' ] && [ "$1" != 'set' ] && [ "$1" != 'copy' ] then echo 'usage: bin/version.sh (get | set | copy) [version]' echo 'get: Gets the current version number from CMakeLists.txt.' echo 'set: Sets CMakeLists.txt version number to version.' echo ' If version is not present, uses current yyyymmdd.' echo 'copy: Copies version number from CMakeLists.txt to other files.' exit 1 fi echo_eval() { echo $* eval $* } # ----------------------------------------------------------------------------- if [ "$1" == 'set' ] then if [ "$2" == '' ] then version=`date +%Y%m%d` else version="$2" fi echo 'sed -i.old CMakeLists.txt ...' sed \ -e "s/(\(cppad_version *\)\"[0-9.]\{8\}[0-9.]*\" *)/(\1\"$version\" )/" \ -i.old CMakeLists.txt if diff CMakeLists.txt.old CMakeLists.txt then echo 'No change in CMakeLists.txt' fi echo_eval rm CMakeLists.txt.old # echo 'bin/version.sh set: OK' exit 0 fi # ----------------------------------------------------------------------------- # get the current version number version=`grep '^SET *( *cppad_version ' CMakeLists.txt | \ sed -e 's|^SET *( *cppad_version *"\([0-9.]\{8\}[0-9.]*\)" *)|\1|'` if ! (echo $version | grep '[0-9]\{8\}') > /dev/null then echo 'bin/version.sh: Cannot find verison number in CMakeLists.txt' exit 1 fi if [ "$1" == 'get' ] then echo "$version" exit 0 fi # ----------------------------------------------------------------------------- # Make the version number in the relevant files is the same yyyy_mm_dd=`echo $version | sed \ -e 's|\([0-9]\{4\}\)0000|\10101|' \ -e 's|\(....\)\(..\)\(..\).*|\1-\2-\3|'` echo 'sed -i.old AUTHORS ...' sed \ -e "s/, [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} *,/, $yyyy_mm_dd,/" \ -i.old AUTHORS # echo 'sed -i.old configure.ac ...' sed \ -e "s/(\[cppad\], *\[[0-9]\{8\}[.0-9]*\] *,/([cppad], [$version],/" \ -i.old configure.ac # echo 'sed -i.old configure ...' sed \ -e "s/cppad [0-9]\{8\}[.0-9]*/cppad $version/g" \ -e "s/VERSION='[0-9]\{8\}[.0-9]*'/VERSION='$version'/g" \ -e "s/configure [0-9]\{8\}[.0-9]*/configure $version/g" \ -e "s/config.status [0-9]\{8\}[.0-9]*/config.status $version/g" \ -e "s/\$as_me [0-9]\{8\}[.0-9]*/\$as_me $version/g" \ -e "s/Generated by GNU Autoconf.*$version/&./" \ -i.old configure list=' omh/install/auto_tools.omh omh/install/download.omh doc.omh ' for file in $list do sed -e "s/cppad-[0-9]\{8\}\(\.[eg]pl\)/cppad-$version\1/" \ -e "s/cppad-[0-9]\{8\}\.[0-9]*\(\.[eg]pl\)/cppad-$version\1/" \ -e "s/cppad-[0-9]\{8\}[0-9.]*\:/cppad-$version:/" \ -i.old $file done list=" $list AUTHORS configure.ac configure " for name in $list do echo '-------------------------------------------------------------' echo "diff $name.old $name" if diff $name.old $name then echo ' no difference was found' fi # echo_eval rm $name.old done echo 'bin/version.sh copy: OK' cppad-20160000.1/bin/git_ignore.sh0000755000175200017650000000360112656321776015673 0ustar coincoin-web#! /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/git_ignore.sh" ] then echo "bin/git_ignore.sh: must be executed from its parent directory" exit 1 fi # ----------------------------------------------------------------------------- # use @ for * so does not get replaced during echo command dir_list=' . ./@ ./@/@ ' top_dir_list=' git_commit.sh aclocal.m4 ar-lib autom4te.cache build commit.sh.old doc doxydoc cppad/configure.hpp ' all_dir_list=' @.err @.log @.swp @.tmp build new test_one.exe test_one.sh test_one.cpp ' root_name_list=' doxyfile junk temp ' # ----------------------------------------------------------------------------- if [ -e .gitignore ] then rm .gitignore fi echo '# top directory only' >> .gitignore for name in $top_dir_list do echo "$name" | sed -e 's|^./||' -e 's|@|*|g' >> .gitignore done echo '# all directories' >> .gitignore for name in $all_dir_list do for dir in $dir_list do echo "$dir/$name" | sed -e 's|^./||' -e 's|@|*|g' >> .gitignore done done echo '# all directions with and without extension' >> .gitignore for name in $root_name_list do for dir in $dir_list do echo "$dir/$name" | sed -e 's|^./||' -e 's|@|*|g' >> .gitignore echo "$dir/$name.*" | sed -e 's|^./||' -e 's|@|*|g' >> .gitignore done done # ---------------------------------------------------------------------------- echo 'git_ignore.sh: OK' exit 0 cppad-20160000.1/bin/check_svn_dist.sh0000755000175200017650000000430612656321776016536 0ustar coincoin-web#! /bin/bash -e # $Id: check_svn_dist.sh 2506 2012-10-24 19:36:49Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- 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 "./build.sh configure" if ! ./build.sh configure then echo "$script: error durring ./build.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" cppad-20160000.1/bin/proj_desc.py0000755000175200017650000001510112656321776015531 0ustar coincoin-web#! /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) cppad-20160000.1/bin/clean_tar.sh0000755000175200017650000000373412656321776015504 0ustar coincoin-web#! /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/clean_tar.sh" ] then echo "bin/clean_tar.sh: must be executed from its parent directory" exit 1 fi # bash function that echos and executes a command echo_eval() { echo $* eval $* } # ----------------------------------------------------------------------------- list=`find . -name '*.swp'` for file in $list do response='' read -p "Remove the editor temporary file $file [y/n]" response if [ "$response" == 'y' ] then echo_eval rm $file fi done for dir in build doc doxydoc do if [ -e "$dir" ] then echo_eval rm -r $dir fi done list=`find . -name 'new'` for dir in $list do echo_eval rm -r $dir done list=`find . \ \( -name '*.err' \) -or \ \( -name '*.log' \) -or \ \( -name '*.tmp' \) -or \ \( -name 'junk.*' \) -or \ \( -name 'temp.*' \) -or \ \( -name 'test_one.exe' \) -or \ \( -name 'test_one.sh' \) -or \ \( -name 'test_one.cpp' \) -or \ \( -name 'aclocal.m4' \) -or \ \( -name 'ar-lib' \) -or \ \( -name 'configure.hpp' \) -or \ \( -name 'git_commit.sh' \) -or \ \( -name 'junk' \) -or \ \( -name 'temp' \) | \ sed -e '/\.git\//d' -e '/example\/atomic\/test_one.sh/d' ` for file in $list do echo_eval rm $file done version=`date +%Y%m%d` name=`pwd | sed -e 's|.*/||'` cd .. cp -r $name $name-$version echo_eval tar -czf $name-$version.tgz $name-$version rm -rf $name-$version # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/check_jenkins.sh0000755000175200017650000000303612656321776016345 0ustar coincoin-web#! /bin/bash -e # $Id: check_jenkins.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 [ ! -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 # ---------------------------------------------------------------------------- redo_external='install' echo_eval bin/jenkins.sh $redo_external # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/mv_branch.sh0000755000175200017650000001017412656321776015507 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ "$0" != "bin/mv_branch.sh" ] then echo 'bin/mv_branch.sh: must be executed from its parent directory' exit 1 fi if [ ! -e '.git/svn' ] then echo 'bin/mv_branch.sh: must be executed in the git_svn repository' exit 1 fi if [ "$2" == '' ] then echo 'usage: bin/mv_branch.sh old_branch_name new_branch_name' exit 1 fi old_branch_name="$1" new_branch_name="$2" repository='https://projects.coin-or.org/svn/CppAD' old_branch_path="branches/$old_branch_name" new_branch_path="branches/$new_branch_name" # ----------------------------------------------------------------------------- # bash function that echos and executes a command pause() { response='' while [ "$response" != 'y' ] && [ "$response" != 'n' ] do read -p 'Continue [y/n] ' response done if [ "$response" != 'y' ] then exit 1 fi } echo_eval() { echo $* eval $* } # ----------------------------------------------------------------------------- if [ "$old_branch_name" == "$new_branch_name" ] then echo "mv_branch.sh: old and new branch names are the same" exit 1 fi for branch_path in $old_branch_path $new_branch_path do for name in 'master' 'trunk' do if [ "$branch_path" == "$name" ] then echo "mv_branch.sh: neither old or new branch path can be $name" exit 1 fi done done old_fetch="$old_branch_path:refs/remotes/svn/$old_branch_path" if ! grep "fetch *= *$old_fetch" .git/config > /dev/null then echo "mv_branch.sh: cannot find $old_branch_path in ./git/config" exit 1 fi svn_remote_dir=".git/svn/refs/remotes/svn" dir=`echo $new_branch_path | sed -e 's|/[^/]*$||'` if [ ! -e "$svn_remote_dir/$dir" ] then echo 'mv_branch.sh: Must first create the directory' echo " $svn_remote_dir/$dir" exit 1 fi dir=`echo $new_branch_name | sed -e 's|/.*||'` if [ "$dir" != "$new_branch_name" ] then if ! svn list $repository/branches | grep "$dir/" > /dev/null then echo 'mv_branch.sh: Must frist create the directory' echo " $repository/branches/$dir" fi fi # ----------------------------------------------------------------------------- # make sure repsitories are in sync echo_eval git fetch github echo "git show-ref --hash $old_branch_name | head -1" git show-ref --hash $old_branch_name | head -1 echo_eval git show-ref --hash github/$old_branch_name pause # ----------------------------------------------------------------------------- # svn msg="Moving $old_branch_path to $new_branch_path" cmd="svn mv $repository/$old_branch_path $repository/$new_branch_path" echo "$cmd -m \"$msg\"" $cmd -m "$msg" pause # ---------------------------------------------------------------------------- # change the name locally echo_eval git branch -m $old_branch_name $new_branch_name pause # ---------------------------------------------------------------------------- # change the remote github name for the branch echo_eval git push github --set-upstream $new_branch_name echo_eval git push github :$old_branch_name pause # ---------------------------------------------------------------------------- # change the remote svn name for the branch # # backup current version of .git/config index='1' while [ -e .git/config.$index ] do index=`expr $index + 1` done echo_eval cp .git/config .git/config.$index # # change the svn fetch command new_fetch="$new_branch_path:refs/remotes/svn/$new_branch_path" # sed -e "s|$old_fetch|$new_fetch|" -i .git/config echo_eval diff .git/config.$index .git/config pause # # move the svn fetch infromation svn_remote_dir=".git/svn/refs/remotes/svn" echo_eval mv $dir/$old_branch_path $dir/$new_branch_path # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 cppad-20160000.1/bin/get_fadbad.sh0000755000175200017650000000613712656321776015614 0ustar coincoin-web#! /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. # # A copy of 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 get_fadbad.sh$$ $newlinech #$$ # $spell # Fadbad # CppAD # $$ # # $section Download and Install Fadbad in Build Directory$$ # $index fadbad, download and install$$ # $index download, install fadbad$$ # $index install, fadbad$$ # # $head Syntax$$ # $code bin/get_fadbad.sh$$ # # $head Purpose$$ # If you are using Unix, this command will download and install # $href%http://www.fadbad.com%Fadbad%$$ in the # CppAD $code build$$ directory. # # $head Distribution Directory$$ # This command must be executed in the # $cref/distribution directory/download/Distribution Directory/$$. # # $head External Directory$$ # The Fadbad source code is downloaded into the sub-directory # $code build/external$$ below the distribution directory. # # $head Prefix Directory$$ # The Fadbad include files are installed in the sub-directory # $code build/prefix/include/FADBAD++$$ below the distribution directory. # # $end # ----------------------------------------------------------------------------- if [ $0 != "bin/get_fadbad.sh" ] then 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 'Download fadbad to build/external and install it to build/prefix' version='2.1' web_page='http://www.fadbad.com/download' cppad_dir=`pwd` prefix="$cppad_dir/build/prefix" installed_flag="build/external/fadbad-${version}.installed" if [ -e "$installed_flag" ] then echo "$installed_flag exists: Skipping get_fadbad.sh" exit 0 fi # ----------------------------------------------------------------------------- if [ ! -d build/external ] then 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 fi if [ -e "FADBAD++" ] then 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" fi if [ -e "$prefix/include/FADBAD++" ] then echo_eval rm -r "$prefix/include/FADBAD++" fi echo_eval cp -r FADBAD++ "$prefix/include/FADBAD++" # ----------------------------------------------------------------------------- echo_eval touch $cppad_dir/$installed_flag echo "get_fadbad.sh: OK" cppad-20160000.1/bin/jenkins.sh0000755000175200017650000001212712656321776015211 0ustar coincoin-web#! /bin/bash -e # $Id: jenkins.sh 3758 2015-11-30 15:29:22Z 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/jenkins.sh" ] then echo "bin/jenkins.sh: must be executed from its parent directory" exit 1 fi if [ "$1" != '' ] then echo 'bin/junk.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 log_eval() { echo "------------------------------------------------" >> ../jenkins.log echo "------------------------------------------------" >> ../jenkins.err echo $* >> $trunk_dir/jenkins.log echo $* >> $trunk_dir/jenkins.err echo $* "1>> $trunk_dir/jenkins.log 2>> $trunk_dir/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 } 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 # ------------------------------------------------------------------- # Running bin/get_sacado.sh ensures its include files are in # $trunk_dir/build/prefix/include # and library files in # $trunk_dir/build/prefix/$libdir log_eval bin/get_sacado.sh # ------------------------------------------------------------------- # Running bin/get_colpack.sh ensures its library files are in # $trunk_dir/build/prefix/$libdir log_eval bin/get_colpack.sh # ------------------------------------------------------------------- # Running bin/get_acolc.sh ensures its include files are in # $trunk_dir/build/prefix/include/adolc # and library files in # $trunk_dir/build/prefix/$libdir log_eval bin/get_adolc.sh # ------------------------------------------------------------------- system_name=`uname | sed -e 's|\(......\).*|\1|'` if [ "$system_name" == 'CYGWIN' ] then export PATH="$trunk_dir/build/prefix/bin:$PATH" else export LD_LIBRARY_PATH="$trunk_dir/build/prefix/$libdir" fi # ----------------------------------------------------------------------- # Use trunk_dir/build/auto_tools to build and test CppAD (no reuse) echo_eval cd build echo_eval rm -rf auto_tools echo_eval mkdir auto_tools echo_eval cd auto_tools # # 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 # cat << EOF $trunk_dir/configure \\ $build_type \\ --disable-silent-rules \\ --with-implicit_ctor \\ ADOLC_DIR="$trunk_dir/build/prefix" \\ SACADO_DIR="$trunk_dir/build/prefix" \\ EIGEN_DIR="$trunk_dir/build/prefix" \\ IPOPT_DIR="$trunk_dir/build/prefix" \\ FADBAD_DIR="$trunk_dir/build/prefix" \\ OPENMP_FLAGS=-fopenmp EOF if ! $trunk_dir/configure $build_type \ --disable-silent-rules \ --with-implicit_ctor \ ADOLC_DIR="$trunk_dir/build/prefix" \ SACADO_DIR="$trunk_dir/build/prefix" \ EIGEN_DIR="$trunk_dir/build/prefix" \ IPOPT_DIR="$trunk_dir/build/prefix" \ FADBAD_DIR="$trunk_dir/build/prefix" \ OPENMP_FLAGS=-fopenmp then echo "Error during configure command. Here is config.log file:" echo "--------------------------------------------------------" cat config.log exit 1 fi # # compile the tests log_eval make check # # run the tests 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" cppad-20160000.1/makefile.am0000644000175200017650000002622612656321777014543 0ustar coincoin-web# $Id: makefile.am 3769 2015-12-29 16:13:16Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # BUILT_SOURCES = $(top_srcdir)/cppad/configure.hpp $(top_srcdir)/cppad/configure.hpp: cppad/configure.hpp cp cppad/configure.hpp $(top_srcdir)/cppad/configure.hpp # if CppAD_POSTFIX postfix_dir = $(POSTFIX_DIR) else postfix_dir = . endif # # Did user specify a value for ADOLC_DIR in configure command line if CppAD_ADOLC SPEED_ADOLC_TESTS = speed/adolc else SPEED_ADOLC_TESTS = endif # # Did user specify a value for FADBAD_DIR in configure command line if CppAD_FADBAD SPEED_FADBAD_TESTS = speed/fadbad else SPEED_FADBAD_TESTS = endif # # Did user specify a value for SACADO_DIR in configure command line if CppAD_SACADO SPEED_SACADO_TESTS = speed/sacado else SPEED_SACADO_TESTS = endif # # Did user specify a value for IPOPT_DIR in configure command line if CppAD_IPOPT IPOPT_TESTS = \ example/ipopt_solve \ cppad_ipopt/example \ cppad_ipopt/speed \ cppad_ipopt/test # IPOPT_DIRS = \ cppad_ipopt/src \ $(IPOPT_TESTS) # IPOPT_HEADER = \ cppad_ipopt/src/cppad_ipopt_nlp.hpp else IPOPT_TESTS = IPOPT_DIRS = IPOPT_HEADER = endif # # Is the library archiving program present if CppAD_HAVE_AR SPEED_TESTS = \ $(SPEED_ADOLC_TESTS) \ speed/cppad \ speed/double \ speed/example \ $(SPEED_FADBAD_TESTS) \ speed/profile \ $(SPEED_SACADO_TESTS) # SPEED_DIRS = \ speed/src \ $(SPEED_TESTS) else SPEED_TESTS = SPEED_DIRS = endif # --------------------------------------------------------------------------- myincludedir = $(includedir)/$(postfix_dir) # myinclude_HEADERS = \ $(IPOPT_HEADER) # nobase_myinclude_HEADERS = \ cppad/utility.hpp \ cppad/base_require.hpp \ cppad/utility/check_numeric_type.hpp \ cppad/utility/check_simple_vector.hpp \ cppad/configure.hpp \ cppad/cppad.hpp \ cppad/utility/elapsed_seconds.hpp \ cppad/example/base_adolc.hpp \ cppad/example/cppad_eigen.hpp \ cppad/example/eigen_plugin.hpp \ cppad/example/matrix_mul.hpp \ cppad/utility/error_handler.hpp \ cppad/utility/index_sort.hpp \ cppad/ipopt/solve.hpp \ cppad/ipopt/solve_callback.hpp \ cppad/ipopt/solve_result.hpp \ cppad/local/abort_recording.hpp \ cppad/local/abs.hpp \ cppad/local/abs_op.hpp \ cppad/local/acos_op.hpp \ cppad/local/acosh.hpp \ cppad/local/acosh_op.hpp \ cppad/local/ad_assign.hpp \ cppad/local/ad_binary.hpp \ cppad/local/ad_ctor.hpp \ cppad/local/add_eq.hpp \ cppad/local/add.hpp \ cppad/local/add_op.hpp \ cppad/local/ad_io.hpp \ cppad/local/ad_fun.hpp \ cppad/local/ad.hpp \ cppad/local/ad_tape.hpp \ cppad/local/ad_to_string.hpp \ cppad/local/ad_valued.hpp \ cppad/local/arithmetic.hpp \ cppad/local/asin_op.hpp \ cppad/local/asinh.hpp \ cppad/local/asinh_op.hpp \ cppad/local/atan2.hpp \ cppad/local/atan_op.hpp \ cppad/local/atanh.hpp \ cppad/local/atanh_op.hpp \ cppad/local/atomic_base.hpp \ cppad/local/azmul.hpp \ cppad/local/base_complex.hpp \ cppad/local/base_cond_exp.hpp \ cppad/local/base_double.hpp \ cppad/local/base_float.hpp \ cppad/local/base_limits.hpp \ cppad/local/base_std_math.hpp \ cppad/local/base_to_string.hpp \ cppad/local/bender_quad.hpp \ cppad/local/bool_fun.hpp \ cppad/local/bool_valued.hpp \ cppad/local/capacity_order.hpp \ cppad/local/checkpoint.hpp \ cppad/local/check_for_nan.hpp \ cppad/local/color_general.hpp \ cppad/local/color_symmetric.hpp \ cppad/local/compare.hpp \ cppad/local/comp_op.hpp \ cppad/local/compute_assign.hpp \ cppad/local/cond_exp.hpp \ cppad/local/cond_op.hpp \ cppad/local/convert.hpp \ cppad/local/cosh_op.hpp \ cppad/local/cos_op.hpp \ cppad/local/cppad_assert.hpp \ cppad/local/cppad_colpack.hpp \ cppad/local/cskip_op.hpp \ cppad/local/csum_op.hpp \ cppad/local/declare_ad.hpp \ cppad/local/define.hpp \ cppad/local/dependent.hpp \ cppad/local/discrete.hpp \ cppad/local/discrete_op.hpp \ cppad/local/div_eq.hpp \ cppad/local/div.hpp \ cppad/local/div_op.hpp \ cppad/local/drivers.hpp \ cppad/local/epsilon.hpp \ cppad/local/equal_op_seq.hpp \ cppad/local/erf.hpp \ cppad/local/erf_op.hpp \ cppad/local/exp_op.hpp \ cppad/local/expm1.hpp \ cppad/local/expm1_op.hpp \ cppad/local/for_jac_sweep.hpp \ cppad/local/for_one.hpp \ cppad/local/for_sparse_jac.hpp \ cppad/local/for_two.hpp \ cppad/local/forward0sweep.hpp \ cppad/local/forward1sweep.hpp \ cppad/local/forward2sweep.hpp \ cppad/local/forward.hpp \ cppad/local/fun_check.hpp \ cppad/local/fun_construct.hpp \ cppad/local/fun_eval.hpp \ cppad/local/hash_code.hpp \ cppad/local/hessian.hpp \ cppad/local/identical.hpp \ cppad/local/independent.hpp \ cppad/local/integer.hpp \ cppad/local/jacobian.hpp \ cppad/local/load_op.hpp \ cppad/local/log_op.hpp \ cppad/local/log1p.hpp \ cppad/local/log1p_op.hpp \ cppad/local/lu_ratio.hpp \ cppad/local/mul_eq.hpp \ cppad/local/mul.hpp \ cppad/local/mul_op.hpp \ cppad/local/near_equal_ext.hpp \ cppad/local/numeric_limits.hpp \ cppad/local/num_skip.hpp \ cppad/local/old_atomic.hpp \ cppad/local/omp_max_thread.hpp \ cppad/local/op_code.hpp \ cppad/local/op.hpp \ cppad/local/optimize.hpp \ cppad/local/opt_val_hes.hpp \ cppad/local/ordered.hpp \ cppad/local/parallel_ad.hpp \ cppad/local/parameter_op.hpp \ cppad/local/par_var.hpp \ cppad/local/player.hpp \ cppad/local/pod_vector.hpp \ cppad/local/pow.hpp \ cppad/local/pow_op.hpp \ cppad/local/print_for.hpp \ cppad/local/print_op.hpp \ cppad/local/prototype_op.hpp \ cppad/local/recorder.hpp \ cppad/local/reverse.hpp \ cppad/local/reverse_sweep.hpp \ cppad/local/rev_hes_sweep.hpp \ cppad/local/rev_jac_sweep.hpp \ cppad/local/rev_one.hpp \ cppad/local/rev_sparse_hes.hpp \ cppad/local/rev_sparse_jac.hpp \ cppad/local/rev_two.hpp \ cppad/local/set_get_in_parallel.hpp \ cppad/local/sign.hpp \ cppad/local/sign_op.hpp \ cppad/local/sin_op.hpp \ cppad/local/sinh_op.hpp \ cppad/local/sparse_binary_op.hpp \ cppad/local/sparse_hessian.hpp \ cppad/local/sparse.hpp \ cppad/local/sparse_jacobian.hpp \ cppad/local/sparse_list.hpp \ cppad/local/sparse_pack.hpp \ cppad/local/sparse_pattern.hpp \ cppad/local/sparse_set.hpp \ cppad/local/sparse_unary_op.hpp \ cppad/local/sqrt_op.hpp \ cppad/local/standard_math.hpp \ cppad/local/std_math_98.hpp \ cppad/local/std_set.hpp \ cppad/local/store_op.hpp \ cppad/local/sub_eq.hpp \ cppad/local/sub.hpp \ cppad/local/sub_op.hpp \ cppad/local/tanh_op.hpp \ cppad/local/tan_op.hpp \ cppad/local/tape_link.hpp \ cppad/local/test_vector.hpp \ cppad/local/testvector.hpp \ cppad/local/unary_minus.hpp \ cppad/local/unary_plus.hpp \ cppad/local/undef.hpp \ cppad/local/user_ad.hpp \ cppad/local/value.hpp \ cppad/local/var2par.hpp \ cppad/local/vec_ad.hpp \ cppad/local/zdouble.hpp \ cppad/local/zmul_op.hpp \ cppad/utility/lu_factor.hpp \ cppad/utility/lu_invert.hpp \ cppad/utility/lu_solve.hpp \ cppad/utility/memory_leak.hpp \ cppad/utility/nan.hpp \ cppad/utility/near_equal.hpp \ cppad/utility/ode_err_control.hpp \ cppad/utility/ode_gear_control.hpp \ cppad/utility/ode_gear.hpp \ cppad/utility/omp_alloc.hpp \ cppad/utility/poly.hpp \ cppad/utility/pow_int.hpp \ cppad/utility/romberg_mul.hpp \ cppad/utility/romberg_one.hpp \ cppad/utility/rosen_34.hpp \ cppad/utility/runge_45.hpp \ cppad/utility/to_string.hpp \ cppad/speed/det_33.hpp \ cppad/speed/det_by_lu.hpp \ cppad/speed/det_by_minor.hpp \ 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/utility/speed_test.hpp \ cppad/speed/uniform_01.hpp \ cppad/utility/thread_alloc.hpp \ cppad/utility/time_test.hpp \ cppad/utility/track_new_del.hpp \ cppad/utility/vector.hpp # End nobase_myinclude_HEADERS (check_makefile.sh uses this comment) # --------------------------------------------------------------- # # No objects or executables are required to install CppAD. # See 'make test' below for building the tests. SUBDIRS = \ $(IPOPT_DIRS) \ $(SPEED_DIRS) \ example \ example/atomic \ compare_c \ introduction/get_started \ introduction/exp_apx \ print_for \ multi_thread \ multi_thread/test_multi \ test_more # # note that bin/gpl_license.sh is deleted by dist-hook EXTRA_DIST = \ bin \ build.sh \ doc.omh \ doc \ gpl-3.0.txt \ epl-v10.html \ omh \ uw_copy_040507.html \ \ compare_c/CMakeLists.txt \ cppad/CMakeLists.txt \ pkgconfig/CMakeLists.txt \ example/CMakeLists.txt \ example/atomic/CMakeLists.txt \ example/ipopt_solve/CMakeLists.txt \ test_more/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 \ multi_thread/bthread/CMakeLists.txt \ multi_thread/CMakeLists.txt \ multi_thread/openmp/CMakeLists.txt \ multi_thread/pthread/CMakeLists.txt \ print_for/CMakeLists.txt test_directory_list = \ $(IPOPT_TESTS) \ $(SPEED_TESTS) \ example \ example/atomic \ compare_c \ introduction/get_started \ introduction/exp_apx \ multi_thread \ multi_thread/test_multi \ print_for \ test_more test: all rm -f test.log touch test.log echo "#! /bin/sh -e" > test.sh for dir in $(test_directory_list) ; do ( \ echo "#" >> test.sh ; \ echo "echo \"Running make test in $$dir\"" >> test.sh ; \ echo "cd $$dir " >> test.sh ; \ echo "make test" >> test.sh ; \ echo "cd $(ABS_TOP_BUILDDIR)" >> test.sh ; \ ) done 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 # 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 pkgconfig_DATA = pkgconfig/cppad.pc cppad-20160000.1/bug/0002755000175200017650000000000012656321777013216 5ustar coincoin-webcppad-20160000.1/bug/eigen_shadow.sh0000755000175200017650000000334212656321776016210 0ustar coincoin-web#! /bin/bash -e # $Id: eigen_shadow.sh 3066 2013-12-29 17:27:20Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Eigen generates lots of warnings if -Wshadow is set of compile; e.g., # the first warning generated by this script is: # # warning: declaration of ‘value’ shadows a member of 'this' [-Wshadow] # explicit variable_if_dynamic(T value) : m_value(value) {} # ^ # ------------------------------------------------------------------------------ # bash function that echos and executes a command echo_eval() { echo $* eval $* } # ----------------------------------------------- if [ ! -e build ] then mkdir build fi cd build echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` # cat << EOF > $name.cpp # include # include int main() { using Eigen::Matrix; using Eigen::Dynamic; Matrix A(1,1); A(0,0) = 6.0; if( A(0,0) != 6.0 ) { std::cout << "$name: Error" << std::endl; return 1; } std::cout << "$name: OK" << std::endl; return 0; } EOF if [ -e "$name" ] then echo_eval rm $name fi echo_eval g++ \ $name.cpp \ -I$HOME/prefix/eigen/include \ -g \ -O0 \ -std=c++11 \ -Wshadow \ -o $name echo_eval ./$name cppad-20160000.1/bug/cond_exp.sh0000755000175200017650000000576212656321776015363 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- cat << EOF This example works for type zdouble, but not double. We want it to work for type double so as to avoid the overhead of zdouble. f(x) = 1 / x[0] if x[0] > 0 else 0.0 EOF cat << EOF > bug.$$ #include namespace { template bool test_float(void) { bool ok = true; using CppAD::vector; Float eps = Float( 10. * std::numeric_limits::epsilon() ); typedef CppAD::AD a1float; typedef CppAD::AD a2float; // -------------------------------------------------------------------- // create a1f = f(x) vector a2x(1), a2y(1); a2x[0] = a2float( 5.0 ); Independent(a2x); a2float a2zero = a2float(0.0); a2float a2one = a2float(1.0); a2y[0] = CondExpGt(a2x[0], a2zero, a2one / a2x[0], a2zero); CppAD::ADFun a1f; a1f.Dependent(a2x, a2y); // -------------------------------------------------------------------- // create g = f'(x) vector a1x(1), a1dy(1), a1w(1); a1x[0] = 2.0; a1w[0] = 1.0; Independent(a1x); a1f.Forward(0, a1x); a1dy = a1f.Reverse(1, a1w); CppAD::ADFun g; g.Dependent(a1x, a1dy); // -------------------------------------------------------------------- // check g where f(x) = 1 / x vector x(1), y(1); x[0] = 2.0; y = g.Forward(0, x); ok &= CppAD::NearEqual(y[0], - Float(1.0) / (x[0] * x[0]), eps, eps); // -------------------------------------------------------------------- // check g at edge case where 1 / x is infinity x[0] = 0.0; y = g.Forward(0, x); ok &= CppAD::NearEqual(y[0], Float(0.0), eps, eps); // -------------------------------------------------------------------- return ok; } } int main(void) { bool ok = true; if( test_float() ) std::cout << "zdouble: OK" << std::endl; else { ok = false; std::cout << "zdouble: Error" << std::endl; } if( test_float() ) std::cout << "double: OK" << std::endl; else { ok = false; std::cout << "double: Error" << std::endl; } if( ! ok ) return 1; return 0; } EOF # ----------------------------------------------------------------------------- if [ ! -e build ] then mkdir build fi cd build echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` mv ../bug.$$ $name.cpp echo "g++ -I../.. --std=c++11 -g $name.cpp -o $name" g++ -I../.. --std=c++11 -g $name.cpp -o $name # echo "./$name" if ! ./$name then echo echo "$name.sh: Error" exit 1 fi echo echo "$name.sh: OK" exit 0 cppad-20160000.1/bug/boost_equals.sh0000755000175200017650000000460712656321776016261 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- cat << EOF This is a simpler case that has the same error message as ./boost_lu.sh. The gist of the message: /usr/include/boost/numeric/ublas/detail/matrix_assign.hpp:33:35: error: no match for ‘operator<’ ... snip ... return norm_inf (e1 - e2) < epsilon * EOF cat << EOF > bug.$$ # include # include int main() { typedef CppAD::AD T; using boost::numeric::ublas::norm_inf; boost::numeric::ublas::matrix a(5,5); T epsilon = static_cast( std::numeric_limits::epsilon() ); T min_norm = static_cast( std::numeric_limits::min() ); T norm = norm_inf(a); bool equals = norm < epsilon; std::cout << "equals = " << equals << std::endl; // // using boost::numeric::ublas::detail::equals; // std::cout << "equals = " << equals(a, a, epsilon, min_norm) << std::endl; return 0; } EOF # ----------------------------------------------------------------------------- if [ ! -e build ] then mkdir build fi cd build echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` mv ../bug.$$ $name.cpp echo "g++ -I../.. --std=c++11 -g $name.cpp -o $name >& $name.log" if ! g++ -I../.. --std=c++11 -g $name.cpp -o $name >& $name.log then cat << EOF > $name.sed s|\\[|&\\n|g s|\\]|&\\n|g s|[‘{}]|&\\n|g s|[a-zA-Z0-9_]* *=|\\n&|g # s|boost::numeric::ublas::||g s|/usr/include/boost/numeric/ublas/||g # s|CppAD::AD *|AD|g s|, basic_unit_lower<> >||g s|, basic_upper<> >||g s|scalar_minus|scalar_minus_AD|g EOF echo "sed -f $name.sed $name.log > ../$name.log" sed -f $name.sed $name.log > ../$name.log echo "$name.sh: Compliation Error: see $name.log" exit 1 exit 1 fi # echo "./$name" if ! ./$name then echo echo "$name.sh: Execution Error" exit 1 fi echo echo "$name.sh: OK" exit 0 cppad-20160000.1/bug/cppad_cg.sh0000755000175200017650000001102712656321776015313 0ustar coincoin-web#! /bin/bash -e # $Id:$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- #! /bin/bash -e web_page='https://github.com/joaoleal/CppADCodeGen.git' # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { echo $* eval $* } # ----------------------------------------------------------------------------- cat << EOF This is not a bug but rather a demonstration of using conditional expressions with CppADCodeGen https://github.com/joaoleal/CppADCodeGen/ EOF # if [ ! -e build ] then echo_eval mkdir -p build fi echo_eval cd build cat << EOF > cppad_cg.cpp # include # include int main(void) { typedef CppAD::cg::CG cg_double; typedef CppAD::AD acg_double; // declare independent variables for f(x) size_t nx = 2; CppAD::vector ax(nx); ax[0] = 2.0; ax[1] = 3.0; CppAD::Independent(ax); // create dependent variables and values for f(x) // f(x) = x[0] / x[1] if (x[0] > 0 and x[1] >= x[0]) else 1.0 size_t nz = 1; CppAD::vector az(nz); acg_double acg_zero = acg_double(0.0); acg_double acg_one = acg_double(1.0); acg_double acg_temp_1 = CondExpGt(ax[1], ax[0], ax[0] / ax[1], acg_one); acg_double acg_temp_2 = CondExpGt(ax[0], acg_zero, acg_temp_1, acg_one); az[0] = acg_temp_2; // create AD function mapping independent to dependent variables CppAD::ADFun F(ax, az); // create the source code generator for function g(x) CppAD::cg::CodeHandler G; // declare the independent variables for g(x) CppAD::vector cg_x(nx); G.makeVariables(cg_x); // Compute the dependent variables and values for g(x) size_t ny = nz * nx; CppAD::vector cg_y(ny); cg_y = F.Jacobian(cg_x); // Mapping from variables in this program to variables in source_code // independent variable = x // dependent variable = y // temporary variable = v CppAD::cg::LanguageC langC("double"); CppAD::cg::LangCDefaultVariableNameGenerator nameGen; // generate the source code std::ostringstream source_code; G.generateCode(source_code, langC, cg_y, nameGen); // string corresponding to source code std::string source_str = source_code.str(); // C souce code corresponding to y = g(x) std::cout << source_str; return 0; } EOF # # Compile and run cppad_cg.cpp echo_eval g++ \ -g \ -std=c++11 \ -I$HOME/prefix/cppad_cg/include \ -I../.. \ cppad_cg.cpp -o cppad_cg # # Determine the maximum v index v_max_index=`./cppad_cg | sed \ -e '/^ *v\[[0-9]*\]/! d' \ -e 's|^ *v\[\([0-9]*\)\].*|\1|' | sort | tail -1` # # # Wrap y = g(x) in C++ function and test it cat << EOF > tst_cppad_cg.cpp # include namespace { using CppAD::zdouble; typedef CppAD::vector zvector; // // f(x) = x[0] / x[1] if (x[0] > 0 and x[1] >= x[0]) else 1.0 // g(x) = d/dx f(x) void g(const zvector& x, zvector& y) { zvector v($v_max_index + 1); EOF ./cppad_cg | sed -e 's|^ *|\t\t|' >> tst_cppad_cg.cpp cat << EOF >> tst_cppad_cg.cpp return; } } int main(void) { // initialize flag bool ok = true; // numerical precision for tests zdouble eps = 10. * std::numeric_limits::epsilon(); // number of components in vectors size_t nx = 2; size_t nz = 1; size_t ny = nz * nx; zdouble zero = 0.0; // // compute y = g(x) case where x[0] == 0.0 zvector x(nx), y(ny); x[0] = 0.0; x[1] = 0.0; g(x, y); // // check results ok &= CppAD::NearEqual(y[0], zero, eps, eps); ok &= CppAD::NearEqual(y[1], zero, eps, eps); // // compute y = g(x) case where g(x) = x[0] / x[1] x[0] = 2.0; x[1] = 3.0; g(x, y); // // check results ok &= CppAD::NearEqual(y[0], 1.0/x[1], eps, eps); ok &= CppAD::NearEqual(y[1], -x[0]/(x[1]*x[1]), eps, eps); // if( ! ok ) return 1; return 0; } EOF # # Compile test echo_eval g++ \ -g \ -std=c++11 \ -I../.. \ tst_cppad_cg.cpp -o tst_cppad_cg # if ! ./tst_cppad_cg then file="$HOME/install/cppad_cg/build/tst_cppad_cg.cpp" echo "install_cppad_cg.sh: Error" exit 1 fi # echo 'cppad_cg.sh: OK' exit 0 cppad-20160000.1/bug/numeric_limit.sh0000755000175200017650000001230312656321776016411 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- if [ ! -e ../cppad/configure.hpp ] then echo 'numeric_limits.sh: must first run bin/run_cmake.sh' echo 'from parent directory.' exit 1 fi cat << EOF This is not a bug, but rather a test of specialization of numeric_limits for AD types. EOF cat << EOF > bug.$$ # include /*! \\def CPPAD_STD_NUMERIC_LIMITS(Other, Base) This macro defines the specialization std::numeric_limits to have the same values and functions as the existing specialization std::numeric_limits. */ # define CPPAD_STD_NUMERIC_LIMITS(Other, Base) \\ namespace std {\\ template <> class numeric_limits\\ {\\ public:\\ static const bool is_specialized =\\ numeric_limits::is_specialized;\\ static const bool is_signed =\\ numeric_limits::is_signed;\\ static const bool is_integer =\\ numeric_limits::is_integer;\\ static const bool is_exact =\\ numeric_limits::is_exact;\\ static const bool has_infinity =\\ numeric_limits::has_infinity;\\ static const bool has_quiet_NaN =\\ numeric_limits::has_quiet_NaN;\\ static const bool has_signaling_NaN =\\ numeric_limits::has_signaling_NaN;\\ static const bool has_denorm_loss =\\ numeric_limits::has_denorm_loss;\\ static const bool is_iec559 =\\ numeric_limits::is_iec559;\\ static const bool is_bounded =\\ numeric_limits::is_bounded;\\ static const bool is_modulo =\\ numeric_limits::is_modulo;\\ static const bool traps =\\ numeric_limits::traps;\\ static const bool tinyness_before =\\ numeric_limits::tinyness_before;\\ static const int digits =\\ numeric_limits::digits;\\ static const int digits10 =\\ numeric_limits::digits10;\\ static const int radix =\\ numeric_limits::radix;\\ static const int min_exponent =\\ numeric_limits::min_exponent;\\ static const int min_exponent10 =\\ numeric_limits::min_exponent10;\\ static const int max_exponent =\\ numeric_limits::max_exponent;\\ static const int max_exponent10 =\\ numeric_limits::max_exponent10;\\ static const Base min(void)\\ { return static_cast( numeric_limits::min() ); }\\ static const Base max(void)\\ { return static_cast( numeric_limits::max() ); }\\ static const Base epsilon(void)\\ { return static_cast( numeric_limits::epsilon() ); }\\ static const Base round_error(void)\\ { return static_cast( numeric_limits::round_error() ); }\\ static const Base infinity(void)\\ { return static_cast( numeric_limits::infinity() ); }\\ static const Base quiet_NaN(void)\\ { return static_cast( numeric_limits::quiet_NaN() ); }\\ static const Base signaling_NaN(void)\\ { return static_cast( numeric_limits::signaling_NaN() ); }\\ static const Base denorm_min(void)\\ { return static_cast( numeric_limits::denorm_min() ); }\\ static const float_denorm_style has_denorm =\\ numeric_limits::has_denorm;\\ static const float_round_style round_style =\\ numeric_limits::round_style;\\ };\\ } CPPAD_STD_NUMERIC_LIMITS(double, CppAD::AD) # define PRINT_VAL(name) \\ std::cout << #name << " = " \\ << std::numeric_limits< CppAD::AD >::name << std::endl; # define PRINT_FUN(name) \\ std::cout << #name << " = " \\ << std::numeric_limits< CppAD::AD >::name() << std::endl; int main(void) { bool ok = true; // PRINT_VAL(is_specialized) PRINT_VAL(is_signed) PRINT_VAL(is_integer) PRINT_VAL(is_exact) PRINT_VAL(has_infinity) PRINT_VAL(has_quiet_NaN) PRINT_VAL(has_signaling_NaN) PRINT_VAL(has_denorm_loss) PRINT_VAL(is_iec559) PRINT_VAL(is_bounded) PRINT_VAL(is_modulo) PRINT_VAL(traps) PRINT_VAL(tinyness_before) // int PRINT_VAL(digits) PRINT_VAL(digits10) PRINT_VAL(radix) PRINT_VAL(min_exponent) PRINT_VAL(min_exponent10) PRINT_VAL(max_exponent) PRINT_VAL(max_exponent10) // function PRINT_FUN(min) PRINT_FUN(max) PRINT_FUN(epsilon) PRINT_FUN(round_error) PRINT_FUN(infinity) PRINT_FUN(quiet_NaN) PRINT_FUN(signaling_NaN) PRINT_FUN(denorm_min) // other PRINT_VAL(has_denorm) PRINT_VAL(round_style) // C++11 only // PRINT_VAL(max_digits10) // PRINT_FUN(lowest) // if( ok ) return 0; return 1; } EOF # ----------------------------------------------------------------------------- if [ ! -e build ] then mkdir build fi cd build echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` mv ../bug.$$ $name.cpp echo "g++ -I../.. --std=c++11 -g $name.cpp -o $name" g++ -I../.. --std=c++11 -g $name.cpp -o $name # echo "./$name" if ! ./$name then echo echo "$name.sh: Error" exit 1 fi echo echo "$name.sh: OK" exit 0 cppad-20160000.1/bug/eigen_quad.sh0000755000175200017650000000434012656321776015654 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { echo $* eval $* } # ----------------------------------------------- cat << EOF Function: f(x) = x^T * Q * x / 2 Note that the derivative of f(x) is given by: f'(x) = [ x^T * Q + (Q * x)^T ] / 2 = x^T * (Q * Q^T) / 2 EOF # ----------------------------------------------- if [ ! -e build ] then mkdir build fi cd build echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` # cat << EOF > $name.cpp # include # include # include int main() { bool ok = true; using CppAD::AD; using CppAD::ADFun; using CppAD::Independent; using Eigen::Matrix; using Eigen::Dynamic; using Eigen::VectorXd; typedef Matrix< AD , Dynamic, Dynamic > a_MatrixXd; typedef Matrix< AD , Dynamic , 1> a_VectorXd; int size = 2, i , j; a_VectorXd a_x(size); VectorXd x(size); x << 1, 2; for(i = 0; i < size; i++) { a_x[i] = x[i]; } a_MatrixXd a_Q(size, size); a_Q << 1, 2, 3, 4; Independent(a_x); AD a_two = 2.0; a_VectorXd a_y = (a_x.transpose() * a_Q * a_x) / a_two; // create f: x -> y and stop tape recording ADFun f(a_x, a_y); VectorXd jac = f.Jacobian(x); a_MatrixXd a_check_jac = a_x.transpose() * (a_Q + a_Q.transpose()) / a_two; std::cout << "True f'(x) = " << a_check_jac << std::endl; std::cout << "CppAD f'(x) = " << jac.transpose() << std::endl; return 0; } EOF if [ -e "$name" ] then echo_eval rm $name fi echo_eval g++ \ $name.cpp \ -I../.. \ -I$HOME/prefix/eigen/include \ -g \ -O0 \ -std=c++11 \ -Wno-shadow \ -Wno-deprecated-declarations \ -o $name echo_eval ./$name cppad-20160000.1/bug/test_install.sh0000755000175200017650000000345512656321776016266 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- cat << EOF This is not a bug but rather a test of installing with cppad_prefix=$HOME/prefix EOF cat << EOF > bug.$$ # include int main(void) { bool ok = true; using std::cout; using CppAD::AD; // CPPAD_TESTVECTOR( AD ) ax(1), ay(1); ax[0] = 1.0; CppAD::Independent(ax); ay[0] = sin( ax[0] ); CppAD::ADFun f(ax, ay); // std::vector< std::set > p(1); p[0].insert(0); CppAD::vector< size_t > row(1), col(1); row[0] = 0; col[0] = 0; CppAD::sparse_jacobian_work work; work.color_method = "colpack"; CPPAD_TESTVECTOR(double) x(1), jac(1); x[0] = 2.0; f.SparseJacobianForward(x, p, row, col, jac, work); // ok &= jac[0] == std::cos( x[0] ); // if( ok ) return 0; return 1; } EOF # ----------------------------------------------------------------------------- if [ ! -e build ] then mkdir build fi cd build echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` mv ../bug.$$ $name.cpp cmd="g++ -I $HOME/prefix/cppad/include --std=c++11 -g $name.cpp -o $name" cmd="$cmd -L $HOME/prefix/cppad/lib64 -lcppad_lib" cmd="$cmd -L $HOME/prefix/colpack/lib64 -lColPack" echo "$cmd" eval $cmd # echo "./$name" if ! ./$name then echo echo "$name.sh: Error" exit 1 fi echo echo "$name.sh: OK" exit 0 cppad-20160000.1/bug/alloc_global.sh0000755000175200017650000000631012656321776016164 0ustar coincoin-web#! /bin/bash -e # $Id: alloc_global.sh 2898 2013-09-18 13:07:32Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- #!/bin/bash -e # if [ ! -e build ] then mkdir build fi cd build if [ ! -e ../../cppad/configure.hpp ] then cmake ../.. fi # echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` echo "create $name.cpp" cat << EOF > $name.cpp // BEGIN PROGRAM # include # include # define NUMBER_THREADS 2 namespace { 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); std::stringstream stream; stream << "thread_num = " << thread_num << std::endl; std::cout << stream.str(); } } // Test routine called by the master thread (thread_num = 0). bool alloc_global(void) { bool ok = true; using std::cout; using std::endl; size_t num_threads = NUMBER_THREADS; if( omp_get_max_threads() < num_threads ) { cout << "can't set num_threads = " << num_threads << endl; ok = false; return ok; } // call setup for using thread_alloc in parallel mode. thread_alloc::parallel_setup(num_threads, in_parallel, thread_number); // Execute the worker function in parallel int thread_num; # pragma omp parallel for for(thread_num = 0; thread_num < num_threads; thread_num++) worker(); // end omp parallel for // now inform CppAD that there is only one thread thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL); 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); // free memory that was allocated by thread thread_num thread_all_[thread_num].x.resize(0); } return ok; } int main(void) { bool ok = alloc_global(); std::cout << "OK = " << ok << std::endl; return int(! ok); } EOF echo "g++ -g $name.cpp -I../.. -fopenmp -std=c++11 -o $name" g++ -g $name.cpp -I../.. -fopenmp -std=c++11 -o $name # echo "./$name" ./$name # echo "rm $name $name.cpp" rm $name $name.cpp cppad-20160000.1/bug/doxy_member.sh0000755000175200017650000000456212656321776016073 0ustar coincoin-web#! /bin/bash -e # $Id: doxy_member.sh 3237 2014-04-28 13:28:43Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Trying to figure out why ADFun::Forward appers twice where there is only # one implementation. # # ------------------------------------------------------------------------------ # bash function that echos and executes a command echo_eval() { echo $* eval $* } # ----------------------------------------------- echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` # ----------------------------------------------- for dir in build doxy_member do if [ ! -e $dir ] then mkdir $dir fi cd $dir done # ------------------------------------------------------------------------- cat << EOF > $name.hpp template class my_class { private: T value_; public: void set_value(T value = 0); T get_value(void); }; EOF cat << EOF > implement.hpp /*! \\file implement.hpp Implementation of member functions */ /*! Member function that sets the value. \\param value [in] New value. */ template void my_class::set_value(T value) { value_ = value; } /*! Member function that gets the value. \\return Current value. */ template T my_class::get_value(void) { return value_; } EOF cat << EOF > $name.cpp # include # include "$name.hpp" # include "implement.hpp" int main(void) { my_class x; x.set_value(2); std::cout << "x.value = " << x.get_value() << std::endl; return 0; } EOF # ------------------------------------------------------------------------- # echo_eval doxygen -g doxyfile cp ../../../doxyfile . sed \ -e 's|^\(INPUT *=\)|& .|' \ -e 's|^\(FILE_PATTERNS *=\)|& *.hpp *.cpp|' \ -i doxyfile # ------------------------------------------------------------------------- echo_eval doxygen doxyfile # ------------------------------------------------------------------------- echo_eval g++ $name.cpp -o name echo_eval ./name cppad-20160000.1/bug/template.sh0000755000175200017650000000263012656321776015366 0ustar coincoin-web#! /bin/bash -e # $Id: template.sh 3719 2015-09-02 18:41:58Z 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. # ----------------------------------------------------------------------------- cat << EOF Description EOF cat << EOF > bug.$$ # include int main(void) { bool ok = true; using std::cout; // cout << "1. copy template.sh to .sh\n"; cout << "2. Edit .sh replacing description and C++ source code\n"; cout << "3. Run ./.sh\n"; cout << "where is a name that describes the bug\n"; // if( ok ) return 0; return 1; } EOF # ----------------------------------------------------------------------------- if [ ! -e build ] then mkdir build fi cd build echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` mv ../bug.$$ $name.cpp echo "g++ -I../.. --std=c++11 -g $name.cpp -o $name" g++ -I../.. --std=c++11 -g $name.cpp -o $name # echo "./$name" if ! ./$name then echo echo "$name.sh: Error" exit 1 fi echo echo "$name.sh: OK" exit 0 cppad-20160000.1/bug/eigen_scalar.sh0000755000175200017650000000567212656321776016200 0ustar coincoin-web#! /bin/bash -e # $Id: eigen_scalar.sh 3066 2013-12-29 17:27:20Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # eigen_scalar.cpp:57:21: # warning: ISO C++ says that these are ambiguous, # even though the worst conversion for the first is better # than the worst conversion for the second: [enabled by default] # D = A * (B * C); # ^ # ------------------------------------------------------------------------------ # bash function that echos and executes a command echo_eval() { echo $* eval $* } # ----------------------------------------------- if [ ! -e build ] then mkdir build fi cd build echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` # cat << EOF > $name.cpp # include # include // following is 0 or 1. If 0, there is no warning # define DEFINE_TEMPLATED_CONSTRUCTOR 1 // ------------------------------------------------------------------------ class myscalar { public: // data double value_; // constructors myscalar(void) { value_ = 0.0; } myscalar(const double& value) { value_ = value; } # if DEFINE_TEMPLATED_CONSTRUCTOR template explicit myscalar(const T& value) { value_ = double(value); } # endif // binary operators myscalar operator+(const myscalar& right) const { myscalar result = value_ + right.value_; return result; } myscalar operator*(const myscalar& right) const { myscalar result = value_ * right.value_; return result; } bool operator!=(const myscalar& right) const { bool result = value_ != right.value_; return result; } // assignments myscalar& operator=(const double& value) { value_ = value; return *this; } // computed assignment operators myscalar& operator +=(const myscalar& right) { value_ += right.value_; return *this; } }; // ------------------------------------------------------------------------ int main() { using Eigen::Matrix; using Eigen::Dynamic; Matrix A(1,1); Matrix B(1,1); Matrix C(1,1); Matrix D(1,1); A(0,0) = 1.0; B(0,0) = 2.0; C(0,0) = 3.0; D = A * (B * C); if( D(0,0) != myscalar(6.0) ) { std::cout << "$name: Error" << std::endl; return 1; } std::cout << "$name: OK" << std::endl; return 0; } EOF if [ -e "$name" ] then echo_eval rm $name fi echo_eval g++ \ $name.cpp \ -I$HOME/prefix/eigen/include \ -g \ -O0 \ -std=c++11 \ -o $name echo_eval ./$name cppad-20160000.1/bug/std_vector.sh0000755000175200017650000000255412656321776015734 0ustar coincoin-web#! /bin/bash -e # $Id: std_vector.sh 2935 2013-10-12 19:40:01Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- # Using g++ 4.8.1 results in the following error message: # # std_vector.cpp:8:7: error: no match for ‘operator|=’ (operand types are # ‘std::vector::reference {aka std::_Bit_reference}’ and ‘bool’) # y[1] |= true; # ^ # ----------------------------------------------------------------------------- if [ ! -e build ] then mkdir build fi cd build echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` cat << EOF > $name.cpp # include int main(void) { int N = 1; std::vector y(N); for(int i = 0; i < N; i++ ) y[i] = false; y[0] = y[0] | true; y[1] |= true; return 0; } EOF echo "g++ -g $name.cpp -o $name" g++ -g $name.cpp -o $name # echo "./$name" ./$name # echo "rm $name $name.cpp" rm $name $name.cpp cppad-20160000.1/bug/sparsity.sh0000755000175200017650000000500712656321777015433 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- gigabytes='1.0' # memory limit in gigabytes # ----------------------------------------------------------------------------- kilobytes=`echo "($gigabytes * 10^9) / 1024" | bc` ulimit -Sv $kilobytes cat << EOF This is testing the idea that vector< std::set > sparsity; is inefficient compared to vector row, col; The results on one system for this script are: ./sparsity set 1e7 elapsed_seconds = 3.62206 ./sparsity set 2e7 std::bad_alloc ./sparsity vec 2e7 elapsed_seconds = 1.34243 ./sparsity vec 4e7 std::bad_alloc EOF cat << EOF > bug.$$ # include int main(int argc, char *argv[]) { using CppAD::elapsed_seconds; if( argc != 3 ) { std::cerr << "usage: $0 (set|vec) n" << std::endl; return 1; } bool set = std::strcmp(argv[1], "set") == 0; bool vec = std::strcmp(argv[1], "vec") == 0; bool ok = vec || set; if( ! ok ) { std::cerr << "usage: $0 (set|vec) n" << std::endl; return 1; } size_t n = size_t( std::atof( argv[2] ) ); const char* label; elapsed_seconds(); try { if( set ) { std::vector< std::set > my_set(n); for(size_t i = 0; i < n; i++) my_set[i].insert(i); } else { std::vector row; std::vector col; for(size_t i = 0; i < n; i++) { row.push_back(i); col.push_back(i); } } for(int i = 0; i < argc; i++) std::cout << argv[i] << " "; std::cout << "elapsed_seconds = " << elapsed_seconds() << std::endl; } catch( std::bad_alloc& ba ) { for(int i = 0; i < argc; i++) std::cout << argv[i] << " "; std::cout << ba.what() << std::endl; } return 0; } EOF # ----------------------------------------------------------------------------- if [ ! -e build ] then mkdir build fi cd build echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` mv ../bug.$$ $name.cpp echo "g++ -I../.. -DNDEBUG --std=c++11 $name.cpp -o $name" g++ -I../.. -DNDEBUG --std=c++11 $name.cpp -o $name # ./$name set 1e7 ./$name set 2e7 ./$name vec 2e7 ./$name vec 4e7 cppad-20160000.1/bug/gcc_complex.sh0000755000175200017650000000322512656321777016040 0ustar coincoin-web#! /bin/bash -e # $Id: gcc_complex.sh 2886 2013-08-06 15:54:58Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- echo_eval() { echo $* eval $* } # ----------------------------------------------- echo "create gcc_complex.cpp" cat << EOF > gcc_complex.cpp # include # include # include int main(void) { double inf = std::numeric_limits::infinity(); std::complex c_inf( inf ); std::complex c_1( 1. ); std::cout << "c_inf = " << c_inf << std::endl; std::cout << "c_1 = " << c_1 << std::endl; std::cout << "c_inf / c1 = " << c_inf / c_1 << std::endl; return 0; } EOF echo_eval g++ gcc_complex.cpp -o gcc_complex echo_eval ./gcc_complex cat << EOF Explination: (x + i*y) (x + i*y) * (a - i*b) (x*a - y*b) + i*(y*a - x*b) --------- = --------------------- = --------------------------- (a + i*b) (a + i*b) * (a - i*b) a*a + b*b In our case x = inf, y = 0, a = 1, b = 0, so we have (x + i*y) (inf*1 - 0*0) + i*(0*1 - inf*0) --------- = ------------------------------ = inf - i*nan (a + i*b) 1*1 + 0*0 EOF echo_eval rm gcc_complex.cpp gcc_complex cppad-20160000.1/bug/boost_lu.sh0000755000175200017650000001117012656321777015401 0ustar coincoin-web#! /bin/bash -e # $Id$ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- cat << EOF This test results in a very long error message with boost-1.55.0 and gcc-4.9.2. Here is the gist of the message: /usr/include/boost/numeric/ublas/detail/matrix_assign.hpp:33:35: error: no match for ‘operator<’ ... snip ... return norm_inf (e1 - e2) < epsilon * ^ The folowing change to /usr/include/boost/numeric/ublas/detail/matrix_assign.hpp seems to fix the problem: Old Text: return norm_inf (e1 - e2) < epsilon * std::max (std::max (norm_inf (e1), norm_inf (e2)), min_norm); New Text: S norm_1 = norm_inf(e1); S norm_2 = norm_inf(e2); S norm_diff = norm_inf(e1 - e2); return norm_diff < epsilon * std::max( std::max(norm_1, norm_2) , min_norm ); EOF cat << EOF > bug.$$ #include # define NUMERIC_LIMITS_FUN(name) \ static CppAD::AD name(void) \ { return static_cast< CppAD::AD > ( \ std::numeric_limits::name() \ ); \ } # define NUMERIC_LIMITS_BOOL(name) \ static const bool name = \ std::numeric_limits::name; # define NUMERIC_LIMITS_INT(name) \ static const int name = \ std::numeric_limits::name; namespace std { /// Specialization of numeric_limits< CppAD::AD > template <> class numeric_limits< CppAD::AD > { public: // has_denorm static const float_denorm_style has_denorm = std::numeric_limits::has_denorm; // round_style static const float_round_style round_style = std::numeric_limits::round_style; // bool NUMERIC_LIMITS_BOOL(is_specialized); NUMERIC_LIMITS_BOOL(is_signed); NUMERIC_LIMITS_BOOL(is_integer); NUMERIC_LIMITS_BOOL(is_exact); NUMERIC_LIMITS_BOOL(has_infinity); NUMERIC_LIMITS_BOOL(has_quiet_NaN); NUMERIC_LIMITS_BOOL(has_signaling_NaN); NUMERIC_LIMITS_BOOL(has_denorm_loss); NUMERIC_LIMITS_BOOL(is_iec559); NUMERIC_LIMITS_BOOL(is_bounded); NUMERIC_LIMITS_BOOL(is_modulo); NUMERIC_LIMITS_BOOL(traps); NUMERIC_LIMITS_BOOL(tinyness_before); // int NUMERIC_LIMITS_INT(digits); NUMERIC_LIMITS_INT(digits10); NUMERIC_LIMITS_INT(radix); NUMERIC_LIMITS_INT(min_exponent); NUMERIC_LIMITS_INT(min_exponent10); NUMERIC_LIMITS_INT(max_exponent); NUMERIC_LIMITS_INT(max_exponent10); /// functions NUMERIC_LIMITS_FUN( epsilon) NUMERIC_LIMITS_FUN( min ) NUMERIC_LIMITS_FUN( max ) }; } #include int main() { typedef CppAD::AD T; boost::numeric::ublas::matrix a(5,5); boost::numeric::ublas::permutation_matrix pert(5); // lu decomposition const std::size_t s = lu_factorize(a, pert); return 0; } EOF # ----------------------------------------------------------------------------- if [ ! -e build ] then mkdir build fi cd build echo "$0" name=`echo $0 | sed -e 's|.*/||' -e 's|\..*||'` mv ../bug.$$ $name.cpp echo "g++ -I../.. --std=c++11 -g $name.cpp -o $name >& $name.log" if ! g++ -I../.. --std=c++11 -g $name.cpp -o $name >& $name.log then cat << EOF > $name.sed s|\\[|&\\n|g s|\\]|&\\n|g s|[‘{}]|&\\n|g s|[a-zA-Z0-9_]* *=|\\n&|g # s|boost::numeric::ublas::||g s|/usr/include/boost/numeric/ublas/||g # s|CppAD::AD *|AD|g s|, basic_unit_lower<> >||g s|, basic_upper<> >||g s|scalar_minus|scalar_minus_AD|g s|triangular_adaptor<\\([^<>]*\\)>|triangular_\\1|g s|triangular_matrix_AD_ulower|AD_ulower|g s|triangular_matrix_AD_upper|AD_upper|g s|matrix_matrix_prod *|AD_prod_ulower_upper|g s| *||g s|matrix_matrix_binary|AD_prod_ulower_upper|g EOF echo "sed -f $name.sed $name.log > ../$name.log" sed -f $name.sed $name.log > ../$name.log echo "$name.sh: Compliation Error: see $name.log" exit 1 fi # echo "./$name" if ! ./$name then echo echo "$name.sh: Execution Error" exit 1 fi echo echo "$name.sh: OK" exit 0 cppad-20160000.1/bug/cmake_target.sh0000755000175200017650000000275612656321777016213 0ustar coincoin-web#! /bin/bash -e # $Id: cmake_target.sh 3090 2014-01-31 11:31:54Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell # # CppAD is distributed under multiple licenses. This distribution is under # the terms of the # GNU General Public License Version 3. # # A copy of this license is included in the COPYING file of this distribution. # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. # ----------------------------------------------------------------------------- #! /bin/bash -e echo 'This script does not work properly on el6; see' echo 'https://bugzilla.redhat.com/show_bug.cgi?id=896116' echo # if [ -e build ] then rm -r build fi mkdir build cd build cat << EOF > hello_one.cpp # include int main(void) { std::cout << "hello_one" << std::endl << std::endl; return 0; } EOF cat << EOF > hello_two.cpp # include int main(void) { std::cout << "hello_two" << std::endl << std::endl; return 0; } EOF cat << EOF > CMakeLists.txt CMAKE_MINIMUM_REQUIRED(VERSION 2.6) # PROJECT(hello) # ADD_EXECUTABLE(hello_one EXCLUDE_FROM_ALL hello_one.cpp ) ADD_EXECUTABLE(hello_two EXCLUDE_FROM_ALL hello_two.cpp ) # ADD_CUSTOM_TARGET(check_one hello_one DEPENDS hello_one) ADD_CUSTOM_TARGET(check_two hello_two DEPENDS hello_two) # ADD_CUSTOM_TARGET(check DEPENDS check_one check_two) EOF # uname -a cmake --version cmake . make check cppad-20160000.1/install-sh0000755000175200017650000003452312561675772014454 0ustar coincoin-web#!/bin/sh # install - install a program, script, or datafile scriptversion=2013-12-25.23; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: cppad-20160000.1/gpl-3.0.txt0000644000175200017650000010451312656321777014264 0ustar coincoin-web 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 . cppad-20160000.1/doc.omh0000644000175200017650000001677212656321777013726 0ustar coincoin-web$Id: doc.omh 3786 2016-02-08 13:14:26Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell CppAD is distributed under multiple licenses. This distribution is under the terms of the GNU General Public License Version 3. A copy of this license is included in the COPYING file of this distribution. Please visit http://www.coin-or.org/CppAD/ for information on other licenses. -------------------------------------------------------------------------- */ $begin CppAD$$ $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 %$$ $comment ------------------------------------------------------------- default automatic indexing command for all CppAD documentaiton $$ $aindex section head subhead$$ $comment ------------------------------------------------------------- Latex used throughout the CppAD documentation $$ $latex \newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} } $$ $comment ------------------------------------------------------------- hilite commands used throughout the CppAD documentation $$ $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 $$ , $comment bin/version assumes that : follows cppad version number here$$ $section cppad-20160000.1: A Package for Differentiation of C++ Algorithms $$ $mindex AD algorithmic differentiation automatic C++ algorithm derivative CppAD version cppad.hpp$$ $comment This comment is used to remove the table below$$ $table $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%$$ $tend $head Syntax$$ $code # include $$ $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 $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. Arbitrary order $xref/Forward//forward/$$ and $xref/Reverse//reverse/$$ mode derivative calculations can be preformed on the operation sequence. Logical comparisons can be included in an operation sequence using AD $xref/CondExp//conditional expressions/$$. Evaluation of user defined unary $xref/Discrete//discrete functions/$$ can also be included in the sequence of operations; 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). $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/$$. $lnext 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%$$, and $href%http://trilinos.sandia.gov/packages/sacado/%Sacado%$$ are included. $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 Example$$ The file $xref/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/local/user_ad.hpp% cppad/local/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 %$$ $end cppad-20160000.1/doc/0002755000175200017650000000000012656322034013171 5ustar coincoin-webcppad-20160000.1/doc/_external.xml0000644000175200017650000005552112656322012015676 0ustar coincoin-web External Internet References
Prev Next _external Headings

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.orgauto_tools#eigen_dir
http://eigen.tuxfamily.orgcppad_eigen.hpp#Purpose
http://eigen.tuxfamily.orgwhats_new_13#04-28
http://eigen.tuxfamily.orgwhats_new_12#06-16
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/mailman/listinfo/cppadFaq#Bugs
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://opensource.org/licenses/EPL-1.0download#Subversion.Limitations
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#Subversion.Limitations
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/auto_tools#sacado_dir
http://trilinos.sandia.gov/packages/sacado/speed#Purpose
http://trilinos.sandia.gov/packages/sacado/whats_new_07#10-22
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#Compressed Archives.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
http://www.coin-or.org/download/source/CppAD/download#Compressed Archives.Release Versions
http://www.coin-or.org/download/source/CppAD/download#Compressed Archives.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/download/source/CppAD/cppad-20160000.1.epl.tgzdownload#Compressed Archives
http://www.coin-or.org/download/source/CppAD/cppad-20160000.1.gpl.tgzdownload#Compressed Archives
http://www.coin-or.org/foundation.htmlCppAD#Introduction
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.xmlauto_tools#ipopt_dir
http://www.coin-or.org/projects/Ipopt.xmlipopt_solve#Purpose
http://www.coin-or.org/projects/Ipopt.xmlcppad_ipopt_nlp#Purpose
http://www.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/auto_tools#fadbad_dir
http://www.fadbad.com/speed#Purpose
http://www.microsoft.com/en-us/download/confirmation.aspx?id=44914download#Compressed Archives.Windows File Extraction and Testing
http://www.mingw.orgwhats_new_03#12-22
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/omhelp/download#Subversion.Install Instructions
http://www.seanet.com/~bradbell/pycppad/pycppad.htmaddon#Name
http://www.winzip.comwhats_new_04#09-02
https://github.com/bradbell/cppaddownload#Compressed Archives.Current Version
https://github.com/joaoleal/CppADCodeGen/addon#Name
https://github.com/kaskr/adcompwhats_new_15#03-06
https://github.com/kaskr/adcompaddon#Name
https://projects.coin-or.org/ADOL-CCppAD#Introduction
https://projects.coin-or.org/ADOL-Cadolc_prefix#Purpose
https://projects.coin-or.org/ADOL-Cget_adolc.sh#Purpose
https://projects.coin-or.org/ADOL-Cauto_tools#adolc_dir
https://projects.coin-or.org/ADOL-Cspeed#Purpose
https://projects.coin-or.org/ADOL-Cwhats_new_13#10-14
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/CppAD/browser/releasesdownload#Subversion.Release Versions
https://projects.coin-or.org/CppAD/browser/stabledownload#Subversion.Stable Versions
https://projects.coin-or.org/CppAD/browser/trunkdownload#Compressed Archives.Current Version
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
cppad-20160000.1/doc/_search.xml.js0000644000175200017650000021653212656322004015736 0ustar coincoin-web// ------------------------------------------------------------ // Copyright (C) Bradley M. Bell 1998-2015, All rights reserved // ------------------------------------------------------------ Keyword = [ 'CppAD cppad-20160000.1: 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 ', 'download Download The CppAD Source Code ',' purpose distribution directory compressed archives current version release versions monthly unix file extraction windows testing install instructions subversion limitations stable ', '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 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 cppad_profile_flag eigen fadbad cppad_testvector cppad_max_num_threads cppad_sparse_list cppad_tape_id_type cstdint cppad_tape_addr_type 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 Using ColPack: Example and Test ',' jacobian sparse ', 'colpack_hes.cpp Using ColPack: Example and Test ',' hessian sparse ', '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 ', 'pkgconfig CppAD pkg-config Files ',' pc purpose usage defined fields configuration ', 'auto_tools Auto Tools Unix Test and Installation ',' speed profile prefix std vector boost eigen sparse internal sets implicit explicit compile flags openmp postfix adolc fadbad ipopt sacado memory usage tape deprecated 2012-12-26 distribution directory work configure make examples tests profiling cppad prefix_dir --with-documentation --with-testvector --with-sparse_option --with-deprecated 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 ', 'Introduction An Introduction by Example to Algorithmic Differentiation ',' ad automatic purpose preface forward mode reverse operation count efficiency outline reference ', 'get_started.cpp Getting Started Using CppAD to Compute Derivatives ',' simple example purpose function value poly exercises program output running ', '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_main.cpp Correctness Tests For Exponential Approximation in Introduction ',' run running ', 'AD AD Objects ',' require purpose base type requirements ', 'ad_ctor AD Constructors ',' convert base vecad syntax purpose implicit explicit deprecated 2013-12-31 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 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 Computed 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 ', 'compute_assign AD Computed 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 Computed Assignment Addition: Example and Test ',' += plus ', 'sub_eq.cpp AD Computed Assignment Subtraction: Example and Test ',' -= plus add ', 'mul_eq.cpp AD Computed Assignment Multiplication: Example and Test ',' *= multiply plus add ', 'div_eq.cpp AD Computed 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 ', 'abs.cpp AD Absolute Value Function: Example and Test ',' fabs ', '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 ',' condexp 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 example ', 'num_limits.cpp Numeric Limits: Example and Test ',' ', 'atomic Atomic AD Functions ',' operation ', 'checkpoint Checkpointing Functions ',' syntax purpose reduce memory faster recording method constructor base advector name ay sparsity size_var option algo atom_fun clear restriction example ', 'checkpoint.cpp Simple Checkpointing: Example and Test ',' purpose ', '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 examples 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 define use ', 'atomic_reverse Atomic Reverse Mode ',' syntax purpose implementation q tx ty f g h py px ok examples define use ', 'atomic_for_sparse_jac Atomic Forward Jacobian Sparsity Patterns ',' syntax purpose implementation q ok examples define use ', 'atomic_rev_sparse_jac Atomic Reverse Jacobian Sparsity Patterns ',' syntax purpose implementation q rt st ok examples define use ', 'atomic_rev_sparse_hes Atomic Reverse Hessian Sparsity Patterns ',' syntax purpose implementation vx q examples define use ', 'atomic_base_clear Free Static Variables ',' syntax purpose future use restriction ', '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_sparsity.cpp Atomic Sparsity Patterns: Example and Test ',' function pack_sparsity_enum start class definition constructor forward for_sparse_jac rev_sparse_jac rev_sparse_hes end use recording forsparse_jac ', '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_hes_sparse.cpp Atomic Operation Hessian Sparsity: Example and Test ',' purpose start class definition constructor forward for_sparse_jac rev_sparse_hes use function with x_1 both variable parameter ', 'atomic_mat_mul.cpp User Atomic Matrix Multiply: Example and Test ',' class definition function constructor recording forward reverse option for_sparse_jac rev_sparse_jac rev_sparse_hes ', 'atomic_matrix_mul.hpp Matrix Multiply as an Atomic Operation ',' start class definition constructor left operand element index right result forward multipliy 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_example Example AD Base Types That are not AD ',' ', 'base_alloc.hpp Example AD Where Base Constructor Allocates Memory ',' purpose include file computed 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 ', '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 ', '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 ', '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 ', 'FunEval Evaluate ADFun Functions, Derivatives, and Sparsity Patterns ',' ', 'Forward Forward Mode ',' ', '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 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 Reverse Mode ',' multiple directions ', '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_any.cpp Reverse Mode General Case: Example and Test ',' purpose processing steps ', 'Sparse Calculating Sparsity Patterns ',' ', '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 ', '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 ', 'dependency.cpp Computing Dependency: Example and Test ',' discussion pattern ', '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 ', 'bool_sparsity.cpp Using vectorBool Sparsity To Conserve Memory: Example and Test ',' purpose ', 'Drivers First and Second Derivatives: Easy Drivers ',' forward reverse ', 'Jacobian Jacobian: Driver Routine ',' first derivative syntax purpose vector forward reverse example ', 'jacobian.cpp Jacobian: 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 ',' ', '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 ',' heslagrangian ', '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 ',' ', 'sparse_jacobian Sparse Jacobian: Easy Driver ',' sparsejacobian 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 ',' spare ', 'sparse_hessian Sparse Hessian: Easy Driver ',' sparsehessian syntax purpose f w row col work color_method n_sweep vectorbase vectorset restrictions vectorsize uses forward example subset ', 'sparse_hessian.cpp Sparse Hessian: Example and Test ',' spare ', 'sub_sparse_hes.cpp Computing Sparse Hessian for a Subset of Variables ',' purpose see also function example ', 'sparse_sub_hes.cpp Sparse Hessian on Subset of Variables: Example and Test ',' purpose see also ', '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 ', 'optimize Optimize an ADFun Object Tape ',' sequence operations speed memory ndebug syntax purpose improvements testing efficiency atomic functions rev_sparse_jac nan checking optimization example ', 'optimize.cpp ADFun Operation Sequence Optimization: Example and Test ',' ', '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_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 ',' openmp pthread bthread syntax running purpose 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-Threaded Implementation of Summation of 1/i ',' multi_thread syntax ok num_sum num_threads source ', 'harmonic_time.cpp Timing Test of Multi-Threaded Summation of 1/i ',' multi_thread speed syntax purpose ok time_out test_time num_threads mega_sum source ', 'harmonic_work.cpp Multi-threading Sum of 1/i Utility Routines ',' setup worker combine syntax purpose harmonic_setup num_sum num_threads harmonic_worker harmonic_combine source ', 'multi_newton.cpp A Multi-Threaded Newton\'s Method ',' threading multi-threading syntax purpose ok xout fun num_sub xlow xup epsilon max_itr num_threads source ', 'multi_newton_time.cpp Timing Test of Multi-Threaded Newton Method ',' multi_thread speed syntax purpose ok time_out test_time num_threads num_zero num_sub num_sum use_ad source ', 'multi_newton_work.cpp Multi-threading Newton Method Utility Routines ',' setup worker combine syntax purpose multi_newton_setup fun num_sub xlow xup epsilon max_itr num_threads multi_newton_worker multi_newton_combine xout 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 simple vector template class multi-threading memory allocation sorting indices to_string ', '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 ',' ', '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 ',' ', '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 running the cppad test vector template class ', 'General General Examples ',' realistic description ', 'ExampleUtility Utility Routines used by CppAD Examples ',' ', 'ListAllExamples List of All the 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 ', 'example.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 introduction cppad::vector std::vector boost::numeric::ublas::vector eigen vectors ', 'speed Speed Test an Operator Overloading AD Package ',' purpose ', 'speed_main Running the Speed Test Program ',' cppad uniform_01 syntax purpose package double profile correct seed option_list onetape optimize atomic memory sparsity options boolsparsity 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 ',' operator reporting errorhandler avoid record taping mode cppad_testvector standard math function storage assignment independent bugs comparechange complex types exceptions variables matrix inverse mode: forward reverse namespace preprocessor symbol using speed ndebug optimize memory allocation tape storage: disk ', '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 sparsity pattern 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 ',' base requirements printfor optimization checkpoint machine epsilon examples adolc optimizing nested conditional expressions forward mode recomputation iterator interface compilation speed operation sequence comparison changes software guidelines tracing atan2 benderquad ', 'whats_new Changes and Additions to CppAD ',' introduction this year previous years ', 'whats_new_15 CppAD Changes and Additions During 2015 ',' introduction 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 ',' ', 'include_deprecated Deprecated Include Files ',' 2015-11-30 2006-12-17 linking new to commands ', '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 ',' ', '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'; } cppad-20160000.1/doc/_image.gif0000644000175200017650000000210612656321777015113 0ustar coincoin-webGIF89a."÷€€€€€€€€€ÀÀÀÀÜÀ¦ÊðÿÿÌÌ™fÿf3Bš§7<™ÿ33f€ÿfÌ™f™fÌ"""ÌÌÿ™™ÿffÌ3ÿ™3f™Ì3333f3™3Ì3ÿff3fff™fÌfÿ™™3™f™™™ÌÌÌ3ÌfÌ™ÌÌÌÿÿ3ÿfÿ™ÿÌ3333f3™3Ì3ÿ3333333™33Ì33ÿ3f3f33ff3f™3fÌ3fÿ3™3™33™f3™™3™Ì3™ÿ3Ì3Ì33Ìf3Ì™3ÌÌ3Ìÿ3ÿ3ÿ33ÿf3ÿÌ3ÿÿff3fff™fÌfÿf3f33f3ff3™f3Ìf3ÿffff3fffff™ffÿf™f™3f™ff™™f™Ìf™ÿfÌfÌ3fÌffÌ™fÌÌfÌÿfÿfÿ3fÿffÿ™fÿÌfÿÿ™™3™™™Ì™ÿ™3™33™3f™3™™3Ì™3ÿ™f™f3™ff™f™™fÿ™™™™3™™f™™™™™Ì™Ì™Ì3™Ìf™Ì™™ÌÌ™Ìÿ™ÿ™ÿ3™ÿf™ÿ™™ÿÌ™ÿÿÌÌ3ÌfÌ™ÌÌÌÿÌ3Ì33Ì3fÌ3™Ì3ÌÌ3ÿÌfÌf3ÌffÌf™ÌfÌÌfÿ̙̙3Ì™™Ì™ÌÌ™ÿÌÌÌÌ3ÌÌfÌÌ™ÌÿÌÿ3ÌÿfÌÿ™ÌÿÌÌÿÿÿ3ÿfÿ™ÿÌÿ3ÿ33ÿ3fÿ3™ÿ3Ìÿ3ÿÿfÿffÿf™ÿfÿÿ™ÿ™3ÿ™fÿ™™ÿ™Ìÿ™ÿÿÌÿÌ3ÿÌfÿÌ™ÿÌÌÿÌÿÿÿ3ÿÿfÿÿ™æ“¦ä·šä¼¤ÛžÁεÉä˜ÀâµÆÖÅ›×Å´æÉ“éɰùèÌÌÌÍÊÒÏÒåÛâÝÜáîñÙÇäÚäõäÔüüûHy%Èù¨¶ÀÿÿÌÿûð  ¤€€€ÿÿÿÿÿÿÿÿÿÿÿÿ,."þH° Áƒ*\HÐÂJ\èð‚Å !NÜhЂ AfŒÈ±¤G BbY’ãÉ RŠ|H²%×+c†|ÁæÍVž”‰bOŸqz\º2$ÄšHž„¸´jS§P‘NZu)„*³ú,Z¡«Y*À„p4ê@FV‹ÂeêÀFn;29÷%Û¼zO‚Äg•­Ø¼q1ôýøpÁ¸wã^8ì¶pd¦“)ûlР*ÛË'/0jà>;{\°€i ø˜– Ø4jøX³f°`6gÔœ9;N¼¸q›&?Žp¹@çÌ B‡}àtë–gOž;õÛ·,?·~@ûxçß%^/OÞ<ûðé®GϾ>w·óÛO¾åúòÝÙ·ŸxÕ¹;cppad-20160000.1/doc/install.xml0000644000175200017650000001104012656322004015350 0ustar coincoin-web 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
auto_toolsAuto Tools Unix Test and Installation

Input File: omh/install/install.omh cppad-20160000.1/doc/download.xml0000644000175200017650000005157612656322004015533 0ustar coincoin-web 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 instruction below as the distribution directory. To be specific, the distribution directory contains the file cppad/cppad.hpp.

Compressed Archives
These files have been archived using tar and compressed using gzip:
version    license    link
current EPL cppad-20160000.1.epl.tgz
current GPL cppad-20160000.1.gpl.tgz
old Both CppAD download page

Current Version
The current versions listed above correspond to the subversion trunk and the git master . These tarballs only last for a few days.

Release Versions
Release versions of the compressed tar files are available on the CppAD download page . This includes all the releases going back to 2007. These file have the form
     cppad-
yyyymmdd.rel.lic.tgz
The license code lic is gpl, epl or cpl where gpl denotes the GNU General Public License, epl denotes the Eclipse Public License, and cpl denotes the Common Public License (not being used for new versions). The version number yyyymmdd is the date at which the features of the program were frozen where yyyy is the year, mm is the month, and dd is the day. The release number rel corresponds to a bug fix index where higher numbers corresponding to more bug fixes.

Monthly Versions
Monthly versions of the compressed tar files are available on the CppAD 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
where the license code lic is gpl or epl and yyyy is the current year.

Unix File Extraction
On unix, you can use the command
     tar -xvzf cppad-
version.lic.tgz
where version either refers to the current version, or one of the release versions. This will decompress and extract the CppAD into the distribution directory cppad-version . To see if this has been done correctly, check for the following file:
     cppad-
version/cppad/cppad.hpp

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 tarball:
         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 instructions on the web correspond to the current version of CppAD. If you are using an old version of CppAD You should follow the install instructions in the doc subdirectory of the distribution directory.

Subversion

Limitations
This download procedure has the following limitations:
  1. The subversion program must be installed on your system.
  2. No documentation is included by this download procedure, though it can be build from the source code; see install instructions below.
  3. Only the EPL licensed version of CppAD can be obtained by this download procedure (some old versions correspond to CPL instead of EPL).


Current Version
To obtain current version of CppAD, execute the following commands
     svn export https://projects.coin-or.org/svn/CppAD/trunk 
dir
To see if this has been done correctly, check for the following file:
     
dir/cppad/cppad.hpp
We refer to your directory choice dir above as the distribution directory.

Stable Versions
Subversion downloads are available for a set of stable versions (after the specified date, only bug fixes get applied). The following link will list the available dir values corresponding to stable versions . The following command will download a stable version of the CppAD source code:
     svn export https://projects.coin-or.org/svn/CppAD/stable/
dir dir
To see if this has been done correctly, check for the following file:
     
dir/cppad/cppad.hpp
Note that it will correspond to the most recent release for this stable version.

Release Versions
Subversion downloads are available for a set of release versions (no changes are applied). The following link will list the available dir values corresponding to release versions . The following command will download a release version of the CppAD source code:
     svn export https://projects.coin-or.org/svn/CppAD/releases/
dir dir
To see if this has been done correctly, check for the following file:
     
dir/cppad/cppad.hpp

Install Instructions
If you are using subversion to download an old version of CppAD, you will have to 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:
     ./build.sh omhelp
You will then be able to follow the install instructions in the doc subdirectory of the distribution directory.
Input File: omh/install/download.omh cppad-20160000.1/doc/cmake.xml0000644000175200017650000010435212656322004014773 0ustar coincoin-web 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_sparse_list=
cppad_sparse_list                                 \
    -D cppad_tape_id_type=
cppad_tape_id_type                               \
    -D cppad_tape_addr_type=
cppad_tape_addr_type                           \
    -D cppad_deprecated=
cppad_deprecated \
    \
    ..

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, besides the debug and release 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).

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_sparse_list
There are two possible values for this option, YES and NO. This affect the internal data structure used to store a sparsity pattern when the users version of the sparsity pattern is a vector of std::set<size_t>. If cppad_sparse_list is NO the vectors of standard sets are also used internally. If cppad_sparse_list is YES, a special sparse list structure is used instead. This should affect the speed and memory required by the sparse_jacobian , sparse_hessian , and sparse drivers The default value for cppad_sparse_list is YES

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_par , size_par .

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_deprecated
The default value for cppad_deprecated is NO. If it is YES, then all the CppAD deprecated features are included in the installation . Otherwise, some of the deprecated features may be excluded from the installation. (The intention here is to exclude more deprecated features as time marches on.)
Input File: omh/install/cmake.omh cppad-20160000.1/doc/get_adolc.sh.xml0000644000175200017650000001137412656322004016246 0ustar coincoin-web 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 cppad-20160000.1/doc/colpack_prefix.xml0000644000175200017650000001416312656322004016704 0ustar coincoin-web 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 cppad-20160000.1/doc/colpack_jac.cpp.xml0000644000175200017650000001174512656322004016730 0ustar coincoin-web Using ColPack: Example and Test
Prev Next colpack_jac.cpp Headings

Using ColPack: Example and Test
 

# include <cppad/cppad.hpp>
bool colpack_jac(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;
	typedef CPPAD_TESTVECTOR(AD<double>) a_vector;
	typedef CPPAD_TESTVECTOR(double)     d_vector;
	typedef CppAD::vector<size_t>        i_vector;
	size_t i, j, k, ell;
	double eps = 10. * CppAD::numeric_limits<double>::epsilon();

	// domain space vector
	size_t n = 4;
	a_vector  a_x(n);
	for(j = 0; j < n; j++)
		a_x[j] = AD<double> (0);

	// declare independent variables and starting recording
	CppAD::Independent(a_x);

	size_t m = 3;
	a_vector  a_y(m);
	a_y[0] = a_x[0] + a_x[1];
	a_y[1] = a_x[2] + a_x[3];
	a_y[2] = a_x[0] + a_x[1] + a_x[2] + a_x[3] * a_x[3] / 2.;

	// create f: x -> y and stop tape recording
	CppAD::ADFun<double> f(a_x, a_y);

	// new value for the independent variable vector
	d_vector x(n);
	for(j = 0; j < n; j++)
		x[j] = double(j);

	/*
	      [ 1 1 0 0  ]
	jac = [ 0 0 1 1  ]
	      [ 1 1 1 x_3]
	*/
	d_vector check(m * n);
	check[0] = 1.; check[1] = 1.; check[2]  = 0.; check[3]  = 0.;
	check[4] = 0.; check[5] = 0.; check[6]  = 1.; check[7]  = 1.;
	check[8] = 1.; check[9] = 1.; check[10] = 1.; check[11] = x[3];

	// Normally one would use f.ForSparseJac or f.RevSparseJac to compute
	// sparsity pattern, but for this example we extract it from check.
	std::vector< std::set<size_t> >  p(m);

	// using row and column indices to compute non-zero in rows 1 and 2
	i_vector row, col;
	for(i = 0; i < m; i++)
	{	for(j = 0; j < n; j++)
		{	ell = i * n + j;
			if( check[ell] != 0. )
			{	row.push_back(i);
				col.push_back(j);
				p[i].insert(j);
			}
		}
	}
	size_t K = row.size();
	d_vector jac(K);

	// empty work structure
	CppAD::sparse_jacobian_work work;
	ok &= work.color_method == "cppad";

	// choose to use ColPack
	work.color_method = "colpack";

	// forward mode
	size_t n_sweep = f.SparseJacobianForward(x, p, row, col, jac, work);
	for(k = 0; k < K; k++)
	{	ell = row[k] * n + col[k];
		ok &= NearEqual(check[ell], jac[k], eps, eps);
	}
	ok &= n_sweep == 4;

	// reverse mode
	work.clear();
	work.color_method = "colpack";
	n_sweep = f.SparseJacobianReverse(x, p, row, col, jac, work);
	for(k = 0; k < K; k++)
	{	ell = row[k] * n + col[k];
		ok &= NearEqual(check[ell], jac[k], eps, eps);
	}
	ok &= n_sweep == 2;

	return ok;
}

Input File: example/colpack_jac.cpp cppad-20160000.1/doc/colpack_hes.cpp.xml0000644000175200017650000001327212656322004016747 0ustar coincoin-web Using ColPack: Example and Test
Prev Next colpack_hes.cpp Headings

Using ColPack: Example and Test
 

# include <cppad/cppad.hpp>
bool colpack_hes(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;
	typedef CPPAD_TESTVECTOR(AD<double>) a_vector;
	typedef CPPAD_TESTVECTOR(double)     d_vector;
	typedef CppAD::vector<size_t>        i_vector;
	size_t i, j, k, ell;
	double eps = 10. * CppAD::numeric_limits<double>::epsilon();

	// domain space vector
	size_t n = 5;
	a_vector  a_x(n);
	for(j = 0; j < n; j++)
		a_x[j] = AD<double> (0);

	// declare independent variables and starting recording
	CppAD::Independent(a_x);

	// colpack example case where hessian is a spear head
	// i.e, H(i, j) non zero implies i = 0, j = 0, or i = j
	AD<double> sum = 0.0;
	// partial_0 partial_j = x[j]
	// partial_j partial_j = x[0]
	for(j = 1; j < n; j++)
		sum += a_x[0] * a_x[j] * a_x[j] / 2.0;
	//
	// partial_i partial_i = 2 * x[i]
	for(i = 0; i < n; i++)
		sum += a_x[i] * a_x[i] * a_x[i] / 3.0;

	// declare dependent variables
	size_t m = 1;
	a_vector  a_y(m);
	a_y[0] = sum;

	// create f: x -> y and stop tape recording
	CppAD::ADFun<double> f(a_x, a_y);

	// new value for the independent variable vector
	d_vector x(n);
	for(j = 0; j < n; j++)
		x[j] = double(j + 1);

	/*
	      [ 2  2  3  4  5 ]
	hes = [ 2  5  0  0  0 ]
	      [ 3  0  7  0  0 ]
	      [ 4  0  0  9  0 ]
	      [ 5  0  0  0 11 ]
	*/
	d_vector check(n * n);
	for(i = 0; i < n; i++)
	{	for(j = 0; j < n; j++)
		{	size_t index = i * n + j;
			check[index] = 0.0;
			if( i == 0 && 1 <= j )
				check[index] += x[j];
			if( 1 <= i && j == 0 )
				check[index] += x[i];
			if( i == j )
			{	check[index] += 2.0 * x[i];
				if( i != 0 )
					check[index] += x[0];
			}
		}
	}
	// Normally one would use f.RevSparseHes to compute
	// sparsity pattern, but for this example we extract it from check.
	std::vector< std::set<size_t> >  p(n);
	i_vector row, col;
	for(i = 0; i < n; i++)
	{	for(j = 0; j < n; j++)
		{	ell = i * n + j;
			if( check[ell] != 0. )
			{	// insert this non-zero entry in sparsity pattern
				p[i].insert(j);

				// the Hessian is symmetric, so only upper lower triangle
				if( j <= i )
				{	row.push_back(i);
					col.push_back(j);
				}
			}
		}
	}
	size_t K = row.size();
	d_vector hes(K);

	// contrast and check results using both cppad and colpack
	CppAD::sparse_hessian_work work;
	for(size_t i_method = 0; i_method < 3; i_method++)
	{	// empty work structure
		ok &= work.color_method == "cppad.symmetric";
		if( i_method == 2 )
			work.color_method = "colpack.star";

		// compute Hessian
		d_vector w(m);
		w[0] = 1.0;
		size_t n_sweep = f.SparseHessian(x, w, p, row, col, hes, work);

		// check result
		for(k = 0; k < K; k++)
		{	ell = row[k] * n + col[k];
			ok &= NearEqual(check[ell], hes[k], eps, eps);
		}
		if( work.color_method != "cppad.general" )
			ok &= n_sweep == 2;
		else
			ok &= n_sweep == 5;
		//
		// check that clear resets color_method to cppad.symmetric
		work.clear();
		ok &= work.color_method == "cppad.symmetric";
	}

	return ok;
}

Input File: example/colpack_hes.cpp cppad-20160000.1/doc/get_colpack.sh.xml0000644000175200017650000001074712656322004016603 0ustar coincoin-web 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 cppad-20160000.1/doc/eigen_prefix.xml0000644000175200017650000001545012656322004016357 0ustar coincoin-web 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

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 cppad-20160000.1/doc/get_eigen.sh.xml0000644000175200017650000001055712656322004016255 0ustar coincoin-web 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 cppad-20160000.1/doc/fadbad_prefix.xml0000644000175200017650000001357312656322004016475 0ustar coincoin-web 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 cppad-20160000.1/doc/get_fadbad.sh.xml0000644000175200017650000000734412656322004016367 0ustar coincoin-web 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 cppad-20160000.1/doc/ipopt_prefix.xml0000644000175200017650000001335012656322004016420 0ustar coincoin-web 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 cppad-20160000.1/doc/get_ipopt.sh.xml0000644000175200017650000001060612656322004016314 0ustar coincoin-web 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 cppad-20160000.1/doc/sacado_prefix.xml0000644000175200017650000001363112656322004016521 0ustar coincoin-web 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 cppad-20160000.1/doc/get_sacado.sh.xml0000644000175200017650000001075112656322004016414 0ustar coincoin-web 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 cppad-20160000.1/doc/cppad_testvector.xml0000644000175200017650000001317012656322004017261 0ustar coincoin-web 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 cppad-20160000.1/doc/cmake_check.xml0000644000175200017650000001374212656322004016132 0ustar coincoin-web 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
It is possible to build and run the following subsets of the examples and tests:
Command Description
make check_compare_c Compare Speed of C and C++
make check_introduction the programs in the Introduction
make check_example most of the Example programs
make check_print_for the PrintFor command
make check_test_more correctness tests that are not examples
make check_multi_thread multi_thread tests (run correctness only)
make check_speed single threading speed tests (run correctness only)
make check_cppad_ipopt the cppad_ipopt_nlp speed and correctness tests

Input File: omh/install/cmake_check.omh cppad-20160000.1/doc/pkgconfig.xml0000644000175200017650000001766412656322004015673 0ustar coincoin-web 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 cppad-20160000.1/doc/_pkgconfig_xml.js0000644000175200017650000000303612656322004016512 0ustar coincoin-webvar 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', 'auto_tools.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]; } cppad-20160000.1/doc/introduction.xml0000644000175200017650000002070512656322004016433 0ustar coincoin-web 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_main.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
get_started.cppGetting Started Using CppAD to Compute Derivatives
exp_2Second Order Exponential Approximation
exp_epsAn Epsilon Accurate Exponential Approximation
exp_apx_main.cppCorrectness Tests For Exponential Approximation in Introduction

Input File: omh/introduction.omh cppad-20160000.1/doc/get_started.cpp.xml0000644000175200017650000003153412656322004017002 0ustar coincoin-web 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: introduction/get_started/get_started.cpp cppad-20160000.1/doc/exp_2.xml0000644000175200017650000003461512656322004014734 0ustar coincoin-web 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_apx/exp_2.hpp cppad-20160000.1/doc/_exp_2_xml.js0000644000175200017650000000345012656322004015560 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/exp_2.hpp.xml0000644000175200017650000000543412656322004015517 0ustar coincoin-web exp_2: Implementation
Prev Next exp_2.hpp Headings

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_apx/exp_2.omh cppad-20160000.1/doc/exp_2.cpp.xml0000644000175200017650000000520312656322004015504 0ustar coincoin-web exp_2: Test
Prev Next exp_2.cpp Headings

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_apx/exp_2.omh cppad-20160000.1/doc/exp_2_for0.xml0000644000175200017650000004152612656322004015661 0ustar coincoin-web 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_apx/exp_2.omh cppad-20160000.1/doc/exp_2_for0.cpp.xml0000644000175200017650000000611312656322004016433 0ustar coincoin-web exp_2: Verify Zero Order Forward Sweep
Prev Next exp_2_for0.cpp Headings

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_apx/exp_2_for0.cpp cppad-20160000.1/doc/exp_2_for1.cpp.xml0000644000175200017650000000642212656322004016437 0ustar coincoin-web exp_2: Verify First Order Forward Sweep
Prev Next exp_2_for1.cpp Headings

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_apx/exp_2_for1.cpp cppad-20160000.1/doc/exp_2_rev1.cpp.xml0000644000175200017650000000675712656322004016460 0ustar coincoin-web exp_2: Verify First Order Reverse Sweep
Prev Next exp_2_rev1.cpp Headings

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_apx/exp_2_rev1.cpp cppad-20160000.1/doc/exp_2_for2.cpp.xml0000644000175200017650000000646012656322004016442 0ustar coincoin-web exp_2: Verify Second Order Forward Sweep
Prev Next exp_2_for2.cpp Headings

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_apx/exp_2_for2.cpp cppad-20160000.1/doc/exp_2_rev2.cpp.xml0000644000175200017650000001075312656322004016450 0ustar coincoin-web exp_2: Verify Second Order Reverse Sweep
Prev Next exp_2_rev2.cpp Headings

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_apx/exp_2_rev2.cpp cppad-20160000.1/doc/exp_2_for1.xml0000644000175200017650000006100512656322004015654 0ustar coincoin-web 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_apx/exp_2.omh cppad-20160000.1/doc/exp_2_rev1.xml0000644000175200017650000006465612656322004015701 0ustar coincoin-web 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_apx/exp_2.omh cppad-20160000.1/doc/exp_2_for2.xml0000644000175200017650000006773512656322004015675 0ustar coincoin-web 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_apx/exp_2.omh cppad-20160000.1/doc/exp_2_rev2.xml0000644000175200017650000013423112656322004015665 0ustar coincoin-web 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_apx/exp_2.omh cppad-20160000.1/doc/exp_2_cppad.xml0000644000175200017650000002154512656322004016101 0ustar coincoin-web 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_apx/exp_2_cppad.cpp cppad-20160000.1/doc/exp_eps.xml0000644000175200017650000005005112656322004015352 0ustar coincoin-web 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_apx/exp_eps.hpp cppad-20160000.1/doc/exp_eps.hpp.xml0000644000175200017650000000614612656322004016146 0ustar coincoin-web exp_eps: Implementation
Prev Next exp_eps.hpp Headings

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_apx/exp_eps.omh cppad-20160000.1/doc/exp_eps.cpp.xml0000644000175200017650000000543712656322004016143 0ustar coincoin-web exp_eps: Test of exp_eps
Prev Next exp_eps.cpp Headings

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_apx/exp_eps.omh cppad-20160000.1/doc/exp_eps_for0.xml0000644000175200017650000004542212656322004016306 0ustar coincoin-web 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_apx/exp_eps.omh cppad-20160000.1/doc/exp_eps_for0.cpp.xml0000644000175200017650000000664712656322004017075 0ustar coincoin-web exp_eps: Verify Zero Order Forward Sweep
Prev Next exp_eps_for0.cpp Headings

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_apx/exp_eps_for0.cpp cppad-20160000.1/doc/exp_eps_for1.cpp.xml0000644000175200017650000000711312656322004017063 0ustar coincoin-web exp_eps: Verify First Order Forward Sweep
Prev Next exp_eps_for1.cpp Headings

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_apx/exp_eps_for1.cpp cppad-20160000.1/doc/exp_eps_rev1.cpp.xml0000644000175200017650000000761312656322004017076 0ustar coincoin-web exp_eps: Verify First Order Reverse Sweep
Prev Next exp_eps_rev1.cpp Headings

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_apx/exp_eps_rev1.cpp cppad-20160000.1/doc/exp_eps_for2.cpp.xml0000644000175200017650000000721112656322004017063 0ustar coincoin-web exp_eps: Verify Second Order Forward Sweep
Prev Next exp_eps_for2.cpp Headings

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_apx/exp_eps_for2.cpp cppad-20160000.1/doc/exp_eps_rev2.cpp.xml0000644000175200017650000001250012656322004017066 0ustar coincoin-web exp_eps: Verify Second Order Reverse Sweep
Prev Next exp_eps_rev2.cpp Headings

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_apx/exp_eps_rev2.cpp cppad-20160000.1/doc/exp_eps_for1.xml0000644000175200017650000007515012656322004016310 0ustar coincoin-web 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_apx/exp_eps.omh cppad-20160000.1/doc/exp_eps_rev1.xml0000644000175200017650000012114312656322004016310 0ustar coincoin-web 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_apx/exp_eps.omh cppad-20160000.1/doc/exp_eps_for2.xml0000644000175200017650000010361112656322004016303 0ustar coincoin-web 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_apx/exp_eps.omh cppad-20160000.1/doc/exp_eps_rev2.xml0000644000175200017650000021543012656322004016314 0ustar coincoin-web 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_apx/exp_eps.omh cppad-20160000.1/doc/exp_eps_cppad.xml0000644000175200017650000002446512656322004016533 0ustar coincoin-web 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_apx/exp_eps_cppad.cpp cppad-20160000.1/doc/exp_apx_main.cpp.xml0000644000175200017650000001210312656322004017134 0ustar coincoin-web Correctness Tests For Exponential Approximation in Introduction
Prev Next exp_apx_main.cpp

Correctness Tests For Exponential Approximation in Introduction

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

main.cpp
 

// system include files used for I/O
# include <iostream>

// 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);

namespace {
	static size_t Run_ok_count    = 0;
	static size_t Run_error_count = 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.c_str();
		//
		ok &= name.size() < size_t(width);
		ok &= TestOk();
		if( ok )
		{	std::cout << "OK" << std::endl;
			Run_ok_count++;
		}
		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 namespace std;

	// This comment is used by OneTest

	// external compiled tests
	ok &= Run( exp_2,           "exp_2"          );
	ok &= Run( exp_2_cppad,     "exp_2_cppad"    );
	ok &= Run( exp_2_for0,      "exp_2_for0"     );
	ok &= Run( exp_2_for1,      "exp_2_for1"     );
	ok &= Run( exp_2_for2,      "exp_2_for2"     );
	ok &= Run( exp_2_rev1,      "exp_2_rev1"     );
	ok &= Run( exp_2_rev2,      "exp_2_rev2"     );
	ok &= Run( exp_eps,         "exp_eps"        );
	ok &= Run( exp_eps_cppad,   "exp_eps_cppad"  );
	ok &= Run( exp_eps_for0,    "exp_eps_for0"   );
	ok &= Run( exp_eps_for1,    "exp_eps_for1"   );
	ok &= Run( exp_eps_for2,    "exp_eps_for2"   );
	ok &= Run( exp_eps_rev1,    "exp_eps_rev1"   );
	ok &= Run( exp_eps_rev2,    "exp_eps_rev2"   );
	if( ok )
		cout << "All " << int(Run_ok_count) << " tests passed." << endl;
	else	cout << int(Run_error_count) << " tests failed." << endl;

	return static_cast<int>( ! ok );
}

Input File: introduction/exp_apx/main.cpp cppad-20160000.1/doc/ad.xml0000644000175200017650000001115312656322004014273 0ustar coincoin-web 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/local/user_ad.hpp cppad-20160000.1/doc/ad_ctor.xml0000644000175200017650000002031012656322004015315 0ustar coincoin-web 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) .

Deprecated 2013-12-31
If you set cppad_deprecated to be YES during the install procedure, you will get an implicit constructor with 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/local/ad_ctor.hpp cppad-20160000.1/doc/ad_ctor.cpp.xml0000644000175200017650000000625612656322004016113 0ustar coincoin-web AD Constructors: Example and Test
Prev Next ad_ctor.cpp Headings

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/ad_ctor.cpp cppad-20160000.1/doc/ad_assign.xml0000644000175200017650000001301212656322004015633 0ustar coincoin-web 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/local/ad_assign.hpp cppad-20160000.1/doc/ad_assign.cpp.xml0000644000175200017650000000573412656322004016430 0ustar coincoin-web AD Assignment: Example and Test
Prev Next ad_assign.cpp Headings

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/ad_assign.cpp cppad-20160000.1/doc/convert.xml0000644000175200017650000000566712656322004015404 0ustar coincoin-web 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/local/convert.hpp cppad-20160000.1/doc/value.xml0000644000175200017650000001456512656322004015035 0ustar coincoin-web 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/local/value.hpp cppad-20160000.1/doc/value.cpp.xml0000644000175200017650000000663612656322004015616 0ustar coincoin-web Convert From AD to its Base Type: Example and Test
Prev Next value.cpp Headings

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/value.cpp cppad-20160000.1/doc/integer.xml0000644000175200017650000002331212656322004015344 0ustar coincoin-web 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/local/integer.hpp cppad-20160000.1/doc/integer.cpp.xml0000644000175200017650000000673612656322004016140 0ustar coincoin-web Convert From AD to Integer: Example and Test
Prev Next integer.cpp Headings

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/integer.cpp cppad-20160000.1/doc/ad_to_string.xml0000644000175200017650000001317012656322004016364 0ustar coincoin-web 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/local/ad_to_string.hpp cppad-20160000.1/doc/ad_input.xml0000644000175200017650000002031612656322004015513 0ustar coincoin-web 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/local/ad_io.hpp cppad-20160000.1/doc/ad_input.cpp.xml0000644000175200017650000000637012656322004016300 0ustar coincoin-web AD Output Operator: Example and Test
Prev Next ad_input.cpp Headings

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/ad_input.cpp cppad-20160000.1/doc/_acos_xml.js0000644000175200017650000000375112656322004015474 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/ad_output.xml0000644000175200017650000002047712656322004015724 0ustar coincoin-web 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/local/ad_io.hpp cppad-20160000.1/doc/printfor.xml0000644000175200017650000003206212656322004015554 0ustar coincoin-web 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 .

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/local/print_for.hpp cppad-20160000.1/doc/print_for_cout.cpp.xml0000644000175200017650000001452712656322004017534 0ustar coincoin-web 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)
{    bool ok = true;
     print_for();

     size_t thread;
     for(thread = 0; thread < 2; thread++)
     {    ok &= CppAD::omp_alloc::inuse(thread) == 0;
          ok &= CppAD::omp_alloc::available(thread) == 0;
     }
     if( ! ok )
          return 1;
     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: print_for/print_for.cpp cppad-20160000.1/doc/print_for_string.cpp.xml0000644000175200017650000001043412656322004020061 0ustar coincoin-web Print During Zero Order Forward Mode: Example and Test
Prev Next print_for_string.cpp Headings

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/print_for.cpp cppad-20160000.1/doc/var2par.xml0000644000175200017650000001246112656322004015267 0ustar coincoin-web 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/local/var2par.hpp cppad-20160000.1/doc/var2par.cpp.xml0000644000175200017650000000750512656322004016053 0ustar coincoin-web Convert an AD Variable to a Parameter: Example and Test
Prev Next var2par.cpp Headings

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/var2par.cpp cppad-20160000.1/doc/advalued.xml0000644000175200017650000000666412656322004015507 0ustar coincoin-web AD Valued Operations and Functions
Prev Next

AD Valued Operations and Functions

Contents
ArithmeticAD Arithmetic Operators and Computed 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/local/ad_valued.hpp cppad-20160000.1/doc/arithmetic.xml0000644000175200017650000000646312656322004016050 0ustar coincoin-web AD Arithmetic Operators and Computed Assignments
Prev Next

AD Arithmetic Operators and Computed Assignments

Contents
UnaryPlusAD Unary Plus Operator
UnaryMinusAD Unary Minus Operator
ad_binaryAD Binary Arithmetic Operators
compute_assignAD Computed Assignment Operators

Input File: cppad/local/arithmetic.hpp cppad-20160000.1/doc/unaryplus.xml0000644000175200017650000001566112656322004015761 0ustar coincoin-web 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/local/unary_plus.hpp cppad-20160000.1/doc/unary_plus.cpp.xml0000644000175200017650000000760112656322004016674 0ustar coincoin-web AD Unary Plus Operator: Example and Test
Prev Next unary_plus.cpp Headings

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/unary_plus.cpp cppad-20160000.1/doc/unaryminus.xml0000644000175200017650000001626412656322004016131 0ustar coincoin-web 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/local/unary_minus.hpp cppad-20160000.1/doc/unary_minus.cpp.xml0000644000175200017650000000762112656322004017046 0ustar coincoin-web AD Unary Minus Operator: Example and Test
Prev Next unary_minus.cpp Headings

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/unary_minus.cpp cppad-20160000.1/doc/ad_binary.xml0000644000175200017650000004410412656322004015641 0ustar coincoin-web 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/local/ad_binary.hpp cppad-20160000.1/doc/add.cpp.xml0000644000175200017650000001136312656322004015223 0ustar coincoin-web AD Binary Addition: Example and Test
Prev Next add.cpp Headings

AD Binary Addition: Example and Test
 
# include <cppad/cppad.hpp>

bool Add(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;

	// 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,  1e-10 , 1e-10);

	// 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., 1e-10, 1e-10);

	// 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., 1e-10, 1e-10);

	// 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/add.cpp cppad-20160000.1/doc/sub.cpp.xml0000644000175200017650000001140612656322004015262 0ustar coincoin-web AD Binary Subtraction: Example and Test
Prev Next sub.cpp Headings

AD Binary Subtraction: Example and Test
 
# include <cppad/cppad.hpp>

bool Sub(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;

	// 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.,  1e-10 , 1e-10);

	// 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., 1e-10, 1e-10);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], -1., 1e-10, 1e-10);

	// 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/sub.cpp cppad-20160000.1/doc/mul.cpp.xml0000644000175200017650000001150712656322004015270 0ustar coincoin-web AD Binary Multiplication: Example and Test
Prev Next mul.cpp Headings

AD Binary Multiplication: Example and Test
 
# include <cppad/cppad.hpp>

bool Mul(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;

	// 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,  1e-10 , 1e-10);

	// 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, 1e-10 , 1e-10);

	// 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, 1e-10 , 1e-10);

	// 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/mul.cpp cppad-20160000.1/doc/div.cpp.xml0000644000175200017650000001145612656322004015260 0ustar coincoin-web AD Binary Division: Example and Test
Prev Next div.cpp Headings

AD Binary Division: Example and Test
 
# include <cppad/cppad.hpp>

bool Div(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;


	// 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),  1e-10 , 1e-10);

	// 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., 1e-10, 1e-10);

	// 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., 1e-10, 1e-10);

	// 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/div.cpp cppad-20160000.1/doc/compute_assign.xml0000644000175200017650000004306212656322004016733 0ustar coincoin-web AD Computed Assignment Operators
Prev Next

AD Computed Assignment Operators

Syntax
x Op y

Purpose
Performs computed 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 Computed Assignment Addition: Example and Test
sub_eq.cpp AD Computed Assignment Subtraction: Example and Test
mul_eq.cpp AD Computed Assignment Multiplication: Example and Test
div_eq.cpp AD Computed 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/local/compute_assign.hpp cppad-20160000.1/doc/addeq.cpp.xml0000644000175200017650000001120512656322004015544 0ustar coincoin-web AD Computed Assignment Addition: Example and Test
Prev Next AddEq.cpp Headings

AD Computed Assignment Addition: Example and Test
 
# include <cppad/cppad.hpp>

bool AddEq(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;

	// 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 computed 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,  1e-10 , 1e-10);
	ok &= NearEqual(y[1] ,        y[0],  1e-10 , 1e-10);

	// 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., 1e-10, 1e-10);
	ok   &= NearEqual(dy[1], 2., 1e-10, 1e-10);

	// 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., 1e-10, 1e-10);

	// 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/add_eq.cpp cppad-20160000.1/doc/sub_eq.cpp.xml0000644000175200017650000001125012656322004015744 0ustar coincoin-web AD Computed Assignment Subtraction: Example and Test
Prev Next sub_eq.cpp Headings

AD Computed Assignment Subtraction: Example and Test
 
# include <cppad/cppad.hpp>

bool SubEq(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;

	// 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 computed 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),  1e-10 , 1e-10);
	ok &= NearEqual(y[1] ,             y[0],  1e-10 , 1e-10);

	// 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., 1e-10, 1e-10);
	ok   &= NearEqual(dy[1], 2., 1e-10, 1e-10);

	// 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., 1e-10, 1e-10);

	// 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/sub_eq.cpp cppad-20160000.1/doc/mul_eq.cpp.xml0000644000175200017650000001127712656322004015761 0ustar coincoin-web AD Computed Assignment Multiplication: Example and Test
Prev Next mul_eq.cpp Headings

AD Computed Assignment Multiplication: Example and Test
 
# include <cppad/cppad.hpp>

bool MulEq(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;

	// 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 computed 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,  1e-10 , 1e-10);
	ok &= NearEqual(y[1] ,        y[0],  1e-10 , 1e-10);

	// 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, 1e-10, 1e-10);
	ok   &= NearEqual(dy[1], 8.*2.*x0, 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	// 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/mul_eq.cpp cppad-20160000.1/doc/div_eq.cpp.xml0000644000175200017650000001125112656322004015736 0ustar coincoin-web AD Computed Assignment Division: Example and Test
Prev Next div_eq.cpp Headings

AD Computed Assignment Division: Example and Test
 
# include <cppad/cppad.hpp>

bool DivEq(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;

	// 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 computed 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),  1e-10 , 1e-10);
	ok &= NearEqual(y[1] ,             y[0],  1e-10 , 1e-10);

	// 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., 1e-10, 1e-10);
	ok   &= NearEqual(dy[1], 1./8., 1e-10, 1e-10);

	// 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., 1e-10, 1e-10);

	// 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/div_eq.cpp cppad-20160000.1/doc/unary_standard_math.xml0000644000175200017650000003205212656322004017737 0ustar coincoin-web 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/local/standard_math.hpp cppad-20160000.1/doc/acos.xml0000644000175200017650000001162712656322004014642 0ustar coincoin-web Inverse Sine Function: acos
Prev Next

Inverse Sine Function: acos

Syntax
y = acos(x)

x, y
See the possible types for a unary standard math function.

Atomic
This is an atomic operation .

Derivative acos ( 1 ) ( x ) = - ( 1 - x * x ) -1 / 2
Example
The file acos.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/std_math_98.hpp cppad-20160000.1/doc/atan2.xml0000644000175200017650000002057512656322005014725 0ustar coincoin-web 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/local/atan2.hpp cppad-20160000.1/doc/atan2.cpp.xml0000644000175200017650000001054712656322005015504 0ustar coincoin-web The AD atan2 Function: Example and Test
Prev Next atan2.cpp Headings

The AD atan2 Function: Example and Test
 

# include <cppad/cppad.hpp>

bool atan2(void)
{	bool ok = true;

	using CppAD::AD;
	using CppAD::NearEqual;

	// 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,  1e-10 , 1e-10);

	// forward computation of first partial w.r.t. x[0]
	CPPAD_TESTVECTOR(double) dx(n);
	CPPAD_TESTVECTOR(double) dy(m);
	dx[0] = 1.;
	dy    = f.Forward(1, dx);
	ok   &= NearEqual(dy[0], 1., 1e-10, 1e-10);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], 1., 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	return ok;
}


Input File: example/atan2.cpp cppad-20160000.1/doc/acos.cpp.xml0000644000175200017650000001115212656322004015414 0ustar coincoin-web The AD acos Function: Example and Test
Prev Next acos.cpp Headings

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/acos.cpp cppad-20160000.1/doc/asin.cpp.xml0000644000175200017650000001115212656322004015421 0ustar coincoin-web The AD asin Function: Example and Test
Prev Next asin.cpp Headings

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/asin.cpp cppad-20160000.1/doc/atan.cpp.xml0000644000175200017650000001103212656322004015407 0ustar coincoin-web The AD atan Function: Example and Test
Prev Next atan.cpp Headings

The AD atan Function: Example and Test
 

# include <cppad/cppad.hpp>

bool atan(void)
{	bool ok = true;

	using CppAD::AD;
	using CppAD::NearEqual;

	// 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,  1e-10 , 1e-10);

	// forward computation of first partial w.r.t. x[0]
	CPPAD_TESTVECTOR(double) dx(n);
	CPPAD_TESTVECTOR(double) dy(m);
	dx[0] = 1.;
	dy    = f.Forward(1, dx);
	ok   &= NearEqual(dy[0], 1., 1e-10, 1e-10);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], 1., 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	return ok;
}


Input File: example/atan.cpp cppad-20160000.1/doc/cos.cpp.xml0000644000175200017650000001101712656322004015253 0ustar coincoin-web The AD cos Function: Example and Test
Prev Next cos.cpp Headings

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;

	// 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,  1e-10 , 1e-10);

	// 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, 1e-10, 1e-10);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], check, 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	return ok;
}


Input File: example/cos.cpp cppad-20160000.1/doc/cosh.cpp.xml0000644000175200017650000001103712656322005015426 0ustar coincoin-web The AD cosh Function: Example and Test
Prev Next cosh.cpp Headings

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;

	// 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,  1e-10 , 1e-10);

	// 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, 1e-10, 1e-10);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], check, 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	return ok;
}


Input File: example/cosh.cpp cppad-20160000.1/doc/exp.cpp.xml0000644000175200017650000001102612656322005015264 0ustar coincoin-web The AD exp Function: Example and Test
Prev Next exp.cpp Headings

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/exp.cpp cppad-20160000.1/doc/log.cpp.xml0000644000175200017650000001102412656322005015247 0ustar coincoin-web The AD log Function: Example and Test
Prev Next log.cpp Headings

The AD log Function: Example and Test
 

# include <cppad/cppad.hpp>

bool log(void)
{	bool ok = true;

	using CppAD::AD;
	using CppAD::NearEqual;

	// 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,  1e-10 , 1e-10);

	// forward computation of first partial w.r.t. x[0]
	CPPAD_TESTVECTOR(double) dx(n);
	CPPAD_TESTVECTOR(double) dy(m);
	dx[0] = 1.;
	dy    = f.Forward(1, dx);
	ok   &= NearEqual(dy[0], 1., 1e-10, 1e-10);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], 1., 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	return ok;
}


Input File: example/log.cpp cppad-20160000.1/doc/log10.cpp.xml0000644000175200017650000001120012656322005015404 0ustar coincoin-web The AD log10 Function: Example and Test
Prev Next log10.cpp Headings

The AD log10 Function: Example and Test
 

# include <cppad/cppad.hpp>

bool log10(void)
{	bool ok = true;

	using CppAD::AD;
	using CppAD::NearEqual;

	// 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,  1e-10 , 1e-10);

	// forward computation of first partial w.r.t. x[0]
	CPPAD_TESTVECTOR(double) dx(n);
	CPPAD_TESTVECTOR(double) dy(m);
	dx[0] = 1.;
	dy    = f.Forward(1, dx);
	ok   &= NearEqual(dy[0], 1., 1e-10, 1e-10);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], 1., 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	return ok;
}


Input File: example/log10.cpp cppad-20160000.1/doc/sin.cpp.xml0000644000175200017650000001101512656322005015257 0ustar coincoin-web The AD sin Function: Example and Test
Prev Next sin.cpp Headings

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;

	// 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,  1e-10 , 1e-10);

	// 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, 1e-10, 1e-10);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], check, 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	return ok;
}


Input File: example/sin.cpp cppad-20160000.1/doc/sinh.cpp.xml0000644000175200017650000001104012656322005015425 0ustar coincoin-web The AD sinh Function: Example and Test
Prev Next sinh.cpp Headings

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;

	// 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,  1e-10 , 1e-10);

	// 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, 1e-10, 1e-10);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], check, 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	return ok;
}


Input File: example/sinh.cpp cppad-20160000.1/doc/sqrt.cpp.xml0000644000175200017650000001105412656322005015462 0ustar coincoin-web The AD sqrt Function: Example and Test
Prev Next sqrt.cpp Headings

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;

	// 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,  1e-10 , 1e-10);

	// 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, 1e-10, 1e-10);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], check, 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	return ok;
}


Input File: example/sqrt.cpp cppad-20160000.1/doc/tan.cpp.xml0000644000175200017650000001115312656322005015253 0ustar coincoin-web The AD tan Function: Example and Test
Prev Next tan.cpp Headings

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/tan.cpp cppad-20160000.1/doc/tanh.cpp.xml0000644000175200017650000001117712656322005015431 0ustar coincoin-web The AD tanh Function: Example and Test
Prev Next tanh.cpp Headings

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/tanh.cpp cppad-20160000.1/doc/asin.xml0000644000175200017650000001156312656322004014646 0ustar coincoin-web Inverse Sine Function: asin
Prev Next

Inverse Sine Function: asin

Syntax
y = asin(x)

x, y
See the possible types for a unary standard math function.

Atomic
This is an atomic operation .

Derivative asin ( 1 ) ( x ) = ( 1 - x * x ) -1 / 2
Example
The file asin.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/std_math_98.hpp cppad-20160000.1/doc/atan.xml0000644000175200017650000001141412656322004014632 0ustar coincoin-web Inverse Tangent Function: atan
Prev Next

Inverse Tangent Function: atan

Syntax
y = atan(x)

x, y
See the possible types for a unary standard math function.

Atomic
This is an atomic operation .

Derivative atan ( 1 ) ( x ) = 1 1 + x 2
Example
The file atan.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/std_math_98.hpp cppad-20160000.1/doc/cos.xml0000644000175200017650000001132512656322004014474 0ustar coincoin-web The Cosine Function: cos
Prev Next

The Cosine Function: cos

Syntax
y = cos(x)

x, y
See the possible types for a unary standard math function.

Atomic
This is an atomic operation .

Derivative cos ( 1 ) ( x ) = - sin ( x )
Example
The file cos.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/std_math_98.hpp cppad-20160000.1/doc/cosh.xml0000644000175200017650000001136212656322004014645 0ustar coincoin-web 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/local/std_math_98.hpp cppad-20160000.1/doc/exp.xml0000644000175200017650000001131512656322005014504 0ustar coincoin-web The Exponential Function: exp
Prev Next

The Exponential Function: exp

Syntax
y = exp(x)

x, y
See the possible types for a unary standard math function.

Atomic
This is an atomic operation .

Derivative exp ( 1 ) ( x ) = exp ( x )
Example
The file exp.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/std_math_98.hpp cppad-20160000.1/doc/log.xml0000644000175200017650000001127612656322005014477 0ustar coincoin-web The Exponential Function: log
Prev Next

The Exponential Function: log

Syntax
y = log(x)

x, y
See the possible types for a unary standard math function.

Atomic
This is an atomic operation .

Derivative log ( 1 ) ( x ) = 1 x
Example
The file log.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/std_math_98.hpp cppad-20160000.1/doc/log10.xml0000644000175200017650000001106312656322005014632 0ustar coincoin-web 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/local/std_math_98.hpp cppad-20160000.1/doc/sin.xml0000644000175200017650000001126212656322005014502 0ustar coincoin-web The Sine Function: sin
Prev Next

The Sine Function: sin

Syntax
y = sin(x)

x, y
See the possible types for a unary standard math function.

Atomic
This is an atomic operation .

Derivative sin ( 1 ) ( x ) = cos ( x )
Example
The file sin.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/std_math_98.hpp cppad-20160000.1/doc/sinh.xml0000644000175200017650000001135212656322005014652 0ustar coincoin-web 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/local/std_math_98.hpp cppad-20160000.1/doc/sqrt.xml0000644000175200017650000001154612656322005014707 0ustar coincoin-web The Square Root Function: sqrt
Prev Next

The Square Root Function: sqrt

Syntax
y = sqrt(x)

x, y
See the possible types for a unary standard math function.

Atomic
This is an atomic operation .

Derivative sqrt ( 1 ) ( x ) = 1 2 sqrt ( x )
Example
The file sqrt.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/std_math_98.hpp cppad-20160000.1/doc/tan.xml0000644000175200017650000001137512656322005014500 0ustar coincoin-web 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/local/std_math_98.hpp cppad-20160000.1/doc/tanh.xml0000644000175200017650000001146612656322005014651 0ustar coincoin-web 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/local/std_math_98.hpp cppad-20160000.1/doc/abs.xml0000644000175200017650000001623512656322005014463 0ustar coincoin-web 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 abs.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/abs.hpp cppad-20160000.1/doc/abs.cpp.xml0000644000175200017650000001303112656322005015233 0ustar coincoin-web AD Absolute Value Function: Example and Test
Prev Next abs.cpp Headings

AD Absolute Value Function: Example and Test
 

# include <cppad/cppad.hpp>

bool abs(void)
{	bool ok = true;

	using CppAD::AD;
	using CppAD::NearEqual;

	// 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]     = abs(x[0] - 1.);
	y[1]     = abs(x[0]);
	y[2]     = abs(x[0] + 1.);
	//
	y[3]     = fabs(x[0] - 1.);
	y[4]     = fabs(x[0]);
	y[5]     = fabs(x[0] + 1.);

	// create f: x -> y and stop tape recording
	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 = abs(v[zero]);
	ok    &= NearEqual(result, 1., 1e-10, 1e-10);
	result = fabs(v[zero]);
	ok    &= NearEqual(result, 1., 1e-10, 1e-10);

	return ok;
}


Input File: example/abs.cpp cppad-20160000.1/doc/acosh.xml0000644000175200017650000001350512656322005015010 0ustar coincoin-web The Inverse Hyperbolic Cosine Function: acosh
Prev Next

The Inverse Hyperbolic Cosine Function: acosh

Syntax
y = acosh(x)

Description
The inverse hyperbolic cosine function is defined by x == cosh(y) .

x, y
See the possible types for a unary standard math function.

CPPAD_USE_CPLUSPLUS_2011

true
If this preprocessor symbol is true (1), and x is an AD type, this is an atomic operation .

false
If this preprocessor symbol is false (0), CppAD uses the representation acosh ( x ) = log (x + x 2 - 1 ) to compute this function.

Example
The file acosh.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/acosh.hpp cppad-20160000.1/doc/acosh.cpp.xml0000644000175200017650000001117712656322005015574 0ustar coincoin-web The AD acosh Function: Example and Test
Prev Next acosh.cpp Headings

The AD acosh Function: Example and Test
 

# include <cppad/cppad.hpp>

bool acosh(void)
{	bool ok = true;

	using CppAD::AD;
	using CppAD::NearEqual;

	// 10 times machine epsilon
	double eps = 10. * std::numeric_limits<double>::epsilon();

	// domain space vector
	size_t n  = 1;
	double x0 = 0.5;
	CPPAD_TESTVECTOR(AD<double>) x(n);
	x[0]      = x0;

	// declare independent variables and start tape recording
	CppAD::Independent(x);

	// a temporary value
	AD<double> cosh_of_x0 = CppAD::cosh(x[0]);

	// range space vector
	size_t m = 1;
	CPPAD_TESTVECTOR(AD<double>) y(m);
	y[0] = CppAD::acosh(cosh_of_x0);

	// create f: x -> y and stop tape recording
	CppAD::ADFun<double> f(x, y);

	// check value
	ok &= NearEqual(y[0] , x0,  eps, eps);

	// forward computation of first partial w.r.t. x[0]
	CPPAD_TESTVECTOR(double) dx(n);
	CPPAD_TESTVECTOR(double) dy(m);
	dx[0] = 1.;
	dy    = f.Forward(1, dx);
	ok   &= NearEqual(dy[0], 1., eps, eps);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], 1., eps, eps);

	// use a VecAD<Base>::reference object with acosh
	CppAD::VecAD<double> v(1);
	AD<double> zero(0);
	v[zero] = cosh_of_x0;
	AD<double> result = CppAD::acosh(v[zero]);
	ok     &= NearEqual(result, x0, eps, eps);

	return ok;
}


Input File: example/acosh.cpp cppad-20160000.1/doc/asinh.xml0000644000175200017650000001347512656322005015023 0ustar coincoin-web The Inverse Hyperbolic Sine Function: asinh
Prev Next

The Inverse Hyperbolic Sine Function: asinh

Syntax
y = asinh(x)

Description
The inverse hyperbolic sine function is defined by x == sinh(y) .

x, y
See the possible types for a unary standard math function.

CPPAD_USE_CPLUSPLUS_2011

true
If this preprocessor symbol is true (1), and x is an AD type, this is an atomic operation .

false
If this preprocessor symbol is false (0), CppAD uses the representation asinh ( x ) = log (x + 1 + x 2 ) to compute this function.

Example
The file asinh.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/asinh.hpp cppad-20160000.1/doc/asinh.cpp.xml0000644000175200017650000001117712656322005015601 0ustar coincoin-web The AD asinh Function: Example and Test
Prev Next asinh.cpp Headings

The AD asinh Function: Example and Test
 

# include <cppad/cppad.hpp>

bool asinh(void)
{	bool ok = true;

	using CppAD::AD;
	using CppAD::NearEqual;

	// 10 times machine epsilon
	double eps = 10. * std::numeric_limits<double>::epsilon();

	// domain space vector
	size_t n  = 1;
	double x0 = 0.5;
	CPPAD_TESTVECTOR(AD<double>) x(n);
	x[0]      = x0;

	// declare independent variables and start tape recording
	CppAD::Independent(x);

	// a temporary value
	AD<double> sinh_of_x0 = CppAD::sinh(x[0]);

	// range space vector
	size_t m = 1;
	CPPAD_TESTVECTOR(AD<double>) y(m);
	y[0] = CppAD::asinh(sinh_of_x0);

	// create f: x -> y and stop tape recording
	CppAD::ADFun<double> f(x, y);

	// check value
	ok &= NearEqual(y[0] , x0,  eps, eps);

	// forward computation of first partial w.r.t. x[0]
	CPPAD_TESTVECTOR(double) dx(n);
	CPPAD_TESTVECTOR(double) dy(m);
	dx[0] = 1.;
	dy    = f.Forward(1, dx);
	ok   &= NearEqual(dy[0], 1., eps, eps);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], 1., eps, eps);

	// use a VecAD<Base>::reference object with asinh
	CppAD::VecAD<double> v(1);
	AD<double> zero(0);
	v[zero] = sinh_of_x0;
	AD<double> result = CppAD::asinh(v[zero]);
	ok     &= NearEqual(result, x0, eps, eps);

	return ok;
}


Input File: example/asinh.cpp cppad-20160000.1/doc/atanh.xml0000644000175200017650000001361612656322005015011 0ustar coincoin-web The Inverse Hyperbolic Tangent Function: atanh
Prev Next

The Inverse Hyperbolic Tangent Function: atanh

Syntax
y = atanh(x)

Description
The inverse hyperbolic tangent function is defined by x == tanh(y) .

x, y
See the possible types for a unary standard math function.

CPPAD_USE_CPLUSPLUS_2011

true
If this preprocessor symbol is true (1), and x is an AD type, this is an atomic operation .

false
If this preprocessor symbol is false (0), CppAD uses the representation atanh ( x ) = 1 2 log (1 + x 1 - x ) to compute this function.

Example
The file atanh.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/atanh.hpp cppad-20160000.1/doc/atanh.cpp.xml0000644000175200017650000001117512656322005015570 0ustar coincoin-web The AD atanh Function: Example and Test
Prev Next atanh.cpp Headings

The AD atanh Function: Example and Test
 

# include <cppad/cppad.hpp>

bool atanh(void)
{	bool ok = true;

	using CppAD::AD;
	using CppAD::NearEqual;

	// 10 times machine epsilon
	double eps = 10. * std::numeric_limits<double>::epsilon();

	// domain space vector
	size_t n  = 1;
	double x0 = 0.5;
	CPPAD_TESTVECTOR(AD<double>) x(n);
	x[0]      = x0;

	// declare independent variables and start tape recording
	CppAD::Independent(x);

	// a temporary value
	AD<double> tanh_of_x0 = CppAD::tanh(x[0]);

	// range space vector
	size_t m = 1;
	CPPAD_TESTVECTOR(AD<double>) y(m);
	y[0] = CppAD::atanh(tanh_of_x0);

	// create f: x -> y and stop tape recording
	CppAD::ADFun<double> f(x, y);

	// check value
	ok &= NearEqual(y[0] , x0,  eps, eps);

	// forward computation of first partial w.r.t. x[0]
	CPPAD_TESTVECTOR(double) dx(n);
	CPPAD_TESTVECTOR(double) dy(m);
	dx[0] = 1.;
	dy    = f.Forward(1, dx);
	ok   &= NearEqual(dy[0], 1., eps, eps);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], 1., eps, eps);

	// use a VecAD<Base>::reference object with atanh
	CppAD::VecAD<double> v(1);
	AD<double> zero(0);
	v[zero] = tanh_of_x0;
	AD<double> result = CppAD::atanh(v[zero]);
	ok     &= NearEqual(result, x0, eps, eps);

	return ok;
}


Input File: example/atanh.cpp cppad-20160000.1/doc/erf.xml0000644000175200017650000001416712656322005014474 0ustar coincoin-web 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/local/erf.hpp cppad-20160000.1/doc/erf.cpp.xml0000644000175200017650000001233412656322005015247 0ustar coincoin-web The AD erf Function: Example and Test
Prev Next erf.cpp Headings

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.52050;
	ok &= NearEqual(ay[0] , erf_x0,  0.,    4e-4);
# if CPPAD_USE_CPLUSPLUS_2011
	ok &= NearEqual(ay[0] , erf_x0,  0.,    1e-5);
# 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/erf.cpp cppad-20160000.1/doc/expm1.xml0000644000175200017650000001333112656322005014742 0ustar coincoin-web The Exponential Function Minus One: expm1
Prev Next

The Exponential Function Minus One: expm1

Syntax
y = expm1(x)

Description
Returns the value of the exponential function minus one which is defined by y == exp(x) - 1 .

x, y
See the possible types for a unary standard math function.

CPPAD_USE_CPLUSPLUS_2011

true
If this preprocessor symbol is true (1), and x is an AD type, this is an atomic operation .

false
If this preprocessor symbol is false (0), CppAD uses the representation expm 1 ( x ) = exp ( x ) - 1 to compute this function.

Example
The file expm1.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/expm1.hpp cppad-20160000.1/doc/expm1.cpp.xml0000644000175200017650000001106612656322005015526 0ustar coincoin-web The AD exp Function: Example and Test
Prev Next expm1.cpp Headings

The AD exp Function: Example and Test
 

# include <cppad/cppad.hpp>
# include <cmath>

bool expm1(void)
{	bool ok = true;

	using CppAD::AD;
	using CppAD::NearEqual;
	double eps = 10. * std::numeric_limits<double>::epsilon();

	// domain space vector
	size_t n  = 1;
	double x0 = 0.5;
	CPPAD_TESTVECTOR(AD<double>) ax(n);
	ax[0]     = x0;

	// declare independent variables and start tape recording
	CppAD::Independent(ax);

	// range space vector
	size_t m = 1;
	CPPAD_TESTVECTOR(AD<double>) ay(m);
	ay[0] = CppAD::expm1(ax[0]);

	// create f: x -> y and stop tape recording
	CppAD::ADFun<double> f(ax, ay);

	// expx0 value
	double expx0 = std::exp(x0);
	ok &= NearEqual(ay[0], expx0-1.0,  eps, eps);

	// forward computation of first partial w.r.t. x[0]
	CPPAD_TESTVECTOR(double) dx(n);
	CPPAD_TESTVECTOR(double) dy(m);
	dx[0] = 1.;
	dy    = f.Forward(1, dx);
	ok   &= NearEqual(dy[0], expx0, eps, eps);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], expx0, eps, eps);

	// use a VecAD<Base>::reference object with exp
	CppAD::VecAD<double> v(1);
	AD<double> zero(0);
	v[zero]           = x0;
	AD<double> result = CppAD::expm1(v[zero]);
	ok   &= NearEqual(result, expx0-1.0, eps, eps);

	return ok;
}


Input File: example/expm1.cpp cppad-20160000.1/doc/log1p.xml0000644000175200017650000001337012656322005014735 0ustar coincoin-web The Logarithm of One Plus Argument: log1p
Prev Next

The Logarithm of One Plus Argument: log1p

Syntax
y = log1p(x)

Description
Returns the value of the logarithm of one plus argument which is defined by y == log(1 + x) .

x, y
See the possible types for a unary standard math function.

CPPAD_USE_CPLUSPLUS_2011

true
If this preprocessor symbol is true (1), and x is an AD type, this is an atomic operation .

false
If this preprocessor symbol is false (0), CppAD uses the representation log 1 p ( x ) = log ( 1 + x ) to compute this function.

Example
The file log1p.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/log1p.hpp cppad-20160000.1/doc/log1p.cpp.xml0000644000175200017650000001120212656322005015506 0ustar coincoin-web The AD log1p Function: Example and Test
Prev Next log1p.cpp Headings

The AD log1p Function: Example and Test
 

# include <cppad/cppad.hpp>

bool log1p(void)
{	bool ok = true;

	using CppAD::AD;
	using CppAD::NearEqual;

	// 10 times machine epsilon
	double eps = 10. * std::numeric_limits<double>::epsilon();

	// domain space vector
	size_t n  = 1;
	double x0 = 0.5;
	CPPAD_TESTVECTOR(AD<double>) x(n);
	x[0]      = x0;

	// declare independent variables and start tape recording
	CppAD::Independent(x);

	// a temporary value
	AD<double> expm1_of_x0 = CppAD::expm1(x[0]);

	// range space vector
	size_t m = 1;
	CPPAD_TESTVECTOR(AD<double>) y(m);
	y[0] = CppAD::log1p(expm1_of_x0);

	// create f: x -> y and stop tape recording
	CppAD::ADFun<double> f(x, y);

	// check value
	ok &= NearEqual(y[0] , x0,  eps, eps);

	// forward computation of first partial w.r.t. x[0]
	CPPAD_TESTVECTOR(double) dx(n);
	CPPAD_TESTVECTOR(double) dy(m);
	dx[0] = 1.;
	dy    = f.Forward(1, dx);
	ok   &= NearEqual(dy[0], 1., eps, eps);

	// reverse computation of derivative of y[0]
	CPPAD_TESTVECTOR(double)  w(m);
	CPPAD_TESTVECTOR(double) dw(n);
	w[0]  = 1.;
	dw    = f.Reverse(1, w);
	ok   &= NearEqual(dw[0], 1., eps, eps);

	// use a VecAD<Base>::reference object with log1p
	CppAD::VecAD<double> v(1);
	AD<double> zero(0);
	v[zero] = expm1_of_x0;
	AD<double> result = CppAD::log1p(v[zero]);
	ok     &= NearEqual(result, x0, eps, eps);

	return ok;
}


Input File: example/log1p.cpp cppad-20160000.1/doc/sign.xml0000644000175200017650000001476612656322005014665 0ustar coincoin-web 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/local/sign.hpp cppad-20160000.1/doc/sign.cpp.xml0000644000175200017650000001065412656322005015436 0ustar coincoin-web Sign Function: Example and Test
Prev Next sign.cpp Headings

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/sign.cpp cppad-20160000.1/doc/_atan2_xml.js0000644000175200017650000000347212656322005015555 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/pow.xml0000644000175200017650000002310712656322005014517 0ustar coincoin-web 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/local/pow.hpp cppad-20160000.1/doc/_pow_xml.js0000644000175200017650000000347012656322005015353 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/pow.cpp.xml0000644000175200017650000001255512656322005015305 0ustar coincoin-web The AD Power Function: Example and Test
Prev Next pow.cpp Headings

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/pow.cpp cppad-20160000.1/doc/azmul.xml0000644000175200017650000002344712656322005015051 0ustar coincoin-web Absolute Zero Multiplication
Prev Next

Absolute Zero Multiplication

Syntax
z = azmul(xy)

Purpose
Evaluates multiplication with an absolute zero for any of the possible types listed below. The result is given by z = { 0 if x = 0 x · y otherwise Note if x is zero and y is infinity, ieee multiplication would result in not a number whereas z would be zero.

Base
If Base satisfies the base type requirements and arguments x , y have prototypes
     const 
Basex
     const 
Basey
then the result z has prototype
     
Base z

AD<Base>
If the arguments x , y have prototype
     const AD<
Base>& x
     const AD<
Base>& y
then the result z has prototype
     AD<
Basez

VecAD<Base>
If the arguments x , y have prototype
     const VecAD<
Base>::reference& x
     const VecAD<
Base>::reference& y
then the result z has prototype
     AD<
Basez

Example
The file azmul.cpp is an examples and tests of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/azmul.hpp cppad-20160000.1/doc/azmul.cpp.xml0000644000175200017650000001014412656322005015620 0ustar coincoin-web AD Absolute Zero Multiplication: Example and Test
Prev Next azmul.cpp Headings

AD Absolute Zero Multiplication: Example and Test
 

# include <cppad/cppad.hpp>
# include <cmath>

bool azmul(void)
{	bool ok = true;

	using CppAD::AD;
	using CppAD::NearEqual;
	double inf = std::numeric_limits<double>::infinity();
	double eps = 10. * std::numeric_limits<double>::epsilon();

	// domain space vector
	size_t n  = 2;
	double x = 0.5;
	double y = 2.0;
	CPPAD_TESTVECTOR(AD<double>) axy(n);
	axy[0]      = x;
	axy[1]      = y;

	// declare independent variables and start tape recording
	CppAD::Independent(axy);

	// range space vector
	size_t m = 5;
	CPPAD_TESTVECTOR(AD<double>) az(m);
	az[0] = CppAD::azmul(axy[0], axy[1]); // azmul(variable, variable)
	az[1] = CppAD::azmul(axy[0], inf);    // azmul(variable, parameter=inf)
	az[2] = CppAD::azmul(axy[0], 3.0);    // azmul(variable, parameter=3.0)
	az[3] = CppAD::azmul(0.0, axy[1]);    // azmul(parameter=0.0, variable)
	az[4] = CppAD::azmul(4.0, axy[1]);    // azmul(parameter=4.0, variable)

	// create f: axy -> az and stop tape recording
	CppAD::ADFun<double> f(axy, az);

	// check value when x is not zero
	ok &= NearEqual(az[0] , x * y,  eps, eps);
	ok &= az[1] == inf;
	ok &= NearEqual(az[2] , x * 3.0,  eps, eps);
	ok &= az[3] == 0.0;
	ok &= NearEqual(az[4] , 4.0 * y,  eps, eps);


	// check value x is zero and y is infinity
	CPPAD_TESTVECTOR(double) xy(n), z(m);
	xy[0] = 0.0;
	xy[1] = inf;
	z     = f.Forward(0, xy);
	ok &= z[0] == 0.0;
	ok &= z[1] == 0.0;
	ok &= z[2] == 0.0;
	ok &= z[3] == 0.0;
	ok &= z[4] == inf;

	return ok;
}


Input File: example/azmul.cpp cppad-20160000.1/doc/condexp.xml0000644000175200017650000004300412656322005015350 0ustar coincoin-web 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. There is one exception to this optimization; see optimizing nested conditional expressions .

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 = abs(x);
	AD<Base> ay = abs(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/local/cond_exp.hpp cppad-20160000.1/doc/discrete.xml0000644000175200017650000003441612656322005015521 0ustar coincoin-web 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/local/discrete.hpp cppad-20160000.1/doc/_discrete_xml.js0000644000175200017650000000432212656322005016345 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/atomic.xml0000644000175200017650000000561412656322005015171 0ustar coincoin-web Atomic AD Functions
Prev Next

Atomic AD Functions

Contents
checkpointCheckpointing Functions
atomic_baseUser Defined Atomic AD Functions

Input File: omh/atomic.omh cppad-20160000.1/doc/compare.xml0000644000175200017650000003260612656322005015344 0ustar coincoin-web 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/local/compare.hpp cppad-20160000.1/doc/interp_retape.cpp.xml0000644000175200017650000001502512656322005017334 0ustar coincoin-web 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;

	// 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, 1e-10, 1e-10);

		// 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, 1e-10, 1e-10);
	}
	return ok;
}


Input File: example/interp_retape.cpp cppad-20160000.1/doc/_interp_retape.cpp_xml.js0000644000175200017650000000332412656322005020166 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/numeric_limits.xml0000644000175200017650000003524212656322005016740 0ustar coincoin-web Numeric Limits For an AD and Base Types
Prev Next

Numeric Limits For an AD and Base Types

Syntax
eps = numeric_limits<Float>::epsilon()
min = numeric_limits<Float>::min()
max = numeric_limits<Float>::max()
nan = numeric_limits<Float>::quiet_NaN()

CppAD::numeric_limits
These functions and have the prototype
     static 
Float CppAD::numeric_limits<Float>::fun(void)
where fun is epsilon, min, max, and quiet_NaN.

std::numeric_limits
CppAD does not use a specialization of std::numeric_limits because this would be to restrictive. The C++ standard specifies that Non-fundamental standard types, such as std::complex<double> shall not have specializations of std::numeric_limits; see Section 18.2 of ISO/IEC 14882:1998(E). In addition, since C++11, a only literal types can have a specialization of std::numeric_limits.

Float
These functions are defined for all AD<Base> , and for all corresponding Base types; see Base type base_limits .

epsilon
The result eps is equal to machine epsilon and has prototype
     
Float eps
The file num_limits.cpp tests the value eps by checking that the following are true
     1 != 1 + 
eps
     1 == 1 + 
eps / 2
where all the values, and calculations, are done with the precision corresponding to Float .

min
The result min is equal to the minimum positive normalized value and has prototype
     
Float min
The file num_limits.cpp tests the value min by checking that the following are true
     abs( ((
min / 100) * 100) / min - 1 ) > 3 * eps
     abs( ((
min * 100) / 100) / min - 1 ) < 3 * eps
where all the values, and calculations, are done with the precision corresponding to Float .

max
The result max is equal to the maximum finite value and has prototype
     
Float max
The file num_limits.cpp tests the value max by checking that the following are true
     abs( ((
max * 100) / 100) / max - 1 ) > 3 * eps
     abs( ((
max / 100) * 100) / max - 1 ) < 3 * eps
where all the values, and calculations, are done with the precision corresponding to Float .

quiet_NaN
The result nan is not a number and has prototype
     
Float nan
The file num_limits.cpp tests the value nan by checking that the following is true
     
nan != nan

Example
The file num_limits.cpp contains an example and test of these functions.
Input File: cppad/local/numeric_limits.hpp cppad-20160000.1/doc/num_limits.cpp.xml0000644000175200017650000001052212656322005016650 0ustar coincoin-web Numeric Limits: Example and Test
Prev Next num_limits.cpp Headings

Numeric Limits: Example and Test
 

# ifdef _MSC_VER
// Supress Microsoft compiler warning about possible loss of precision,
// in the constructors (when converting to std::complex<float>)
//	Float one = 1
//	Float two = 2
// 1 and 2 are small enough so no loss of precision when converting to float.
# pragma warning(disable:4244)
# endif

# include <cppad/cppad.hpp>
# include <complex>

namespace {
	typedef CppAD::AD<double> Float;
	//
	// -----------------------------------------------------------------
	bool check_epsilon(void)
	{	bool ok    = true;
		Float eps   = CppAD::numeric_limits<Float>::epsilon();
		Float eps2  = eps / 2.0;
		Float check = 1.0 + eps;
		ok         &= 1.0 !=  check;
		check       = 1.0 + eps2;
		ok         &= 1.0 == check;
		return ok;
	}
	// -----------------------------------------------------------------
	bool check_min(void)
	{	bool ok     = true;
		Float min   = CppAD::numeric_limits<Float>::min();
		Float eps   = CppAD::numeric_limits<Float>::epsilon();
		//
		Float match = (min / 100.) * 100.;
		ok         &= abs(match / min - 1.0)  > 3.0 * eps;
		//
		match       = (min * 100.) / 100.;
		ok         &= abs(match / min - 1.0)  < 3.0 * eps;
		return ok;
	}
	// -----------------------------------------------------------------
	bool check_max(void)
	{	bool ok     = true;
		Float max   = CppAD::numeric_limits<Float>::max();
		Float eps   = CppAD::numeric_limits<Float>::epsilon();
		//
		Float match = (max * 100.) / 100.;
		ok         &= abs(match / max - 1.0) > 3.0 * eps;
		//
		match       = (max / 100.) * 100.;
		ok         &= abs(match / max - 1.0) < 3.0 * eps;
		return ok;
	}
	// -----------------------------------------------------------------
	bool check_nan(void)
	{	bool ok     = true;
		Float nan   = CppAD::numeric_limits<Float>::quiet_NaN();
		ok         &= nan != nan;
		return ok;
	}
}

bool num_limits(void)
{	bool ok = true;

	ok &= check_epsilon();
	ok &= check_min();
	ok &= check_max();
	ok &= check_nan();

	return ok;
}

Input File: example/num_limits.cpp cppad-20160000.1/doc/_atomic_xml.js0000644000175200017650000000351712656322005016024 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/checkpoint.cpp.xml0000644000175200017650000002361012656322005016621 0ustar coincoin-web 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 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 becasue f and g are only used once
		ok &= check_not.size_var() <=
			check_yes.size_var() + atom_f.size_var() + atom_g.size_var();

		// compare forward mode results for orders 0, 1, 2
		size_t q = 2;
		CPPAD_TESTVECTOR(double) x_q(n*(q+1)), z_not(m*(q+1)), z_yes(m*(q+1));
		for(j = 0; j < n; j++)
		{	for(k = 0; k <= q; k++)
				x_q[ j * (q+1) + k ] = 1.0 / (q + 1 - k);
		}
		z_not = check_not.Forward(q, x_q);
		z_yes = check_yes.Forward(q, x_q);
		for(i = 0; i < m; i++)
		{	for(k = 0; k <= q; k++)
			{	double zik_not = z_not[ i * (q+1) + k];
				double zik_yes = z_yes[ i * (q+1) + k];
				ok &= NearEqual(zik_not, zik_yes, eps, eps);
			}
		}

		// compare reverse mode results
		CPPAD_TESTVECTOR(double) w(m*(q+1)), dw_not(n*(q+1)), dw_yes(n*(q+1));
		dw_not = check_not.Reverse(q+1, w);
		dw_yes = check_yes.Reverse(q+1, w);
		for(j = 0; j < n; j++)
		{	for(k = 0; k <= q; k++)
			{	double dwjk_not = dw_not[ j * (q+1) + k];
				double dwjk_yes = dw_yes[ j * (q+1) + k];
				ok &= NearEqual(dwjk_not, dwjk_yes, eps, eps);
			}
		}

		// compare forward mode Jacobian sparsity patterns
		CppAD::vector< std::set<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 &= s_not[i] == s_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);
	ok &= test_case(pack_sparsity, bool_sparsity);
	ok &= test_case(bool_sparsity, set_sparsity);
	ok &= test_case(set_sparsity,  set_sparsity);

	return ok;
}

Input File: example/atomic/checkpoint.cpp cppad-20160000.1/doc/atomic_base.xml0000644000175200017650000004414612656322005016166 0ustar coincoin-web 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.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_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_sparsity.cppAtomic Sparsity Patterns: Example and Test
atomic_tangent.cppTan and Tanh as User Atomic Operations: Example and Test
atomic_hes_sparse.cppAtomic Operation Hessian Sparsity: 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_hes_sparse.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 cppad-20160000.1/doc/atomic_ctor.xml0000644000175200017650000003415612656322005016223 0ustar coincoin-web 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).

Examples

Define Constructor
The following are links to user atomic function constructor definitions: get_started.cpp , norm_sq.cpp , reciprocal.cpp , tangent.cpp , matrix_mul.hpp .

Use Constructor
The following are links to user atomic function constructor uses: get_started.cpp , norm_sq.cpp , reciprocal.cpp , tangent.cpp , mat_mul.cpp .
Input File: cppad/local/atomic_base.hpp cppad-20160000.1/doc/atomic_option.xml0000644000175200017650000002475112656322005016564 0ustar coincoin-web 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/local/atomic_base.hpp cppad-20160000.1/doc/atomic_afun.xml0000644000175200017650000002167012656322005016202 0ustar coincoin-web 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 , matrix_mul.cpp .
Input File: cppad/local/atomic_base.hpp cppad-20160000.1/doc/atomic_forward.xml0000644000175200017650000010606112656322005016713 0ustar coincoin-web Atomic Forward Mode
Prev Next atomic_forward

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(axayid)
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

Define forward
The following files contain example atomic forward functions: get_started.cpp , norm_sq.cpp , reciprocal.cpp , tangent.cpp , matrix_mul.hpp .

Use forward
The following are links to user atomic function forward uses: get_started.cpp , norm_sq.cpp , reciprocal.cpp , tangent.cpp , mat_mul.cpp .
Input File: cppad/local/atomic_base.hpp cppad-20160000.1/doc/atomic_reverse.xml0000644000175200017650000010314012656322005016715 0ustar coincoin-web Atomic Reverse Mode
Prev Next atomic_reverse

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, G, H
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 } ] 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 ) = i = 0 m -1 k = 0 q ( G / y i k ) ( y i k / x j ) = i = 0 m -1 k = q 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

Define reverse
The following files contain example atomic reverse functions: norm_sq.cpp , reciprocal.cpp , tangent.cpp , matrix_mul.hpp .

Use reverse
The following are links to user atomic function constructor uses: norm_sq.cpp , reciprocal.cpp , tangent.cpp , mat_mul.cpp .
Input File: cppad/local/atomic_base.hpp cppad-20160000.1/doc/atomic_rev_sparse_jac.xml0000644000175200017650000003034712656322005020240 0ustar coincoin-web Atomic Reverse Jacobian Sparsity Patterns
Prev Next atomic_rev_sparse_jac

Atomic Reverse Jacobian Sparsity Patterns

Syntax
ok = afun.rev_sparse_jac(qrtst)

Purpose
This function is used by RevSparseJac to compute Jacobian sparsity patterns. For a fixed matrix R B q × m , the Jacobian of R * f ( x ) with respect to x B q 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 , 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 .

ok
The return value ok has prototype
     bool 
ok
If it is true, the corresponding evaluation succeeded, otherwise it failed.

Examples

Define rev_sparse_jac
The following files contain example atomic rev_sparse_jac functions: norm_sq.cpp , reciprocal.cpp , tangent.cpp , matrix_mul.hpp .

Use rev_sparse_jac
The following are links to user atomic function constructor uses: norm_sq.cpp , reciprocal.cpp , tangent.cpp , mat_mul.cpp .
Input File: cppad/local/atomic_base.hpp cppad-20160000.1/doc/atomic_rev_sparse_hes.xml0000644000175200017650000006564112656322005020267 0ustar coincoin-web Atomic Reverse Hessian Sparsity Patterns
Prev Next atomic_rev_sparse_hes

Atomic Reverse Hessian Sparsity Patterns

Syntax
ok = afun.rev_sparse_hes(vxstqruv)

Purpose
This function is used by RevSparseHes to compute Hessian sparsity patterns. 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(axayid)

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 ) ( y ) 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 ] } u = 0 = u { g ( 1 ) [ y + f ( 1 ) ( x ) R u ] } u = 0 = g ( 2 ) ( y ) 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 ) ( y ) f ( 1 ) ( x ) R + i = 1 m g i ( 1 ) ( y ) f i ( 2 ) ( x ) R = f ( 1 ) ( x ) T U ( x ) + i = 1 m S i ( x ) f i ( 2 ) ( x ) R
Examples

Define rev_sparse_hes
The following files contain example atomic rev_sparse_hes functions: norm_sq.cpp , reciprocal.cpp , tangent.cpp , matrix_mul.hpp .

Use rev_sparse_hes
The following are links to user atomic function constructor uses: norm_sq.cpp , reciprocal.cpp , tangent.cpp , mat_mul.cpp .
Input File: cppad/local/atomic_base.hpp cppad-20160000.1/doc/atomic_base_clear.xml0000644000175200017650000001123112656322005017321 0ustar coincoin-web 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/local/atomic_base.hpp cppad-20160000.1/doc/_atomic_base_clear_xml.js0000644000175200017650000000411712656322005020161 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_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]; } cppad-20160000.1/doc/atomic_norm_sq.cpp.xml0000644000175200017650000004421612656322005017511 0ustar coincoin-web 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
     )
     {    size_t n = tx.size() / (q+1);
          size_t m = ty.size() / (q+1);
          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
     )
     {    size_t n = tx.size() / (q+1);
          size_t m = ty.size() / (q+1);
          assert( px.size() == n * (q+1) );
          assert( py.size() == m * (q+1) );
          assert( n == 2 );
          assert( m == 1 );
          bool ok = q <= 1;

          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 )
     {    // This function needed if using f.ForSparseJac
          size_t n = r.size() / p;
          size_t m = s.size() / p;
          assert( n == 2 );
          assert( m == 1 );

          // sparsity for S(x) = f'(x) * R
          // 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 )
     {    // This function needed if using RevSparseJac or optimize
          size_t n = st.size() / p;
          size_t m = rt.size() / p;
          assert( n == 2 );
          assert( m == 1 );

          // sparsity for S(x)^T = f'(x)^T * R^T
          // 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 )
     {    // This function needed if using RevSparseHes
          size_t m = s.size();
          size_t n = t.size();
          assert( r.size() == n * p );
          assert( u.size() == m * p );
          assert( v.size() == n * p );
          assert( n == 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 cppad-20160000.1/doc/atomic_reciprocal.cpp.xml0000644000175200017650000004564512656322005020165 0ustar coincoin-web 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.
void my_union(
     std::set<size_t>&         result  ,
     const std::set<size_t>&   left    ,
     const std::set<size_t>&   right   )
{    std::set<size_t> temp;
     std::set_union(
          left.begin()              ,
          left.end()                ,
          right.begin()             ,
          right.end()               ,
          std::inserter(temp, temp.begin())
     );
     result.swap(temp);
}
//
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
     )
     {    size_t n = tx.size() / (q + 1);
          size_t m = ty.size() / (q + 1);
          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
     )
     {    size_t n = tx.size() / (q + 1);
          size_t m = ty.size() / (q + 1);
          assert( px.size() == n * (q + 1) );
          assert( py.size() == m * (q + 1) );
          assert( n == 1 );
          assert( m == 1 );
          bool ok = q <= 2;

          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 )
     {    // This function needed if using f.ForSparseJac
          size_t n = r.size();
          size_t m = s.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 )
     {    // This function needed if using RevSparseJac or optimize
          size_t n = st.size();
          size_t m = rt.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 )
     {    // This function needed if using RevSparseHes
          size_t n = vx.size();
          size_t m = s.size();
          assert( t.size() == n );
          assert( r.size() == n );
          assert( u.size() == m );
          assert( v.size() == n );
          assert( n == 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] )
               my_union(v[0], 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 cppad-20160000.1/doc/atomic_sparsity.cpp.xml0000644000175200017650000003435512656322005017714 0ustar coincoin-web Atomic Sparsity Patterns: Example and Test
Prev Next atomic_sparsity.cpp

Atomic Sparsity Patterns: Example and Test

function
For this example, the atomic function f : R 3 R 2 is defined by f ( x 0 , x 1 , x 2 ) = ( x 2 x 0 * x 1 )
pack_sparsity_enum
This example only uses pack sparsity patterns.

Start Class Definition
 
# include <cppad/cppad.hpp>
namespace {                 // isolate items below to this file
using CppAD::vector;        // abbreviate as vector
using CppAD::vectorBool;    // abbreviate as vectorBool
//
class atomic_sparsity : public CppAD::atomic_base<double> {

Constructor
 
     public:
     // constructor
     atomic_sparsity(const std::string& name) :
     // this exampel only uses pack sparsity patterns
     CppAD::atomic_base<double>(name, pack_sparsity_enum )
     { }
     private:

forward
 
     // forward
     virtual bool forward(
          size_t                    p ,
          size_t                    q ,
          const vector<bool>&      vx ,
          vector<bool>&            vy ,
          const vector<double>&    tx ,
          vector<double>&          ty
     )
     {    size_t n = tx.size() / (q + 1);
          size_t m = ty.size() / (q + 1);
          assert( n == 3 );
          assert( m == 2 );

          // only order zero
          bool ok = q == 0;
          if( ! ok )
               return ok;

          // check for defining variable information
          if( vx.size() > 0 )
          {    ok   &= vx.size() == n;
               vy[0] = vx[2];
               vy[1] = vx[0] || vx[1];
          }

          // Order zero forward mode.
          // y[0] = x[2], y[1] = x[0] * x[1]
          if( p <= 0 )
          {    ty[0] = tx[2];
               ty[1] = tx[0] * tx[1];
          }
          return ok;
     }

for_sparse_jac
 
     // for_sparse_jac
     virtual bool for_sparse_jac(
          size_t                          p ,
          const vectorBool&               r ,
          vectorBool&                     s )
     {    // This function needed if using f.ForSparseJac
          size_t n = r.size() / p;
          size_t m = s.size() / p;
          assert( n == 3 );
          assert( m == 2 );

          // sparsity for S(x) = f'(x) * R  = [ 0,   0, 1 ] * R
          //                                  [ x1, x0, 0 ]
          for(size_t j = 0; j < p; j++)
          {    s[ 0 * p + j] = r[ 2 * p + j];
               s[ 1 * p + j] = r[ 0 * p + j] || r[ 1 * p + j];
          }
          return true;
     }

rev_sparse_jac
 
     virtual bool rev_sparse_jac(
          size_t                                p  ,
          const vectorBool&                     rt ,
          vectorBool&                           st )
     {    // This function needed if using RevSparseJac or optimize
          size_t n = st.size() / p;
          size_t m = rt.size() / p;
          assert( n == 3 );
          assert( m == 2 );

          //                                       [ 0, x1 ]
          // sparsity for S(x)^T = f'(x)^T * R^T = [ 0, x0 ] * R^T
          //                                       [ 1, 0  ]
          for(size_t j = 0; j < p; j++)
          {    st[ 0 * p + j ] = rt[ 1 * m + j ];
               st[ 1 * p + j ] = rt[ 1 * m + j ];
               st[ 2 * p + j ] = rt[ 0 * m + j ];
          }
          return true;
     }

rev_sparse_hes
 
     virtual bool rev_sparse_hes(
          const vector<bool>&                   vx,
          const vector<bool>&                   s ,
                vector<bool>&                   t ,
          size_t                                p ,
          const vectorBool&                     r ,
          const vectorBool&                     u ,
          vectorBool&                           v )
     {    // This function needed if using RevSparseHes
          size_t m = s.size();
          size_t n = t.size();
          assert( r.size() == n * p );
          assert( u.size() == m * p );
          assert( v.size() == n * p );
          assert( n == 3 );
          assert( m == 2 );

          // sparsity for T(x) = S(x) * f'(x) = S(x) * [  0,  0,  1 ]
          //                                           [ x1, x0,  0 ]
          t[0] = s[1];
          t[1] = s[1];
          t[2] = s[0];

          // V(x) = f'(x)^T * g''(y) * f'(x) * R  +  g'(y) * f''(x) * R
          // U(x) = g''(y) * f'(x) * R
          // S(x) = g'(y)

          //                               [ 0, x1 ]
          // sparsity for f'(x)^T * U(x) = [ 0, x0 ] * U(x)
          //                               [ 1, 0  ]
          size_t j;
          for(j = 0; j < p; j++)
          {    v[ 0 * p + j ] = u[ 1 * m + j ];
               v[ 1 * p + j ] = u[ 1 * m + j ];
               v[ 2 * p + j ] = u[ 0 * m + j ];
          }

          // include forward Jacobian sparsity in Hessian sparsity
          //                                                [ 0, 1, 0 ]
          // sum_i S_i (x) g'(y) * f_i''(x) * R = S_1 (x) * [ 1, 0, 0 ] * R
          //                                                [ 0, 0, 0 ]
          if( s[1] )
          {    for(j = 0; j < p; j++)
               {    v[ 0 * p + j ] = bool(v[0 * p + j]) | bool(r[1 * p + j]);
                    v[ 1 * p + j ] = bool(v[1 * p + j]) | bool(r[0 * p + j]);
               }
          }
          return true;
     }

End Class Definition
 
}; // End of atomic_sparsity class
}  // End empty namespace

Use Atomic Function
 
bool sparsity(void)
{    bool ok = true;
     using CppAD::AD;
     using CppAD::NearEqual;
     double eps = 10. * std::numeric_limits<double>::epsilon();

Constructor
 
     // Create the atomic get_started object
     atomic_sparsity afun("atomic_sparsity");

Recording
 
     size_t n = 3;
     size_t m = 2;
     vector< AD<double> > ax(n), ay(m);
     for(size_t j = 0; j < n; j++)
          ax[j] = double(j + 1);

     // declare independent variables and start tape recording
     CppAD::Independent(ax);

     // call user function
     afun(ax, ay);

     // create f: x -> y and stop tape recording
     CppAD::ADFun<double> f;
     f.Dependent (ax, ay);  // f(x) = x

     // check function value
     ok &= NearEqual(ay[0] , ax[2],  eps, eps);
     ok &= NearEqual(ay[1] , ax[0] * ax[1],  eps, eps);

forsparse_jac and rev_sparse_jac
 
     for(size_t dir = 0; dir < 2; dir++)
     {    size_t ell;
          if( dir == 0 )
               ell = n;
          else
               ell = m;

          // identity martrix
          vectorBool r(ell * ell);
          for(size_t i = 0; i < ell; i++)
               for(size_t j = 0; j < ell; j++)
                    r[i * ell + j] = (i == j);

          vectorBool s;
          if( dir == 0 )
               s = f.ForSparseJac(n, r);
          else
               s = f.RevSparseJac(m, r);

          // check Jacobian result
          ok  &= s.size() == m * n;
          ok  &= s[0 * n + 0] == false;
          ok  &= s[0 * n + 1] == false;
          ok  &= s[0 * n + 2] == true;
          ok  &= s[1 * n + 0] == true;
          ok  &= s[1 * n + 1] == true;
          ok  &= s[1 * n + 2] == false;
     }

rev_sparse_hes
 
     vectorBool s(m), h(n * n);
     s[0] = true;
     s[1] = true;
     h    = f.RevSparseHes(n, s);
     for(size_t i = 0; i < n; i++)
     {    for(size_t j = 0; j < n; j++)
          {    bool check = false;
               check     |= (i == 0) && (j == 1);
               check     |= (j == 0) && (i == 1);
               ok        &= h[ i * n + j] == check;
          }
     }
     //
     return ok;
}

Input File: example/atomic/sparsity.cpp cppad-20160000.1/doc/atomic_tangent.cpp.xml0000644000175200017650000005523612656322005017477 0ustar coincoin-web 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.
void my_union(
     std::set<size_t>&         result  ,
     const std::set<size_t>&   left    ,
     const std::set<size_t>&   right   )
{    std::set<size_t> temp;
     std::set_union(
          left.begin()              ,
          left.end()                ,
          right.begin()             ,
          right.end()               ,
          std::inserter(temp, temp.begin())
     );
     result.swap(temp);
}
//
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;
          size_t n  = tx.size()  / q1;
          size_t m  = tzy.size() / q1;
          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] = tanh( tx[0] );
               else tzy[0] = 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] * 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;
          size_t n  = tx.size()  / q1;
          size_t m  = tzy.size() / q1;
          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] * k * j_inv;

               // H_{y^{j-k)} += +- H_{z^{(j)} x^{(k)} * k / j
               for(k = 1; k <= j; k++)
                    qzy[q1 + j-k] += qzy[j] * tx[k] * k * j_inv;

               // 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 )
     {    size_t n = r.size() / p;
          size_t m = s.size() / p;
          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 )
     {    size_t n = r.size();
          size_t m = s.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 )
     {    size_t n = st.size() / p;
          size_t m = rt.size() / p;
          assert( n == 1 );
          assert( m == 2 );

          // 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 )
     {    size_t n = st.size();
          size_t m = rt.size();
          assert( n == 1 );
          assert( m == 2 );

          // sparsity for S(x)^T = f'(x)^T * R^T
          my_union(st[0], 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 )
     {
          size_t m = s.size();
          size_t n = t.size();
          assert( r.size() == n * p );
          assert( u.size() == m * p );
          assert( v.size() == n * p );
          assert( n == 1 );
          assert( m == 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 )
     {    size_t m = s.size();
          size_t n = t.size();
          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;
          my_union(v[0], 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] )
               my_union(v[0], 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 cppad-20160000.1/doc/atomic_hes_sparse.cpp.xml0000644000175200017650000003020012656322005020153 0ustar coincoin-web Atomic Operation Hessian Sparsity: Example and Test
Prev Next atomic_hes_sparse.cpp

Atomic Operation Hessian Sparsity: Example and Test

Purpose
This example demonstrates calculation of the Hessian sparsity pattern for an atomic operation.

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.
void my_union(
     std::set<size_t>&         result  ,
     const std::set<size_t>&   left    ,
     const std::set<size_t>&   right   )
{    std::set<size_t> temp;
     std::set_union(
          left.begin()              ,
          left.end()                ,
          right.begin()             ,
          right.end()               ,
          std::inserter(temp, temp.begin())
     );
     result.swap(temp);
}
//
class atomic_hes_sparse : public CppAD::atomic_base<double> {

Constructor
 
     public:
     // constructor (could use const char* for name)
     atomic_hes_sparse(const std::string& name) :
     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 n = tx.size() / (q + 1);
          size_t m = ty.size() / (q + 1);
          assert( n == 2 );
          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
          // y^0 = f( x^0 ) = [ x0_0 * x0_0  , x0_0 * x0_1 ]^T
          assert( p <= 0 );
          if( p <= 0 )
          {    ty[0] = tx[0] * tx[0];
               ty[1] = tx[0] * tx[1];
          }
          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 )
     {    // This function needed if using f.ForSparseJac
          // with afun.option( CppAD::atomic_base<double>::set_sparsity_enum )
          size_t n = r.size();
          size_t m = s.size();
          assert( n == 2 );
          assert( m == 2 );

          // sparsity for S(x) = f'(x) * R is union of rows of R
          s[0] = r[0];
          my_union(s[1], r[0], r[1]);

          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 )
     {    // This function needed if using RevSparseHes
          // with afun.option( CppAD::atomic_base<double>::set_sparsity_enum )
          size_t n = vx.size();
          size_t m = s.size();
          assert( t.size() == n );
          assert( r.size() == n );
          assert( u.size() == m );
          assert( v.size() == n );
          assert( n == 2 );
          assert( m == 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];
          t[1] = 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] = u[0];
          my_union(v[1], u[0], u[1]);

          // include forward Jacobian sparsity in Hessian sparsity
          // f_0''(x) * R
          if( s[0] )
               my_union(v[0], v[0], r[0] );
          // f_1''(x) * R
          if( s[1] )
          {    my_union(v[1], v[1], r[0] );
               my_union(v[0], v[0], r[1] );
          }
          return true;
     }
}; // End of atomic_hes_sparse class

Use Atomic Function
 
bool use_atomic_hes_sparse(bool x_1_variable)
{    bool ok = true;
     using CppAD::AD;
     using CppAD::NearEqual;
     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
     //
     // Create the atomic hes_sparse object
     atomic_hes_sparse afun("atomic_hes_sparse");
     //
     // Create the function f(u)
     //
     // domain space vector
     size_t n  = 2;
     double x0_0 = 0.75, x0_1 = 2.00;
     vector< AD<double> > au(n);
     au[0] = x0_0;
     au[1] = x0_1;

     // 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];
     if( x_1_variable )
          ax[1] = au[1];
     else
          ax[1] = x0_1;
     afun(ax, ay);        // y = [ x[0] * x[0] ,  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_y0_0 = x0_0 * x0_0;
     double check_y0_1 = x0_0 * x0_1;
     ok &= NearEqual( Value(ay[0]) , check_y0_0,  eps, eps);
     ok &= NearEqual( Value(ay[1]) , check_y0_1,  eps, eps);

     // check zero order forward mode
     size_t q;
     vector<double> uq(n), yq(m);
     q     = 0;
     uq[0] = x0_0;
     uq[1] = x0_1;
     yq    = f.Forward(q, uq);
     ok &= NearEqual(yq[0] , check_y0_0,  eps, eps);
     ok &= NearEqual(yq[1] , check_y0_1,  eps, eps);

     // forward sparse jacobian
     afun.option( CppAD::atomic_base<double>::set_sparsity_enum );
     vector< std::set<size_t> > r(2), jac_s(2), check_s(2);
     r[0].insert(0);
     r[1].insert(1);
     jac_s = f.ForSparseJac(n, r);
     check_s[0].insert(0);
     ok &= jac_s[0] == check_s[0];
     check_s[1].insert(0);
     if( x_1_variable )
          check_s[1].insert(1);
     ok &= jac_s[1] == check_s[1];

     // reverse sparse Hessian
     vector< std::set<size_t> > h(2), check_h(2), hes_s(1);
     hes_s[0].insert(0);
     hes_s[0].insert(1);
     h = f.RevSparseHes(n, hes_s);
     check_h[0].insert(0);
     if( x_1_variable )
          check_h[0].insert(1);
     ok &= h[0] == check_h[0];
     if( x_1_variable )
          check_h[1].insert(0);
     ok &= h[1] == check_h[1];

     return ok;
}
}  // End empty namespace

Test with x_1 Both a Variable and a Parameter
 
bool hes_sparse(void)
{    bool ok = true;
     // test with x_1 a variable
     ok     &= use_atomic_hes_sparse(true);
     // test with x_1 a parameter
     ok     &= use_atomic_hes_sparse(false);
     return ok;
}

Input File: example/atomic/hes_sparse.cpp cppad-20160000.1/doc/atomic_mat_mul.cpp.xml0000644000175200017650000003264212656322005017471 0ustar coincoin-web User Atomic Matrix Multiply: Example and Test
Prev Next

User Atomic Matrix Multiply: Example and Test

Class Definition
This example uses the file atomic_matrix_mul.hpp which defines matrix multiply as a atomic_base operation.

Use Atomic Function
 
# include <cppad/cppad.hpp>
# include <cppad/example/matrix_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
     size_t nr_result = 2;
     size_t n_middle  = 2;
     size_t nc_result = 2;
     matrix_mul afun(nr_result, n_middle, nc_result);

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] = j + 1;
     CppAD::Independent(ax);

     // ------------------------------------------------------------------
     vector< AD<double> > atom_x(nr_result * n_middle + n_middle * nc_result);

     // left matrix
     atom_x[0] = ax[0];  // left[0, 0] = x0
     atom_x[1] = ax[1];  // left[0, 1] = x1
     atom_x[2] = 5.;     // left[1, 0] = 5
     atom_x[3] = 6.;     // left[1, 1] = 6

     // right matix
     atom_x[4] = ax[2];  // right[0, 0] = x2
     atom_x[5] = 7.;     // right[0, 1] = 7
     atom_x[6] = ax[3];  // right[1, 0] = x3
     atom_x[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 ]
     */
     vector< AD<double> > atom_y(nr_result * nc_result);
     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] = 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] = 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 cppad-20160000.1/doc/atomic_matrix_mul.hpp.xml0000644000175200017650000006032612656322005020221 0ustar coincoin-web Matrix Multiply as an Atomic Operation
Prev Next atomic_matrix_mul.hpp

Matrix Multiply as an Atomic Operation

Start Class Definition
 
# include <cppad/cppad.hpp>
namespace { // Begin empty namespace
using CppAD::vector;
//
void my_union(
     std::set<size_t>&         result  ,
     const std::set<size_t>&   left    ,
     const std::set<size_t>&   right   )
{    std::set<size_t> temp;
     std::set_union(
          left.begin()              ,
          left.end()                ,
          right.begin()             ,
          right.end()               ,
          std::inserter(temp, temp.begin())
     );
     result.swap(temp);
}
//
// matrix result = left * right
class matrix_mul : public CppAD::atomic_base<double> {

Constructor
 
     private:
     // number of rows in left operand and in the result
     const size_t nr_result_;
     // number of columns in left operand and rows in right operand
     const size_t n_middle_;
     // number of columns in right operand and in the result
     const size_t nc_result_;
     // dimension of the domain space
     const size_t n_;
     // dimension of the range space
# ifndef NDEBUG
     const size_t m_;
# endif
     public:
     // ---------------------------------------------------------------------
     // constructor
     matrix_mul(size_t nr_result, size_t n_middle, size_t nc_result)
     : CppAD::atomic_base<double>("matrix_mul"),
     nr_result_(nr_result) ,
     n_middle_(n_middle)    ,
     nc_result_(nc_result) ,
     n_( nr_result * n_middle + n_middle * nc_result )
# ifndef NDEBUG
     , m_( n_middle * nc_result )
# endif
     { }
     private:

Left Operand Element Index
 
     // left matrix element index in the taylor coefficient vector tx.
     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
     {    assert( i < nr_result_ );
          assert( j < n_middle_ );
          return (i * n_middle_ + j) * nk + k;
     }

Right Operand Element Index
 
     // right matrix element index in the taylor coefficient vector tx.
     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
     {    assert( i < n_middle_  );
          assert( j < nc_result_ );
          size_t offset = nr_result_ * n_middle_;
          return (offset + i * nc_result_ + j) * nk + k;
     }

Result Element Index
 
     // result matrix element index in the taylor coefficient vector ty.
     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
     {    assert( i < nr_result_  );
          assert( j < nc_result_ );
          return (i * nc_result_ + j) * nk + k;
     }

Forward Matrix Multipliy
 
     // 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 nk       = tx.size() / n_;
          assert( nk == ty.size() / m_ );
          //
          size_t k_result = k_left + k_right;
          assert( k_result < nk );
          //
          for(size_t i = 0; i < nr_result_; i++)
          {    for(size_t j = 0; j < nc_result_; j++)
               {    double sum = 0.0;
                    for(size_t ell = 0; ell < n_middle_; ell++)
                    {    size_t i_left  = left(i, ell, k_left, nk);
                         size_t i_right = right(ell, j,  k_right, nk);
                         sum           += tx[i_left] * tx[i_right];
                    }
                    size_t i_result = result(i, j, k_result, nk);
                    ty[i_result]   += sum;
               }
          }
     }

Reverse Matrix Multipliy
 
     // 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 nk       = tx.size() / n_;
          assert( nk == ty.size() / m_ );
          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_result_; i++)
          {    for(size_t j = 0; j < nc_result_; j++)
               {    size_t i_result = result(i, j, k_result, nk);
                    for(size_t ell = 0; ell < n_middle_; ell++)
                    {    size_t i_left  = left(i, ell, k_left, nk);
                         size_t i_right = right(ell, j,  k_right, nk);
                         // 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
 
     // forward mode routine called by CppAD
     bool forward(
          size_t                    q ,
          size_t                    p ,
          const vector<bool>&      vx ,
                vector<bool>&      vy ,
          const vector<double>&    tx ,
                vector<double>&    ty
     )
     {    size_t p1 = p + 1;
          assert( vx.size() == 0 || n_ == vx.size() );
          assert( vx.size() == 0 || m_ == vy.size() );
          assert( n_ * p1 == tx.size() );
          assert( m_ * p1 == 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_result_; i++)
               {    for(j = 0; j < nc_result_; j++)
                    {    bool var = false;
                         for(ell = 0; ell < n_middle_; ell++)
                         {    size_t i_left  = left(i, ell, k, nk);
                              size_t i_right = right(ell, j, k, nk);
                              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);
                         vy[i_result] = var;
                    }
               }
          }

          // initialize result as zero
          size_t k;
          for(i = 0; i < nr_result_; i++)
          {    for(j = 0; j < nc_result_; j++)
               {    for(k = q; k <= p; k++)
                         ty[ result(i, j, k, p1) ] = 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);
          }

          // all orders are implented, so always return true
          return true;
     }

reverse
 
     // reverse mode routine called by CppAD
     virtual bool reverse(
          size_t                     p ,
          const vector<double>&     tx ,
          const vector<double>&     ty ,
                vector<double>&     px ,
          const vector<double>&     py
     )
     {    size_t p1 = p + 1;
          assert( n_ * p1 == tx.size() );
          assert( m_ * p1 == 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 = p1;
          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);
          }

          // all orders are implented, so always return true
          return true;
     }

for_sparse_jac
 
     // forward Jacobian sparsity routine called by CppAD
     virtual bool for_sparse_jac(
          size_t                                q ,
          const vector<bool>&                   r ,
                vector<bool>&                   s )
     {    assert( n_ * q == r.size() );
          assert( m_ * 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_result_; i++)
          {    for(size_t j = 0; j < nc_result_; j++)
               {    size_t i_result = result(i, j, k, nk);
                    for(p = 0; p < q; p++)
                         s[i_result * q + p] = false;
                    for(size_t ell = 0; ell < n_middle_; ell++)
                    {    size_t i_left  = left(i, ell, k, nk);
                         size_t i_right = right(ell, j, k, nk);
                         for(p = 0; p < q; p++)
                         {    // 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;
     }
     virtual bool for_sparse_jac(
          size_t                                q ,
          const vector< std::set<size_t> >&     r ,
                vector< std::set<size_t> >&     s )
     {    assert( n_ == r.size() );
          assert( m_ == s.size() );

          // sparsity for S(x) = f'(x) * R
          size_t nk = 1;
          size_t k  = 0;
          for(size_t i = 0; i < nr_result_; i++)
          {    for(size_t j = 0; j < nc_result_; j++)
               {    size_t i_result = result(i, j, k, nk);
                    s[i_result].clear();
                    for(size_t ell = 0; ell < n_middle_; ell++)
                    {    size_t i_left  = left(i, ell, k, nk);
                         size_t i_right = right(ell, j, k, nk);
                         //
                         my_union( s[i_result], s[i_result], r[i_left] );
                         my_union( s[i_result], s[i_result], r[i_right] );
                    }
               }
          }
          return true;
     }

rev_sparse_jac
 
     // reverse Jacobian sparsity routine called by CppAD
     virtual bool rev_sparse_jac(
          size_t                                q ,
          const vector<bool>&                  rt ,
                vector<bool>&                  st )
     {    assert( n_ * q == st.size() );
          assert( m_ * q == rt.size() );
          size_t i, j, p;

          // initialize
          for(i = 0; i < n_; 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_result_; i++)
          {    for(j = 0; j < nc_result_; j++)
               {    size_t i_result = result(i, j, k, nk);
                    for(size_t ell = 0; ell < n_middle_; ell++)
                    {    size_t i_left  = left(i, ell, k, nk);
                         size_t i_right = right(ell, j, k, nk);
                         for(p = 0; p < q; p++)
                         {    st[i_left * q + p] |= bool( rt[i_result * q + p] );
                              st[i_right* q + p] |= bool( rt[i_result * q + p] );
                         }
                    }
               }
          }
          return true;
     }
     virtual bool rev_sparse_jac(
          size_t                                q ,
          const vector< std::set<size_t> >&    rt ,
                vector< std::set<size_t> >&    st )
     {    assert( n_ == st.size() );
          assert( m_ == rt.size() );
          size_t i, j;

          // initialize
          for(i = 0; i < n_; 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_result_; i++)
          {    for(j = 0; j < nc_result_; j++)
               {    size_t i_result = result(i, j, k, nk);
                    for(size_t ell = 0; ell < n_middle_; ell++)
                    {    size_t i_left  = left(i, ell, k, nk);
                         size_t i_right = right(ell, j, k, nk);
                         //
                         my_union(st[i_left],  st[i_left],  rt[i_result]);
                         my_union(st[i_right], st[i_right], rt[i_result]);
                    }
               }
          }
          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 vector< std::set<size_t> >&     r ,
          const vector< std::set<size_t> >&     u ,
                vector< std::set<size_t> >&     v )
     {    size_t n = vx.size();
          assert( t.size() == n );
          assert( r.size() == n );
          assert( v.size() == n );
# ifndef NDEBUG
          size_t m = s.size();
          assert( u.size() == m );
# endif
          size_t i, j;
          //
          // initilaize sparsity patterns as false
          for(j = 0; j < n; j++)
          {    t[j] = false;
               v[j].clear();
          }
          size_t nk = 1;
          size_t k  = 0;
          for(i = 0; i < nr_result_; i++)
          {    for(j = 0; j < nc_result_; j++)
               {    size_t i_result = result(i, j, k, nk);
                    for(size_t ell = 0; ell < n_middle_; ell++)
                    {    size_t i_left  = left(i, ell, k, nk);
                         size_t i_right = right(ell, j, k, nk);
                         //
                         // 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)
                         my_union(v[i_left],  v[i_left],  u[i_result] );
                         my_union(v[i_right], 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] )
                         {    my_union(v[i_left],  v[i_left],  r[i_right] );
                              my_union(v[i_right], v[i_right], r[i_left]  );
                         }
                    }
               }
          }
          return true;
     }
     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 )
     {    size_t n = vx.size();
          assert( t.size() == n );
          assert( r.size() == n * q );
          assert( v.size() == n * q );
# ifndef NDEBUG
          size_t m = s.size();
          assert( u.size() == m * q );
# endif
          size_t i, j, p;
          //
          // initilaize sparsity patterns as false
          for(j = 0; j < n; 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_result_; i++)
          {    for(j = 0; j < nc_result_; j++)
               {    size_t i_result = result(i, j, k, nk);
                    for(size_t ell = 0; ell < n_middle_; ell++)
                    {    size_t i_left  = left(i, ell, k, nk);
                         size_t i_right = right(ell, j, k, nk);
                         //
                         // 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 matrix_mul class
}  // End empty namespace

Input File: cppad/example/matrix_mul.hpp cppad-20160000.1/doc/boolvalued.xml0000644000175200017650000000577112656322005016055 0ustar coincoin-web 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/local/bool_valued.hpp cppad-20160000.1/doc/_boolvalued_xml.js0000644000175200017650000000301512656322005016675 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_compare_xml.js0000644000175200017650000000367612656322005016204 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/compare.cpp.xml0000644000175200017650000001144012656322005016116 0ustar coincoin-web AD Binary Comparison Operators: Example and Test
Prev Next compare.cpp Headings

AD Binary Comparison Operators: Example and Test
 
# include <cppad/cppad.hpp>

bool Compare(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;

	// 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,  1e-10 , 1e-10);

	// 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, 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);
	ok   &= NearEqual(dw[1], 3.*x0*x0*x1*x1*x0, 1e-10, 1e-10);

	return ok;
}


Input File: example/compare.cpp cppad-20160000.1/doc/nearequalext.xml0000644000175200017650000003211612656322005016410 0ustar coincoin-web 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/local/near_equal_ext.hpp cppad-20160000.1/doc/boolfun.xml0000644000175200017650000003663312656322005015366 0ustar coincoin-web 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/local/bool_fun.hpp cppad-20160000.1/doc/_boolfun_xml.js0000644000175200017650000000410712656322005016210 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/bool_fun.cpp.xml0000644000175200017650000000661312656322005016301 0ustar coincoin-web AD Boolean Functions: Example and Test
Prev Next bool_fun.cpp Headings

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/bool_fun.cpp cppad-20160000.1/doc/parvar.xml0000644000175200017650000001506012656322005015204 0ustar coincoin-web 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/local/par_var.hpp cppad-20160000.1/doc/par_var.cpp.xml0000644000175200017650000000734312656322005016131 0ustar coincoin-web AD Parameter and Variable Functions: Example and Test
Prev Next par_var.cpp Headings

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] = abs(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/par_var.cpp cppad-20160000.1/doc/equalopseq.xml0000644000175200017650000002154112656322005016071 0ustar coincoin-web 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/local/equal_op_seq.hpp cppad-20160000.1/doc/equal_op_seq.cpp.xml0000644000175200017650000000662512656322005017156 0ustar coincoin-web EqualOpSeq: Example and Test
Prev Next equal_op_seq.cpp Headings

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/equal_op_seq.cpp cppad-20160000.1/doc/vecad.xml0000644000175200017650000007325312656322005015003 0ustar coincoin-web 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 computed 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 (Sparse ) 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/local/vec_ad.hpp cppad-20160000.1/doc/vec_ad.cpp.xml0000644000175200017650000002056012656322005015714 0ustar coincoin-web AD Vectors that Record Index Operations: Example and Test
Prev Next vec_ad.cpp Headings

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(abs(a[0]), abs(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;

	// 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,  1e-10 , 1e-10);
	ok &= NearEqual(Y[1] , num1 / den,  1e-10 , 1e-10);

	// 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, 1e-10, 1e-10);
	ok &= NearEqual(dy[1], b[1] / den - num1 * x[3] / dsq, 1e-10, 1e-10);

	// 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,  1e-10 , 1e-10);
	ok &= NearEqual(y[1] , num1 / den,  1e-10 , 1e-10);

	// forward computation of partials w.r.t. x[1]
	dx[0] = 0.; dx[1] = 1.;
	dx[2] = 0.; dx[3] = 0.;
	dy    = f.Forward(1, dx);
	ok   &= NearEqual(dy[0],-b[1] / den + num0 * x[2] / dsq, 1e-10, 1e-10);
	ok   &= NearEqual(dy[1], 0.         + num1 * x[2] / dsq, 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);
	ok  &= NearEqual(dw[1],-b[1] / den + num0 * x[2] / dsq, 1e-10, 1e-10);
	ok  &= NearEqual(dw[2], 0.         + num0 * x[1] / dsq, 1e-10, 1e-10);
	ok  &= NearEqual(dw[3], b[0] / den - num0 * x[0] / dsq, 1e-10, 1e-10);

	return ok;
}


Input File: example/vec_ad.cpp cppad-20160000.1/doc/base_require.xml0000644000175200017650000003065212656322005016363 0ustar coincoin-web 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_exampleExample AD Base Types That are not AD<OtherBase>

Input File: cppad/base_require.hpp cppad-20160000.1/doc/base_member.xml0000644000175200017650000002453412656322005016160 0ustar coincoin-web 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 cppad-20160000.1/doc/base_cond_exp.xml0000644000175200017650000004307112656322005016505 0ustar coincoin-web 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/local/base_cond_exp.hpp cppad-20160000.1/doc/base_identical.xml0000644000175200017650000004065212656322005016644 0ustar coincoin-web 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 cppad-20160000.1/doc/base_ordered.xml0000644000175200017650000002426412656322005016335 0ustar coincoin-web 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 cppad-20160000.1/doc/base_std_math.xml0000644000175200017650000005272712656322005016521 0ustar coincoin-web 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/local/base_std_math.hpp cppad-20160000.1/doc/base_limits.xml0000644000175200017650000001364012656322005016206 0ustar coincoin-web 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() ); }\
};

Input File: cppad/local/base_limits.hpp cppad-20160000.1/doc/base_to_string.xml0000644000175200017650000001142512656322005016714 0ustar coincoin-web 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;\
          Base epsilon    = CppAD::numeric_limits<Base>::epsilon();\
          Base log10      = CppAD::log( epsilon ) / CppAD::log(Base(10.));\
          size_t n_digits = 1 - Integer( log10 );\
          os << std::setprecision(n_digits);\
          os << value;\
          return os.str();\
     }\
};

Input File: cppad/local/base_to_string.hpp cppad-20160000.1/doc/base_example.xml0000644000175200017650000000756712656322005016353 0ustar coincoin-web 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 cppad-20160000.1/doc/base_alloc.hpp.xml0000644000175200017650000004277512656322005016600 0ustar coincoin-web 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>

Computed Assignment Macro
This macro is used for the base_alloc computed 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(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 its std name is fabs
 
namespace CppAD {
     inline base_alloc abs(const base_alloc& x)
     {    return std::fabs(*x.ptrdbl_); }
}

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)
}

Input File: example/base_alloc.hpp cppad-20160000.1/doc/base_require.cpp.xml0000644000175200017650000001166112656322005017143 0ustar coincoin-web 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
 
# 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/base_require.cpp cppad-20160000.1/doc/base_adolc.hpp.xml0000644000175200017650000003676412656322005016571 0ustar coincoin-web 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)
}

Input File: cppad/example/base_adolc.hpp cppad-20160000.1/doc/mul_level_adolc.cpp.xml0000644000175200017650000002705112656322005017623 0ustar coincoin-web 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
 
# 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/mul_level_adolc.cpp cppad-20160000.1/doc/base_float.hpp.xml0000644000175200017650000002526612656322005016607 0ustar coincoin-web 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 define the unary standard math functions required to use AD<float>: (in the CppAD namespace)
 
namespace CppAD {
     CPPAD_STANDARD_MATH_UNARY(float, acos)
     CPPAD_STANDARD_MATH_UNARY(float, asin)
     CPPAD_STANDARD_MATH_UNARY(float, atan)
     CPPAD_STANDARD_MATH_UNARY(float, cos)
     CPPAD_STANDARD_MATH_UNARY(float, cosh)
     CPPAD_STANDARD_MATH_UNARY(float, exp)
     CPPAD_STANDARD_MATH_UNARY(float, fabs)
     CPPAD_STANDARD_MATH_UNARY(float, log)
     CPPAD_STANDARD_MATH_UNARY(float, log10)
     CPPAD_STANDARD_MATH_UNARY(float, sin)
     CPPAD_STANDARD_MATH_UNARY(float, sinh)
     CPPAD_STANDARD_MATH_UNARY(float, sqrt)
     CPPAD_STANDARD_MATH_UNARY(float, tan)
     CPPAD_STANDARD_MATH_UNARY(float, tanh)
# if CPPAD_USE_CPLUSPLUS_2011
     CPPAD_STANDARD_MATH_UNARY(float, erf)
     CPPAD_STANDARD_MATH_UNARY(float, asinh)
     CPPAD_STANDARD_MATH_UNARY(float, acosh)
     CPPAD_STANDARD_MATH_UNARY(float, atanh)
     CPPAD_STANDARD_MATH_UNARY(float, expm1)
     CPPAD_STANDARD_MATH_UNARY(float, log1p)
# endif
}
The absolute value function is special because its 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>:
 
namespace CppAD {
     inline float pow(const float& x, const float& y)
     { return std::pow(x, y); }
}

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/local/base_float.hpp cppad-20160000.1/doc/base_double.hpp.xml0000644000175200017650000002532212656322005016745 0ustar coincoin-web 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 define the unary standard math functions required to use AD<double>:
 
namespace CppAD {
     CPPAD_STANDARD_MATH_UNARY(double, acos)
     CPPAD_STANDARD_MATH_UNARY(double, asin)
     CPPAD_STANDARD_MATH_UNARY(double, atan)
     CPPAD_STANDARD_MATH_UNARY(double, cos)
     CPPAD_STANDARD_MATH_UNARY(double, cosh)
     CPPAD_STANDARD_MATH_UNARY(double, exp)
     CPPAD_STANDARD_MATH_UNARY(double, fabs)
     CPPAD_STANDARD_MATH_UNARY(double, log)
     CPPAD_STANDARD_MATH_UNARY(double, log10)
     CPPAD_STANDARD_MATH_UNARY(double, sin)
     CPPAD_STANDARD_MATH_UNARY(double, sinh)
     CPPAD_STANDARD_MATH_UNARY(double, sqrt)
     CPPAD_STANDARD_MATH_UNARY(double, tan)
     CPPAD_STANDARD_MATH_UNARY(double, tanh)
# if CPPAD_USE_CPLUSPLUS_2011
     CPPAD_STANDARD_MATH_UNARY(double, erf)
     CPPAD_STANDARD_MATH_UNARY(double, asinh)
     CPPAD_STANDARD_MATH_UNARY(double, acosh)
     CPPAD_STANDARD_MATH_UNARY(double, atanh)
     CPPAD_STANDARD_MATH_UNARY(double, expm1)
     CPPAD_STANDARD_MATH_UNARY(double, log1p)
# endif
}
The absolute value function is special because its 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>:
 
namespace CppAD {
     inline double pow(const double& x, const double& y)
     { return std::pow(x, y); }
}

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/local/base_double.hpp cppad-20160000.1/doc/base_complex.hpp.xml0000644000175200017650000003460212656322005017143 0ustar coincoin-web 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/local/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(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/local/base_complex.hpp cppad-20160000.1/doc/complex_poly.cpp.xml0000644000175200017650000001050412656322005017202 0ustar coincoin-web Complex Polynomial: Example and Test
Prev Next complex_poly.cpp

Complex Polynomial: Example and Test

Poly
Select this link to view specifications for Poly :
 

# 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(i, 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/complex_poly.cpp cppad-20160000.1/doc/adfun.xml0000644000175200017650000001055512656322005015012 0ustar coincoin-web 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
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
FunEvalEvaluate ADFun Functions, Derivatives, and Sparsity Patterns
DriversFirst and Second Derivatives: Easy Drivers
FunCheckCheck an ADFun Sequence of Operations
optimizeOptimize an ADFun Object Tape
check_for_nanCheck an ADFun Object For Nan Results

Input File: cppad/local/ad_fun.hpp cppad-20160000.1/doc/independent.xml0000644000175200017650000002775212656322005016221 0ustar coincoin-web 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/local/independent.hpp cppad-20160000.1/doc/independent.cpp.xml0000644000175200017650000001325112656322005016767 0ustar coincoin-web Independent and ADFun Constructor: Example and Test
Prev Next independent.cpp Headings

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;

	// 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.,  1e-10 , 1e-10);
	ok &= NearEqual(Y[1] , 0.,  1e-10 , 1e-10);

	// 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.,  1e-10 , 1e-10);
	ok &= NearEqual(y[1] , 2.,  1e-10 , 1e-10);

	// 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.,  1e-10 , 1e-10);
	ok &= NearEqual(dy[1] , x[1],  1e-10 , 1e-10);

	// 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.,  1e-10 , 1e-10);
	ok &= NearEqual(dy[1] , x[0],  1e-10 , 1e-10);

	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/independent.cpp cppad-20160000.1/doc/funconstruct.xml0000644000175200017650000006016212656322005016451 0ustar coincoin-web 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/local/fun_construct.hpp cppad-20160000.1/doc/fun_assign.cpp.xml0000644000175200017650000001302012656322005016620 0ustar coincoin-web ADFun Assignment: Example and Test
Prev Next fun_assign.cpp Headings

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() == f.size_forward_bool() );
	ok &= ( g.size_forward_set()  == f.size_forward_set() );

	// 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/fun_assign.cpp cppad-20160000.1/doc/dependent.xml0000644000175200017650000003135412656322005015663 0ustar coincoin-web 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/local/dependent.hpp cppad-20160000.1/doc/abort_recording.xml0000644000175200017650000000753612656322005017065 0ustar coincoin-web 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/local/abort_recording.hpp cppad-20160000.1/doc/abort_recording.cpp.xml0000644000175200017650000001042512656322005017635 0ustar coincoin-web Abort Current Recording: Example and Test
Prev Next abort_recording.cpp Headings

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/abort_recording.cpp cppad-20160000.1/doc/seq_property.xml0000644000175200017650000005660212656322005016454 0ustar coincoin-web 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 .

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::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)
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 cppad-20160000.1/doc/seq_property.cpp.xml0000644000175200017650000001445312656322005017233 0ustar coincoin-web ADFun Sequence Properties: Example and Test
Prev Next seq_property.cpp Headings

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] becasue it is a parameter
	nvar  += 1;   // special variable for y[0] because it is a parameter
	narg  += 1;   // identifies which parameter corresponds to y[0]
	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::OpCode);
	sum += narg   * sizeof(CPPAD_TAPE_ADDR_TYPE);
	sum += npar   * sizeof(double);
	sum += ntext  * sizeof(char);
	sum += nvecad * sizeof(CPPAD_TAPE_ADDR_TYPE);
	ok &= f.size_op_seq() == sum;

	return ok;
}


Input File: example/seq_property.cpp cppad-20160000.1/doc/funeval.xml0000644000175200017650000000563412656322005015357 0ustar coincoin-web Evaluate ADFun Functions, Derivatives, and Sparsity Patterns
Prev Next

Evaluate ADFun Functions, Derivatives, and Sparsity Patterns

Contents
ForwardForward Mode
ReverseReverse Mode
SparseCalculating Sparsity Patterns

Input File: cppad/local/fun_eval.hpp cppad-20160000.1/doc/forward.xml0000644000175200017650000001017012656322005015352 0ustar coincoin-web 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/forward/forward.omh cppad-20160000.1/doc/forward_zero.xml0000644000175200017650000004155012656322005016417 0ustar coincoin-web 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 cppad-20160000.1/doc/forward_one.xml0000644000175200017650000004306512656322005016224 0ustar coincoin-web 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 cppad-20160000.1/doc/forward_two.xml0000644000175200017650000006304212656322005016251 0ustar coincoin-web 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 cppad-20160000.1/doc/forward_order.xml0000644000175200017650000010643112656322005016553 0ustar coincoin-web 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 cppad-20160000.1/doc/forward.cpp.xml0000644000175200017650000001177012656322005016142 0ustar coincoin-web Forward Mode: Example and Test
Prev Next forward.cpp Headings

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/forward.cpp cppad-20160000.1/doc/forward_order.cpp.xml0000644000175200017650000001074212656322006017334 0ustar coincoin-web Forward Mode: Example and Test of Multiple Orders
Prev Next forward_order.cpp Headings

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/forward_order.cpp cppad-20160000.1/doc/forward_dir.xml0000644000175200017650000010022012656322006016205 0ustar coincoin-web 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 ) ]
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 cppad-20160000.1/doc/forward_dir.cpp.xml0000644000175200017650000001220712656322006016775 0ustar coincoin-web Forward Mode: Example and Test of Multiple Directions
Prev Next forward_dir.cpp Headings

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/forward_dir.cpp cppad-20160000.1/doc/size_order.xml0000644000175200017650000002466212656322006016067 0ustar coincoin-web 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 cppad-20160000.1/doc/compare_change.xml0000644000175200017650000004347212656322006016655 0ustar coincoin-web 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 cppad-20160000.1/doc/compare_change.cpp.xml0000644000175200017650000001603412656322006017430 0ustar coincoin-web CompareChange and Re-Tape: Example and Test
Prev Next compare_change.cpp Headings

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();
		}
	}
	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/compare_change.cpp cppad-20160000.1/doc/capacity_order.xml0000644000175200017650000002742712656322006016714 0ustar coincoin-web 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/local/capacity_order.hpp cppad-20160000.1/doc/capacity_order.cpp.xml0000644000175200017650000001301512656322006017461 0ustar coincoin-web Controlling Taylor Coefficient Memory Allocation: Example and Test
Prev Next capacity_order.cpp Headings

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/capacity_order.cpp cppad-20160000.1/doc/number_skip.xml0000644000175200017650000001273212656322006016233 0ustar coincoin-web 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 . This leads to the fact that some terms only need to be evaluated depending on the value of the comparison in the conditional expression. The 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/local/num_skip.hpp cppad-20160000.1/doc/number_skip.cpp.xml0000644000175200017650000000755012656322006017016 0ustar coincoin-web Number of Variables That Can be Skipped: Example and Test
Prev Next number_skip.cpp Headings

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/number_skip.cpp cppad-20160000.1/doc/reverse.xml0000644000175200017650000000746612656322006015400 0ustar coincoin-web 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

Input File: omh/reverse/reverse.omh cppad-20160000.1/doc/reverse_one.xml0000644000175200017650000003156212656322006016233 0ustar coincoin-web 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 cppad-20160000.1/doc/reverse_one.cpp.xml0000644000175200017650000001121512656322006017005 0ustar coincoin-web First Order Reverse Mode: Example and Test
Prev Next reverse_one.cpp Headings

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;

	// 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 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.*X[0]*X[1], 1e-10, 1e-10);
	ok  &= NearEqual(dw[1] ,    X[0]*X[0], 1e-10, 1e-10);

	// 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], 1e-10, 1e-10);

	// 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], 1e-10, 1e-10);
	ok  &= NearEqual(dw[1] ,    x[0]*x[0], 1e-10, 1e-10);

	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/reverse_one.cpp cppad-20160000.1/doc/reverse_two.xml0000644000175200017650000007305312656322006016264 0ustar coincoin-web 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 cppad-20160000.1/doc/reverse_two.cpp.xml0000644000175200017650000001150012656322006017032 0ustar coincoin-web Second Order Reverse ModeExample and Test
Prev Next reverse_two.cpp Headings

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;

	// 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], 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	// 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], 1e-10, 1e-10);
	ok   &= NearEqual(dw[1*2+0] ,    x[0]*x[0], 1e-10, 1e-10);

	// check derivative of f^{(1)} (x) * dx
	check = 2.*x[1]*dx[1] + 2.*x[0]*dx[1];
	ok   &= NearEqual(dw[0*2+1] , check, 1e-10, 1e-10);
	check = 2.*x[0]*dx[1];
	ok   &= NearEqual(dw[1*2+1] , check, 1e-10, 1e-10);

	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/reverse_two.cpp cppad-20160000.1/doc/hes_times_dir.cpp.xml0000644000175200017650000001034012656322006017305 0ustar coincoin-web Hessian Times Direction: Example and Test
Prev Next hes_times_dir.cpp Headings

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;

	// 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], 1e-10, 1e-10);

	return ok;
}

Input File: example/hes_times_dir.cpp cppad-20160000.1/doc/reverse_any.xml0000644000175200017650000011346212656322006016241 0ustar coincoin-web 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_any.cpp contains an example and test of the general reverse mode case.

Input File: omh/reverse/reverse_any.omh cppad-20160000.1/doc/reverse_three.cpp.xml0000644000175200017650000002156012656322006017337 0ustar coincoin-web 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/reverse_three.cpp cppad-20160000.1/doc/reverse_any.cpp.xml0000644000175200017650000007110112656322006017013 0ustar coincoin-web Reverse Mode General Case: Example and Test
Prev Next reverse_any.cpp

Reverse Mode General Case: Example and Test

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/reverse_any.cpp cppad-20160000.1/doc/sparse.xml0000644000175200017650000000702212656322006015206 0ustar coincoin-web Calculating Sparsity Patterns
Prev Next

Calculating Sparsity Patterns

Contents
ForSparseJacJacobian Sparsity Pattern: Forward Mode
RevSparseJacJacobian Sparsity Pattern: Reverse Mode
dependency.cppComputing Dependency: Example and Test
RevSparseHesHessian Sparsity Pattern: Reverse Mode
bool_sparsity.cppUsing vectorBool Sparsity To Conserve Memory: Example and Test

Input File: cppad/local/sparse.hpp cppad-20160000.1/doc/forsparsejac.xml0000644000175200017650000006373512656322006016410 0ustar coincoin-web 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 s to the total number of elements in all the sets corresponding to the sparsity pattern stored in the function object f . 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 (unless the entire sparsity pattern is false). 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
the sparsity pattern is valid for all values of the independent variables in x B n (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/local/for_sparse_jac.hpp cppad-20160000.1/doc/for_sparse_jac.cpp.xml0000644000175200017650000002040412656322006017451 0ustar coincoin-web Forward Mode Jacobian Sparsity: Example and Test
Prev Next for_sparse_jac.cpp Headings

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/for_sparse_jac.cpp cppad-20160000.1/doc/revsparsejac.xml0000644000175200017650000004762512656322006016416 0ustar coincoin-web 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
the sparsity pattern is valid for all values of the independent variables in x B n (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/local/rev_sparse_jac.hpp cppad-20160000.1/doc/rev_sparse_jac.cpp.xml0000644000175200017650000001716712656322006017473 0ustar coincoin-web Reverse Mode Jacobian Sparsity: Example and Test
Prev Next rev_sparse_jac.cpp Headings

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/rev_sparse_jac.cpp cppad-20160000.1/doc/dependency.cpp.xml0000644000175200017650000002062412656322006016613 0ustar coincoin-web 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 matrices. The dependency argument to ForSparseJac and RevSparseJac is a flag that signals that the dependency pattern (instead of the sparsity pattern) is computed.
 
# include <cppad/cppad.hpp>
namespace {
	double heavyside(const double& x)
	{	if( x <= 0.0 )
			return 0.0;
		return 1.0;
	}
	CPPAD_DISCRETE_FUNCTION(double, heavyside)
}

bool dependency(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;

	// VecAD object for use later
	CppAD::VecAD<double> vec_ad(2);
	vec_ad[0] = 0.0;
	vec_ad[1] = 1.0;

	// domain space vector
	size_t n  = 5;
	CPPAD_TESTVECTOR(AD<double>) ax(n);
	for(size_t j = 0; j < n; j++)
		ax[j] = AD<double>(j + 1);

	// declare independent variables and start tape recording
	CppAD::Independent(ax);

	// some AD constants
	AD<double> azero(0.0), aone(1.0);

	// range space vector
	size_t m  = n;
	size_t m1 = n - 1;
	CPPAD_TESTVECTOR(AD<double>) ay(m);
	ay[m1-0] = sign( ax[0] );
	ay[m1-1] = CondExpLe( ax[1], azero, azero, aone);
	ay[m1-2] = CondExpLe( azero, ax[2], azero, aone);
	ay[m1-3] = heavyside( ax[3] );
	ay[m1-4] = vec_ad[ ax[4] - AD<double>(4.0) ];

	// create f: x -> y and stop tape recording
	CppAD::ADFun<double> f(ax, ay);

	// -----------------------------------------------------------
	// ForSparseJac and bool dependency
	bool transpose  = false;
	bool dependency;
	// could replace CppAD::vectorBooll by CPPAD_TEST_VECTOR<bool>
	CppAD::vectorBool eye_bool(n * n), depend_bool(m * n);
	for(size_t i = 0; i < n; i++)
	{	for(size_t j = 0; j < n; j++)
			eye_bool[i * n + j] = (i == j);
	}
	dependency = true;
	depend_bool = f.ForSparseJac(n, eye_bool, transpose, dependency);
	for(size_t i = 0; i < m; i++)
	{	for(size_t j = 0; j < n; j++)
			ok &= depend_bool[i * n + j] == (i == (m1-j));
	}
	dependency = false;
	depend_bool = f.ForSparseJac(n, eye_bool, transpose, dependency);
	for(size_t i = 0; i < m; i++)
	{	for(size_t j = 0; j < n; j++)
			ok &= depend_bool[i * n + j] == false;
	}

	// -----------------------------------------------------------
	// RevSparseJac and set dependency
	CppAD::vector<    std::set<size_t> > eye_set(m), depend_set(m);
	for(size_t i = 0; i < m; i++)
	{	ok &= eye_set[i].empty();
		eye_set[i].insert(i);
	}
	dependency = true;
	depend_set = f.RevSparseJac(n, eye_set, transpose, dependency);
	for(size_t i = 0; i < m; i++)
	{	std::set<size_t> check;
		check.insert(m1 - i);
		ok &= depend_set[i] == check;
	}
	dependency = false;
	depend_set = f.RevSparseJac(n, eye_set, transpose, dependency);
	for(size_t i = 0; i < m; i++)
		ok &= depend_set[i].empty();
	return ok;
}


Input File: example/dependency.cpp cppad-20160000.1/doc/revsparsehes.xml0000644000175200017650000006022212656322006016424 0ustar coincoin-web 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
the sparsity pattern is valid for all values of the independent variables in x R n (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/local/rev_sparse_hes.hpp cppad-20160000.1/doc/rev_sparse_hes.cpp.xml0000644000175200017650000001722312656322006017506 0ustar coincoin-web Reverse Mode Hessian Sparsity: Example and Test
Prev Next rev_sparse_hes.cpp Headings

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>) 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 = 2;
	CPPAD_TESTVECTOR(AD<double>) Y(m);
	Y[0] = sin( X[2] );
	Y[1] = X[0] * 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);
	}

	// 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>) 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 = 2;
	CPPAD_TESTVECTOR(AD<double>) Y(m);
	Y[0] = sin( X[2] );
	Y[1] = X[0] * 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);
	}

	// 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 RevSparseHes(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/rev_sparse_hes.cpp cppad-20160000.1/doc/sparsity_sub.cpp.xml0000644000175200017650000001275112656322006017226 0ustar coincoin-web 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/sparsity_sub.cpp cppad-20160000.1/doc/bool_sparsity.cpp.xml0000644000175200017650000001654412656322006017374 0ustar coincoin-web Using vectorBool Sparsity To Conserve Memory: Example and Test
Prev Next bool_sparsity.cpp

Using vectorBool Sparsity To Conserve Memory: Example and Test

Purpose
This example show how to conserve memory when computing sparsity patterns.
 
# include <cppad/cppad.hpp>
namespace {
	using CppAD::vector;
	using std::cout;
	using CppAD::vectorBool;
	using CppAD::AD;
	using CppAD::ADFun;

	// function f(x) that we are computing sparsity patterns for
	template <class Float>
	vector<Float> fun(const vector<Float>& x)
	{	size_t n  = x.size();
		vector<Float> ret(n + 1);
		for(size_t j = 0; j < n; j++)
		{	size_t k = (j + 1) % n;
			ret[j] = x[j] * x[j] * x[k];
		}
		ret[n] = 0.0;
		return ret;
	}
	// check sparsity pattern for f(x)
	bool check_jac(const vectorBool& pattern, size_t n)
	{	bool ok = true;
		for(size_t i = 0; i < n; i++)
		{	size_t k = (i + 1) % n;
			for(size_t j = 0; j < n; j++)
			{	bool non_zero = (i == j) || (j == k);
				ok &= pattern[ i * n + j] == non_zero;
			}
		}
		for(size_t j = 0; j < n; j++)
			ok &= pattern[ n * n + j] == false;
		return ok;
	}
	// check sparsity pattern for the Hessian of sum_i f_i(x)
	bool check_hes(const vectorBool& pattern, size_t n)
	{	bool ok = true;
		for(size_t i = 0; i < n; i++)
		{	size_t k1 = (i + 1) % n;
			size_t k2 = (n + i - 1) % n;
			for(size_t j = 0; j < n; j++)
			{	bool non_zero = (i == j) || (j == k1) || (j == k2);
				ok &= pattern[ i * n + j] == non_zero;
			}
		}
		return ok;
	}
	// compute sparsity for Jacobian of f(x) using forward mode
	bool for_sparse_jac(ADFun<double>& f)
	{	bool ok = true;
		size_t n = f.Domain();
		size_t m = f.Range();
		//
		// number of columns of the sparsity patter to compute at a time
		size_t n_col = vectorBool::bit_per_unit();
		vectorBool pattern(m * n), s(m * n_col), r(n * n_col);
		//
		size_t n_loop = (n - 1) / n_col + 1;
		for(size_t i_loop = 0; i_loop < n_loop; i_loop++)
		{	size_t j_col = i_loop * n_col;

			for(size_t i = 0; i < n; i++)
			{	for(size_t j = 0; j < n_col; j++)
					r[i * n_col + j] = (i == j_col + j);
			}
			s = f.ForSparseJac(n_col, r);
			for(size_t i = 0; i < m; i++)
			{	for(size_t j = 0; j < n_col; j++)
					if( j_col + j < n )
						pattern[ i * n + j_col + j ] = s[ i * n_col + j];
			}
		}
		ok &= check_jac(pattern, n);
		//
		return ok;
	}
	// compute sparsity for Jacobian of f(x) using reverse mode
	bool rev_sparse_jac(ADFun<double>& f)
	{	bool ok = true;
		size_t n = f.Domain();
		size_t m = f.Range();
		//
		// number of rows of the sparsity patter to compute at a time
		size_t n_row = vectorBool::bit_per_unit();
		vectorBool pattern(m * n), s(n_row * n), r(n_row * m);
		//
		size_t n_loop = (m - 1) / n_row + 1;
		for(size_t i_loop = 0; i_loop < n_loop; i_loop++)
		{	size_t i_row = i_loop * n_row;

			for(size_t i = 0; i < n_row; i++)
			{	for(size_t j = 0; j < m; j++)
					r[i * m + j] = (i_row + i == j);
			}
			s = f.RevSparseJac(n_row, r);
			for(size_t i = 0; i < n_row; i++)
			{	for(size_t j = 0; j < n; j++)
					if( i_row + i < m )
						pattern[ (i_row + i) * n + j ] = s[ i * n + j];
			}
		}
		ok &= check_jac(pattern, n);
		//
		return ok;
	}
	// compute sparsity for Hessian of sum_i f_i (x)
	bool rev_sparse_hes(ADFun<double>& f)
	{	bool ok = true;
		size_t n = f.Domain();
		size_t m = f.Range();
		//
		// number of columns of the sparsity patter to compute at a time
		size_t n_col = vectorBool::bit_per_unit();
		vectorBool pattern(n * n), r(n * n_col), h(n * n_col);

		// consider case where Hessian for sum of f_i(x) w.r.t i
		vectorBool s(m);
		for(size_t i = 0; i < m; i++)
			s[i] = true;
		//
		size_t n_loop = (n - 1) / n_col + 1;
		for(size_t i_loop = 0; i_loop < n_loop; i_loop++)
		{	size_t j_col = i_loop * n_col;

			for(size_t i = 0; i < n; i++)
			{	for(size_t j = 0; j < n_col; j++)
					r[i * n_col + j] = (i == j_col + j);
			}
			//
			f.ForSparseJac(n_col, r);
			bool transpose = true;
			h = f.RevSparseHes(n_col, s, transpose);
			//
			for(size_t i = 0; i < n; i++)
			{	for(size_t j = 0; j < n_col; j++)
					if( j_col + j < n )
						pattern[ i * n + j_col + j ] = h[ i * n_col + j];
			}
		}
		ok &= check_hes(pattern, n);
		//
		return ok;
	}
}
// driver for all of the cases above
bool bool_sparsity(void)
{	bool ok = true;
	//
	// record the funcion
	size_t n = 100;
	size_t m = n + 1;
	vector< AD<double> > x(n), y(m);
	for(size_t j = 0; j < n; j++)
		x[j] = AD<double>(j+1);
	CppAD::Independent(x);
	y = fun(x);
	ADFun<double> f(x, y);
	//
	// run the three example / tests
	ok &= for_sparse_jac(f);
	ok &= rev_sparse_jac(f);
	ok &= rev_sparse_hes(f);
	return ok;
}

Input File: example/bool_sparsity.cpp cppad-20160000.1/doc/drivers.xml0000644000175200017650000000732612656322006015376 0ustar coincoin-web First and Second Derivatives: Easy Drivers
Prev Next

First and Second Derivatives: Easy Drivers

Contents
JacobianJacobian: Driver Routine
ForOneFirst Order Partial Derivative: Driver Routine
RevOneFirst Order Derivative: Driver Routine
HessianHessian: Easy Driver
ForTwoForward Mode Second Partial Derivative Driver
RevTwoReverse Mode Second Partial Derivative Driver
sparse_jacobianSparse Jacobian: Easy Driver
sparse_hessianSparse Hessian: Easy Driver

Input File: cppad/local/drivers.hpp cppad-20160000.1/doc/jacobian.xml0000644000175200017650000002714112656322006015463 0ustar coincoin-web 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/local/jacobian.hpp cppad-20160000.1/doc/jacobian.cpp.xml0000644000175200017650000001170212656322006016240 0ustar coincoin-web Jacobian: Example and Test
Prev Next jacobian.cpp Headings

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;
	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], 1e-10, 1e-10 );
	ok &=  NearEqual( 2.*x[0]*sin(x[1]), jac[1*n+0], 1e-10, 1e-10 );
	ok &=  NearEqual( 2.*x[0]*cos(x[1]), jac[2*n+0], 1e-10, 1e-10 );

	ok &=  NearEqual( x[0] * x[0] *exp(x[1]), jac[0*n+1], 1e-10, 1e-10 );
	ok &=  NearEqual( x[0] * x[0] *cos(x[1]), jac[1*n+1], 1e-10, 1e-10 );
	ok &=  NearEqual(-x[0] * x[0] *sin(x[1]), jac[2*n+1], 1e-10, 1e-10 );

	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/jacobian.cpp cppad-20160000.1/doc/forone.xml0000644000175200017650000003315512656322006015207 0ustar coincoin-web 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/local/for_one.hpp cppad-20160000.1/doc/for_one.cpp.xml0000644000175200017650000001117612656322006016126 0ustar coincoin-web First Order Partial Driver: Example and Test
Prev Next for_one.cpp Headings

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;
	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]), 1e-10, 1e-10 ); // for y[0]
	ok &= NearEqual( dy[1], sin(x[1]), 1e-10, 1e-10 ); // for y[1]
	ok &= NearEqual( dy[2], cos(x[1]), 1e-10, 1e-10 ); // 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]), 1e-10, 1e-10 );
	ok &= NearEqual( dy[1],  x[0]*cos(x[1]), 1e-10, 1e-10 );
	ok &= NearEqual( dy[2], -x[0]*sin(x[1]), 1e-10, 1e-10 );

	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/for_one.cpp cppad-20160000.1/doc/revone.xml0000644000175200017650000003267312656322006015221 0ustar coincoin-web 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/local/rev_one.hpp cppad-20160000.1/doc/rev_one.cpp.xml0000644000175200017650000001132712656322006016132 0ustar coincoin-web First Order Derivative Driver: Example and Test
Prev Next rev_one.cpp Headings

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;
	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]), 1e-10, 1e-10 ); // w.r.t x[0]
	ok &= NearEqual(dw[1], x[0]*exp(x[1]), 1e-10, 1e-10 ); // w.r.t x[1]

	// compute and check derivative of y[1]
	dw  = f.RevOne(x, 1);
	ok &= NearEqual(dw[0],      sin(x[1]), 1e-10, 1e-10 );
	ok &= NearEqual(dw[1], x[0]*cos(x[1]), 1e-10, 1e-10 );

	// compute and check derivative of y[2]
	dw  = f.RevOne(x, 2);
	ok &= NearEqual(dw[0],        cos(x[1]), 1e-10, 1e-10 );
	ok &= NearEqual(dw[1], - x[0]*sin(x[1]), 1e-10, 1e-10 );

	return ok;
}
} // End empty namespace
# 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/rev_one.cpp cppad-20160000.1/doc/hessian.xml0000644000175200017650000003740012656322006015346 0ustar coincoin-web 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/local/hessian.hpp cppad-20160000.1/doc/hessian.cpp.xml0000644000175200017650000001140412656322006016123 0ustar coincoin-web Hessian: Example and Test
Prev Next hessian.cpp Headings

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;
	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], 1e-10, 1e-10 );
	ok &=  NearEqual(     2.*x[0]*cos(x[1]), hes[0*n+1], 1e-10, 1e-10 );
	ok &=  NearEqual(     2.*x[0]*cos(x[1]), hes[1*n+0], 1e-10, 1e-10 );
	ok &=  NearEqual( - x[0]*x[0]*sin(x[1]), hes[1*n+1], 1e-10, 1e-10 );

	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/hessian.cpp cppad-20160000.1/doc/hes_lagrangian.cpp.xml0000644000175200017650000002232412656322006017436 0ustar coincoin-web Hessian of Lagrangian and ADFun Default Constructor: Example and Test
Prev Next hes_lagrangian.cpp Headings

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;
		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, 1e-10, 1e-10);
		// L_01 = L_10 = 0
		ok &= NearEqual(H[0 * n + 1], 0., 1e-10, 1e-10);
		ok &= NearEqual(H[1 * n + 0], 0., 1e-10, 1e-10);
		// L_02 = L_20 = 0
		ok &= NearEqual(H[0 * n + 2], 0., 1e-10, 1e-10);
		ok &= NearEqual(H[2 * n + 0], 0., 1e-10, 1e-10);
		// L_11 = 0
		ok &= NearEqual(H[1 * n + 1], 0., 1e-10, 1e-10);
		// L_12 = L_21 = 0
		ok &= NearEqual(H[1 * n + 2], 0., 1e-10, 1e-10);
		ok &= NearEqual(H[2 * n + 1], 0., 1e-10, 1e-10);
		// L_22 = - y1 / (x2 * x2)
		check = - y1 / (x2 * x2);
		ok &= NearEqual(H[2 * n + 2], check, 1e-10, 1e-10);

		return ok;
	}
	bool UseL()
	{	using CppAD::AD;
		using CppAD::vector;

		// double values corresponding to XYZ vector
		double x0(.5), x1(1e3), x2(1), y0(2.), y1(3.), z(4.);

		// domain space vector
		size_t n = 3;
		vector< AD<double> >  XYZ(n);
		XYZ[0] = x0;
		XYZ[1] = x1;
		XYZ[2] = x2;

		// declare X as independent variable vector and start recording
		CppAD::Independent(XYZ);

		// add the Lagragian multipliers to XYZ
		// (note that this modifies the vector XYZ)
		XYZ.push_back(y0);
		XYZ.push_back(y1);
		XYZ.push_back(z);

		// range space vector
		size_t m = 1;
		vector< AD<double> >  L(m);
		L[0] = Lagragian(XYZ);

		// create K: X -> L and stop tape recording
		// We cannot use the ADFun sequence constructor because XYZ has
		// changed between the call to Independent and here.
		CppAD::ADFun<double> K;
		K.Dependent(L);

		// Operation sequence corresponding to K does depends on
		// value of y0, y1, and z. Must redo calculations above when
		// y0, y1, or z changes.

		// declare independent variable vector and Hessian
		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> >  X(n);
		X[0] = x0;
		X[1] = x1;
		X[2] = x2;

		// declare X as independent variable vector and start recording
		CppAD::Independent(X);

		// range space vector
		size_t m = 3;
		vector< AD<double> >  FG(m);
		FG = fg(X);

		// create K: X -> FG and stop tape recording
		CppAD::ADFun<double> K;
		K.Dependent(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/hes_lagrangian.cpp cppad-20160000.1/doc/fortwo.xml0000644000175200017650000004257412656322006015244 0ustar coincoin-web 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/local/for_two.hpp cppad-20160000.1/doc/for_two.cpp.xml0000644000175200017650000001317712656322006016161 0ustar coincoin-web Subset of Second Order Partials: Example and Test
Prev Next for_two.cpp Headings

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;
	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], 1e-10, 1e-10 );
	ok &=  NearEqual( 2.*sin(x[1]), ddy[1*p+0], 1e-10, 1e-10 );
	ok &=  NearEqual( 2.*cos(x[1]), ddy[2*p+0], 1e-10, 1e-10 );

	// second partial of F w.r.t x[0] and x[1]
	ok &=  NearEqual( 2.*x[0]*exp(x[1]), ddy[0*p+1], 1e-10, 1e-10 );
	ok &=  NearEqual( 2.*x[0]*cos(x[1]), ddy[1*p+1], 1e-10, 1e-10 );
	ok &=  NearEqual(-2.*x[0]*sin(x[1]), ddy[2*p+1], 1e-10, 1e-10 );

	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/for_two.cpp cppad-20160000.1/doc/revtwo.xml0000644000175200017650000004313412656322006015243 0ustar coincoin-web 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/local/rev_two.hpp cppad-20160000.1/doc/rev_two.cpp.xml0000644000175200017650000001272212656322006016162 0ustar coincoin-web Second Partials Reverse Driver: Example and Test
Prev Next rev_two.cpp Headings

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;
	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], 1e-10, 1e-10 );
	ok &=  NearEqual( 2.*x[0]*exp(x[1]), ddw[1*p+0], 1e-10, 1e-10 );

	// partials of y[1] w.r.t x[1] is x[0] * x[0] * cos(x[1])
	// check partials of F_1 w.r.t x[1] and x[k] for k = 0, 1
	ok &=  NearEqual(    2.*x[0]*cos(x[1]), ddw[0*p+1], 1e-10, 1e-10 );
	ok &=  NearEqual( -x[0]*x[0]*sin(x[1]), ddw[1*p+1], 1e-10, 1e-10 );

	return ok;
}
} // End empty namespace
# 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/rev_two.cpp cppad-20160000.1/doc/sparse_jacobian.xml0000644000175200017650000010001112656322006017024 0ustar coincoin-web Sparse Jacobian: Easy Driver
Prev Next

Sparse Jacobian: Easy Driver

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/local/sparse_jacobian.hpp cppad-20160000.1/doc/sparse_jacobian.cpp.xml0000644000175200017650000002316212656322006017620 0ustar coincoin-web Sparse Jacobian: Example and Test
Prev Next sparse_jacobian.cpp Headings

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_jacobian.cpp cppad-20160000.1/doc/sparse_hessian.xml0000644000175200017650000010516412656322006016726 0ustar coincoin-web Sparse Hessian: Easy Driver
Prev Next

Sparse Hessian: Easy Driver

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 ) .

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 . 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 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.star"
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.

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 routines sub_sparse_hes.cpp and sparse_sub_hes.cpp are examples and tests that compute a sparse Hessian for a subset of the variables. They return true, if they succeed and false otherwise.
Input File: cppad/local/sparse_hessian.hpp cppad-20160000.1/doc/sparse_hessian.cpp.xml0000644000175200017650000001605312656322006017505 0ustar coincoin-web Sparse Hessian: Example and Test
Prev Next sparse_hessian.cpp Headings

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_hessian.cpp cppad-20160000.1/doc/sub_sparse_hes.cpp.xml0000644000175200017650000002226712656322006017507 0ustar coincoin-web 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/sub_sparse_hes.cpp cppad-20160000.1/doc/sparse_sub_hes.cpp.xml0000644000175200017650000001360212656322006017500 0ustar coincoin-web Sparse Hessian on Subset of Variables: Example and Test
Prev Next sparse_sub_hes.cpp

Sparse Hessian on Subset of Variables: Example and Test

Purpose
This example uses a subset of the sparsity pattern, to compute the Hessian for a subset of the variables, without having to compute the sparsity pattern for the entire function.

See Also
sub_sparse_hes.cpp
 
# include <cppad/cppad.hpp>
bool sparse_sub_hes(void)
{	bool ok = true;
	using CppAD::AD;
	typedef CppAD::vector< double >                   d_vector;
	typedef CppAD::vector< AD<double> >               a_vector;
	typedef CppAD::vector<size_t>                     i_vector;
	typedef CppAD::vector< std::set<size_t> >         s_vector;

	// domain space vector
	size_t n = 12;  // must be greater than or equal 3; see n_sweep below
	a_vector a_x(n);
	for(size_t j = 0; j < n; j++)
		a_x[j] = AD<double> (0);

	// declare independent variables and starting recording
	CppAD::Independent(a_x);

	// range space vector
	size_t m = 1;
	a_vector a_y(m);
	a_y[0] = 0.0;
	for(size_t j = 1; j < n; j++)
		a_y[0] += a_x[j-1] * a_x[j] * a_x[j];

	// create f: x -> y and stop tape recording
	// (without executing zero order forward calculation)
	CppAD::ADFun<double> f;
	f.Dependent(a_x, a_y);

	// sparsity patteren for the sub-set of variables we are computing
	// the hessian w.r.t.
	size_t n_sub = 4;
	s_vector r(n);
	for(size_t j = 0; j < n_sub; j++)
	{	assert(  r[j].empty() );
		r[j].insert(j);
	}

	// store forward sparsity for J(x) = F^{(1)} (x) * R
	f.ForSparseJac(n_sub, r);

	// compute sparsity pattern for H(x) = (S * F)^{(2)} ( x ) * R
	s_vector s(1);
	assert(  s[0].empty() );
	s[0].insert(0);
	bool transpose = true;
	s_vector h = f.RevSparseHes(n_sub, s, transpose);

	// check sparsity pattern
	for(size_t i = 0; i < n; i++)
	{	std::set<size_t> check;
		assert( check.empty() );
		if( i <= n_sub )
		{	if( i == 0 )
				check.insert(1);
			else
			{	check.insert(i-1);
				if( i < n_sub )
					check.insert(i);
				if( i + 1 < n_sub)
					check.insert(i+1);
			}
		}
		ok &= h[i] == check;
	}

	// set the row and column indices that correspond to lower triangle
	i_vector row, col;
	for(size_t i = 0; i < n_sub; i++)
	{	std::set<size_t>::iterator itr;
		for(itr = h[i].begin(); itr != h[i].end(); itr++)
		{	if( *itr <= i )
			{	row.push_back( i );
				col.push_back( *itr );
			}
		}
	}

	// weighting for the Hessian
	d_vector w(1);
	w[0] = 1.0;

	// compute Hessian
	CppAD::sparse_hessian_work work;
	d_vector x(n), hes( row.size() );
	for(size_t j = 0; j < n; j++)
		x[j] = double(j+1);
	f.SparseHessian(x, w, h, row, col, hes, work);

	// check the values in the sparse hessian
	for(size_t ell = 0; ell < row.size(); ell++)
	{	size_t i = row[ell];
		size_t j = col[ell];
		if( i == j )
			ok &= hes[ell] == 2.0 * x[i-1];
		else
		{	ok &= j+1 == i;
			ok &= hes[ell] == 2.0 * x[i];
		}
		ell++;
	}
	return ok;
}

Input File: example/sparse_sub_hes.cpp cppad-20160000.1/doc/funcheck.xml0000644000175200017650000005670612656322006015514 0ustar coincoin-web 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/local/fun_check.hpp cppad-20160000.1/doc/fun_check.cpp.xml0000644000175200017650000001355412656322006016426 0ustar coincoin-web ADFun Check and Re-Tape: Example and Test
Prev Next fun_check.cpp Headings

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;

	// 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 = 1e-10;
	double a = 1e-10;
	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/fun_check.cpp cppad-20160000.1/doc/optimize.xml0000644000175200017650000002743112656322006015557 0ustar coincoin-web Optimize an ADFun Object Tape
Prev Next

Optimize an ADFun Object Tape

Syntax
f.optimize()

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

Improvements
You can see the reduction in number of variables in the operation sequence by calling the function f.size_var() before and after the optimization procedure. Given that the optimization procedure takes time, it may be faster to skip this optimize procedure and just compute derivatives using the original operation sequence.

Testing
You can run the CppAD speed tests and see the corresponding changes in number of variables and execution time; see cmake_check .

Efficiency
The optimize member function may greatly reduce the number of variables in the operation sequence; see size_var . 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 .

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() .

Example
The file optimize.cpp contains an example and test of this operation. It returns true if it succeeds and false otherwise.
Input File: cppad/local/optimize.hpp cppad-20160000.1/doc/optimize.cpp.xml0000644000175200017650000001302612656322006016333 0ustar coincoin-web ADFun Operation Sequence Optimization: Example and Test
Prev Next optimize.cpp Headings

ADFun Operation Sequence Optimization: Example and Test
 
# include <cppad/cppad.hpp>
namespace {
	template <class VectorFloat> void fun(
		const VectorFloat& x, VectorFloat& y, size_t& n_var, size_t& n_opt )
	{	typedef typename VectorFloat::value_type Float;

		// One for each independent variable and one phantom variable at
		// the beginning of operation sequence.
		n_var = 1 + x.size();

		// One operator for each independent variable and one to mark
		// beginning of operation sequence.
		n_opt = 1 + x.size();

		// Create a variable that is is only used in the comparision operation
		// (was optimized out until 2015-01-12).
		Float a = 1. / x[0];
		n_var += 1;
		n_opt += 1;

		// Create a variable that is used by the result
		Float b = x[0] * 5.;
		n_var += 1;
		n_opt += 1;

		// only one variable created for this comparison operation
		// but the value depends on which branch is taken.
		Float c;
		if( a < x[0] )
			c = 2.0 * b;
		else
			c = 3.0 * b;
		n_var += 1;
		n_opt += 1;

		// Create a variable that is optimized out because it
		// will always have the same value as b
		Float d = 5. * x[0];
		n_var += 1;
		n_opt += 0;

		// Create three variables that will be converted to one
		// cumulative summation. Note that a is not connected to
		// the result y (in the operation sequence).
		y[0]   = 1.0 + b + c + d;
		n_var += 3;
		n_opt += 1;
	}
}

bool optimize(void)
{	bool ok = true;
	using CppAD::AD;

	// domain space vector
	size_t n  = 1;
	CPPAD_TESTVECTOR(AD<double>) ax(n);
	ax[0] = 0.5;

	// declare independent variables and start tape recording
	CppAD::Independent(ax);

	// range space vector
	size_t m = 1;
	CPPAD_TESTVECTOR(AD<double>) ay(m);
	size_t n_var, n_opt;
	fun(ax, ay, n_var, n_opt);

	// create f: x -> y and stop tape recording
	CppAD::ADFun<double> f(ax, ay);
	ok &= (f.size_var() == n_var);

	// Optimize the operation sequence
	f.optimize();
	ok &= (f.size_var() == n_opt);

	// Check result for a zero order calculation for a different x,
	// where the result of the comparison is he same.
	CPPAD_TESTVECTOR(double) x(n), y(m), check(m);
	x[0] = 0.75;
	y    = f.Forward(0, x);
	ok  &= f.CompareChange() == 0;
	fun(x, check, n_var, n_opt);
	ok  &= (y[0] == check[0]);

	// Check case where result of the comparision is differnent
	x[0] = 2.0;
	y    = f.Forward(0, x);
	ok  &= f.CompareChange() == 1;
	fun(x, check, n_var, n_opt);
	ok &= (y[0] != check[0]);

	// re-tape at new x value, re-optimize, and re-evaluate forward
	ax[0] = x[0];
	CppAD::Independent(ax);
	fun(ax, ay, n_var, n_opt);
	f.Dependent(ax, ay);
	f.optimize();
	y   = f.Forward(0, x);
	ok &= f.CompareChange() == 0;
	ok &= (y[0] == check[0]);

	return ok;
}


Input File: example/optimize.cpp cppad-20160000.1/doc/check_for_nan.xml0000644000175200017650000003031712656322006016473 0ustar coincoin-web 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/local/check_for_nan.hpp cppad-20160000.1/doc/check_for_nan.cpp.xml0000644000175200017650000001212512656322006017251 0ustar coincoin-web ADFun Checking For Nan: Example and Test
Prev Next check_for_nan.cpp Headings

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 varialbe index that is nan
		pattern = "index = ";
		start   = msg.find(pattern) + pattern.size();
		number  = "";
		for(size_t i = start; msg[i] != '\n'; i++)
			number += msg[i];
		size_t index = std::atoi(number.c_str());
		ok &= index == 1;

		// get the name of the file
		pattern = "file_name = ";
		start   = msg.find(pattern) + pattern.size();
		string file_name;
		for(size_t i = start; msg[i] != '\n'; i++)
			file_name += msg[i];

		// get and check independent variable vector that resulted in the nan
		CppAD::vector<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/check_for_nan.cpp cppad-20160000.1/doc/preprocessor.xml0000644000175200017650000001675212656322006016451 0ustar coincoin-web CppAD API Preprocessor Symbols
Prev Next preprocessor

CppAD API Preprocessor Symbols

Purpose
The CppAD include files define 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_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 cppad-20160000.1/doc/multi_thread.xml0000644000175200017650000001625312656322006016400 0ustar coincoin-web 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 cppad-20160000.1/doc/parallel_ad.xml0000644000175200017650000001516512656322006016160 0ustar coincoin-web 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/local/parallel_ad.hpp cppad-20160000.1/doc/thread_test.cpp.xml0000644000175200017650000005507112656322006017007 0ustar coincoin-web Run Multi-Threading Examples and Speed Tests
Prev Next

Run Multi-Threading Examples and Speed Tests

Syntax
./multi_thread_threading a11c
./multi_thread_
threading simple_ad
./multi_thread_
threading team_example
./multi_thread_
threading harmonic test_time max_threads mega_sum
./multi_thread_
threading multi_newton test_time max_threads \
     
num_zero num_sub num_sum use_ad

Running Tests
You can build this program and run the default version of its test parameters by executing the following commands:
     cd multi_thread
     make test
After this operation you can run the syntax above for the different valid values of threading :

threading
If the cmake command output indicates that openmp is supported by your system, you can execute the syntax above with threading equal to openmp.

If the cmake command output indicates that pthreads with barriers is supported by your system, you can execute the syntax above with threading equal to pthread.

If the cmake command output indicates that boost threads is supported is by your system, you can execute the syntax above with threading equal to bthread.

Purpose
Runs the CppAD multi-threading examples and timing tests:

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.cpp 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.cpp .

multi_newton
The multi_newton_time.cpp 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.cpp .

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.cpp .

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.cpp .

use_ad
The command line argument use_ad is either true or false and has the same meaning as in multi_newton_time.cpp .

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_time.hpp"
# include "multi_newton_time.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_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_newton = std::strcmp(test_name, "multi_newton") == 0;
	if( run_a11c || run_simple_ad || run_team_example )
		ok = (argc == 2);
	else if( run_harmonic )
		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
	if( run_harmonic )
	{	// mega_sum
		mega_sum = arg2size_t( *++argv, 1,
			"run: mega_sum 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
	size_t num_threads, inuse_this_thread = 0;
	cout << "time_all  = [" << endl;
	for(num_threads = 0; num_threads <= max_threads; num_threads++)
	{	double time_out;

		// set the number of threads
		if( num_threads > 0 )
			ok &= team_create(num_threads);

		// ammount of memory initialy inuse by thread zero
		ok &= 0 == thread_alloc::thread_num();
		inuse_this_thread = thread_alloc::inuse(0);

		// run the requested test
		if( run_harmonic ) ok &=
			harmonic_time(time_out, test_time, num_threads, mega_sum);
		else
		{	ok &= run_multi_newton;
			ok &= multi_newton_time(
				time_out                ,
				test_time               ,
				num_threads             ,
				num_zero                ,
				num_sub                 ,
				num_sum                 ,
				use_ad
			);
		}

		// set back to one thread and fee all avaialable memory
		if( num_threads > 0 )
			ok &= team_destroy();
		size_t thread;
		for(thread = 0; thread < num_threads; thread++)
		{	thread_alloc::free_available(thread);
			if( thread == 0 )
				ok &= thread_alloc::inuse(thread) == inuse_this_thread;
			else	ok &= thread_alloc::inuse(thread) == 0;
		}
		cout << "\t" << time_out << " % ";
		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: multi_thread/thread_test.cpp cppad-20160000.1/doc/a11c_openmp.cpp.xml0000644000175200017650000001010712656322006016573 0ustar coincoin-web 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: multi_thread/openmp/a11c_openmp.cpp cppad-20160000.1/doc/a11c_bthread.cpp.xml0000644000175200017650000001175512656322006016720 0ustar coincoin-web A Simple Boost Thread Example and Test
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.0;
			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. * 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: multi_thread/bthread/a11c_bthread.cpp cppad-20160000.1/doc/a11c_pthread.cpp.xml0000644000175200017650000001276412656322006016737 0ustar coincoin-web 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.0;
		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. * 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: multi_thread/pthread/a11c_pthread.cpp cppad-20160000.1/doc/simple_ad_bthread.cpp.xml0000644000175200017650000002541012656322006020121 0ustar coincoin-web 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: multi_thread/bthread/simple_ad_bthread.cpp cppad-20160000.1/doc/simple_ad_pthread.cpp.xml0000644000175200017650000002771212656322006020146 0ustar coincoin-web 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: multi_thread/pthread/simple_ad_pthread.cpp cppad-20160000.1/doc/team_example.cpp.xml0000644000175200017650000001627212656322006017142 0ustar coincoin-web 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 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: multi_thread/team_example.cpp cppad-20160000.1/doc/_team_example.cpp_xml.js0000644000175200017650000000365612656322006017777 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/harmonic.cpp.xml0000644000175200017650000001727612656322006016306 0ustar coincoin-web Multi-Threaded Implementation of Summation of 1/i
Prev Next

Multi-Threaded Implementation of Summation of 1/i

Syntax
ok = harmonic(sumnum_sumnum_threads)

Summation
Multi-threaded computation of the summation that defines the harmonic series s = 1 + 1 / 2 + 1 / 3 + . . . + 1 / n
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 .

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 a multi-threading environment.

Contents
harmonic_time.cppTiming Test of Multi-Threaded Summation of 1/i
harmonic_work.cppMulti-threading Sum of 1/i Utility Routines

Source
 
// general purpose multi-threading interface
# include "team_thread.hpp"
// special utilities for the harmonic problem
# include "harmonic_work.hpp"

bool harmonic(double& sum, size_t num_sum, size_t num_threads)
{	// sum = 1/num_sum + 1/(num_sum-1) + ... + 1
	bool ok = true;

	// setup the work for num_threads_ threads
	ok &= harmonic_setup(num_sum, num_threads);

	// now do the work for each thread
	if( num_threads > 0 )
		team_work( harmonic_worker );
	else	harmonic_worker();

	// now combine the result for all the threads
	ok &= harmonic_combine(sum);

	return ok;
}

Input File: multi_thread/harmonic.cpp cppad-20160000.1/doc/harmonic_time.cpp.xml0000644000175200017650000002376312656322006017322 0ustar coincoin-web Timing Test of Multi-Threaded Summation of 1/i
Prev Next harmonic_time.cpp

Timing Test of Multi-Threaded Summation of 1/i

Syntax
ok = harmonic_time(time_outnum_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 This routine must be called in sequential execution mode, even though in_parallel may return true.

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 == CppAD::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 = CppAD::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 <omp.h>
# include <cstring>
# include <limits>
# include <vector>
# 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>
# include "harmonic.hpp"

namespace { // empty namespace

	// value of num_threads in previous call to harmonic_time.
	size_t num_threads_;

	// value of mega_sum in previous call to harmonic_time.
	size_t mega_sum_;

	// 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_, num_sum, num_threads_);
		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;
	}
} // end empty namespace

bool harmonic_time(
	double& time_out, double test_time, size_t num_threads, size_t mega_sum)
{	bool ok  = true;
	using std::vector;

	// arguments passed to harmonic_time
	num_threads_ = num_threads;
	mega_sum_    = mega_sum;

	// convert zero to actual number of threads
	num_threads  = std::max(num_threads_, size_t(1));

	// expect number of threads to already be set up
	ok &= num_threads == CppAD::thread_alloc::num_threads();

	// run the test case and set the time return value
	time_out = CppAD::time_test(test_repeat, test_time);

	// Correctness check
	double eps   = 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) <= eps;

	return ok;
}


Input File: multi_thread/harmonic_time.cpp cppad-20160000.1/doc/harmonic_work.cpp.xml0000644000175200017650000002510512656322006017336 0ustar coincoin-web Multi-threading Sum of 1/i Utility Routines
Prev Next harmonic_work.cpp

Multi-threading Sum of 1/i Utility Routines

Syntax
ok = harmonic_setup(num_sumnum_threads)
harmonic_worker()
ok = harmonic_combine(sum)

Purpose
These routines aid in the multi-threading computation of the summation that defines the harmonic series 1 + 1 / 2 + 1 / 3 + . . . + 1 / n
harmonic_setup
Calling this function splits up the computation of the summation into different parts for each thread.

num_sum
The argument num_sum has prototype
     size_t 
num_sum
It specifies the value of n in the summation.

num_threads
The argument num_threads has prototype
     size_t 
num_threads
It specifies the number of threads that will be used for the summation. In the special case where num_thread is zero, the summation should be done by one thread, but without the overhead of the multi_threading system.

harmonic_worker
Calling this function does the computation for one thread. Following a call to harmonic_setup, this function should be called by each of the num_threads threads.

harmonic_combine
After the num_threads threads have completed their calls to harmonic_worker, this function call will combine the results and return the final summation.

Source
 
# include <cppad/cppad.hpp>
# include "harmonic_work.hpp"
# define MAX_NUMBER_THREADS 48

namespace {
	using CppAD::thread_alloc;

	// number of threads specified by previous call to harmonic_setup
	size_t num_threads_ = 0;

	// structure with information for one thread
	typedef struct {
		// index to start summation at (worker input)
		size_t start;
		// index to end summation at (worker input)
		size_t stop;
		// summation for this thread (worker output)
		double sum;
		// 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_[MAX_NUMBER_THREADS];
}
// -----------------------------------------------------------------------
// do the work for one thread
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;
}
// -----------------------------------------------------------------------
// setup the work up for multiple threads
bool harmonic_setup(size_t num_sum, size_t num_threads)
{	// sum = 1/num_sum + 1/(num_sum-1) + ... + 1
	num_threads_ = num_threads;
	num_threads  = std::max(num_threads_, size_t(1));
	bool ok      = num_threads == thread_alloc::num_threads();
	ok          &= num_sum >= num_threads;

	size_t thread_num;
	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);
		// 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;
}
// -----------------------------------------------------------------------
// get the result of the work
bool harmonic_combine(double& sum)
{	// sum = 1/num_sum + 1/(num_sum-1) + ... + 1
	bool ok            = true;
	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: multi_thread/harmonic_work.cpp cppad-20160000.1/doc/multi_newton.cpp.xml0000644000175200017650000005065512656322006017230 0ustar coincoin-web A Multi-Threaded Newton's Method
Prev Next

A Multi-Threaded Newton's Method

Syntax
ok = multi_newton(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 .

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
     CppAD::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.

Contents
multi_newton_time.cppTiming Test of Multi-Threaded Newton Method
multi_newton_work.cppMulti-threading Newton Method Utility Routines

Source
 
// general purpose multi-threading interface
# include "team_thread.hpp"
// special utilities for the multi_newton problem
# include "multi_newton_work.hpp"

bool multi_newton(
	CppAD::vector<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;
	using CppAD::AD;
	using CppAD::vector;

	// setup the work for num_threads threads
	ok &= multi_newton_setup(
		fun, 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 result for all the threads
	ok &= multi_newton_combine(xout);

	return ok;
}

Input File: multi_thread/multi_newton.cpp cppad-20160000.1/doc/multi_newton_work.cpp.xml0000644000175200017650000006477312656322006020300 0ustar coincoin-web Multi-threading Newton Method Utility Routines
Prev Next multi_newton_work.cpp

Multi-threading Newton Method Utility Routines

Syntax
ok = multi_newton_setup(
     
funnum_subxlowxupepsilonmax_itrnum_threads
)
multi_newton_worker()
ok = multi_newton_combine(xout)

Purpose
These routines aid in the computation of multiple zeros of a function f : [ a , b ] R .

multi_newton_setup
Calling this functions splits up the computation of the zeros into different sub-intervals for each thread.

fun
The argument fun has prototype
     void 
fun (double x, double& f, double& df)
This argument must evaluate the function f ( x ) , and its derivative f ( 1 ) ( x ) , using the syntax
     
fun(xfdf)
where the arguments 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 in to split the calculation into.

xlow
The argument xlow has prototype
     double 
xlow
It specifies the lower limit for the entire search; i.e., a .

xup
The argument xup has prototype
     double 
xup
It specifies the upper limit for the entire search; 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 | f ( x ) | ε .

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.

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.

multi_newton_worker
Calling this function does the computation for one thread. Following a call to multi_newton_setup, this function should be called by each of the num_threads threads.

multi_newton_combine
After the num_threads threads have completed their calls to multi_newton_worker, this function call will combine the results and return the final set of approximate zeros for f ( x ) .

xout
The argument xout has the prototype
     CppAD::vector<double>& 
xout
The input size and value of the elements of xout do not matter. Upon return from multi_newton_combine, the size of xout is less than or equal n and
     | 
fxout[i] ) | <= epsilon
for each valid index i . In addition, the elements of xout are in ascending order and
     
xout[i+1] - xout[i] >=  0.5 * (xup - xlow) / num_sub

Source
 
# include <cppad/cppad.hpp>
# include "multi_newton_work.hpp"

# define USE_THREAD_ALLOC_FOR_WORK_ALL 1

namespace {
	using CppAD::thread_alloc;

	// This vector template class frees all memory when resized to zero.
	// In addition, its memory allocation works well during multi-threading.
	using CppAD::vector;

	// number of threads in previous call to multi_newton_setup
	size_t num_threads_ = 0;
	// convergence criteria in previous call to multi_newton_setup
	double epsilon_ = 0.;
	// maximum number of iterations in previous call to multi_newton_setup
	size_t max_itr_ = 0;
	// length for all sub-intervals
	double sub_length_ = 0.;
	// function we are finding zeros of in previous call to multi_newton_setup
	void (*fun_)(double x, double& f, double& df) = 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_combine: 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_combine: work_all.size() == 0
	// (use pointers instead of values to avoid false sharing)
	vector<work_one_t*> work_all_;
}
// -----------------------------------------------------------------------
// do the work for one thread
void multi_newton_worker(void)
{	using CppAD::vector;

	// 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 * sub_length_; // over sub_length_ away from x_low
	double flast = 2 * 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 + i * sub_length_;

		// note that when i == num_sub - 1, xup_i = xup (exactly)
		double xup_i  = xup  - (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;
}
// -----------------------------------------------------------------------
// setup the work up for multiple threads
bool multi_newton_setup(
	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                          )
{
	num_threads_ = num_threads;
	num_threads  = std::max(num_threads_, size_t(1));
	bool ok      = num_threads == thread_alloc::num_threads();

	// inputs that are same for all threads
	epsilon_ = epsilon;
	max_itr_ = max_itr;
	fun_     = fun;

	// 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 CppAD::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 + sum_num * sub_length_;

		// when thread_num == num_threads - 1, xup_thread = xup
		double xup_thread = xlow + (sum_num + num_sub_thread) * sub_length_;
		if( thread_num == num_threads - 1 )
			xup_thread = xup;

		// 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;
}
// -----------------------------------------------------------------------
// get the result of the work
bool multi_newton_combine(CppAD::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;
	size_t thread_num;

	// initialize as more that sub_lenght_ / 2 from any possible solution
	double xlast = - sub_length_;
	for(thread_num = 0; thread_num < num_threads; thread_num++)
	{	vector<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];
				}
			}
		}
		ok &= work_all_[thread_num]->ok;
	}

	// go down so free memory for other threads before memory for master
	thread_num = num_threads;
	while(thread_num--)
	{
# if USE_THREAD_ALLOC_FOR_WORK_ALL
		// call the destructor for CppAD::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
	// (becasue it is a static variable)
	work_all_.clear();

	return ok;
}

Input File: multi_thread/multi_newton_work.cpp cppad-20160000.1/doc/team_thread.hpp.xml0000644000175200017650000002621312656322006016757 0ustar coincoin-web 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-Threaded Implementation of Summation of 1/i
multi_newton.cpp A Multi-Threaded Newton's Method

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: multi_thread/team_thread.hpp cppad-20160000.1/doc/_team_thread.hpp_xml.js0000644000175200017650000000451012656322006017606 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/team_openmp.cpp.xml0000644000175200017650000001100312656322006016770 0ustar coincoin-web OpenMP Implementation of a Team of AD Threads
Prev Next team_openmp.cpp Headings

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(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: multi_thread/openmp/team_openmp.cpp cppad-20160000.1/doc/team_bthread.cpp.xml0000644000175200017650000002425712656322006017122 0ustar coincoin-web Boost Thread Implementation of a Team of AD Threads
Prev Next team_bthread.cpp Headings

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(num_threads);
	wait_for_job_  = new boost::barrier(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: multi_thread/bthread/team_bthread.cpp cppad-20160000.1/doc/team_pthread.cpp.xml0000644000175200017650000003155112656322006017133 0ustar coincoin-web 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, num_threads
	);
	ok &= (rc == 0);
	rc  = pthread_barrier_init(
		&wait_for_job_, no_barrierattr, num_threads
	);
	ok &= (rc == 0);

	// structure used to create the threads
	pthread_t       pthread_id;
	// default for pthread_attr_setdetachstate is PTHREAD_CREATE_JOINABLE
	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: multi_thread/pthread/team_pthread.cpp cppad-20160000.1/doc/utility.xml0000644000175200017650000002124312656322006015415 0ustar coincoin-web 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

C++ Concepts
We refer to a the set of classes that satisfy certain conditions as a C++ concept. The following concepts are used by the CppAD Template library:
NumericType Definition of a Numeric Type
CheckNumericType Check NumericType Class Concept
SimpleVector Definition of a Simple Vector
CheckSimpleVector Check Simple Vector Concept

General Numerical Routines
The routines listed below are general purpose numerical routines written with the floating point type a C++ template parameter. This enables them to be used with algorithmic differentiation types, as well as for other purposes.
nan Obtain Nan or Determine if a Value is Nan
pow_int The Integer Power Function
Poly Evaluate a Polynomial or its Derivative
LuDetAndSolve Compute Determinants and Solve Equations by LU Factorization
RombergOne One DimensionalRomberg Integration
RombergMul Multi-dimensional Romberg Integration
Runge45 An Embedded 4th and 5th Order Runge-Kutta ODE Solver
Rosen34 A 3rd and 4th Order Rosenbrock ODE Solver
OdeErrControl An Error Controller for ODE Solvers
OdeGear An Arbitrary Order Gear Method
OdeGearControl An Error Controller for Gear's Ode Solvers

Miscellaneous

Error Handler
All of the routines in the CppAD namespace use the following general purpose error handler:
ErrorHandler Replacing the CppAD Error Handler

Simple Vector Template Class
A simple implementation of a template vector class (that is easy to view in a C++ debugger):
CppAD_vector The CppAD::vector Template Class

Multi-Threading Memory Allocation
thread_alloc A Fast Multi-Threading Memory Allocator

Sorting Indices
index_sort Returns Indices that Sort a Vector

to_string
to_string Convert Certain Types to a String

Input File: omh/utility.omh cppad-20160000.1/doc/errorhandler.xml0000644000175200017650000002777612656322006016422 0ustar coincoin-web 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 cppad-20160000.1/doc/error_handler.cpp.xml0000644000175200017650000001026712656322006017325 0ustar coincoin-web Replacing The CppAD Error Handler: Example and Test
Prev Next error_handler.cpp Headings

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/error_handler.cpp cppad-20160000.1/doc/cppad_assert.xml0000644000175200017650000001560312656322006016365 0ustar coincoin-web 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/local/cppad_assert.hpp cppad-20160000.1/doc/nearequal.xml0000644000175200017650000003052612656322006015673 0ustar coincoin-web 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 cppad-20160000.1/doc/near_equal.cpp.xml0000644000175200017650000001157312656322006016614 0ustar coincoin-web 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/near_equal.cpp cppad-20160000.1/doc/speed_test.xml0000644000175200017650000003034712656322006016056 0ustar coincoin-web 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 cppad-20160000.1/doc/speed_test.cpp.xml0000644000175200017650000001023112656322006016625 0ustar coincoin-web speed_test: Example and test
Prev Next speed_test.cpp Headings

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] = i;
			b[i] = 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 cppad-20160000.1/doc/_nan_xml.js0000644000175200017650000000424512656322006015324 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/speedtest.xml0000644000175200017650000003374112656322006015720 0ustar coincoin-web 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 cppad-20160000.1/doc/time_test.xml0000644000175200017650000002756012656322006015717 0ustar coincoin-web 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 cppad-20160000.1/doc/elapsed_seconds.xml0000644000175200017650000001225312656322006017046 0ustar coincoin-web 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::high_resolution_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 cppad-20160000.1/doc/elapsed_seconds.cpp.xml0000644000175200017650000000653212656322006017632 0ustar coincoin-web Elapsed Seconds: Example and Test
Prev Next elapsed_seconds.cpp Headings

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 cppad-20160000.1/doc/time_test.cpp.xml0000644000175200017650000001010712656322006016465 0ustar coincoin-web time_test: Example and test
Prev Next time_test.cpp Headings

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] = i;
			b[i] = 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 cppad-20160000.1/doc/numerictype.xml0000644000175200017650000003721112656322006016260 0ustar coincoin-web 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 computed assignment addition unspecified
z -= y computed assignment subtraction unspecified
z *= y computed assignment multiplication unspecified
z /= y computed 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 cppad-20160000.1/doc/numeric_type.cpp.xml0000644000175200017650000001154412656322006017201 0ustar coincoin-web The NumericType: Example and Test
Prev Next numeric_type.cpp Headings

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;
		}
		// computed assignment addition
		void operator += (const MyType &x)
		{	d += x.d; }
		// computed assignment subtraction
		void operator -= (const MyType &x)
		{	d -= x.d; }
		// computed assignment multiplication
		void operator *= (const MyType &x)
		{	d *= x.d; }
		// computed 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/numeric_type.cpp cppad-20160000.1/doc/checknumerictype.xml0000644000175200017650000001250712656322006017257 0ustar coincoin-web 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 cppad-20160000.1/doc/check_numeric_type.cpp.xml0000644000175200017650000001472612656322006020343 0ustar coincoin-web The CheckNumericType Function: Example and Test
Prev Next check_numeric_type.cpp Headings

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
		// computed assignment addition
		void operator += (const MyType &x)
		{	d += x.d; }
# endif
# if CppADMyTypeOmit != 8
		// computed assignment subtraction
		void operator -= (const MyType &x)
		{	d -= x.d; }
# endif
# if CppADMyTypeOmit != 9
		// computed assignment multiplication
		void operator *= (const MyType &x)
		{	d *= x.d; }
# endif
# if CppADMyTypeOmit != 10
		// computed 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;

	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 &= CppAD::NearEqual(sum.Double(), b[0].Double(), 1e-10, 1e-10);

	sum = A[2] * x[0] + A[3] * x[1];
	ok &= CppAD::NearEqual(sum.Double(), b[1].Double(), 1e-10, 1e-10);

	return ok;
}


Input File: example/check_numeric_type.cpp cppad-20160000.1/doc/simplevector.xml0000644000175200017650000006316112656322006016433 0ustar coincoin-web 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 cppad-20160000.1/doc/simple_vector.cpp.xml0000644000175200017650000001211212656322006017341 0ustar coincoin-web Simple Vector Template Class: Example and Test
Prev Next simple_vector.cpp Headings

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/simple_vector.cpp cppad-20160000.1/doc/checksimplevector.xml0000644000175200017650000002505512656322006017431 0ustar coincoin-web 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 cppad-20160000.1/doc/check_simple_vector.cpp.xml0000644000175200017650000001503312656322006020503 0ustar coincoin-web The CheckSimpleVector Function: Example and Test
Prev Next check_simple_vector.cpp Headings

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/check_simple_vector.cpp cppad-20160000.1/doc/nan.xml0000644000175200017650000003324212656322006014470 0ustar coincoin-web 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 cppad-20160000.1/doc/nan.cpp.xml0000644000175200017650000000655212656322006015255 0ustar coincoin-web nan: Example and Test
Prev Next nan.cpp Headings

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/nan.cpp cppad-20160000.1/doc/pow_int.xml0000644000175200017650000002532012656322006015371 0ustar coincoin-web 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 cppad-20160000.1/doc/pow_int.cpp.xml0000644000175200017650000001134712656322006016156 0ustar coincoin-web The Pow Integer Exponent: Example and Test
Prev Next pow_int.cpp Headings

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;

	// 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,  1e-10 , 1e-10);
	}

	// 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,  1e-10 , 1e-10);
	}

	// 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,  1e-10 , 1e-10);
		w[i] = 0.;
	}

	return ok;
}


Input File: example/pow_int.cpp cppad-20160000.1/doc/poly.xml0000644000175200017650000003624612656322006014706 0ustar coincoin-web 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 computed assignment
x += y addition computed 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 cppad-20160000.1/doc/poly.cpp.xml0000644000175200017650000000656312656322006015466 0ustar coincoin-web Polynomial Evaluation: Example and Test
Prev Next poly.cpp Headings

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/poly.cpp cppad-20160000.1/doc/poly.hpp.xml0000644000175200017650000000772112656322006015470 0ustar coincoin-web Source: Poly
Prev Next poly.hpp Headings

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       = 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 cppad-20160000.1/doc/ludetandsolve.xml0000644000175200017650000000667412656322006016576 0ustar coincoin-web 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 cppad-20160000.1/doc/lusolve.xml0000644000175200017650000006346212656322006015414 0ustar coincoin-web 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 cppad-20160000.1/doc/lu_solve.cpp.xml0000644000175200017650000001130312656322006016317 0ustar coincoin-web LuSolve With Complex Arguments: Example and Test
Prev Next lu_solve.cpp Headings

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(j, 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/lu_solve.cpp cppad-20160000.1/doc/lu_solve.hpp.xml0000644000175200017650000001263512656322006016335 0ustar coincoin-web Source: LuSolve
Prev Next lu_solve.hpp Headings

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/local/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 cppad-20160000.1/doc/lufactor.xml0000644000175200017650000007363012656322006015540 0ustar coincoin-web 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 cppad-20160000.1/doc/lu_factor.cpp.xml0000644000175200017650000001163612656322006016456 0ustar coincoin-web LuFactor: Example and Test
Prev Next lu_factor.cpp Headings

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

	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  &= CppAD::NearEqual(pij, sum, 1e-10, 1e-10);
		}
	}

	return ok;
}


Input File: example/lu_factor.cpp cppad-20160000.1/doc/lu_factor.hpp.xml0000644000175200017650000001656212656322006016466 0ustar coincoin-web Source: LuFactor
Prev Next lu_factor.hpp Headings

Source: LuFactor
# ifndef CPPAD_LU_FACTOR_HPP
# define CPPAD_LU_FACTOR_HPP
 

# include <complex>
# include <vector>

# include <cppad/local/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/local/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 cppad-20160000.1/doc/luinvert.xml0000644000175200017650000005227412656322006015572 0ustar coincoin-web 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 cppad-20160000.1/doc/lu_invert.cpp.xml0000644000175200017650000001236612656322006016510 0ustar coincoin-web LuInvert: Example and Test
Prev Next lu_invert.cpp Headings

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

	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], 1e-10, 1e-10
			);
		}
	}
	return ok;
}


Input File: example/lu_invert.cpp cppad-20160000.1/doc/lu_invert.hpp.xml0000644000175200017650000001130512656322006016505 0ustar coincoin-web Source: LuInvert
Prev Next lu_invert.hpp Headings

Source: LuInvert
# ifndef CPPAD_LU_INVERT_HPP
# define CPPAD_LU_INVERT_HPP
 
# include <cppad/local/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 cppad-20160000.1/doc/rombergone.xml0000644000175200017650000003731112656322006016054 0ustar coincoin-web 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 cppad-20160000.1/doc/romberg_one.cpp.xml0000644000175200017650000001026112656322006016767 0ustar coincoin-web One Dimensional Romberg Integration: Example and Test
Prev Next romberg_one.cpp Headings

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) / (degree+1);

	// step size corresponding to r
	double step = (b - a) / exp(log(2.)*(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 < (degree+1) * spow;
		ok  &= CppAD::NearEqual(check, r, 0., e);
	}

	return ok;
}


Input File: example/romberg_one.cpp cppad-20160000.1/doc/rombergmul.xml0000644000175200017650000005031212656322006016064 0ustar coincoin-web 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 cppad-20160000.1/doc/rombergmul.cpp.xml0000644000175200017650000001147512656322006016654 0ustar coincoin-web One Dimensional Romberg Integration: Example and Test
Prev Next Rombergmul.cpp Headings

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) / (deg[0]+1);
	bpow = 1.;
	apow = 1.;
	for(i = 0; i <= deg[1]; i++)
	{	bpow *= b[1];
		apow *= a[1];
	}
	check *= (bpow - apow) / (deg[1]+1);

	double step = (b[1] - a[1]) / exp(log(2.)*(n[1]-1));
	double spow = 1;
	for(k = 0; k <= n[1]; k++)
	{	spow = spow * step * step;
		double bnd = 3 * (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/romberg_mul.cpp cppad-20160000.1/doc/runge45.xml0000644000175200017650000007351212656322006015211 0ustar coincoin-web 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 cppad-20160000.1/doc/runge45_1.cpp.xml0000644000175200017650000002040612656322006016204 0ustar coincoin-web Runge45: Example and Test
Prev Next runge45_1.cpp Headings

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] = (i+1) * x[i-1];
				else	f[i] = (i+1) * ti;
			}
		}
	private:
		const bool use_x;

	};
}

bool runge_45_1(void)
{	bool ok = true;     // initial return value
	size_t i;           // 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]
	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 &=
				CppAD::NearEqual(xf[i], check, 1e-10, 1e-10);
			// 4th order method is exact for i < 4
			if( i < 4 )
				ok &= (e[i] <= 1e-10);

			// check value for next i
			check *= tf;
		}
	}
	return ok;
}


Input File: example/runge45_1.cpp cppad-20160000.1/doc/runge45_2.cpp.xml0000644000175200017650000003025512656322006016210 0ustar coincoin-web Runge45: Example and Test
Prev Next runge45_2.cpp Headings

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/runge45_2.cpp cppad-20160000.1/doc/rosen34.xml0000644000175200017650000010604112656322006015207 0ustar coincoin-web 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 cppad-20160000.1/doc/rosen_34.cpp.xml0000644000175200017650000002526212656322006016134 0ustar coincoin-web Rosen34: Example and Test
Prev Next rosen_34.cpp Headings

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

	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 &=
				CppAD::NearEqual(xf[i], check, 1e-10, 1e-10);
			// 3rd order method is exact for i < 3
			if( i < 3 )
				ok &= (e[i] <= 1e-10);

			// check value for next i
			check *= tf;
		}
	}
	return ok;
}


Input File: example/rosen_34.cpp cppad-20160000.1/doc/odeerrcontrol.xml0000644000175200017650000014543612656322006016606 0ustar coincoin-web 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 cppad-20160000.1/doc/ode_err_control.cpp.xml0000644000175200017650000002445712656322006017664 0ustar coincoin-web 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/ode_err_control.cpp cppad-20160000.1/doc/ode_err_maxabs.cpp.xml0000644000175200017650000002442512656322006017452 0ustar coincoin-web OdeErrControl: Example and Test Using Maxabs Argument
Prev Next ode_err_maxabs.cpp Headings

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/ode_err_maxabs.cpp cppad-20160000.1/doc/odegear.xml0000644000175200017650000015330112656322006015321 0ustar coincoin-web 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 cppad-20160000.1/doc/ode_gear.cpp.xml0000644000175200017650000002343112656322006016241 0ustar coincoin-web OdeGear: Example and Test
Prev Next ode_gear.cpp Headings

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

	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, 1e-10, 1e-10
			);
			// error bound should be zero up to order m-1
			if( i + 1 < m ) ok &= CppAD::NearEqual(
				e[i], 0., 1e-10, 1e-10
			);
			// check value for next i
			check *= T[m];
		}
	}
	return ok;
}


Input File: example/ode_gear.cpp cppad-20160000.1/doc/odegearcontrol.xml0000644000175200017650000013445512656322006016733 0ustar coincoin-web 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 cppad-20160000.1/doc/ode_gear_control.cpp.xml0000644000175200017650000002456712656322006020014 0ustar coincoin-web OdeGearControl: Example and Test
Prev Next ode_gear_control.cpp Headings

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

	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 = 1e-10;
	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 &= CppAD::NearEqual(x0, xf[0], 1e-4, 1e-4);
	ok &= CppAD::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 &= CppAD::NearEqual(x1, xf[1], 1e-4, 1e-4);
	ok &= CppAD::NearEqual(0., ef[1], 1e-4, 1e-4);

	return ok;
}


Input File: example/ode_gear_control.cpp cppad-20160000.1/doc/cppad_vector.xml0000644000175200017650000010156312656322007016370 0ustar coincoin-web 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. The 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 cppad-20160000.1/doc/cppad_vector.cpp.xml0000644000175200017650000001247312656322007017152 0ustar coincoin-web CppAD::vector Template Class: Example and Test
Prev Next cppad_vector.cpp Headings

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/cppad_vector.cpp cppad-20160000.1/doc/vector_bool.cpp.xml0000644000175200017650000001203612656322007017011 0ustar coincoin-web CppAD::vectorBool Class: Example and Test
Prev Next vector_bool.cpp Headings

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/vector_bool.cpp cppad-20160000.1/doc/thread_alloc.xml0000644000175200017650000001610212656322007016332 0ustar coincoin-web 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 cppad-20160000.1/doc/thread_alloc.cpp.xml0000644000175200017650000002247412656322007017124 0ustar coincoin-web Fast Multi-Threading Memory Allocator: Example and Test
Prev Next thread_alloc.cpp Headings

Fast Multi-Threading Memory Allocator: Example and Test
 
# include <cppad/utility/thread_alloc.hpp>
# include <cppad/utility/memory_leak.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 &= ! 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 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 &= ! CppAD::memory_leak();

	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/thread_alloc.cpp cppad-20160000.1/doc/ta_parallel_setup.xml0000644000175200017650000002237612656322007017423 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_num_threads.xml0000644000175200017650000001152512656322007016712 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_in_parallel.xml0000644000175200017650000001132712656322007016663 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_thread_num.xml0000644000175200017650000001114012656322007016520 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_get_memory.xml0000644000175200017650000001766712656322007016565 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_return_memory.xml0000644000175200017650000001357712656322007017321 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_free_available.xml0000644000175200017650000001337112656322007017323 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_hold_memory.xml0000644000175200017650000001307112656322007016715 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_inuse.xml0000644000175200017650000001314112656322007015520 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_available.xml0000644000175200017650000001321712656322007016321 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_create_array.xml0000644000175200017650000002333512656322007017044 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_delete_array.xml0000644000175200017650000001544112656322007017042 0ustar coincoin-web 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 cppad-20160000.1/doc/ta_free_all.xml0000644000175200017650000001260312656322007016150 0ustar coincoin-web 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 cppad-20160000.1/doc/index_sort.xml0000644000175200017650000002200312656322007016064 0ustar coincoin-web 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 cppad-20160000.1/doc/index_sort.cpp.xml0000644000175200017650000001077612656322007016663 0ustar coincoin-web Index Sort: Example and Test
Prev Next index_sort.cpp Headings

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/index_sort.cpp cppad-20160000.1/doc/to_string.xml0000644000175200017650000002126312656322007015725 0ustar coincoin-web Convert Certain Types to a String
Prev Next

Convert Certain Types to a String

Syntax
# include <cppad/utility/to_string.hpp>
s = to_string(value) .

See Also
base_to_string , ad_to_string

Purpose
This routine is similar to the C++11 routine std::to_string with the following differences:
  1. It works with C++98.
  2. It has been extended to the fundamental floating point types.
  3. It has specifications for extending to an arbitrary type; see base_to_string .
  4. If <cppad/cppad.hpp> is included, and it has been extended to a Base type, it automatically extends to the AD types above Base .


value

Integer
The argument value can have the following prototype
     const 
Integer&  value
where Integer is any of the fundamental integer types; e.g., short int and unsigned long. Note that if C++11 is supported by this compilation, unsigned long long is also a fundamental integer type.

Float
The argument value can have the following prototype
     const 
Float&  value
where Float is any of the fundamental floating point types; i.e., float, double, and long double.

s
The return value has prototype
     std::string 
s
and contains a representation of the specified value .

Integer
If value is an Integer , the representation is equivalent to os << value where os is an std::ostringstream.

Float
If value is a Float , enough digits are used in the representation so that the result is accurate to withing round off error.

Example
The file to_string.cpp contains an example and test of this routine. It returns true if it succeeds and false otherwise.
Input File: cppad/utility/to_string.hpp cppad-20160000.1/doc/to_string.cpp.xml0000644000175200017650000001164212656322007016506 0ustar coincoin-web to_string: Example and Test
Prev Next to_string.cpp Headings

to_string: Example and Test
 

// Examples with fundamental types
# include <cppad/utility/to_string.hpp>
namespace {
	template <class Integer>
	Integer string2int(const std::string& s)
	{	Integer result = 0;
		size_t index   = 0;
		if( s[0] == '-' )
			++index;
		while( index < s.size() )
			result = 10 * result + Integer( s[index++] - '0');
		if( s[0] == '-' )
			return - result;
		return result;
	}
	template <class Integer>
	bool integer(void)
	{	bool ok = true;
		//
		Integer max    = std::numeric_limits<Integer>::max();
		std::string s  = CppAD::to_string(max);
		Integer check  = string2int<Integer>(s);
		ok            &= max == check;
		//
		Integer min       = std::numeric_limits<Integer>::min();
		s              = CppAD::to_string(min);
		check          = string2int<Integer>(s);
		ok            &= min == check;
		//
		return ok;
	}
	template <class Float>
	bool floating(void)
	{	bool  ok  = true;
		Float eps = std::numeric_limits<Float>::epsilon();
		Float pi  = 4.0 * std::atan(1.);
		//
		std::string s = CppAD::to_string( pi );
		Float check    = std::atof( s.c_str() );
		ok           &= std::fabs( check - pi ) <= 2.0 * eps;
		//
		return ok;
	}
}

// Examples with AD types
# include <cppad/cppad.hpp>
namespace {
	template <class Base>
	bool ad_floating(void)
	{	bool  ok  = true;
		Base eps = std::numeric_limits<Base>::epsilon();
		Base pi  = 4.0 * std::atan(1.);
		//
		std::string s = CppAD::to_string( CppAD::AD<Base>( pi ) );
		Base check    = std::atof( s.c_str() );
		ok           &= std::fabs( check - pi ) <= 2.0 * eps;
		//
		return ok;
	}
}

// Test driver
bool to_string(void)
{	bool ok = true;

	ok &= integer<unsigned short>();
	ok &= integer<signed int>();
	ok &= integer<unsigned long>();
# if CPPAD_USE_CPLUSPLUS_2011
	ok &= integer<signed long long>();
# endif
	//
	ok &= floating<float>();
	ok &= floating<double>();
	ok &= floating<long double>();
	//
	ok &= ad_floating<float>();
	ok &= ad_floating<double>();
	//
	return ok;
}


Input File: example/to_string.cpp cppad-20160000.1/doc/ipopt_solve.xml0000644000175200017650000011105312656322007016255 0ustar coincoin-web 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 cppad-20160000.1/doc/ipopt_solve_retape.cpp.xml0000644000175200017650000001220312656322007020373 0ustar coincoin-web 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( abs(x[0]) <= eps )
				fg[0] = x[0] * x[0] / (2.0 * eps);
			else
				fg[0] = abs(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 cppad-20160000.1/doc/_ipopt_solve_retape.cpp_xml.js0000644000175200017650000000275312656322007021237 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/example.xml0000644000175200017650000000777112656322007015360 0ustar coincoin-web 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.

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 cppad-20160000.1/doc/_example_xml.js0000644000175200017650000000257112656322007016204 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_current0 = [ 'example.xml#Introduction', '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]; } cppad-20160000.1/doc/general.xml0000644000175200017650000001342612656322007015334 0ustar coincoin-web 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 cppad-20160000.1/doc/_general_xml.js0000644000175200017650000000346712656322007016173 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/example.cpp.xml0000644000175200017650000004334512656322007016136 0ustar coincoin-web CppAD Examples and Tests
Prev Next example.cpp

CppAD Examples and Tests

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

// 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>

// prototype external compiled tests (this line expected by bin/new_test.sh)
extern bool abort_recording(void);
extern bool ad_assign(void);
extern bool ad_ctor(void);
extern bool abs(void);
extern bool acos(void);
extern bool acosh(void);
extern bool Add(void);
extern bool AddEq(void);
extern bool ad_fun(void);
extern bool ad_in_c(void);
extern bool ad_input(void);
extern bool ad_output(void);
extern bool asin(void);
extern bool asinh(void);
extern bool atan(void);
extern bool atanh(void);
extern bool atan2(void);
extern bool azmul(void);
extern bool base_require(void);
extern bool BenderQuad(void);
extern bool BoolFun(void);
extern bool bool_sparsity(void);
extern bool capacity_order(void);
extern bool change_param(void);
extern bool check_for_nan(void);
extern bool CheckNumericType(void);
extern bool CheckSimpleVector(void);
extern bool colpack_hes(void);
extern bool colpack_jac(void);
extern bool Compare(void);
extern bool compare_change(void);
extern bool complex_poly(void);
extern bool CondExp(void);
extern bool conj_grad(void);
extern bool Cos(void);
extern bool Cosh(void);
extern bool CppAD_vector(void);
extern bool dependency(void);
extern bool Div(void);
extern bool DivEq(void);
extern bool eigen_array(void);
extern bool eigen_det(void);
extern bool EqualOpSeq(void);
extern bool Erf(void);
extern bool ErrorHandler(void);
extern bool exp(void);
extern bool expm1(void);
extern bool ForOne(void);
extern bool ForTwo(void);
extern bool ForSparseJac(void);
extern bool Forward(void);
extern bool forward_dir(void);
extern bool forward_order(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 index_sort(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 log(void);
extern bool log10(void);
extern bool log1p(void);
extern bool LuFactor(void);
extern bool LuInvert(void);
extern bool LuRatio(void);
extern bool LuSolve(void);
extern bool LuVecADOk(void);
extern bool Mul(void);
extern bool MulEq(void);
extern bool mul_level(void);
extern bool mul_level_adolc(void);
extern bool mul_level_ode(void);
extern bool mul_level_adolc_ode(void);
extern bool nan(void);
extern bool Near_Equal(void);
extern bool NearEqualExt(void);
extern bool number_skip(void);
extern bool NumericType(void);
extern bool num_limits(void);
extern bool OdeErrControl(void);
extern bool OdeErrMaxabs(void);
extern bool OdeGear(void);
extern bool OdeGearControl(void);
extern bool OdeStiff(void);
extern bool ode_taylor(void);
extern bool opt_val_hes(void);
extern bool optimize(void);
extern bool ParVar(void);
extern bool Poly(void);
extern bool pow(void);
extern bool pow_int(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 RevSparseHes(void);
extern bool RevSparseJac(void);
extern bool RevTwo(void);
extern bool RombergMul(void);
extern bool RombergOne(void);
extern bool Rosen34(void);
extern bool runge_45_1(void);
extern bool runge_45_2(void);
extern bool seq_property(void);
extern bool sign(void);
extern bool SimpleVector(void);
extern bool Sin(void);
extern bool Sinh(void);
extern bool sparse_hessian(void);
extern bool sparse_jacobian(void);
extern bool sparse_sub_hes(void);
extern bool sparsity_sub(void);
extern bool Sqrt(void);
extern bool StackMachine(void);
extern bool Sub(void);
extern bool SubEq(void);
extern bool sub_sparse_hes(void);
extern bool Tan(void);
extern bool Tanh(void);
extern bool TapeIndex(void);
extern bool thread_alloc(void);
extern bool to_string(void);
extern bool UnaryMinus(void);
extern bool UnaryPlus(void);
extern bool Value(void);
extern bool Var2Par(void);
extern bool vec_ad(void);
extern bool vectorBool(void);

namespace {
	// function that runs one test
	static size_t Run_ok_count    = 0;
	static size_t Run_error_count = 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;
		//
		ok &= name.size() < size_t(width);
		ok &= TestOk();
		if( ok )
		{	std::cout << "OK" << std::endl;
			Run_ok_count++;
		}
		else
		{	std::cout << "Error" << std::endl;
			Run_error_count++;
		}
		return ok;
	}
}

// main program that runs all the tests
int main(void)
{	bool ok = true;

	// This line is used by test_one.sh

	// run external compiled tests (this line expected by bin/new_test.sh)
	ok &= Run( abort_recording,   "abort_recording"  );
	ok &= Run( ad_assign,         "ad_assign"        );
	ok &= Run( ad_ctor,           "ad_ctor"          );
	ok &= Run( abs,               "abs"              );
	ok &= Run( acos,              "acos"             );
	ok &= Run( acosh,             "acosh"            );
	ok &= Run( Add,               "Add"              );
	ok &= Run( AddEq,             "AddEq"            );
	ok &= Run( ad_fun,            "ad_fun"           );
	ok &= Run( ad_in_c,           "ad_in_c"          );
	ok &= Run( ad_input,          "ad_input"         );
	ok &= Run( ad_output,         "ad_output"        );
	ok &= Run( asin,              "asin"             );
	ok &= Run( asinh,             "asinh"            );
	ok &= Run( atan,              "atan"             );
	ok &= Run( atanh,             "atanh"            );
	ok &= Run( atan2,             "atan2"            );
	ok &= Run( azmul,             "azmul"            );
	ok &= Run( BenderQuad,        "BenderQuad"       );
	ok &= Run( BoolFun,           "BoolFun"          );
	ok &= Run( bool_sparsity,     "bool_sparsity"    );
	ok &= Run( capacity_order,    "capacity_order"   );
	ok &= Run( change_param,      "change_param"     );
	ok &= Run( check_for_nan,     "check_for_nan"    );
	ok &= Run( CheckNumericType,  "CheckNumericType" );
	ok &= Run( CheckSimpleVector, "CheckSimpleVector");
	ok &= Run( Compare,           "Compare"          );
	ok &= Run( compare_change,    "compare_change"   );
	ok &= Run( complex_poly,      "complex_poly"     );
	ok &= Run( CondExp,           "CondExp"          );
	ok &= Run( conj_grad,         "conj_grad"        );
	ok &= Run( Cos,               "Cos"              );
	ok &= Run( Cosh,              "Cosh"             );
	ok &= Run( CppAD_vector,      "CppAD_vector"     );
	ok &= Run( dependency,        "dependency"       );
	ok &= Run( Div,               "Div"              );
	ok &= Run( DivEq,             "DivEq"            );
	ok &= Run( EqualOpSeq,        "EqualOpSeq"       );
	ok &= Run( Erf,               "Erf"              );
	ok &= Run( ErrorHandler,      "ErrorHandler"     );
	ok &= Run( exp,               "exp"              );
	ok &= Run( expm1,             "expm1"            );
	ok &= Run( ForOne,            "ForOne"           );
	ok &= Run( ForTwo,            "ForTwo"           );
	ok &= Run( Forward,           "Forward"          );
	ok &= Run( forward_dir,       "forward_dir"      );
	ok &= Run( forward_order,     "forward_order"    );
	ok &= Run( ForSparseJac,      "ForSparseJac"     );
	ok &= Run( fun_assign,        "fun_assign"       );
	ok &= Run( FunCheck,          "FunCheck"         );
	ok &= Run( HesLagrangian,     "HesLagrangian"    );
	ok &= Run( HesLuDet,          "HesLuDet"         );
	ok &= Run( HesMinorDet,       "HesMinorDet"      );
	ok &= Run( Hessian,           "Hessian"          );
	ok &= Run( HesTimesDir,       "HesTimesDir"      );
	ok &= Run( Independent,       "Independent"      );
	ok &= Run( index_sort,        "index_sort"       );
	ok &= Run( Integer,           "Integer"          );
	ok &= Run( Interface2C,       "Interface2C"      );
	ok &= Run( interp_onetape,    "interp_onetape"   );
	ok &= Run( interp_retape,     "interp_retape"    );
	ok &= Run( JacLuDet,          "JacLuDet"         );
	ok &= Run( JacMinorDet,       "JacMinorDet"      );
	ok &= Run( Jacobian,          "Jacobian"         );
	ok &= Run( log,               "log"              );
	ok &= Run( log10,             "log10"            );
	ok &= Run( log1p,             "log1p"            );
	ok &= Run( LuFactor,          "LuFactor"         );
	ok &= Run( LuInvert,          "LuInvert"         );
	ok &= Run( LuRatio,           "LuRatio"          );
	ok &= Run( LuSolve,           "LuSolve"          );
	ok &= Run( LuVecADOk,         "LuVecADOk"        );
	ok &= Run( Mul,               "Mul"              );
	ok &= Run( MulEq,             "MulEq"            );
	ok &= Run( mul_level,         "mul_level"        );
	ok &= Run( mul_level_ode,     "mul_level_ode"    );
	ok &= Run( nan,               "nan"              );
	ok &= Run( Near_Equal,        "Near_Equal"       );
	ok &= Run( NearEqualExt,      "NearEqualExt"     );
	ok &= Run( number_skip,       "number_skip"      );
	ok &= Run( NumericType,       "NumericType"      );
	ok &= Run( num_limits,        "num_limits"       );
	ok &= Run( OdeErrControl,     "OdeErrControl"    );
	ok &= Run( OdeErrMaxabs,      "OdeErrMaxabs"     );
	ok &= Run( OdeGear,           "OdeGear"          );
	ok &= Run( OdeGearControl,    "OdeGearControl"   );
	ok &= Run( OdeStiff,          "OdeStiff"         );
	ok &= Run( ode_taylor,        "ode_taylor"       );
	ok &= Run( opt_val_hes,       "opt_val_hes"      );
	ok &= Run( optimize,          "optimize"         );
	ok &= Run( ParVar,            "ParVar"           );
	ok &= Run( Poly,              "Poly"             );
	ok &= Run( pow,               "pow"              );
	ok &= Run( pow_int,           "pow_int"          );
	ok &= Run( reverse_any,       "reverse_any"      );
	ok &= Run( reverse_one,       "reverse_one"      );
	ok &= Run( reverse_three,     "reverse_three"    );
	ok &= Run( reverse_two,       "reverse_two"      );
	ok &= Run( RevOne,            "RevOne"           );
	ok &= Run( RevSparseHes,      "RevSparseHes"     );
	ok &= Run( RevSparseJac,      "RevSparseJac"     );
	ok &= Run( RevTwo,            "RevTwo"           );
	ok &= Run( RombergMul,        "RombergMul"       );
	ok &= Run( RombergOne,        "RombergOne"       );
	ok &= Run( Rosen34,           "Rosen34"          );
	ok &= Run( runge_45_1,        "runge_45_1"       );
	ok &= Run( runge_45_2,        "runge_45_2"       );
	ok &= Run( seq_property,      "seq_property"     );
	ok &= Run( sign,              "sign"             );
	ok &= Run( SimpleVector,      "SimpleVector"     );
	ok &= Run( Sin,               "Sin"              );
	ok &= Run( Sinh,              "Sinh"             );
	ok &= Run( sparse_hessian,    "sparse_hessian"   );
	ok &= Run( sparse_jacobian,   "sparse_jacobian"  );
	ok &= Run( sparse_sub_hes,    "sparse_sub_hes"   );
	ok &= Run( sparsity_sub,      "sparsity_sub"     );
	ok &= Run( Sqrt,              "Sqrt"             );
	ok &= Run( StackMachine,      "StackMachine"     );
	ok &= Run( Sub,               "Sub"              );
	ok &= Run( SubEq,             "SubEq"            );
	ok &= Run( sub_sparse_hes,    "sub_sparse_hes"   );
	ok &= Run( Tan,               "Tan"              );
	ok &= Run( Tanh,              "Tanh"             );
	ok &= Run( TapeIndex,         "TapeIndex"        );
	ok &= Run( thread_alloc,      "thread_alloc"     );
	ok &= Run( to_string,         "to_string"        );
	ok &= Run( UnaryMinus,        "UnaryMinus"       );
	ok &= Run( UnaryPlus,         "UnaryPlus"        );
	ok &= Run( Value,             "Value"            );
	ok &= Run( Var2Par,           "Var2Par"          );
	ok &= Run( vec_ad,            "vec_ad"           );
	ok &= Run( vectorBool,        "vectorBool"       );
# ifdef CPPAD_ADOLC_EXAMPLES
	ok &= Run( mul_level_adolc,      "mul_level_adolc"     );
	ok &= Run( mul_level_adolc_ode,  "mul_level_adolc_ode" );
# endif
# ifdef CPPAD_COLPACK_EXAMPLES
	ok &= Run( colpack_hes,       "colpack_hes"      );
	ok &= Run( colpack_jac,       "colpack_jac"      );
# endif
# ifdef CPPAD_EIGEN_EXAMPLES
	ok &= Run( eigen_array,       "eigen_array"      );
	ok &= Run( eigen_det,         "eigen_det"        );
# endif

	// check for errors
	using std::cout;
	using std::endl;
	assert( ok || (Run_error_count > 0) );
	if( CppAD::thread_alloc::free_all() )
	{	Run_ok_count++;
		cout << "OK:    " << "No memory leak detected" << endl;
	}
	else
	{	ok = false;
		Run_error_count++;
		cout << "Error: " << "memory leak detected" << endl;
	}
	// Run base_require after memory leak check because base_alloc.hpp uses
	// thread_alloc to allocate memory for static copies of nan.
	ok &= Run( base_require,      "base_require"     );
	// convert int(size_t) to avoid warning on _MSC_VER systems
	if( ok )
		cout << "All " << int(Run_ok_count) << " tests passed." << endl;
	else	cout << int(Run_error_count) << " tests failed." << endl;

	return static_cast<int>( ! ok );
}

Input File: example/example.cpp cppad-20160000.1/doc/testvector.xml0000644000175200017650000001643212656322007016121 0ustar coincoin-web Using The CppAD Test Vector Template Class
Prev Next testvector

Using The CppAD Test Vector Template Class

Syntax
CPPAD_TESTVECTOR(Scalar)

Introduction
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'.

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/local/testvector.hpp cppad-20160000.1/doc/speed.xml0000644000175200017650000000777312656322007015027 0ustar coincoin-web 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 . 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 cppad-20160000.1/doc/ad_in_c.cpp.xml0000644000175200017650000003724712656322007016063 0ustar coincoin-web Example and Test Linking CppAD to Languages Other than C++
Prev Next ad_in_c.cpp Headings

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 = abs( *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/ad_in_c.cpp cppad-20160000.1/doc/conj_grad.cpp.xml0000644000175200017650000004404312656322007016425 0ustar coincoin-web 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/conj_grad.cpp cppad-20160000.1/doc/cppad_eigen.hpp.xml0000644000175200017650000002454612656322007016750 0ustar coincoin-web 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> .

Example
The files eigen_array.cpp and eigen_det.cpp contain an example and test of this include file. It returns true if it succeeds and false otherwise.

Include Files
The file cppad_eigen.hpp includes both <cppad/cppad.hpp> and <Eigen/Core>. In addition, The file eigen_plugin.hpp is used to define value_type in the Eigen matrix class definition so its vectors are simple vectors .
 
# 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 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(); }

     };
}

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; }
}

namespace Eigen {
     namespace internal {

          template<class Base>
          struct significant_decimals_default_impl< CppAD::AD<Base>, false>
          {    typedef CppAD::AD<Base> Scalar;

               typedef typename NumTraits<Scalar>::Real RealScalar;
               static inline int run()
               {    Scalar neg_log_eps = - log(
                         NumTraits<RealScalar>::epsilon()
                    );
                    int ceil_neg_log_eps = Integer( neg_log_eps );
                    if( Scalar(ceil_neg_log_eps) < neg_log_eps )
                         ceil_neg_log_eps++;
                    return ceil_neg_log_eps;
               }
          };
     }
}

Input File: cppad/example/cppad_eigen.hpp cppad-20160000.1/doc/eigen_plugin.hpp.xml0000644000175200017650000000524612656322007017153 0ustar coincoin-web Source Code for eigen_plugin.hpp
Prev Next eigen_plugin.hpp Headings

Source Code for eigen_plugin.hpp
 
// Declaration needed so an Eigen vector is a simple vector
typedef Scalar value_type;

Input File: cppad/example/eigen_plugin.hpp cppad-20160000.1/doc/eigen_array.cpp.xml0000644000175200017650000001016212656322007016757 0ustar coincoin-web Using Eigen Arrays: Example and Test
Prev Next eigen_array.cpp Headings

Using Eigen Arrays: Example and Test
 
# 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() + sin(a_x.array());

	// 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/eigen_array.cpp cppad-20160000.1/doc/eigen_det.cpp.xml0000644000175200017650000001164712656322007016426 0ustar coincoin-web Using Eigen To Compute Determinant: Example and Test
Prev Next eigen_det.cpp Headings

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/eigen_det.cpp cppad-20160000.1/doc/hes_minor_det.cpp.xml0000644000175200017650000001120112656322007017304 0ustar coincoin-web Gradient of Determinant Using Expansion by Minors: Example and Test
Prev Next hes_minor_det.cpp Headings

Gradient of Determinant Using Expansion by Minors: Example and Test
 

# 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/hes_minor_det.cpp cppad-20160000.1/doc/hes_lu_det.cpp.xml0000644000175200017650000001065112656322007016610 0ustar coincoin-web Gradient of Determinant Using LU Factorization: Example and Test
Prev Next hes_lu_det.cpp Headings

Gradient of Determinant Using LU Factorization: Example and Test
 

# include <cppad/cppad.hpp>
# include <cppad/speed/det_by_lu.hpp>

bool HesLuDet(void)
{	bool ok = true;

	using namespace CppAD;

	typedef std::complex<double> Complex;

	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], 1e-10 , 1e-10 );

	return ok;
}


Input File: example/hes_lu_det.cpp cppad-20160000.1/doc/interface2c.cpp.xml0000644000175200017650000001576212656322007016672 0ustar coincoin-web Interfacing to C: Example and Test
Prev Next interface2c.cpp Headings

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/interface2c.cpp cppad-20160000.1/doc/jac_minor_det.cpp.xml0000644000175200017650000001104312656322007017266 0ustar coincoin-web Gradient of Determinant Using Expansion by Minors: Example and Test
Prev Next jac_minor_det.cpp Headings

Gradient of Determinant Using Expansion by Minors: Example and Test
 

# 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/jac_minor_det.cpp cppad-20160000.1/doc/jac_lu_det.cpp.xml0000644000175200017650000001031112656322007016557 0ustar coincoin-web Gradient of Determinant Using Lu Factorization: Example and Test
Prev Next jac_lu_det.cpp Headings

Gradient of Determinant Using Lu Factorization: Example and Test
 

# include <cppad/cppad.hpp>
# include <cppad/speed/det_by_lu.hpp>

bool JacLuDet(void)
{	bool ok = true;

	using namespace CppAD;

	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], 1e-10 , 1e-10 );

	return ok;
}


Input File: example/jac_lu_det.cpp cppad-20160000.1/doc/mul_level.xml0000644000175200017650000003414512656322007015704 0ustar coincoin-web 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 calculation 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 calculation 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 cppad-20160000.1/doc/mul_level.cpp.xml0000644000175200017650000002462412656322007016466 0ustar coincoin-web 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/mul_level.cpp cppad-20160000.1/doc/change_param.cpp.xml0000644000175200017650000001373112656322007017104 0ustar coincoin-web Computing a Jacobian With Constants that Change
Prev Next change_param.cpp

Computing a Jacobian With Constants that Change

Purpose
In this example we use two levels of taping so that a derivative can have constant parameters that can be changed. To be specific, we consider the function f : R 2 R 2 f ( x ) = p ( sin ( x 0 ) sin ( x 1 ) ) were p R is a parameter. The Jacobian of this function is g ( x , p ) = p ( cos ( x 0 ) 0 0 cos ( x 1 ) ) In this example we use two levels of AD to avoid computing the partial of f ( x ) with respect to p , but still allow for the evaluation of g ( x , p ) at different values of p .
Input File: example/change_param.cpp cppad-20160000.1/doc/ode_stiff.cpp.xml0000644000175200017650000003052712656322007016443 0ustar coincoin-web A Stiff Ode: Example and Test
Prev Next ode_stiff.cpp Headings

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/ode_stiff.cpp cppad-20160000.1/doc/mul_level_ode.cpp.xml0000644000175200017650000007465712656322007017330 0ustar coincoin-web 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     = 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 becasue 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/mul_level_ode.cpp cppad-20160000.1/doc/ode_taylor.cpp.xml0000644000175200017650000004020012656322007016627 0ustar coincoin-web 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     = 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/ode_taylor.cpp cppad-20160000.1/doc/_ode_taylor.cpp_xml.js0000644000175200017650000000406412656322007017472 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/stack_machine.cpp.xml0000644000175200017650000002056412656322007017272 0ustar coincoin-web Example Differentiating a Stack Machine Interpreter
Prev Next stack_machine.cpp Headings

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;
	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., 1e-10, 1e-10);
	ok   &= NearEqual(dy[1], 2., 1e-10, 1e-10);
	ok   &= NearEqual(dy[2], 2., 1e-10, 1e-10);
	ok   &= NearEqual(dy[3], .5, 1e-10, 1e-10);

	// Use Jacobian routine (which automatically decides which mode to use)
	dy = f.Jacobian(x);
	ok   &= NearEqual(dy[0], 1., 1e-10, 1e-10);
	ok   &= NearEqual(dy[1], 2., 1e-10, 1e-10);
	ok   &= NearEqual(dy[2], 2., 1e-10, 1e-10);
	ok   &= NearEqual(dy[3], .5, 1e-10, 1e-10);

	return ok;
}

Input File: example/stack_machine.cpp cppad-20160000.1/doc/exampleutility.xml0000644000175200017650000000550712656322007016777 0ustar coincoin-web Utility Routines used by CppAD Examples
Prev Next

Utility Routines used by CppAD Examples

Contents
example.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 cppad-20160000.1/doc/speed_example.cpp.xml0000644000175200017650000001265412656322007017315 0ustar coincoin-web 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 cppad-20160000.1/doc/lu_vec_ad.cpp.xml0000644000175200017650000003265612656322007016427 0ustar coincoin-web 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/lu_vec_ad.cpp cppad-20160000.1/doc/lu_vec_ad_ok.cpp.xml0000644000175200017650000001266112656322007017112 0ustar coincoin-web Lu Factor and Solve With Recorded Pivoting: Example and Test
Prev Next lu_vec_ad_ok.cpp Headings

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;

	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, 1e-10, 1e-10);


	// 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, 1e-10, 1e-10 );
		}
	}

	CPPAD_TESTVECTOR(double) y2(1 + n * m);
	CPPAD_TESTVECTOR(double) A2(n * n);
	for(i = 0; i < n * n; i++)
		A[i] = A2[i] = a2[i];


	y2          = f.Forward(0, A2);
	determinant = Det(A);
	ok &= NearEqual(y2[ n * m], Value(determinant), 1e-10, 1e-10);

	// Check solution of Rhs = A2 * Result
	for(k = 0; k < m; k++)
	{	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, 1e-10, 1e-10 );
		}
	}

	return ok;
}


Input File: example/lu_vec_ad_ok.cpp cppad-20160000.1/doc/listallexamples.xml0000644000175200017650000006606612656322007017132 0ustar coincoin-web List of All the CppAD Examples
Prev Next ListAllExamples Headings

List of All the 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.cpp AD Absolute Value Function: Example and Test
acos.cpp The AD acos Function: Example and Test
acosh.cpp The AD acosh Function: Example and Test
add.cpp AD Binary Addition: Example and Test
AddEq.cpp AD Computed Assignment Addition: Example and Test
ad_assign.cpp AD Assignment: Example and Test
ad_ctor.cpp AD Constructors: Example and Test
ad_fun.cpp Creating Your Own Interface to an ADFun Object
ad_input.cpp AD Output Operator: Example and Test
ad_in_c.cpp Example and Test Linking CppAD to Languages Other than C++
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
atan.cpp The AD atan Function: Example and Test
atan2.cpp The AD atan2 Function: Example and Test
atanh.cpp The AD atanh Function: Example and Test
atomic_get_started.cpp Getting Started with Atomic Operations: Example and Test
atomic_hes_sparse.cpp Atomic Operation Hessian Sparsity: Example and Test
atomic_matrix_mul.hpp Matrix Multiply as an Atomic Operation
atomic_mat_mul.cpp User Atomic Matrix Multiply: 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_sparsity.cpp Atomic Sparsity 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
bool_sparsity.cpp Using vectorBool Sparsity To Conserve Memory: Example and Test
capacity_order.cpp Controlling Taylor Coefficient Memory Allocation: Example and Test
change_param.cpp Computing a Jacobian With Constants that Change
checkpoint.cpp Simple Checkpointing: Example and Test
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
colpack_hes.cpp Using ColPack: Example and Test
colpack_jac.cpp Using ColPack: Example and Test
compare.cpp AD Binary Comparison Operators: Example and Test
compare_change.cpp CompareChange and Re-Tape: 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 Computed 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
eigen_plugin.hpp Source Code for eigen_plugin.hpp
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
example.cpp CppAD Examples and Tests
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
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
for_one.cpp First Order Partial Driver: 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
fun_assign.cpp ADFun Assignment: Example and Test
fun_check.cpp ADFun Check and Re-Tape: Example and Test
get_started.cpp Getting Started Using CppAD to Compute Derivatives
harmonic.cpp Multi-Threaded Implementation of Summation of 1/i
harmonic_time.cpp Timing Test of Multi-Threaded Summation of 1/i
harmonic_work.cpp Multi-threading Sum of 1/i Utility Routines
hessian.cpp Hessian: Example and 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
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
jacobian.cpp Jacobian: 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
log.cpp The AD log Function: Example and Test
log10.cpp The AD log10 Function: Example and Test
log1p.cpp The AD log1p Function: Example and Test
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
mul.cpp AD Binary Multiplication: Example and Test
multi_newton.cpp A Multi-Threaded Newton's Method
multi_newton_time.cpp Timing Test of Multi-Threaded Newton Method
multi_newton_work.cpp Multi-threading Newton Method Utility Routines
mul_eq.cpp AD Computed Assignment Multiplication: Example and Test
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
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.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
optimize.cpp ADFun Operation Sequence Optimization: Example and Test
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
reverse_any.cpp Reverse Mode General Case: 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_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
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
sin.cpp The AD sin Function: Example and Test
sinh.cpp The AD sinh Function: Example and Test
sparse_hessian.cpp Sparse Hessian: Example and Test
sparse_hes_fun.cpp sparse_hes_fun: Example and test
sparse_jacobian.cpp Sparse Jacobian: Example and Test
sparse_jac_fun.cpp sparse_jac_fun: Example and test
sparse_sub_hes.cpp Sparse Hessian on Subset of Variables: 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 Computed Assignment Subtraction: 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
vector_bool.cpp CppAD::vectorBool Class: Example and Test
vec_ad.cpp AD Vectors that Record Index Operations: Example and Test

Input File: omh/example_list.omh cppad-20160000.1/doc/_speed_xml.js0000644000175200017650000000252512656322007015650 0ustar coincoin-webvar 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#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]; } cppad-20160000.1/doc/speed_main.xml0000644000175200017650000005711612656322007016027 0ustar coincoin-web 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 a positive integer. The random number simulator uniform_01 is initialized with the call
     uniform_01(
seed)
before any of the testing routines (listed above) are called.

option_list
This is a list of options that follow seed value. The order of the options does not matter and the list can be empty. Each option in the list, must be separate command line argument to the main program. The documentation below specifics how CppAD uses these options, see the examples in speed_adolc for how another package might uses these options.

onetape
If the option onetape is present, the symbol
 
     extern bool global_onetape
is true and otherwise it is false. If this external symbol is true, CppAD will use one taping of the operation sequence for all the repetitions of that speed test. Otherwise, the operation sequence will be retaped for each test repetition.

All of the tests, except det_lu , have a fixed operations sequence. The operation sequence for det_lu may be different for each repetition of the test because it depends on the matrix for which the determinant is being calculated. For this reason, the CppAD test cppad_det_lu.cpp returns false (indicating that the test not implemented) when global_onetape is true.

optimize
If the option optimize is present, the symbol
 
     extern bool global_optimize
is true and otherwise it is false. If this external symbol is true, CppAD will optimize the operation sequence before doing computations. If it is false, this optimization will not be done.

atomic
If the option atomic is present, the symbol
 
     extern bool global_atomic
is true and otherwise it is false. If this external symbol is true, CppAD will use its user defined atomic operation is used for the test. If no such atomic operation exists, and atomic is chosen, CppAD returns false for the test.

memory
If the option memory is present, the symbol
 
     extern bool global_memory
is true and otherwise it is false. If it is true, the CppAD hold_memory routine will be called by the main program before any of the tests are executed. This should make the CppAD thread_alloc allocator faster. If it is false, CppAD will used standard memory allocation.

Sparsity Options
The following options only apply to the sparse_jacobian and sparse_hessian tests. The other tests will ignore these options:

boolsparsity
If the option boolsparsity is present, the symbol
 
     extern bool global_boolsparsity
is true and otherwise it is false. If it is true, CppAD will use a vector of bool for its sparsity patterns. Otherwise it will use a vector of sets .

colpack
If the option colpack is present, the symbol
 
     extern bool global_colpack
is true and otherwise it is false. If this external symbol is true, CppAD will use colpack to do the coloring for its 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 cppad-20160000.1/doc/link_det_lu.xml0000644000175200017650000001701212656322007016203 0ustar coincoin-web 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 cppad-20160000.1/doc/link_det_minor.xml0000644000175200017650000001702312656322007016711 0ustar coincoin-web 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 cppad-20160000.1/doc/link_mat_mul.xml0000644000175200017650000002601612656322007016371 0ustar coincoin-web 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 cppad-20160000.1/doc/link_ode.xml0000644000175200017650000002604612656322007015505 0ustar coincoin-web 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 cppad-20160000.1/doc/link_poly.xml0000644000175200017650000001723312656322007015717 0ustar coincoin-web 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 cppad-20160000.1/doc/link_sparse_jacobian.xml0000644000175200017650000004231312656322007020054 0ustar coincoin-web 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 cppad-20160000.1/doc/microsoft_timer.xml0000644000175200017650000001002612656322007017115 0ustar coincoin-web 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 cppad-20160000.1/doc/_microsoft_timer_xml.js0000644000175200017650000000370112656322007017752 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/speed_utility.xml0000644000175200017650000001465212656322007016604 0ustar coincoin-web 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 cppad-20160000.1/doc/det_by_lu.xml0000644000175200017650000003151412656322007015663 0ustar coincoin-web 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). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

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 cppad-20160000.1/doc/det_by_lu.cpp.xml0000644000175200017650000000641412656322007016445 0ustar coincoin-web Determinant Using Lu Factorization: Example and Test
Prev Next det_by_lu.cpp Headings

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;

	// 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, 1e-10, 1e-10);

	return ok;
}


Input File: speed/example/det_by_lu.cpp cppad-20160000.1/doc/det_by_lu.hpp.xml0000644000175200017650000001013512656322007016445 0ustar coincoin-web Source: det_by_lu
Prev Next det_by_lu.hpp Headings

Source: det_by_lu
# ifndef CPPAD_DET_BY_LU_HPP
# define CPPAD_DET_BY_LU_HPP
 
# include <cppad/cppad.hpp>
# include <complex>

// BEGIN CppAD namespace
namespace CppAD {

// The AD complex case is used by examples by not used by speed tests
// Must define a specializatgion of LeqZero,AbsGeq for the ADComplex case
typedef std::complex<double>     Complex;
typedef CppAD::AD<Complex>     ADComplex;
CPPAD_BOOL_UNARY(Complex,  LeqZero )
CPPAD_BOOL_BINARY(Complex, AbsGeq )

template <class Scalar>
class det_by_lu {
private:
	const size_t m_;
	const size_t n_;
	CPPAD_TESTVECTOR(Scalar) A_;
	CPPAD_TESTVECTOR(Scalar) B_;
	CPPAD_TESTVECTOR(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)
	{
		using CppAD::exp;

		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 cppad-20160000.1/doc/det_of_minor.xml0000644000175200017650000006346512656322007016373 0ustar coincoin-web 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). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

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 cppad-20160000.1/doc/det_of_minor.cpp.xml0000644000175200017650000000733512656322007017146 0ustar coincoin-web Determinant of a Minor: Example and Test
Prev Next det_of_minor.cpp Headings

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 cppad-20160000.1/doc/det_of_minor.hpp.xml0000644000175200017650000000773012656322007017152 0ustar coincoin-web Source: det_of_minor
Prev Next det_of_minor.hpp Headings

Source: det_of_minor
# ifndef CPPAD_DET_OF_MINOR_HPP
# define CPPAD_DET_OF_MINOR_HPP
 
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 representaion 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 cppad-20160000.1/doc/det_by_minor.xml0000644000175200017650000003132112656322007016363 0ustar coincoin-web 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). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

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 cppad-20160000.1/doc/det_by_minor.cpp.xml0000644000175200017650000000636412656322007017155 0ustar coincoin-web Determinant Using Expansion by Minors: Example and Test
Prev Next det_by_minor.cpp Headings

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 cppad-20160000.1/doc/det_by_minor.hpp.xml0000644000175200017650000000662712656322007017164 0ustar coincoin-web Source: det_by_minor
Prev Next det_by_minor.hpp Headings

Source: det_by_minor
# ifndef CPPAD_DET_BY_MINOR_HPP
# define CPPAD_DET_BY_MINOR_HPP
 
# include <cppad/cppad.hpp>
# include <cppad/speed/det_of_minor.hpp>

// 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 cppad-20160000.1/doc/det_33.xml0000644000175200017650000002155012656322007014775 0ustar coincoin-web 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). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

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 cppad-20160000.1/doc/det_33.hpp.xml0000644000175200017650000000566212656322007015571 0ustar coincoin-web Source: det_33
Prev Next det_33.hpp Headings

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;

		// 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], 1e-10, 1e-10);

		return ok;
	}
}
# endif

Input File: omh/det_33_hpp.omh cppad-20160000.1/doc/det_grad_33.xml0000644000175200017650000002252412656322007015774 0ustar coincoin-web 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). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

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 cppad-20160000.1/doc/det_grad_33.hpp.xml0000644000175200017650000000671212656322007016563 0ustar coincoin-web Source: det_grad_33
Prev Next det_grad_33.hpp Headings

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 cppad-20160000.1/doc/mat_sum_sq.xml0000644000175200017650000003355412656322007016073 0ustar coincoin-web 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). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

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 cppad-20160000.1/doc/mat_sum_sq.cpp.xml0000644000175200017650000000673712656322007016657 0ustar coincoin-web Sum of the Elements of the Square of a Matrix: Example and Test
Prev Next mat_sum_sq.cpp Headings

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 cppad-20160000.1/doc/mat_sum_sq.hpp.xml0000644000175200017650000000602012656322007016645 0ustar coincoin-web Source: mat_sum_sq
Prev Next mat_sum_sq.hpp Headings

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 cppad-20160000.1/doc/ode_evaluate.xml0000644000175200017650000004001712656322007016350 0ustar coincoin-web 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). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

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 , and n -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 cppad-20160000.1/doc/ode_evaluate.cpp.xml0000644000175200017650000000715312656322007017135 0ustar coincoin-web ode_evaluate: Example and test
Prev Next ode_evaluate.cpp Headings

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 cppad-20160000.1/doc/ode_evaluate.hpp.xml0000644000175200017650000001152412656322007017137 0ustar coincoin-web Source: ode_evaluate
Prev Next ode_evaluate.hpp Headings

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 cppad-20160000.1/doc/sparse_jac_fun.xml0000644000175200017650000005102512656322007016676 0ustar coincoin-web 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). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

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 row has prototype
      const CppAD::vector<size_t>& 
col
and its size must be K ; i.e., the same as for col . 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 cppad-20160000.1/doc/sparse_jac_fun.hpp.xml0000644000175200017650000000746712656322007017477 0ustar coincoin-web Source: sparse_jac_fun
Prev Next sparse_jac_fun.hpp Headings

Source: sparse_jac_fun
# ifndef CPPAD_SPARSE_JAC_FUN_HPP
# define CPPAD_SPARSE_JAC_FUN_HPP
 
# include <cppad/local/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 cppad-20160000.1/doc/sparse_hes_fun.xml0000644000175200017650000005534412656322007016730 0ustar coincoin-web 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). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

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 cppad-20160000.1/doc/_sparse_hes_fun_xml.js0000644000175200017650000000453212656322007017554 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/sparse_hes_fun.hpp.xml0000644000175200017650000001157412656322007017513 0ustar coincoin-web Source: sparse_hes_fun
Prev Next sparse_hes_fun.hpp Headings

Source: sparse_hes_fun
# ifndef CPPAD_SPARSE_HES_FUN_HPP
# define CPPAD_SPARSE_HES_FUN_HPP
 
# include <cppad/local/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 cppad-20160000.1/doc/uniform_01.xml0000644000175200017650000002021212656322007015665 0ustar coincoin-web 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). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

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 cppad-20160000.1/doc/_uniform_01_xml.js0000644000175200017650000000411412656322007016523 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/uniform_01.hpp.xml0000644000175200017650000000541012656322007016456 0ustar coincoin-web Source: uniform_01
Prev Next uniform_01.hpp Headings

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 cppad-20160000.1/doc/speed_double.xml0000644000175200017650000001164412656322007016351 0ustar coincoin-web 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 cppad-20160000.1/doc/double_det_minor.cpp.xml0000644000175200017650000001016512656322007020007 0ustar coincoin-web 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_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize;

bool link_det_minor(
     size_t                     size     ,
     size_t                     repeat   ,
     CppAD::vector<double>     &matrix   ,
     CppAD::vector<double>     &det      )
{
     if(global_onetape||global_atomic||global_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 cppad-20160000.1/doc/double_det_lu.cpp.xml0000644000175200017650000001023012656322007017274 0ustar coincoin-web 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_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize;

bool link_det_lu(
     size_t                           size     ,
     size_t                           repeat   ,
     CppAD::vector<double>           &matrix   ,
     CppAD::vector<double>           &det      )
{
     if(global_onetape||global_atomic||global_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 cppad-20160000.1/doc/double_mat_mul.cpp.xml0000644000175200017650000001014712656322007017465 0ustar coincoin-web 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_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize;

bool link_mat_mul(
     size_t                           size     ,
     size_t                           repeat   ,
     CppAD::vector<double>&           x        ,
     CppAD::vector<double>&           z        ,
     CppAD::vector<double>&           dz
)
{
     if(global_onetape||global_atomic||global_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 cppad-20160000.1/doc/double_ode.cpp.xml0000644000175200017650000001005112656322007016570 0ustar coincoin-web 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_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize;

bool link_ode(
     size_t                     size       ,
     size_t                     repeat     ,
     CppAD::vector<double>      &x         ,
     CppAD::vector<double>      &jacobian
)
{
     if(global_onetape||global_atomic||global_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 cppad-20160000.1/doc/double_poly.cpp.xml0000644000175200017650000001007012656322007017005 0ustar coincoin-web 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_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize;

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_onetape||global_atomic||global_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 cppad-20160000.1/doc/double_sparse_hessian.cpp.xml0000644000175200017650000001106512656322007021036 0ustar coincoin-web 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_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize, global_boolsparsity;

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_onetape||global_atomic||global_optimize||global_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 cppad-20160000.1/doc/speed_adolc.xml0000644000175200017650000001305312656322007016155 0ustar coincoin-web 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 cppad-20160000.1/doc/_speed_adolc_xml.js0000644000175200017650000000346512656322007017016 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/adolc_det_minor.cpp.xml0000644000175200017650000001573012656322007017622 0ustar coincoin-web 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
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_atomic )
          return false;
     if( global_memory || global_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_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 cppad-20160000.1/doc/adolc_det_lu.cpp.xml0000644000175200017650000001436312656322007017117 0ustar coincoin-web 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
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_onetape || global_atomic )
          return false;
     if( global_memory || global_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 cppad-20160000.1/doc/adolc_mat_mul.cpp.xml0000644000175200017650000001600112656322007017270 0ustar coincoin-web Adolc Speed: Matrix Multiplication
Prev Next adolc_mat_mul.cpp

Adolc Speed: Matrix Multiplication

Specifications
See link_mat_mul .

Implementation
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_memory || global_atomic || global_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_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 cppad-20160000.1/doc/adolc_ode.cpp.xml0000644000175200017650000001540512656322007016410 0ustar coincoin-web Adolc Speed: Ode
Prev Next adolc_ode.cpp

Adolc Speed: Ode

Specifications
See link_ode .

Implementation
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

bool link_ode(
     size_t                     size       ,
     size_t                     repeat     ,
     CppAD::vector<double>      &x         ,
     CppAD::vector<double>      &jac
)
{
     // speed test global option values
     if( global_atomic )
          return false;
     if( global_memory || global_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_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 cppad-20160000.1/doc/adolc_poly.cpp.xml0000644000175200017650000001573312656322007016630 0ustar coincoin-web Adolc Speed: Second Derivative of a Polynomial
Prev Next adolc_poly.cpp

Adolc Speed: Second Derivative of a Polynomial

Specifications
See link_poly .

Implementation
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_atomic )
          return false;
     if( global_memory || global_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_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 cppad-20160000.1/doc/adolc_sparse_hessian.cpp.xml0000644000175200017650000002172212656322007020647 0ustar coincoin-web Adolc Speed: Sparse Hessian
Prev Next adolc_sparse_hessian.cpp

Adolc Speed: Sparse Hessian

Specifications
See link_sparse_hessian .

Implementation
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;
extern bool global_colpack, global_boolsparsity;

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_atomic || (! global_colpack) )
          return false;
     if( global_memory || global_optimize || global_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_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 cppad-20160000.1/doc/adolc_sparse_jacobian.cpp.xml0000644000175200017650000002255112656322007020764 0ustar coincoin-web adolc Speed: Sparse Jacobian
Prev Next adolc_sparse_jacobian.cpp

adolc Speed: Sparse Jacobian

Specifications
See link_sparse_jacobian .

Implementation
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;
extern bool global_colpack, global_boolsparsity;

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_atomic || (! global_colpack) )
          return false;
     if( global_memory || global_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];
     extern bool global_boolsparsity;
     if( global_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_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 cppad-20160000.1/doc/adolc_alloc_mat.xml0000644000175200017650000001375412656322007017020 0ustar coincoin-web 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 cppad-20160000.1/doc/speed_cppad.xml0000644000175200017650000001206412656322007016163 0ustar coincoin-web 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 cppad-20160000.1/doc/cppad_det_minor.cpp.xml0000644000175200017650000001501412656322007017622 0ustar coincoin-web 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/utility/vector.hpp>
# include <cppad/speed/det_by_minor.hpp>
# include <cppad/speed/uniform_01.hpp>

// Note that CppAD uses global_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize;

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_atomic )
          return false;

     // -----------------------------------------------------
     // 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_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_optimize )
               f.optimize();

          // skip comparison operators
          f.compare_change_count(0);

          // evaluate the determinant at the new matrix value
          f.Forward(0, matrix);

          // evaluate and return gradient using reverse mode
          gradient = f.Reverse(1, w);
     }
     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_optimize )
               f.optimize();

          // skip comparison operators
          f.compare_change_count(0);

          // ------------------------------------------------------
          while(repeat--)
          {    // get the next matrix
               CppAD::uniform_01(n, matrix);

               // evaluate the determinant at the new matrix value
               f.Forward(0, matrix);

               // evaluate and return gradient using reverse mode
               gradient = f.Reverse(1, w);
          }
     }
     return true;
}

Input File: speed/cppad/det_minor.cpp cppad-20160000.1/doc/cppad_det_lu.cpp.xml0000644000175200017650000001257112656322007017123 0ustar coincoin-web 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/utility/vector.hpp>
# include <cppad/speed/det_by_lu.hpp>
# include <cppad/speed/uniform_01.hpp>

// Note that CppAD uses global_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize;

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_onetape || global_atomic )
          return false;

     // -----------------------------------------------------
     // 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_optimize )
               f.optimize();

          // skip comparison operators
          f.compare_change_count(0);

          // evaluate and return gradient using reverse mode
          f.Forward(0, matrix);
          gradient = f.Reverse(1, w);
     }
     return true;
}

Input File: speed/cppad/det_lu.cpp cppad-20160000.1/doc/cppad_mat_mul.cpp.xml0000644000175200017650000001677612656322007017320 0ustar coincoin-web 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/matrix_mul.hpp>

// Note that CppAD uses global_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize, global_boolsparsity;

bool link_mat_mul(
     size_t                           size     ,
     size_t                           repeat   ,
     CppAD::vector<double>&           x        ,
     CppAD::vector<double>&           z        ,
     CppAD::vector<double>&           dz
)
{
     // -----------------------------------------------------
     // 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(2 * n), ay(n);
     size_t nr_result = size;
     size_t n_middle  = size;
     size_t nc_result = size;
     matrix_mul atom_mul(nr_result, n_middle, nc_result);
     //
     if( global_boolsparsity )
          atom_mul.option( CppAD::atomic_base<double>::pack_sparsity_enum );
     else
          atom_mul.option( CppAD::atomic_base<double>::set_sparsity_enum );
     // ------------------------------------------------------
     if( ! global_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_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_optimize )
               f.optimize();

          // skip comparison operators
          f.compare_change_count(0);

          // evaluate and return gradient using reverse mode
          z  = f.Forward(0, x);
          dz = f.Reverse(1, w);
     }
     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_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_optimize )
               f.optimize();

          // 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. (If there are future calls to
     // mat_mul they would create new temporary work space.)
     CppAD::user_atomic<double>::clear();

     return true;
}

Input File: speed/cppad/mat_mul.cpp cppad-20160000.1/doc/cppad_ode.cpp.xml0000644000175200017650000001347512656322007016422 0ustar coincoin-web 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_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize;

bool link_ode(
     size_t                     size       ,
     size_t                     repeat     ,
     CppAD::vector<double>      &x         ,
     CppAD::vector<double>      &jacobian
)
{
     // speed test global option values
     if( global_atomic )
          return false;

     // --------------------------------------------------------------------
     // 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_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_optimize )
               f.optimize();

          // 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_optimize )
               f.optimize();

          // 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 cppad-20160000.1/doc/cppad_poly.cpp.xml0000644000175200017650000001573512656322007016637 0ustar coincoin-web 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_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize;

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
{
     // speed test global option values
     if( global_atomic )
          return false;

     // -----------------------------------------------------
     // 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_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_optimize )
               f.optimize();

          // skip comparison operators
          f.compare_change_count(0);

          // pre-allocate memory for three forward mode calculations
          f.capacity_order(3);

          // evaluate the polynomial
          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_optimize )
               f.optimize();

          // 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 cppad-20160000.1/doc/cppad_sparse_hessian.cpp.xml0000644000175200017650000002230012656322007020645 0ustar coincoin-web 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_memory at the main program level
extern bool
     global_onetape, global_colpack,
     global_atomic, global_optimize, global_boolsparsity;

namespace {
     using CppAD::vector;
     typedef vector< std::set<size_t> >  SetVector;
     typedef vector<bool>                BoolVector;

     void calc_sparsity(SetVector& sparsity_set, CppAD::ADFun<double>& f)
     {    size_t n = f.Domain();
          size_t m = f.Range();
          CPPAD_ASSERT_UNKNOWN( m == 1 );
          SetVector r_set(n);
          for(size_t i = 0; i < n; i++)
               r_set[i].insert(i);
          f.ForSparseJac(n, r_set);
          //
          SetVector s_set(m);
          s_set[0].insert(0);
          //
          sparsity_set = f.RevSparseHes(n, s_set);
     }
     void calc_sparsity(BoolVector& sparsity_bool, CppAD::ADFun<double>& f)
     {    size_t n = f.Domain();
          size_t m = f.Range();
          CPPAD_ASSERT_UNKNOWN( m == 1 );
          BoolVector r_bool(n * n);
          size_t i, j;
          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);
          //
          BoolVector s_bool(m);
          s_bool[0] = true;
          //
          sparsity_bool = f.RevSparseHes(n, s_bool);
     }

}

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_atomic )
          return false;
# ifndef CPPAD_COLPACK_SPEED
     if( global_colpack )
          return false;
# endif
     // -----------------------------------------------------
     // setup
     typedef vector<double>              DblVector;
     typedef vector< std::set<size_t> >  SetVector;
     typedef CppAD::AD<double>           ADScalar;
     typedef vector<ADScalar>            ADVector;

     size_t j;
     size_t order = 0;         // derivative order corresponding to function
     size_t m = 1;             // number of dependent variables
     size_t n = size;          // number of independent variables
     ADVector   a_x(n);        // AD domain space vector
     ADVector   a_y(m);        // AD range space vector
     DblVector  w(m);          // double range space vector
     CppAD::ADFun<double> f;   // AD function object

     // weights for hessian calculation (only one component of f)
     w[0] = 1.;

     // declare sparsity pattern
     SetVector  set_sparsity(n);
     BoolVector bool_sparsity(n * n);

     // ------------------------------------------------------
     if( ! global_onetape ) while(repeat--)
     {    // choose a value for x
          CppAD::uniform_01(n, x);
          for(j = 0; j < n; j++)
               a_x[j] = x[j];

          // declare independent variables
          Independent(a_x);

          // AD computation of f(x)
          CppAD::sparse_hes_fun<ADScalar>(n, a_x, row, col, order, a_y);

          // create function object f : X -> Y
          f.Dependent(a_x, a_y);

          if( global_optimize )
               f.optimize();

          // skip comparison operators
          f.compare_change_count(0);

          // calculate the Hessian sparsity pattern for this function
          if( global_boolsparsity )
               calc_sparsity(bool_sparsity, f);
          else
               calc_sparsity(set_sparsity, f);

          // structure that holds some of work done by SparseHessian
          CppAD::sparse_hessian_work work;
# ifdef CPPAD_COLPACK_SPEED
          if( global_colpack )
               work.color_method = "colpack.star";
# endif
          // calculate this Hessian at this x
          if( global_boolsparsity) n_sweep = f.SparseHessian(
               x, w, bool_sparsity, row, col, hessian, work
          );
          else n_sweep = f.SparseHessian(
                    x, w, set_sparsity, row, col, hessian, work
          );
     }
     else
     {    // choose a value for x
          CppAD::uniform_01(n, x);
          for(j = 0; j < n; j++)
               a_x[j] = x[j];

          // declare independent variables
          Independent(a_x);

          // AD computation of f(x)
          CppAD::sparse_hes_fun<ADScalar>(n, a_x, row, col, order, a_y);

          // create function object f : X -> Y
          f.Dependent(a_x, a_y);

          if( global_optimize )
               f.optimize();

          // skip comparison operators
          f.compare_change_count(0);

          // calculate the Hessian sparsity pattern for this function
          if( global_boolsparsity)
               calc_sparsity(bool_sparsity, f);
          else
               calc_sparsity(set_sparsity, f);

          // declare structure that holds some of work done by SparseHessian
          CppAD::sparse_hessian_work work;
# ifdef CPPAD_COLPACK_SPEED
          if( global_colpack )
               work.color_method = "colpack.star";
# endif
          while(repeat--)
          {    // choose a value for x
               CppAD::uniform_01(n, x);

               // calculate hessian at this x
               if( global_boolsparsity ) n_sweep = f.SparseHessian(
                    x, w, bool_sparsity, row, col, hessian, work
               );
               else n_sweep = f.SparseHessian(
                    x, w, set_sparsity, row, col, hessian, work
               );
          }
     }
     return true;
}

Input File: speed/cppad/sparse_hessian.cpp cppad-20160000.1/doc/cppad_sparse_jacobian.cpp.xml0000644000175200017650000002141512656322007020767 0ustar coincoin-web 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_memory at the main program level
extern bool
     global_onetape, global_colpack,
     global_atomic, global_optimize, global_boolsparsity;

namespace {
     using CppAD::vector;
     typedef vector< std::set<size_t> >  SetVector;
     typedef vector<bool>                BoolVector;

     void calc_sparsity(SetVector& sparsity_set, CppAD::ADFun<double>& f)
     {    size_t n = f.Domain();
          SetVector r_set(n);
          for(size_t j = 0; j < n; j++)
               r_set[j].insert(j);
          sparsity_set = f.ForSparseJac(n, r_set);
     }
     void calc_sparsity(BoolVector& sparsity_bool, CppAD::ADFun<double>& f)
     {    size_t n = f.Domain();
          BoolVector r_bool(n * n);
          size_t i, j;
          for(i = 0; i < n; i++)
          {    for(j = 0; j < n; j++)
                    r_bool[ i * n + j] = false;
               r_bool[ i * n + i] = true;
          }
          sparsity_bool = f.ForSparseJac(n, r_bool);
     }

}

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_atomic )
          return false;
# ifndef CPPAD_COLPACK_SPEED
     if( global_colpack )
          return false;
# endif
     // -----------------------------------------------------
     // setup
     typedef vector< std::set<size_t> >  SetVector;
     typedef CppAD::AD<double>           ADScalar;
     typedef CppAD::vector<ADScalar>     ADVector;

     size_t j;
     size_t order = 0;         // derivative order corresponding to function
     size_t n     = size;      // number of independent variables
     ADVector   a_x(n);        // AD domain space vector
     ADVector   a_y(m);        // AD range space vector y = g(x)
     CppAD::ADFun<double> f;   // AD function object

     // declare sparsity pattern
     SetVector  set_sparsity(m);
     BoolVector bool_sparsity(m * n);

     // ------------------------------------------------------
     if( ! global_onetape ) while(repeat--)
     {    // choose a value for x
          CppAD::uniform_01(n, x);
          for(j = 0; j < n; j++)
               a_x[j] = x[j];

          // declare independent variables
          Independent(a_x);

          // 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
          f.Dependent(a_x, a_y);

          if( global_optimize )
               f.optimize();

          // skip comparison operators
          f.compare_change_count(0);

          // calculate the Jacobian sparsity pattern for this function
          if( global_boolsparsity )
               calc_sparsity(bool_sparsity, f);
          else
               calc_sparsity(set_sparsity, f);

          // structure that holds some of the work done by SparseJacobian
          CppAD::sparse_jacobian_work work;
# ifdef CPPAD_COLPACK_SPEED
          if( global_colpack )
               work.color_method = "colpack";
# endif
          // calculate the Jacobian at this x
          // (use forward mode because m > n ?)
          if( global_boolsparsity) n_sweep = f.SparseJacobianForward(
                    x, bool_sparsity, row, col, jacobian, work
          );
          else n_sweep = f.SparseJacobianForward(
                    x, set_sparsity, row, col, jacobian, work
          );
     }
     else
     {    // choose a value for x
          CppAD::uniform_01(n, x);
          for(j = 0; j < n; j++)
               a_x[j] = x[j];

          // declare independent variables
          Independent(a_x);

          // 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
          f.Dependent(a_x, a_y);

          if( global_optimize )
               f.optimize();

          // skip comparison operators
          f.compare_change_count(0);

          // calculate the Jacobian sparsity pattern for this function
          if( global_boolsparsity )
               calc_sparsity(bool_sparsity, f);
          else
               calc_sparsity(set_sparsity, f);

          // structure that holds some of the work done by SparseJacobian
          CppAD::sparse_jacobian_work work;
# ifdef CPPAD_COLPACK_SPEED
          if( global_colpack )
               work.color_method = "colpack";
# endif
          while(repeat--)
          {    // choose a value for x
               CppAD::uniform_01(n, x);

               // calculate the Jacobian at this x
               // (use forward mode because m > n ?)
               if( global_boolsparsity ) n_sweep = f.SparseJacobianForward(
                         x, bool_sparsity, row, col, jacobian, work
               );
               else n_sweep = f.SparseJacobianForward(
                         x, set_sparsity, row, col, jacobian, work
               );
          }
     }
     return true;
}

Input File: speed/cppad/sparse_jacobian.cpp cppad-20160000.1/doc/speed_fadbad.xml0000644000175200017650000001261212656322007016274 0ustar coincoin-web 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 cppad-20160000.1/doc/fadbad_det_minor.cpp.xml0000644000175200017650000001210712656322007017734 0ustar coincoin-web 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
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_atomic )
          return false;
     if( global_memory || global_onetape || global_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 cppad-20160000.1/doc/fadbad_det_lu.cpp.xml0000644000175200017650000001213412656322007017230 0ustar coincoin-web 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
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_onetape || global_atomic )
          return false;
     if( global_memory || global_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 cppad-20160000.1/doc/fadbad_mat_mul.cpp.xml0000644000175200017650000001225312656322007017414 0ustar coincoin-web Fadbad Speed: Matrix Multiplication
Prev Next fadbad_mat_mul.cpp

Fadbad Speed: Matrix Multiplication

Specifications
See link_mat_mul .

Implementation
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_memory || global_onetape || global_atomic || global_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 cppad-20160000.1/doc/fadbad_ode.cpp.xml0000644000175200017650000001207412656322007016526 0ustar coincoin-web Fadbad Speed: Ode
Prev Next fadbad_ode.cpp

Fadbad Speed: Ode

Specifications
See link_ode .

Implementation
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_atomic )
          return false;
     if( global_memory || global_onetape || global_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 cppad-20160000.1/doc/fadbad_poly.cpp.xml0000644000175200017650000001220312656322007016734 0ustar coincoin-web 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_atomic )
          return false;
     if( global_memory || global_onetape || global_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 cppad-20160000.1/doc/fadbad_sparse_hessian.cpp.xml0000644000175200017650000000620112656322007020761 0ustar coincoin-web Fadbad Speed: Sparse Hessian
Prev Next fadbad_sparse_hessian.cpp Headings

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 cppad-20160000.1/doc/fadbad_sparse_jacobian.cpp.xml0000644000175200017650000000622612656322007021104 0ustar coincoin-web fadbad Speed: sparse_jacobian
Prev Next fadbad_sparse_jacobian.cpp Headings

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 cppad-20160000.1/doc/speed_sacado.xml0000644000175200017650000001265712656322007016336 0ustar coincoin-web 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 cppad-20160000.1/doc/sacado_det_minor.cpp.xml0000644000175200017650000001175512656322007017775 0ustar coincoin-web 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
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_atomic )
          return false;
     if( global_memory || global_onetape || global_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 cppad-20160000.1/doc/sacado_det_lu.cpp.xml0000644000175200017650000001177312656322007017271 0ustar coincoin-web 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
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_onetape || global_atomic )
          return false;
     if( global_memory || global_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 cppad-20160000.1/doc/sacado_mat_mul.cpp.xml0000644000175200017650000001217612656322007017451 0ustar coincoin-web Sacado Speed: Matrix Multiplication
Prev Next sacado_mat_mul.cpp

Sacado Speed: Matrix Multiplication

Specifications
See link_mat_mul .

Implementation
 
# 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_memory || global_onetape || global_atomic || global_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 cppad-20160000.1/doc/sacado_ode.cpp.xml0000644000175200017650000001167012656322007016560 0ustar coincoin-web Sacado Speed: Gradient of Ode Solution
Prev Next sacado_ode.cpp

Sacado Speed: Gradient of Ode Solution

Specifications
See link_ode .

Implementation
 
# include <Sacado.hpp>
// # 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
extern bool global_memory, global_onetape, global_atomic, global_optimize;

bool link_ode(
     size_t                     size       ,
     size_t                     repeat     ,
     CppAD::vector<double>      &x         ,
     CppAD::vector<double>      &jacobian
)
{
     // speed test global option values
     if( global_atomic )
          return false;
     if( global_memory || global_onetape || global_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 cppad-20160000.1/doc/sacado_poly.cpp.xml0000644000175200017650000001224612656322007016774 0ustar coincoin-web Sacado Speed: Second Derivative of a Polynomial
Prev Next sacado_poly.cpp

Sacado 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 <Sacado.hpp>

// list of possible options
extern bool global_memory, global_onetape, global_atomic, global_optimize;

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_atomic )
          return false;
     if( global_memory || global_onetape || global_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 cppad-20160000.1/doc/sacado_sparse_hessian.cpp.xml0000644000175200017650000000621212656322007021014 0ustar coincoin-web Sacado Speed: Sparse Hessian
Prev Next sacado_sparse_hessian.cpp Headings

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 cppad-20160000.1/doc/sacado_sparse_jacobian.cpp.xml0000644000175200017650000000622212656322007021131 0ustar coincoin-web sacado Speed: sparse_jacobian
Prev Next sacado_sparse_jacobian.cpp Headings

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 cppad-20160000.1/doc/appendix.xml0000644000175200017650000000671712656322007015534 0ustar coincoin-web Appendix
Prev Next

Appendix

Contents
FaqFrequently Asked Questions and Answers
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 cppad-20160000.1/doc/_appendix_xml.js0000644000175200017650000000254412656322007016361 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/faq.xml0000644000175200017650000004032012656322007014457 0ustar coincoin-web 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 search this page for mention of some feature that perhaps you interpreting as a bug (and is not). If this does not solve your problem, continue to the next step.
  2. The second step is to check the whats_new messages from the date of the release that you are using to the current date. If the bug has been mentioned and fixed, then install the current version of CppAD. If this does not solve your problem, continue to the next step.
  3. Create a simple as possible 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. Send an e-mail message to the mailing list cppad@list.coin-or.org with a description of the bug. Attaching your program that demonstrates the bug.


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 ?

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.

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).

Using
Why do I have trouble when the following command
 
     using namespace CppAD
is at the global level (not within a function or some other limited scope).

Some versions of # include <cmath> for gcc and Visual C++ define the standard math functions, (for example double sqrt(double x) ) at the global level. It is necessary to put your using commands within the scope of a function, or some other limited scope, in order to shadow these improper global definitions.

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/faq.omh cppad-20160000.1/doc/theory.xml0000644000175200017650000000552212656322007015227 0ustar coincoin-web The Theory of Derivative Calculations
Prev Next

The Theory of Derivative Calculations

Contents

Input File: omh/theory/theory.omh cppad-20160000.1/doc/exp_forward.xml0000644000175200017650000003524612656322007016243 0ustar coincoin-web 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/theory/exp_forward.omh cppad-20160000.1/doc/log_forward.xml0000644000175200017650000003551512656322007016227 0ustar coincoin-web 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/theory/log_forward.omh cppad-20160000.1/doc/sqrt_forward.xml0000644000175200017650000003077612656322007016443 0ustar coincoin-web Square Root Function Forward Mode Theory
Prev Next sqrt_forward Headings

Square Root Function Forward Mode Theory
If F ( x ) = x F ( x ) * F ( 1 ) ( x ) - 0 * F ( x ) = 1 / 2 and in the standard math function differential equation , A ( x ) = 0 , B ( x ) = F ( x ) , and D ( x ) = 1 / 2 . We use a , b , d , and z to denote the Taylor coefficients for A [ X ( t ) ] , B [ X ( t ) ] , D [ X ( t ) ] , and F [ X ( t ) ] respectively. It now follows from the general Taylor coefficients recursion formula that for j = 0 , 1 , , z ( 0 ) = x ( 0 ) e ( j ) = d ( j ) + k = 0 j a ( j - k ) * z ( k ) = { 1 / 2 if j = 0 0 otherwise z ( j + 1 ) = 1 j + 1 1 b ( 0 ) ( k = 1 j + 1 k x ( k ) e ( j + 1 - k ) - k = 1 j k z ( k ) b ( j + 1 - k ) ) = 1 j + 1 1 z ( 0 ) (j + 1 2 x ( j + 1 ) - k = 1 j k z ( k ) z ( j + 1 - k ) )
Input File: omh/theory/sqrt_forward.omh cppad-20160000.1/doc/sin_cos_forward.xml0000644000175200017650000004170312656322007017077 0ustar coincoin-web 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/theory/sin_cos_forward.omh cppad-20160000.1/doc/atan_forward.xml0000644000175200017650000004141512656322007016365 0ustar coincoin-web 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/theory/atan_forward.omh cppad-20160000.1/doc/asin_forward.xml0000644000175200017650000005163412656322007016400 0ustar coincoin-web 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/theory/asin_forward.omh cppad-20160000.1/doc/acos_forward.xml0000644000175200017650000005270112656322007016367 0ustar coincoin-web 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/theory/acos_forward.omh cppad-20160000.1/doc/tan_forward.xml0000644000175200017650000004172612656322007016231 0ustar coincoin-web 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/theory/tan_forward.omh cppad-20160000.1/doc/erf_forward.xml0000644000175200017650000002735612656322007016226 0ustar coincoin-web 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/theory/erf_forward.omh cppad-20160000.1/doc/reversetheory.xml0000644000175200017650000012002512656322007016617 0ustar coincoin-web 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/theory/reverse_theory.omh cppad-20160000.1/doc/exp_reverse.xml0000644000175200017650000003077612656322007016255 0ustar coincoin-web Exponential Function Reverse Mode Theory
Prev Next exp_reverse Headings

Exponential Function Reverse Mode Theory
We use the reverse theory standard math function definition for the functions H and G . The zero order forward mode formula for the exponential is z ( 0 ) = F ( x ( 0 ) ) and for j > 0 , z ( j ) = x ( j ) d ( 0 ) + 1 j k = 1 j k x ( k ) z ( j - k ) where d ( 0 ) = { 0 if F ( x ) = exp ( x ) 1 if F ( x ) = expm 1 ( x ) For order j = 0 , 1 , we note that H x ( j ) = G x ( j ) + G z ( j ) z ( j ) x ( j ) = G x ( j ) + G z ( j ) ( d ( 0 ) + z ( 0 ) ) If j > 0 , then for k = 1 , , j H x ( k ) = G x ( k ) + G z ( j ) 1 j k z ( j - k ) H z ( j - k ) = G z ( j - k ) + G z ( j ) 1 j k x ( k )
Input File: omh/theory/exp_reverse.omh cppad-20160000.1/doc/log_reverse.xml0000644000175200017650000005216112656322007016232 0ustar coincoin-web Logarithm Function Reverse Mode Theory
Prev Next log_reverse Headings

Logarithm Function Reverse Mode Theory
We use the reverse theory standard math function definition for the functions H and G . The zero order forward mode formula for the logarithm is z ( 0 ) = F ( x ( 0 ) ) and for j > 0 , z ( j ) = 1 b ¯ + x ( 0 ) 1 j (j x ( j ) - k = 1 j -1 k z ( k ) x ( j - k ) ) where b ¯ = { 0 if F ( x ) = log ( x ) 1 if F ( x ) = log 1 p ( x ) We note that for j > 0 z ( j ) x ( 0 ) = - 1 b ¯ + x ( 0 ) 1 b ¯ + x ( 0 ) 1 j (j x ( j ) - k = 1 j -1 k z ( k ) x ( j - k ) ) = - z ( j ) b ¯ + x ( 0 ) Removing the zero order partials are given by H x ( 0 ) = G x ( 0 ) + G z ( 0 ) z ( 0 ) x ( 0 ) = G x ( 0 ) + G z ( 0 ) 1 b ¯ + x ( 0 ) For orders j > 0 and for k = 1 , , j -1 H x ( 0 ) = G x ( 0 ) + G z ( j ) z ( j ) x ( 0 ) = G x ( 0 ) - G z ( j ) z ( j ) b ¯ + x ( 0 ) H x ( j ) = G x ( j ) + G z ( j ) z ( j ) x ( j ) = G x ( j ) + G z ( j ) 1 b ¯ + x ( 0 ) H x ( j - k ) = G x ( j - k ) - G z ( j ) 1 b ¯ + x ( 0 ) k j z ( k ) H z ( k ) = G z ( k ) - G z ( j ) 1 b ¯ + x ( 0 ) k j x ( j - k )
Input File: omh/theory/log_reverse.omh cppad-20160000.1/doc/sqrt_reverse.xml0000644000175200017650000003747512656322007016455 0ustar coincoin-web Square Root Function Reverse Mode Theory
Prev Next sqrt_reverse Headings

Square Root Function Reverse Mode Theory
We use the reverse theory standard math function definition for the functions H and G . The forward mode formulas for the square root function are z ( j ) = x ( 0 ) for the case j = 0 , and for j > 0 , z ( j ) = 1 j 1 z ( 0 ) (j 2 x ( j ) - = 1 j -1 z ( ) z ( j - ) ) If j = 0 , we have the relation H x ( j ) = G x ( j ) + G z ( j ) z ( j ) x ( 0 ) = G x ( j ) + G z ( j ) 1 2 z ( 0 ) If j > 0 , then for k = 1 , , j -1 H z ( 0 ) = G z ( 0 ) + G z ( j ) z ( j ) z ( 0 ) = G z ( 0 ) - G z ( j ) z ( j ) z ( 0 ) H x ( j ) = G x ( j ) + G z ( j ) z ( j ) x ( j ) = G x ( j ) + G z ( j ) 1 2 z ( 0 ) H z ( k ) = G z ( k ) + G z ( j ) z ( j ) z ( k ) = G z ( k ) - G z ( j ) z ( j - k ) z ( 0 )
Input File: omh/theory/sqrt_reverse.omh cppad-20160000.1/doc/sin_cos_reverse.xml0000644000175200017650000004474412656322007017116 0ustar coincoin-web Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
Prev Next sin_cos_reverse Headings

Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
We use the reverse theory standard math function definition for the functions H and G . In addition, we use the following definitions for s and c and the integer
Coefficients s c
Trigonometric Case sin [ X ( t ) ] cos [ X ( t ) ] 1
Hyperbolic Case sinh [ X ( t ) ] cosh [ X ( t ) ] -1
We use the value z ( j ) = ( s ( j ) , c ( j ) ) in the definition for G and H . The forward mode formulas for the sine and cosine functions are s ( j ) = 1 + 2 sin ( x ( 0 ) ) + 1 - 2 sinh ( x ( 0 ) ) c ( j ) = 1 + 2 cos ( x ( 0 ) ) + 1 - 2 cosh ( x ( 0 ) ) for the case j = 0 , and for j > 0 , s ( j ) = 1 j k = 1 j k x ( k ) c ( j - k ) c ( j ) = 1 j k = 1 j k x ( k ) s ( j - k ) If j = 0 , we have the relation H x ( j ) = G x ( j ) + G s ( j ) c ( 0 ) + G c ( j ) s ( 0 ) If j > 0 , then for k = 1 , , j -1 H x ( k ) = G x ( k ) + G s ( j ) 1 j k c ( j - k ) + G c ( j ) 1 j k s ( j - k ) H s ( j - k ) = G s ( j - k ) + G c ( j ) k x ( k ) H c ( j - k ) = G c ( j - k ) + G s ( j ) k x ( k )
Input File: omh/theory/sin_cos_reverse.omh cppad-20160000.1/doc/atan_reverse.xml0000644000175200017650000010343012656322007016370 0ustar coincoin-web Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
Prev Next atan_reverse Headings

Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
We use the reverse theory standard math function definition for the functions H and G . In addition, we use the forward mode notation in atan_forward for B ( t ) = 1 ± X ( t ) * X ( t ) We use b for the p-th order Taylor coefficient row vectors corresponding to B ( t ) and replace z ( j ) by ( z ( j ) , b ( j ) ) in the definition for G and H . The zero order forward mode formulas for the atan function are z ( 0 ) = F ( x ( 0 ) ) b ( 0 ) = 1 ± x ( 0 ) x ( 0 ) where F ( x ) = atan ( x ) for + and F ( x ) = atanh ( x ) for - . For orders j greater than zero we have b ( j ) = ± k = 0 j x ( k ) x ( j - k ) z ( j ) = 1 j 1 b ( 0 ) (j x ( j ) - k = 1 j -1 k z ( k ) b ( j - k ) ) If j = 0 , we note that F ( 1 ) ( x ( 0 ) ) = 1 / b ( 0 ) and hence H x ( j ) = G x ( j ) + G z ( j ) z ( j ) x ( 0 ) + G b ( j ) b ( j ) x ( 0 ) = G x ( j ) + G z ( j ) 1 b ( 0 ) ± G b ( j ) 2 x ( 0 ) If j > 0 , then for k = 1 , , j -1 H b ( 0 ) = G b ( 0 ) + G z ( j ) z ( j ) b ( 0 ) = G b ( 0 ) - G z ( j ) z ( j ) b ( 0 ) H x ( j ) = G x ( j ) + G z ( j ) z ( j ) x ( j ) + G b ( j ) b ( j ) x ( j ) = G x ( j ) + G z ( j ) 1 b ( 0 ) ± G b ( j ) 2 x ( 0 ) H x ( 0 ) = G x ( 0 ) + G z ( j ) z ( j ) x ( 0 ) + G b ( j ) b ( j ) x ( 0 ) = G x ( 0 ) ± G b ( j ) 2 x ( j ) H x ( k ) = G x ( k ) + G z ( j ) z ( j ) x ( k ) + G b ( j ) b ( j ) x ( k ) = G x ( k ) ± G b ( j ) 2 x ( j - k ) H z ( k ) = G z ( k ) + G z ( j ) z ( j ) z ( k ) + G b ( j ) b ( j ) z ( k ) = G z ( k ) - G z ( j ) k b ( j - k ) j b ( 0 ) H b ( j - k ) = G b ( j - k ) + G z ( j ) z ( j ) b ( j - k ) + G b ( j ) b ( j ) b ( j - k ) = G b ( j - k ) - G z ( j ) k z ( k ) j b ( 0 )
Input File: omh/theory/atan_reverse.omh cppad-20160000.1/doc/asin_reverse.xml0000644000175200017650000011711512656322007016404 0ustar coincoin-web Inverse Sine and Hyperbolic Sine Reverse Mode Theory
Prev Next asin_reverse Headings

Inverse Sine and Hyperbolic Sine Reverse Mode Theory
We use the reverse theory standard math function definition for the functions H and G . In addition, we use the forward mode notation in asin_forward for Q ( t ) = 1 X ( t ) * X ( t ) B ( t ) = Q ( t ) We use q and b for the p-th order Taylor coefficient row vectors corresponding to these functions and replace z ( j ) by ( z ( j ) , b ( j ) ) in the definition for G and H . The zero order forward mode formulas for the asin function are q ( 0 ) = 1 x ( 0 ) x ( 0 ) b ( 0 ) = q ( 0 ) z ( 0 ) = F ( x ( 0 ) ) where F ( x ) = asin ( x ) for - and F ( x ) = asinh ( x ) for + . For the orders j greater than zero we have q ( j ) = k = 0 j x ( k ) x ( j - k ) b ( j ) = 1 j 1 b ( 0 ) (j 2 q ( j ) - k = 1 j -1 k b ( k ) b ( j - k ) ) z ( j ) = 1 j 1 b ( 0 ) (j x ( j ) - k = 1 j -1 k z ( k ) b ( j - k ) ) If j = 0 , we note that F ( 1 ) ( x ( 0 ) ) = 1 / b ( 0 ) and hence H x ( j ) = G x ( j ) + G z ( j ) z ( j ) x ( 0 ) + G b ( j ) b ( j ) q ( 0 ) q ( 0 ) x ( 0 ) = G x ( j ) + G z ( j ) 1 b ( 0 ) G b ( j ) x ( 0 ) b ( 0 ) If j > 0 , then for k = 1 , , j -1 H b ( 0 ) = G b ( 0 ) + G z ( j ) z ( j ) b ( 0 ) + G b ( j ) b ( j ) b ( 0 ) = G b ( 0 ) - G z ( j ) z ( j ) b ( 0 ) - G b ( j ) b ( j ) b ( 0 ) H x ( 0 ) = G x ( 0 ) + G b ( j ) b ( j ) q ( j ) q ( j ) x ( 0 ) = G x ( 0 ) G b ( j ) x ( j ) b ( 0 ) H x ( j ) = G x ( j ) + G z ( j ) z ( j ) x ( j ) + G b ( j ) b ( j ) q ( j ) q ( j ) x ( j ) = G x ( j ) + G z ( j ) 1 b ( 0 ) G b ( j ) x ( 0 ) b ( 0 ) H b ( j - k ) = G b ( j - k ) + G z ( j ) z ( j ) b ( j - k ) + G b ( j ) b ( j ) b ( j - k ) = G b ( j - k ) - G z ( j ) k z ( k ) j b ( 0 ) - G b ( j ) b ( k ) b ( 0 ) H x ( k ) = G x ( k ) + G z ( j ) z ( j ) x ( k ) + G b ( j ) b ( j ) q ( j ) q ( j ) x ( k ) = G x ( k ) G b ( j ) x ( j - k ) b ( 0 ) H z ( k ) = G z ( k ) + G z ( j ) z ( j ) z ( k ) + G b ( j ) b ( j ) z ( k ) = G z ( k ) - G z ( j ) k b ( j - k ) j b ( 0 )
Input File: omh/theory/asin_reverse.omh cppad-20160000.1/doc/acos_reverse.xml0000644000175200017650000011752712656322007016406 0ustar coincoin-web Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
Prev Next acos_reverse Headings

Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
We use the reverse theory standard math function definition for the functions H and G . In addition, we use the forward mode notation in acos_forward for Q ( t ) = ( X ( t ) * X ( t ) - 1 ) B ( t ) = Q ( t ) We use q and b for the p-th order Taylor coefficient row vectors corresponding to these functions and replace z ( j ) by ( z ( j ) , b ( j ) ) in the definition for G and H . The zero order forward mode formulas for the acos function are q ( 0 ) = ( x ( 0 ) x ( 0 ) - 1 ) b ( 0 ) = q ( 0 ) z ( 0 ) = F ( x ( 0 ) ) where F ( x ) = acos ( x ) for - and F ( x ) = acosh ( x ) for + . For orders j greater than zero we have q ( j ) = k = 0 j x ( k ) x ( j - k ) b ( j ) = 1 j 1 b ( 0 ) (j 2 q ( j ) - k = 1 j -1 k b ( k ) b ( j - k ) ) z ( j ) = 1 j 1 b ( 0 ) ( j x ( j ) - k = 1 j -1 k z ( k ) b ( j - k ) ) If j = 0 , we note that F ( 1 ) ( x ( 0 ) ) = 1 / b ( 0 ) and hence H x ( j ) = G x ( j ) + G z ( j ) z ( j ) x ( 0 ) + G b ( j ) b ( j ) q ( 0 ) q ( 0 ) x ( 0 ) = G x ( j ) G z ( j ) 1 b ( 0 ) G b ( j ) x ( 0 ) b ( 0 ) If j > 0 , then for k = 1 , , j -1 H b ( 0 ) = G b ( 0 ) + G z ( j ) z ( j ) b ( 0 ) + G b ( j ) b ( j ) b ( 0 ) = G b ( 0 ) - G z ( j ) z ( j ) b ( 0 ) - G b ( j ) b ( j ) b ( 0 ) H x ( 0 ) = G x ( 0 ) + G b ( j ) b ( j ) q ( j ) q ( j ) x ( 0 ) = G x ( 0 ) G b ( j ) x ( j ) b ( 0 ) H x ( j ) = G x ( j ) + G z ( j ) z ( j ) x ( j ) + G b ( j ) b ( j ) q ( j ) q ( j ) x ( j ) = G x ( j ) G z ( j ) 1 b ( 0 ) G b ( j ) x ( 0 ) b ( 0 ) H b ( j - k ) = G b ( j - k ) + G z ( j ) z ( j ) b ( j - k ) + G b ( j ) b ( j ) b ( j - k ) = G b ( j - k ) - G z ( j ) k z ( k ) j b ( 0 ) - G b ( j ) b ( k ) b ( 0 ) H x ( k ) = G x ( k ) + G z ( j ) z ( j ) x ( k ) + G b ( j ) b ( j ) q ( j ) q ( j ) x ( k ) = G x ( k ) G b ( j ) x ( j - k ) b ( 0 ) H z ( k ) = G z ( k ) + G z ( j ) z ( j ) z ( k ) + G b ( j ) b ( j ) z ( k ) = G z ( k ) - G z ( j ) k b ( j - k ) j b ( 0 )
Input File: omh/theory/acos_reverse.omh cppad-20160000.1/doc/tan_reverse.xml0000644000175200017650000005657012656322007016243 0ustar coincoin-web 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/theory/tan_reverse.omh cppad-20160000.1/doc/erf_reverse.xml0000644000175200017650000003324612656322007016230 0ustar coincoin-web 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/theory/erf_reverse.omh cppad-20160000.1/doc/reverse_identity.xml0000644000175200017650000011075512656322007017306 0ustar coincoin-web 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/theory/reverse_identity.omh cppad-20160000.1/doc/glossary.xml0000644000175200017650000011404312656322007015557 0ustar coincoin-web 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.

Sparsity Pattern
CppAD describes a sparse matrix as a vector of sets with each vector component corresponding to a row and the elements of the set corresponding to the possibly non-zero columns. A vector of bool can represent a vector of sets using one bit per element. (Some vectors of bool use one byte per element but vectorBool is an example class that uses one bit per element.) The problem is that this representation uses one bit for both the elements that are there and the ones that are not.

A vector of std::set<size_t> does not represent the elements that are not present, but it uses about three size_t values for each element that is present. For example, if size_t uses 32 bits, a vector of std::set<size_t> uses about 100 bits for each element that is present in the vector of sets. Thus, a vector of std::set<size_t> should be more efficient for very sparse matrix representations.

Vector of Boolean
Given a matrix A B m × n , a vector of bool B of length m × n is a sparsity pattern for A if for i = 0 , , m -1 and j = 0 , n -1 , A i , j 0 B i * n + j = true Given two sparsity patterns B and C for a matrix A , we say that B is more efficient than C if B has fewer true elements than C . For example, if A is the identity matrix, B i * n + j = ( i = j ) defines an efficient sparsity pattern for A .

Vector of Sets
Given a matrix A B m × n , a vector of sets S of length m is a sparsity pattern for A if for i = 0 , , m -1 A i , j 0 j S i Given two sparsity patterns S and T for a matrix A , we say that S is more efficient than T if S has fewer elements than T . For example, if A is the identity matrix, S i = { i } defines an efficient sparsity pattern for A .

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/glossary.omh cppad-20160000.1/doc/_glossary_xml.js0000644000175200017650000000431712656322007016414 0ustar coincoin-webvar 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', '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#Sparsity Pattern', 'glossary.xml#Sparsity Pattern.Vector of Boolean', '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]; } cppad-20160000.1/doc/bib.xml0000644000175200017650000000707312656322007014454 0ustar coincoin-web 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/bib.omh cppad-20160000.1/doc/wish_list.xml0000644000175200017650000002634512656322007015730 0ustar coincoin-web The CppAD Wish List
Prev Next wish_list

The CppAD Wish List

Base Requirements
Change the Base requirements to use template specialization instead of functions so that there is a default value for each function. The default would result in a known assert when the operation is used and not defined by the base class. An example of this type of template specialization can be found in the implementation of to_string .

PrintFor Optimization
Do not remove PrintFor operations during optimize because they are very useful when debugging expected calculations on the tape. If not this, we at least need to disable optimization of checkpoint functions.

checkpoint
There should be some examples and tests for both speed and memory use that demonstrate that checkpointing is useful.

Machine Epsilon in Examples
Use a multiple of std::numeric_limits<double>::epsilon() instead 1e-10 for a small number in correctness checks; e.g., see sqrt.cpp .

Adolc
Create a documentation page that shows how to convert Adolc commands to CppAD commands.

Optimizing Nested Conditional Expressions
If one optimizes the code
 
     x = CondExpLt(left_x, right_x, true_x, false_x)
     y = CondExpGt(left_y, right_y, true_y, false_y)
     z = CondExpEq(left_z, right_z, x, y)
only two of the expressions true_x, false_x, true_y, false_y will be evaluated (two will be skipped depending on the result of left_z == right_z). Not all of the expressions corresponding to left_x, right_x, left_y, right_y need to be evaluate, but they are. The optimizer could be improved to skip two more expressions (depending on the result of left_z == right_z).

Forward Mode Recomputation
If the results of forward_order have already been computed and are still stored in the ADFun object (see size_order ), then they do not need to be recomputed and the results can just be returned.

Iterator Interface
All of the CppAD simple vector interfaces should also have an iterator version for the following reasons:
  1. It would not be necessary to copy information to simple vectors when it was originally stored in a different type of container.
  2. It would not be necessary to reallocate memory for a result that is repeatedly calculated (because an iterator for the result container would be passed in).


Compilation Speed
One could build a CppAD library for use with the type AD<double>. This would speed up compilation for the most common usage where the Base type is double.

Operation Sequence
It is possible to detect if the AD of Base operation sequence does not depend on any of the independent variable values. This could be returned as an extra seq_property .

Comparison Changes and Optimization
The comparison operators used to not be taped when NDEBUG was defined. They are now taped so that the compare_change interface works even for compiler optimize code. This caused a significant slow down in the cppad_det_lu.cpp speed test (with no options specified). Perhaps there should be an option to skip the comparison taping.

Software Guidelines
The following is a list of some software guidelines taken from boost . These guidelines are not followed by the current CppAD source code, but perhaps they should be:
  1. Names (except as noted below) should be all lowercase, with words separated by underscores. For example, acronyms should be treated as ordinary names (xml_parser instead of XML_parser).
  2. Template parameter names should begin with an uppercase letter.
  3. Use spaces rather than tabs. Currently, CppAD uses a tabs stops at column multiples of 5. Five columns were chosen to avoid high levels of indenting and to allow for
     
         if( expression )
              statement
         else statement
    
    with a tab after the else. Automatic conversion to actual spaces should be easy.


Tracing
Add tracing the operation sequence to the user API and documentation. Tracing the operation sequence is currently done by changing the CppAD source code. Use the command
 
     grep '^# *define *CPPAD_.*_TRACE' cppad/local/*.hpp
to find all the possible tracing flags.

atan2
The atan2 function could be made faster by adding a special operator for it.

BenderQuad
See the problem with the current BenderQuad specifications.
Input File: omh/wish_list.omh cppad-20160000.1/doc/whats_new.xml0000644000175200017650000001111112656322007015703 0ustar coincoin-web 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_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/whats_new/whats_new.omh cppad-20160000.1/doc/whats_new_14.xml0000644000175200017650000007751212656322010016222 0ustar coincoin-web 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_hes_sparse.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 auto-tools 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 auto-tools 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/whats_new/whats_new_14.omh cppad-20160000.1/doc/whats_new_13.xml0000644000175200017650000007215112656322010016213 0ustar coincoin-web 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 auto_tools (created when optional implicit constructor from any type was added). This has been fixed by adding the --with-implicit_ctor option (later changed to --with-deprecated ).


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 nesting conditional expressions .

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 auto_tools ) 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_any.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/whats_new/whats_new_13.omh cppad-20160000.1/doc/whats_new_12.xml0000644000175200017650000021424012656322010016207 0ustar coincoin-web 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 auto_tools 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 auto_tools 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 .
  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 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 .
  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/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 .

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 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 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 multi_thread/test.sh from source directory (no need to copy to build directory).


01-16
The test program 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, in the file multi_newton_work.cpp .
  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_work.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.cpp 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_combine 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/whats_new/whats_new_12.omh cppad-20160000.1/doc/whats_new_11.xml0000644000175200017650000020306212656322010016206 0ustar coincoin-web 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.cpp .
  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_work.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 multi_thread/openmp. and create 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 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 auto_tools 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 sparsity 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. Change to openmp/run.sh maximum number of threads instead of specifying the entire set of values to be tested.
  2. Change settings for newton_example so that n_gird is a multiple of the maximum number of threads.
  3. Report dynamic number of thread results as a separate result in the summary output line.
  4. Fix automatic removal of executables from openmp directory (was commented out).
  5. 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.

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 download 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/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/whats_new/whats_new_11.omh cppad-20160000.1/doc/whats_new_10.xml0000644000175200017650000005404412656322010016211 0ustar coincoin-web 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/whats_new/whats_new_10.omh cppad-20160000.1/doc/whats_new_09.xml0000644000175200017650000011111412656322010016211 0ustar coincoin-web 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 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/whats_new/whats_new_09.omh cppad-20160000.1/doc/whats_new_08.xml0000644000175200017650000010201012656322010016203 0ustar coincoin-web 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 computed 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/whats_new/whats_new_08.omh cppad-20160000.1/doc/whats_new_07.xml0000644000175200017650000017663312656322010016230 0ustar coincoin-web 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/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 computed 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 computed assignment operators has been grouped together. In addition, a computed 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_any.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/whats_new/whats_new_07.omh cppad-20160000.1/doc/whats_new_06.xml0000644000175200017650000024240612656322010016217 0ustar coincoin-web 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_main.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 example.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 .

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 , compute_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 computed 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/whats_new/whats_new_06.omh cppad-20160000.1/doc/whats_new_05.xml0000644000175200017650000017215612656322010016222 0ustar coincoin-web 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 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 ADTape<Base> tape;
          static 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 ADTape<Base> *Tape(void)
     {    static 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_any.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 compute_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/whats_new/whats_new_05.omh cppad-20160000.1/doc/whats_new_04.xml0000644000175200017650000021175612656322010016221 0ustar coincoin-web 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/whats_new/whats_new_04.omh cppad-20160000.1/doc/whats_new_03.xml0000644000175200017650000015170312656322010016213 0ustar coincoin-web 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 computed 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/whats_new/whats_new_03.omh cppad-20160000.1/doc/omp_alloc.xml0000644000175200017650000001655512656322010015664 0ustar coincoin-web 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/deprecated/omp_alloc.omh cppad-20160000.1/doc/omp_inuse.xml0000644000175200017650000001335612656322010015711 0ustar coincoin-web 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 cppad-20160000.1/doc/deprecated.xml0000644000175200017650000001314112656322010016003 0ustar coincoin-web 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
CppADCreateUnaryBool AD Boolean Functions
CppADCreateDiscrete Discrete AD Functions
auto_tools Auto Tools Unix Test and Installation
nan(zero) nan(zero)

Input File: omh/deprecated/deprecated.omh cppad-20160000.1/doc/fundeprecated.xml0000644000175200017650000004330312656322010016517 0ustar coincoin-web 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/deprecated/fun_deprecated.omh cppad-20160000.1/doc/_fundeprecated_xml.js0000644000175200017650000000517712656322010017361 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_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]; } cppad-20160000.1/doc/comparechange.xml0000644000175200017650000002126612656322010016506 0ustar coincoin-web 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/deprecated/compare_change.omh cppad-20160000.1/doc/omp_max_thread.xml0000644000175200017650000001450712656322010016701 0ustar coincoin-web 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/local/omp_max_thread.hpp cppad-20160000.1/doc/tracknewdel.xml0000644000175200017650000005447412656322010016224 0ustar coincoin-web 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 cppad-20160000.1/doc/tracknewdel.cpp.xml0000644000175200017650000000671412656322010016777 0ustar coincoin-web Tracking Use of New and Delete: Example and Test
Prev Next TrackNewDel.cpp Headings

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 lenght 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 lenght 10
	newlen = 10;
	ptr    = CPPAD_TRACK_EXTEND(newlen, ncopy, ptr);

	// copy data into the new part of the array
	for(i = ncopy; i < newlen; i++)
		ptr[i] = double(i);

	// check the values in the array
	for(i = 0; i < newlen; i++)
		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: test_more/track_new_del.cpp cppad-20160000.1/doc/_omp_alloc_xml.js0000644000175200017650000000456612656322010016516 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/omp_in_parallel.xml0000644000175200017650000001161112656322010017040 0ustar coincoin-web 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 cppad-20160000.1/doc/omp_get_thread_num.xml0000644000175200017650000001172212656322010017546 0ustar coincoin-web 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 cppad-20160000.1/doc/omp_get_memory.xml0000644000175200017650000001672412656322010016737 0ustar coincoin-web 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 cppad-20160000.1/doc/omp_return_memory.xml0000644000175200017650000001402512656322010017467 0ustar coincoin-web 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 cppad-20160000.1/doc/omp_free_available.xml0000644000175200017650000001206112656322010017477 0ustar coincoin-web 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 cppad-20160000.1/doc/_omp_inuse_xml.js0000644000175200017650000000433312656322010016537 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/omp_available.xml0000644000175200017650000001344612656322010016506 0ustar coincoin-web 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 cppad-20160000.1/doc/omp_create_array.xml0000644000175200017650000002244512656322010017226 0ustar coincoin-web 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 cppad-20160000.1/doc/omp_delete_array.xml0000644000175200017650000001571412656322010017226 0ustar coincoin-web 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 cppad-20160000.1/doc/omp_efficient.xml0000644000175200017650000001721512656322010016520 0ustar coincoin-web 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 cppad-20160000.1/doc/old_max_num_threads.xml0000644000175200017650000001202712656322010017721 0ustar coincoin-web 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 cppad-20160000.1/doc/omp_alloc.cpp.xml0000644000175200017650000002022412656322010016431 0ustar coincoin-web 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: test_more/omp_alloc.cpp cppad-20160000.1/doc/memory_leak.xml0000644000175200017650000002275612656322010016223 0ustar coincoin-web 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 cppad-20160000.1/doc/epsilon.xml0000644000175200017650000001174212656322010015361 0ustar coincoin-web 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/local/epsilon.hpp cppad-20160000.1/doc/test_vector.xml0000644000175200017650000002145112656322010016247 0ustar coincoin-web 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/local/test_vector.hpp cppad-20160000.1/doc/cppad_ipopt_nlp.xml0000644000175200017650000022164112656322010017064 0ustar coincoin-web 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 cppad-20160000.1/doc/ipopt_nlp_get_started.cpp.xml0000644000175200017650000002352712656322010021066 0ustar coincoin-web 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 cppad-20160000.1/doc/ipopt_nlp_ode.xml0000644000175200017650000000733712656322010016550 0ustar coincoin-web 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 cppad-20160000.1/doc/ipopt_nlp_ode_problem.xml0000644000175200017650000013405412656322010020265 0ustar coincoin-web 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 cppad-20160000.1/doc/ipopt_nlp_ode_problem.hpp.xml0000644000175200017650000001076512656322010021055 0ustar coincoin-web ODE Inverse Problem Definitions: Source Code
Prev Next ipopt_nlp_ode_problem.hpp Headings

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 cppad-20160000.1/doc/ipopt_nlp_ode_simple.hpp.xml0000644000175200017650000001171512656322010020702 0ustar coincoin-web ODE Fitting Using Simple Representation
Prev Next ipopt_nlp_ode_simple.hpp Headings

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 cppad-20160000.1/doc/ipopt_nlp_ode_fast.hpp.xml0000644000175200017650000001557712656322010020360 0ustar coincoin-web ODE Fitting Using Fast Representation
Prev Next ipopt_nlp_ode_fast.hpp Headings

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 cppad-20160000.1/doc/ipopt_nlp_ode_simple.xml0000644000175200017650000003117112656322010020112 0ustar coincoin-web 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 cppad-20160000.1/doc/ipopt_nlp_ode_fast.xml0000644000175200017650000012107412656322010017560 0ustar coincoin-web 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 cppad-20160000.1/doc/ipopt_nlp_ode_run.hpp.xml0000644000175200017650000001326712656322010020221 0ustar coincoin-web Driver for Running the Ipopt ODE Example
Prev Next ipopt_nlp_ode_run.hpp Headings

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 cppad-20160000.1/doc/ipopt_nlp_ode_check.cpp.xml0000644000175200017650000001243512656322010020461 0ustar coincoin-web Correctness Check for Both Simple and Fast Representations
Prev Next ipopt_nlp_ode_check.cpp Headings

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;
	double max_step = 0.;
	for(i = 1; i <= Nz; i++)
	{	S[i] = S[i-1] + N[i];
		max_step = std::max(max_step, (s[i] - s[i-1]) / 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 cppad-20160000.1/doc/ipopt_ode_speed.cpp.xml0000644000175200017650000001063112656322010017627 0ustar coincoin-web Speed Test for Both Simple and Fast Representations
Prev Next ipopt_ode_speed.cpp Headings

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 cppad-20160000.1/doc/old_atomic.xml0000644000175200017650000037762312656322010016037 0ustar coincoin-web 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/local/old_atomic.hpp cppad-20160000.1/doc/old_reciprocal.cpp.xml0000644000175200017650000003603212656322010017451 0ustar coincoin-web 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.
	void my_union(
		std::set<size_t>&         result  ,
		const std::set<size_t>&   left    ,
		const std::set<size_t>&   right   )
	{	std::set<size_t> temp;
		std::set_union(
			left.begin()              ,
			left.end()                ,
			right.begin()             ,
			right.end()               ,
			std::inserter(temp, temp.begin())
		);
		result.swap(temp);
	}

	// ----------------------------------------------------------------------
	// forward mode routine called by CppAD
	bool reciprocal_forward(
		size_t                   id ,
		size_t                    k ,
		size_t                    n ,
		size_t                    m ,
		const vector<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] )
			my_union(v[0], 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: test_more/old_reciprocal.cpp cppad-20160000.1/doc/old_usead_1.cpp.xml0000644000175200017650000003447712656322010016662 0ustar coincoin-web 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: test_more/old_usead_1.cpp cppad-20160000.1/doc/old_usead_2.cpp.xml0000644000175200017650000004553112656322010016654 0ustar coincoin-web 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] / 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: test_more/old_usead_2.cpp cppad-20160000.1/doc/old_tan.cpp.xml0000644000175200017650000004031212656322010016104 0ustar coincoin-web 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.
	void my_union(
		std::set<size_t>&         result  ,
		const std::set<size_t>&   left    ,
		const std::set<size_t>&   right   )
	{	std::set<size_t> temp;
		std::set_union(
			left.begin()              ,
			left.end()                ,
			right.begin()             ,
			right.end()               ,
			std::inserter(temp, temp.begin())
		);
		result.swap(temp);
	}

	// ----------------------------------------------------------------------
	// forward mode routine called by CppAD
	bool old_tan_forward(
		size_t                   id ,
		size_t                order ,
		size_t                    n ,
		size_t                    m ,
		const vector<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] = tan( tx[0] );
			else	tzy[0] = tanh( tx[0] );

			// y^{(0)} = z^{(0)} * z^{(0)}
			tzy[n_order + 0] = tzy[0] * tzy[0];
		}
		else
		{	float j_inv = 1.f / float(j);
			if( id == 1 )
				j_inv = - j_inv;

			// z^{(j)} = x^{(j)} +- sum_{k=1}^j k x^{(k)} y^{(j-k)} / j
			tzy[j] = tx[j];
			for(k = 1; k <= j; k++)
				tzy[j] += tx[k] * tzy[n_order + j-k] * k * j_inv;

			// y^{(j)} = sum_{k=0}^j z^{(k)} z^{(j-k)}
			tzy[n_order + j] = 0.;
			for(k = 0; k <= j; k++)
				tzy[n_order + j] += tzy[k] * tzy[j-k];
		}

		// All orders are implemented and there are no possible errors
		return true;
	}
	// ----------------------------------------------------------------------
	// reverse mode routine called by CppAD
	bool old_tan_reverse(
		size_t                   id ,
		size_t                order ,
		size_t                    n ,
		size_t                    m ,
		const vector<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] * k * j_inv;

			// H_{y^{j-k)} += +- H_{z^{(j)} x^{(k)} * k / j
			for(k = 1; k <= j; k++)
				qzy[n_order + j-k] += qzy[j] * tx[k] * k * j_inv;

			// H_{z^{(k)}} += H_{y^{(j-1)}} * z^{(j-k-1)} * 2.
			for(k = 0; k < j; k++)
				qzy[k] += qzy[n_order + j-1] * tzy[j-k-1] * 2.f;
		}

		// eliminate order zero
		if( id == 0 )
			px[0] += qzy[0] * (1.f + tzy[n_order + 0]);
		else
			px[0] += qzy[0] * (1.f - tzy[n_order + 0]);

		return true;
	}
	// ----------------------------------------------------------------------
	// forward Jacobian sparsity routine called by CppAD
	bool old_tan_for_jac_sparse(
		size_t                               id ,
		size_t                                n ,
		size_t                                m ,
		size_t                                p ,
		const vector< std::set<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]
		my_union(r[0], s[0], s[1]);
		return true;
	}
	// ----------------------------------------------------------------------
	// reverse Hessian sparsity routine called by CppAD
	bool old_tan_rev_hes_sparse(
		size_t                               id ,
		size_t                                n ,
		size_t                                m ,
		size_t                                p ,
		const vector< std::set<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, ...
		my_union(v[0], u[0], u[1]);

		// convert forward Jacobian sparsity to Hessian sparsity
		// because tan and tanh are nonlinear
		if( t[0] )
			my_union(v[0], v[0], r[0]);

		return true;
	}
	// ---------------------------------------------------------------------
	// Declare the AD<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: test_more/old_tan.cpp cppad-20160000.1/doc/old_mat_mul.cpp.xml0000644000175200017650000002661612656322010016773 0ustar coincoin-web 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; see atomic_mat_mul.cpp .

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] = 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] = 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: test_more/old_mat_mul.cpp cppad-20160000.1/doc/old_mat_mul.hpp.xml0000644000175200017650000005042512656322010016773 0ustar coincoin-web 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
 
     void my_union(
          std::set<size_t>&         result  ,
          const std::set<size_t>&   left    ,
          const std::set<size_t>&   right   )
     {    std::set<size_t> temp;
          std::set_union(
               left.begin()              ,
               left.end()                ,
               right.begin()             ,
               right.end()               ,
               std::inserter(temp, temp.begin())
          );
          result.swap(temp);
     }

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] )
                         my_union(s[ij_result], s[ij_result], r[im_left]);

                         // s[ij_result] = union( s[ij_result], r[mj_right] )
                         my_union(s[ij_result], s[ij_result], r[mj_right]);
                    }
               }
          }
          return true;
     }
     // ----------------------------------------------------------------------
     // reverse Jacobian sparsity routine called by CppAD
     bool mat_mul_rev_jac_sparse(
          size_t                               id ,
          size_t                                n ,
          size_t                                m ,
          size_t                                p ,
          vector< std::set<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] )
                         my_union(r[im_left], r[im_left], s[ij_result]);

                         // r[mj_right] = union( r[mj_right], s[ij_result] )
                         my_union(r[mj_right], r[mj_right], s[ij_result]);
                    }
               }
          }
          return true;
     }
     // ----------------------------------------------------------------------
     // reverse Hessian sparsity routine called by CppAD
     bool mat_mul_rev_hes_sparse(
          size_t                               id ,
          size_t                                n ,
          size_t                                m ,
          size_t                                p ,
          const vector< std::set<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] )
                         my_union(v[im_left],  v[im_left],  u[ij_result] );
                         my_union(v[mj_right], v[mj_right], u[ij_result] );

                         // Check for case where the (i,j) result element
                         // is in reverse Jacobian and both left and right
                         // operands in multiplication are variables
                         if(s[ij_result] & (*vx_)[im_left] & (*vx_)[mj_right])
                         {    // v[im_left] = union( v[im_left], r[mj_right] )
                              my_union(v[im_left], v[im_left], r[mj_right] );
                              // v[mj_right] = union( v[mj_right], r[im_left] )
                              my_union(v[mj_right], v[mj_right], r[im_left] );
                         }
                    }
               }
          }
          return true;
     }

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: test_more/old_mat_mul.hpp cppad-20160000.1/doc/zdouble.xml0000644000175200017650000004160312656322010015353 0ustar coincoin-web zdouble: An AD Base Type With Absolute Zero
Prev Next

zdouble: An AD Base Type With Absolute Zero

Deprecated 2015-09-26
Use the function azmul instead.

Absolute Zero
The zdouble class acts like the double type with the added property that zero times any value is zero. This includes zero time nan and zero times infinity. In addition, zero divided by any value and any value times zero are also zero.

Syntax

Constructor and Assignment
    zdouble z
    zdouble z(x)
    z1 op x
where x is a double or zdouble object and op is =, +=, -=, *= or /=-.

Comparison Operators
    b = z op x
    b = x op z
where b is a bool object, z is a zdouble object, x is a double or zdouble object, and op is ==, !=, <=, >=, < or >.

Arithmetic Operators
    z2 = z1 op x
    z2 = x op z1
where z1 , z2 are zdouble objects, x is a double or zdouble object, and op is +, -, * or /.

Standard Math
    z2 = fun(z1)
    z3 = pow(z1z2)
where z1 , z2 , z3 are zdouble objects and fun is a unary_standard_math function.

Nan
There is a specialization of nan so that
    z2
 = nan(z1)
returns 'not a number' when z1 has type zdouble. Note that this template function needs to be specialized because  zdouble(0.0) ==  zdouble(0.0) / zdouble(0.0)

Motivation

General
Often during computing (and more so in parallel computing) alternative values for an expression are computed and one of the alternatives is chosen using some boolean variable. This is often represented by
     
result = flag * value_if_true + (1 - flag) * value_if_false
where flag is one for true and zero for false. This representation does not work for double when the value being multiplied by zero is +inf, -inf, or nan.

CppAD
In CppAD one can use conditional expressions to achieve the representation
     
result = flag * value_if_true + (1 - flag) * value_if_false
This works fine except when there are multiple levels of AD ; e.g., when using AD< AD<double> > . In this case the corresponding AD function objects have type ADFun< AD<double> > . When these AD function objects compute derivatives using reverse mode, the conditional expressions are represented use zeros to multiply the expression that is not used. Using AD< AD<zdouble> > instead of AD< AD<double> > makes this representation work and fixes the problem.

Base Type Requirements
The type zdouble satisfies all of the CppAD base type requirements .

Example
The file zdouble.cpp contains an example and test of this class. It returns true if it succeeds and false otherwise.
Input File: cppad/local/zdouble.hpp cppad-20160000.1/doc/zdouble.cpp.xml0000644000175200017650000001274112656322010016135 0ustar coincoin-web zdouble: Example and Test
Prev Next zdouble.cpp Headings

zdouble: Example and Test
 
# include <cppad/cppad.hpp>

namespace {
	template <class Base> bool test(bool is_double)
	{	bool ok = true;
		Base eps = 10. * std::numeric_limits<double>::epsilon();

		typedef CppAD::AD<Base>   a1type;
		typedef CppAD::AD<a1type> a2type;

		// value during taping
		size_t n = 2;
		CPPAD_TESTVECTOR(Base) x(n);
		x[0] = 0.0;
		x[1] = 0.0;

		// declare independent variable
		CPPAD_TESTVECTOR(a2type) a2x(n);
		for (size_t j = 0; j < n; j++)
			a2x[j] = a2type( a1type(x[j]) );
		Independent(a2x);

		// zero and one as a2type values
		a2type a2zero = a2type(0.0);
		a2type a2one  = a2type(1.0);

		// h(x) = x[0] / x[1] if x[1] > x[0] else 1.0
		a2type h_x = CondExpGt(a2x[1], a2x[0], a2x[0] / a2x[1], a2one);

		// f(x) = h(x) if x[0] > 0.0 else 0.0
		//      = x[0] / x[1] if x[1] > x[0]  and x[0] > 0.0
		//      = 1.0         if x[0] >= x[1] and x[0] > 0.0
		//      = 0.0         if x[0] <= 0.0
		a2type f_x = CondExpGt(a2x[0], a2zero, h_x, a2one);

		// define the function f(x)
		size_t m = 1;
		CPPAD_TESTVECTOR(a2type) a2y(m);
		a2y[0] = f_x;
		CppAD::ADFun<a1type> af1;
		af1.Dependent(a2x, a2y);

		// Define function g(x) = gradient of f(x)
		CPPAD_TESTVECTOR(a1type) a1x(n), a1z(n), a1w(m);
		for (size_t j = 0; j < n; j++)
			a1x[j] = a1type(x[j]);
		a1w[0] = a1type(1.0);
		Independent(a1x);
		af1.Forward(0, a1x);
		a1z = af1.Reverse(1, a1w);
		CppAD::ADFun<Base> g;
		g.Dependent(a1x, a1z);

		// check result for a case where f(x) = 0.0;
		CPPAD_TESTVECTOR(Base) z(2);
		x[0] = 0.0;
		x[1] = 0.0;
		z    = g.Forward(0, x);
		ok &= z[0] == 0.0;
		ok &= z[1] == 0.0;

		// check result for a case where f(x) = 1.0;
		x[0] = 1.0;
		x[1] = 0.5;
		z    = g.Forward(0, x);
		ok &= z[0] == 0.0;
		ok &= z[1] == 0.0;

		// check result for a case where f(x) = x[0] / x[1];
		x[0] = 1.0;
		x[1] = 2.0;
		z    = g.Forward(0, x);
		ok &= CppAD::NearEqual(z[0], 1.0/x[1], eps, eps);
		ok &= CppAD::NearEqual(z[1], - x[0]/(x[1]*x[1]), eps, eps);

		return ok;
	}
}

bool zdouble(void)
{	bool ok = true;
	using CppAD::AD;
	using CppAD::NearEqual;
	using CppAD::zdouble;
	//
	bool is_double = false;
	ok &= test<zdouble>(is_double);
	//
	is_double = true;
	ok &= test<double>(is_double);
	//
	return ok;
}


Input File: test_more/zdouble.cpp cppad-20160000.1/doc/compare_c.xml0000644000175200017650000001072512656322010015640 0ustar coincoin-web Compare Speed of C and C++
Prev Next

Compare Speed of C and C++

Syntax
compare_c/det_by_minor_c
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: compare_c/CMakeLists.txt cppad-20160000.1/doc/det_of_minor_c.xml0000644000175200017650000005223212656322010016655 0ustar coincoin-web 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: compare_c/det_by_minor.c cppad-20160000.1/doc/det_by_minor_c.xml0000644000175200017650000002074512656322010016667 0ustar coincoin-web 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: compare_c/det_by_minor.c cppad-20160000.1/doc/uniform_01_c.xml0000644000175200017650000001367612656322010016201 0ustar coincoin-web 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(seed); }
void uniform_01(unsigned n, double* a)
{    static double factor = 1. / (double) RAND_MAX;
     while(n--)
          a[n] = rand() * factor;
}

Input File: compare_c/det_by_minor.c cppad-20160000.1/doc/correct_det_by_minor_c.xml0000644000175200017650000001054312656322010020403 0ustar coincoin-web 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] );

     if( fabs(det / check - 1.0) < 1e-10 )
          return true;
     return false;
}

Input File: compare_c/det_by_minor.c cppad-20160000.1/doc/repeat_det_by_minor_c.xml0000644000175200017650000001144412656322010020223 0ustar coincoin-web 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: compare_c/det_by_minor.c cppad-20160000.1/doc/elapsed_seconds_c.xml0000644000175200017650000001233112656322010017340 0ustar coincoin-web 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: compare_c/det_by_minor.c cppad-20160000.1/doc/time_det_by_minor_c.xml0000644000175200017650000001465312656322010017706 0ustar coincoin-web 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: compare_c/det_by_minor.c cppad-20160000.1/doc/main_compare_c.xml0000644000175200017650000000712112656322010016640 0ustar coincoin-web 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: compare_c/det_by_minor.c cppad-20160000.1/doc/numeric_ad.xml0000644000175200017650000000613612656322010016017 0ustar coincoin-web 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/numeric_ad.omh cppad-20160000.1/doc/benderquad.xml0000644000175200017650000011454212656322010016024 0ustar coincoin-web 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/local/bender_quad.hpp cppad-20160000.1/doc/bender_quad.cpp.xml0000644000175200017650000003141712656322010016743 0ustar coincoin-web BenderQuad: Example and Test
Prev Next bender_quad.cpp Headings

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/bender_quad.cpp cppad-20160000.1/doc/opt_val_hes.xml0000644000175200017650000010000212656322010016177 0ustar coincoin-web 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/local/opt_val_hes.hpp cppad-20160000.1/doc/opt_val_hes.cpp.xml0000644000175200017650000003630512656322010016776 0ustar coincoin-web opt_val_hes: Example and Test
Prev Next opt_val_hes.cpp Headings

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);
	int signdet = 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/opt_val_hes.cpp cppad-20160000.1/doc/luratio.xml0000644000175200017650000007050112656322010015365 0ustar coincoin-web 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/local/lu_ratio.hpp cppad-20160000.1/doc/lu_ratio.cpp.xml0000644000175200017650000001445212656322010016310 0ustar coincoin-web LuRatio: Example and Test
Prev Next lu_ratio.cpp Headings

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;

	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  &= CppAD::NearEqual(pij, sum, 1e-10, 1e-10);
		}
	}
	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/lu_ratio.cpp cppad-20160000.1/doc/addon.xml0000644000175200017650000002177212656322010015001 0ustar coincoin-web 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
cg CppADCodeGen C++ Source Code Generation of CppAD Derivative Calculations
py pycppad A Python Interface to CppAD
tmb adcomp An R Interface to CppAD with Random Effects Modeling Utilities
mixed cppad_mixed A C++ Interface to Random Effects Laplace Approximation

Include Files
If includedir is the directory where the include files are installed, the file
     
includedir/cppad/name.hpp
and the directory
     
includedir/cppad/name
are reserved for use by the name addon.

Library Files
If libdir is the directory where CppAD library files are installed, files with the name
     
libdir/libcppad_name.ext
     
libdir/libcppad_name_anything.ext
where anything and ext are arbitrary, are reserved for use by the name addon.

Preprocessor Symbols
C++ preprocessor symbols that begin with
     CPPAD_
NAME_
where NAME is a upper-case version of name , are reserved for use by the name addon.

Namespace
The C++ namespace
     CppAD::
name
is reserved for use by the name addon.
Input File: omh/addon.omh cppad-20160000.1/doc/license.xml0000644000175200017650000011210712656322010015327 0ustar coincoin-web Your License for the CppAD Software
Prev Next License Headings

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/license.omh cppad-20160000.1/doc/_reference.xml0000644000175200017650000025724012656322010016012 0ustar coincoin-web 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.cpp
AD Absolute Value Function: Example and Test
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 Computed 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 Computed 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_for_sparse_jac
Atomic Forward Jacobian Sparsity Patterns
atomic_forward
Atomic Forward Mode
atomic_get_started.cpp
Getting Started with Atomic Operations: Example and Test
atomic_hes_sparse.cpp
Atomic Operation Hessian Sparsity: Example and Test
atomic_mat_mul.cpp
User Atomic Matrix Multiply: Example and Test
atomic_matrix_mul.hpp
Matrix Multiply as an Atomic Operation
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_jac
Atomic Reverse Jacobian Sparsity Patterns
atomic_reverse
Atomic Reverse Mode
atomic_sparsity.cpp
Atomic Sparsity Patterns: Example and Test
atomic_tangent.cpp
Tan and Tanh as User Atomic Operations: Example and Test
auto_tools
Auto Tools 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_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
bool_sparsity.cpp
Using vectorBool Sparsity To Conserve Memory: 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
CheckSimpleVector
Check Simple Vector Concept
cmake
Using CMake to Configure CppAD
cmake_check
Checking the CppAD Examples and Tests
colpack_hes.cpp
Using ColPack: Example and Test
colpack_jac.cpp
Using ColPack: 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
compute_assign
AD Computed 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-20160000.1: 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
Discrete
Discrete AD Functions
div.cpp
AD Binary Division: Example and Test
div_eq.cpp
AD Computed 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 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
example.cpp
CppAD Examples and Tests
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_main.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
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_one.cpp
First Order Partial Driver: 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
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
FunEval
Evaluate ADFun Functions, Derivatives, and Sparsity Patterns
G
General
General Examples
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-Threaded Implementation of Summation of 1/i
harmonic_time.cpp
Timing Test of Multi-Threaded Summation of 1/i
harmonic_work.cpp
Multi-threading Sum of 1/i Utility Routines
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 of All the 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
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
mul.cpp
AD Binary Multiplication: Example and Test
mul_eq.cpp
AD Computed 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_newton.cpp
A Multi-Threaded Newton's Method
multi_newton_time.cpp
Timing Test of Multi-Threaded Newton Method
multi_newton_work.cpp
Multi-threading Newton Method Utility Routines
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.cpp
ADFun Operation Sequence Optimization: Example and Test
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
R
repeat_det_by_minor_c
Repeat det_by_minor Routine A Specified Number of Times
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_any.cpp
Reverse Mode General Case: 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
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
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
Calculating Sparsity Patterns
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: Easy Driver
sparse_hessian.cpp
Sparse Hessian: 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_jacobian
Sparse Jacobian: Easy Driver
sparse_jacobian.cpp
Sparse Jacobian: Example and Test
sparse_sub_hes.cpp
Sparse Hessian on Subset of Variables: Example and Test
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 Computed Assignment Subtraction: Example and Test
sub_sparse_hes.cpp
Computing Sparse Hessian for a Subset of Variables
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_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
wish_list
The CppAD Wish List
Z
zdouble
zdouble: An AD Base Type With Absolute Zero
zdouble.cpp
zdouble: Example and Test
cppad-20160000.1/doc/_index.xml0000644000175200017650000542622312656322012015171 0ustar coincoin-web Keyword Index
Prev Next _index

Keyword Index
!= AD Binary Comparison Operators
   AD Binary Comparison Operators: Example and Test
(double CppAD Speed: Matrix Multiplication (Double Version)
* AD Binary Arithmetic Operators
  AD Computed Assignment Operators
  AD Binary Multiplication: Example and Test
*= AD Computed Assignment Multiplication: Example and Test
+ AD Computed Assignment Operators
  AD Binary Addition: Example and Test
  AD Unary Plus Operator
  AD Binary Arithmetic Operators
+= AD Computed Assignment Addition: Example and Test
- AD Computed Assignment Operators
  AD Binary Subtraction: Example and Test
  AD Binary Arithmetic Operators
  AD Unary Minus Operator
--with-deprecated Auto Tools Unix Test and Installation: --with-deprecated
--with-documentation Auto Tools Unix Test and Installation: --with-Documentation
--with-sparse_option Auto Tools Unix Test and Installation: --with-sparse_option
--with-testvector Auto Tools Unix Test and Installation: --with-testvector
-= AD Computed Assignment Subtraction: Example and Test
/ AD Computed Assignment Operators
  AD Binary Division: Example and Test
  AD Binary Arithmetic Operators
/= AD Computed Assignment Division: Example and Test
Evaluate a Function Defined in Terms of an ODE: p.p == 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-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
01-19 Changes and Additions to CppAD During 2011: 01-19
      CppAD Changes and Additions During 2012: 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
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
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
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
01-30 CppAD Changes and Additions During 2012: 01-30
      CppAD Changes and Additions During 2015: 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
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
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
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
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
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
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
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
02-12 Changes and Additions to CppAD During 2004: 02-12
02-13 Changes and Additions to CppAD During 2006: 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
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
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
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
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
02-26 CppAD Changes and Additions During 2014: 02-26
02-27 Changes and Additions to CppAD During 2007: 03-09.02-27
      CppAD Changes and Additions During 2014: 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
02-29 Changes and Additions to CppAD During 2004: 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
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
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
03-06 Changes and Additions to CppAD During 2004: 03-06
      CppAD Changes and Additions During 2015: 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
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
03-12 Changes and Additions to CppAD During 2004: 03-12
03-13 Changes and Additions to CppAD During 2007: 03-15.03-13
      CppAD Changes and Additions During 2015: 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
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
03-20 Changes and Additions to CppAD During 2007: 03-20
03-21 CppAD Changes and Additions During 2012: 03-21
03-22 Changes and Additions to CppAD During 2005: 03-22
      Changes and Additions to CppAD During 2006: 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
03-24 Changes and Additions to CppAD During 2006: 03-24
      Changes and Additions to CppAD During 2009: 03-24
03-25 Changes and Additions to CppAD During 2004: 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
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
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
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
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
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
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
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
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
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
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
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
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
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
06-04 Changes and Additions to CppAD During 2004: 06-04
      CppAD Changes and Additions During 2012: 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
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
06-11 Changes and Additions to CppAD During 2008: 06-11
      CppAD Changes and Additions During 2015: 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
06-28 Changes and Additions to CppAD During 2009: 07-04.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
06-30 Changes and Additions to CppAD During 2009: 07-04.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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Evaluate a Function Defined in Terms of an ODE: p.p = 1
1/Multi-threading Sum of 1/i Utility Routines
    Timing Test of Multi-Threaded Summation of 1/i
    Multi-Threaded Implementation of Summation 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
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
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
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
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
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
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
11-13 Changes and Additions to CppAD During 2004: 11-13
      CppAD Changes and Additions During 2013: 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
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
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
11-19 Changes and Additions to CppAD During 2005: 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
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
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
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
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
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
12-06 Changes and Additions to CppAD During 2005: 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
12-09 Changes and Additions to CppAD During 2004: 12-09
      Changes and Additions to CppAD During 2006: 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
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
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
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
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
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
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
1: CppAD Download, Test, and Install Instructions: Instructions.Step 1: Download
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 Auto Tools 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
2013-12-31 AD Constructors: x.Deprecated 2013-12-31
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
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
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
== 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 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
   Timing Test of Multi-Threaded Newton Method
   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-20160000.1: 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
Adolc Auto Tools Unix Test and Installation
Automatic An Introduction by Example to Algorithmic Differentiation
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
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
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
   Using AD Version of Atomic Function
   User Defined Atomic AD Functions
   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 Computed Assignment Division: Example and Test
   AD Computed Assignment Multiplication: Example and Test
   AD Computed Assignment Subtraction: Example and Test
   AD Computed Assignment Addition: Example and Test
   AD Computed 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 Computed 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
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 Computed Assignment Division: Example and Test
    AD Computed Assignment Multiplication: Example and Test
    AD Computed Assignment Subtraction: Example and Test
    AD Computed Assignment Addition: Example and Test
    AD Computed 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 Computed Assignment Operators: Derivative.Addition
         AD Binary Arithmetic Operators: Derivative.Addition
addition: AD Computed 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
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 Operation Sequence Optimization: Example and Test
      Optimize an ADFun Object Tape
      ADFun Check and Re-Tape: Example and Test
      Check an ADFun Sequence of Operations
      Hessian of Lagrangian and  ADFun Default Constructor: Example and Test
      Evaluate ADFun Functions, Derivatives, and Sparsity Patterns
      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
      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 Auto Tools 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
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
          An Epsilon Accurate Exponential Approximation
          Second Order Exponential Approximation
          cppad-20160000.1: 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-20160000.1: A Package for Differentiation of C++ Algorithms
algorithms cppad-20160000.1: 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 of All the 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
     Sparse Hessian on Subset of Variables: 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
     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
     Interpolation With Retaping: Example and Test: See Also
     Interpolation With Out Retaping: 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
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
    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
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
              Correctness Tests For Exponential Approximation in Introduction
              An Epsilon Accurate Exponential Approximation
              Second Order Exponential Approximation
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 Computed 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 Computed Assignment Division: Example and Test
       AD Computed Assignment Multiplication: Example and Test
       AD Computed Assignment Subtraction: Example and Test
       AD Computed 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: Computed Assignment Macro
           Required Base Class Member Functions: Assignment Operators
           AD Computed Assignment Division: Example and Test
           AD Computed Assignment Multiplication: Example and Test
           AD Computed Assignment Subtraction: Example and Test
           AD Computed Assignment Addition: Example and Test
           AD Computed Assignment Operators
           AD Assignment Operator
assignment: ADFun Assignment: Example and Test
            AD Assignment: Example and Test
assignments AD Arithmetic Operators and Computed 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
       Glossary: Operation.Atomic
       Running the Speed Test Program: option_list.atomic
       Optimize an ADFun Object Tape: Atomic Functions
       Matrix Multiply as an Atomic Operation
       User Atomic Matrix Multiply: Example and Test: Use Atomic Function
       User Atomic Matrix Multiply: Example and Test
       Atomic Operation Hessian Sparsity: Example and Test: Use Atomic Function
       Atomic Operation Hessian Sparsity: 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 Patterns: Example and Test: Use Atomic Function
       Atomic Sparsity 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 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 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
auto Auto Tools Unix Test and Installation
automatic Example and Test Linking CppAD to Languages Other than C++
          cppad-20160000.1: A Package for Differentiation of C++ Algorithms
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
avoid Frequently Asked Questions and Answers
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
   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
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>
     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 Computed 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
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.Vector of Boolean
        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
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
      Auto Tools Unix Test and Installation
      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 Auto Tools Unix Test and Installation: boost_dir
both Speed Test for Both Simple and Fast Representations
     Correctness Check for Both Simple and Fast Representations
     Atomic Operation Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
box An ODE Inverse Problem Example: Black Box Method
bthread Boost Thread Implementation of a Team of AD Threads
        Run Multi-Threading Examples and Speed Tests
bug Pthread Implementation of a Team of AD Threads: Bug in Cygwin
bugs Frequently Asked Questions and Answers: Bugs
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
bvector Use Ipopt to Solve a Nonlinear Programming Problem: Bvector
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-20160000.1: 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
        Conditional Expressions: Example and Test
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 Frequently Asked Questions and Answers
                 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-20160000.1: 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
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
  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-20160000.1: 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 Sparsity Patterns
calculation LU Factorization of A Square Matrix and Stability 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
     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
     User Defined Atomic AD Functions: General Case
case: Reverse Mode General Case: Example and Test
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
        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
        The CppAD Wish List: Comparison Changes and Optimization
        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: Check All
      CppAD Download, Test, and Install Instructions: Instructions.Step 3: Check
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 Functions
checkpointing: Simple Checkpointing: Example and Test
checksimplevector The CheckSimpleVector Function: Example and Test
                  Enable AD Calculations During Parallel Mode: CheckSimpleVector
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.Simple 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 Operation Hessian Sparsity: Example and Test: Start 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 Patterns: Example and Test: End Class Definition
      Atomic Sparsity 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
      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
     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
coefficient Glossary: Taylor Coefficient
            Controlling Taylor Coefficient Memory Allocation: Example and Test
            Number Taylor Coefficient Orders Currently Stored
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
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 Hessian: Easy Driver: row, col
    Sparse Jacobian: Easy Driver: row, col
color_method Sparse Hessian: Easy Driver: work.color_method
             Sparse Jacobian: Easy Driver: work.color_method
colpack Running the Speed Test Program: Sparsity Options.colpack
        Download and Install ColPack in Build Directory
        Using ColPack: Example and Test
        Using ColPack: Example and Test
        Including the ColPack Sparsity Calculations
colpack: Using ColPack: Example and Test
         Using ColPack: Example and Test
colpack_prefix Including the ColPack Sparsity Calculations: colpack_prefix
combine Multi-threading Newton Method Utility Routines
        Multi-threading Sum of 1/i Utility Routines
command Using CMake to Configure CppAD: CMake Command
commands Deprecated Include Files: Linking New Files to Deprecated Commands
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
           The CppAD Wish List: Comparison Changes and Optimization
           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 Auto Tools Unix Test and Installation
        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
compressed Download The CppAD Source Code: Compressed Archives
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
        Compute Determinant and Solve Linear Equations
        Compute Determinants and Solve Equations by LU Factorization
        Getting Started Using CppAD to Compute Derivatives
computed Example AD<Base> Where Base Constructor Allocates Memory: Computed Assignment Macro
         AD Computed Assignment Division: Example and Test
         AD Computed Assignment Multiplication: Example and Test
         AD Computed Assignment Subtraction: Example and Test
         AD Computed Assignment Addition: Example and Test
         AD Computed Assignment Operators
         AD Arithmetic Operators and Computed Assignments
computing Computing Jacobian and Hessian of Bender's Reduced Objective
          Computing a Jacobian With Constants that Change
          Computing Sparse Hessian for a Subset of Variables
          Computing Dependency: 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 The CppAD Wish List: Optimizing Nested 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
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 Auto Tools Unix Test and Installation: Configure
          Using CMake to Configure CppAD
conjugate Differentiate Conjugate Gradient Algorithm: Example and Test
conserve Using vectorBool Sparsity To Conserve Memory: 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
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
            Hessian of Lagrangian and  ADFun Default Constructor: Example and Test
            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 Operation Hessian Sparsity: Example and Test: 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 Patterns: Example and Test: Use Atomic Function.Constructor
            Atomic Sparsity 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 Function Constructor: Examples.Use Constructor
            Atomic Function Constructor: Examples.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
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 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
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
      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
      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 of All the CppAD Examples
      Utility Routines used by CppAD Examples
      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
      Using CppAD in a Multi-Threading Environment
      CppAD API Preprocessor Symbols
      AD<Base> Requirements for a CppAD Base Type
      exp_eps: CppAD Forward and Reverse Sweeps
      exp_2: CppAD Forward and Reverse Sweeps
      Getting Started Using CppAD to Compute Derivatives
      Auto Tools Unix Test and Installation: Profiling CppAD
      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-20160000.1: cppad-20160000.1: A Package for Differentiation of C++ Algorithms
cppad.hpp cppad-20160000.1: A Package for Differentiation of C++ Algorithms
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_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_sparse_list Using CMake to Configure CppAD: cppad_sparse_list
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
       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 Auto Tools Unix Test and Installation
     Using CMake to Configure CppAD
ctor_arg_list Atomic Function Constructor: atomic_user.ctor_arg_list
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
        Download The CppAD Source Code: Subversion.Current Version
        Download The CppAD Source Code: Compressed Archives.Current Version
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
cxx_flags Auto Tools Unix Test and Installation: cxx_flags
cygwin Pthread Implementation of a Team of AD Threads: Bug in Cygwin
       Auto Tools Unix Test and Installation: adolc_dir.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
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
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
        Required Base Class Member Functions: Default Constructor
define Define Matrix Multiply as a User Atomic Operation
       Atomic Reverse Hessian Sparsity Patterns: Examples.Define rev_sparse_hes
       Atomic Reverse Jacobian Sparsity Patterns: Examples.Define rev_sparse_jac
       Atomic Forward Jacobian Sparsity Patterns: Examples.Define for_sparse_jac
       Atomic Reverse Mode: Examples.Define reverse
       Atomic Forward Mode: Examples.Define forward
       Atomic Function Constructor: Examples.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
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 Operation Hessian Sparsity: Example and Test: Start 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 Patterns: Example and Test: End Class Definition
           Atomic Sparsity 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
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
dependency Computing Dependency: Example and Test: Dependency Pattern
           Jacobian Sparsity Pattern: Reverse Mode: dependency
           Jacobian Sparsity Pattern: Forward Mode: 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 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: Linking New Files to Deprecated Commands
           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
           AD Boolean Functions: Deprecated 2007-07-31
           Discrete AD Functions: CppADCreateDiscrete Deprecated 2007-07-28
           AD Constructors: x.Deprecated 2013-12-31
           Auto Tools Unix Test and Installation: Deprecated 2012-12-26
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
           Evaluate a Polynomial or its Derivative
           Reverse Mode Second Partial Derivative Driver
           Forward Mode Second Partial Derivative Driver
           Hessian: Easy Driver
           First Order Derivative Driver: Example and Test
           First Order Derivative: Driver Routine
           Jacobian: Driver Routine
           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
           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 Computed 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
           Getting Started Using CppAD to Compute Derivatives: Derivative
           cppad-20160000.1: 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
            Evaluate ADFun Functions, Derivatives, and Sparsity Patterns
            Discrete AD Functions: Derivatives
            Getting Started Using CppAD to Compute Derivatives
derivatives: First and Second 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
            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-20160000.1: A Package for Differentiation of C++ Algorithms
                cppad-20160000.1: A Package for Differentiation of C++ Algorithms
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
direction Hessian Times Direction: Example and Test
          Second Order Reverse Mode: Hessian Times Direction
direction: Hessian Times Direction: Example and Test
directions Reverse Mode: Multiple Directions
           Forward Mode: Example and Test of Multiple Directions
           Multiple Directions Forward Mode
directories Using CMake to Configure CppAD
directory Auto Tools Unix Test and Installation: Work Directory
          Auto Tools Unix Test and Installation: Distribution Directory
          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
           Computing Dependency: Example and Test: Discussion
           Comparison Changes Between Taping and Zero Order Forward: number.Discussion
           Atomic Forward Mode: Discussion
           Printing AD Values During Forward Mode: Discussion
disk Frequently Asked Questions and Answers: Tape Storage: Disk or Memory
distribution Auto Tools Unix Test and Installation: 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 Computed Assignment Division: Example and Test
       AD Computed 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 Computed Assignment Operators: Derivative.Division
         AD Binary Arithmetic Operators: Derivative.Division
division: AD Computed Assignment Division: Example and Test
          AD Binary Division: Example and Test
documentation Using CMake to Configure CppAD
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
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 eigen Download and Install Eigen in Build Directory
     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
       Sparse Hessian: Easy Driver
       Sparse Jacobian: Easy Driver
       Reverse Mode Second Partial Derivative Driver
       Forward Mode Second Partial Derivative Driver
       Hessian: Easy Driver
       First Order Derivative: Driver Routine
       First Order Partial Derivative: Driver Routine
       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 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
       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 First Order Derivative: Driver Routine: dw
   Any Order Reverse Mode: dw
   Second Order Reverse Mode: dw
   First Order Reverse Mode: 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 Frequently Asked Questions and Answers
             Replacing the CppAD Error Handler
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 Sparse Hessian: Easy Driver
     Sparse Jacobian: Easy Driver
     Reverse Mode Second Partial Derivative Driver
     Forward Mode Second Partial Derivative Driver
     Hessian: Easy Driver
     First Order Derivative: Driver Routine
     First Order Partial Derivative: Driver Routine
     First and Second 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 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
      Auto Tools Unix Test and Installation
      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
     download and install Download and Install Eigen in Build Directory
eigen_dir Auto Tools 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 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
elementary Glossary: Elementary Vector
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)
elsewhere CppAD API Preprocessor Symbols: Documented Elsewhere
embedded An Embedded 4th and 5th Order Runge-Kutta ODE Solver
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 Matrix Multiply as an Atomic Operation: End Class Definition
    Tan and Tanh as User Atomic Operations: Example and Test: End Class Definition
    Atomic Sparsity 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 Hessian Sparsity Pattern: Reverse Mode: Entire Sparsity Pattern
       Jacobian Sparsity Pattern: Reverse Mode: Entire Sparsity Pattern
       Jacobian Sparsity Pattern: Forward Mode: Entire Sparsity Pattern
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
        The CppAD Wish List: Machine Epsilon in Examples
        Multi-threading Newton Method Utility Routines: xlow.epsilon
        A Multi-Threaded Newton's Method: 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
         Evaluate ADFun Functions, Derivatives, and Sparsity Patterns
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
        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
        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
        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
        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
        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 Operation Sequence Optimization: Example and Test
        Optimize an ADFun Object Tape: Example
        ADFun Check and Re-Tape: Example and Test
        Check an ADFun Sequence of Operations: Example
        Sparse Hessian on Subset of Variables: Example and Test
        Computing Sparse Hessian for a Subset of Variables: Example
        Sparse Hessian: Example and Test
        Sparse Hessian: Easy Driver: Example
        Sparse Jacobian: Example and Test
        Sparse Jacobian: Easy Driver: Example
        Second Partials Reverse Driver: Example and Test
        Subset of Second Order Partials: Example and Test
        Hessian of Lagrangian and  ADFun Default Constructor: Example and Test
        Hessian: Example and Test
        Hessian: Easy Driver: Example
        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
        Jacobian: Example and Test
        Jacobian: Driver Routine: Example
        Using vectorBool Sparsity To Conserve Memory: Example and Test
        Sparsity Patterns For a Subset of Variables: Example and Test
        Reverse Mode Hessian Sparsity: Example and Test
        Hessian Sparsity Pattern: Reverse Mode: Example
        Computing Dependency: Example and Test
        Reverse Mode Jacobian Sparsity: Example and Test
        Jacobian Sparsity Pattern: Reverse Mode: Example
        Forward Mode Jacobian Sparsity: Example and Test
        Jacobian Sparsity Pattern: Forward Mode: Example
        Reverse Mode General Case: 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
        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>
        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 Operation Hessian Sparsity: Example and Test
        Tan and Tanh as User Atomic Operations: Example and Test
        Atomic Sparsity 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
        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 Computed Assignment Division: Example and Test
        AD Computed Assignment Multiplication: Example and Test
        AD Computed Assignment Subtraction: Example and Test
        AD Computed Assignment Addition: Example and Test
        AD Computed 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
        Getting Started Using CppAD to Compute Derivatives
        An Introduction by Example to Algorithmic Differentiation
        Using ColPack: Example and Test
        Using ColPack: Example and Test
        Including the ColPack Sparsity Calculations: Example
        cppad-20160000.1: A Package for Differentiation of C++ Algorithms: Example
examples The CppAD Wish List: Machine Epsilon in Examples
         Run the Speed Examples
         CppAD Examples and Tests
         List of All the CppAD Examples
         Utility Routines used by CppAD Examples
         General Examples
         Examples: Running Examples
         Examples
         Run Multi-Threading Examples and Speed Tests
         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 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
         Atomic Function Constructor: Examples
         User Defined Atomic AD Functions: Examples
         Auto Tools Unix Test and Installation: make.Examples and Tests
         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
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 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
          Getting Started Using CppAD to Compute Derivatives: 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
         Auto Tools Unix Test and Installation
         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 The CppAD Wish List: Optimizing Nested Conditional Expressions
            Base Type Requirements for Conditional Expressions
            AD Conditional Expressions
expressions: Conditional Expressions: 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: Compressed Archives.Windows File Extraction and Testing
           Download The CppAD Source Code: Compressed Archives.Unix File Extraction
F
FAQ Frequently Asked Questions and Answers
Fadbad Auto Tools Unix Test and Installation
ForSparseJac Forward Mode Jacobian Sparsity: Example and Test
Forward Controlling Taylor Coefficients Memory Allocation
FunCheck ADFun Check and Re-Tape: Example and Test
Atomic Reverse Mode: F, G, H
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
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
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
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 Auto Tools 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
     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: Compressed Archives.Windows File Extraction and Testing
     Download The CppAD Source Code: Compressed Archives.Unix File Extraction
     cppad-20160000.1: 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: Linking New Files to Deprecated Commands
      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
      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 Derivatives: Easy Drivers
      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
      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
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 Auto Tools Unix Test and Installation
      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_jac Matrix Multiply as an Atomic Operation: for_sparse_jac
               User Atomic Matrix Multiply: Example and Test: Use Atomic Function.for_sparse_jac
               Atomic Operation Hessian Sparsity: Example and Test: 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 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 Forward Jacobian Sparsity Patterns: Examples.Use for_sparse_jac
               Atomic Forward Jacobian Sparsity Patterns: Examples.Define 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
forsparse_jac Atomic Sparsity Patterns: Example and Test: Use Atomic Function.forsparse_jac and rev_sparse_jac
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
        Sparse Hessian: Easy Driver: Uses Forward
        Sparse Jacobian: Easy Driver: Uses Forward
        Reverse Mode Second Partial Derivative Driver: RevTwo Uses Forward
        Forward Mode Second Partial Derivative Driver: ForTwo Uses Forward
        Forward Mode Second Partial Derivative Driver
        Hessian: Easy Driver: Hessian Uses Forward
        First Order Derivative: Driver Routine: RevOne Uses Forward
        First Order Partial Derivative: Driver Routine: ForOne Uses Forward
        Jacobian: Driver Routine: Forward or Reverse
        First and Second Derivatives: Easy Drivers
        Forward Mode Jacobian Sparsity: Example and Test
        Jacobian Sparsity Pattern: Forward Mode
        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
        Forward Mode
        Stop Recording and Store Operation Sequence: Forward
        Matrix Multiply as an Atomic Operation: forward
        Matrix Multiply as an Atomic Operation: Forward Matrix Multipliy
        User Atomic Matrix Multiply: Example and Test: Use Atomic Function.forward
        Atomic Operation Hessian Sparsity: Example and Test: 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 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 Forward Jacobian Sparsity Patterns
        Atomic Forward Mode: Examples.Use forward
        Atomic Forward Mode: Examples.Define forward
        Atomic Forward Mode
        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
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
    Multi-threading Newton Method Utility Routines: multi_newton_setup.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
         Frequently Asked Questions and Answers
         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
         The Integer Power Function
         Computing Sparse Hessian for a Subset of Variables: 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 Operation Hessian Sparsity: Example and Test: Use Atomic Function
         Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function
         Atomic Sparsity Patterns: Example and Test: Use Atomic Function
         Atomic Sparsity 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
         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
         Getting Started Using CppAD to Compute Derivatives: 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
          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
          Optimize an ADFun Object Tape: Atomic Functions
          Evaluate ADFun Functions, Derivatives, and Sparsity Patterns
          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
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
  Atomic Reverse Mode: F, G, H
g_Nonlinear Programming Using the CppAD Interface to Ipopt: g_l
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: 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 Use Ipopt to Solve a Nonlinear Programming Problem: Example.get_started
get_thread_num Get the Current OpenMP Thread Number
getting Getting Started with Atomic Operations: Example and Test
        User Defined Atomic AD Functions: Examples.Getting Started
        Getting Started Using CppAD to Compute Derivatives
gl Use Ipopt to Solve a Nonlinear Programming Problem: gl
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
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
HesLagrangian Hessian of Lagrangian and  ADFun Default Constructor: Example and Test
Hessian Sparse Hessian: Example and Test
        Hessian: Example and Test
Hessian Sparsity Pattern: Reverse Mode: h
  Atomic Reverse Mode: F, 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-Threaded Implementation of Summation of 1/i
         Run Multi-Threading Examples and Speed Tests: harmonic
harmonic_combine Multi-threading Sum of 1/i Utility Routines: harmonic_combine
harmonic_setup Multi-threading Sum of 1/i Utility Routines: harmonic_setup
harmonic_time Timing Test of Multi-Threaded Summation of 1/i
harmonic_work Multi-threading Sum of 1/i Utility Routines
harmonic_worker Multi-threading Sum of 1/i Utility Routines: harmonic_worker
has Evaluate a Function That Has a Sparse Hessian
    Evaluate a Function That Has a Sparse Jacobian
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: Easy Driver: hes
    Hessian: Easy Driver: hes
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
        Sparse Hessian on Subset of Variables: Example and Test
        Computing Sparse Hessian for a Subset of Variables
        Sparse Hessian: Easy Driver: Subset Hessian
        Hessian of Lagrangian and  ADFun Default Constructor: Example and Test
        Hessian: Easy Driver: Hessian Uses Forward
        Reverse Mode Hessian Sparsity: Example and Test
        Hessian Sparsity Pattern: Reverse Mode
        Hessian Times Direction: Example and Test
        Second Order Reverse Mode: Hessian Times Direction
        Atomic Operation Hessian Sparsity: Example and Test
        Atomic Reverse Hessian Sparsity Patterns
        User Defined Atomic AD Functions: Examples.Hessian Sparsity Patterns
        Using ColPack: Example and Test
hessian: Sparse Hessian: Example and Test
         Sparse Hessian: Easy Driver
         Hessian: Example and Test
         Hessian: Easy Driver
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
Ipopt Auto Tools Unix Test and Installation
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 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 AD Constructors: x.implicit
         Auto Tools Unix Test and Installation
         Using CMake to Configure CppAD
important An Important Reverse Mode Identity
improvements Optimize an ADFun Object Tape: Improvements
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-20160000.1: 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
      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
info Replacing the CppAD Error Handler: info
information Define Matrix Multiply as a User Atomic Operation: Extra Call 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
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 Auto Tools 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: Subversion.Install Instructions
        Download The CppAD Source Code: Compressed Archives.Install Instructions
        CppAD Download, Test, and Install Instructions
     eigen Download and Install Eigen in Build Directory
     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 Auto Tools Unix Test and Installation
             CppAD Download, Test, and Install Instructions: Instructions.Step 4: Installation
instructions Download The CppAD Source Code: Subversion.Install Instructions
             Download The CppAD Source Code: Compressed Archives.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
internal Auto Tools Unix Test and Installation
         Using CMake to Configure CppAD
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: Introduction
             Using The CppAD Test Vector Template Class: Introduction
             Examples: Introduction
             Correctness Tests For Exponential Approximation in Introduction
             An Introduction by Example to Algorithmic Differentiation
             cppad-20160000.1: 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
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 Auto Tools 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
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 Sparse Jacobian: Example and Test
         Jacobian: Example and Test
         Jacobian: Driver Routine
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: Easy Driver: 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
         Reverse Mode Jacobian Sparsity: Example and Test
         Jacobian Sparsity Pattern: Reverse Mode
         Forward Mode Jacobian Sparsity: Example and Test
         Jacobian Sparsity Pattern: Forward Mode
         Atomic Reverse Jacobian Sparsity Patterns
         Atomic Forward Jacobian Sparsity Patterns
         Using ColPack: Example and Test
jacobian: Sparse Jacobian: Example and Test
          Sparse Jacobian: Easy Driver
          Jacobian: Example and Test
          Jacobian: Driver Routine
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
User Defined Atomic AD Functions: k
  Evaluate a Polynomial or its Derivative: k
  Forward Mode Second Partial Derivative Driver: k
keys Returns Indices that Sort a Vector: keys
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
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 Matrix Multiply as an Atomic Operation: Left Operand Element Index
     AD Conditional Expressions: left
leqzero Compute Determinant and Solve Linear Equations: LeqZero
level Computing a Jacobian With Constants that Change
      Multiple Level of AD: Example and Test
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
limitations Download The CppAD Source Code: Subversion.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
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 Deprecated Include Files: Linking New Files to Deprecated Commands
        Microsoft Version of Elapsed Number of Seconds: Linking
        Example and Test Linking CppAD to Languages Other than C++
linux Auto Tools Unix Test and Installation: adolc_dir.Linux
list Nonlinear Programming Using the CppAD Interface to Ipopt: Wish List
     The CppAD Wish List
     List of All the CppAD Examples
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
lower Multiple Directions Forward Mode: Non-Zero Lower Orders
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 Source: LuSolve
        LuSolve With Complex Arguments: Example and Test
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
  Multiple Directions Forward Mode: Notation.m
  Multiple Order Forward Mode: Notation.m
machine Machine Epsilon For AD Types
        The CppAD Wish List: Machine Epsilon in Examples
        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: Computed 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
main.cpp Correctness Tests For Exponential Approximation in Introduction: main.cpp
make Auto Tools Unix Test and Installation: make install
     Auto Tools Unix Test and Installation: make
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
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
     Frequently Asked Questions and Answers
     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
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
       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
       Matrix Multiply as an Atomic Operation: Reverse Matrix Multipliy
       Matrix Multiply as an Atomic Operation: Forward Matrix Multipliy
       Matrix Multiply as an Atomic Operation
       User Atomic Matrix Multiply: Example and Test
matrix: Sum of the Elements of the Square of a Matrix: Example and Test
max Numeric Limits For an AD and Base Types: max
max_itr Multi-threading Newton Method Utility Routines: max_itr
        A Multi-Threaded Newton's Method: max_itr
max_num_threads Set Maximum Number of Threads for omp_alloc Allocator
                Auto Tools Unix Test and Installation: max_num_threads
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
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
       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: option_list.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
       Auto Tools Unix Test and Installation
       Using CMake to Configure CppAD
memory: Using vectorBool Sparsity To Conserve Memory: Example and Test
memory_leak Memory Leak Detection
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
       Multi-threading Newton Method Utility Routines
       Timing Test of Multi-Threaded Newton Method
       A Multi-Threaded Newton's Method: Method
       A Multi-Threaded Newton's 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
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 Computed 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
     Frequently Asked Questions and Answers
     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
     Reverse Mode Second Partial Derivative Driver
     Forward Mode Second Partial Derivative Driver
     Reverse Mode Hessian Sparsity: Example and Test
     Hessian Sparsity Pattern: Reverse Mode
     Reverse Mode Jacobian Sparsity: Example and Test
     Jacobian Sparsity Pattern: Reverse Mode
     Forward Mode Jacobian Sparsity: Example and Test
     Jacobian Sparsity Pattern: Forward Mode
     Reverse Mode General Case: Example and Test
     Any Order Reverse Mode
     Second Order Reverse Mode
     First Order Reverse Mode
     Reverse Mode
     Multiple Directions Forward Mode
     Multiple Order Forward Mode
     Forward Mode
     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
     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
      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: Compressed Archives.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
multi OpenMP Memory Allocator: Example and Test
      Routines That Track Use of New and Delete
      Multi-dimensional Romberg Integration
      Run Multi-Threading Examples and Speed Tests
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
               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
                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 Newton Method Utility Routines
                A Multi-Threaded Newton's Method
                Multi-threading Sum of 1/i Utility Routines
                Run Multi-Threading Examples and Speed Tests
                Using CppAD in a Multi-Threading Environment
multi_newton A Multi-Threaded Newton's Method
             Run Multi-Threading Examples and Speed Tests: multi_newton
multi_newton_combine Multi-threading Newton Method Utility Routines: multi_newton_combine
multi_newton_setup Multi-threading Newton Method Utility Routines: multi_newton_setup
multi_newton_time Timing Test of Multi-Threaded Newton Method
multi_newton_work Multi-threading Newton Method Utility Routines
multi_newton_worker Multi-threading Newton Method Utility Routines: multi_newton_worker
multi_thread Timing Test of Multi-Threaded Newton Method
             Timing Test of Multi-Threaded Summation of 1/i
             Multi-Threaded Implementation of Summation of 1/i
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
         Reverse Mode: Multiple Directions
         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
         Using Adolc with Multiple Levels of Taping: Example and Test
         AD Computed Assignment Operators
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 Computed Assignment Operators: Derivative.Multiplication
               AD Binary Arithmetic Operators: Derivative.Multiplication
multiplication: AD Absolute Zero Multiplication: Example and Test
                AD Computed Assignment Multiplication: Example and Test
                AD Binary Multiplication: Example and Test
multipliy Matrix Multiply as an Atomic Operation: Reverse Matrix Multipliy
          Matrix Multiply as an Atomic Operation: Forward Matrix Multipliy
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
         User Atomic Matrix Multiply: Example and Test
         AD Computed Assignment Multiplication: Example and Test
         AD Computed Assignment Operators
         AD Binary Multiplication: Example and Test
         AD Binary Arithmetic Operators
multiply: User Atomic 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: Easy Driver: n_sweep
        Sparse Jacobian: Easy Driver: n_sweep
name CppAD Addons: Name
     Run One Speed Test and Print Results: Test.name
     NearEqual Function: Example and Test: File 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-20160000.1: 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
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 The CppAD Wish List: Optimizing Nested Conditional Expressions
new Tracking Use of New and Delete: Example and Test
    Routines That Track Use of New and Delete
    Deprecated Include Files: Linking New Files to Deprecated Commands
newlen Routines That Track Use of New and Delete: newlen
newptr Routines That Track Use of New and Delete: head newptr
newton Multi-threading Newton Method Utility Routines
       Timing Test of Multi-Threaded Newton Method
newton'A Multi-Threaded Newton's Method
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
         Any Order Reverse Mode: Notation
         Multiple Directions Forward Mode: Notation
         Multiple Order Forward Mode: Notation
         Required Base Class Member Functions: Notation
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_sub Multi-threading Newton Method Utility Routines: multi_newton_setup.num_sub
        Timing Test of Multi-Threaded Newton Method: num_sub
        A Multi-Threaded Newton's 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-threading Sum of 1/i Utility Routines: harmonic_setup.num_sum
        Multi-Threaded Implementation of Summation 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
            Multi-threading Newton Method Utility Routines: max_itr.num_threads
            Timing Test of Multi-Threaded Newton Method: num_threads
            A Multi-Threaded Newton's Method: num_threads
            Multi-threading Sum of 1/i Utility Routines: harmonic_setup.num_threads
            Timing Test of Multi-Threaded Summation of 1/i: num_threads
            Multi-Threaded Implementation of 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
       Auto Tools Unix Test and Installation
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
       Check an ADFun Object For Nan Results
       Optimize an ADFun Object Tape
       Construct an ADFun Object and Stop Recording
       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
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
   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 of Multi-Threaded Summation of 1/i: ok
   Multi-Threaded Implementation of Summation of 1/i: ok
   Check an ADFun Sequence of Operations: 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
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 Sparse Hessian on Subset of Variables: 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
    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: option_list.onetape
op AD Binary Comparison Operators: Op
   AD Computed 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
       Run Multi-Threading Examples and Speed Tests
openmp/run.sh Changes and Additions to CppAD During 2011: 07-11.openmp/run.sh
openmp_flags Auto Tools 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
          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
          ADFun Operation Sequence Optimization: Example and Test
          Abort Recording of an Operation Sequence
          Stop Recording and Store 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
          Atomic Operation Hessian Sparsity: Example and Test
          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 Computed 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 Evaluate a Polynomial or its Derivative: Type.Operations
           Optimize an ADFun Object Tape
           Check an ADFun Sequence of Operations
           AD Vectors that Record Index Operations
           Bool Valued Operations and Functions with AD Arguments
           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 Frequently Asked Questions and Answers
         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 Theory of Reverse Mode: Binary Operators
          The Theory of Forward Mode: Binary Operators
          Definition of a Numeric Type: 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 Computed Assignment Operators
          AD Binary Arithmetic Operators
          AD Arithmetic Operators and Computed 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: Comparison Changes and Optimization
             The CppAD Wish List: PrintFor Optimization
             A 3rd and 4th Order Rosenbrock ODE Solver: Fun.Optimization
             Optimize an ADFun Object Tape: Checking Optimization
optimization: ADFun Operation Sequence Optimization: Example and Test
optimize Frequently Asked Questions and Answers: Speed.Optimize
         Running the Speed Test Program: option_list.optimize
         ADFun Operation Sequence Optimization: Example and Test
         Optimize an ADFun Object Tape
         Number of Variables That Can be Skipped: Example and Test
         AD Conditional Expressions: Optimize
optimizing The CppAD Wish List: Optimizing Nested Conditional Expressions
option User Atomic Matrix Multiply: Example and Test: Use Atomic Function.option
       Checkpointing Functions: option
option_list Running the Speed Test Program: option_list
options Running the Speed Test Program: Sparsity Options
        Use Ipopt to Solve a Nonlinear Programming Problem: 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
      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
      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
      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 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
       AD Output Operator: Example and Test
       AD Output Operator: Example and Test
       AD Output Stream Operator
       AD Output Stream Operator
       Getting Started Using CppAD to Compute Derivatives: Output
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
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: Easy Driver: work.p
  Sparse Hessian: Easy Driver: p
  Sparse Jacobian: Easy Driver: work.p
  Sparse Jacobian: Easy Driver: p
  Atomic Forward Mode: p
pack_sparsity_enum Atomic Sparsity Patterns: Example and Test: 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-20160000.1: 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 Operation Hessian 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
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 Partials Reverse Driver: Example and Test
         Second Order Reverse Mode: dw.Second Order Partials
         Second Order Reverse Mode: dw.First Order Partials
partials: Subset of Second Order Partials: Example and Test
pattern Glossary: Sparsity Pattern
        Hessian Sparsity Pattern: Reverse Mode: Entire Sparsity Pattern
        Computing Dependency: Example and Test: Dependency Pattern
        Jacobian Sparsity Pattern: Reverse Mode: Entire Sparsity Pattern
        Jacobian Sparsity Pattern: Forward Mode: Entire Sparsity Pattern
pattern: Hessian Sparsity Pattern: Reverse Mode
         Jacobian Sparsity Pattern: Reverse Mode
         Jacobian Sparsity Pattern: Forward Mode
patterns Sparsity Patterns For a Subset of Variables: Example and Test
         Calculating Sparsity Patterns
         Evaluate ADFun Functions, Derivatives, and Sparsity Patterns
         Construct an ADFun Object and Stop Recording: Assignment Operator.Sparsity Patterns
         Atomic Reverse Hessian Sparsity Patterns
         Atomic Reverse Jacobian Sparsity Patterns
         Atomic Forward Jacobian Sparsity Patterns
         User Defined Atomic AD Functions: Examples.Hessian Sparsity Patterns
patterns: Atomic Sparsity 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
plus The Logarithm of One Plus Argument: log1p
     AD Computed Assignment Division: Example and Test
     AD Computed Assignment Multiplication: Example and Test
     AD Computed Assignment Subtraction: Example and Test
     AD Computed Assignment Addition: Example and Test
     AD Computed Assignment Operators
     AD Binary Addition: Example and Test
     AD Binary Arithmetic Operators
     AD Unary Plus Operator: Example and Test
     AD Unary Plus Operator
point Extending to_string To Another Floating Point Type
pointer CppAD API Preprocessor Symbols
poly Source: Poly
     Complex Polynomial: Example and Test: Poly
     Getting Started Using CppAD to Compute Derivatives: 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 Auto Tools Unix Test and Installation
        Using CMake to Configure CppAD
postfix_dir Auto Tools 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
prefix Auto Tools Unix Test and Installation
       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 Auto Tools 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-20160000.1: 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
      Print During Zero Order Forward Mode: Example and Test
      Printing During Forward Mode: Example and Test
      Printing AD Values During Forward Mode
printfor The CppAD Wish List: PrintFor Optimization
printing Printing During Forward Mode: Example and Test
         Printing AD Values During Forward Mode
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
procedure Using Multiple Levels of AD: Procedure
processing Reverse Mode General Case: Example and Test: Processing Steps
profile Running the Speed Test Program: package.profile
        Auto Tools Unix Test and Installation
        Using CMake to Configure CppAD
profiling Auto Tools 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
        Example Use of SpeedTest: Program
        Example Use of SpeedTest: Running This Program
        Getting Started Using CppAD to Compute Derivatives: Program
        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
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
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
        Run Multi-Threading Examples and Speed Tests
pthread_exit Pthread Implementation of a Team of AD Threads
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
        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
        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
        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
        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
        Multi-threading Newton Method Utility Routines: Purpose
        Timing Test of Multi-Threaded Newton Method: Purpose
        A Multi-Threaded Newton's Method: Purpose
        Multi-threading Sum of 1/i Utility Routines: Purpose
        Timing Test of Multi-Threaded Summation 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
        Optimize an ADFun Object Tape: Purpose
        Check an ADFun Sequence of Operations: Purpose
        Sparse Hessian on Subset of Variables: Example and Test: Purpose
        Computing Sparse Hessian for a Subset of Variables: Purpose
        Sparse Hessian: Easy Driver: Purpose
        Sparse Jacobian: Easy Driver: Purpose
        Reverse Mode Second Partial Derivative Driver: Purpose
        Forward Mode Second Partial Derivative Driver: Purpose
        Hessian: Easy Driver: Purpose
        First Order Derivative: Driver Routine: Purpose
        First Order Partial Derivative: Driver Routine: Purpose
        Jacobian: Driver Routine: Purpose
        Using vectorBool Sparsity To Conserve Memory: Example and Test: Purpose
        Hessian Sparsity Pattern: Reverse Mode: Purpose
        Jacobian Sparsity Pattern: Reverse Mode: Purpose
        Jacobian Sparsity Pattern: Forward Mode: Purpose
        Reverse Mode General Case: 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
        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 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 Operation Hessian Sparsity: Example and Test: Purpose
        Getting Started with Atomic Operations: Example and Test: Purpose
        Free Static Variables: Purpose
        Atomic Reverse 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
        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 Computed 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
        Getting Started Using CppAD to Compute Derivatives: 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
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
  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
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 Frequently Asked Questions and Answers
       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 Patterns: Example and Test: Use 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
reduce Checkpointing Functions: Purpose.Reduce Memory
reduced Computing Jacobian and Hessian of Bender's Reduced Objective
reference Jacobian and Hessian of Optimal Values: Reference
          The CppAD::vector Template Class: Assignment.Return Reference
          AD Vectors that Record Index Operations
          An Introduction by Example to Algorithmic Differentiation: Reference
rel AD Conditional Expressions: Rel
relative Determine if Two Values Are Nearly Equal
release Download The CppAD Source Code: Subversion.Release Versions
        Download The CppAD Source Code: Compressed Archives.Release Versions
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
replace Replacing the CppAD Error Handler
replacing Replacing The CppAD Error Handler: Example and Test
          Replacing the CppAD Error Handler
reporting Frequently Asked Questions and Answers
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
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 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 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
            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: Easy Driver: VectorSet.Restrictions
             Sparse Jacobian: Easy Driver: VectorSet.Restrictions
             Multiple Order Forward Mode: xq.Restrictions
             Atomic Function Constructor: atomic_base.Restrictions
result Lu Factor and Solve with Recorded Pivoting: Result
       Matrix Multiply as an Atomic Operation: Result Element Index
       AD Conditional Expressions: result
       AD Computed 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 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 Operation Hessian Sparsity: Example and Test: 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 Patterns: Example and Test: Use Atomic Function.rev_sparse_hes
               Atomic Sparsity 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 Patterns: Examples.Use rev_sparse_hes
               Atomic Reverse Hessian Sparsity Patterns: Examples.Define 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
               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 Patterns: Example and Test: Use Atomic Function.forsparse_jac and rev_sparse_jac
               Atomic Sparsity 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 Jacobian Sparsity Patterns: Examples.Use rev_sparse_jac
               Atomic Reverse Jacobian Sparsity Patterns: Examples.Define 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
        Second Partials Reverse Driver: Example and Test
        Reverse Mode Second Partial Derivative Driver
        Jacobian: Driver Routine: Forward or Reverse
        First and Second Derivatives: Easy Drivers
        Reverse Mode Hessian Sparsity: Example and Test
        Hessian Sparsity Pattern: Reverse Mode
        Reverse Mode Jacobian Sparsity: Example and Test
        Jacobian Sparsity Pattern: Reverse Mode
        Reverse Mode General Case: 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
        Reverse Mode
        Matrix Multiply as an Atomic Operation: reverse
        Matrix Multiply as an Atomic Operation: Reverse Matrix Multipliy
        User Atomic Matrix Multiply: Example and Test: Use Atomic Function.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 Patterns
        Atomic Reverse Jacobian Sparsity Patterns
        Atomic Reverse Mode: Examples.Use reverse
        Atomic Reverse Mode: Examples.Define reverse
        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
revone First Order Derivative: Driver Routine: RevOne Uses Forward
revsparsehes Sparsity Patterns For a Subset of Variables: Example and Test: RevSparseHes
revtwo Reverse Mode Second Partial Derivative Driver: RevTwo Uses Forward
rhs Lu Factor and Solve with Recorded Pivoting: Rhs
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
     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
         Multi-threading Newton Method Utility Routines
         Multi-threading Sum of 1/i Utility Routines
row 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 Hessian: Easy Driver: row, col
    Sparse Jacobian: Easy Driver: row, col
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-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
        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
        Getting Started Using CppAD to Compute Derivatives: Running
S
Sacado Auto Tools Unix Test and Installation
SimpleVector The CheckSimpleVector Function: Example and Test
SparseHessian Sparse Hessian: Easy Driver
SparseJacobian Sparse Jacobian: Easy Driver
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 Auto Tools 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> >
       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 Derivatives: Easy Drivers
       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
       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
    Sparse Hessian on Subset of Variables: 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
    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
    Interpolation With Retaping: Example and Test: See Also
    Interpolation With Out Retaping: 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
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
         ADFun Operation Sequence Optimization: Example and Test
         Optimize an ADFun Object Tape
         Check an ADFun Sequence of Operations
         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 Computed 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
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
    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 Reciprocal as an Atomic Operation: Example and Test
                  Set Atomic Function Options: atomic_sparsity.set_sparsity_enum
sets Glossary: Sparsity Pattern.Vector of Sets
     Auto Tools Unix Test and Installation
     Using CMake to Configure CppAD
setup OpenMP Parallel Setup
      Setup thread_alloc For Use in Multi-Threading Environment
      Multi-threading Newton Method Utility Routines
      Multi-threading Sum of 1/i Utility Routines
shampine Bibliography: Shampine, L.F.
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
       Check Simple Vector Concept
       Simple Vector Template Class: Example and Test
       Definition of a Simple Vector
       Some General Purpose Utilities: Miscellaneous.Simple Vector Template Class
       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
       Getting Started Using CppAD to Compute Derivatives
simple_ad Run Multi-Threading Examples and Speed Tests: simple_ad
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
size_forward_set Jacobian Sparsity Pattern: Forward Mode: 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
           LU Factorization of A Square Matrix: 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 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
solver A 3rd and 4th Order Rosenbrock ODE Solver
       An Embedded 4th and 5th Order Runge-Kutta 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
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
       Multi-threading Newton Method Utility Routines: Source
       Timing Test of Multi-Threaded Newton Method: Source
       A Multi-Threaded Newton's Method: Source
       Multi-threading Sum of 1/i Utility Routines: Source
       Timing Test of Multi-Threaded Summation of 1/i: Source
       Multi-Threaded Implementation of Summation of 1/i: Source
       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
       Using Adolc with Multiple Levels of Taping: Example and Test: Source
       Printing During Forward Mode: Example and Test: Source Code
       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
spare Sparse Hessian: Example and Test
      Sparse Jacobian: Example and Test
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 Hessian on Subset of Variables: Example and Test
       Computing Sparse Hessian for a Subset of Variables
       Sparse Hessian: Example and Test
       Sparse Hessian: Easy Driver
       Sparse Jacobian: Example and Test
       Sparse Jacobian: Easy Driver
       Jacobian Sparsity Pattern: Reverse Mode
       Auto Tools Unix Test and Installation
       Using ColPack: Example and Test
       Using ColPack: 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_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_jacobian sacado Speed: sparse_jacobian
                fadbad Speed: sparse_jacobian
sparsity Glossary: Sparsity Pattern
         Running the Speed Test Program: Sparsity Options
         Using vectorBool Sparsity To Conserve Memory: Example and Test
         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 Jacobian Sparsity: Example and Test
         Jacobian Sparsity Pattern: Reverse Mode: Entire Sparsity Pattern
         Jacobian Sparsity Pattern: Reverse Mode
         Forward Mode Jacobian Sparsity: Example and Test
         Jacobian Sparsity Pattern: Forward Mode: Entire Sparsity Pattern
         Jacobian Sparsity Pattern: Forward Mode
         Calculating Sparsity Patterns
         Evaluate ADFun Functions, Derivatives, and Sparsity Patterns
         Construct an ADFun Object and Stop Recording: Assignment Operator.Sparsity Patterns
         Atomic Operation Hessian Sparsity: Example and Test
         Tan and Tanh as User Atomic Operations: Example and Test: sparsity
         Atomic Sparsity 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 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: Reverse Mode Hessian Sparsity: Example and Test
          Reverse Mode Jacobian Sparsity: Example and Test
          Forward Mode Jacobian Sparsity: Example and Test
          Atomic Operation Hessian Sparsity: Example and Test
special 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
      Timing Test of Multi-Threaded Newton Method
      Timing Test of Multi-Threaded Summation of 1/i
      Run Multi-Threading Examples and Speed Tests
      Optimize an ADFun Object Tape
      Comparison Changes Between Taping and Zero Order Forward: count.Speed
      AD Vectors that Record Index Operations: Speed and Memory
      Auto Tools Unix Test and Installation
      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
       The Square Root Function: sqrt
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
stable Download The CppAD Source Code: Subversion.Stable Versions
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
         Frequently Asked Questions and Answers
         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>
      Declare Independent Variables and Start Recording: Start Recording
      Declare Independent Variables and Start Recording
      Matrix Multiply as an Atomic Operation: Start Class Definition
      Atomic Operation Hessian Sparsity: Example and Test: Start Class Definition
      Tan and Tanh as User Atomic Operations: Example and Test: Start Class Definition
      Atomic Sparsity 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
      Getting Started Using CppAD to Compute Derivatives
started Getting Started with Atomic Operations: Example and Test
        User Defined Atomic AD Functions: Examples.Getting Started
        Getting Started Using CppAD to Compute Derivatives
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 Auto Tools Unix Test and Installation
    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
     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: 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
        Frequently Asked Questions and Answers
        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 Using CMake to Configure CppAD
subset Sparse Hessian on Subset of Variables: Example and Test
       Computing Sparse Hessian for a Subset of Variables: Subset
       Computing Sparse Hessian for a Subset of Variables
       Sparse Hessian: Easy Driver: Subset Hessian
       Subset of Second Order Partials: Example and Test
       Sparsity Patterns For a Subset of Variables: Example and Test
subsets Checking the CppAD Examples and Tests: Subsets
subtract AD Computed Assignment Subtraction: Example and Test
         AD Computed 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 Computed Assignment Operators: Derivative.Subtraction
            AD Binary Arithmetic Operators: Derivative.Subtraction
subtraction: AD Computed Assignment Subtraction: Example and Test
             AD Binary Subtraction: Example and Test
subversion Download The CppAD Source Code: 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-threading Sum of 1/i Utility Routines
    Multi-Threaded Implementation of Summation of 1/i: sum
summation Timing Test of Multi-Threaded Summation of 1/i
          Multi-Threaded Implementation of Summation of 1/i: Summation
          Multi-Threaded Implementation of Summation of 1/i
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-20160000.1: 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
       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
       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
       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
       Multi-threading Newton Method Utility Routines: Syntax
       Timing Test of Multi-Threaded Newton Method: Syntax
       A Multi-Threaded Newton's Method: Syntax
       Multi-threading Sum of 1/i Utility Routines: Syntax
       Timing Test of Multi-Threaded Summation of 1/i: Syntax
       Multi-Threaded Implementation of Summation of 1/i: Syntax
       Run Multi-Threading Examples and Speed Tests: Syntax
       Enable AD Calculations During Parallel Mode: Syntax
       Check an ADFun Object For Nan Results: Syntax
       Optimize an ADFun Object Tape: Syntax
       Check an ADFun Sequence of Operations: Syntax
       Sparse Hessian: Easy Driver: Syntax
       Sparse Jacobian: Easy Driver: Syntax
       Reverse Mode Second Partial Derivative Driver: Syntax
       Forward Mode Second Partial Derivative Driver: Syntax
       Hessian: Easy Driver: Syntax
       First Order Derivative: Driver Routine: Syntax
       First Order Partial Derivative: Driver Routine: Syntax
       Jacobian: Driver Routine: Syntax
       Hessian Sparsity Pattern: Reverse Mode: Syntax
       Jacobian Sparsity Pattern: Reverse Mode: Syntax
       Jacobian Sparsity Pattern: Forward Mode: 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
       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
       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 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 Computed 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-20160000.1: 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
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
     Auto Tools Unix Test and Installation
     Using CMake to Configure CppAD
tape_addr_type Auto Tools Unix Test and Installation: tape_addr_type
tape_id_type Auto Tools Unix Test and Installation: tape_id_type
taping Frequently Asked Questions and Answers
       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
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
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.Simple 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
     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
     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
     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
     Timing Test of Multi-Threaded Summation of 1/i
     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 Operation Sequence Optimization: Example and Test
     ADFun Check and Re-Tape: Example and Test
     Sparse Hessian on Subset of Variables: Example and Test
     Sparse Hessian: Example and Test
     Sparse Jacobian: Example and Test
     Second Partials Reverse Driver: Example and Test
     Subset of Second Order Partials: Example and Test
     Hessian of Lagrangian and  ADFun Default Constructor: Example and Test
     Hessian: Example and Test
     First Order Derivative Driver: Example and Test
     First Order Partial Driver: Example and Test
     Jacobian: Example and Test
     Using vectorBool Sparsity To Conserve Memory: Example and Test
     Sparsity Patterns For a Subset of Variables: Example and Test
     Reverse Mode Hessian Sparsity: Example and Test
     Computing Dependency: Example and Test
     Reverse Mode Jacobian Sparsity: Example and Test
     Forward Mode Jacobian Sparsity: Example and Test
     Reverse Mode General Case: 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
     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 Operation Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
     Atomic Operation Hessian Sparsity: Example and Test
     Tan and Tanh as User Atomic Operations: Example and Test
     Atomic Sparsity 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
     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 Computed Assignment Division: Example and Test
     AD Computed Assignment Multiplication: Example and Test
     AD Computed Assignment Subtraction: Example and Test
     AD Computed 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
     Auto Tools Unix Test and Installation
     Choosing the CppAD Test Vector Template Class
     Including the Eigen Examples and Tests: Test Vector
     Using ColPack: Example and Test
     Using ColPack: Example and Test
     CppAD Download, Test, and Install Instructions
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 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
        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: Improvements.Testing
        Download The CppAD Source Code: Compressed Archives.Windows File Extraction and Testing
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
      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
      Auto Tools Unix Test and Installation: make.Examples and Tests
      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
     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
    List of All the CppAD 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
    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
       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
       A Multi-Threaded Newton's Method
       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_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
thread_team Using a Team of AD Threads: Example and Test: thread_team
thread_test Run Multi-Threading Examples and Speed Tests
threading A Multi-Threaded Newton's Method
          A Simple Boost Threading AD: Example and Test
          Run Multi-Threading Examples and Speed Tests: Running 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
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 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 Computed 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 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
          Extending to_string To Another Floating Point Type
to_string: to_string: Example and Test
tools Auto Tools Unix Test and Installation
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 Hessian Sparsity Pattern: Reverse Mode: h.transpose true
          Hessian Sparsity Pattern: Reverse Mode: h.transpose false
          Hessian Sparsity Pattern: Reverse Mode: 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
          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
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
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
    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
     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
      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
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) 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
unix Auto Tools Unix Test and Installation
     Including the ADOL-C Examples and Tests: Unix
     Download The CppAD Source Code: Compressed Archives.Unix File Extraction
unknown CppAD Assertions During Execution: Unknown
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
      Auto Tools Unix Test and Installation
      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
    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 Operation Hessian Sparsity: Example and Test: Use Atomic Function
    Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function
    Atomic Sparsity Patterns: 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
    Free Static Variables: Future Use
    Atomic Reverse Hessian Sparsity Patterns: Examples.Use rev_sparse_hes
    Atomic Reverse Jacobian Sparsity Patterns: Examples.Use rev_sparse_jac
    Atomic Forward Jacobian Sparsity Patterns: Examples.Use for_sparse_jac
    Atomic Reverse Mode: Examples.Use reverse
    Atomic Forward Mode: Examples.Use forward
    Atomic Function Constructor: Examples.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
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
     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
     Sparse Hessian: Easy Driver: Uses Forward
     Sparse Jacobian: Easy Driver: Uses Forward
     Reverse Mode Second Partial Derivative Driver: RevTwo Uses Forward
     Forward Mode Second Partial Derivative Driver: ForTwo Uses Forward
     Hessian: Easy Driver: Hessian Uses Forward
     First Order Derivative: Driver Routine: RevOne Uses Forward
     First Order Partial Derivative: Driver Routine: ForOne 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
      Frequently Asked Questions and Answers: Namespace.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
      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
      Using vectorBool Sparsity To Conserve Memory: Example and Test
      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
      Getting Started Using CppAD to Compute Derivatives
      Using ColPack: Example and Test
      Using ColPack: Example and Test
      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
        Multi-threading Newton Method Utility Routines
        Multi-threading Sum of 1/i Utility Routines
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
User Defined Atomic AD Functions: rev_hes_sparse.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
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
      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
      Getting Started Using CppAD to Compute Derivatives: 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
       Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function.Large x Values
       Printing AD Values During Forward Mode
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 Operation Hessian 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
          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
          Free Static Variables
variables: Sparse Hessian on Subset of Variables: Example and Test
           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.Vector of Boolean
       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.Simple Vector Template Class
       Check an ADFun Sequence of Operations: Vector
       Hessian: Easy Driver: Vector
       First Order Derivative: Driver Routine: Vector
       First Order Partial Derivative: Driver Routine: Vector
       Jacobian: Driver Routine: Vector
       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
       User Defined Atomic AD Functions: Examples.Vector Range
       Auto Tools Unix Test and Installation
       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: Easy Driver: VectorBase
           Sparse Jacobian: Easy Driver: VectorBase
           Reverse Mode Second Partial Derivative Driver: VectorBase
           Forward Mode Second Partial Derivative Driver: VectorBase
vectorbool The CppAD::vector Template Class: vectorBool
           Using vectorBool Sparsity To Conserve Memory: Example and Test
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: Easy Driver: VectorSet
          Sparse Jacobian: Easy Driver: VectorSet
          Hessian Sparsity Pattern: Reverse Mode: VectorSet
          Jacobian Sparsity Pattern: Reverse Mode: VectorSet
          Jacobian Sparsity Pattern: Forward Mode: VectorSet
vectorsize Sparse Hessian: Easy Driver: VectorSize
           Sparse Jacobian: Easy Driver: 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: Subversion.Current Version
        Download The CppAD Source Code: Compressed Archives.Current Version
        cppad-20160000.1: A Package for Differentiation of C++ Algorithms
version) CppAD Speed: Matrix Multiplication (Double Version)
versions Download The CppAD Source Code: Subversion.Release Versions
         Download The CppAD Source Code: Subversion.Stable Versions
         Download The CppAD Source Code: Compressed Archives.Monthly Versions
         Download The CppAD Source Code: Compressed Archives.Release 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 Mode: vx
vy User Defined Atomic AD Functions: forward.vy
   Atomic Forward Mode: vy
W
Sparse Hessian: Easy Driver: w
  Hessian: Easy Driver: w
  Any Order Reverse Mode: w
  Second Order Reverse Mode: w
  Second Order Reverse Mode: W
  First Order Reverse Mode: 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
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
windows Choosing The Vector Testing Template Class: MS Windows
        Checking the CppAD Examples and Tests: Check All.Windows
        Download The CppAD Source Code: Compressed Archives.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
     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 Operation Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
     Getting Started with Atomic Operations: Example and Test
     Interpolation With Retaping: Example and Test
     Interpolation With Out Retaping: Example and Test
work Sparse Hessian: Easy Driver: work
     Sparse Jacobian: Easy Driver: work
     Auto Tools Unix Test and Installation: Work Directory
worker Multi-threading Newton Method Utility Routines
       Multi-threading Sum of 1/i Utility Routines
write AD Output Stream Operator
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
  Sparse Hessian: Easy Driver: x
  Sparse Jacobian: Easy Driver: x
  Reverse Mode Second Partial Derivative Driver: x
  Forward Mode Second Partial Derivative Driver: x
  Hessian: Easy Driver: x
  First Order Derivative: Driver Routine: x
  First Order Partial Derivative: Driver Routine: x
  Jacobian: Driver Routine: x
  Hessian Sparsity Pattern: Reverse Mode: x
  Jacobian Sparsity Pattern: Reverse Mode: x
  Jacobian Sparsity Pattern: Forward Mode: x
  First Order Reverse Mode: x
  Stop Recording and Store Operation Sequence: x
  Construct an ADFun Object and Stop Recording: x
  Declare Independent Variables and Start Recording: 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
  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 Computed 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 Operation Hessian 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_Nonlinear Programming Using the CppAD Interface to Ipopt: x_l
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
xl Use Ipopt to Solve a Nonlinear Programming Problem: xl
xlow Multi-threading Newton Method Utility Routines: xlow
     A Multi-Threaded Newton's Method: xlow
xout Multi-threading Newton Method Utility Routines: multi_newton_combine.xout
     A Multi-Threaded Newton's Method: xout
xq Multiple Directions Forward Mode: xq
   Multiple Order Forward Mode: xq
xu Use Ipopt to Solve a Nonlinear Programming Problem: xu
xup Multi-threading Newton Method Utility Routines: xlow.xup
    A Multi-Threaded Newton's 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)
y0 Zero Order Forward Mode: Function Values: y0
y2 Second Order Forward Mode: Derivative Values: y2
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
yq Multiple Directions Forward Mode: yq
   Multiple Order Forward Mode: yq
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_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
zl Use Ipopt to Solve a Nonlinear Programming Problem: solution.zl
zu Use Ipopt to Solve a Nonlinear Programming Problem: solution.zu
cppad-20160000.1/doc/_search_xml.htm0000644000175200017650000000432212656322012016162 0ustar coincoin-web Search This Web Site
Prev Next _search Headings

Search This Web Site

1: Enter keywords separated by spaces 3: section

2: Select from following list of keyword matches

cppad-20160000.1/doc/index.html0000644000175200017650000000011712656322034015163 0ustar coincoin-web cppad-20160000.1/doc/_close.gif0000644000175200017650000000021712656322004015117 0ustar coincoin-webGIF89a‰{àÓtïñ¹ºª5ÿÿÿÿÿÿÿÿÿ!þMade with GIMP!ù,BXºÜþ0Êj „½¶`x5€`ž¨9¤À½ïÚ´̔4lgnÎí œo,‡Å£/9h:ŸNVƒ@­Z­˜¬vËÍ&;cppad-20160000.1/doc/_open.gif0000644000175200017650000000040112656322004014746 0ustar coincoin-webGIF89a„‰{ôî¾íò¸àÓtððºïï¹îñ¸¸©4ºª5ïñ¹ïð¹îñ¹ðêµ¹©4¶¨3 ·¨3ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ!þMade with GIMP!ù,l $Ždižhª¦@Û®# À€0ì{àº&  ¢”:wÊXbJ­Nƒè(¡P,5CÐH ²Ë˜ÂÁn·Í­ÚñpÄnˆ\X»Ýfi$}l qƒ1Š'Š’““0–—˜™–!;cppad-20160000.1/doc/_closeblue.gif0000644000175200017650000000163112656322004015770 0ustar coincoin-webGIF89a÷+(p…ÓÂÀêD?±ÿÿÿÿÿÿÿÿÿ!þMade with GIMP!ù,c H° Áƒ*L aÃ…˜8D‡3>,@€Ç = ÀQÅ“'G–DÉR%ÁŽ,QºŒh2&Å™aÚœˆ³€Î=Ú : ¨Ñ£FI$À´©S§£JJ5j@;cppad-20160000.1/doc/_openblue.gif0000644000175200017650000000170212656322004015623 0ustar coincoin-webGIF89a÷+(pÈÆìÂÀê…ÓÂÀêÁ¿éÂÀêC>®D?±ÂÀêÂÀêÂÀ꿽éD?¯C>¬ C>¬ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ!þMade with GIMP!ù,Œ%H° Áƒ*L aÃ… `"ˆ ظ1€C‡%rä€@ (˜q¤Ë*#&˜I³æLbL @Á0Ð ‚œ+#*pÀ´iS£t*uðÀAÔN!H`©S§F$%Ø•i‚¨_ŒøõkµÕÊ;¢Ý»xóÚ ;cppad-20160000.1/doc/_ad_xml.js0000644000175200017650000000252612656322004015132 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_contents.js0000644000175200017650000000437012656322004015522 0ustar coincoin-webvar Cookie = document.cookie; var Open = ''; var SectionCount = 589 ; 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'; } cppad-20160000.1/doc/cppad.xml0000644000175200017650000003157212656322004015005 0ustar coincoin-web cppad-20160000.1: A Package for Differentiation of C++ Algorithms
PrevNext

,
cppad-20160000.1: 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 cppad-20160000.1/doc/_cppad_xml.js0000644000175200017650000000221712656322004015632 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_contents_xml.htm0000644000175200017650000047157312656322004016573 0ustar coincoin-web Table of Contents
Prev Next _contents Headings

Table of Contents

cppad-20160000.1: A Package for Differentiation of C++ Algorithms
cppad-20160000.1: 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
                Using ColPack: Example and Test
                Using ColPack: 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
        Auto Tools Unix Test and Installation

     An Introduction by Example to Algorithmic Differentiation
    An Introduction by Example to Algorithmic Differentiation
        Getting Started Using CppAD to Compute Derivatives
         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 Computed Assignments
            AD Arithmetic Operators and Computed 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 Computed Assignment Operators
                AD Computed Assignment Operators
                    AD Computed Assignment Addition: Example and Test
                    AD Computed Assignment Subtraction: Example and Test
                    AD Computed Assignment Multiplication: Example and Test
                    AD Computed 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

                 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 Reverse Mode
                    Atomic Forward Jacobian Sparsity Patterns
                    Atomic Reverse Jacobian Sparsity Patterns
                    Atomic Reverse Hessian Sparsity Patterns
                    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 Patterns: Example and Test
                    Tan and Tanh as User Atomic Operations: Example and Test
                    Atomic Operation Hessian Sparsity: Example and Test
                     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
             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
         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

         Evaluate ADFun Functions, Derivatives, and Sparsity Patterns
        Evaluate ADFun Functions, Derivatives, and Sparsity Patterns
             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: Example and Test

             Calculating Sparsity Patterns
            Calculating Sparsity Patterns
                 Jacobian Sparsity Pattern: Forward Mode
                Jacobian Sparsity Pattern: Forward Mode
                    Forward Mode Jacobian Sparsity: Example and Test

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

                Computing Dependency: 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

                Using vectorBool Sparsity To Conserve Memory: Example and Test

         First and Second Derivatives: Easy Drivers
        First and Second Derivatives: Easy Drivers
             Jacobian: Driver Routine
            Jacobian: Driver Routine
                Jacobian: 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

             Hessian: Easy Driver
            Hessian: Easy Driver
                Hessian: Example and Test
                Hessian of Lagrangian and ADFun Default Constructor: 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

             Sparse Jacobian: Easy Driver
            Sparse Jacobian: Easy Driver
                Sparse Jacobian: Example and Test

             Sparse Hessian: Easy Driver
            Sparse Hessian: Easy Driver
                Sparse Hessian: Example and Test
                Computing Sparse Hessian for a Subset of Variables
                Sparse Hessian on Subset of Variables: Example and Test

         Check an ADFun Sequence of Operations
        Check an ADFun Sequence of Operations
            ADFun Check and Re-Tape: Example and Test

         Optimize an ADFun Object Tape
        Optimize an ADFun Object Tape
            ADFun Operation Sequence Optimization: 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-Threaded Implementation of Summation of 1/i
            Multi-Threaded Implementation of Summation of 1/i
                Timing Test of Multi-Threaded Summation of 1/i
                Multi-threading Sum of 1/i Utility Routines

             A Multi-Threaded Newton's Method
            A Multi-Threaded Newton's Method
                Timing Test of Multi-Threaded Newton Method
                Multi-threading Newton Method Utility Routines

             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

         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

     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
         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 of All the CppAD Examples
        Using The CppAD Test Vector Template Class

     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
         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
            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

         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
cppad-20160000.1/doc/__contents_xml.js0000644000175200017650000000217412656322004016541 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_install_xml.js0000644000175200017650000000273412656322004016215 0ustar coincoin-webvar 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', 'auto_tools.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' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[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]; } cppad-20160000.1/doc/_download_xml.js0000644000175200017650000000412112656322004016346 0ustar coincoin-webvar 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', 'auto_tools.xml' ]; var list_current0 = [ 'download.xml#Purpose', 'download.xml#Distribution Directory', 'download.xml#Compressed Archives', 'download.xml#Compressed Archives.Current Version', 'download.xml#Compressed Archives.Release Versions', 'download.xml#Compressed Archives.Monthly Versions', 'download.xml#Compressed Archives.Unix File Extraction', 'download.xml#Compressed Archives.Windows File Extraction and Testing', 'download.xml#Compressed Archives.Install Instructions', 'download.xml#Subversion', 'download.xml#Subversion.Limitations', 'download.xml#Subversion.Current Version', 'download.xml#Subversion.Stable Versions', 'download.xml#Subversion.Release Versions', 'download.xml#Subversion.Install Instructions' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[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]; } cppad-20160000.1/doc/_cmake_xml.js0000644000175200017650000000455312656322004015630 0ustar coincoin-webvar 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', 'auto_tools.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#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_profile_flag', 'cmake.xml#cppad_profile_flag.Eigen and Fadbad', 'cmake.xml#cppad_testvector', 'cmake.xml#cppad_max_num_threads', 'cmake.xml#cppad_sparse_list', '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_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]; } cppad-20160000.1/doc/adolc_prefix.xml0000644000175200017650000002403212656322004016346 0ustar coincoin-web 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 cppad-20160000.1/doc/_adolc_prefix_xml.js0000644000175200017650000000375512656322004017212 0ustar coincoin-webvar 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', 'auto_tools.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]; } cppad-20160000.1/doc/_get_adolc.sh_xml.js0000644000175200017650000000353112656322004017075 0ustar coincoin-webvar 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', 'auto_tools.xml' ]; var list_down2 = [ 'adolc_prefix.xml', 'colpack_prefix.xml', 'eigen_prefix.xml', 'fadbad_prefix.xml', 'ipopt_prefix.xml', 'sacado_prefix.xml', 'cppad_testvector.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_colpack_prefix_xml.js0000644000175200017650000000376612656322004017546 0ustar coincoin-webvar 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', 'auto_tools.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_hes.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]; } cppad-20160000.1/doc/_colpack_jac.cpp_xml.js0000644000175200017650000000321512656322004017554 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'install.xml', 'cmake.xml', 'colpack_prefix.xml', 'colpack_jac.cpp.xml' ]; var list_down3 = [ 'download.xml', 'cmake.xml', 'cmake_check.xml', 'pkgconfig.xml', 'auto_tools.xml' ]; var list_down2 = [ 'adolc_prefix.xml', 'colpack_prefix.xml', 'eigen_prefix.xml', 'fadbad_prefix.xml', 'ipopt_prefix.xml', 'sacado_prefix.xml', 'cppad_testvector.xml' ]; var list_down1 = [ 'colpack_jac.cpp.xml', 'colpack_hes.cpp.xml', 'get_colpack.sh.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_colpack_hes.cpp_xml.js0000644000175200017650000000321512656322004017576 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'install.xml', 'cmake.xml', 'colpack_prefix.xml', 'colpack_hes.cpp.xml' ]; var list_down3 = [ 'download.xml', 'cmake.xml', 'cmake_check.xml', 'pkgconfig.xml', 'auto_tools.xml' ]; var list_down2 = [ 'adolc_prefix.xml', 'colpack_prefix.xml', 'eigen_prefix.xml', 'fadbad_prefix.xml', 'ipopt_prefix.xml', 'sacado_prefix.xml', 'cppad_testvector.xml' ]; var list_down1 = [ 'colpack_jac.cpp.xml', 'colpack_hes.cpp.xml', 'get_colpack.sh.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_get_colpack.sh_xml.js0000644000175200017650000000357012656322004017432 0ustar coincoin-webvar 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', 'auto_tools.xml' ]; var list_down2 = [ 'adolc_prefix.xml', 'colpack_prefix.xml', 'eigen_prefix.xml', 'fadbad_prefix.xml', 'ipopt_prefix.xml', 'sacado_prefix.xml', 'cppad_testvector.xml' ]; var list_down1 = [ 'colpack_jac.cpp.xml', 'colpack_hes.cpp.xml', 'get_colpack.sh.xml' ]; 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]; } cppad-20160000.1/doc/_eigen_prefix_xml.js0000644000175200017650000000367112656322004017214 0ustar coincoin-webvar 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', 'auto_tools.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]; } cppad-20160000.1/doc/_get_eigen.sh_xml.js0000644000175200017650000000347012656322004017104 0ustar coincoin-webvar 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', 'auto_tools.xml' ]; var list_down2 = [ 'adolc_prefix.xml', 'colpack_prefix.xml', 'eigen_prefix.xml', 'fadbad_prefix.xml', 'ipopt_prefix.xml', 'sacado_prefix.xml', 'cppad_testvector.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_fadbad_prefix_xml.js0000644000175200017650000000364412656322004017326 0ustar coincoin-webvar 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', 'auto_tools.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]; } cppad-20160000.1/doc/_get_fadbad.sh_xml.js0000644000175200017650000000344612656322004017221 0ustar coincoin-webvar 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', 'auto_tools.xml' ]; var list_down2 = [ 'adolc_prefix.xml', 'colpack_prefix.xml', 'eigen_prefix.xml', 'fadbad_prefix.xml', 'ipopt_prefix.xml', 'sacado_prefix.xml', 'cppad_testvector.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ipopt_prefix_xml.js0000644000175200017650000000364312656322004017257 0ustar coincoin-webvar 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', 'auto_tools.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]; } cppad-20160000.1/doc/_get_ipopt.sh_xml.js0000644000175200017650000000347012656322004017150 0ustar coincoin-webvar 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', 'auto_tools.xml' ]; var list_down2 = [ 'adolc_prefix.xml', 'colpack_prefix.xml', 'eigen_prefix.xml', 'fadbad_prefix.xml', 'ipopt_prefix.xml', 'sacado_prefix.xml', 'cppad_testvector.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_sacado_prefix_xml.js0000644000175200017650000000364412656322004017357 0ustar coincoin-webvar 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', 'auto_tools.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]; } cppad-20160000.1/doc/_get_sacado.sh_xml.js0000644000175200017650000000350112656322004017242 0ustar coincoin-webvar 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', 'auto_tools.xml' ]; var list_down2 = [ 'adolc_prefix.xml', 'colpack_prefix.xml', 'eigen_prefix.xml', 'fadbad_prefix.xml', 'ipopt_prefix.xml', 'sacado_prefix.xml', 'cppad_testvector.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_cppad_testvector_xml.js0000644000175200017650000000362212656322004020115 0ustar coincoin-webvar 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', 'auto_tools.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]; } cppad-20160000.1/doc/_cmake_check_xml.js0000644000175200017650000000303512656322004016757 0ustar coincoin-webvar 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', 'auto_tools.xml' ]; var list_current0 = [ 'cmake_check.xml#Purpose', 'cmake_check.xml#Check All', 'cmake_check.xml#Check All.Windows', 'cmake_check.xml#Subsets' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[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]; } cppad-20160000.1/doc/auto_tools.xml0000644000175200017650000012052412656322004016102 0ustar coincoin-web Auto Tools Unix Test and Installation
Prev Next auto_tools

Auto Tools Unix Test and Installation

Deprecated 2012-12-26
These install instructions have been deprecated and no improvements have been added since 2012. For example, this install procedure will not detect any of the c++11 extensions. You should use the cmake instructions to install CppAD.

Distribution Directory
You must first obtain a copy of the CppAD distribution directory using the download instructions. The install instructions below correspond to the current version which has distribution directory cppad-20121230.

Work Directory
Create the directory cppad-20121230/build, which will be referred to as the build directory below.

Configure
Execute the following command in the build directory:
./configure                                  \
     --prefix=
prefix_dir                    \
     --with-Documentation                     \
     --with-
testvector                      \
     --with-sparse_
option                   \
     --with-deprecated                        \
     MAX_NUM_THREADS=
max_num_threads         \
     CXX_FLAGS=
cxx_flags                     \
     OPENMP_FLAGS=
openmp_flags               \
     POSTFIX_DIR=
postfix_dir                 \
     ADOLC_DIR=
adolc_dir                     \
     BOOST_DIR=
boost_dir                     \
     EIGEN_DIR=
eigen_dir                     \
     FADBAD_DIR=
fadbad_dir                   \
     SADADO_DIR=
sacado_dir                   \
     IPOPT_DIR=
ipopt_dir                     \
     TAPE_ADDR_TYPE=
tape_addr_type           \
     TAPE_ID_TYPE=
tape_id_type
where only the configure line need appear; i.e., the entries in all of the other lines are optional. The text in italic is replaced values that you choose; see discussion below.

make
CppAD has some object libraries that are used for its correctness tests. (Currently, none of these libraries get installed.) You can build these libraries by executing the command
     make
in the build directory.

Examples and Tests
Once you have executed the make command, you can run the correctness and speed tests.

The following command will build all the correctness and speed tests. In addition, it will run all the correctness tests:
 
     make test


The following links describe how to build and run subsets of these tests:
get_started Getting Started Using CppAD to Compute Derivatives
exp_apx_main Correctness Tests For Exponential Approximation in Introduction
example CppAD Examples and Tests
print_for_cout Printing During Forward Mode: Example and Test
speed_example Run the Speed Examples
speed_double Speed Test of Functions in Double
speed_adolc Speed Test of Derivatives Using Adolc
speed_cppad Speed Test Derivatives Using CppAD
speed_fadbad Speed Test Derivatives Using Fadbad
speed_sacado Speed Test Derivatives Using Sacado
In addition, you can run a large subset of correctness tests (that are not intended to be examples) by executing the following commands starting in the build directory:
     cd test_more
     make test

Profiling CppAD
The CppAD derivative speed tests mentioned above can be profiled. You can test that the results computed during this profiling are correct by executing the following commands starting in the build directory:
     cd speed/profile
     make test
After executing make test, you can run a profile speed test by executing the command ./profile; see speed_main for the meaning of the command line options to this program.

After you have run a profiling speed test, you can then obtain the profiling results with
     gprof -b profile
If you are using a windows operating system with Cygwin or MinGW, you may have to replace profile by profile.exe in the gprof command above; i.e.,
 
     gprof -b profile.exe
In C++, template parameters and argument types become part of a routines's name. This can make the gprof output hard to read (the routine names can be very long). You can remove the template parameters and argument types from the routine names by executing the following command
 
     gprof -b profile | sed -f gprof.sed
If you are using a windows operating system with Cygwin or MinGW, you would need to use
 
     gprof -b profile.exe | sed -f gprof.sed

prefix_dir
The default value for prefix directory is $HOME i.e., by default the CppAD include files will install below $HOME. If you want to install elsewhere, you will have to use this option. As an example of using the --prefix=prefix_dir option, if you specify
 
     ./configure --prefix=/usr/local
the CppAD include files will be installed in the directory
     /usr/local/include/cppad
If --with-Documentation is specified, the CppAD documentation files will be installed in the directory
     /usr/local/share/doc/cppad-20121230

--with-Documentation
If the command line argument --with-Documentation is specified, the CppAD documentation HTML and XML files are copied to the directory
     
prefix_dir/share/doc/postfix_dir/cppad-20121230
(see postfix_dir ). The top of the CppAD HTML documentation tree (with mathematics displayed as LaTex command) will be located at
     
prefix_dir/share/doc/postfix_dir/cppad-20121230/cppad.htm
and the top of the XML documentation tree (with mathematics displayed as MathML) will be located at
     
prefix_dir/share/doc/postfix_dir/cppad-20121230/cppad.xml

--with-testvector
The CPPAD_TESTVECTOR template class is used for many of the CppAD examples and tests. The default for this template class is CppAD::vector<Scalar> . If one, and only one, of the following command line arguments is specified:
 
     --with-stdvector
     --with-boostvector
     --with-eigenvector
the corresponding of the following template classes is used
     std::vector<
Scalar>
     boost::numeric::ublas::vector<
Scalar>
     Eigen::matrix<
Scalar, Eigen::Dynamic, 1>
See also, boost_dir and eigen_dir .

--with-sparse_option
There are two options for the preprocessor symbol CPPAD_INTERNAL_SPARSE_SET. If --with-sparse_set (--with-sparse_list) is specified, this symbol is sparse_set (sparse_list). This should affect the speed and memory required by the sparse_jacobian , sparse_hessian , and the sparse drivers .

--with-deprecated
If this configure argument is present, then all the deprecated features are included in the install. Otherwise, they are not included.

max_num_threads
this specifies the value for the default value for the preprocessor symbol CPPAD_MAX_NUM_THREADS . It must be greater than or equal to four; i.e., max_num_threads >= 4 .

cxx_flags
If the command line argument CompilerFlags is present, it specifies compiler flags. For example,
     CXX_FLAGS="-Wall -ansi"
would specify that warning flags -Wall and -ansi should be included in all the C++ compile commands. The error and warning flags chosen must be valid options for the C++ compiler. The default value for CompilerFlags is the empty string.

openmp_flags
If the command line argument OpenmpFlags is present, it specifies the necessary flags so that the compiler will properly interpret OpenMP directives. For example, when using the GNU g++ compiler, the following setting includes the OpenMP tests:
     OPENMP_FLAGS=-fopenmp
If you specify configure command, the CppAD OpenMP correctness and speed tests will be built; see threading multi-threading tests.

postfix_dir
By default, the postfix directory is empty; i.e., there is no postfix directory. As an example of using the POSTFIX_DIR=postfix_dir option, if you specify
 
     ./configure --prefix=/usr/local POSTFIX_DIR=coin
the CppAD include files will be installed in the directory
     /usr/local/include/coin/cppad
If --with-Documentation is specified, the CppAD documentation files will be installed in the directory
     /usr/local/share/doc/coin/cppad-20121230

adolc_dir
If you have ADOL-C installed on your system, you can specify a value for adolc_dir in the configure command line. The value of adolc_dir must be such that
     
adolc_dir/include/adolc/adouble.h
is a valid way to reference adouble.h. In this case, you can run the Adolc speed correctness tests by executing the following commands starting in the build directory:
     cd speed/adolc
     make test
After executing make test, you can run an Adolc speed tests by executing the command ./adolc; see speed_main for the meaning of the command line options to this program. Note that these speed tests assume Adolc has been configure with its sparse matrix computations enabled using
     --with-colpack=
colpack_dir

Linux
If you are using Linux, you will have to add adolc_dir/lib to LD_LIBRARY_PATH. For example, if you use the bash shell to run your programs, you could include
     LD_LIBRARY_PATH=
adolc_dir/lib:${LD_LIBRARY_PATH}
     export LD_LIBRARY_PATH
in your $HOME/.bash_profile file.

Cygwin
If you are using Cygwin, you will have to add to following lines to the file .bash_profile in your home directory:
     PATH=
adolc_dir/bin:${PATH}
     export PATH
in order for Adolc to run properly. If adolc_dir begins with a disk specification, you must use the Cygwin format for the disk specification. For example, if d:/adolc_base is the proper directory, /cygdrive/d/adolc_base should be used for adolc_dir .

boost_dir
If the command line argument
     BOOST_DIR=
boost_dir
is present, it must be such that files
     
boost_dir/include/boost/numeric/ublas/vector.hpp
     
boost_dir/include/boost/thread.hpp
are present. In this case, these files will be used by CppAD. See also, --with-boostvector

eigen_dir
If you have Eigen installed on your system, you can specify a value for eigen_dir . It must be such that
     
eigen_dir/include/Eigen/Core
is a valid include file. In this case CppAD will compile and test the Eigen examples; e.g., eigen_array.cpp . See also, --with-eigenvector

fadbad_dir
If you have Fadbad 2.1 installed on your system, you can specify a value for fadbad_dir . It must be such that
     
fadbad_dir/include/FADBAD++/badiff.h
is a valid reference to badiff.h. In this case, you can run the Fadbad speed correctness tests by executing the following commands starting in the build directory:
     cd speed/fadbad
     make test
After executing make test, you can run a Fadbad speed tests by executing the command ./fadbad; see speed_main for the meaning of the command line options to this program.

ipopt_dir
If you have Ipopt installed on your system, you can specify a value for ipopt_dir . It must be such that
     
ipopt_dir/include/coin/IpIpoptApplication.hpp
is a valid reference to IpIpoptApplication.hpp. In this case, the CppAD interface to Ipopt examples can be built and tested by executing the following commands starting in the build directory:
     make
     #
     cd cppad_ipopt/example
     make test
     #
     cd ../test
     make test
     #
     cd ../speed
     make test
Once this has been done, you can execute the program ./speed in the build/cppad_ipopt/speed directory; see ipopt_ode_speed.cpp .

sacado_dir
If you have Sacado installed on your system, you can specify a value for sacado_dir . It must be such that
     
sacado_dir/include/Sacado.hpp
is a valid reference to Sacado.hpp. In this case, you can run the Sacado speed correctness tests by executing the following commands starting in the build directory:
     cd speed/sacado
     make test
After executing make test, you can run a Sacado speed tests by executing the command ./sacado; see speed_main for the meaning of the command line options to this program.

tape_addr_type
If the command line argument tape_addr_type is present, it specifies the type used for address in the AD recordings (tapes). The valid values for this argument are unsigned short int, unsigned int, size_t. The smaller the value of sizeof(tape_addr_type) , the less memory is used. On the other hand, the value
     std::numeric_limits<
tape_addr_type>::max()
must be larger than any of the following: size_op , size_op_arg , size_par , size_par , size_par .

tape_id_type
If the command line argument tape_id_type is present, it specifies the type used for identifying tapes. The valid values for this argument are unsigned short int, unsigned int, size_t. The smaller the value of sizeof(tape_id_type) , the less memory is used. On the other hand, the value
     std::numeric_limits<
tape_id_type>::max()
must be larger than the maximum number of tapes per thread times max_num_threads .

make install
Once you are satisfied that the tests are giving correct results, you can install CppAD into easy to use directories by executing the command
 
     make install
This will install CppAD in the location specified by prefix_dir . You must have permission to write in the prefix_dir directory to execute this command. You may optionally specify a destination directory for the install; i.e.,
     make install DESTDIR=
DestinationDirectory

Input File: omh/install/auto_tools.omh cppad-20160000.1/doc/_auto_tools_xml.js0000644000175200017650000000442112656322004016732 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'install.xml', 'auto_tools.xml' ]; var list_down2 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down1 = [ 'download.xml', 'cmake.xml', 'cmake_check.xml', 'pkgconfig.xml', 'auto_tools.xml' ]; var list_current0 = [ 'auto_tools.xml#Deprecated 2012-12-26', 'auto_tools.xml#Distribution Directory', 'auto_tools.xml#Work Directory', 'auto_tools.xml#Configure', 'auto_tools.xml#make', 'auto_tools.xml#make.Examples and Tests', 'auto_tools.xml#Profiling CppAD', 'auto_tools.xml#prefix_dir', 'auto_tools.xml#--with-Documentation', 'auto_tools.xml#--with-testvector', 'auto_tools.xml#--with-sparse_option', 'auto_tools.xml#--with-deprecated', 'auto_tools.xml#max_num_threads', 'auto_tools.xml#cxx_flags', 'auto_tools.xml#openmp_flags', 'auto_tools.xml#postfix_dir', 'auto_tools.xml#adolc_dir', 'auto_tools.xml#adolc_dir.Linux', 'auto_tools.xml#adolc_dir.Cygwin', 'auto_tools.xml#boost_dir', 'auto_tools.xml#eigen_dir', 'auto_tools.xml#fadbad_dir', 'auto_tools.xml#ipopt_dir', 'auto_tools.xml#sacado_dir', 'auto_tools.xml#tape_addr_type', 'auto_tools.xml#tape_id_type', 'auto_tools.xml#make install' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_introduction_xml.js0000644000175200017650000000313712656322004017266 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_get_started.cpp_xml.js0000644000175200017650000000327512656322004017636 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'introduction.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', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.cpp.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]; } cppad-20160000.1/doc/_exp_2.hpp_xml.js0000644000175200017650000000332512656322004016347 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2.cpp_xml.js0000644000175200017650000000332512656322004016342 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2_for0_xml.js0000644000175200017650000000430212656322004016503 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2_for0.cpp_xml.js0000644000175200017650000000312212656322004017263 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2_for1_xml.js0000644000175200017650000000442412656322004016511 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2_for1.cpp_xml.js0000644000175200017650000000312212656322004017264 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2_rev1_xml.js0000644000175200017650000000404412656322004016515 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2_rev1.cpp_xml.js0000644000175200017650000000312212656322004017272 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2_for2_xml.js0000644000175200017650000000446512656322004016517 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2_for2.cpp_xml.js0000644000175200017650000000312212656322004017265 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2_rev2_xml.js0000644000175200017650000000404412656322004016516 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2_rev2.cpp_xml.js0000644000175200017650000000312212656322004017273 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_2_cppad_xml.js0000644000175200017650000000344712656322004016735 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_xml.js0000644000175200017650000000352312656322004016207 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps.hpp_xml.js0000644000175200017650000000335112656322004016774 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps.cpp_xml.js0000644000175200017650000000335112656322004016767 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_for0_xml.js0000644000175200017650000000450612656322004017137 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_for0.cpp_xml.js0000644000175200017650000000315212656322004017714 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_for1_xml.js0000644000175200017650000000445012656322004017136 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_for1.cpp_xml.js0000644000175200017650000000315212656322004017715 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_rev1_xml.js0000644000175200017650000000425212656322004017144 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_rev1.cpp_xml.js0000644000175200017650000000315212656322004017723 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_for2_xml.js0000644000175200017650000000454712656322004017146 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_for2.cpp_xml.js0000644000175200017650000000315212656322004017716 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_rev2_xml.js0000644000175200017650000000425212656322004017145 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_rev2.cpp_xml.js0000644000175200017650000000315212656322004017724 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_eps_cppad_xml.js0000644000175200017650000000347712656322004017366 0ustar coincoin-webvar 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 = [ 'get_started.cpp.xml', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.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]; } cppad-20160000.1/doc/_exp_apx_main.cpp_xml.js0000644000175200017650000000275612656322004020004 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'introduction.xml', 'exp_apx_main.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', 'exp_2.xml', 'exp_eps.xml', 'exp_apx_main.cpp.xml' ]; var list_current0 = [ 'exp_apx_main.cpp.xml#Running Tests', 'exp_apx_main.cpp.xml#main.cpp' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[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]; } cppad-20160000.1/doc/_ad_ctor_xml.js0000644000175200017650000000324412656322004016157 0ustar coincoin-webvar 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#x.Deprecated 2013-12-31', '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]; } cppad-20160000.1/doc/_ad_ctor.cpp_xml.js0000644000175200017650000000317212656322004016740 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ad_assign_xml.js0000644000175200017650000000312712656322004016474 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ad_assign.cpp_xml.js0000644000175200017650000000320012656322004017245 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_convert_xml.js0000644000175200017650000000305012656322004016217 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_value_xml.js0000644000175200017650000000367212656322004015665 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_value.cpp_xml.js0000644000175200017650000000310312656322004016433 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_integer_xml.js0000644000175200017650000000376012656322004016204 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_integer.cpp_xml.js0000644000175200017650000000311112656322004016753 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ad_to_string_xml.js0000644000175200017650000000356412656322004017225 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ad_input_xml.js0000644000175200017650000000367312656322004016355 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ad_input.cpp_xml.js0000644000175200017650000000311412656322004017124 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ad_output_xml.js0000644000175200017650000000374012656322004016551 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/ad_output.cpp.xml0000644000175200017650000000710312656322004016474 0ustar coincoin-web AD Output Operator: Example and Test
Prev Next ad_output.cpp Headings

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/ad_output.cpp cppad-20160000.1/doc/_ad_output.cpp_xml.js0000644000175200017650000000311712656322004017330 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_printfor_xml.js0000644000175200017650000000405212656322004016405 0ustar coincoin-webvar 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#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]; } cppad-20160000.1/doc/_print_for_cout.cpp_xml.js0000644000175200017650000000336512656322004020365 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_print_for_string.cpp_xml.js0000644000175200017650000000316612656322004020720 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_var2par_xml.js0000644000175200017650000000362112656322004016120 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_var2par.cpp_xml.js0000644000175200017650000000311112656322004016673 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_advalued_xml.js0000644000175200017650000000315512656322004016332 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_arithmetic_xml.js0000644000175200017650000000357412656322004016703 0ustar coincoin-webvar 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', 'compute_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]; } cppad-20160000.1/doc/_unaryplus_xml.js0000644000175200017650000000361012656322004016603 0ustar coincoin-webvar 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', 'compute_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]; } cppad-20160000.1/doc/_unary_plus.cpp_xml.js0000644000175200017650000000311712656322004017525 0ustar coincoin-webvar 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', 'compute_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]; } cppad-20160000.1/doc/_unaryminus_xml.js0000644000175200017650000000365012656322004016757 0ustar coincoin-webvar 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', 'compute_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]; } cppad-20160000.1/doc/_unary_minus.cpp_xml.js0000644000175200017650000000312212656322004017671 0ustar coincoin-webvar 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', 'compute_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]; } cppad-20160000.1/doc/_ad_binary_xml.js0000644000175200017650000000421012656322004016466 0ustar coincoin-webvar 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', 'compute_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]; } cppad-20160000.1/doc/_add.cpp_xml.js0000644000175200017650000000315612656322004016057 0ustar coincoin-webvar 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', 'compute_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]; } cppad-20160000.1/doc/_sub.cpp_xml.js0000644000175200017650000000315612656322004016120 0ustar coincoin-webvar 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', 'compute_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]; } cppad-20160000.1/doc/_mul.cpp_xml.js0000644000175200017650000000315612656322004016124 0ustar coincoin-webvar 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', 'compute_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]; } cppad-20160000.1/doc/_div.cpp_xml.js0000644000175200017650000000315612656322004016111 0ustar coincoin-webvar 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', 'compute_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]; } cppad-20160000.1/doc/_compute_assign_xml.js0000644000175200017650000000434312656322004017565 0ustar coincoin-webvar 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', 'compute_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', 'compute_assign.xml' ]; var list_down0 = [ 'addeq.cpp.xml', 'sub_eq.cpp.xml', 'mul_eq.cpp.xml', 'div_eq.cpp.xml' ]; var list_current0 = [ 'compute_assign.xml#Syntax', 'compute_assign.xml#Purpose', 'compute_assign.xml#Op', 'compute_assign.xml#Base', 'compute_assign.xml#x', 'compute_assign.xml#y', 'compute_assign.xml#Result', 'compute_assign.xml#Operation Sequence', 'compute_assign.xml#Example', 'compute_assign.xml#Derivative', 'compute_assign.xml#Derivative.Addition', 'compute_assign.xml#Derivative.Subtraction', 'compute_assign.xml#Derivative.Multiplication', 'compute_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]; } cppad-20160000.1/doc/_addeq.cpp_xml.js0000644000175200017650000000320012656322004016373 0ustar coincoin-webvar 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', 'compute_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', 'compute_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]; } cppad-20160000.1/doc/_sub_eq.cpp_xml.js0000644000175200017650000000320112656322004016574 0ustar coincoin-webvar 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', 'compute_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', 'compute_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]; } cppad-20160000.1/doc/_mul_eq.cpp_xml.js0000644000175200017650000000320112656322004016600 0ustar coincoin-webvar 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', 'compute_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', 'compute_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]; } cppad-20160000.1/doc/_div_eq.cpp_xml.js0000644000175200017650000000320112656322004016565 0ustar coincoin-webvar 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', 'compute_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', 'compute_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]; } cppad-20160000.1/doc/_unary_standard_math_xml.js0000644000175200017650000000451512656322004020575 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_acos.cpp_xml.js0000644000175200017650000000337012656322004016252 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_asin_xml.js0000644000175200017650000000375112656322004015501 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_asin.cpp_xml.js0000644000175200017650000000337012656322004016257 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_atan_xml.js0000644000175200017650000000375112656322004015472 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_atan.cpp_xml.js0000644000175200017650000000337012656322004016250 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_cos_xml.js0000644000175200017650000000374212656322004015333 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_cos.cpp_xml.js0000644000175200017650000000336512656322004016115 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_cosh_xml.js0000644000175200017650000000375112656322004015503 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_cosh.cpp_xml.js0000644000175200017650000000337012656322005016262 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_exp_xml.js0000644000175200017650000000374212656322005015344 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_exp.cpp_xml.js0000644000175200017650000000336512656322005016126 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_log_xml.js0000644000175200017650000000374212656322005015331 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_log.cpp_xml.js0000644000175200017650000000336512656322005016113 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_log10_xml.js0000644000175200017650000000373012656322005015467 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_log10.cpp_xml.js0000644000175200017650000000337312656322005016253 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sin_xml.js0000644000175200017650000000374212656322005015341 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sin.cpp_xml.js0000644000175200017650000000336512656322005016123 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sinh_xml.js0000644000175200017650000000375112656322005015511 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sinh.cpp_xml.js0000644000175200017650000000337012656322005016267 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sqrt_xml.js0000644000175200017650000000375112656322005015541 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sqrt.cpp_xml.js0000644000175200017650000000337012656322005016317 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_tan_xml.js0000644000175200017650000000374212656322005015332 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_tan.cpp_xml.js0000644000175200017650000000336512656322005016114 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_tanh_xml.js0000644000175200017650000000375112656322005015502 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_tanh.cpp_xml.js0000644000175200017650000000337012656322005016260 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_abs_xml.js0000644000175200017650000000377312656322005015321 0ustar coincoin-webvar 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 = [ 'abs.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]; } cppad-20160000.1/doc/_abs.cpp_xml.js0000644000175200017650000000336512656322005016077 0ustar coincoin-webvar 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', 'abs.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 = [ 'abs.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]; } cppad-20160000.1/doc/_acosh_xml.js0000644000175200017650000000413212656322005015637 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_acosh.cpp_xml.js0000644000175200017650000000337312656322005016426 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_asinh_xml.js0000644000175200017650000000413212656322005015644 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_asinh.cpp_xml.js0000644000175200017650000000337312656322005016433 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_atanh_xml.js0000644000175200017650000000413212656322005015635 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_atanh.cpp_xml.js0000644000175200017650000000337312656322005016424 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_erf_xml.js0000644000175200017650000000411012656322005015312 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_erf.cpp_xml.js0000644000175200017650000000336512656322005016106 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_expm1_xml.js0000644000175200017650000000413212656322005015574 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_expm1.cpp_xml.js0000644000175200017650000000337312656322005016363 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_log1p_xml.js0000644000175200017650000000413212656322005015564 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_log1p.cpp_xml.js0000644000175200017650000000337312656322005016353 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sign_xml.js0000644000175200017650000000400112656322005015475 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sign.cpp_xml.js0000644000175200017650000000337012656322005016266 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/binary_math.xml0000644000175200017650000000603412656322005016207 0ustar coincoin-web 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/local/standard_math.hpp cppad-20160000.1/doc/_binary_math_xml.js0000644000175200017650000000353112656322005017041 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_atan2.cpp_xml.js0000644000175200017650000000303512656322005016331 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_pow.cpp_xml.js0000644000175200017650000000302712656322005016132 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_azmul_xml.js0000644000175200017650000000346612656322005015703 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_azmul.cpp_xml.js0000644000175200017650000000303512656322005016454 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_condexp_xml.js0000644000175200017650000000421012656322005016177 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/cond_exp.cpp.xml0000644000175200017650000001660212656322005016274 0ustar coincoin-web Conditional Expressions: Example and Test
Prev Next cond_exp.cpp

Conditional Expressions: Example and Test

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;
	using CppAD::abs;
	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/cond_exp.cpp cppad-20160000.1/doc/_cond_exp.cpp_xml.js0000644000175200017650000000322712656322005017126 0ustar coincoin-webvar 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#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]; } cppad-20160000.1/doc/tape_index.cpp.xml0000644000175200017650000001112312656322005016606 0ustar coincoin-web Taping Array Index Operation: Example and Test
Prev Next tape_index.cpp Headings

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/tape_index.cpp cppad-20160000.1/doc/_tape_index.cpp_xml.js0000644000175200017650000000322712656322005017447 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/interp_onetape.cpp.xml0000644000175200017650000001535712656322005017517 0ustar coincoin-web 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;

	// 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, 1e-10, 1e-10);

	// evaluate f where x has different value
	x[0]   = .7 * ArgumentValue[2] + .3 * ArgumentValue[3];
	y      = f.Forward(0, x);

	// check function value
	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, 1e-10, 1e-10);

	// 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, 1e-10, 1e-10);

	return ok;
}


Input File: example/interp_onetape.cpp cppad-20160000.1/doc/_interp_onetape.cpp_xml.js0000644000175200017650000000332612656322005020343 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_numeric_limits_xml.js0000644000175200017650000000412012656322005017562 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'ad.xml', 'advalued.xml', 'numeric_limits.xml' ]; var list_down3 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down2 = [ 'ad_ctor.xml', 'ad_assign.xml', 'convert.xml', 'advalued.xml', 'boolvalued.xml', 'vecad.xml', 'base_require.xml' ]; var list_down1 = [ 'arithmetic.xml', 'unary_standard_math.xml', 'binary_math.xml', 'condexp.xml', 'discrete.xml', 'numeric_limits.xml', 'atomic.xml' ]; var list_down0 = [ 'num_limits.cpp.xml' ]; var list_current0 = [ 'numeric_limits.xml#Syntax', 'numeric_limits.xml#CppAD::numeric_limits', 'numeric_limits.xml#std::numeric_limits', 'numeric_limits.xml#Float', 'numeric_limits.xml#epsilon', 'numeric_limits.xml#min', 'numeric_limits.xml#max', 'numeric_limits.xml#quiet_NaN', 'numeric_limits.xml#Example' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_num_limits.cpp_xml.js0000644000175200017650000000315212656322005017504 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/checkpoint.xml0000644000175200017650000005522312656322005016045 0ustar coincoin-web Checkpointing Functions
Prev Next

Checkpointing Functions

Syntax
checkpoint<Baseatom_fun(namealgoaxaysparsity)
sv = atom_fun.size_var()
atom_fun.option(option_value)
algo(axay)
atom_fun(axay)
checkpoint<
Base>::clear()


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 . The operation sequence representing f ( x ) cannot depend on the value of x .

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.

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/local/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.

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/local/checkpoint.hpp cppad-20160000.1/doc/_checkpoint_xml.js0000644000175200017650000000426712656322005016702 0ustar coincoin-webvar 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' ]; var list_current0 = [ 'checkpoint.xml#Syntax', 'checkpoint.xml#Purpose', 'checkpoint.xml#Purpose.Reduce Memory', 'checkpoint.xml#Purpose.Faster Recording', '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#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]; } cppad-20160000.1/doc/_checkpoint.cpp_xml.js0000644000175200017650000000313512656322005017454 0ustar coincoin-webvar 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' ]; 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]; } cppad-20160000.1/doc/_atomic_base_xml.js0000644000175200017650000000463412656322005017017 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_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]; } cppad-20160000.1/doc/_atomic_ctor_xml.js0000644000175200017650000000465112656322005017053 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_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#Examples', 'atomic_ctor.xml#Examples.Define Constructor', 'atomic_ctor.xml#Examples.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]; } cppad-20160000.1/doc/_atomic_option_xml.js0000644000175200017650000000425112656322005017410 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_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]; } cppad-20160000.1/doc/_atomic_afun_xml.js0000644000175200017650000000416012656322005017030 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_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]; } cppad-20160000.1/doc/_atomic_forward_xml.js0000644000175200017650000000455012656322005017546 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_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', 'atomic_forward.xml#Examples.Define forward', 'atomic_forward.xml#Examples.Use 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]; } cppad-20160000.1/doc/_atomic_reverse_xml.js0000644000175200017650000000452012656322005017552 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_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, G, H', 'atomic_reverse.xml#py', 'atomic_reverse.xml#py.px', 'atomic_reverse.xml#ok', 'atomic_reverse.xml#Examples', 'atomic_reverse.xml#Examples.Define reverse', 'atomic_reverse.xml#Examples.Use reverse' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/atomic_for_sparse_jac.xml0000644000175200017650000003011612656322005020224 0ustar coincoin-web Atomic Forward Jacobian Sparsity Patterns
Prev Next atomic_for_sparse_jac

Atomic Forward Jacobian Sparsity Patterns

Syntax
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 , 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 .

ok
The return value ok has prototype
     bool 
ok
If it is true, the corresponding evaluation succeeded, otherwise it failed.

Examples

Define for_sparse_jac
The following files contain example atomic for_sparse_jac functions: norm_sq.cpp , reciprocal.cpp , tangent.cpp , matrix_mul.hpp .

Use for_sparse_jac
The following are links to user atomic function constructor uses: norm_sq.cpp , reciprocal.cpp , tangent.cpp , mat_mul.cpp .
Input File: cppad/local/atomic_base.hpp cppad-20160000.1/doc/_atomic_for_sparse_jac_xml.js0000644000175200017650000000460312656322005021061 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_for_sparse_jac.xml#Syntax', '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#ok', 'atomic_for_sparse_jac.xml#Examples', 'atomic_for_sparse_jac.xml#Examples.Define for_sparse_jac', 'atomic_for_sparse_jac.xml#Examples.Use for_sparse_jac' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_atomic_rev_sparse_jac_xml.js0000644000175200017650000000460512656322005021071 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_rev_sparse_jac.xml#Syntax', '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#ok', 'atomic_rev_sparse_jac.xml#Examples', 'atomic_rev_sparse_jac.xml#Examples.Define rev_sparse_jac', 'atomic_rev_sparse_jac.xml#Examples.Use rev_sparse_jac' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_atomic_rev_sparse_hes_xml.js0000644000175200017650000000500012656322005021101 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_rev_sparse_hes.xml#Syntax', '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#Examples', 'atomic_rev_sparse_hes.xml#Examples.Define rev_sparse_hes', 'atomic_rev_sparse_hes.xml#Examples.Use 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]; } cppad-20160000.1/doc/atomic_get_started.cpp.xml0000644000175200017650000001766212656322005020345 0ustar coincoin-web 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
     )
     {    size_t n = tx.size() / (q + 1);
          size_t m = ty.size() / (q + 1);
          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 cppad-20160000.1/doc/_atomic_get_started.cpp_xml.js0000644000175200017650000000461612656322005021173 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_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]; } cppad-20160000.1/doc/_atomic_norm_sq.cpp_xml.js0000644000175200017650000000542212656322005020340 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_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]; } cppad-20160000.1/doc/_atomic_reciprocal.cpp_xml.js0000644000175200017650000000551312656322005021006 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_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]; } cppad-20160000.1/doc/_atomic_sparsity.cpp_xml.js0000644000175200017650000000516412656322005020543 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'ad.xml', 'advalued.xml', 'atomic.xml', 'atomic_base.xml', 'atomic_sparsity.cpp.xml' ]; var list_down3 = [ 'arithmetic.xml', 'unary_standard_math.xml', 'binary_math.xml', 'condexp.xml', 'discrete.xml', 'numeric_limits.xml', 'atomic.xml' ]; var list_down2 = [ 'checkpoint.xml', 'atomic_base.xml' ]; var list_down1 = [ 'atomic_ctor.xml', 'atomic_option.xml', 'atomic_afun.xml', 'atomic_forward.xml', 'atomic_reverse.xml', 'atomic_for_sparse_jac.xml', 'atomic_rev_sparse_jac.xml', 'atomic_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_sparsity.cpp.xml#function', 'atomic_sparsity.cpp.xml#pack_sparsity_enum', 'atomic_sparsity.cpp.xml#Start Class Definition', 'atomic_sparsity.cpp.xml#Constructor', 'atomic_sparsity.cpp.xml#forward', 'atomic_sparsity.cpp.xml#for_sparse_jac', 'atomic_sparsity.cpp.xml#rev_sparse_jac', 'atomic_sparsity.cpp.xml#rev_sparse_hes', 'atomic_sparsity.cpp.xml#End Class Definition', 'atomic_sparsity.cpp.xml#Use Atomic Function', 'atomic_sparsity.cpp.xml#Use Atomic Function.Constructor', 'atomic_sparsity.cpp.xml#Use Atomic Function.Recording', 'atomic_sparsity.cpp.xml#Use Atomic Function.forsparse_jac and rev_sparse_jac', 'atomic_sparsity.cpp.xml#Use Atomic Function.rev_sparse_hes' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_atomic_tangent.cpp_xml.js0000644000175200017650000000551712656322005020327 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_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]; } cppad-20160000.1/doc/_atomic_hes_sparse.cpp_xml.js0000644000175200017650000000450412656322005021016 0ustar coincoin-webvar 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_hes_sparse.cpp.xml' ]; var list_down3 = [ 'arithmetic.xml', 'unary_standard_math.xml', 'binary_math.xml', 'condexp.xml', 'discrete.xml', 'numeric_limits.xml', 'atomic.xml' ]; var list_down2 = [ 'checkpoint.xml', 'atomic_base.xml' ]; var list_down1 = [ 'atomic_ctor.xml', 'atomic_option.xml', 'atomic_afun.xml', 'atomic_forward.xml', 'atomic_reverse.xml', 'atomic_for_sparse_jac.xml', 'atomic_rev_sparse_jac.xml', 'atomic_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_current0 = [ 'atomic_hes_sparse.cpp.xml#Purpose', 'atomic_hes_sparse.cpp.xml#Start Class Definition', 'atomic_hes_sparse.cpp.xml#Constructor', 'atomic_hes_sparse.cpp.xml#forward', 'atomic_hes_sparse.cpp.xml#for_sparse_jac', 'atomic_hes_sparse.cpp.xml#rev_sparse_hes', 'atomic_hes_sparse.cpp.xml#Use Atomic Function', 'atomic_hes_sparse.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]; } cppad-20160000.1/doc/_atomic_mat_mul.cpp_xml.js0000644000175200017650000000503312656322005020316 0ustar coincoin-webvar 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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_down0 = [ 'atomic_matrix_mul.hpp.xml' ]; var list_current0 = [ '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]; } cppad-20160000.1/doc/_atomic_matrix_mul.hpp_xml.js0000644000175200017650000000475112656322005021054 0ustar coincoin-webvar 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_matrix_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_rev_sparse_hes.xml', 'atomic_base_clear.xml', 'atomic_get_started.cpp.xml', 'atomic_norm_sq.cpp.xml', 'atomic_reciprocal.cpp.xml', 'atomic_sparsity.cpp.xml', 'atomic_tangent.cpp.xml', 'atomic_hes_sparse.cpp.xml', 'atomic_mat_mul.cpp.xml' ]; var list_down1 = [ 'atomic_matrix_mul.hpp.xml' ]; var list_current0 = [ 'atomic_matrix_mul.hpp.xml#Start Class Definition', 'atomic_matrix_mul.hpp.xml#Constructor', 'atomic_matrix_mul.hpp.xml#Left Operand Element Index', 'atomic_matrix_mul.hpp.xml#Right Operand Element Index', 'atomic_matrix_mul.hpp.xml#Result Element Index', 'atomic_matrix_mul.hpp.xml#Forward Matrix Multipliy', 'atomic_matrix_mul.hpp.xml#Reverse Matrix Multipliy', 'atomic_matrix_mul.hpp.xml#forward', 'atomic_matrix_mul.hpp.xml#reverse', 'atomic_matrix_mul.hpp.xml#for_sparse_jac', 'atomic_matrix_mul.hpp.xml#rev_sparse_jac', 'atomic_matrix_mul.hpp.xml#rev_sparse_hes', 'atomic_matrix_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]; } cppad-20160000.1/doc/_compare.cpp_xml.js0000644000175200017650000000305612656322005016755 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_nearequalext_xml.js0000644000175200017650000000400512656322005017237 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/near_equal_ext.cpp.xml0000644000175200017650000000735612656322005017477 0ustar coincoin-web Compare AD with Base Objects: Example and Test
Prev Next near_equal_ext.cpp Headings

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/near_equal_ext.cpp cppad-20160000.1/doc/_near_equal_ext.cpp_xml.js0000644000175200017650000000310112656322005020312 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_vecad_xml.js0000644000175200017650000000366412656322005015635 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_bool_fun.cpp_xml.js0000644000175200017650000000306012656322005017125 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_parvar_xml.js0000644000175200017650000000357112656322005016043 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_par_var.cpp_xml.js0000644000175200017650000000305512656322005016760 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_equalopseq_xml.js0000644000175200017650000000364612656322005016732 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_equal_op_seq.cpp_xml.js0000644000175200017650000000307312656322005020003 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_vec_ad.cpp_xml.js0000644000175200017650000000316612656322005016552 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_base_require_xml.js0000644000175200017650000000375012656322005017215 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_base_member_xml.js0000644000175200017650000000414112656322005017003 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_base_cond_exp_xml.js0000644000175200017650000000401612656322005017334 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_base_identical_xml.js0000644000175200017650000000421212656322005017467 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_base_ordered_xml.js0000644000175200017650000000360612656322005017165 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_base_std_math_xml.js0000644000175200017650000000405112656322005017337 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_base_limits_xml.js0000644000175200017650000000357112656322005017043 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'ad.xml', 'base_require.xml', 'base_limits.xml' ]; var list_down3 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down2 = [ 'ad_ctor.xml', 'ad_assign.xml', 'convert.xml', 'advalued.xml', 'boolvalued.xml', 'vecad.xml', 'base_require.xml' ]; var list_down1 = [ 'base_member.xml', 'base_cond_exp.xml', 'base_identical.xml', 'base_ordered.xml', 'base_std_math.xml', 'base_limits.xml', 'base_to_string.xml', 'base_example.xml' ]; var list_current0 = [ 'base_limits.xml#CppAD::numeric_limits', 'base_limits.xml#CPPAD_NUMERIC_LIMITS' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_base_to_string_xml.js0000644000175200017650000000357012656322005017551 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'ad.xml', 'base_require.xml', 'base_to_string.xml' ]; var list_down3 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down2 = [ 'ad_ctor.xml', 'ad_assign.xml', 'convert.xml', 'advalued.xml', 'boolvalued.xml', 'vecad.xml', 'base_require.xml' ]; var list_down1 = [ 'base_member.xml', 'base_cond_exp.xml', 'base_identical.xml', 'base_ordered.xml', 'base_std_math.xml', 'base_limits.xml', 'base_to_string.xml', 'base_example.xml' ]; var list_current0 = [ 'base_to_string.xml#Base Requirement', 'base_to_string.xml#CPPAD_TO_STRING' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_base_example_xml.js0000644000175200017650000000374412656322005017177 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_base_alloc.hpp_xml.js0000644000175200017650000000471212656322005017420 0ustar coincoin-webvar 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_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#Computed 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' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_base_require.cpp_xml.js0000644000175200017650000000347212656322005017777 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_base_adolc.hpp_xml.js0000644000175200017650000000453412656322005017412 0ustar coincoin-webvar 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_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' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_mul_level_adolc.cpp_xml.js0000644000175200017650000000360312656322005020453 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_base_float.hpp_xml.js0000644000175200017650000000422612656322005017433 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_base_double.hpp_xml.js0000644000175200017650000000424312656322005017577 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_base_complex.hpp_xml.js0000644000175200017650000000451412656322005017775 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_complex_poly.cpp_xml.js0000644000175200017650000000336512656322005020044 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_adfun_xml.js0000644000175200017650000000260212656322005015637 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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]; } cppad-20160000.1/doc/_independent_xml.js0000644000175200017650000000347312656322005017046 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'independent.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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_independent.cpp_xml.js0000644000175200017650000000331512656322005017622 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'independent.xml', 'independent.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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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]; } cppad-20160000.1/doc/_funconstruct_xml.js0000644000175200017650000000422512656322005017302 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funconstruct.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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_fun_assign.cpp_xml.js0000644000175200017650000000331412656322005017460 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funconstruct.xml', 'fun_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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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]; } cppad-20160000.1/doc/_dependent_xml.js0000644000175200017650000000336112656322005016513 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'dependent.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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_abort_recording_xml.js0000644000175200017650000000322612656322005017710 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'abort_recording.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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_abort_recording.cpp_xml.js0000644000175200017650000000333112656322005020466 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'abort_recording.xml', 'abort_recording.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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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]; } cppad-20160000.1/doc/_seq_property_xml.js0000644000175200017650000000374712656322005017311 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'seq_property.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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_seq_property.cpp_xml.js0000644000175200017650000000332012656322005020055 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'seq_property.xml', 'seq_property.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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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]; } cppad-20160000.1/doc/_funeval_xml.js0000644000175200017650000000313312656322005016202 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down0 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_current0 = [ 'funeval.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]; } cppad-20160000.1/doc/_forward_xml.js0000644000175200017650000000371612656322005016215 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml' ]; var list_down3 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down2 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'forward.xml', 'reverse.xml', 'sparse.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_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_forward_zero_xml.js0000644000175200017650000000375612656322005017260 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'forward_zero.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_forward_one_xml.js0000644000175200017650000000371712656322005017057 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'forward_one.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_forward_two_xml.js0000644000175200017650000000377312656322005017111 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'forward_two.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_forward_order_xml.js0000644000175200017650000000512712656322005017406 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'forward_order.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_forward.cpp_xml.js0000644000175200017650000000316712656322005016776 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'forward_order.xml', 'forward.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.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]; } cppad-20160000.1/doc/_forward_order.cpp_xml.js0000644000175200017650000000317512656322006020171 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'forward_order.xml', 'forward_order.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.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]; } cppad-20160000.1/doc/_forward_dir_xml.js0000644000175200017650000000432412656322006017050 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'forward_dir.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ '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#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]; } cppad-20160000.1/doc/_forward_dir.cpp_xml.js0000644000175200017650000000314412656322006017630 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'forward_dir.xml', 'forward_dir.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.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]; } cppad-20160000.1/doc/_size_order_xml.js0000644000175200017650000000376312656322006016721 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'size_order.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_compare_change_xml.js0000644000175200017650000000416012656322006017477 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'compare_change.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_compare_change.cpp_xml.js0000644000175200017650000000315512656322006020263 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'compare_change.xml', 'compare_change.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.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]; } cppad-20160000.1/doc/_capacity_order_xml.js0000644000175200017650000000413712656322006017540 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'capacity_order.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_capacity_order.cpp_xml.js0000644000175200017650000000315512656322006020320 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'capacity_order.xml', 'capacity_order.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.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]; } cppad-20160000.1/doc/_number_skip_xml.js0000644000175200017650000000371512656322006017067 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'number_skip.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_number_skip.cpp_xml.js0000644000175200017650000000314412656322006017644 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'forward.xml', 'number_skip.xml', 'number_skip.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.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]; } cppad-20160000.1/doc/_reverse_xml.js0000644000175200017650000000356712656322006016231 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', '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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down0 = [ 'reverse_one.xml', 'reverse_two.xml', 'reverse_any.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_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_reverse_one_xml.js0000644000175200017650000000356512656322006017070 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'reverse.xml', 'reverse_one.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ 'reverse_one.xml', 'reverse_two.xml', 'reverse_any.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]; } cppad-20160000.1/doc/_reverse_one.cpp_xml.js0000644000175200017650000000275212656322006017646 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'reverse.xml', 'reverse_one.xml', 'reverse_one.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down2 = [ 'reverse_one.xml', 'reverse_two.xml', 'reverse_any.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]; } cppad-20160000.1/doc/_reverse_two_xml.js0000644000175200017650000000405112656322006017107 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'reverse.xml', 'reverse_two.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ 'reverse_one.xml', 'reverse_two.xml', 'reverse_any.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]; } cppad-20160000.1/doc/_reverse_two.cpp_xml.js0000644000175200017650000000300312656322006017664 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'reverse.xml', 'reverse_two.xml', 'reverse_two.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down2 = [ 'reverse_one.xml', 'reverse_two.xml', 'reverse_any.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]; } cppad-20160000.1/doc/_hes_times_dir.cpp_xml.js0000644000175200017650000000300512656322006020140 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'reverse.xml', 'reverse_two.xml', 'hes_times_dir.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down2 = [ 'reverse_one.xml', 'reverse_two.xml', 'reverse_any.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]; } cppad-20160000.1/doc/_reverse_any_xml.js0000644000175200017650000000422612656322006017071 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'reverse.xml', 'reverse_any.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ 'reverse_one.xml', 'reverse_two.xml', 'reverse_any.xml' ]; var list_down0 = [ 'reverse_three.cpp.xml', 'reverse_any.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]; } cppad-20160000.1/doc/_reverse_three.cpp_xml.js0000644000175200017650000000311212656322006020163 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'reverse.xml', 'reverse_any.xml', 'reverse_three.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down2 = [ 'reverse_one.xml', 'reverse_two.xml', 'reverse_any.xml' ]; var list_down1 = [ 'reverse_three.cpp.xml', 'reverse_any.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]; } cppad-20160000.1/doc/_reverse_any.cpp_xml.js0000644000175200017650000000314212656322006017646 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'reverse.xml', 'reverse_any.xml', 'reverse_any.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down2 = [ 'reverse_one.xml', 'reverse_two.xml', 'reverse_any.xml' ]; var list_down1 = [ 'reverse_three.cpp.xml', 'reverse_any.cpp.xml' ]; var list_current0 = [ 'reverse_any.cpp.xml#Purpose', 'reverse_any.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]; } cppad-20160000.1/doc/_sparse_xml.js0000644000175200017650000000360412656322006016043 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'sparse.xml' ]; var list_down3 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down2 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down0 = [ 'forsparsejac.xml', 'revsparsejac.xml', 'dependency.cpp.xml', 'revsparsehes.xml', 'bool_sparsity.cpp.xml' ]; var list_current0 = [ 'sparse.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]; } cppad-20160000.1/doc/_forsparsejac_xml.js0000644000175200017650000000443012656322006017226 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'sparse.xml', 'forsparsejac.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ 'forsparsejac.xml', 'revsparsejac.xml', 'dependency.cpp.xml', 'revsparsehes.xml', 'bool_sparsity.cpp.xml' ]; var list_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]; } cppad-20160000.1/doc/_for_sparse_jac.cpp_xml.js0000644000175200017650000000304212656322006020303 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'sparse.xml', 'forsparsejac.xml', 'for_sparse_jac.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down2 = [ 'forsparsejac.xml', 'revsparsejac.xml', 'dependency.cpp.xml', 'revsparsehes.xml', 'bool_sparsity.cpp.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_revsparsejac_xml.js0000644000175200017650000000431112656322006017232 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'sparse.xml', 'revsparsejac.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ 'forsparsejac.xml', 'revsparsejac.xml', 'dependency.cpp.xml', 'revsparsehes.xml', 'bool_sparsity.cpp.xml' ]; var list_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]; } cppad-20160000.1/doc/_rev_sparse_jac.cpp_xml.js0000644000175200017650000000304212656322006020311 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'sparse.xml', 'revsparsejac.xml', 'rev_sparse_jac.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down2 = [ 'forsparsejac.xml', 'revsparsejac.xml', 'dependency.cpp.xml', 'revsparsehes.xml', 'bool_sparsity.cpp.xml' ]; var list_down1 = [ 'rev_sparse_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]; } cppad-20160000.1/doc/_dependency.cpp_xml.js0000644000175200017650000000341012656322006017440 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'sparse.xml', 'dependency.cpp.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ 'forsparsejac.xml', 'revsparsejac.xml', 'dependency.cpp.xml', 'revsparsehes.xml', 'bool_sparsity.cpp.xml' ]; var list_current0 = [ 'dependency.cpp.xml#Discussion', 'dependency.cpp.xml#Dependency Pattern' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_revsparsehes_xml.js0000644000175200017650000000421512656322006017257 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'sparse.xml', 'revsparsehes.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ 'forsparsejac.xml', 'revsparsejac.xml', 'dependency.cpp.xml', 'revsparsehes.xml', 'bool_sparsity.cpp.xml' ]; var list_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]; } cppad-20160000.1/doc/_rev_sparse_hes.cpp_xml.js0000644000175200017650000000307212656322006020336 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'sparse.xml', 'revsparsehes.xml', 'rev_sparse_hes.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down2 = [ 'forsparsejac.xml', 'revsparsejac.xml', 'dependency.cpp.xml', 'revsparsehes.xml', 'bool_sparsity.cpp.xml' ]; var list_down1 = [ 'rev_sparse_hes.cpp.xml', 'sparsity_sub.cpp.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_sparsity_sub.cpp_xml.js0000644000175200017650000000327312656322006020060 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'sparse.xml', 'revsparsehes.xml', 'sparsity_sub.cpp.xml' ]; var list_down3 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down2 = [ 'forsparsejac.xml', 'revsparsejac.xml', 'dependency.cpp.xml', 'revsparsehes.xml', 'bool_sparsity.cpp.xml' ]; var list_down1 = [ 'rev_sparse_hes.cpp.xml', 'sparsity_sub.cpp.xml' ]; var list_current0 = [ 'sparsity_sub.cpp.xml#See Also', 'sparsity_sub.cpp.xml#ForSparseJac', 'sparsity_sub.cpp.xml#RevSparseHes' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_bool_sparsity.cpp_xml.js0000644000175200017650000000334212656322006020217 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'funeval.xml', 'sparse.xml', 'bool_sparsity.cpp.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'forward.xml', 'reverse.xml', 'sparse.xml' ]; var list_down1 = [ 'forsparsejac.xml', 'revsparsejac.xml', 'dependency.cpp.xml', 'revsparsehes.xml', 'bool_sparsity.cpp.xml' ]; var list_current0 = [ 'bool_sparsity.cpp.xml#Purpose' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_drivers_xml.js0000644000175200017650000000326312656322006016225 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down0 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.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]; } cppad-20160000.1/doc/_jacobian_xml.js0000644000175200017650000000405112656322006016311 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.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]; } cppad-20160000.1/doc/_jacobian.cpp_xml.js0000644000175200017650000000324712656322006017100 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_forone_xml.js0000644000175200017650000000404612656322006016037 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.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]; } cppad-20160000.1/doc/_for_one.cpp_xml.js0000644000175200017650000000324312656322006016755 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_revone_xml.js0000644000175200017650000000404612656322006016045 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.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]; } cppad-20160000.1/doc/_rev_one.cpp_xml.js0000644000175200017650000000324312656322006016763 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_hessian_xml.js0000644000175200017650000000413512656322006016200 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.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]; } cppad-20160000.1/doc/_hessian.cpp_xml.js0000644000175200017650000000327612656322006016766 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_hes_lagrangian.cpp_xml.js0000644000175200017650000000330512656322006020267 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_fortwo_xml.js0000644000175200017650000000412712656322006016067 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.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]; } cppad-20160000.1/doc/_for_two.cpp_xml.js0000644000175200017650000000324312656322006017005 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_revtwo_xml.js0000644000175200017650000000412712656322006016075 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.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]; } cppad-20160000.1/doc/_rev_two.cpp_xml.js0000644000175200017650000000324312656322006017013 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_sparse_jacobian_xml.js0000644000175200017650000000463112656322006017672 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'drivers.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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.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]; } cppad-20160000.1/doc/_sparse_jacobian.cpp_xml.js0000644000175200017650000000327412656322006020455 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'drivers.xml', 'sparse_jacobian.xml', 'sparse_jacobian.cpp.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.xml' ]; var list_down1 = [ 'sparse_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]; } cppad-20160000.1/doc/_sparse_hessian_xml.js0000644000175200017650000000476712656322006017570 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'drivers.xml', 'sparse_hessian.xml' ]; var list_down3 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down2 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.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#row, col', 'sparse_hessian.xml#hes', 'sparse_hessian.xml#work', 'sparse_hessian.xml#work.color_method', '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]; } cppad-20160000.1/doc/_sparse_hessian.cpp_xml.js0000644000175200017650000000335512656322006020341 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'drivers.xml', 'sparse_hessian.xml', 'sparse_hessian.cpp.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.xml' ]; var list_down1 = [ 'sparse_hessian.cpp.xml', 'sub_sparse_hes.cpp.xml', 'sparse_sub_hes.cpp.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_sub_sparse_hes.cpp_xml.js0000644000175200017650000000366012656322006020336 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'drivers.xml', 'sparse_hessian.xml', 'sub_sparse_hes.cpp.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.xml' ]; var list_down1 = [ 'sparse_hessian.cpp.xml', 'sub_sparse_hes.cpp.xml', 'sparse_sub_hes.cpp.xml' ]; var list_current0 = [ 'sub_sparse_hes.cpp.xml#Purpose', 'sub_sparse_hes.cpp.xml#See Also', 'sub_sparse_hes.cpp.xml#Function', 'sub_sparse_hes.cpp.xml#Subset', 'sub_sparse_hes.cpp.xml#Example' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_sparse_sub_hes.cpp_xml.js0000644000175200017650000000351212656322006020332 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'drivers.xml', 'sparse_hessian.xml', 'sparse_sub_hes.cpp.xml' ]; var list_down3 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down2 = [ 'jacobian.xml', 'forone.xml', 'revone.xml', 'hessian.xml', 'fortwo.xml', 'revtwo.xml', 'sparse_jacobian.xml', 'sparse_hessian.xml' ]; var list_down1 = [ 'sparse_hessian.cpp.xml', 'sub_sparse_hes.cpp.xml', 'sparse_sub_hes.cpp.xml' ]; var list_current0 = [ 'sparse_sub_hes.cpp.xml#Purpose', 'sparse_sub_hes.cpp.xml#See Also' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_funcheck_xml.js0000644000175200017650000000353712656322006016341 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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]; } cppad-20160000.1/doc/_fun_check.cpp_xml.js0000644000175200017650000000330612656322006017253 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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]; } cppad-20160000.1/doc/_optimize_xml.js0000644000175200017650000000357612656322006016416 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down0 = [ 'optimize.cpp.xml' ]; var list_current0 = [ 'optimize.xml#Syntax', 'optimize.xml#Purpose', 'optimize.xml#f', 'optimize.xml#Improvements', 'optimize.xml#Improvements.Testing', 'optimize.xml#Efficiency', 'optimize.xml#Atomic Functions', 'optimize.xml#Atomic Functions.rev_sparse_jac', 'optimize.xml#Atomic Functions.nan', 'optimize.xml#Checking Optimization', 'optimize.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]; } cppad-20160000.1/doc/_optimize.cpp_xml.js0000644000175200017650000000330412656322006017164 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'adfun.xml', 'optimize.xml', 'optimize.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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_down1 = [ 'optimize.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]; } cppad-20160000.1/doc/_check_for_nan_xml.js0000644000175200017650000000377712656322006017340 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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]; } cppad-20160000.1/doc/_check_for_nan.cpp_xml.js0000644000175200017650000000332312656322006020104 0ustar coincoin-webvar 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 = [ 'independent.xml', 'funconstruct.xml', 'dependent.xml', 'abort_recording.xml', 'seq_property.xml', 'funeval.xml', 'drivers.xml', 'funcheck.xml', 'optimize.xml', 'check_for_nan.xml' ]; var list_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]; } cppad-20160000.1/doc/_preprocessor_xml.js0000644000175200017650000000270012656322006017270 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_multi_thread_xml.js0000644000175200017650000000300312656322006017220 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_parallel_ad_xml.js0000644000175200017650000000306312656322006017005 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_thread_test.cpp_xml.js0000644000175200017650000000463712656322006017644 0ustar coincoin-webvar 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_newton.cpp.xml', 'team_thread.hpp.xml' ]; var list_current0 = [ 'thread_test.cpp.xml#Syntax', 'thread_test.cpp.xml#Running Tests', 'thread_test.cpp.xml#Running Tests.threading', 'thread_test.cpp.xml#Purpose', '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]; } cppad-20160000.1/doc/_a11c_openmp.cpp_xml.js0000644000175200017650000000360712656322006017435 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_a11c_bthread.cpp_xml.js0000644000175200017650000000361212656322006017544 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_a11c_pthread.cpp_xml.js0000644000175200017650000000361212656322006017562 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/simple_ad_openmp.cpp.xml0000644000175200017650000002053112656322006020005 0ustar coincoin-web 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: multi_thread/openmp/simple_ad_openmp.cpp cppad-20160000.1/doc/_simple_ad_openmp.cpp_xml.js0000644000175200017650000000362612656322006020646 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_simple_ad_bthread.cpp_xml.js0000644000175200017650000000363112656322006020755 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_simple_ad_pthread.cpp_xml.js0000644000175200017650000000363112656322006020773 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_harmonic.cpp_xml.js0000644000175200017650000000414512656322006017130 0ustar coincoin-webvar 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_newton.cpp.xml', 'team_thread.hpp.xml' ]; var list_down0 = [ 'harmonic_time.cpp.xml', 'harmonic_work.cpp.xml' ]; var list_current0 = [ 'harmonic.cpp.xml#Syntax', 'harmonic.cpp.xml#Summation', 'harmonic.cpp.xml#ok', 'harmonic.cpp.xml#sum', 'harmonic.cpp.xml#num_sum', 'harmonic.cpp.xml#num_threads', 'harmonic.cpp.xml#Contents', 'harmonic.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]; } cppad-20160000.1/doc/_harmonic_time.cpp_xml.js0000644000175200017650000000374612656322006020154 0ustar coincoin-webvar 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.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_newton.cpp.xml', 'team_thread.hpp.xml' ]; var list_down1 = [ 'harmonic_time.cpp.xml', 'harmonic_work.cpp.xml' ]; var list_current0 = [ 'harmonic_time.cpp.xml#Syntax', 'harmonic_time.cpp.xml#Purpose', 'harmonic_time.cpp.xml#ok', 'harmonic_time.cpp.xml#time_out', 'harmonic_time.cpp.xml#test_time', 'harmonic_time.cpp.xml#num_threads', 'harmonic_time.cpp.xml#mega_sum', 'harmonic_time.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]; } cppad-20160000.1/doc/_harmonic_work.cpp_xml.js0000644000175200017650000000403512656322006020170 0ustar coincoin-webvar 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_work.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_newton.cpp.xml', 'team_thread.hpp.xml' ]; var list_down1 = [ 'harmonic_time.cpp.xml', 'harmonic_work.cpp.xml' ]; var list_current0 = [ 'harmonic_work.cpp.xml#Syntax', 'harmonic_work.cpp.xml#Purpose', 'harmonic_work.cpp.xml#harmonic_setup', 'harmonic_work.cpp.xml#harmonic_setup.num_sum', 'harmonic_work.cpp.xml#harmonic_setup.num_threads', 'harmonic_work.cpp.xml#harmonic_worker', 'harmonic_work.cpp.xml#harmonic_combine', 'harmonic_work.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]; } cppad-20160000.1/doc/_multi_newton.cpp_xml.js0000644000175200017650000000450412656322006020053 0ustar coincoin-webvar 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_newton.cpp.xml', 'team_thread.hpp.xml' ]; var list_down0 = [ 'multi_newton_time.cpp.xml', 'multi_newton_work.cpp.xml' ]; var list_current0 = [ 'multi_newton.cpp.xml#Syntax', 'multi_newton.cpp.xml#Purpose', 'multi_newton.cpp.xml#Method', 'multi_newton.cpp.xml#ok', 'multi_newton.cpp.xml#xout', 'multi_newton.cpp.xml#fun', 'multi_newton.cpp.xml#num_sub', 'multi_newton.cpp.xml#xlow', 'multi_newton.cpp.xml#xup', 'multi_newton.cpp.xml#epsilon', 'multi_newton.cpp.xml#max_itr', 'multi_newton.cpp.xml#num_threads', 'multi_newton.cpp.xml#Contents', 'multi_newton.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]; } cppad-20160000.1/doc/multi_newton_time.cpp.xml0000644000175200017650000004117212656322006020240 0ustar coincoin-web Timing Test of Multi-Threaded Newton Method
Prev Next multi_newton_time.cpp

.
Timing Test of Multi-Threaded Newton Method

Syntax
ok = multi_newton_time(time_outnum_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.

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 == CppAD::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 == CppAD::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 zero and should probably be greater than two times num_zero .

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
 
# include <cppad/cppad.hpp>
# include <cppad/utility/time_test.hpp>
# include <cmath>
# include <cstring>
# include "multi_newton.hpp"

namespace { // empty namespace

	// values correspond to arguments in previous call to multi_newton_time
	size_t num_threads_;// value passed to multi_newton_time
	size_t num_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
	CppAD::vector<double> xout_;

	// either fun_ad or fun_no depending on value of use_ad
	void (*fun_)(double x, double& f, double& df) = 0;

	// 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)
	{	// use CppAD::vector because it uses fast multi-threaded memory alloc
		using CppAD::vector;
		using CppAD::AD;
		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     = (num_zero_ - 1) * pi;
		double eps     =
			xup * 100. * CppAD::numeric_limits<double>::epsilon();
		size_t max_itr = 20;

		bool ok = multi_newton(
			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

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;
	using CppAD::thread_alloc;

	// Set local namespace environment variables
	num_threads_  = num_threads;
	num_zero_     = num_zero;
	num_sub_      = num_sub;
	num_sum_      = num_sum;
	if( use_ad )
		fun_ = fun_ad;
	else	fun_ = fun_no;

	// expect number of threads to already be set up
	if( num_threads > 0 )
		ok &= num_threads == CppAD::thread_alloc::num_threads();
	else	ok &= 1           == CppAD::thread_alloc::num_threads();

	// run the test case and set time return value
	time_out = CppAD::time_test(test_repeat, test_time);

	// Call test_once for a correctness check
	double pi      = 4. * std::atan(1.);
	double xup     = (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 < num_zero; i++)
		ok &= std::fabs( xout_[i] - pi * 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: multi_thread/multi_newton_time.cpp cppad-20160000.1/doc/_multi_newton_time.cpp_xml.js0000644000175200017650000000420412656322006021066 0ustar coincoin-webvar 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.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_newton.cpp.xml', 'team_thread.hpp.xml' ]; var list_down1 = [ 'multi_newton_time.cpp.xml', 'multi_newton_work.cpp.xml' ]; var list_current0 = [ 'multi_newton_time.cpp.xml#Syntax', 'multi_newton_time.cpp.xml#Purpose', 'multi_newton_time.cpp.xml#ok', 'multi_newton_time.cpp.xml#time_out', 'multi_newton_time.cpp.xml#test_time', 'multi_newton_time.cpp.xml#num_threads', 'multi_newton_time.cpp.xml#num_zero', 'multi_newton_time.cpp.xml#num_sub', 'multi_newton_time.cpp.xml#num_sum', 'multi_newton_time.cpp.xml#use_ad', 'multi_newton_time.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]; } cppad-20160000.1/doc/_multi_newton_work.cpp_xml.js0000644000175200017650000000453012656322006021114 0ustar coincoin-webvar 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_work.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_newton.cpp.xml', 'team_thread.hpp.xml' ]; var list_down1 = [ 'multi_newton_time.cpp.xml', 'multi_newton_work.cpp.xml' ]; var list_current0 = [ 'multi_newton_work.cpp.xml#Syntax', 'multi_newton_work.cpp.xml#Purpose', 'multi_newton_work.cpp.xml#multi_newton_setup', 'multi_newton_work.cpp.xml#multi_newton_setup.fun', 'multi_newton_work.cpp.xml#multi_newton_setup.num_sub', 'multi_newton_work.cpp.xml#xlow', 'multi_newton_work.cpp.xml#xlow.xup', 'multi_newton_work.cpp.xml#xlow.epsilon', 'multi_newton_work.cpp.xml#max_itr', 'multi_newton_work.cpp.xml#max_itr.num_threads', 'multi_newton_work.cpp.xml#multi_newton_worker', 'multi_newton_work.cpp.xml#multi_newton_combine', 'multi_newton_work.cpp.xml#multi_newton_combine.xout', 'multi_newton_work.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]; } cppad-20160000.1/doc/_poly_xml.js0000644000175200017650000000406012656322006015526 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_team_openmp.cpp_xml.js0000644000175200017650000000333312656322006017632 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_team_bthread.cpp_xml.js0000644000175200017650000000333412656322006017746 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_team_pthread.cpp_xml.js0000644000175200017650000000343212656322006017763 0ustar coincoin-webvar 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_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]; } cppad-20160000.1/doc/_utility_xml.js0000644000175200017650000000371012656322006016247 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'utility.xml' ]; var list_down1 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down0 = [ 'errorhandler.xml', 'nearequal.xml', 'speed_test.xml', 'speedtest.xml', 'time_test.xml', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_current0 = [ 'utility.xml#Testing', 'utility.xml#C++ Concepts', 'utility.xml#General Numerical Routines', 'utility.xml#Miscellaneous', 'utility.xml#Miscellaneous.Error Handler', 'utility.xml#Miscellaneous.Simple Vector Template Class', 'utility.xml#Miscellaneous.Multi-Threading Memory Allocation', 'utility.xml#Miscellaneous.Sorting Indices', 'utility.xml#Miscellaneous.to_string' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_errorhandler_xml.js0000644000175200017650000000422712656322006017237 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_error_handler.cpp_xml.js0000644000175200017650000000374512656322006020163 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_cppad_assert_xml.js0000644000175200017650000000436212656322006017220 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_nearequal_xml.js0000644000175200017650000000404612656322006016524 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_near_equal.cpp_xml.js0000644000175200017650000000400012656322006017432 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_speed_test_xml.js0000644000175200017650000000420712656322006016705 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_speed_test.cpp_xml.js0000644000175200017650000000371112656322006017465 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_speedtest_xml.js0000644000175200017650000000421112656322006016541 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/speed_program.cpp.xml0000644000175200017650000001163212656322006017323 0ustar coincoin-web 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 cppad-20160000.1/doc/_speed_program.cpp_xml.js0000644000175200017650000000412512656322006020155 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_time_test_xml.js0000644000175200017650000000416412656322006016545 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_elapsed_seconds_xml.js0000644000175200017650000000430512656322006017700 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_elapsed_seconds.cpp_xml.js0000644000175200017650000000354512656322006020466 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_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]; } cppad-20160000.1/doc/_time_test.cpp_xml.js0000644000175200017650000000373512656322006017331 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_numerictype_xml.js0000644000175200017650000000410012656322006017102 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_numeric_type.cpp_xml.js0000644000175200017650000000371612656322006020036 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_checknumerictype_xml.js0000644000175200017650000000374212656322006020113 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_check_numeric_type.cpp_xml.js0000644000175200017650000000373712656322006021176 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_simplevector_xml.js0000644000175200017650000000455112656322006017264 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_simple_vector.cpp_xml.js0000644000175200017650000000372112656322006020202 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_checksimplevector_xml.js0000644000175200017650000000405512656322006020261 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_check_simple_vector.cpp_xml.js0000644000175200017650000000374212656322006021342 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_nan.cpp_xml.js0000644000175200017650000000366412656322006016111 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_pow_int_xml.js0000644000175200017650000000400512656322006016221 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_pow_int.cpp_xml.js0000644000175200017650000000370012656322006017003 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_poly.cpp_xml.js0000644000175200017650000000370712656322006016316 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_poly.hpp_xml.js0000644000175200017650000000370712656322006016323 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ludetandsolve_xml.js0000644000175200017650000000355112656322006017420 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_lusolve_xml.js0000644000175200017650000000470612656322006016243 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_lu_solve.cpp_xml.js0000644000175200017650000000355212656322006017161 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_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]; } cppad-20160000.1/doc/_lu_solve.hpp_xml.js0000644000175200017650000000355212656322006017166 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_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]; } cppad-20160000.1/doc/_lufactor_xml.js0000644000175200017650000000501612656322006016364 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_lu_factor.cpp_xml.js0000644000175200017650000000355612656322006017313 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_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]; } cppad-20160000.1/doc/_lu_factor.hpp_xml.js0000644000175200017650000000355612656322006017320 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_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]; } cppad-20160000.1/doc/_luinvert_xml.js0000644000175200017650000000455612656322006016425 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_lu_invert.cpp_xml.js0000644000175200017650000000355612656322006017344 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_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]; } cppad-20160000.1/doc/_lu_invert.hpp_xml.js0000644000175200017650000000355612656322006017351 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_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]; } cppad-20160000.1/doc/_rombergone_xml.js0000644000175200017650000000413512656322006016705 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_romberg_one.cpp_xml.js0000644000175200017650000000371312656322006017626 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_rombergmul_xml.js0000644000175200017650000000421612656322006016721 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_rombergmul.cpp_xml.js0000644000175200017650000000371112656322006017501 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_runge45_xml.js0000644000175200017650000000442312656322006016037 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_runge45_1.cpp_xml.js0000644000175200017650000000373112656322006017041 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_runge45_2.cpp_xml.js0000644000175200017650000000373112656322006017042 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_rosen34_xml.js0000644000175200017650000000445112656322006016044 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_rosen_34.cpp_xml.js0000644000175200017650000000370212656322006016762 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_odeerrcontrol_xml.js0000644000175200017650000000507212656322006017430 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_ode_err_control.cpp_xml.js0000644000175200017650000000404712656322006020510 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ode_err_maxabs.cpp_xml.js0000644000175200017650000000375712656322006020312 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_odegear_xml.js0000644000175200017650000000433112656322006016152 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_ode_gear.cpp_xml.js0000644000175200017650000000370212656322006017073 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_odegearcontrol_xml.js0000644000175200017650000000517312656322006017560 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_ode_gear_control.cpp_xml.js0000644000175200017650000000373112656322006020635 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_cppad_vector_xml.js0000644000175200017650000000517412656322007017224 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_cppad_vector.cpp_xml.js0000644000175200017650000000374612656322007020010 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_vector_bool.cpp_xml.js0000644000175200017650000000374512656322007017653 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_thread_alloc_xml.js0000644000175200017650000000427612656322007017176 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_thread_alloc.cpp_xml.js0000644000175200017650000000435212656322007017752 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_parallel_setup_xml.js0000644000175200017650000000503012656322007020242 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_num_threads_xml.js0000644000175200017650000000456612656322007017554 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_in_parallel_xml.js0000644000175200017650000000456412656322007017523 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_thread_num_xml.js0000644000175200017650000000456112656322007017364 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_get_memory_xml.js0000644000175200017650000000476312656322007017411 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_return_memory_xml.js0000644000175200017650000000467512656322007020153 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_free_available_xml.js0000644000175200017650000000466312656322007020162 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_hold_memory_xml.js0000644000175200017650000000457412656322007017560 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_inuse_xml.js0000644000175200017650000000456212656322007016362 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_available_xml.js0000644000175200017650000000461212656322007017153 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_create_array_xml.js0000644000175200017650000000502412656322007017672 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_delete_array_xml.js0000644000175200017650000000472112656322007017674 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ta_free_all_xml.js0000644000175200017650000000460312656322007017004 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_index_sort_xml.js0000644000175200017650000000371012656322007016723 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_index_sort.cpp_xml.js0000644000175200017650000000371112656322007017505 0ustar coincoin-webvar 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', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_to_string_xml.js0000644000175200017650000000405312656322007016556 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'utility.xml', 'to_string.xml' ]; var list_down2 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down1 = [ 'errorhandler.xml', 'nearequal.xml', 'speed_test.xml', 'speedtest.xml', 'time_test.xml', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down0 = [ 'to_string.cpp.xml' ]; var list_current0 = [ 'to_string.xml#Syntax', 'to_string.xml#See Also', 'to_string.xml#Purpose', 'to_string.xml#value', 'to_string.xml#value.Integer', 'to_string.xml#value.Float', 'to_string.xml#s', 'to_string.xml#s.Integer', 'to_string.xml#s.Float', 'to_string.xml#Example' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_to_string.cpp_xml.js0000644000175200017650000000370612656322007017343 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'utility.xml', 'to_string.xml', 'to_string.cpp.xml' ]; var list_down3 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down2 = [ 'errorhandler.xml', 'nearequal.xml', 'speed_test.xml', 'speedtest.xml', 'time_test.xml', 'numerictype.xml', 'checknumerictype.xml', 'simplevector.xml', 'checksimplevector.xml', 'nan.xml', 'pow_int.xml', 'poly.xml', 'ludetandsolve.xml', 'rombergone.xml', 'rombergmul.xml', 'runge45.xml', 'rosen34.xml', 'odeerrcontrol.xml', 'odegear.xml', 'odegearcontrol.xml', 'cppad_vector.xml', 'thread_alloc.xml', 'index_sort.xml', 'to_string.xml' ]; var list_down1 = [ 'to_string.cpp.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_ipopt_solve_xml.js0000644000175200017650000000432212656322007017110 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/ipopt_solve_get_started.cpp.xml0000644000175200017650000002143412656322007021426 0ustar coincoin-web 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 cppad-20160000.1/doc/_ipopt_solve_get_started.cpp_xml.js0000644000175200017650000000306212656322007022256 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/ipopt_solve_ode_inverse.cpp.xml0000644000175200017650000011277512656322007021434 0ustar coincoin-web 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 cppad-20160000.1/doc/_ipopt_solve_ode_inverse.cpp_xml.js0000644000175200017650000000401312656322007022250 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/ad_fun.cpp.xml0000644000175200017650000001411412656322007015727 0ustar coincoin-web Creating Your Own Interface to an ADFun Object
Prev Next ad_fun.cpp Headings

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;
	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], 1e-10, 1e-10 );
	ok &=  NearEqual( 2.*x[0]*sin(x[1]), jac[1*n+0], 1e-10, 1e-10 );
	ok &=  NearEqual( 2.*x[0]*cos(x[1]), jac[2*n+0], 1e-10, 1e-10 );

	ok &=  NearEqual( x[0] * x[0] *exp(x[1]), jac[0*n+1], 1e-10, 1e-10 );
	ok &=  NearEqual( x[0] * x[0] *cos(x[1]), jac[1*n+1], 1e-10, 1e-10 );
	ok &=  NearEqual(-x[0] * x[0] *sin(x[1]), jac[2*n+1], 1e-10, 1e-10 );

	return ok;
}



Input File: example/ad_fun.cpp cppad-20160000.1/doc/_ad_fun.cpp_xml.js0000644000175200017650000000363212656322007016565 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_ad_in_c.cpp_xml.js0000644000175200017650000000363312656322007016706 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_conj_grad.cpp_xml.js0000644000175200017650000000376112656322007017262 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_cppad_eigen.hpp_xml.js0000644000175200017650000000433712656322007017577 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_eigen_plugin.hpp_xml.js0000644000175200017650000000351312656322007020001 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_down2 = [ 'ad_fun.cpp.xml', 'ad_in_c.cpp.xml', 'conj_grad.cpp.xml', 'cppad_eigen.hpp.xml', 'hes_minor_det.cpp.xml', 'hes_lu_det.cpp.xml', 'interface2c.cpp.xml', 'jac_minor_det.cpp.xml', 'jac_lu_det.cpp.xml', 'mul_level.xml', 'ode_stiff.cpp.xml', 'mul_level_ode.cpp.xml', 'mul_level_adolc_ode.cpp.xml', 'ode_taylor.cpp.xml', 'stack_machine.cpp.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_eigen_array.cpp_xml.js0000644000175200017650000000351212656322007017613 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_down2 = [ 'ad_fun.cpp.xml', 'ad_in_c.cpp.xml', 'conj_grad.cpp.xml', 'cppad_eigen.hpp.xml', 'hes_minor_det.cpp.xml', 'hes_lu_det.cpp.xml', 'interface2c.cpp.xml', 'jac_minor_det.cpp.xml', 'jac_lu_det.cpp.xml', 'mul_level.xml', 'ode_stiff.cpp.xml', 'mul_level_ode.cpp.xml', 'mul_level_adolc_ode.cpp.xml', 'ode_taylor.cpp.xml', 'stack_machine.cpp.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_eigen_det.cpp_xml.js0000644000175200017650000000351012656322007017247 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_down2 = [ 'ad_fun.cpp.xml', 'ad_in_c.cpp.xml', 'conj_grad.cpp.xml', 'cppad_eigen.hpp.xml', 'hes_minor_det.cpp.xml', 'hes_lu_det.cpp.xml', 'interface2c.cpp.xml', 'jac_minor_det.cpp.xml', 'jac_lu_det.cpp.xml', 'mul_level.xml', 'ode_stiff.cpp.xml', 'mul_level_ode.cpp.xml', 'mul_level_adolc_ode.cpp.xml', 'ode_taylor.cpp.xml', 'stack_machine.cpp.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_hes_minor_det.cpp_xml.js0000644000175200017650000000364112656322007020150 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_hes_lu_det.cpp_xml.js0000644000175200017650000000363612656322007017450 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_interface2c.cpp_xml.js0000644000175200017650000000363712656322007017523 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_jac_minor_det.cpp_xml.js0000644000175200017650000000364112656322007020126 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_jac_lu_det.cpp_xml.js0000644000175200017650000000363612656322007017426 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_mul_level_xml.js0000644000175200017650000000466112656322007016537 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_mul_level.cpp_xml.js0000644000175200017650000000357412656322007017322 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_down2 = [ 'ad_fun.cpp.xml', 'ad_in_c.cpp.xml', 'conj_grad.cpp.xml', 'cppad_eigen.hpp.xml', 'hes_minor_det.cpp.xml', 'hes_lu_det.cpp.xml', 'interface2c.cpp.xml', 'jac_minor_det.cpp.xml', 'jac_lu_det.cpp.xml', 'mul_level.xml', 'ode_stiff.cpp.xml', 'mul_level_ode.cpp.xml', 'mul_level_adolc_ode.cpp.xml', 'ode_taylor.cpp.xml', 'stack_machine.cpp.xml' ]; var list_down1 = [ 'mul_level.cpp.xml', 'change_param.cpp.xml' ]; var list_current0 = [ '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]; } cppad-20160000.1/doc/_change_param.cpp_xml.js0000644000175200017650000000354612656322007017742 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'example.xml', 'general.xml', 'mul_level.xml', 'change_param.cpp.xml' ]; var list_down3 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_down2 = [ 'ad_fun.cpp.xml', 'ad_in_c.cpp.xml', 'conj_grad.cpp.xml', 'cppad_eigen.hpp.xml', 'hes_minor_det.cpp.xml', 'hes_lu_det.cpp.xml', 'interface2c.cpp.xml', 'jac_minor_det.cpp.xml', 'jac_lu_det.cpp.xml', 'mul_level.xml', 'ode_stiff.cpp.xml', 'mul_level_ode.cpp.xml', 'mul_level_adolc_ode.cpp.xml', 'ode_taylor.cpp.xml', 'stack_machine.cpp.xml' ]; var list_down1 = [ 'mul_level.cpp.xml', 'change_param.cpp.xml' ]; var list_current0 = [ 'change_param.cpp.xml#Purpose' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_ode_stiff.cpp_xml.js0000644000175200017650000000363512656322007017276 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_mul_level_ode.cpp_xml.js0000644000175200017650000000424412656322007020144 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/mul_level_adolc_ode.cpp.xml0000644000175200017650000010142312656322007020450 0ustar coincoin-web 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
 
# 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 lenght n (or greater) in double
	double* x = thread_alloc::create_array<double>(n, capacity);

	// the vector x with lenght 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/mul_level_adolc_ode.cpp cppad-20160000.1/doc/_mul_level_adolc_ode.cpp_xml.js0000644000175200017650000000454612656322007021313 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_stack_machine.cpp_xml.js0000644000175200017650000000364112656322007020122 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_exampleutility_xml.js0000644000175200017650000000303012656322007017617 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_down0 = [ 'example.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]; } cppad-20160000.1/doc/_example.cpp_xml.js0000644000175200017650000000331112656322007016756 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'example.xml', 'exampleutility.xml', '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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_down1 = [ 'example.cpp.xml', 'speed_example.cpp.xml', 'lu_vec_ad.cpp.xml' ]; var list_current0 = [ '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]; } cppad-20160000.1/doc/_speed_example.cpp_xml.js0000644000175200017650000000332512656322007020143 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_down1 = [ 'example.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]; } cppad-20160000.1/doc/_lu_vec_ad.cpp_xml.js0000644000175200017650000000376012656322007017254 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_down1 = [ 'example.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]; } cppad-20160000.1/doc/_lu_vec_ad_ok.cpp_xml.js0000644000175200017650000000302212656322007017734 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_down2 = [ 'example.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]; } cppad-20160000.1/doc/_listallexamples_xml.js0000644000175200017650000000261412656322007017752 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.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]; } cppad-20160000.1/doc/_testvector_xml.js0000644000175200017650000000314512656322007016751 0ustar coincoin-webvar 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 = [ 'general.xml', 'exampleutility.xml', 'listallexamples.xml', 'testvector.xml' ]; var list_current0 = [ 'testvector.xml#Syntax', 'testvector.xml#Introduction', '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]; } cppad-20160000.1/doc/_speed_main_xml.js0000644000175200017650000000457212656322007016660 0ustar coincoin-webvar 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#option_list', 'speed_main.xml#option_list.onetape', 'speed_main.xml#option_list.optimize', 'speed_main.xml#option_list.atomic', 'speed_main.xml#option_list.memory', 'speed_main.xml#Sparsity Options', 'speed_main.xml#Sparsity Options.boolsparsity', '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]; } cppad-20160000.1/doc/_link_det_lu_xml.js0000644000175200017650000000410512656322007017035 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_link_det_minor_xml.js0000644000175200017650000000414312656322007017543 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_link_mat_mul_xml.js0000644000175200017650000000403012656322007017214 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_link_ode_xml.js0000644000175200017650000000406412656322007016334 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_link_poly_xml.js0000644000175200017650000000406512656322007016551 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/link_sparse_hessian.xml0000644000175200017650000004620112656322007017740 0ustar coincoin-web 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] )

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 cppad-20160000.1/doc/_link_sparse_hessian_xml.js0000644000175200017650000000424412656322007020574 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_link_sparse_jacobian_xml.js0000644000175200017650000000431612656322007020710 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_speed_utility_xml.js0000644000175200017650000000351112656322007017427 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_by_lu_xml.js0000644000175200017650000000424612656322007016520 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_by_lu.cpp_xml.js0000644000175200017650000000332212656322007017273 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_by_lu.hpp_xml.js0000644000175200017650000000332212656322007017300 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_of_minor_xml.js0000644000175200017650000000437012656322007017214 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_of_minor.cpp_xml.js0000644000175200017650000000333612656322007017776 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_of_minor.hpp_xml.js0000644000175200017650000000333612656322007020003 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_by_minor_xml.js0000644000175200017650000000432012656322007017215 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_by_minor.cpp_xml.js0000644000175200017650000000333612656322007020004 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_by_minor.hpp_xml.js0000644000175200017650000000333612656322007020011 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_33_xml.js0000644000175200017650000000404212656322007015625 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_33.hpp_xml.js0000644000175200017650000000326412656322007016420 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_grad_33_xml.js0000644000175200017650000000412412656322007016623 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_det_grad_33.hpp_xml.js0000644000175200017650000000330312656322007017407 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_mat_sum_sq_xml.js0000644000175200017650000000421512656322007016716 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_mat_sum_sq.cpp_xml.js0000644000175200017650000000332612656322007017501 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_mat_sum_sq.hpp_xml.js0000644000175200017650000000332612656322007017506 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ode_evaluate_xml.js0000644000175200017650000000452612656322007017210 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ode_evaluate.cpp_xml.js0000644000175200017650000000333612656322007017767 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ode_evaluate.hpp_xml.js0000644000175200017650000000333612656322007017774 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sparse_jac_fun_xml.js0000644000175200017650000000456312656322007017536 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/sparse_jac_fun.cpp.xml0000644000175200017650000000766112656322007017466 0ustar coincoin-web sparse_jac_fun: Example and test
Prev Next sparse_jac_fun.cpp Headings

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 cppad-20160000.1/doc/_sparse_jac_fun.cpp_xml.js0000644000175200017650000000334612656322007020315 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sparse_jac_fun.hpp_xml.js0000644000175200017650000000334612656322007020322 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/sparse_hes_fun.cpp.xml0000644000175200017650000001002312656322007017472 0ustar coincoin-web sparse_hes_fun: Example and test
Prev Next sparse_hes_fun.cpp Headings

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 cppad-20160000.1/doc/_sparse_hes_fun.cpp_xml.js0000644000175200017650000000334612656322007020337 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sparse_hes_fun.hpp_xml.js0000644000175200017650000000334612656322007020344 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_uniform_01.hpp_xml.js0000644000175200017650000000330012656322007017305 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_speed_double_xml.js0000644000175200017650000000341112656322007017175 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_double_det_minor.cpp_xml.js0000644000175200017650000000367412656322007020651 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_double_det_lu.cpp_xml.js0000644000175200017650000000366312656322007020143 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_double_mat_mul.cpp_xml.js0000644000175200017650000000366612656322007020330 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_double_ode.cpp_xml.js0000644000175200017650000000365212656322007017434 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_double_poly.cpp_xml.js0000644000175200017650000000365512656322007017653 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_double_sparse_hessian.cpp_xml.js0000644000175200017650000000371312656322007021672 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/double_sparse_jacobian.cpp.xml0000644000175200017650000001116112656322007021147 0ustar coincoin-web 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_memory at the main program level
extern bool
     global_onetape, global_atomic, global_optimize, global_boolsparsity;

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_onetape||global_atomic||global_optimize||global_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 cppad-20160000.1/doc/_double_sparse_jacobian.cpp_xml.js0000644000175200017650000000371612656322007022011 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_adolc_det_minor.cpp_xml.js0000644000175200017650000000371012656322007020450 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_adolc_det_lu.cpp_xml.js0000644000175200017650000000367712656322007017760 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_adolc_mat_mul.cpp_xml.js0000644000175200017650000000370212656322007020127 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_adolc_ode.cpp_xml.js0000644000175200017650000000366612656322007017251 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_adolc_poly.cpp_xml.js0000644000175200017650000000367112656322007017461 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_adolc_sparse_hessian.cpp_xml.js0000644000175200017650000000372712656322007021507 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_adolc_sparse_jacobian.cpp_xml.js0000644000175200017650000000373212656322007021617 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_adolc_alloc_mat_xml.js0000644000175200017650000000377212656322007017652 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_speed_cppad_xml.js0000644000175200017650000000337612656322007017024 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_cppad_det_minor.cpp_xml.js0000644000175200017650000000366112656322007020462 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_cppad_det_lu.cpp_xml.js0000644000175200017650000000365012656322007017754 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_cppad_mat_mul.cpp_xml.js0000644000175200017650000000365312656322007020141 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_cppad_ode.cpp_xml.js0000644000175200017650000000363712656322007017254 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_cppad_poly.cpp_xml.js0000644000175200017650000000364212656322007017464 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_cppad_sparse_hessian.cpp_xml.js0000644000175200017650000000370012656322007021503 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_cppad_sparse_jacobian.cpp_xml.js0000644000175200017650000000370312656322007021622 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_speed_fadbad_xml.js0000644000175200017650000000345312656322007017132 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_fadbad_det_minor.cpp_xml.js0000644000175200017650000000367412656322007020600 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_fadbad_det_lu.cpp_xml.js0000644000175200017650000000366312656322007020072 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_fadbad_mat_mul.cpp_xml.js0000644000175200017650000000366612656322007020257 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_fadbad_ode.cpp_xml.js0000644000175200017650000000365212656322007017363 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_fadbad_poly.cpp_xml.js0000644000175200017650000000365512656322007017602 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_fadbad_sparse_hessian.cpp_xml.js0000644000175200017650000000352312656322007021620 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_fadbad_sparse_jacobian.cpp_xml.js0000644000175200017650000000352412656322007021735 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_speed_sacado_xml.js0000644000175200017650000000345312656322007017163 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sacado_det_minor.cpp_xml.js0000644000175200017650000000367412656322007020631 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sacado_det_lu.cpp_xml.js0000644000175200017650000000366312656322007020123 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sacado_mat_mul.cpp_xml.js0000644000175200017650000000366612656322007020310 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sacado_ode.cpp_xml.js0000644000175200017650000000365212656322007017414 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sacado_poly.cpp_xml.js0000644000175200017650000000365512656322007017633 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sacado_sparse_hessian.cpp_xml.js0000644000175200017650000000352312656322007021651 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_sacado_sparse_jacobian.cpp_xml.js0000644000175200017650000000352412656322007021766 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_faq_xml.js0000644000175200017650000000370212656322007015315 0ustar coincoin-webvar 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', '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#Mode: Forward or Reverse', 'faq.xml#Namespace', 'faq.xml#Namespace.Test Vector Preprocessor Symbol', 'faq.xml#Namespace.Using', '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]; } cppad-20160000.1/doc/_theory_xml.js0000644000175200017650000000314312656322007016057 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/forwardtheory.xml0000644000175200017650000013146712656322007016624 0ustar coincoin-web 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/theory/forward_theory.omh cppad-20160000.1/doc/_forwardtheory_xml.js0000644000175200017650000000504112656322007017443 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_exp_forward_xml.js0000644000175200017650000000354312656322007017071 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'forwardtheory.xml', 'exp_forward.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_forward.xml', 'log_forward.xml', 'sqrt_forward.xml', 'sin_cos_forward.xml', 'atan_forward.xml', 'asin_forward.xml', 'acos_forward.xml', 'tan_forward.xml', 'erf_forward.xml' ]; var list_current0 = [ 'exp_forward.xml#Derivatives', 'exp_forward.xml#Taylor Coefficients Recursion' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_log_forward_xml.js0000644000175200017650000000354312656322007017056 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'forwardtheory.xml', 'log_forward.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_forward.xml', 'log_forward.xml', 'sqrt_forward.xml', 'sin_cos_forward.xml', 'atan_forward.xml', 'asin_forward.xml', 'acos_forward.xml', 'tan_forward.xml', 'erf_forward.xml' ]; var list_current0 = [ 'log_forward.xml#Derivatives', 'log_forward.xml#Taylor Coefficients Recursion' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_sqrt_forward_xml.js0000644000175200017650000000337412656322007017270 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'forwardtheory.xml', 'sqrt_forward.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_forward.xml', 'log_forward.xml', 'sqrt_forward.xml', 'sin_cos_forward.xml', 'atan_forward.xml', 'asin_forward.xml', 'acos_forward.xml', 'tan_forward.xml', 'erf_forward.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_sin_cos_forward_xml.js0000644000175200017650000000350412656322007017727 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'forwardtheory.xml', 'sin_cos_forward.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_forward.xml', 'log_forward.xml', 'sqrt_forward.xml', 'sin_cos_forward.xml', 'atan_forward.xml', 'asin_forward.xml', 'acos_forward.xml', 'tan_forward.xml', 'erf_forward.xml' ]; var list_current0 = [ 'sin_cos_forward.xml#Differential Equation' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_atan_forward_xml.js0000644000175200017650000000354612656322007017223 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'forwardtheory.xml', 'atan_forward.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_forward.xml', 'log_forward.xml', 'sqrt_forward.xml', 'sin_cos_forward.xml', 'atan_forward.xml', 'asin_forward.xml', 'acos_forward.xml', 'tan_forward.xml', 'erf_forward.xml' ]; var list_current0 = [ 'atan_forward.xml#Derivatives', 'atan_forward.xml#Taylor Coefficients Recursion' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_asin_forward_xml.js0000644000175200017650000000354612656322007017232 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'forwardtheory.xml', 'asin_forward.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_forward.xml', 'log_forward.xml', 'sqrt_forward.xml', 'sin_cos_forward.xml', 'atan_forward.xml', 'asin_forward.xml', 'acos_forward.xml', 'tan_forward.xml', 'erf_forward.xml' ]; var list_current0 = [ 'asin_forward.xml#Derivatives', 'asin_forward.xml#Taylor Coefficients Recursion' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_acos_forward_xml.js0000644000175200017650000000354612656322007017225 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'forwardtheory.xml', 'acos_forward.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_forward.xml', 'log_forward.xml', 'sqrt_forward.xml', 'sin_cos_forward.xml', 'atan_forward.xml', 'asin_forward.xml', 'acos_forward.xml', 'tan_forward.xml', 'erf_forward.xml' ]; var list_current0 = [ 'acos_forward.xml#Derivatives', 'acos_forward.xml#Taylor Coefficients Recursion' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_tan_forward_xml.js0000644000175200017650000000354312656322007017057 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_erf_forward_xml.js0000644000175200017650000000354312656322007017051 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_reversetheory_xml.js0000644000175200017650000000444012656322007017454 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_exp_reverse_xml.js0000644000175200017650000000337312656322007017101 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'reversetheory.xml', 'exp_reverse.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_reverse.xml', 'log_reverse.xml', 'sqrt_reverse.xml', 'sin_cos_reverse.xml', 'atan_reverse.xml', 'asin_reverse.xml', 'acos_reverse.xml', 'tan_reverse.xml', 'erf_reverse.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_log_reverse_xml.js0000644000175200017650000000337312656322007017066 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'reversetheory.xml', 'log_reverse.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_reverse.xml', 'log_reverse.xml', 'sqrt_reverse.xml', 'sin_cos_reverse.xml', 'atan_reverse.xml', 'asin_reverse.xml', 'acos_reverse.xml', 'tan_reverse.xml', 'erf_reverse.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_sqrt_reverse_xml.js0000644000175200017650000000337412656322007017277 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'reversetheory.xml', 'sqrt_reverse.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_reverse.xml', 'log_reverse.xml', 'sqrt_reverse.xml', 'sin_cos_reverse.xml', 'atan_reverse.xml', 'asin_reverse.xml', 'acos_reverse.xml', 'tan_reverse.xml', 'erf_reverse.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_sin_cos_reverse_xml.js0000644000175200017650000000337712656322007017746 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'reversetheory.xml', 'sin_cos_reverse.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_reverse.xml', 'log_reverse.xml', 'sqrt_reverse.xml', 'sin_cos_reverse.xml', 'atan_reverse.xml', 'asin_reverse.xml', 'acos_reverse.xml', 'tan_reverse.xml', 'erf_reverse.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_atan_reverse_xml.js0000644000175200017650000000337412656322007017231 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'reversetheory.xml', 'atan_reverse.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_reverse.xml', 'log_reverse.xml', 'sqrt_reverse.xml', 'sin_cos_reverse.xml', 'atan_reverse.xml', 'asin_reverse.xml', 'acos_reverse.xml', 'tan_reverse.xml', 'erf_reverse.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_asin_reverse_xml.js0000644000175200017650000000337412656322007017240 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'reversetheory.xml', 'asin_reverse.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_reverse.xml', 'log_reverse.xml', 'sqrt_reverse.xml', 'sin_cos_reverse.xml', 'atan_reverse.xml', 'asin_reverse.xml', 'acos_reverse.xml', 'tan_reverse.xml', 'erf_reverse.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_acos_reverse_xml.js0000644000175200017650000000337412656322007017233 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'theory.xml', 'reversetheory.xml', 'acos_reverse.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'forwardtheory.xml', 'reversetheory.xml', 'reverse_identity.xml' ]; var list_down1 = [ 'exp_reverse.xml', 'log_reverse.xml', 'sqrt_reverse.xml', 'sin_cos_reverse.xml', 'atan_reverse.xml', 'asin_reverse.xml', 'acos_reverse.xml', 'tan_reverse.xml', 'erf_reverse.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_tan_reverse_xml.js0000644000175200017650000000363612656322007017071 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_erf_reverse_xml.js0000644000175200017650000000357212656322007017062 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_reverse_identity_xml.js0000644000175200017650000000360512656322007020134 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_bib_xml.js0000644000175200017650000000322412656322007015301 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_wish_list_xml.js0000644000175200017650000000403212656322007016550 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'wish_list.xml' ]; var list_down2 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down1 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_current0 = [ 'wish_list.xml#Base Requirements', 'wish_list.xml#PrintFor Optimization', 'wish_list.xml#checkpoint', 'wish_list.xml#Machine Epsilon in Examples', 'wish_list.xml#Adolc', 'wish_list.xml#Optimizing Nested Conditional Expressions', 'wish_list.xml#Forward Mode Recomputation', 'wish_list.xml#Iterator Interface', 'wish_list.xml#Compilation Speed', 'wish_list.xml#Operation Sequence', 'wish_list.xml#Comparison Changes and Optimization', 'wish_list.xml#Software Guidelines', 'wish_list.xml#Tracing', 'wish_list.xml#atan2', 'wish_list.xml#BenderQuad' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_whats_new_xml.js0000644000175200017650000000355212656322007016550 0ustar coincoin-webvar 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', '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_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]; } cppad-20160000.1/doc/whats_new_15.xml0000644000175200017650000017315712656322010016225 0ustar coincoin-web 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-29
Separate to_string from ad_to_string so that it can be used without the rest of CppAD; i.e., by including
     # include <cppad/utility/to_string.hpp>

12-28
  1. Add the to_string utility.
  2. Add base_to_string to the Base type requirements.
  3. A Base requirements item was added to the wish list.
  4. The wish_list item to reorganize the include directory has been removed. It was completed when the utilities was moved to cppad/utility; see 11-30 .


12-08
  1. A convention was included for addon library files .
  2. Change new utility specifications to allow for individual file includes; e.g., <cppad/utility/vector.hpp>.


12-01
Fix problem with auto_tools install handling of the deprecated files. This included changing the auto-tools --with-implicit_ctor option to --with-deprecated .

11-30
  1. The library section has been moved to the utilities section. In addition, the corresponding source code files in cppad have been moved to cppad/utility.
  2. The individual utility include files have been deprecated; see include_deprecated . For example,
     
         # include <cppad/runge_45.hpp>
    
    You should us the utility include instead; i.e.,
     
         # include <cppad/utility.hpp>
    
  3. The numeric_ad routines where moved from the library the a separate documentation section.
  4. Change cmake_install_prefix to cppad_prefix and Change cmake_install_postfix to cppad_postfix .
  5. Change cppad_implicit_ctor_from_any_type to cppad_deprecated and change its specifications to refer to all deprecated features.


11-25
  1. CppAD now installs the object library
     
         -lcppad_lib
    
    to be included when linking. Currently, it is only required when colpack_prefix is specified on the cmake command .
  2. It is no longer necessary to compile and link the file
     
         cppad_colpack.cpp
    
    when colpack_prefix is specified during the install process; see cmake command . (It is included in cppad_lib).


11-24
  1. The check_for_nan output now includes the first dependent variable index that is nan in its error message.
  2. Change the deprecated include reference pow_int.h to pow_int.hpp in pow_int .


11-14
There was a bug in the new get_check_for_nan feature that writes independent variable values to a temporary file; see 11-06 below. This has been fixed.

11-08
  1. Fixed a bug in the RevSparseJac routine. To be specific, the argument r was transposed from what the documentation said. (This has no effect in the usual case where r is the identity.)
  2. Added the bool_sparsity.cpp examples which show how to conserve memory when computing sparsity patterns.
  3. Modified the ipopt_solve procedure to take advantage of the memory conserving sparsity pattern calculations when retape is false.
  4. Added the bit_per_unit function to the vectorBool class. (This aids the memory conservation mentioned above.)


11-06
It is often difficult to determine what cause a nan result during an operation with an ADFun object. The new feature get_check_for_nan was added to make this easier.

10-21
There was a mistake in the documentation for index_sort , the argument ind is not const.

10-16
Add a PrintFor optimization item to the wish list.

10-06
  1. Add CPPAD_USE_CPLUSPLUS_2011 , CPPAD_NUMERIC_LIMITS, and CPPAD_STANDARD_MATH_UNARY, to the preprocessor section. In addition, remove checking that all user API preprocessor symbols are in this section form the wish_list .
  2. Alphabetize and make some corrections to list of examples .
  3. The documentation for some of the deprecated features was missing the date when they were deprecated. This has been fixed; e.g., see Deprecated 2012-12-26 .


10-04
  1. base_require : Add the macro CPPAD_NUMERIC_LIMITS to aid in setting the numeric limits for a user defined Base class.
  2. base_require : The quiet_NaN function has been added to the CppAD numeric_limits. Note the reason for not using std::numeric_limits .
  3. The nan(zero) function computes a nan by dividing zero by zero which results in a warning when using some compilers. This function has been deprecated and the corresponding wish_list item has been removed.
  4. Move documentation for zdouble to deprecated section and documentation for numeric_limits to ADValued .
  5. Remove all uses of, and references to, zdouble from the examples .


10-03
base_require : It is no longer necessary to define the specialization for CppAD::epsilon<Base>() for each Base type.

10-02
There was a bug in test_more/azmul.cpp whereby the vector z had the wrong dimension (in two places). This has been fixed.

09-28
  1. Use the current atomic_option setting to determine which type of sparsity patterns to use for dependency calculations during optimize procedure. It used to be that the bool_sparsity_enum was used when pack_sparsity_enum was specified.
  2. It is not longer an error to take the derivative of the square root function, because the result may be the part of a conditional expression that is not used.
  3. Update the wish_list section.


09-27
  1. It is no longer necessary to use the zdouble class when computing with multiple levels of AD conditional expressions and reverse mode .
  2. The zdouble class has been deprecated. Use the azmul function for absolute zero (when it is needed).


09-25
base_require : absolute zero multiplication is now required for user defined base types. This makes it possible to combine conditional expression , multiple levels , reverse , and a base type that has standard ieee multiplication; e.g., double. In other words, not all multiplications will need to have an absolute zero (as is the case with the zdouble base class.

09-24
Fix some Visual Studio 2013 C++ level four /W4 warnings (previous warnings were are level 3). In addition, disable warning 4100 unreferenced formal parameter, and warning 4127 conditional expression is constant.

09-23
CppAD can optionally test its use with the external packages eigen , ipopt , and colpack . In addition, it can compare its speed with the external AD packages adolc , fadbad , and sacado . The scripts that download and install a local copy of these external packages have been modified to automatically skip installation when it has already been done.

09-21
Improve discussion of windows download and testing .

09-20
  1. Add the cppad_profile_flag to the list of possible cmake command arguments.
  2. More of the warnings generated by Visual Studio 2013 have been fixed. One remaining warning is about asctime and gmtime not being thread safe.


09-19
  1. There was a bug in the numeric_limits section of the example user defined base type. This has been fixed.
  2. There were some compile and link errors when running the tests using Visual Studio 2013. These have been fixed.
  3. Many of the warnings generated by Visual Studio 2013 have been fixed.


09-16
The conditional expressions, CondExp , were not working for the type < CppAD::AD<adouble> > where adouble is the ADOL-C AD type. This has been fixed by adding a call to CPPAD_COND_EXP_REL in base_adolc.hpp.

09-03
  1. There was a bug in the vectorBool assignment . To be specific, it not allow a size zero vector to be assigned using a vector any other size. This has been fixed.
  2. The addition of the pack option on 08-31 introduced a bug in the calculation of RevSparseHes . The checkpoint.cpp example was changed to demonstrate this problem and the bug was fixed.


09-02
The dependency pattern was not being computed correctly for the sign , Discrete , and VecAD operations. This has been fixed. This could have caused problems using checkpoint functions that used any of these operations.

08-31
  1. Mention the fact that using checkpoint functions can make recordings faster .
  2. Add the pack sparsity option for atomic_base operations.
  3. Add the pack sparsity option to checkpoint functions.
  4. Added the atomic_sparsity.cpp example.
  5. Remove mention of OpenMP from thread_alloc::thread_num (thread_alloc never was OpenMP specific).


08-30
  1. The sparsity argument was added to the atomic_base constructor and the checkpoint constructor.
  2. Make atomic_norm_sq.cpp an example with no set sparsity and atomic_reciprocal.cpp an example with no bool sparsity.
  3. Improve discussion of Independent and parallel mode .


08-29
Some asserts in the checkpoint implementation were not using the CppAD ErrorHandler . This has been fixed.

08-28
Free checkpoint function sparsity patters during forward operations that use its atomic operation. (They kept between sparsity calculations because they do not change.)

08-26
Fix a bug in RevSparseJac when used to compute sparsity pattern for a subset of the rows in a checkpoint function.

08-25
Reduce the amount of memory required for checkpoint functions (since sparsity patterns are now being held so they do not need to be recalculated).

08-20
Added an example that computes the sparsity pattern for a subset of the Jacobian and a subset of the Hessian .

08-17
  1. Do some optimization of the checkpoint feature so that sparsity patterns are stored and not recalculated.
  2. Fix a warning (introduced on 08-11) where the CppAD::vector data function was being shadowed by a local variable.
  3. The source code control for CppAD has a link to compile, instead of real file. This sometimes caused problems with the deprecated auto_tools install procedure and has been fixed.


08-16
  1. Improve the documentation for checkpoint functions. To be specific, change the syntax to use the name atom_fun . In addition, include the fact that atom_fun must not be destructed for as along as the corresponding atomic operations are used.
  2. Add the size_var function to the checkpoint objects.


08-09
Add the preservation of data to the specifications of a CppAD::vector during a resize when the capacity of the vector does not change. In addition, added and example of this to cppad_vector.cpp .

08-06
The zdouble numeric_limits were not being computed properly. This has been fixed.

07-31
Added the sparse_sub_hes.cpp example, a way to compute the sparsity for a subset of variables without using multiple levels of AD .

06-16
  1. There were some unknown asserts when the sparsity pattern p in sparse_jacobian and sparse_hessian was not properly dimensioned. These have been changed to known asserts to give better error reporting.
  2. In the special case where sparse Hessian work or sparse Jacobian work was specified and the set of elements to be computed was empty, the work vector is empty after the call (and it appears to need to be calculated on subsequent calls). This resulted in a bug when the sparsity pattern was not provided on subsequent calls (and has been fixed).


06-11
  1. Some C++11 features were not being taken advantage of after the change on 05-10 . To be specific, move semantics, the high resolution clock, and null pointers. This has been fixed.
  2. In the example zdouble.cpp , the vector a1z was not properly dimensioned. This has been fixed and the dimensions of all the variables have been clarified.


06-09
Add an abort_op_index item to the wish list. It has since been removed (domain errors may not affect the results due to conditional expressions ).

06-07
Add a absolute zero item and a numeric_limits item to the wish list. The absolute zero item has been completed and the numeric limit item was modified on implementation. Remove the multiple directions with list item.

05-26

cond_exp_1
There was a problem using conditional expressions with multiple levels of AD where the result of the conditional expression might not be determined during forward mode. This would generate an assert of the form:
     Error detected by false result for
          IdenticalPar(
side)
    at line 
number in the file
          
.../cppad/local/cskip_op.hpp
where side was left or right and number was the line number of an assert in cskip_op.hpp. This has been fixed.

cond_exp_2
There was a problem with using conditional expressions and reverse mode with multiple levels of AD . This was problem was represented by the file bug/cond_exp_2.sh.
  1. The problem above has been fixed by adding the base type zdouble, see CppAD motivation for this new type. (It is no longer necessary to use zdouble to get an absolute zero because CppAD now uses azmul where an absolute zero is required.)
  2. The sections mul_level , change_param.cpp , mul_level.cpp , and mul_level_ode.cpp were changed to use zdouble .
  3. The adolc multi-level examples mul_level_adolc.cpp and mul_level_adolc_ode.cpp were changed to mention the limitations because Adolc does not have an absolute zero .
  4. The example above were also changed so that AD variable names that indicated the level of AD for the variable.
  5. base_require : The base type requirements were modified to include mention of absolute zero . In addition, the base type requirements API warning is now more informative.


05-11
Reorganize the unary_standard_math documentation.

05-10
  1. Add the exponential minus one function log1p .
  2. base_require : If you are defining your own base type, note that log1p was added to the base type requirements.
  3. Use the single preprocessor flag CPPAD_USE_CPLUSPLUS_2011 to signal that the functions erf, asinh, acosh, atanh, expm1, log1p are part of the base type requirements.


05-09
  1. Add the exponential minus one function expm1 . If you are defining your own base type, note that expm1 was added to the base type requirements.
  2. Fix some warnings about comparing signed and unsigned integers when using eigen for the CppAD test vector. (The eigen vector size() function returns an int instead of a size_t.)


05-08
  1. Add the inverse hyperbolic sine function atanh . If you are defining your own base type, note that atanh was added to the base type requirements.
  2. Fix a bug in the implementation of the acosh multiple direction forward mode forward_dir (when compiler has acosh ).


05-07
Add the inverse hyperbolic sine function acosh . If you are defining your own base type, note that acosh was added to the base type requirements.

05-05
Add the inverse hyperbolic sine function asinh . If you are defining your own base type, note that asinh was added to the base type requirements.

04-18
In the sparse jacobian and sparse hessian calculations, If work is present, and has already been computed, the sparsity pattern p is not used. This has been added to the documentation; see sparse jacobian and sparse hessian documentation for work and p .

03-13
Remove the syntax
     AD<
Basey = x
for the AD constructor documentation because it does not work when the constructor is explicit . Also document the restriction that the constructor in the assignment must be implicit.

03-06
The developers of the TMB package reported that for large ADFun tapes, the optimize routine uses a large amount of memory because it allocates a standard set for each variable on the tape. These sets are only necessary for variables in conditional expressions that can be skipped once the independent variables have a set value. The problem has been reduced by using a NULL pointer for the empty set and similar changes. It still needs more work.

02-28
It used to be the case that the Reverse mode would propagate nan through the conditional expression case that is not used. For example, if
 
     Independent(ax);
     AD<double> aeps = 1e-10;
     ay[0] = CondExpGt( ax[0], aeps, 1.0/ax[0], 1.0/aeps );
     ADFun<double> f(ax, ay);
The corresponding reverse mode calculation, at x[0] = 0.0, would result in
 
     Error detected by false result for
     ! ( hasnan(value) && check_for_nan_ )
This has been fixed so that only the conditional expression case that is used affects the reverse mode results. The example cond_exp.cpp was changed to reflect this (a check for nan was changed to a check for zero). Note that this fix only works when IdenticalPar is true for the base type of the result in the conditional expression; e.g., one can still get a nan effect from the case that is not selected when using AD< AD<double> > conditional expressions.

02-18
If the compiler supports the c++11 feature std::chrono:high_resolution_clock then use it for the elapsed_seconds function.

02-16
The new example sub_sparse_hes.cpp shows one way to compute a Hessian for a subset of variables without having to compute the sparsity pattern for the entire functions.

02-14
Fix another bug in the derivative calculations for the c++11 version of the error function; see CPPAD_USE_CPLUSPLUS_2011 .

02-11
Fix a bug in the optimization of conditional expressions. To be specific, if NDEBUG is not defined, one could get an assert with the message:
 
     Error detected by false result for
          var_index_ >= NumRes(op_)

02-10
The change on 2014-12-23 introduced a bug when the c++11 version of the error function was used with an optimized function. see CPPAD_USE_CPLUSPLUS_2011 . There was also a bug in the sparsity calculations for when this erf function was included. These bugs have been fixed.

02-09
The test test_more/optimize.cpp was failing on some systems because an exactly equality check should have been a near equal check. This has been fixed.

02-07
On some systems, the library corresponding to speed/src could not be found. This library is only used for testing and so has been changed to always be static (hence does not need to be found at run time).

02-06
There was a bug in the coloring method change on 2015-01-07 . To be specific, work.color_method was not being set to "cppad.symmetric" after work.color_method.clear() . This has been fixed.

02-04
  1. Enable the same install of CppAD to be used both with and without C++11 features; e.g., with both g++ --std=c++11 and with g++ --std=c++98. Previously if the cppad_cxx_flags specified C++11, then it could only be used in that way.
  2. The cmake command now requires the version of cmake to be greater than or equal 2.8 (due a bug in cmake version 2.6).


02-03
Improved the searching for the boost multi-threading library which is used for by the team_bthread.cpp case of the thread_test.cpp example and test.

02-02
Improve the documentation for the cmake command line options
     cmake_install_
dir
for dir equal to prefix, postfix, includedirs, libdirs, datadir, and docdir.

01-30
Fix bug in link_sparse_hessian speed test introduced on 01-09 below.

01-29
Fix some warnings generated by g++ 4.9.2.

01-26
The change of global variables to local in cppad/local/op_code.hpp on 2014-50-14 created a bug in parallel_ad (some local statics needed to be initialized). This has been fixed.

01-23
There was a bug in the cmake install detection of compiler features. One symptom of this bug was that on systems that had the gettimeofday function, the cmake install would sometimes report
     cppad_has_gettimeofday = 0
This has been fixed.

01-21
The deprecated auto_tools procedure had a bug in the detection of when the size of an unsigned int was the same as the size of a size_t. This has been fixed.

01-20
  1. The new compare_change interface has been created and the old CompareChange function has been deprecated; see the compare_change.cpp example. This enables one to determine the source code during taping that corresponds to changes in the comparisons during zero order forward operations; see abort_op_index .
  2. This new compare_change interface can detect comparison changes even if NDEBUG is defined and even if f.optimize() has been called. The deprecated function CompareChange used to always return zero after
         
    f.optimize()
    and was not even defined when NDEBUG was defined. There was a resulting speed effect for this; see the wish list compare change entry.
  3. The date when some features where deprecated has been added to the documentation. For example, see Deprecated 2006-12-17 .


01-09
  1. The change 01-07 below included (but did not mention) using a sparse, instead of full, structure for the Hessian in the test. This has also been done for the sparse Jacobian test.
  2. For both the sparse_jacobian and sparse_hessian tests, the sparse function is only chosen once (it used to be different for every repeat). This reduced the amount of computation not connected what is being tested. It also make the onetape a valid option for these tests.
  3. There was a bug in the multiple direction forward routine. Results for function values that are parameter were not being computed properly (all the derivatives are zero in this case). This has been fixed.


01-07
The following changes were merged in from the color_hes branch:
  1. Specify the type of coloring for the sparse hessian calculations. To be specific, instead of "cppad" and "colpack", the choices are "cppad.symmetric", "cppad.general", and "colpack.star". This is not compatible with the change on 01-02 , which was so recent that this should not be a problem.
  2. The n_sweep values were not being returned properly by cppad_sparse_hessian.cpp and adolc_sparse_hessian.cpp . The CppAD version has been fixed and the ADOL-C version has been set to zero.
  3. The link_sparse_hessian example case was to sparse for good testing (by mistake). This has been fixed.
  4. Add n_sweep to link_sparse_hessian and speed_main .
  5. Change the cppad sparse Hessian color_method to take advantage of the symmetry of the Hessian (in a similar fashion to the colpack coloring method).


01-02
Added to option to uses colpack for the sparse Hessian coloring method ; see the example colpack_hes.cpp .
Input File: omh/whats_new/whats_new_15.omh cppad-20160000.1/doc/_whats_new_15_xml.js0000644000175200017650000000766012656322007017061 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'whats_new.xml', 'whats_new_15.xml' ]; var list_down3 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down2 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_15.xml#Introduction', 'whats_new_15.xml#12-29', 'whats_new_15.xml#12-28', 'whats_new_15.xml#12-08', 'whats_new_15.xml#12-01', 'whats_new_15.xml#11-30', 'whats_new_15.xml#11-25', 'whats_new_15.xml#11-24', 'whats_new_15.xml#11-14', 'whats_new_15.xml#11-08', 'whats_new_15.xml#11-06', 'whats_new_15.xml#10-21', 'whats_new_15.xml#10-16', 'whats_new_15.xml#10-06', 'whats_new_15.xml#10-04', 'whats_new_15.xml#10-03', 'whats_new_15.xml#10-02', 'whats_new_15.xml#09-28', 'whats_new_15.xml#09-27', 'whats_new_15.xml#09-25', 'whats_new_15.xml#09-24', 'whats_new_15.xml#09-23', 'whats_new_15.xml#09-21', 'whats_new_15.xml#09-20', 'whats_new_15.xml#09-19', 'whats_new_15.xml#09-16', 'whats_new_15.xml#09-03', 'whats_new_15.xml#09-02', 'whats_new_15.xml#08-31', 'whats_new_15.xml#08-30', 'whats_new_15.xml#08-29', 'whats_new_15.xml#08-28', 'whats_new_15.xml#08-26', 'whats_new_15.xml#08-25', 'whats_new_15.xml#08-20', 'whats_new_15.xml#08-17', 'whats_new_15.xml#08-16', 'whats_new_15.xml#08-09', 'whats_new_15.xml#08-06', 'whats_new_15.xml#07-31', 'whats_new_15.xml#06-16', 'whats_new_15.xml#06-11', 'whats_new_15.xml#06-09', 'whats_new_15.xml#06-07', 'whats_new_15.xml#05-26', 'whats_new_15.xml#05-26.cond_exp_1', 'whats_new_15.xml#05-26.cond_exp_2', 'whats_new_15.xml#05-11', 'whats_new_15.xml#05-10', 'whats_new_15.xml#05-09', 'whats_new_15.xml#05-08', 'whats_new_15.xml#05-07', 'whats_new_15.xml#05-05', 'whats_new_15.xml#04-18', 'whats_new_15.xml#03-13', 'whats_new_15.xml#03-06', 'whats_new_15.xml#02-28', 'whats_new_15.xml#02-18', 'whats_new_15.xml#02-16', 'whats_new_15.xml#02-14', 'whats_new_15.xml#02-11', 'whats_new_15.xml#02-10', 'whats_new_15.xml#02-09', 'whats_new_15.xml#02-07', 'whats_new_15.xml#02-06', 'whats_new_15.xml#02-04', 'whats_new_15.xml#02-03', 'whats_new_15.xml#02-02', 'whats_new_15.xml#01-30', 'whats_new_15.xml#01-29', 'whats_new_15.xml#01-26', 'whats_new_15.xml#01-23', 'whats_new_15.xml#01-21', 'whats_new_15.xml#01-20', 'whats_new_15.xml#01-09', 'whats_new_15.xml#01-07', 'whats_new_15.xml#01-02' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_whats_new_14_xml.js0000644000175200017650000000601412656322010017042 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_whats_new_13_xml.js0000644000175200017650000000552612656322010017050 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_whats_new_12_xml.js0000644000175200017650000001032212656322010017035 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_whats_new_11_xml.js0000644000175200017650000001003612656322010017036 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_whats_new_10_xml.js0000644000175200017650000000524012656322010017036 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_whats_new_09_xml.js0000644000175200017650000000722012656322010017046 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_whats_new_08_xml.js0000644000175200017650000000625012656322010017047 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_whats_new_07_xml.js0000644000175200017650000001024212656322010017042 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_whats_new_06_xml.js0000644000175200017650000001143212656322010017043 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_whats_new_05_xml.js0000644000175200017650000000770712656322010017054 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_whats_new_04_xml.js0000644000175200017650000001064212656322010017043 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_whats_new_03_xml.js0000644000175200017650000000662212656322010017045 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'whats_new_15.xml', 'whats_new_14.xml', 'whats_new_13.xml', 'whats_new_12.xml', 'whats_new_11.xml', 'whats_new_10.xml', 'whats_new_09.xml', 'whats_new_08.xml', 'whats_new_07.xml', 'whats_new_06.xml', 'whats_new_05.xml', 'whats_new_04.xml', 'whats_new_03.xml' ]; var list_current0 = [ 'whats_new_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]; } cppad-20160000.1/doc/_deprecated_xml.js0000644000175200017650000000342412656322010016641 0ustar coincoin-webvar 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', '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' ]; var list_current0 = [ 'deprecated.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]; } cppad-20160000.1/doc/include_deprecated.xml0000644000175200017650000003313512656322010017513 0ustar coincoin-web 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 should instead use
 
     # include <cppad/utility.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 should change it to the command
 
     # include <cppad/cppad.hpp>

Linking New Files to Deprecated Commands
On Unix systems, references in your source code of the from
     # include <CppAD/
name.h>
will refer to the older versions of CppAD unless you preform the following steps (this only needs to be done once, not for every install):
     cp 
prefix_dir/include
     sudo mv CppAD CppAD.old
     sudo ln -s cppad CppAD
where prefix_dir is the prefix directory corresponding to your Unix installation . This will link form the deprecated commands to the commands that should be used:
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/deprecated/include_deprecated.omh cppad-20160000.1/doc/_include_deprecated_xml.js0000644000175200017650000000412212656322010020340 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_current0 = [ 'include_deprecated.xml#Deprecated 2015-11-30', 'include_deprecated.xml#Deprecated 2006-12-17', 'include_deprecated.xml#Linking New Files to Deprecated Commands' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_comparechange_xml.js0000644000175200017650000000413412656322010017334 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_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]; } cppad-20160000.1/doc/_omp_max_thread_xml.js0000644000175200017650000000416312656322010017531 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_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]; } cppad-20160000.1/doc/_tracknewdel_xml.js0000644000175200017650000000541012656322010017041 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_tracknewdel.cpp_xml.js0000644000175200017650000000341612656322010017626 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/omp_max_num_threads.xml0000644000175200017650000001432112656322010017735 0ustar coincoin-web 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 cppad-20160000.1/doc/_omp_max_num_threads_xml.js0000644000175200017650000000453712656322010020600 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_omp_in_parallel_xml.js0000644000175200017650000000434212656322010017676 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_omp_get_thread_num_xml.js0000644000175200017650000000436612656322010020407 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_omp_get_memory_xml.js0000644000175200017650000000450412656322010017563 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_omp_return_memory_xml.js0000644000175200017650000000445712656322010020332 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_omp_free_available_xml.js0000644000175200017650000000436612656322010020343 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_omp_available_xml.js0000644000175200017650000000436712656322010017343 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_omp_create_array_xml.js0000644000175200017650000000454612656322010020063 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_omp_delete_array_xml.js0000644000175200017650000000450312656322010020053 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_omp_efficient_xml.js0000644000175200017650000000443512656322010017353 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_old_max_num_threads_xml.js0000644000175200017650000000436312656322010020560 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_omp_alloc.cpp_xml.js0000644000175200017650000000414612656322010017271 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_memory_leak_xml.js0000644000175200017650000000431412656322010017044 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_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]; } cppad-20160000.1/doc/_epsilon_xml.js0000644000175200017650000000403612656322010016212 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_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]; } cppad-20160000.1/doc/_test_vector_xml.js0000644000175200017650000000431712656322010017104 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_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]; } cppad-20160000.1/doc/_cppad_ipopt_nlp_xml.js0000644000175200017650000000673712656322010017726 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_ipopt_nlp_get_started.cpp_xml.js0000644000175200017650000000372212656322010021714 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ipopt_nlp_ode_xml.js0000644000175200017650000000404412656322010017373 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_ipopt_nlp_ode_problem_xml.js0000644000175200017650000000524212656322010021114 0ustar coincoin-webvar 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' ]; 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]; } cppad-20160000.1/doc/_ipopt_nlp_ode_problem.hpp_xml.js0000644000175200017650000000324612656322010021704 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ipopt_nlp_ode_simple_xml.js0000644000175200017650000000426712656322010020753 0ustar coincoin-webvar 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' ]; 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]; } cppad-20160000.1/doc/_ipopt_nlp_ode_simple.hpp_xml.js0000644000175200017650000000324312656322010021532 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ipopt_nlp_ode_fast_xml.js0000644000175200017650000000500212656322010020403 0ustar coincoin-webvar 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' ]; 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]; } cppad-20160000.1/doc/_ipopt_nlp_ode_fast.hpp_xml.js0000644000175200017650000000323512656322010021177 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/_ipopt_nlp_ode_run.hpp_xml.js0000644000175200017650000000351712656322010021051 0ustar coincoin-webvar 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' ]; 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]; } cppad-20160000.1/doc/_ipopt_nlp_ode_check.cpp_xml.js0000644000175200017650000000352112656322010021310 0ustar coincoin-webvar 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' ]; 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]; } cppad-20160000.1/doc/_ipopt_ode_speed.cpp_xml.js0000644000175200017650000000352012656322010020461 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_old_atomic_xml.js0000644000175200017650000000753512656322010016662 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down0 = [ '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]; } cppad-20160000.1/doc/_old_reciprocal.cpp_xml.js0000644000175200017650000000372412656322010020306 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_old_usead_1.cpp_xml.js0000644000175200017650000000375712656322010017512 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_old_usead_2.cpp_xml.js0000644000175200017650000000371412656322010017504 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_old_tan.cpp_xml.js0000644000175200017650000000367712656322010016754 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_old_mat_mul.cpp_xml.js0000644000175200017650000000377512656322010017627 0ustar coincoin-webvar 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', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ '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]; } cppad-20160000.1/doc/_old_mat_mul.hpp_xml.js0000644000175200017650000000424712656322010017627 0ustar coincoin-webvar 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' ]; 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]; } cppad-20160000.1/doc/_zdouble_xml.js0000644000175200017650000000460212656322010016204 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'deprecated.xml', 'zdouble.xml' ]; var list_down3 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down2 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down1 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down0 = [ 'zdouble.cpp.xml' ]; var list_current0 = [ 'zdouble.xml#Deprecated 2015-09-26', 'zdouble.xml#Absolute Zero', 'zdouble.xml#Syntax', 'zdouble.xml#Syntax.Constructor and Assignment', 'zdouble.xml#Syntax.Comparison Operators', 'zdouble.xml#Syntax.Arithmetic Operators', 'zdouble.xml#Syntax.Standard Math', 'zdouble.xml#Syntax.Nan', 'zdouble.xml#Motivation', 'zdouble.xml#Motivation.General', 'zdouble.xml#Motivation.CppAD', 'zdouble.xml#Base Type Requirements', 'zdouble.xml#Example' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_zdouble.cpp_xml.js0000644000175200017650000000340212656322010016762 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'deprecated.xml', 'zdouble.xml', 'zdouble.cpp.xml' ]; var list_down3 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down2 = [ 'include_deprecated.xml', 'fundeprecated.xml', 'comparechange.xml', 'omp_max_thread.xml', 'tracknewdel.xml', 'omp_alloc.xml', 'memory_leak.xml', 'epsilon.xml', 'test_vector.xml', 'cppad_ipopt_nlp.xml', 'old_atomic.xml', 'zdouble.xml' ]; var list_down1 = [ 'zdouble.cpp.xml' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down3(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down3[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_compare_c_xml.js0000644000175200017650000000343512656322010016473 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_det_of_minor_c_xml.js0000644000175200017650000000423012656322010017503 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_det_by_minor_c_xml.js0000644000175200017650000000402112656322010017507 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_uniform_01_c_xml.js0000644000175200017650000000403612656322010017022 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_correct_det_by_minor_c_xml.js0000644000175200017650000000377612656322010021250 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_repeat_det_by_minor_c_xml.js0000644000175200017650000000403612656322010021055 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_elapsed_seconds_c_xml.js0000644000175200017650000000401012656322010020166 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_time_det_by_minor_c_xml.js0000644000175200017650000000407112656322010020532 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_main_compare_c_xml.js0000644000175200017650000000364612656322010017503 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_numeric_ad_xml.js0000644000175200017650000000313512656322010016646 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'numeric_ad.xml' ]; var list_down2 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down1 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_down0 = [ 'benderquad.xml', 'opt_val_hes.xml', 'luratio.xml' ]; var list_current0 = [ 'numeric_ad.xml#Contents' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_benderquad_xml.js0000644000175200017650000000424612656322010016656 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_bender_quad.cpp_xml.js0000644000175200017650000000312612656322010017572 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_opt_val_hes_xml.js0000644000175200017650000000431612656322010017045 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_opt_val_hes.cpp_xml.js0000644000175200017650000000312712656322010017625 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_luratio_xml.js0000644000175200017650000000431012656322010016213 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_lu_ratio.cpp_xml.js0000644000175200017650000000311512656322010017135 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/_addon_xml.js0000644000175200017650000000316512656322010015630 0ustar coincoin-webvar list_across0 = [ '_contents_xml.htm', '_reference.xml', '_index.xml', '_search_xml.htm', '_external.xml' ]; var list_up0 = [ 'cppad.xml', 'appendix.xml', 'addon.xml' ]; var list_down2 = [ 'install.xml', 'introduction.xml', 'ad.xml', 'adfun.xml', 'preprocessor.xml', 'multi_thread.xml', 'utility.xml', 'ipopt_solve.xml', 'example.xml', 'speed.xml', 'appendix.xml' ]; var list_down1 = [ 'faq.xml', 'theory.xml', 'glossary.xml', 'bib.xml', 'wish_list.xml', 'whats_new.xml', 'deprecated.xml', 'compare_c.xml', 'numeric_ad.xml', 'addon.xml', 'license.xml' ]; var list_current0 = [ 'addon.xml#Name', 'addon.xml#Include Files', 'addon.xml#Library Files', 'addon.xml#Preprocessor Symbols', 'addon.xml#Namespace' ]; function choose_across0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_across0[index-1]; } function choose_up0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_up0[index-1]; } function choose_down2(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down2[index-1]; } function choose_down1(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down1[index-1]; } function choose_down0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_down0[index-1]; } function choose_current0(item) { var index = item.selectedIndex; item.selectedIndex = 0; if(index > 0) document.location = list_current0[index-1]; } cppad-20160000.1/doc/_license_xml.js0000644000175200017650000000273612656322010016170 0ustar coincoin-webvar 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', '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]; } cppad-20160000.1/doc/__reference_xml.js0000644000175200017650000000311112656322010016627 0ustar coincoin-webvar 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#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]; } cppad-20160000.1/doc/__index_xml.js0000644000175200017650000000305512656322010016007 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/__search_xml.js0000644000175200017650000000217212656322012016146 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/__external_xml.js0000644000175200017650000000217012656322012016521 0ustar coincoin-webvar 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]; } cppad-20160000.1/doc/error.wrd0000644000175200017650000000000012656322034015024 0ustar coincoin-web