\doxysubsection{Polynomial.\+hpp File Reference}
\hypertarget{Polynomial_8hpp}{}\label{Polynomial_8hpp}\index{Polynomial.hpp@{Polynomial.hpp}}


Define a polynomial and provide several helper functions.  


{\ttfamily \#include $<$string$>$}\newline
{\ttfamily \#include $<$ostream$>$}\newline
\doxysubsubsubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \mbox{\hyperlink{structfunc_1_1polynomial__helper_3_01TOUT_00_01N_00_01true_01_4}{polynomial\+\_\+helper$<$ TOUT, N, true $>$}}
\begin{DoxyCompactList}\small\item\em Arrays of this type of polynomial are aligned. \end{DoxyCompactList}\item 
struct \mbox{\hyperlink{structfunc_1_1polynomial__helper_3_01TOUT_00_01N_00_01false_01_4}{polynomial\+\_\+helper$<$ TOUT, N, false $>$}}
\begin{DoxyCompactList}\small\item\em Arrays of this type of polynomial are not aligned. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{Polynomial_8hpp_acc94ccf3b29d0297ab2669fbc6163b79}\label{Polynomial_8hpp_acc94ccf3b29d0297ab2669fbc6163b79} 
{\footnotesize template$<$typename TOUT, unsigned int N$>$ }\\using {\bfseries polynomial} = \mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial\+\_\+helper}}$<$TOUT,N,std\+::is\+\_\+floating\+\_\+point$<$TOUT$>$\+::value$>$
\end{DoxyCompactItemize}
\doxysubsubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{Polynomial_8hpp_ad7a5da98242ec3aabf16b20579fd79a5}\label{Polynomial_8hpp_ad7a5da98242ec3aabf16b20579fd79a5} 
constexpr unsigned int {\bfseries factorial} (unsigned int n)
\item 
\Hypertarget{Polynomial_8hpp_afd1f5d104ffee48e5ef6598722bf4f08}\label{Polynomial_8hpp_afd1f5d104ffee48e5ef6598722bf4f08} 
constexpr unsigned int {\bfseries permutation} (unsigned int n, unsigned int k)
\item 
{\footnotesize template$<$unsigned int N, typename TOUT, typename TIN = TOUT$>$ }\\TOUT \mbox{\hyperlink{Polynomial_8hpp_a9e7241eec8112d9048e48e184b32c2cb}{polynomial\+\_\+diff}} (\mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$ p, TIN x, unsigned s)
\begin{DoxyCompactList}\small\item\em Compute $p^{(s)}(x)$, the $s$th derivative of $p$ at $x$. \end{DoxyCompactList}\item 
{\footnotesize template$<$unsigned int N, typename TOUT, typename TIN = TOUT$>$ }\\\mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$ \mbox{\hyperlink{Polynomial_8hpp_a1a1546bab925591a6306914032b65a5d}{taylor\+\_\+shift}} (\mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$ p, TIN a, TIN b, TIN c, TIN d)
\begin{DoxyCompactList}\small\item\em Given a polynomial $p:[a,b]\to\mathbb{R}$, compute the coefficients of $q:[c,d]\to\mathbb{R}$ such that $q(x) = p( [(b-a)x + (ad-bc)]/(d-c) )$ by expanding $p$ in a Taylor series. \end{DoxyCompactList}\item 
{\footnotesize template$<$unsigned int N, typename TOUT, typename TIN = TOUT$>$ }\\TOUT \mbox{\hyperlink{Polynomial_8hpp_abeddf4a63f948b91197ac50f9ee238cd}{eval}} (\mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$ p, TIN x)
\begin{DoxyCompactList}\small\item\em Compute $p(x)$. \end{DoxyCompactList}\item 
{\footnotesize template$<$unsigned int N, typename TOUT$>$ }\\std\+::string \mbox{\hyperlink{Polynomial_8hpp_a858064673c60f44633356d74e1c9fa90}{polynomial\+\_\+print}} (const \mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$ \&p)
\item 
{\footnotesize template$<$unsigned int N, typename TOUT$>$ }\\std\+::ostream \& \mbox{\hyperlink{Polynomial_8hpp_a2a0ec246a938810495b66ac480a967f7}{operator$<$$<$}} (std\+::ostream \&out, const \mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$ \&p)
\item 
{\footnotesize template$<$unsigned int N, typename TOUT$>$ }\\std\+::string \mbox{\hyperlink{Polynomial_8hpp_a52d0f263ef52205b8d2d86139da48dc9}{to\+\_\+string}} (const \mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$ \&p)
\end{DoxyCompactItemize}


\doxysubsubsection{Detailed Description}
Define a polynomial and provide several helper functions. 



\label{doc-func-members}
\Hypertarget{Polynomial_8hpp_doc-func-members}
\doxysubsubsection{Function Documentation}
\Hypertarget{Polynomial_8hpp_abeddf4a63f948b91197ac50f9ee238cd}\index{Polynomial.hpp@{Polynomial.hpp}!eval@{eval}}
\index{eval@{eval}!Polynomial.hpp@{Polynomial.hpp}}
\doxyparagraph{\texorpdfstring{eval()}{eval()}}
{\footnotesize\ttfamily \label{Polynomial_8hpp_abeddf4a63f948b91197ac50f9ee238cd} 
template$<$unsigned int N, typename TOUT, typename TIN = TOUT$>$ \\
TOUT eval (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$}]{p}{, }\item[{TIN}]{x}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Compute $p(x)$. 

\begin{DoxyNote}{Note}
$p$ cannot be empty 
\end{DoxyNote}
\Hypertarget{Polynomial_8hpp_a2a0ec246a938810495b66ac480a967f7}\index{Polynomial.hpp@{Polynomial.hpp}!operator$<$$<$@{operator$<$$<$}}
\index{operator$<$$<$@{operator$<$$<$}!Polynomial.hpp@{Polynomial.hpp}}
\doxyparagraph{\texorpdfstring{operator$<$$<$()}{operator<<()}}
{\footnotesize\ttfamily \label{Polynomial_8hpp_a2a0ec246a938810495b66ac480a967f7} 
template$<$unsigned int N, typename TOUT$>$ \\
std\+::ostream \& operator$<$$<$ (\begin{DoxyParamCaption}\item[{std\+::ostream \&}]{out}{, }\item[{const \mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$ \&}]{p}{}\end{DoxyParamCaption})}

Print basic info about a polynomial \Hypertarget{Polynomial_8hpp_a9e7241eec8112d9048e48e184b32c2cb}\index{Polynomial.hpp@{Polynomial.hpp}!polynomial\_diff@{polynomial\_diff}}
\index{polynomial\_diff@{polynomial\_diff}!Polynomial.hpp@{Polynomial.hpp}}
\doxyparagraph{\texorpdfstring{polynomial\_diff()}{polynomial\_diff()}}
{\footnotesize\ttfamily \label{Polynomial_8hpp_a9e7241eec8112d9048e48e184b32c2cb} 
template$<$unsigned int N, typename TOUT, typename TIN = TOUT$>$ \\
TOUT polynomial\+\_\+diff (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$}]{p}{, }\item[{TIN}]{x}{, }\item[{unsigned}]{s}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Compute $p^{(s)}(x)$, the $s$th derivative of $p$ at $x$. 

\begin{DoxyNote}{Note}
$p$ cannot be empty 
\end{DoxyNote}
\Hypertarget{Polynomial_8hpp_a858064673c60f44633356d74e1c9fa90}\index{Polynomial.hpp@{Polynomial.hpp}!polynomial\_print@{polynomial\_print}}
\index{polynomial\_print@{polynomial\_print}!Polynomial.hpp@{Polynomial.hpp}}
\doxyparagraph{\texorpdfstring{polynomial\_print()}{polynomial\_print()}}
{\footnotesize\ttfamily \label{Polynomial_8hpp_a858064673c60f44633356d74e1c9fa90} 
template$<$unsigned int N, typename TOUT$>$ \\
std\+::string polynomial\+\_\+print (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$ \&}]{p}{}\end{DoxyParamCaption})}

Convenient debugging method for printing a polynomial. TODO this could wrap operator\texorpdfstring{$<$}{<}\texorpdfstring{$<$}{<} \Hypertarget{Polynomial_8hpp_a1a1546bab925591a6306914032b65a5d}\index{Polynomial.hpp@{Polynomial.hpp}!taylor\_shift@{taylor\_shift}}
\index{taylor\_shift@{taylor\_shift}!Polynomial.hpp@{Polynomial.hpp}}
\doxyparagraph{\texorpdfstring{taylor\_shift()}{taylor\_shift()}}
{\footnotesize\ttfamily \label{Polynomial_8hpp_a1a1546bab925591a6306914032b65a5d} 
template$<$unsigned int N, typename TOUT, typename TIN = TOUT$>$ \\
polynomial$<$ TOUT, N $>$ taylor\+\_\+shift (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$}]{p}{, }\item[{TIN}]{a}{, }\item[{TIN}]{b}{, }\item[{TIN}]{c}{, }\item[{TIN}]{d}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Given a polynomial $p:[a,b]\to\mathbb{R}$, compute the coefficients of $q:[c,d]\to\mathbb{R}$ such that $q(x) = p( [(b-a)x + (ad-bc)]/(d-c) )$ by expanding $p$ in a Taylor series. 

This is used all over FunC (for example, special case for rightmost interval, Nonuniform LUTs, and Taylor/\+Pade tables). Optimizations are very welcome! \Hypertarget{Polynomial_8hpp_a52d0f263ef52205b8d2d86139da48dc9}\index{Polynomial.hpp@{Polynomial.hpp}!to\_string@{to\_string}}
\index{to\_string@{to\_string}!Polynomial.hpp@{Polynomial.hpp}}
\doxyparagraph{\texorpdfstring{to\_string()}{to\_string()}}
{\footnotesize\ttfamily \label{Polynomial_8hpp_a52d0f263ef52205b8d2d86139da48dc9} 
template$<$unsigned int N, typename TOUT$>$ \\
std\+::string to\+\_\+string (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{structfunc_1_1polynomial__helper}{polynomial}}$<$ TOUT, N $>$ \&}]{p}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}

wraps operator\texorpdfstring{$<$}{<}\texorpdfstring{$<$}{<} 