Prev Next Index-> contents reference index search external Up-> CppAD utility Poly 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 Poly-> poly.cpp poly.hpp Headings-> Syntax Description Include k a z p Type ---..Operations Vector Operation Sequence Example Source

$\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}} }$
Evaluate a Polynomial or its Derivative

Syntax
# include <cppad/utility/poly.hpp>  p = Poly(k, a, z)

Description
Computes the k-th derivative of the polynomial $$P(z) = a_0 + a_1 z^1 + \cdots + a_d z^d$$ If k is equal to zero, the return value is $P(z)$.

Include
The file cppad/poly.hpp 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 Poly within the CppAD namespace.

k
The argument k has prototype       size_t k  It specifies the order of the derivative to calculate.

a
The argument a has prototype       const Vector &a  (see Vector below). It specifies the vector corresponding to the polynomial $P(z)$.

z
The argument z has prototype       const Type &z  (see Type below). It specifies the point at which to evaluate the polynomial

p
The result p has prototype       Type p  (see Type below) and it is equal to the k-th derivative of $P(z)$; i.e., $$p = \frac{k !}{0 !} a_k + \frac{(k+1) !}{1 !} a_{k+1} z^1 + \ldots + \frac{d !}{(d - k) !} a_d z^{d - k}$$ If $k > d$, p = Type(0) .

Type
The type Type is determined by the argument z . It is assumed that multiplication and addition of Type objects are commutative.

Operations
The following operations must be supported where x and y are objects of type Type and i is an int:
 x  = i assignment x  = y assignment x *= y multiplication compound assignment x += y addition compound assignment

Vector
The type Vector must be a SimpleVector class with elements of type Type . The routine CheckSimpleVector will generate an error message if this is not the case.

Operation Sequence
The Type operation sequence used to calculate p is independent of z and the elements of a (it does depend on the size of the vector a ).

Example
The file poly.cpp contains an example and test of this routine. It returns true if it succeeds and false otherwise.

Source
The file poly.hpp contains the current source code that implements these specifications.