Skip to content

Commit

Permalink
Use newer version of CppAD and include tanh, improve doc indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad Bell committed Feb 13, 2009
1 parent 443ceeb commit 0a5ee6a
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 34 deletions.
11 changes: 7 additions & 4 deletions brad/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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" != "" ]
Expand Down
6 changes: 3 additions & 3 deletions brad/doc.omh
Original file line number Diff line number Diff line change
Expand Up @@ -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$$
Expand Down Expand Up @@ -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%
Expand All @@ -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%
Expand Down
8 changes: 2 additions & 6 deletions brad/example/std_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions brad/omh/ad_method.omh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$begin ad_variable$$

$section AD Variable Methods$$
$index ad, variable$$
$index variable, ad$$

$childtable%
pycppad/__init__.py%
Expand Down
22 changes: 11 additions & 11 deletions brad/omh/install.omh
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand All @@ -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
$$
Expand Down Expand Up @@ -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
$$
Expand All @@ -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%
%$$
Expand All @@ -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$$
Expand All @@ -152,7 +152,7 @@ $codei%
%$$
unless the distribution directory
$codep
pycppad-20090210
pycppad-20090213
$$
or (provided you installed $code pycppad$$) the installation directory
$codei%
Expand All @@ -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%
Expand Down
5 changes: 5 additions & 0 deletions brad/omh/license.omh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
$begin license$$
$spell
pycppad
$$

$section License$$
$index license, pycppad$$
$index pycppad, license$$

$verbatim%README%$$

Expand Down
11 changes: 11 additions & 0 deletions brad/omh/whats_new_09.omh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions brad/pycppad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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$$,
Expand Down
9 changes: 1 addition & 8 deletions brad/pycppad/pycppad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
$$
$section Absolute Value Functions$$
$index abs$$
$head Syntax$$
$icode%y% = abs(%x%)%$$
Expand Down Expand Up @@ -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) \
Expand All @@ -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
Expand Down
15 changes: 13 additions & 2 deletions brad/setup.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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' :
Expand All @@ -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
Expand Down

0 comments on commit 0a5ee6a

Please sign in to comment.