<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Source: Poly</title>
<meta name="description" id="description" content="Source: Poly"/>
<meta name="keywords" id="keywords" content=" Poly source "/>
<style type='text/css'>
body { color : black }
body { background-color : white }
A:link { color : blue }
A:visited { color : purple }
A:active { color : purple }
</style>
<script type='text/javascript' language='JavaScript' src='_poly.hpp_xml.js'>
</script>
</head>
<body>
<table><tr>
<td>
<a href="http://www.coin-or.org/CppAD/" target="_top"><img border="0" src="_image.gif"/></a>
</td>
<td><a href="poly.cpp.xml" target="_top">Prev</a>
</td><td><a href="ludetandsolve.xml" target="_top">Next</a>
</td><td>
<select onchange='choose_across0(this)'>
<option>Index-&gt;</option>
<option>contents</option>
<option>reference</option>
<option>index</option>
<option>search</option>
<option>external</option>
</select>
</td>
<td>
<select onchange='choose_up0(this)'>
<option>Up-&gt;</option>
<option>CppAD</option>
<option>library</option>
<option>Poly</option>
<option>poly.hpp</option>
</select>
</td>
<td>
<select onchange='choose_down3(this)'>
<option>CppAD-&gt;</option>
<option>Install</option>
<option>Introduction</option>
<option>AD</option>
<option>ADFun</option>
<option>preprocessor</option>
<option>multi_thread</option>
<option>library</option>
<option>ipopt_solve</option>
<option>Example</option>
<option>speed</option>
<option>Appendix</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>library-&gt;</option>
<option>ErrorHandler</option>
<option>NearEqual</option>
<option>speed_test</option>
<option>SpeedTest</option>
<option>time_test</option>
<option>NumericType</option>
<option>CheckNumericType</option>
<option>SimpleVector</option>
<option>CheckSimpleVector</option>
<option>nan</option>
<option>pow_int</option>
<option>Poly</option>
<option>LuDetAndSolve</option>
<option>RombergOne</option>
<option>RombergMul</option>
<option>Runge45</option>
<option>Rosen34</option>
<option>OdeErrControl</option>
<option>OdeGear</option>
<option>OdeGearControl</option>
<option>CppAD_vector</option>
<option>thread_alloc</option>
<option>index_sort</option>
<option>BenderQuad</option>
<option>opt_val_hes</option>
<option>LuRatio</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>Poly-&gt;</option>
<option>poly.cpp</option>
<option>poly.hpp</option>
</select>
</td>
<td>poly.hpp</td>
<td>Headings</td>
</tr></table><br/>



<center><b><big><big>Source: Poly</big></big></b></center>
<code><font color="blue"># ifndef CPPAD_POLY_INCLUDED 
<code><span style='white-space: nowrap'><br/>
</span></code># define CPPAD_POLY_INCLUDED

<pre style='display:inline'> 
# include &lt;cstddef&gt;  // used to defined size_t
# include &lt;cppad/check_simple_vector.hpp&gt;

namespace CppAD {    // BEGIN CppAD namespace

template &lt;class Type, class Vector&gt;
Type Poly(size_t k, const Vector &amp;a, const Type &amp;z)
{	size_t i;
	size_t d = a.size() - 1;

	Type tmp;

	// check Vector is Simple Vector class with Type elements
	CheckSimpleVector&lt;Type, Vector&gt;();

	// case where derivative order greater than degree of polynomial
	if( k &gt; d )
	{	tmp = 0;
		return tmp;
	}
	// case where we are evaluating a derivative
	if( k &gt; 0 )
	{	// initialize factor as (k-1) !
		size_t factor = 1;
		for(i = 2; i &lt; k; i++)
			factor *= i;

		// set b to coefficient vector corresponding to derivative
		Vector b(d - k + 1);
		for(i = k; i &lt;= d; i++)
		{	factor   *= i;
			tmp       = factor;
			b[i - k]  = a[i] * tmp; 
			factor   /= (i - k + 1);
		}
		// value of derivative polynomial
		return Poly(0, b, z);
	}
	// case where we are evaluating the original polynomial
	Type sum = a[d];
	i        = d;
	while(i &gt; 0)
	{	sum *= z;
		sum += a[--i];
	}
	return sum;
}
} // END CppAD namespace
</pre>


# endif
</font></code>


<hr/>Input File: omh/poly_hpp.omh

</body>
</html>
