\doxysubsection{Transfer\+Function\texorpdfstring{$<$}{<} TIN \texorpdfstring{$>$}{>} Class Template Reference}
\hypertarget{classfunc_1_1TransferFunction}{}\label{classfunc_1_1TransferFunction}\index{TransferFunction$<$ TIN $>$@{TransferFunction$<$ TIN $>$}}


Transforms a uniformly spaced partition of $[a,b]$ into a nonuniform partition of $[a,b]$.  




{\ttfamily \#include $<$Transfer\+Function.\+hpp$>$}

\doxysubsubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{classfunc_1_1TransferFunction_ac53a4169c1980bf5807c2975ce578f04}\label{classfunc_1_1TransferFunction_ac53a4169c1980bf5807c2975ce578f04} 
{\bfseries Transfer\+Function} (const std\+::array$<$ TIN, 4 $>$ \&inv\+\_\+coefs)
\item 
{\footnotesize template$<$typename TOUT$>$ }\\\mbox{\hyperlink{classfunc_1_1TransferFunction_a9f54afdbae15eb1ca7e7052cfe966055}{Transfer\+Function}} (const \mbox{\hyperlink{classfunc_1_1FunctionContainer}{Function\+Container}}$<$ TIN, TOUT $>$ \&fc, TIN min\+Arg, TIN table\+Max\+Arg, TIN step\+Size)
\item 
TIN \mbox{\hyperlink{classfunc_1_1TransferFunction_ab03ed5da5641c5a16f9ccd83e9eca63e}{inverse}} (TIN x) const
\item 
TIN \mbox{\hyperlink{classfunc_1_1TransferFunction_a365e2254995a1f9190197ecf4ce7adfd}{inverse\+\_\+diff}} (TIN x) const
\item 
TIN \mbox{\hyperlink{classfunc_1_1TransferFunction_ab4eec5ae895d5dd0bb95b6547f16272d}{operator()}} (TIN x) const
\item 
\Hypertarget{classfunc_1_1TransferFunction_abc60f6ef1f52423edf9a1a175627d415}\label{classfunc_1_1TransferFunction_abc60f6ef1f52423edf9a1a175627d415} 
std\+::array$<$ TIN, 4 $>$ {\bfseries get\+\_\+coefs} () const
\item 
\Hypertarget{classfunc_1_1TransferFunction_a6a79eec136c95d9acc7bf421e361479f}\label{classfunc_1_1TransferFunction_a6a79eec136c95d9acc7bf421e361479f} 
TIN {\bfseries min\+\_\+arg} () const
\item 
\Hypertarget{classfunc_1_1TransferFunction_aa0de0dec96359f6e6d35aa69607b387a}\label{classfunc_1_1TransferFunction_aa0de0dec96359f6e6d35aa69607b387a} 
TIN {\bfseries max\+\_\+arg} () const
\end{DoxyCompactItemize}


\doxysubsubsection{Detailed Description}
\subsubsection*{template$<$typename TIN$>$\newline
class func\+::\+Transfer\+Function$<$ TIN $>$}
Transforms a uniformly spaced partition of $[a,b]$ into a nonuniform partition of $[a,b]$. 

For efficiency, we require a Transfer function is simply an increasing cubic polynomial such that $p(a)=0, p(b)=b/\mathrm{stepSize}$. To help compete against uniform lookup tables, part of the {\ttfamily operator()} must be baked into those coefficients (explaining why step\+Size appears in the formula above).

When given a \doxylink{classfunc_1_1FunctionContainer}{Function\+Container} with a defined first derivative then this will construct a valid \doxylink{classfunc_1_1TransferFunction}{Transfer\+Function}. Let $f$ be a function defined over $[a,b]$. Then, construct $S: [a,b]\rightarrow[a,b]$ as \[S(x) = a + \frac{b-a}{c}\int_a^x\frac{1}{\sqrt{1+f\textnormal{\textquotesingle}(t)^2}} dt,\] where $c = \int_a^b\frac{1}{\sqrt{1+f\textnormal{\textquotesingle}(t)^2}} dt$. This way, $S(a)=a, S(b)=b$. Computing $S^{-1}$ has to be fast so we approximate is as a monotone Hermite cubic polynomial and then rebuild $S$ as $(S^{-1})^{-1}$ using Boost\textquotesingle{}s newton\+\_\+raphson\+\_\+iterate.

\begin{DoxyNote}{Note}
Can be constructed with a std\+::array$<$\+TIN,4$>$ of polynomial coefficients. 

An example\+: the identity transfer function which is the linear polynomial with coefs \{-\/m\+\_\+min\+Arg/m\+\_\+step\+Size,1/m\+\_\+step\+Size,0,0\}.

We need Boost version 1.\+71.\+0 or newer to generate a candidate transfer function. Boost is not required if \doxylink{classfunc_1_1TransferFunction}{Transfer\+Function} is given coefficients. 

Resulting nonuniform LUT performs better if f\textquotesingle{} is largest near the endpoints \mbox{[}a,b\mbox{]}. If f\textquotesingle{} is largest near the middle of an interval (eg $e^{-x^2}$ when $a<-3$ and $b>3$) then the grid remains uniform. This is an issue with the way we approximate S!
\end{DoxyNote}
\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000005}{Todo}}]Currently, transfer functions are basically useless if $f\textnormal{\textquotesingle}$ is not extreme near the endpoints of its domain. (b/c we use cubic hermite interpolation at the endpoints).\end{DoxyRefDesc}


We want to accurately approximate $S$ anywhere $f\textnormal{\textquotesingle}(x)$ is extreme! The best possible polynomial approximating $S$ might be promising...

\begin{DoxyNote}{Note}
A cubic polynomial $p(x) = a_0 + a_1x + a_2x^2 + a_3x^3$ is monotone over $\mathbb{R}$ if and only if $a_2^2 < 3a_1a_3$. Maybe we can compute a polynomial minimizing $\max_t |f(t)-p(t)| $ such that $p(a) = a, p(b) = b$, and $a_2^2 < 3a_1a_3$. That would be a much better general purpose solution. The search space is convex! 
\end{DoxyNote}


\label{doc-constructors}
\Hypertarget{classfunc_1_1TransferFunction_doc-constructors}
\doxysubsubsection{Constructor \& Destructor Documentation}
\Hypertarget{classfunc_1_1TransferFunction_a9f54afdbae15eb1ca7e7052cfe966055}\index{TransferFunction$<$ TIN $>$@{TransferFunction$<$ TIN $>$}!TransferFunction@{TransferFunction}}
\index{TransferFunction@{TransferFunction}!TransferFunction$<$ TIN $>$@{TransferFunction$<$ TIN $>$}}
\doxyparagraph{\texorpdfstring{TransferFunction()}{TransferFunction()}}
{\footnotesize\ttfamily \label{classfunc_1_1TransferFunction_a9f54afdbae15eb1ca7e7052cfe966055} 
template$<$typename TIN$>$ \\
template$<$typename TOUT$>$ \\
\mbox{\hyperlink{classfunc_1_1TransferFunction}{Transfer\+Function}} (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classfunc_1_1FunctionContainer}{Function\+Container}}$<$ TIN, TOUT $>$ \&}]{fc}{, }\item[{TIN}]{min\+Arg}{, }\item[{TIN}]{table\+Max\+Arg}{, }\item[{TIN}]{step\+Size}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}

Build the coefficients in g\+\_\+inv 

\label{doc-func-members}
\Hypertarget{classfunc_1_1TransferFunction_doc-func-members}
\doxysubsubsection{Member Function Documentation}
\Hypertarget{classfunc_1_1TransferFunction_ab03ed5da5641c5a16f9ccd83e9eca63e}\index{TransferFunction$<$ TIN $>$@{TransferFunction$<$ TIN $>$}!inverse@{inverse}}
\index{inverse@{inverse}!TransferFunction$<$ TIN $>$@{TransferFunction$<$ TIN $>$}}
\doxyparagraph{\texorpdfstring{inverse()}{inverse()}}
{\footnotesize\ttfamily \label{classfunc_1_1TransferFunction_ab03ed5da5641c5a16f9ccd83e9eca63e} 
template$<$typename TIN$>$ \\
TIN inverse (\begin{DoxyParamCaption}\item[{TIN}]{x}{}\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}

Evaluate the inverse using Horner\textquotesingle{}s method \Hypertarget{classfunc_1_1TransferFunction_a365e2254995a1f9190197ecf4ce7adfd}\index{TransferFunction$<$ TIN $>$@{TransferFunction$<$ TIN $>$}!inverse\_diff@{inverse\_diff}}
\index{inverse\_diff@{inverse\_diff}!TransferFunction$<$ TIN $>$@{TransferFunction$<$ TIN $>$}}
\doxyparagraph{\texorpdfstring{inverse\_diff()}{inverse\_diff()}}
{\footnotesize\ttfamily \label{classfunc_1_1TransferFunction_a365e2254995a1f9190197ecf4ce7adfd} 
template$<$typename TIN$>$ \\
TIN inverse\+\_\+diff (\begin{DoxyParamCaption}\item[{TIN}]{x}{}\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}

Evaluate the derivative of the inverse using Horner\textquotesingle{}s method \Hypertarget{classfunc_1_1TransferFunction_ab4eec5ae895d5dd0bb95b6547f16272d}\index{TransferFunction$<$ TIN $>$@{TransferFunction$<$ TIN $>$}!operator()@{operator()}}
\index{operator()@{operator()}!TransferFunction$<$ TIN $>$@{TransferFunction$<$ TIN $>$}}
\doxyparagraph{\texorpdfstring{operator()()}{operator()()}}
{\footnotesize\ttfamily \label{classfunc_1_1TransferFunction_ab4eec5ae895d5dd0bb95b6547f16272d} 
template$<$typename TIN$>$ \\
TIN operator() (\begin{DoxyParamCaption}\item[{TIN}]{x}{}\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}

Use newton-\/raphson\+\_\+iteration on p. Recall that each coef in g was divided by h and we subtracted by m\+\_\+min\+Arg 

The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
Transfer\+Function.\+hpp\end{DoxyCompactItemize}
