CppAD: A C++ Algorithmic Differentiation Package  20171217
integer.hpp
Go to the documentation of this file.
3
4 /* --------------------------------------------------------------------------
6
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.
13 -------------------------------------------------------------------------- */
14
15 /*
16 ------------------------------------------------------------------------------
17 $begin Integer$$18 spell 19 std 20 VecAD 21 CppAD 22 namespace 23 const 24 bool 25$$ 26 27 28 29$section Convert From AD to Integer$$30 31 head Syntax$$
32 $icode%i% = Integer(%x%)%$$33 34 35 head Purpose$$ 36 Converts from an AD type to the corresponding integer value. 37 38$head i$$39 The result icode i$$ has prototype
40 $codei% 41 int %i% 42 %$$43 44 head x$$ 45 46$subhead Real Types$$47 If the argument icode x$$ has either of the following prototypes:
48 $codei% 49 const float %% &%x% 50 const double %% &%x% 51 %$$52 the fractional part is dropped to form the integer value. 53 For example, if icode x$$ is 1.5,$icode i$$is 1. 54 In general, if latex x \geq 0$$, $icode i$$is the 55 greatest integer less than or equal icode x$$. 56 If$latex x \leq 0$$, icode i$$ is the
57 smallest integer greater than or equal $icode x$$. 58 59 subhead Complex Types$$ 60 If the argument$icode x$$has either of the following prototypes: 61 codei% 62 const std::complex<float> %% &%x% 63 const std::complex<double> %% &%x% 64 %$$
65 The result $icode i$$is given by 66 codei% 67 %i% = Integer(%x%.real()) 68 %$$ 69 70$subhead AD Types$$71 If the argument icode x$$ has either of the following prototypes:
72 $codei% 73 const AD<%Base%> &%x% 74 const VecAD<%Base%>::reference &%x% 75 %$$76 icode Base$$ must support the$code Integer$$function and 77 the conversion has the same meaning as for icode Base$$.
78
79 $head Operation Sequence$$80 The result of this operation is not an 81 cref/AD of Base/glossary/AD of Base/$$ object. 82 Thus it will not be recorded as part of an 83 AD of$icode Base$$84 cref/operation sequence/glossary/Operation/Sequence/$$.
85
86 $head Example$$87 children% 88 example/general/integer.cpp 89 %$$ 90 The file 91$cref integer.cpp
92 contains an example and test of this operation.
93
94 \$end
95 ------------------------------------------------------------------------------
96 */
97
98
100
101  template <class Base>
104  { return Integer(x.value_); }
105
106  template <class Base>
109  { return Integer( x.ADBase() ); }
110 }
111 # endif
112
Base value_