Changeset 3680


Ignore:
Timestamp:
May 7, 2015 3:17:37 PM (5 years ago)
Author:
bradbell
Message:

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: 071875a4beba3363e5fa9752426aec4762cd1caa
end hash code: 0bef506513a519e1073c6279d5c4cba9e5c3b180

commit 0bef506513a519e1073c6279d5c4cba9e5c3b180
Author: Brad Bell <bradbell@…>
Date: Thu May 7 12:14:32 2015 -0700

Add the acosh function (as an atomic operation when defined by compiler).

commit b3264fa17b2f65b65800423a0e243c9c3ccfe06a
Author: Brad Bell <bradbell@…>
Date: Wed May 6 20:25:38 2015 -0700

CMakeLists.txt: Change so test only check for compliation.

commit dcbac4d4f20cc383f2bd9edb02036659df40b791
Author: Brad Bell <bradbell@…>
Date: Wed May 6 15:06:28 2015 -0700

asinh.cpp: check higher orders, relax accuracy on test.

commit 5f8881993fedd18cccc3c74831133a8f8a9d17b0
Author: Brad Bell <bradbell@…>
Date: Wed May 6 14:36:18 2015 -0700

Change Acos to acos.
acos.cpp: remove trailing white space.

commit e828fa1f7c4c3848c727f14b1b7a8030071ee705
Author: Brad Bell <bradbell@…>
Date: Wed May 6 12:07:35 2015 -0700

Change Acos to acos.
acos.cpp: remove redundant index commands, remove trailing with space.

commit 3d16e5b9fe1bdafa4ad01d1d466bb72b792650fa
Author: Brad Bell <bradbell@…>
Date: Wed May 6 11:30:49 2015 -0700

op_code.hpp: Minor edits to AcosOp? commnets.

commit 58beaaad149b4ac29fae44589d7f8900bf8f4c40
Author: Brad Bell <bradbell@…>
Date: Wed May 6 10:51:43 2015 -0700

for_jac_sweep.hpp: Add missing AsinhOp? case.

commit 623c134870c522ae5e80bcf0f89d230902594c80
Author: Brad Bell <bradbell@…>
Date: Wed May 6 10:27:39 2015 -0700

Fix comment about AsinhOp? operator.

commit 226b14f6f4810f5abf1ca247aae541963efaf4d6
Author: Brad Bell <bradbell@…>
Date: Wed May 6 10:14:08 2015 -0700

Add derivative of F to make order zero case clearer.
acos_reverse.omh: Fix some sign errors.
asin_reverse.omh: Fix typo.
acos_forward.omh: Simplify by distributing minus sign.

commit 4682f4ee73e33b600b180086576e986f636a24dc
Author: Brad Bell <bradbell@…>
Date: Wed May 6 08:15:50 2015 -0700

acos_forward.omh: fix sign that depends on acos versus acosh.

commit 906ae10adf019ddda7f57dd165aab08fc55289c4
Author: Brad Bell <bradbell@…>
Date: Wed May 6 07:09:47 2015 -0700

  1. Fix inclusion of some temporary files in package (e.g., git_commit.sh).
  2. Simplify and improve using git ls-files and ls bin/check_*.
  3. Remove trailing white space.

commit 5096f4706a547bd76caa3766aa2c62802ef7f0bf
Author: Brad Bell <bradbell@…>
Date: Wed May 6 06:41:20 2015 -0700

Combine base type documentation for erf, asinh
(will add more functions to this list list).

commit b3535db5ad95bee90672abcaa686032d23bce2fc
Author: Brad Bell <bradbell@…>
Date: Tue May 5 18:01:11 2015 -0700

  1. Change Arc Cosine/Sine? to Inverse Cosine/Sine?.
  2. Change arcsin-> asin and arccos->acos.
  3. Remove index commands that are duplicates of words in titles.


acos_reverse.omh: Add acosh case to this page.

Location:
trunk
Files:
4 added
40 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/package.sh

    r3553 r3680  
    55#
    66# CppAD is distributed under multiple licenses. This distribution is under
    7 # the terms of the 
     7# the terms of the
    88#                     Eclipse Public License Version 1.0.
    99#
     
    6262# Run automated checking of file names in original source directory
    6363# (check_include_omh.sh uses files built by cmake)
    64 list="
    65         check_copyright.sh
    66         check_define.sh
    67         check_example.sh
    68         check_if.sh
    69         check_include_def.sh
    70         check_include_file.sh
    71         check_include_omh.sh
    72         check_makefile.sh
    73         check_op_code.sh
    74         check_replace.sh
    75         check_svn_id.sh
    76         check_verbatim.sh
    77 "
    78 for check in $list
     64list=`ls bin/check_* | sed \
     65        -e '/check_all.sh/d' \
     66        -e '/check_jenkins.sh/d' \
     67        -e '/check_svn_dist.sh/d'`
     68for check in $list
    7969do
    80         echo_log_eval bin/$check
     70        echo_log_eval $check
    8171done
    8272# ----------------------------------------------------------------------------
     
    10090# -----------------------------------------------------------------------------
    10191# Source file that are coppied to the package directory
    102 file_list=`find . \
    103         \( -name '*.ac' \) -or \
    104         \( -name '*.am' \) -or \
    105         \( -name '*.c' \) -or \
    106         \( -name '*.cmake' \) -or \
    107         \( -name '*.cpp' \) -or \
    108         \( -name '*.h' \) -or \
    109         \( -name '*.hpp' \) -or \
    110         \( -name '*.html' \) -or \
    111         \( -name '*.in' \) -or \
    112         \( -name '*.omh' \) -or \
    113         \( -name '*.pc' \) -or \
    114         \( -name '*.py' \) -or \
    115         \( -name '*.sed' \) -or \
    116         \( -name '*.sh' \) -or \
    117         \( -name '*.txt' \) | sed \
    118                 -e '/\/new\//d' \
    119                 -e '/\.\/build\//d' \
    120                 -e '/bug\/build\//d' \
    121                 -e '/\/junk\.[a-z]*$/d' \
    122                 -e '/\/temp\.[a-z]*$/d' \
    123                 -e 's|^\./||'`
    124 other_files="
    125         AUTHORS
    126         ChangeLog
    127         configure
    128         config.guess
    129         config.sub
    130         COPYING
    131         depcomp
    132         INSTALL
    133         NEWS
    134         README
    135 "
     92file_list=`git ls-files`
    13693#
    13794# Copy the files, creating sub-directories when necessary
     
    150107done
    151108echo_log_eval echo "remove certain files from $package_dir"
    152 for file in $remove_list 
     109for file in $remove_list
    153110do
    154111        if [ -e $package_dir/$file ]
    155112        then
    156                 echo_log_eval rm $package_dir/$file 
     113                echo_log_eval rm $package_dir/$file
    157114        fi
    158115done
     
    164121# So remove the table at the top (but save the original doc.omh file).
    165122if ! grep < doc.omh > /dev/null \
    166         'This comment is used to remove the table below' 
     123        'This comment is used to remove the table below'
    167124then
    168125        echo "Missing comment expected in doc.omh"
  • trunk/cppad/CMakeLists.txt

    r3675 r3680  
    147147# -----------------------------------------------------------------------------
    148148# cppad_compiler_has_erf
     149# cppad_compiler_has_acosh
    149150# cppad_compiler_has_asinh
    150151#
     
    152153# include <cmath>
    153154int main(void)
    154 {       if( std::c11_function(0.0) == 0.0 )
    155                 return 0;
    156         return 1;
    157 }
    158 "
    159 )
    160 FOREACH(c11_function erf asinh)
     155{       std::c11_function(0.0);
     156        return 0;
     157}
     158"
     159)
     160FOREACH(c11_function erf acosh asinh)
    161161        STRING(REPLACE "c11_function" ${c11_function} source "${source_template}" )
     162        # really only checking if program compiles
    162163        check_source_runs("${source}" cppad_compiler_has_${c11_function} )
    163 ENDFOREACH(c11_function erf asinh)
     164ENDFOREACH(c11_function erf acosh asinh)
    164165# -----------------------------------------------------------------------------
    165166# cppad_has_high_resolution_clock
  • trunk/cppad/configure.hpp.in

    r3675 r3680  
    6969*/
    7070# define CPPAD_COMPILER_HAS_ERF @cppad_compiler_has_erf@
     71# endif
     72
     73# if __cplusplus >= 201100
     74/*!
     75\def CPPAD_COMPILER_HAS_ACOSH
     76C++11: Does compiler support std::acosh(double)
     77*/
     78# define CPPAD_COMPILER_HAS_ACOSH @cppad_compiler_has_acosh@
    7179# endif
    7280
  • trunk/cppad/example/base_adolc.hpp

    r3675 r3680  
    1515$begin base_adolc.hpp$$
    1616$spell
     17        acosh
    1718        asinh
    1819        erf
     
    217218$code tan$$.
    218219
    219 $head asinh$$
    220 If the inverse hyperbolic sine function is supported by the compiler,
    221 it must also be supported by a $icode Base$$ type;
    222 see $cref/asinh/base_std_math/asinh/$$.
    223 The adolc package does not support this function:
    224 $codep */
    225 namespace CppAD {
     220$head erf, asin$$
     221If the
     222$cref/erf, asinh, acosh/base_std_math/erf, asinh, acosh/$$,
     223functions are supported by the compiler,
     224they must also be supported by a $icode Base$$ type;
     225The adolc package does not support these functions so make
     226their use an error:
     227$codep */
     228namespace CppAD {
     229# define CPPAD_BASE_ADOLC_NO_SUPPORT(fun)                         \
     230    inline adouble fun(const adouble& x)                          \
     231    {   CPPAD_ASSERT_KNOWN(                                       \
     232            false,                                                \
     233            #fun ": adolc does not support this function"         \
     234        );                                                        \
     235        return 0.0;                                               \
     236    }
     237# if CPPAD_COMPILER_HAS_ERF
     238        CPPAD_BASE_ADOLC_NO_SUPPORT(erf)
     239# endif
     240# if CPPAD_COMPILER_HAS_ACOSH
     241        CPPAD_BASE_ADOLC_NO_SUPPORT(acosh)
     242# endif
    226243# if CPPAD_COMPILER_HAS_ASINH
    227         inline adouble asinh(const adouble& x)
    228         {       CPPAD_ASSERT_KNOWN(
    229                         false,
    230                         "erf: adolc does not support the inverse hyperbolic sine function"
    231                 );
    232                 return 0;
    233         }
     244        CPPAD_BASE_ADOLC_NO_SUPPORT(asinh)
    234245# endif
    235 }
    236 /* $$
    237 
    238 $head erf$$
    239 If the error function is supported by the compiler,
    240 it must also be supported by a $icode Base$$ type;
    241 see $cref/erf/base_std_math/erf/$$.
    242 The adolc package does not support this function:
    243 $codep */
    244 namespace CppAD {
    245 # if CPPAD_COMPILER_HAS_ERF
    246         inline adouble erf(const adouble& x)
    247         {       CPPAD_ASSERT_KNOWN(
    248                         false,
    249                         "erf: adolc does not support the error function"
    250                 );
    251                 return 0;
    252         }
    253 # endif
    254 }
    255 /* $$
    256 
    257 
     246# undef CPPAD_BASE_ADOLC_NO_SUPPORT
     247}
     248/* $$
    258249
    259250$head sign$$
  • trunk/cppad/local/ad.hpp

    r3675 r3680  
    212212        inline AD erf(void) const;
    213213# endif
     214# if CPPAD_COMPILER_HAS_ACOSH
     215        inline AD acosh(void) const;
     216# endif
    214217
    215218        // ----------------------------------------------------------
  • trunk/cppad/local/asinh_op.hpp

    r3678 r3680  
    2424
    2525/*!
    26 Compute forward mode Taylor coefficient for result of op = AsinOp.
     26Compute forward mode Taylor coefficient for result of op = AsinhOp.
    2727
    2828The C++ source code corresponding to this operation is
     
    4949{
    5050        // check assumptions
    51         CPPAD_ASSERT_UNKNOWN( NumArg(AsinOp) == 1 );
    52         CPPAD_ASSERT_UNKNOWN( NumRes(AsinOp) == 2 );
     51        CPPAD_ASSERT_UNKNOWN( NumArg(AsinhOp) == 1 );
     52        CPPAD_ASSERT_UNKNOWN( NumRes(AsinhOp) == 2 );
    5353        CPPAD_ASSERT_UNKNOWN( q < cap_order );
    5454        CPPAD_ASSERT_UNKNOWN( p <= q );
     
    8888}
    8989/*!
    90 Multiple directions forward mode Taylor coefficient for op = AsinOp.
     90Multiple directions forward mode Taylor coefficient for op = AsinhOp.
    9191
    9292The C++ source code corresponding to this operation is
     
    142142
    143143/*!
    144 Compute zero order forward mode Taylor coefficient for result of op = AsinOp.
     144Compute zero order forward mode Taylor coefficient for result of op = AsinhOp.
    145145
    146146The C++ source code corresponding to this operation is
     
    164164{
    165165        // check assumptions
    166         CPPAD_ASSERT_UNKNOWN( NumArg(AsinOp) == 1 );
    167         CPPAD_ASSERT_UNKNOWN( NumRes(AsinOp) == 2 );
     166        CPPAD_ASSERT_UNKNOWN( NumArg(AsinhOp) == 1 );
     167        CPPAD_ASSERT_UNKNOWN( NumRes(AsinhOp) == 2 );
    168168        CPPAD_ASSERT_UNKNOWN( 0 < cap_order );
    169169
     
    177177}
    178178/*!
    179 Compute reverse mode partial derivatives for result of op = AsinOp.
     179Compute reverse mode partial derivatives for result of op = AsinhOp.
    180180
    181181The C++ source code corresponding to this operation is
     
    203203{
    204204        // check assumptions
    205         CPPAD_ASSERT_UNKNOWN( NumArg(AsinOp) == 1 );
    206         CPPAD_ASSERT_UNKNOWN( NumRes(AsinOp) == 2 );
     205        CPPAD_ASSERT_UNKNOWN( NumArg(AsinhOp) == 1 );
     206        CPPAD_ASSERT_UNKNOWN( NumRes(AsinhOp) == 2 );
    207207        CPPAD_ASSERT_UNKNOWN( d < cap_order );
    208208        CPPAD_ASSERT_UNKNOWN( d < nc_partial );
  • trunk/cppad/local/base_complex.hpp

    r3675 r3680  
    2222$begin base_complex.hpp$$
    2323$spell
     24        acosh
    2425        asinh
    2526        endif
     
    248249        CPPAD_USER_MACRO(asinh)
    249250# endif
     251# if CPPAD_COMPILER_HAS_ACOSH
     252        CPPAD_USER_MACRO(acosh)
     253# endif
    250254}
    251255/* $$
  • trunk/cppad/local/base_double.hpp

    r3675 r3680  
    1818$begin base_double.hpp$$
    1919$spell
     20        acosh
    2021        asinh
    2122        erf
     
    150151        CPPAD_STANDARD_MATH_UNARY(double, asinh)
    151152# endif
     153# if CPPAD_COMPILER_HAS_ACOSH
     154        CPPAD_STANDARD_MATH_UNARY(double, acosh)
     155# endif
    152156# if CPPAD_COMPILER_HAS_ERF
    153157        CPPAD_STANDARD_MATH_UNARY(double, erf)
  • trunk/cppad/local/base_float.hpp

    r3675 r3680  
    1818$begin base_float.hpp$$
    1919$spell
     20        acosh
    2021        asinh
    2122        erf
     
    151152        CPPAD_STANDARD_MATH_UNARY(float, asinh)
    152153# endif
     154# if CPPAD_COMPILER_HAS_ACOSH
     155        CPPAD_STANDARD_MATH_UNARY(float, acosh)
     156# endif
    153157# if CPPAD_COMPILER_HAS_ERF
    154158        CPPAD_STANDARD_MATH_UNARY(float, erf)
  • trunk/cppad/local/base_std_math.hpp

    r3675 r3680  
    1717$begin base_std_math$$
    1818$spell
     19        acosh
    1920        asinh
    2021        inline
     
    9192$cref/float/base_float.hpp/Unary Standard Math/$$.
    9293
    93 $head asinh$$
    94 If the inverse hyperbolic sine function is supported by the compiler,
    95 $cref/CPPAD_COMPILER_HAS_ASINH/asinh/CPPAD_COMPILER_HAS_ASINH/$$
    96 is one,
     94$head erf, asinh, acosh$$
     95The following preprocessor symbols are one (true) and zero (false)
     96if the corresponding function is supported by the compiler.
     97$table
     98$icode%fun%   %$$ $cnext  $icode symbol$$                $rnext
     99$code erf$$       $cnext  $code CPPAD_COMPILER_HAS_ERF$$ $rnext
     100$code asinh$$     $cnext  $code CPPAD_COMPILER_HAS_ASINH$$
     101$code acosh$$     $cnext  $code CPPAD_COMPILER_HAS_ACOSH$$
     102$tend
     103If the corresponding symbol is true,
    97104the type $icode Base$$ must support the syntax
    98105$codei%
    99         %y% = CppAD::asinh(%x%)
     106        %y% = CppAD::%fun%(%x%)
    100107%$$
    101108where $icode x$$ and $icode y$$ have the same prototype as above.
    102109For example, see
    103 $cref/base_alloc/base_alloc.hpp/asinh/$$.
    104 
    105 $head erf$$
    106 $index erf, base require$$
    107 $index base, erf require$$
    108 $index require, base erf$$
    109 If the error function is supported by the compiler,
    110 $cref/CPPAD_COMPILER_HAS_ERF/erf/Method/CPPAD_COMPILER_HAS_ERF/$$
    111 is one,
    112 the type $icode Base$$ must support the syntax
    113 $codei%
    114         %y% = CppAD::erf(%x%)
    115 %$$
    116 where $icode x$$ and $icode y$$ have the same prototype as above.
    117 For example, see
    118 $cref/base_alloc/base_alloc.hpp/erf/$$.
     110$cref/base_alloc/base_alloc.hpp/erf, asinh, acosh/$$.
    119111
    120112$head sign$$
  • trunk/cppad/local/for_jac_sweep.hpp

    r3638 r3680  
    232232                        // -------------------------------------------------
    233233
     234# if CPPAD_COMPILER_HAS_ACOSH
     235                        case AcoshOp:
     236                        // sqrt(x * x - 1), acosh(x)
     237                        CPPAD_ASSERT_NARG_NRES(op, 1, 2);
     238                        forward_sparse_jacobian_unary_op(
     239                                i_var, arg[0], var_sparsity
     240                        );
     241                        break;
     242# endif
     243                        // -------------------------------------------------
     244
    234245                        case AsinOp:
    235246                        // sqrt(1 - x * x), asin(x)
     
    239250                        );
    240251                        break;
     252                        // -------------------------------------------------
     253
     254# if CPPAD_COMPILER_HAS_ASINH
     255                        case AsinhOp:
     256                        // sqrt(1 + x * x), asinh(x)
     257                        CPPAD_ASSERT_NARG_NRES(op, 1, 2);
     258                        forward_sparse_jacobian_unary_op(
     259                                i_var, arg[0], var_sparsity
     260                        );
     261                        break;
     262# endif
    241263                        // -------------------------------------------------
    242264
  • trunk/cppad/local/forward0sweep.hpp

    r3678 r3680  
    310310                        // -------------------------------------------------
    311311
     312# if CPPAD_COMPILER_HAS_ACOSH
     313                        case AcoshOp:
     314                        // sqrt(x * x - 1), acosh(x)
     315                        CPPAD_ASSERT_UNKNOWN( i_var < numvar  );
     316                        forward_acosh_op_0(i_var, arg[0], J, taylor);
     317                        break;
     318# endif
     319                        // -------------------------------------------------
     320
    312321                        case AsinOp:
    313322                        // sqrt(1 - x * x), asin(x)
     
    319328# if CPPAD_COMPILER_HAS_ASINH
    320329                        case AsinhOp:
    321                         // sqrt(1 - x * x), asin(x)
     330                        // sqrt(1 + x * x), asinh(x)
    322331                        CPPAD_ASSERT_UNKNOWN( i_var < numvar  );
    323332                        forward_asinh_op_0(i_var, arg[0], J, taylor);
  • trunk/cppad/local/forward1sweep.hpp

    r3678 r3680  
    360360                        // -------------------------------------------------
    361361
     362# if CPPAD_COMPILER_HAS_ACOSH
     363                        case AcoshOp:
     364                        // sqrt(x * x - 1), acosh(x)
     365                        CPPAD_ASSERT_UNKNOWN( i_var < numvar  );
     366                        forward_acosh_op(p, q, i_var, arg[0], J, taylor);
     367                        break;
     368# endif
     369                        // -------------------------------------------------
     370
    362371                        case AsinOp:
    363372                        // sqrt(1 - x * x), asin(x)
     
    369378# if CPPAD_COMPILER_HAS_ASINH
    370379                        case AsinhOp:
    371                         // sqrt(1 + x * x), asin(x)
     380                        // sqrt(1 + x * x), asinh(x)
    372381                        CPPAD_ASSERT_UNKNOWN( i_var < numvar  );
    373382                        forward_asinh_op(p, q, i_var, arg[0], J, taylor);
  • trunk/cppad/local/forward2sweep.hpp

    r3678 r3680  
    269269                        // -------------------------------------------------
    270270
     271# if CPPAD_COMPILER_HAS_ACOSH
     272                        case AcoshOp:
     273                        // sqrt(x * x - 1), acosh(x)
     274                        CPPAD_ASSERT_UNKNOWN( i_var < numvar  );
     275                        forward_acosh_op_dir(q, r, i_var, arg[0], J, taylor);
     276                        break;
     277# endif
     278                        // -------------------------------------------------
     279
    271280                        case AsinOp:
    272281                        // sqrt(1 - x * x), asin(x)
     
    278287# if CPPAD_COMPILER_HAS_ASINH
    279288                        case AsinhOp:
    280                         // sqrt(1 + x * x), asin(x)
     289                        // sqrt(1 + x * x), asinh(x)
    281290                        CPPAD_ASSERT_UNKNOWN( i_var < numvar  );
    282291                        forward_asinh_op_dir(q, r, i_var, arg[0], J, taylor);
  • trunk/cppad/local/hash_code.hpp

    r3675 r3680  
    8080
    8181\li unary operators:
    82 AbsOp, AcosOp, AsinOp, AsinhOp, AtanOp, CosOp, CoshOp
     82AbsOp, AcosOp, AcoshOp, AsinOp, AsinhOp, AtanOp, CosOp, CoshOp
    8383ExpOp, LogOp, SinOp, SinhOp, SqrtOp, TanOp, TanhOp
    8484
     
    214214                case AbsOp:
    215215                case AcosOp:
     216                case AcoshOp:
    216217                case AsinOp:
    217218                case AsinhOp:
  • trunk/cppad/local/math_other.hpp

    r3675 r3680  
    2828        cppad/local/abs.hpp%
    2929        cppad/local/asinh.hpp%
     30        cppad/local/acosh.hpp%
    3031        cppad/local/sign.hpp%
    3132        cppad/local/atan2.hpp%
     
    4041# include <cppad/local/abs.hpp>
    4142# include <cppad/local/asinh.hpp>
     43# include <cppad/local/acosh.hpp>
    4244# include <cppad/local/sign.hpp>
    4345# include <cppad/local/atan2.hpp>
  • trunk/cppad/local/op.hpp

    r3675 r3680  
    2222# include <cppad/local/add_op.hpp>
    2323# include <cppad/local/acos_op.hpp>
     24# include <cppad/local/acosh_op.hpp>
    2425# include <cppad/local/asin_op.hpp>
    2526# include <cppad/local/asinh_op.hpp>
  • trunk/cppad/local/op_code.hpp

    r3675 r3680  
    4949enum OpCode {
    5050        AbsOp,    //  abs(variable)
    51         AcosOp,   // asin(variable)
     51        AcosOp,   // acos(variable)
     52        AcoshOp,   // acosh(variable)
    5253        AddpvOp,  //      parameter  + variable
    5354        AddvvOp,  //      variable   + variable
     
    158159OpCode   j   NumArgTable[j]  Meaning
    159160AbsOp    0                1  index of variable we are taking absolute value of
    160 AcosOp   1                1  index of variable we are taking cosine of
    161 AddpvOp  1                2  indices of parameter and variable we are adding
     161AcosOp   1                1  index of variable we are taking acos of
     162AcoshOp  2                1  index of variable we are taking acosh of
    162163\endverbatim
    163164Note that the meaning of the arguments depends on the operator.
     
    170171                1, // AbsOp
    171172                1, // AcosOp
     173                1, // AcoshOp
    172174                2, // AddpvOp
    173175                2, // AddvvOp
     
    261263AbsOp    0                1  variable that is the result of the absolute value
    262264AcosOp   1                2  acos(x) and sqrt(1-x*x) are required for this op
    263 AddpvOp  1                1  variable that is the result of the addition
     265AcoshOp  2                2  acosh(x) and sqrt(x*x-1) are required for this op
    264266\endverbatim
    265267*/
     
    271273                1, // AbsOp
    272274                2, // AcosOp
     275                2, // AcoshOp
    273276                1, // AddpvOp
    274277                1, // AddvvOp
     
    355358                "Abs"   ,
    356359                "Acos"  ,
     360                "Acosh" ,
    357361                "Addpv" ,
    358362                "Addvv" ,
     
    684688                case AbsOp:
    685689                case AcosOp:
     690                case AcoshOp:
    686691                case AsinOp:
    687692                case AsinhOp:
     
    881886                // 1 argument, 2 results
    882887                case AcosOp:
     888                case AcoshOp:
    883889                case AsinOp:
    884890                case AsinhOp:
  • trunk/cppad/local/optimize.hpp

    r3675 r3680  
    15461546                        case AbsOp:
    15471547                        case AcosOp:
     1548                        case AcoshOp:
    15481549                        case AsinOp:
    15491550                        case AsinhOp:
     
    23102311                        case AbsOp:
    23112312                        case AcosOp:
     2313                        case AcoshOp:
    23122314                        case AsinOp:
    23132315                        case AsinhOp:
  • trunk/cppad/local/rev_hes_sweep.hpp

    r3678 r3680  
    252252                        );
    253253                        break;
     254                        // -------------------------------------------------
     255
     256# if CPPAD_COMPILER_HAS_ACOSH
     257                        case AcoshOp:
     258                        // sqrt(x * x - 1), acosh(x)
     259                        CPPAD_ASSERT_NARG_NRES(op, 1, 2)
     260                        reverse_sparse_hessian_nonlinear_unary_op(
     261                        i_var, arg[0], RevJac, for_jac_sparse, rev_hes_sparse
     262                        );
     263                        break;
     264# endif
    254265                        // -------------------------------------------------
    255266
  • trunk/cppad/local/rev_jac_sweep.hpp

    r3678 r3680  
    241241                        );
    242242                        break;
     243                        // -------------------------------------------------
     244
     245# if CPPAD_COMPILER_HAS_ACOSH
     246                        case AcoshOp:
     247                        // sqrt(x * x - 1), acosh(x)
     248                        CPPAD_ASSERT_NARG_NRES(op, 1, 2);
     249                        reverse_sparse_jacobian_unary_op(
     250                                i_var, arg[0], var_sparsity
     251                        );
     252                        break;
     253# endif
    243254                        // -------------------------------------------------
    244255
  • trunk/cppad/local/reverse_sweep.hpp

    r3678 r3680  
    309309                        // --------------------------------------------------
    310310
     311# if CPPAD_COMPILER_HAS_ACOSH
     312                        case AcoshOp:
     313                        // sqrt(x * x - 1), acosh(x)
     314                        CPPAD_ASSERT_UNKNOWN( i_var < numvar );
     315                        reverse_acosh_op(
     316                                d, i_var, arg[0], J, Taylor, K, Partial
     317                        );
     318                        break;
     319# endif
     320                        // --------------------------------------------------
     321
    311322                        case AddvvOp:
    312323                        reverse_addvv_op(
     
    335346# if CPPAD_COMPILER_HAS_ASINH
    336347                        case AsinhOp:
    337                         // sqrt(1 - x * x), asin(x)
     348                        // sqrt(1 + x * x), asinh(x)
    338349                        CPPAD_ASSERT_UNKNOWN( i_var < numvar );
    339350                        reverse_asinh_op(
  • trunk/cppad/local/std_math_ad.hpp

    r3675 r3680  
    1717$begin std_math_ad$$
    1818$spell
     19        acosh
    1920        Vec
    2021        std
     
    318319     CPPAD_STANDARD_MATH_UNARY_AD(asinh, AsinhOp)
    319320# endif
     321# if CPPAD_COMPILER_HAS_ACOSH
     322     CPPAD_STANDARD_MATH_UNARY_AD(acosh, AcoshOp)
     323# endif
    320324
    321325# if CPPAD_COMPILER_HAS_ERF
  • trunk/cppad/local/undef.hpp

    r3675 r3680  
    2727# undef CPPAD_BOOL_UNARY          in user api
    2828# undef CPPAD_COMPILER_HAS_ASINH  in user api
     29# undef CPPAD_COMPILER_HAS_ACOSH  in user api
    2930# undef CPPAD_COMPILER_HAS_ERF    in user api
    3031# undef CPPAD_DISCRETE_FUNCTION   in user api
  • trunk/example/CMakeLists.txt

    r3675 r3680  
    7777        abs.cpp
    7878        acos.cpp
     79        acosh.cpp
    7980        add.cpp
    8081        add_eq.cpp
  • trunk/example/acos.cpp

    r2506 r3680  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
    6 the terms of the 
     6the terms of the
    77                    Eclipse Public License Version 1.0.
    88
     
    1212
    1313/*
    14 $begin Acos.cpp$$
     14$begin acos.cpp$$
    1515$spell
    1616        cos
     
    1919
    2020$section The AD acos Function: Example and Test$$
    21 
    22 $index acos, AD example$$
    23 $index example, AD acos$$
    24 $index test, AD acos$$
    2521
    2622$code
     
    3430# include <cppad/cppad.hpp>
    3531
    36 bool Acos(void)
     32bool acos(void)
    3733{       bool ok = true;
    3834
    3935        using CppAD::AD;
    4036        using CppAD::NearEqual;
     37
     38        // 10 times machine epsilon
     39        double eps = 10. * std::numeric_limits<double>::epsilon();
    4140
    4241        // domain space vector
     
    5251        AD<double> cos_of_x0 = CppAD::cos(x[0]);
    5352
    54         // range space vector 
     53        // range space vector
    5554        size_t m = 1;
    5655        CPPAD_TESTVECTOR(AD<double>) y(m);
     
    5857
    5958        // create f: x -> y and stop tape recording
    60         CppAD::ADFun<double> f(x, y); 
     59        CppAD::ADFun<double> f(x, y);
    6160
    62         // check value 
    63         ok &= NearEqual(y[0] , x0,  1e-10 , 1e-10);
     61        // check value
     62        ok &= NearEqual(y[0] , x0,  eps, eps);
    6463
    6564        // forward computation of first partial w.r.t. x[0]
     
    6867        dx[0] = 1.;
    6968        dy    = f.Forward(1, dx);
    70         ok   &= NearEqual(dy[0], 1., 1e-10, 1e-10);
     69        ok   &= NearEqual(dy[0], 1., eps, eps);
    7170
    7271        // reverse computation of derivative of y[0]
     
    7574        w[0]  = 1.;
    7675        dw    = f.Reverse(1, w);
    77         ok   &= NearEqual(dw[0], 1., 1e-10, 1e-10);
     76        ok   &= NearEqual(dw[0], 1., eps, eps);
    7877
    7978        // use a VecAD<Base>::reference object with acos
     
    8281        v[zero] = cos_of_x0;
    8382        AD<double> result = CppAD::acos(v[zero]);
    84         ok     &= NearEqual(result, x0, 1e-10, 1e-10);
     83        ok     &= NearEqual(result, x0, eps, eps);
    8584
    8685        return ok;
  • trunk/example/base_alloc.hpp

    r3675 r3680  
    1515$begin base_alloc.hpp$$
    1616$spell
     17        acosh
    1718        asinh
    1819        Rel
     
    302303/* $$
    303304
    304 $head asinh$$
    305 The following defines the $code CppAD::asinh$$ function that
    306 is required th use $code AD<Base_alloc>$$:
    307 $codep */
     305$head erf, asinh, acosh$$
     306The following defines the
     307$cref/erf, asinh, acosh/base_std_math/erf, asinh, acosh/$$ functions
     308required by $code AD<base_alloc>$$:
     309$codep */
     310# if CPPAD_COMPILER_HAS_ERF
     311        BASE_ALLOC_STD_MATH(erf)
     312# endif
     313# if CPPAD_COMPILER_HAS_ACOSH
     314        BASE_ALLOC_STD_MATH(acosh)
     315# endif
    308316# if CPPAD_COMPILER_HAS_ASINH
    309         inline base_alloc asinh(const base_alloc& x)
    310         {       return std::asinh(*x.ptrdbl_); }
    311 # endif
    312 /* $$
    313 
    314 $head erf$$
    315 The following defines the $code CppAD::erf$$ function that
    316 is required th use $code AD<Base_alloc>$$:
    317 $codep */
    318 # if CPPAD_COMPILER_HAS_ERF
    319         inline base_alloc erf(const base_alloc& x)
    320         {       return std::erf(*x.ptrdbl_); }
     317        BASE_ALLOC_STD_MATH(asinh)
    321318# endif
    322319/* $$
  • trunk/example/example.cpp

    r3675 r3680  
    4949extern bool ad_ctor(void);
    5050extern bool abs(void);
    51 extern bool Acos(void);
     51extern bool acos(void);
     52extern bool acosh(void);
    5253extern bool Add(void);
    5354extern bool AddEq(void);
     
    213214        ok &= Run( ad_ctor,           "ad_ctor"          );
    214215        ok &= Run( abs,               "abs"              );
    215         ok &= Run( Acos,              "Acos"             );
     216        ok &= Run( acos,              "acos"             );
     217        ok &= Run( acosh,             "acosh"            );
    216218        ok &= Run( Add,               "Add"              );
    217219        ok &= Run( AddEq,             "AddEq"            );
  • trunk/example/makefile.am

    r3679 r3680  
    8383        abs.cpp \
    8484        acos.cpp \
     85        acosh.cpp \
    8586        add.cpp \
    8687        add_eq.cpp \
  • trunk/makefile.am

    r3675 r3680  
    126126        cppad/local/abs_op.hpp \
    127127        cppad/local/acos_op.hpp \
     128        cppad/local/acosh.hpp \
     129        cppad/local/acosh_op.hpp \
    128130        cppad/local/ad_assign.hpp \
    129131        cppad/local/ad_binary.hpp \
  • trunk/omh/theory/acos_forward.omh

    r3679 r3680  
    2121$$
    2222
    23 $section Arc Cosine and Hyperbolic Cosine Forward Taylor Polynomial Theory$$
     23$section Inverse Cosine and Hyperbolic Cosine Forward Mode Theory$$
    2424$mindex acos, acosh$$
    2525
     
    2727$latex \[
    2828\begin{array}{rcl}
    29 \R{arccos}^{(1)} (x)  & = & - 1 / \sqrt{ 1 - x * x }
     29\R{acos}^{(1)} (x)  & = & - 1 / \sqrt{ 1 - x * x }
    3030\\
    31 \R{arccosh}^{(1)} (x) & = & + 1 / \sqrt{ x * x - 1}
     31\R{acosh}^{(1)} (x) & = & + 1 / \sqrt{ x * x - 1}
    3232\end{array}
    3333\] $$
    34 If $latex F(x)$$ is $latex \R{arccos} (x)$$ or $latex \R{arccosh} (x)$$
     34If $latex F(x)$$ is $latex \R{acos} (x)$$ or $latex \R{acosh} (x)$$
    3535the corresponding derivative satisfies the equation
    3636$latex \[
     
    109109\right)
    110110\\
    111 z^{(j+1)} & = & - \frac{1}{j+1} \frac{1}{ b^{(0)} }
     111z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} }
    112112\left(
    113         (j+1) x^{(j+1)}
    114         + \sum_{k=1}^j k z^{(k)}  b^{(j+1-k)}
     113        \mp (j+1) x^{(j+1)}
     114        - \sum_{k=1}^j k z^{(k)}  b^{(j+1-k)}
    115115\right)
    116116\end{array}
  • trunk/omh/theory/acos_reverse.omh

    r3679 r3680  
    1515$begin acos_reverse$$
    1616$spell
     17        acosh
    1718        acos
    1819        Taylor
    19         Arccosine
    2020$$
    2121
    22 $index acos, reverse theory$$
    23 $index theory, acos reverse$$
    24 $index reverse, acos theory$$
    25 
    26 $section Arccosine Function Reverse Mode Theory$$
     22$section Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory$$
     23$mindex acos, acosh$$
    2724
    2825
    2926We use the reverse theory
    30 $xref%
    31         ReverseTheory%
    32         Standard Math Functions%
    33         standard math function
     27$cref%standard math function
     28        %ReverseTheory
     29        %Standard Math Functions
    3430%$$
    3531definition for the functions $latex H$$ and $latex G$$.
    36 In addition,
    37 
    38 we use $latex q$$ and $latex b$$
    39 for the $th p$$ order Taylor coefficient
    40 row vectors corresponding to functions
     32In addition, we use the forward mode notation in
     33$cref acos_forward$$ for
    4134$latex \[
    4235\begin{array}{rcl}
    43         Q(t) & = & 1 - X(t) * X(t) \\
     36        Q(t) & = & \mp ( X(t) * X(t) - 1 ) \\
    4437        B(t) & = & \sqrt{ Q(t) }
    4538\end{array}
    4639\] $$
     40We use $latex q$$ and $latex b$$
     41for the $th p$$ order Taylor coefficient
     42row vectors corresponding to these functions
    4743and replace $latex z^{(j)}$$ by
    4844$latex \[
     
    5046\] $$
    5147in the definition for $latex G$$ and $latex H$$.
    52 The forward mode formulas for the
     48The zero order forward mode formulas for the
    5349$cref/acos/acos_forward/$$
    5450function are
    5551$latex \[
    5652\begin{array}{rcl}
    57         q^{(0)}  & = & 1 - x^{(0)} x^{(0)} \\
    58         b^{(j)}  & = & \sqrt{ q^{(0)} }    \\
    59         z^{(j)}  & = & \arccos ( x^{(0)} )
     53        q^{(0)}  & = & \mp ( x^{(0)} x^{(0)} - 1) \\
     54        b^{(0)}  & = & \sqrt{ q^{(0)} }    \\
     55        z^{(0)}  & = & F ( x^{(0)} )
    6056\end{array}
    6157\] $$
    62 
    63 for the case $latex j = 0$$, and for $latex j > 0$$,
    64 
     58where $latex F(x) = \R{acos} (x)$$ for $latex -$$
     59and $latex F(x) = \R{acosh} (x) $$ for $latex +$$.
     60For orders $latex j$$ greater than zero we have
    6561$latex \[
    6662\begin{array}{rcl}
    6763q^{(j)} & = &
    68         - \sum_{k=0}^j x^{(k)} x^{(j-k)}
     64        \mp \sum_{k=0}^j x^{(k)} x^{(j-k)}
    6965\\
    7066b^{(j)} & = &
     
    7571        \right)
    7672\\
    77 z^{(j)} & = & - \frac{1}{j} \frac{1}{ b^{(0)} }
     73z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} }
    7874\left(
    79         j x^{(j)}
    80         + \sum_{k=1}^{j-1} k z^{(k)}  b^{(j-k)}
     75        \mp j x^{(j)}
     76        - \sum_{k=1}^{j-1} k z^{(k)}  b^{(j-k)}
    8177\right)
    8278\end{array}
    8379\] $$
    8480
    85 If $latex j = 0$$, we have the relation
     81If $latex j = 0$$, we note that
     82$latex F^{(1)} ( x^{(0)} ) =  \mp 1 / b^{(0)}$$ and hence
    8683
    8784$latex \[
    8885\begin{array}{rcl}
    8986\D{H}{ x^{(j)} } & = &
    90 \D{G}{ x^{(0)} }
     87\D{G}{ x^{(j)} }
    9188+ \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} }
    9289+ \D{G}{ b^{(j)} } \D{ b^{(j)} }{ q^{(0)} } \D{ q^{(0)} }{ x^{(0)} }
     
    9491& = &
    9592\D{G}{ x^{(j)} }
    96 - \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} }
    97 - \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} }
     93\mp \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} }
     94\mp \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} }
    9895\end{array}
    9996\] $$
     
    120117& = &
    121118\D{G}{ x^{(0)} }
    122 - \D{G}{ b^{(j)} } \frac{ x^{(j)} }{ b^{(0)} }
     119\mp \D{G}{ b^{(j)} } \frac{ x^{(j)} }{ b^{(0)} }
    123120\\
    124121\D{H}{ x^{(j)} } & = &
     
    129126& = &
    130127\D{G}{ x^{(j)} }
    131 - \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} }
    132 - \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} }
     128\mp \D{G}{ z^{(j)} } \frac{1}{ b^{(0)} }
     129\mp \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} }
    133130\\
    134131\D{H}{ b^{(j - k)} } & = &
     
    149146& = &
    150147\D{G}{ x^{(k)} }
    151 - \D{G}{ b^{(j)} } \frac{ x^{(j-k)} }{ b^{(0)} }
     148\mp \D{G}{ b^{(j)} } \frac{ x^{(j-k)} }{ b^{(0)} }
    152149\\
    153150\D{H}{ z^{(k)} } & = &
  • trunk/omh/theory/asin_forward.omh

    r3679 r3680  
    1717        asinh
    1818        asin
    19         Arcsine
    2019        Taylor
    2120$$
    2221
    23 $section Arc Sine and Hyperbolic Sine Forward Taylor Polynomial Theory$$
     22$section Inverse Sine and Hyperbolic Sine Forward Mode Theory$$
    2423$mindex asin, asinh$$
    2524
     
    2726$latex \[
    2827\begin{array}{rcl}
    29 \R{arcsin}^{(1)} (x)  & = & 1 / \sqrt{ 1 - x * x }
     28\R{asin}^{(1)} (x)  & = & 1 / \sqrt{ 1 - x * x }
    3029\\
    31 \R{arcsinh}^{(1)} (x) & = & 1 / \sqrt{ 1 + x * x }
     30\R{asinh}^{(1)} (x) & = & 1 / \sqrt{ 1 + x * x }
    3231\end{array}
    3332\] $$
    34 If $latex F(x)$$ is $latex \R{arcsin} (x) $$ or $latex \R{arcsinh} (x)$$
     33If $latex F(x)$$ is $latex \R{asin} (x) $$ or $latex \R{asinh} (x)$$
    3534the corresponding derivative satisfies the equation
    3635$latex \[
  • trunk/omh/theory/asin_reverse.omh

    r3675 r3680  
    1515$begin asin_reverse$$
    1616$spell
     17        asinh
    1718        asin
    1819        Taylor
    19         Arcsine
    2020$$
    2121
    22 $index asin, reverse theory$$
    23 $index theory, asin reverse$$
    24 $index reverse, asin theory$$
    25 
    26 $section Arc Sine and Hyperbolic Sine Reverse Mode Theory$$
     22$section Inverse Sine and Hyperbolic Sine Reverse Mode Theory$$
     23$mindex asin, asinh$$
    2724
    2825
    2926We use the reverse theory
    30 $xref%
    31         ReverseTheory%
    32         Standard Math Functions%
    33         standard math function
     27$cref%standard math function
     28        %ReverseTheory
     29        %Standard Math Functions
    3430%$$
    3531definition for the functions $latex H$$ and $latex G$$.
     
    6056\end{array}
    6157\] $$
    62 where $latex F(x) = \R{arcsin} (x)$$ for $latex -$$
    63 and $latex F(x) = \R{arcsinh} (x) $$ for $latex +$$.
     58where $latex F(x) = \R{asin} (x)$$ for $latex -$$
     59and $latex F(x) = \R{asinh} (x) $$ for $latex +$$.
    6460For the orders $latex j$$ greater than zero we have
    6561$latex \[
     
    8379\] $$
    8480
    85 If $latex j = 0$$, we have the relation
    86 
     81If $latex j = 0$$, we note that
     82$latex F^{(1)} ( x^{(0)} ) =  1 / b^{(0)}$$ and hence
    8783$latex \[
    8884\begin{array}{rcl}
    8985\D{H}{ x^{(j)} } & = &
    90 \D{G}{ x^{(0)} }
     86\D{G}{ x^{(j)} }
    9187+ \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} }
    9288+ \D{G}{ b^{(j)} } \D{ b^{(j)} }{ q^{(0)} } \D{ q^{(0)} }{ x^{(0)} }
  • trunk/omh/whats_new/whats_new_15.omh

    r3675 r3680  
    1414$dollar @$$
    1515$spell
     16        acosh
    1617        asinh
    1718        src
     
    5051assist you in learning about changes between various versions of CppAD.
    5152
     53$head 05-07$$
     54Add the inverse hyperbolic sine function $cref acosh$$.
     55If you are defining your own base type,
     56note that $cref/acosh/base_std_math/erf, asinh, acosh/$$
     57was added to the base type requirements.
     58
    5259$head 05-05$$
    5360Add the inverse hyperbolic sine function $cref asinh$$.
    5461If you are defining your own base type,
    55 note that $cref/asinh/base_std_math/asinh/$$
     62note that $cref/asinh/base_std_math/erf, asinh, acosh/$$
    5663was added to the base type requirements.
    5764
  • trunk/test_more/CMakeLists.txt

    r3675 r3680  
    6767        abs.cpp
    6868        acos.cpp
     69        acosh.cpp
    6970        adfun_copy.cpp
    7071        asin.cpp
  • trunk/test_more/acos.cpp

    r2506 r3680  
    11/* $Id$ */
    22/* --------------------------------------------------------------------------
    3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
    44
    55CppAD is distributed under multiple licenses. This distribution is under
    6 the terms of the 
     6the terms of the
    77                    Eclipse Public License Version 1.0.
    88
     
    1212
    1313/*
    14 Old Acos examples now used just for valiadation testing
     14Old acos examples now used just for valiadation testing
    1515*/
    1616# include <cppad/cppad.hpp>
    1717
    18 bool Acos(void)
     18bool acos(void)
    1919{       bool ok = true;
    2020
     
    2828
    2929        // a temporary values
    30         AD<double> x = cos(U[0]); 
     30        AD<double> x = cos(U[0]);
    3131
    32         // dependent variable vector 
     32        // dependent variable vector
    3333        CPPAD_TESTVECTOR(AD<double>) Z(1);
    3434        Z[0] = acos(x); // acos( cos(u) )
    3535
    3636        // create f: U -> Z and vectors used for derivative calculations
    37         ADFun<double> f(U, Z); 
     37        ADFun<double> f(U, Z);
    3838        CPPAD_TESTVECTOR(double) v(1);
    3939        CPPAD_TESTVECTOR(double) w(1);
    4040
    41         // check value 
     41        // check value
    4242        ok &= NearEqual(U[0] , Z[0],  1e-10 , 1e-10);
    4343
     
    5050        for(j = 1; j < p; j++)
    5151        {       jfac *= j;
    52                 w     = f.Forward(j, v);       
     52                w     = f.Forward(j, v);
    5353                ok &= NearEqual(jfac*w[0], value, 1e-10 , 1e-10); // d^jz/du^j
    5454                v[0]  = 0.;
     
    5757
    5858        // reverse computation of partials of Taylor coefficients
    59         CPPAD_TESTVECTOR(double) r(p); 
     59        CPPAD_TESTVECTOR(double) r(p);
    6060        w[0]  = 1.;
    6161        r     = f.Reverse(p, w);
  • trunk/test_more/asinh.cpp

    r3675 r3680  
    2525        size_t n  = 1;
    2626        double x0 = 0.5;
    27         CPPAD_TESTVECTOR(AD<double>) x(n);
    28         x[0]      = x0;
     27        CPPAD_TESTVECTOR(AD<double>) ax(n);
     28        ax[0]     = x0;
    2929
    3030        // declare independent variables and start tape recording
    31         CppAD::Independent(x);
     31        CppAD::Independent(ax);
    3232
    3333        // a temporary value
    34         AD<double> sinh_of_x0 = CppAD::sinh(x[0]);
     34        AD<double> sinh_of_x0 = CppAD::sinh(ax[0]);
    3535
    3636        // range space vector
    3737        size_t m = 1;
    38         CPPAD_TESTVECTOR(AD<double>) y(m);
    39         y[0] = CppAD::asinh(sinh_of_x0);
     38        CPPAD_TESTVECTOR(AD<double>) ay(m);
     39        ay[0] = CppAD::asinh(sinh_of_x0);
    4040
    4141        // create f: x -> y and stop tape recording
    42         CppAD::ADFun<double> f(x, y);
     42        CppAD::ADFun<double> f(ax, ay);
    4343
    4444        // check value
    45         ok &= NearEqual(y[0] , x0,  eps, eps);
     45        ok &= NearEqual(ay[0] , x0,  eps, eps);
    4646
    4747        // forward computation of first partial w.r.t. x[0]
     
    5252        ok   &= NearEqual(dy[0], 1., eps, eps);
    5353
    54         // forward computation of second partial w.r.t. x[0]
    55         CPPAD_TESTVECTOR(double) ddx(n);
    56         CPPAD_TESTVECTOR(double) ddy(m);
    57         ddx[0] = 0.;
    58         ddy   = f.Forward(2, ddx);
    59         ok   &= NearEqual(ddy[0], 0., eps, eps);
    60 
     54        // forward computation of higher order partials w.r.t. x[0]
     55        size_t n_order = 5;
     56        for(size_t order = 2; order < n_order; order++)
     57        {       dx[0] = 0.;
     58                dy    = f.Forward(order, dx);
     59                ok   &= NearEqual(dy[0], 0., eps, eps);
     60        }
    6161        // reverse computation of derivatives
    6262        CPPAD_TESTVECTOR(double)  w(m);
    63         CPPAD_TESTVECTOR(double) dw(3 * n);
     63        CPPAD_TESTVECTOR(double) dw(n_order * n);
    6464        w[0]  = 1.;
    65         dw    = f.Reverse(3, w);
     65        dw    = f.Reverse(n_order, w);
    6666        ok   &= NearEqual(dw[0], 1., eps, eps);
    67         ok   &= NearEqual(dw[1], 0., eps, eps);
    68         ok   &= NearEqual(dw[2], 0., eps, eps);
     67        for(size_t order = 1; order < n_order; order++)
     68                ok   &= NearEqual(dw[order * n + 0], 0., eps, eps);
    6969
    7070        return ok;
  • trunk/test_more/makefile.am

    r3679 r3680  
    9292        abs.cpp \
    9393        acos.cpp \
     94        acosh.cpp \
    9495        adfun_copy.cpp \
    9596        asin.cpp \
  • trunk/test_more/test_more.cpp

    r3675 r3680  
    1919// prototype external compiled tests (this line expected by bin/new_test.sh)
    2020extern bool abs(void);
    21 extern bool Acos(void);
     21extern bool acos(void);
     22extern bool acosh(void);
    2223extern bool adfun_copy(void);
    2324extern bool Add(void);
     
    135136        // run external compiled tests (this line expected by bin/new_test.sh)
    136137        ok &= Run( abs,             "abs"            );
    137         ok &= Run( Acos,            "Acos"           );
     138        ok &= Run( acos,            "acos"           );
     139        ok &= Run( acosh,           "acosh"          );
    138140        ok &= Run( adfun_copy,      "adfun_copy"     );
    139141        ok &= Run( Add,             "Add"            );
Note: See TracChangeset for help on using the changeset viewer.