CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
log1p.hpp
Go to the documentation of this file.
1 # ifndef CPPAD_CORE_LOG1P_HPP
2 # define CPPAD_CORE_LOG1P_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 log1p$$
18 $spell
19  CppAD
20 $$
21 
22 $section The Logarithm of One Plus Argument: log1p$$
23 
24 $head Syntax$$
25 $icode%y% = log1p(%x%)%$$
26 
27 $head Description$$
28 Returns the value of the logarithm of one plus argument which is defined
29 by $icode%y% == log(1 + %x%)%$$.
30 
31 $head x, y$$
32 See the $cref/possible types/unary_standard_math/Possible Types/$$
33 for a unary standard math function.
34 
35 $head CPPAD_USE_CPLUSPLUS_2011$$
36 
37 $subhead true$$
38 If this preprocessor symbol is true ($code 1$$),
39 and $icode x$$ is an AD type,
40 this is an $cref/atomic operation/glossary/Operation/Atomic/$$.
41 
42 $subhead false$$
43 If this preprocessor symbol is false ($code 0$$),
44 CppAD uses the representation
45 $latex \[
46 \R{log1p} (x) = \log(1 + x)
47 \] $$
48 to compute this function.
49 
50 $head Example$$
51 $children%
52  example/general/log1p.cpp
53 %$$
54 The file
55 $cref log1p.cpp$$
56 contains an example and test of this function.
57 It returns true if it succeeds and false otherwise.
58 
59 $end
60 -------------------------------------------------------------------------------
61 */
62 # include <cppad/configure.hpp>
63 # if ! CPPAD_USE_CPLUSPLUS_2011
64 
65 // BEGIN CppAD namespace
66 namespace CppAD {
67 
68 template <class Type>
69 Type log1p_template(const Type &x)
70 { return CppAD::log(Type(1) + x);
71 }
72 
73 inline float log1p(const float &x)
74 { return log1p_template(x); }
75 
76 inline double log1p(const double &x)
77 { return log1p_template(x); }
78 
79 template <class Base>
80 inline AD<Base> log1p(const AD<Base> &x)
81 { return log1p_template(x); }
82 
83 template <class Base>
84 inline AD<Base> log1p(const VecAD_reference<Base> &x)
85 { return log1p_template( x.ADBase() ); }
86 
87 
88 } // END CppAD namespace
89 
90 # endif // CPPAD_USE_CPLUSPLUS_2011
91 # endif // CPPAD_LOG1P_INCLUDED
AD< Base > log(const AD< Base > &x)
std::complex< double > log1p(const std::complex< double > &x)