source: trunk/cppad/local/base_float.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.3 KB
Line 
1/* $Id: base_float.hpp 3680 2015-05-07 19:17:37Z bradbell $ */
2# ifndef CPPAD_BASE_FLOAT_INCLUDED
3# define CPPAD_BASE_FLOAT_INCLUDED
4/* --------------------------------------------------------------------------
5CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
6
7CppAD is distributed under multiple licenses. This distribution is under
8the terms of the
9                    Eclipse Public License Version 1.0.
10
11A copy of this license is included in the COPYING file of this distribution.
12Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
13-------------------------------------------------------------------------- */
14# include <cppad/configure.hpp>
15# include <limits>
16
17/*
18$begin base_float.hpp$$
19$spell
20        acosh
21        asinh
22        erf
23        endif
24        abs_geq
25        acos
26        asin
27        atan
28        cos
29        sqrt
30        tanh
31        std
32        fabs
33        bool
34        Lt Le Eq Ge Gt
35        Rel
36        CppAD
37        CondExpOp
38        namespace
39        inline
40        enum
41        const
42        exp
43        const
44$$
45
46$index float, Base$$
47$index Base, float$$
48$index float, Base$$
49
50$section Enable use of AD<Base> where Base is float$$
51
52$head CondExpOp$$
53The type $code float$$ is a relatively simple type that supports
54$code <$$, $code <=$$, $code ==$$, $code >=$$, and $code >$$ operators; see
55$cref/ordered type/base_cond_exp/CondExpTemplate/Ordered Type/$$.
56Hence its $code CondExpOp$$ function is defined by
57$codep */
58namespace CppAD {
59        inline float CondExpOp(
60                enum CompareOp     cop          ,
61                const float&       left         ,
62                const float&       right        ,
63                const float&       exp_if_true  ,
64                const float&       exp_if_false )
65        {       return CondExpTemplate(cop, left, right, exp_if_true, exp_if_false);
66        }
67}
68/* $$
69
70$head CondExpRel$$
71The $cref/CPPAD_COND_EXP_REL/base_cond_exp/CondExpRel/$$ macro invocation
72$codep */
73namespace CppAD {
74        CPPAD_COND_EXP_REL(float)
75}
76/* $$
77uses $code CondExpOp$$ above to
78define $codei%CondExp%Rel%$$ for $code float$$ arguments
79and $icode%Rel%$$ equal to
80$code Lt$$, $code Le$$, $code Eq$$, $code Ge$$, and $code Gt$$.
81
82$head EqualOpSeq$$
83The type $code float$$ is simple (in this respect) and so we define
84$codep */
85namespace CppAD {
86        inline bool EqualOpSeq(const float& x, const float& y)
87        {       return x == y; }
88}
89/* $$
90
91$head Identical$$
92The type $code float$$ is simple (in this respect) and so we define
93$codep */
94namespace CppAD {
95        inline bool IdenticalPar(const float& x)
96        {       return true; }
97        inline bool IdenticalZero(const float& x)
98        {       return (x == 0.f); }
99        inline bool IdenticalOne(const float& x)
100        {       return (x == 1.f); }
101        inline bool IdenticalEqualPar(const float& x, const float& y)
102        {       return (x == y); }
103}
104/* $$
105
106$head Integer$$
107$codep */
108namespace CppAD {
109        inline int Integer(const float& x)
110        {       return static_cast<int>(x); }
111}
112/* $$
113
114$head Ordered$$
115The $code float$$ type supports ordered comparisons
116$codep */
117namespace CppAD {
118        inline bool GreaterThanZero(const float& x)
119        {       return x > 0.f; }
120        inline bool GreaterThanOrZero(const float& x)
121        {       return x >= 0.f; }
122        inline bool LessThanZero(const float& x)
123        {       return x < 0.f; }
124        inline bool LessThanOrZero(const float& x)
125        {       return x <= 0.f; }
126        inline bool abs_geq(const float& x, const float& y)
127        {       return std::fabs(x) >= std::fabs(y); }
128}
129/* $$
130
131$head Unary Standard Math$$
132The following macro invocations define the unary standard math functions
133required to use $code AD<float>$$:
134(in the CppAD namespace)
135$codep */
136namespace CppAD {
137        CPPAD_STANDARD_MATH_UNARY(float, acos)
138        CPPAD_STANDARD_MATH_UNARY(float, asin)
139        CPPAD_STANDARD_MATH_UNARY(float, atan)
140        CPPAD_STANDARD_MATH_UNARY(float, cos)
141        CPPAD_STANDARD_MATH_UNARY(float, cosh)
142        CPPAD_STANDARD_MATH_UNARY(float, exp)
143        CPPAD_STANDARD_MATH_UNARY(float, fabs)
144        CPPAD_STANDARD_MATH_UNARY(float, log)
145        CPPAD_STANDARD_MATH_UNARY(float, log10)
146        CPPAD_STANDARD_MATH_UNARY(float, sin)
147        CPPAD_STANDARD_MATH_UNARY(float, sinh)
148        CPPAD_STANDARD_MATH_UNARY(float, sqrt)
149        CPPAD_STANDARD_MATH_UNARY(float, tan)
150        CPPAD_STANDARD_MATH_UNARY(float, tanh)
151# if CPPAD_COMPILER_HAS_ASINH
152        CPPAD_STANDARD_MATH_UNARY(float, asinh)
153# endif
154# if CPPAD_COMPILER_HAS_ACOSH
155        CPPAD_STANDARD_MATH_UNARY(float, acosh)
156# endif
157# if CPPAD_COMPILER_HAS_ERF
158        CPPAD_STANDARD_MATH_UNARY(float, erf)
159# endif
160}
161/* $$
162The absolute value function is special because its $code std$$ name is
163$code fabs$$
164$codep */
165namespace CppAD {
166        inline float abs(const float& x)
167        {       return std::fabs(x); }
168}
169/* $$
170
171$head sign$$
172The following defines the $code CppAD::sign$$ function that
173is required to use $code AD<float>$$:
174$codep */
175namespace CppAD {
176        inline float sign(const float& x)
177        {       if( x > 0.f )
178                        return 1.f;
179                if( x == 0.f )
180                        return 0.f;
181                return -1.f;
182        }
183}
184/* $$
185
186$head pow $$
187The following defines a $code CppAD::pow$$ function that
188is required to use $code AD<float>$$:
189$codep */
190namespace CppAD {
191        inline float pow(const float& x, const float& y)
192        { return std::pow(x, y); }
193}
194/*$$
195
196$head limits$$
197The following defines the numeric limits functions
198$code epsilon$$, $code min$$, and $code max$$ for the type
199$code float$$:
200$codep */
201namespace CppAD {
202        template <>
203        class numeric_limits<float> {
204        public:
205                // machine epsilon
206                static float epsilon(void)
207                {       return std::numeric_limits<float>::epsilon(); }
208                // minimum positive normalized value
209                static float min(void)
210                {       return std::numeric_limits<float>::min(); }
211                // maximum finite value
212                static float max(void)
213                {       return std::numeric_limits<float>::max(); }
214        };
215        // deprecated machine epsilon
216        template <>
217        inline float epsilon<float>(void)
218        {       return numeric_limits<float>::epsilon(); }
219}
220/* $$
221$end
222*/
223
224
225# endif
Note: See TracBrowser for help on using the repository browser.