From 0a5ee6a2ece70b78fe2b488ea8a5e08ac65c3d79 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Fri, 13 Feb 2009 05:57:13 -0800 Subject: [PATCH] Use newer version of CppAD and include tanh, improve doc indexing --- brad/build.sh | 11 +++++++---- brad/doc.omh | 6 +++--- brad/example/std_math.py | 8 ++------ brad/omh/ad_method.omh | 2 ++ brad/omh/install.omh | 22 +++++++++++----------- brad/omh/license.omh | 5 +++++ brad/omh/whats_new_09.omh | 11 +++++++++++ brad/pycppad/__init__.py | 4 ++++ brad/pycppad/pycppad.cpp | 9 +-------- brad/setup.template | 15 +++++++++++++-- 10 files changed, 59 insertions(+), 34 deletions(-) diff --git a/brad/build.sh b/brad/build.sh index c8c83dc..db9fc9b 100755 --- a/brad/build.sh +++ b/brad/build.sh @@ -13,7 +13,8 @@ then fi option="$1" # --------------------------------------------------------------------- -cppad_version="20080919.0" # cppad release version we are using +cppad_version="20090131.0" # cppad release version we are using +cppad_with_doc="no" # include CppAD documention in download yyyymmdd=`date +%G%m%d` # todays year, month, and day # --------------------------------------------------------------------- # Note for Sebastian: this choice forces cppad to be dowloanded each time. @@ -32,10 +33,12 @@ then fi # ---------------------------------------------------------------------------- # Create setup.py from setup.template with certain replacements +# only edit line corresponding to assignment statement not check for == sed < ./setup.template > setup.py \ - -e "s|\(package_version *=\).*|\1 '$yyyymmdd'|" \ - -e "s|\(cppad_version *=\).*|\1 '$cppad_version'|" \ - -e "s|\(cppad_parent_dir *=\).*|\1 '$cppad_parent_dir'|" + -e "s|\(package_version *=\)[^=].*|\1 '$yyyymmdd'|" \ + -e "s|\(cppad_version *=\)[^=].*|\1 '$cppad_version'|" \ + -e "s|\(cppad_parent_dir *=\)[^=].*|\1 '$cppad_parent_dir'|" \ + -e "s|\(cppad_with_doc *=\)[^=].*|\1 '$cppad_with_doc'|" chmod +x setup.py # ---------------------------------------------------------------------------- if [ "$omhelp_location" != "" ] diff --git a/brad/doc.omh b/brad/doc.omh index c743c7c..41067e0 100644 --- a/brad/doc.omh +++ b/brad/doc.omh @@ -28,7 +28,7 @@ $hiliteseq% %.%reverse%(% reverse %$$ -$section pycppad-20090210: A Python Algorithm Derivative Package$$ +$section pycppad-20090213: A Python Algorithm Derivative Package$$ $index AD, python$$ $index python, AD$$ @@ -58,7 +58,7 @@ $codei%from pycppad import *%$$ $head Purpose$$ The command above imports a -$href%http://www.boost.org%boost python%$$ +$href%http://www.boost.org%boost%$$$code ::python%$$ interface to the C++ $href% http://en.wikipedia.org/wiki/Automatic_differentiation% @@ -80,7 +80,7 @@ The operation sequence can be evaluated to obtain new function values or derivatives of arbitrary order. In addition, multiple levels of AD are supported. This means that AD derivatives can be used in the definition of a function -which in true can be differentiated using AD. +which in turn can be differentiated using AD. See $cref/whats_new_09/$$ for a list of recent extensions and bug fixes. $childtable% diff --git a/brad/example/std_math.py b/brad/example/std_math.py index 776280e..31e524e 100644 --- a/brad/example/std_math.py +++ b/brad/example/std_math.py @@ -36,9 +36,7 @@ def pycppad_test_std_math(): assert abs( sinh(a_x) - math.sinh(x) ) < delta assert abs( sqrt(a_x) - math.sqrt(x) ) < delta assert abs( tan(a_x) - math.tan(x) ) < delta - # tanh was not available in the previouis release cppad-20080919.0. - # A new CppAD release is being built so that tanh can be inclued in pycppad - # assert abs( tanh(a_x) - math.tanh(x) ) < delta + assert abs( tanh(a_x) - math.tanh(x) ) < delta # example array and derivative calculation n = 5 @@ -73,9 +71,7 @@ def pycppad_test_std_math_a2(): assert abs( sinh(a2x) - math.sinh(x) ) < delta assert abs( sqrt(a2x) - math.sqrt(x) ) < delta assert abs( tan(a2x) - math.tan(x) ) < delta - # tanh was not available in the previouis release cppad-20080919.0. - # A new CppAD release is being built so that tanh can be inclued in pycppad - # assert abs( tanh(a2x) - math.tanh(x) ) < delta + assert abs( tanh(a2x) - math.tanh(x) ) < delta # example array and derivative calculation n = 5 diff --git a/brad/omh/ad_method.omh b/brad/omh/ad_method.omh index 847d38b..22b36fb 100644 --- a/brad/omh/ad_method.omh +++ b/brad/omh/ad_method.omh @@ -1,6 +1,8 @@ $begin ad_variable$$ $section AD Variable Methods$$ +$index ad, variable$$ +$index variable, ad$$ $childtable% pycppad/__init__.py% diff --git a/brad/omh/install.omh b/brad/omh/install.omh index eb9d90b..f0429ca 100644 --- a/brad/omh/install.omh +++ b/brad/omh/install.omh @@ -32,8 +32,8 @@ $index download, pycppad$$ $index pycppad, download$$ Download the file $href% - http://www.seanet.com/~bradbell/pycppad-20090210.tar.gz% - pycppad-20090210.tar.gz + http://www.seanet.com/~bradbell/pycppad-20090213.tar.gz% + pycppad-20090213.tar.gz %$$ and store it on your machine. @@ -44,14 +44,14 @@ $index extract, pycppad$$ $index pycppad, extract$$ On unix, you could use the command $codep - tar -xvzf pycppad-20090210.tar.gz + tar -xvzf pycppad-20090213.tar.gz $$ -which would create the directory $code pycppad-20090210$$. +which would create the directory $code pycppad-20090213$$. $head Required Setup Information$$ The value of the following setup variables, in the file $codep - pycppad-20090210/setup.py + pycppad-20090213/setup.py $$ must be set to agree with your system: $code @@ -64,7 +64,7 @@ properly set this information $head Building$$ $index build, pycppad$$ $index pycppad, build$$ -Change into the directory $code pycppad-20090210$$ and execute the command +Change into the directory $code pycppad-20090213$$ and execute the command $codep ./setup.py build_ext --inplace --debug --undef NDEBUG $$ @@ -98,7 +98,7 @@ $index test, pycppad$$ $index pycppad, test$$ You can test of all the $cref/examples/example/$$ in the $code pycppad$$ documentation. -Change into the directory $code pycppad-20090210$$ and execute the command +Change into the directory $code pycppad-20090213$$ and execute the command $codep python test_example.py $$ @@ -115,7 +115,7 @@ You may or may not preform this step: $pre $$ -Change into the directory $code pycppad-20090210$$ and execute the command +Change into the directory $code pycppad-20090213$$ and execute the command $codei% python setup.py install --prefix=%prefix% %$$ @@ -134,7 +134,7 @@ an uninstall command. You can uninstall the $code pycppad$$ package by removing the entries $codei% %prefix%/lib/python%major%.%minor%/site-packages/pycppad - %prefix%/lib/python%major%.%minor%/site-packages/pycppad-20090210.egg-info + %prefix%/lib/python%major%.%minor%/site-packages/pycppad-20090213.egg-info %prefix%/share/doc/pycppad %$$ where $icode major$$ and $icode minor$$ @@ -152,7 +152,7 @@ $codei% %$$ unless the distribution directory $codep - pycppad-20090210 + pycppad-20090213 $$ or (provided you installed $code pycppad$$) the installation directory $codei% @@ -174,7 +174,7 @@ $codei% $head pycppad Documentation$$ The documentation for $code pycppad$$ starts out in the directory $codep - pycppad-20090210/doc + pycppad-20090213/doc $$ During the installation process, it is copied to the directory $codei% diff --git a/brad/omh/license.omh b/brad/omh/license.omh index fb3ea12..f6ab5fd 100644 --- a/brad/omh/license.omh +++ b/brad/omh/license.omh @@ -1,6 +1,11 @@ $begin license$$ +$spell + pycppad +$$ $section License$$ +$index license, pycppad$$ +$index pycppad, license$$ $verbatim%README%$$ diff --git a/brad/omh/whats_new_09.omh b/brad/omh/whats_new_09.omh index e480af8..7bffc01 100644 --- a/brad/omh/whats_new_09.omh +++ b/brad/omh/whats_new_09.omh @@ -9,6 +9,17 @@ $spell $$ $section Extensions, Bug Fixes, and Changes During 2009$$ +$index bug, fix 2009$$ +$index fix, bug 2009$$ +$index version, feature 2009$$ +$index feature, version 2009$$ +$index 2009, feature$$ + +$head 02-13$$ +Changed to new version of CppAD, (20090131.0) +so that $code tanh$$ is now included in $cref std_math$$ +(it was documented but missing from the actual +pycppad implementation before this date). $head 02-09$$ Added cross reference links from the examples to the corresponding diff --git a/brad/pycppad/__init__.py b/brad/pycppad/__init__.py index d15b7df..a91db13 100644 --- a/brad/pycppad/__init__.py +++ b/brad/pycppad/__init__.py @@ -28,6 +28,10 @@ # element types listed in the previous sentence. # # $head a_x$$ +# $index a_float, create$$ +# $index create, a_float$$ +# $index a2float, create$$ +# $index create, a2float$$ # If $icode x$$ is an instance of $code int$$ or $code float$$, # $codei a_x$$ is an $code a_float$$ (AD level 1). # If $icode x$$ is an $code a_float$$, diff --git a/brad/pycppad/pycppad.cpp b/brad/pycppad/pycppad.cpp index 8f020ed..f5358b6 100644 --- a/brad/pycppad/pycppad.cpp +++ b/brad/pycppad/pycppad.cpp @@ -6,6 +6,7 @@ $$ $section Absolute Value Functions$$ +$index abs$$ $head Syntax$$ $icode%y% = abs(%x%)%$$ @@ -392,11 +393,7 @@ contains an example and test of these operations. PYCPPAD_UNARY_FUNCTION(sinh, Base) \ PYCPPAD_UNARY_FUNCTION(sqrt, Base) \ PYCPPAD_UNARY_FUNCTION(tan, Base) \ - -# if 0 - // not available in cppad-20080919.0 will be in cppad-20090131.0 PYCPPAD_UNARY_FUNCTION(tanh, Base) -# endif # define PYCPPAD_STD_MATH_LINK_PY(Base) \ .def("arccos", acos_AD_##Base) \ @@ -411,11 +408,7 @@ contains an example and test of these operations. .def("sinh", sinh_AD_##Base) \ .def("sqrt", sqrt_AD_##Base) \ .def("tan", tan_AD_##Base) \ - -# if 0 - // not available in cppad-20080919.0 will be in cppad-20090131.0 .def("tanh", tanh_AD_##Base) -# endif namespace pycppad { // Replacement for the CppAD error handler diff --git a/brad/setup.template b/brad/setup.template index e75b9ed..77781be 100644 --- a/brad/setup.template +++ b/brad/setup.template @@ -15,7 +15,20 @@ boost_python_lib = 'boost_python' # name of the library in that directory cppad_parent_dir = # cppad tarball and distribution directory will be here package_version = # date in yyyymmdd format corresonding to this distribution cppad_version = # version of CppAD corresponding to this version of pycppad +cppad_with_doc = # include documentation in CppAD download [yes/no] # --------------------------------------------------------------------- +if cppad_with_doc == 'yes' : + cppad_dir = 'cppad' + '-' + cppad_version + cppad_tarball = cppad_dir + '.cpl.tgz' +elif cppad_with_doc == 'no' : + cppad_dir = 'CppAD' + '-' + cppad_version + cppad_tarball = cppad_dir + '.tgz' +else : + print 'cppad_with_doc: ' + cppad_with_doc + ' is not a valid choice.' + exit(1) +cppad_include_dir = cppad_parent_dir + '/' + cppad_dir +# --------------------------------------------------------------------- + import os import sys from distutils.core import setup, Extension @@ -31,7 +44,6 @@ if not os.access ( boost_python_lib_path , os.R_OK ) : print 'at the beginnin of the file setup.py' # --------------------------------------------------------------------- # set cppad_include_dir -cppad_include_dir = cppad_parent_dir + '/' + 'cppad-' + cppad_version build_source_dist = False if len( sys.argv ) == 2 : if sys.argv[1] == 'sdist' : @@ -40,7 +52,6 @@ if not build_source_dist : if not os.access( cppad_include_dir , os.R_OK ) : print 'os.getcwd() = ' + os.getcwd() print 'Please wait while the proper version of CppAD is downloaded' - cppad_tarball = 'cppad-' + cppad_version + '.gpl.tgz' cppad_download_dir = 'http://www.coin-or.org/download/source/CppAD/' cmd = 'wget --no-clobber -P ' + cppad_parent_dir cmd = cmd + ' ' + cppad_download_dir + cppad_tarball