Prev Next Index-> contents reference index search external Up-> CppAD utility pow_int CppAD-> Install Introduction AD ADFun preprocessor multi_thread utility ipopt_solve Example speed Appendix utility-> ErrorHandler NearEqual speed_test SpeedTest time_test test_boolofvoid NumericType CheckNumericType SimpleVector CheckSimpleVector nan pow_int Poly LuDetAndSolve RombergOne RombergMul Runge45 Rosen34 OdeErrControl OdeGear OdeGearControl CppAD_vector thread_alloc index_sort to_string set_union sparse_rc sparse_rcv pow_int-> pow_int.cpp Headings-> Syntax See Also Purpose Include x y z Type Operation Sequence Example

$\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }$
The Integer Power Function

Syntax
# include <cppad/utility/pow_int.hpp>  z = pow(x, y)

pow

Purpose
Determines the value of the power function $${\rm pow} (x, y) = x^y$$ for integer exponents n using multiplication and possibly division to compute the value. The other CppAD pow function may use logarithms and exponentiation to compute derivatives of the same value (which will not work if x is less than or equal zero).

Include
The file cppad/pow_int.h is included by cppad/cppad.hpp but it can also be included separately with out the rest of the CppAD routines. Including this file defines this version of the pow within the CppAD namespace.

x
The argument x has prototype       const Type& x 
y
The argument y has prototype       const int& y 
z
The result z has prototype       Type z 
Type
The type Type must support the following operations where a and b are Type objects and i is an int:
 Operation    Description Result Type Type a(i) construction of a Type object from an int Type a * b binary multiplication of Type objects Type a / b binary division of Type objects Type

Operation Sequence
The Type operation sequence used to calculate z is independent of x .

Example
The file pow_int.cpp is an example and test of this function. It returns true if it succeeds and false otherwise.