source: trunk/cppad/local/base_std_math.hpp @ 3680

Last change on this file since 3680 was 3680, checked in by bradbell, 5 years ago

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.

  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1/* $Id: base_std_math.hpp 3680 2015-05-07 19:17:37Z bradbell $ */
2# ifndef CPPAD_BASE_STD_MATH_INCLUDED
3# define CPPAD_BASE_STD_MATH_INCLUDED
4
5/* --------------------------------------------------------------------------
6CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
7
8CppAD is distributed under multiple licenses. This distribution is under
9the terms of the
10                    Eclipse Public License Version 1.0.
11
12A copy of this license is included in the COPYING file of this distribution.
13Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
14-------------------------------------------------------------------------- */
15
16/*
17$begin base_std_math$$
18$spell
19        acosh
20        asinh
21        inline
22        fabs
23        isnan
24        alloc
25        std
26        acos
27        asin
28        atan
29        cos
30        exp
31        sqrt
32        const
33        CppAD
34        namespace
35        erf
36$$
37
38$section Base Type Requirements for Standard Math Functions$$
39$index math, base require$$
40$index base, math require$$
41$index require, base math$$
42
43$head Purpose$$
44These definitions are required for the user's code to use the type
45$codei%AD<%Base%>%$$:
46
47$head Unary Standard Math$$
48$index math, base unary$$
49$index base, unary math$$
50$index unary, base math$$
51The type $icode Base$$ must support the following functions
52unary standard math functions (in the CppAD namespace):
53$table
54$bold Syntax$$ $cnext $bold Result$$
55$rnext
56$icode%y% = abs(%x%)%$$  $cnext absolute value     $rnext
57$icode%y% = acos(%x%)%$$ $cnext inverse cosine     $rnext
58$icode%y% = asin(%x%)%$$ $cnext inverse sine       $rnext
59$icode%y% = atan(%x%)%$$ $cnext inverse tangent    $rnext
60$icode%y% = cos(%x%)%$$  $cnext cosine             $rnext
61$icode%y% = cosh(%x%)%$$ $cnext hyperbolic cosine  $rnext
62$icode%y% = exp(%x%)%$$  $cnext exponential        $rnext
63$icode%y% = fabs(%x%)%$$ $cnext absolute value     $rnext
64$icode%y% = log(%x%)%$$  $cnext natural logarithm  $rnext
65$icode%y% = sin(%x%)%$$  $cnext sine               $rnext
66$icode%y% = sinh(%x%)%$$ $cnext hyperbolic sine    $rnext
67$icode%y% = sqrt(%x%)%$$ $cnext square root        $rnext
68$icode%y% = tan(%x%)%$$  $cnext tangent
69$tend
70where the arguments and return value have the prototypes
71$codei%
72        const %Base%& %x%
73        %Base%        %y%
74%$$
75For example,
76$cref/base_alloc/base_alloc.hpp/Unary Standard Math/$$,
77
78
79$head CPPAD_STANDARD_MATH_UNARY$$
80$index CPPAD_STANDARD_MATH_UNARY$$
81The macro invocation, within the CppAD namespace,
82$codei%
83        CPPAD_STANDARD_MATH_UNARY(%Base%, %Fun%)
84%$$
85defines the syntax
86$codei%
87        %y% = CppAD::%Fun%(%x%)
88%$$
89This macro uses the functions $codei%std::%Fun%$$ which
90must be defined and have the same prototype as $codei%CppAD::%Fun%$$.
91For example,
92$cref/float/base_float.hpp/Unary Standard Math/$$.
93
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,
104the type $icode Base$$ must support the syntax
105$codei%
106        %y% = CppAD::%fun%(%x%)
107%$$
108where $icode x$$ and $icode y$$ have the same prototype as above.
109For example, see
110$cref/base_alloc/base_alloc.hpp/erf, asinh, acosh/$$.
111
112$head sign$$
113$index sign, base require$$
114$index base, sign require$$
115$index require, base sign$$
116The type $icode Base$$ must support the syntax
117$codei%
118        %y% = CppAD::sign(%x%)
119%$$
120which computes
121$latex \[
122y = \left\{ \begin{array}{ll}
123        +1 & {\rm if} \; x > 0 \\
124         0 & {\rm if} \; x = 0 \\
125        -1 & {\rm if} \; x < 0
126\end{array} \right.
127\] $$
128where $icode x$$ and $icode y$$ have the same prototype as above.
129For example, see
130$cref/base_alloc/base_alloc.hpp/sign/$$.
131Note that, if ordered comparisons are not defined for the type $icode Base$$,
132the $code code sign$$ function should generate an assert if it is used; see
133$cref/complex invalid unary math/base_complex.hpp/Invalid Unary Math/$$.
134
135$head pow$$
136$index pow, base require$$
137$index base, pow require$$
138$index require, base pow$$
139The type $icode Base$$ must support the syntax
140$codei%
141        %z% = CppAD::pow(%x%, %y%)
142%$$
143which computes $latex z = x^y$$.
144The arguments $icode x$$ and $icode y$$ have prototypes
145$codei%
146        const %Base%& %x%
147        const %Base%& %y%
148%$$
149and the return value $icode z$$ has prototype
150$codei%
151        %Base% %z%
152%$$
153For example, see
154$cref/base_alloc/base_alloc.hpp/pow/$$.
155
156
157$head isnan$$
158$index isnan, base type$$
159$index base, isnan$$
160If $icode Base$$ defines the $code isnan$$ function,
161you may also have to provide a definition in the CppAD namespace
162(to avoid a function ambiguity).
163For example, see
164$cref/base_complex/base_complex.hpp/isnan/$$.
165
166
167$head limits$$
168$index numeric, limits Base$$
169$index limits, numeric Base$$
170$index Base, numeric_limits$$
171The $cref/numeric_limits/limits/$$ functions
172$codei%
173        %Base% CppAD::numeric_limits<%Base%>::epsilon()
174        %Base% CppAD::numeric_limits<%Base%>::min()
175        %Base% CppAD::numeric_limits<%Base%>::max()
176%$$
177must return machine epsilon,
178minimum positive normalize value,
179and maximum finite value for the type $icode Base$$.
180
181$subhead epsilon$$
182The deprecated function $cref epsilon$$ function
183must also be included. It can be implemented using
184$codei%
185namespace CppAD {
186        template <> inline %Base% epsilon<%Base%>(void)
187        {       return numeric_limits<%Base%>::epsilon(); }
188}
189%$$
190
191$end
192-------------------------------------------------------------------------------
193*/
194
195# include <cmath>
196
197namespace CppAD { // BEGIN_CPPAD_NAMESPACE
198
199/*!
200\file base_std_math.hpp
201Defintions that aid meeting Base type requirements for standard math functions.
202*/
203
204/*!
205\def CPPAD_STANDARD_MATH_UNARY(Type, Fun)
206This macro defines the function
207\verbatim
208        y = CppAD:Fun(x)
209\endverbatim
210where the argument \c x and return value \c y have type \c Type
211using the corresponding function <code>std::Fun</code>.
212*/
213# define CPPAD_STANDARD_MATH_UNARY(Type, Fun) \
214        inline Type Fun(const Type& x)            \
215        {       return std::Fun(x); }
216
217} // END_CPPAD_NAMESPACE
218
219# endif
Note: See TracBrowser for help on using the repository browser.