📄 a00087.html
字号:
</tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"><code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>initialization constructor.<p>Initializes a polynomial of arbitrary size and coeficients. Care must be taken to properly cast the variable arguments to the same type as template type <em>T</em>.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"><tt>[in]</tt> </td><td valign="top"><em>n</em> </td><td>polynomial's degree </td></tr> <tr><td valign="top"><tt>[in]</tt> </td><td valign="top"><em>a0</em> </td><td>degree 0 coeficient </td></tr> <tr><td valign="top"><tt>[in]</tt> </td><td valign="top"><em>...</em> </td><td>coeficients <img class="formulaInl" alt="$a_1..a_n$" src="form_36.png"> , number of parameters must match parameter <em>n</em>. </td></tr> </table></dl><p>Definition at line <a class="el" href="a00103.html#l00114">114</a> of file <a class="el" href="a00103.html">Polynomial.h</a>. </td> </tr></table><hr><h2>Member Function Documentation</h2><a class="anchor" name="7d71a634b3ab7d5071c031633b9614d5"></a><!-- doxytag: member="Polynomial::compact" ref="7d71a634b3ab7d5071c031633b9614d5" args="()" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="mdPrefix" colspan="4">template<class T> </td> </tr> <tr> <td class="md" nowrap valign="top">void <a class="el" href="a00087.html">Polynomial</a>< T >::compact </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>compacts array.<p>Compacts array size to match actual polynomial degree by enforcing the rule <em>p[p.size() - 1] != 0</em>.<p>This function is called by other member functions to enforce the rule automatically whenever operations are performed on the polynomial.<p><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00087.html#ba49e76c2d516f6aa270b8333e99df8f">degree()</a> </dd></dl><p>Definition at line <a class="el" href="a00103.html#l00155">155</a> of file <a class="el" href="a00103.html">Polynomial.h</a>. </td> </tr></table><a class="anchor" name="ba49e76c2d516f6aa270b8333e99df8f"></a><!-- doxytag: member="Polynomial::degree" ref="ba49e76c2d516f6aa270b8333e99df8f" args="()" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="mdPrefix" colspan="4">template<class T> </td> </tr> <tr> <td class="md" nowrap valign="top">int <a class="el" href="a00087.html">Polynomial</a>< T >::degree </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>returns degree of polynomial.<p>Degree of the polynomial is the index of the highest degree non_null coeficient.<p>This non-constant version of the function calls <a class="el" href="a00087.html#7d71a634b3ab7d5071c031633b9614d5">compact()</a> before returning.<p><dl compact><dt><b>Returns:</b></dt><dd>The degree of the polynomial.</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00087.html#b433e0edb11b32a205a9d07b89aefa8f">degree() const</a> </dd></dl><p>Definition at line <a class="el" href="a00103.html#l00195">195</a> of file <a class="el" href="a00103.html">Polynomial.h</a>. </td> </tr></table><a class="anchor" name="b433e0edb11b32a205a9d07b89aefa8f"></a><!-- doxytag: member="Polynomial::degree" ref="b433e0edb11b32a205a9d07b89aefa8f" args="() const " --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="mdPrefix" colspan="4">template<class T> </td> </tr> <tr> <td class="md" nowrap valign="top">int <a class="el" href="a00087.html">Polynomial</a>< T >::degree </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap> const<code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>returns degree of polynomial.<p>Degree of the polynomial is the index of the highest degree non_null coeficient.<p><dl compact><dt><b>Example:</b></dt><dd><div class="fragment"><pre class="fragment"><span class="comment">// degree.cpp : Shows use of degree()</span><span class="comment">//</span><span class="preprocessor">#include <iostream></span><span class="preprocessor">#include <<a class="code" href="a00092.html">polynomial.h</a>></span><span class="keyword">using namespace </span>std;<span class="keywordtype">int</span> main() { <span class="comment">// Initialize p(x) = 5x^4 + 3x^2 + x + 10</span> Polynomial<double> p(4, 10., 1., 3., 0., 5.); <span class="comment">// Initialize q(x) = x^3 + x^2 - 5x + 2</span> Polynomial<double> q(3, 2., -5., 1., 1.); <span class="comment">// Add p and q</span> Polynomial<double> r = p + r; <span class="comment">// Display degree of new polynomial</span> cout << <span class="stringliteral">"degree of r(x): "</span> << r.<a class="code" href="a00087.html#b433e0edb11b32a205a9d07b89aefa8f">degree</a>() << endl; <span class="keywordflow">return</span> 0;}</pre></div> </dd></dl><dl compact><dt><b>Program output:</b></dt><dd><div class="fragment"><pre class="fragment"><a class="code" href="a00087.html#b433e0edb11b32a205a9d07b89aefa8f">degree</a> of r(x): 4</pre></div></dd></dl><dl compact><dt><b>Returns:</b></dt><dd>the degree of the polynomial.</dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00087.html#ba49e76c2d516f6aa270b8333e99df8f">degree()</a> </dd></dl><p>Definition at line <a class="el" href="a00103.html#l00175">175</a> of file <a class="el" href="a00103.html">Polynomial.h</a>. </td> </tr></table><a class="anchor" name="a845bf5cc0f93217a7c7f403a0bc9d38"></a><!-- doxytag: member="Polynomial::eval" ref="a845bf5cc0f93217a7c7f403a0bc9d38" args="(const T &x) const " --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="mdPrefix" colspan="4">template<class T> </td> </tr> <tr> <td class="md" nowrap valign="top">T <a class="el" href="a00087.html">Polynomial</a>< T >::eval </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const T & </td> <td class="mdname1" valign="top" nowrap> <em>x</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap> const<code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>evaluates polynomial value <img class="formulaInl" alt="$p(x)$" src="form_21.png"> .<p>Evaluates <img class="formulaInl" alt="$p(x)$" src="form_21.png"> by Horner's recurence.<p>No error checking is performed, so any validation for overflow, or underflow is the responsibility of the caller.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"><tt>[in]</tt> </td><td valign="top"><em>x</em> </td><td>parameter of <img class="formulaInl" alt="$p(x)$" src="form_21.png"></td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>The value of <img class="formulaInl" alt="$p(x)$" src="form_21.png"> . </dd></dl><p>Definition at line <a class="el" href="a00103.html#l00299">299</a> of file <a class="el" href="a00103.html">Polynomial.h</a>. </td> </tr></table><a class="anchor" name="4dc10e1190f7f71f0d04e9871c1d7a2f"></a><!-- doxytag: member="Polynomial::evalAndDeflate" ref="4dc10e1190f7f71f0d04e9871c1d7a2f" args="(const T &a, Polynomial< T > &q) const " --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="mdPrefix" colspan="4">template<class T> </td> </tr> <tr> <td class="md" nowrap valign="top">T <a class="el" href="a00087.html">Polynomial</a>< T >::evalAndDeflate </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const T & </td> <td class="mdname" nowrap> <em>a</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="a00087.html">Polynomial</a>< T > & </td> <td class="mdname" nowrap> <em>q</em></td> </tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"> const<code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -