CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
expm1.hpp
Go to the documentation of this file.
1 # ifndef CPPAD_CORE_EXPM1_HPP
2 # define CPPAD_CORE_EXPM1_HPP
3 
4 /* --------------------------------------------------------------------------
5 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
6 
7 CppAD is distributed under multiple licenses. This distribution is under
8 the terms of the
9  Eclipse Public License Version 1.0.
10 
11 A copy of this license is included in the COPYING file of this distribution.
12 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
13 -------------------------------------------------------------------------- */
14 
15 /*
16 -------------------------------------------------------------------------------
17 $begin expm1$$
18 $spell
19  exp
20  expm1
21  const
22  Vec
23  std
24  cmath
25  CppAD
26 $$
27 $section The Exponential Function Minus One: expm1$$
28 
29 $head Syntax$$
30 $icode%y% = expm1(%x%)%$$
31 
32 $head Description$$
33 Returns the value of the exponential function minus one which is defined
34 by $icode%y% == exp(%x%) - 1%$$.
35 
36 $head x, y$$
37 See the $cref/possible types/unary_standard_math/Possible Types/$$
38 for a unary standard math function.
39 
40 $head CPPAD_USE_CPLUSPLUS_2011$$
41 
42 $subhead true$$
43 If this preprocessor symbol is true ($code 1$$),
44 and $icode x$$ is an AD type,
45 this is an $cref/atomic operation/glossary/Operation/Atomic/$$.
46 
47 $subhead false$$
48 If this preprocessor symbol is false ($code 0$$),
49 CppAD uses the representation
50 $latex \[
51 \R{expm1} (x) = \exp(x) - 1
52 \] $$
53 to compute this function.
54 
55 $head Example$$
56 $children%
57  example/general/expm1.cpp
58 %$$
59 The file
60 $cref expm1.cpp$$
61 contains an example and test of this function.
62 It returns true if it succeeds and false otherwise.
63 
64 $end
65 -------------------------------------------------------------------------------
66 */
67 # include <cppad/configure.hpp>
68 # if ! CPPAD_USE_CPLUSPLUS_2011
69 
70 // BEGIN CppAD namespace
71 namespace CppAD {
72 
73 template <class Type>
74 Type expm1_template(const Type &x)
75 { return CppAD::exp(x) - Type(1);
76 }
77 
78 inline float expm1(const float &x)
79 { return expm1_template(x); }
80 
81 inline double expm1(const double &x)
82 { return expm1_template(x); }
83 
84 template <class Base>
85 inline AD<Base> expm1(const AD<Base> &x)
86 { return expm1_template(x); }
87 
88 template <class Base>
89 inline AD<Base> expm1(const VecAD_reference<Base> &x)
90 { return expm1_template( x.ADBase() ); }
91 
92 
93 } // END CppAD namespace
94 
95 # endif // CPPAD_USE_CPLUSPLUS_2011
96 # endif // CPPAD_EXPM1_INCLUDED
AD< Base > exp(const AD< Base > &x)
std::complex< double > expm1(const std::complex< double > &x)