\hypertarget{namespacepolynomial__functions}{}\section{polynomial\+\_\+functions Module Reference}
\label{namespacepolynomial__functions}\index{polynomial\+\_\+functions@{polynomial\+\_\+functions}}


\subsection{Detailed Description}
Polynomial functions. 

Date of creation\+: 2008.\+06.\+12 L. White.

This module contains routines that handle polynomials. \subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
real function, public \hyperlink{namespacepolynomial__functions_adb2b5d18db527314545e8e21638a2872}{evaluation\+\_\+polynomial} (coeff, ncoef, x)
\begin{DoxyCompactList}\small\item\em Pointwise evaluation of a polynomial at x. \end{DoxyCompactList}\item 
real function, public \hyperlink{namespacepolynomial__functions_a38462b1bc63d3f1f441e4d340c2b4627}{first\+\_\+derivative\+\_\+polynomial} (coeff, ncoef, x)
\begin{DoxyCompactList}\small\item\em Calculates the first derivative of a polynomial evaluated at a point x. \end{DoxyCompactList}\item 
real function, public \hyperlink{namespacepolynomial__functions_ae7112cbad01d6a9477bbaf4a9695ed7a}{integration\+\_\+polynomial} (xi0, xi1, Coeff, npoly)
\begin{DoxyCompactList}\small\item\em Exact integration of polynomial of degree npoly. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacepolynomial__functions_adb2b5d18db527314545e8e21638a2872}\label{namespacepolynomial__functions_adb2b5d18db527314545e8e21638a2872}} 
\index{polynomial\+\_\+functions@{polynomial\+\_\+functions}!evaluation\+\_\+polynomial@{evaluation\+\_\+polynomial}}
\index{evaluation\+\_\+polynomial@{evaluation\+\_\+polynomial}!polynomial\+\_\+functions@{polynomial\+\_\+functions}}
\subsubsection{\texorpdfstring{evaluation\+\_\+polynomial()}{evaluation\_polynomial()}}
{\footnotesize\ttfamily real function, public polynomial\+\_\+functions\+::evaluation\+\_\+polynomial (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{coeff,  }\item[{integer, intent(in)}]{ncoef,  }\item[{real, intent(in)}]{x }\end{DoxyParamCaption})}



Pointwise evaluation of a polynomial at x. 

The polynomial is defined by the coefficients contained in the array of the same name, as follows\+: C(1) + C(2)x + C(3)x$^\wedge$2 + C(4)x$^\wedge$3 + ... where C refers to the array \textquotesingle{}coeff\textquotesingle{}. The number of coefficients is given by ncoef and x is the coordinate where the polynomial is to be evaluated.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em coeff} & The coefficients of the polynomial\\
\hline
\mbox{\tt in}  & {\em ncoef} & The number of polynomial coefficients\\
\hline
\mbox{\tt in}  & {\em x} & The position at which to evaluate the polynomial \\
\hline
\end{DoxyParams}


Definition at line 20 of file polynomial\+\_\+functions.\+F90.


\begin{DoxyCode}
20   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: coeff\textcolor{comment}{ !< The coefficients of the polynomial}
21   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)} :: ncoef\textcolor{comment}{ !< The number of polynomial coefficients}
22   \textcolor{keywordtype}{real},               \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{     !< The position at which to evaluate the polynomial}
23   \textcolor{comment}{! Local variables}
24   \textcolor{keywordtype}{integer} :: k
25   \textcolor{keywordtype}{real}    :: f    \textcolor{comment}{! value of polynomial at x}
26 
27   f = 0.0
28   \textcolor{keywordflow}{do} k = 1,ncoef
29     f = f + coeff(k) * ( x**(k-1) )
30 \textcolor{keywordflow}{  enddo}
31 
32   evaluation\_polynomial = f
33 
\end{DoxyCode}
\mbox{\Hypertarget{namespacepolynomial__functions_a38462b1bc63d3f1f441e4d340c2b4627}\label{namespacepolynomial__functions_a38462b1bc63d3f1f441e4d340c2b4627}} 
\index{polynomial\+\_\+functions@{polynomial\+\_\+functions}!first\+\_\+derivative\+\_\+polynomial@{first\+\_\+derivative\+\_\+polynomial}}
\index{first\+\_\+derivative\+\_\+polynomial@{first\+\_\+derivative\+\_\+polynomial}!polynomial\+\_\+functions@{polynomial\+\_\+functions}}
\subsubsection{\texorpdfstring{first\+\_\+derivative\+\_\+polynomial()}{first\_derivative\_polynomial()}}
{\footnotesize\ttfamily real function, public polynomial\+\_\+functions\+::first\+\_\+derivative\+\_\+polynomial (\begin{DoxyParamCaption}\item[{real, dimension(\+:), intent(in)}]{coeff,  }\item[{integer, intent(in)}]{ncoef,  }\item[{real, intent(in)}]{x }\end{DoxyParamCaption})}



Calculates the first derivative of a polynomial evaluated at a point x. 

The polynomial is defined by the coefficients contained in the array of the same name, as follows\+: C(1) + C(2)x + C(3)x$^\wedge$2 + C(4)x$^\wedge$3 + ... where C refers to the array \textquotesingle{}coeff\textquotesingle{}. The number of coefficients is given by ncoef and x is the coordinate where the polynomial\textquotesingle{}s derivative is to be evaluated.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em coeff} & The coefficients of the polynomial\\
\hline
\mbox{\tt in}  & {\em ncoef} & The number of polynomial coefficients\\
\hline
\mbox{\tt in}  & {\em x} & The position at which to evaluate the derivative \\
\hline
\end{DoxyParams}


Definition at line 44 of file polynomial\+\_\+functions.\+F90.


\begin{DoxyCode}
44   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: coeff\textcolor{comment}{ !< The coefficients of the polynomial}
45   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)} :: ncoef\textcolor{comment}{ !< The number of polynomial coefficients}
46   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}               :: x\textcolor{comment}{     !< The position at which to evaluate the derivative}
47   \textcolor{comment}{! Local variables}
48   \textcolor{keywordtype}{integer}                               :: k
49   \textcolor{keywordtype}{real}                                  :: f    \textcolor{comment}{! value of polynomial at x}
50 
51   f = 0.0
52   \textcolor{keywordflow}{do} k = 2,ncoef
53     f = f + \textcolor{keywordtype}{REAL}(k-1)*coeff(k) * ( x**(k-2) )
54 \textcolor{keywordflow}{  enddo}
55 
56   first\_derivative\_polynomial = f
57 
\end{DoxyCode}
\mbox{\Hypertarget{namespacepolynomial__functions_ae7112cbad01d6a9477bbaf4a9695ed7a}\label{namespacepolynomial__functions_ae7112cbad01d6a9477bbaf4a9695ed7a}} 
\index{polynomial\+\_\+functions@{polynomial\+\_\+functions}!integration\+\_\+polynomial@{integration\+\_\+polynomial}}
\index{integration\+\_\+polynomial@{integration\+\_\+polynomial}!polynomial\+\_\+functions@{polynomial\+\_\+functions}}
\subsubsection{\texorpdfstring{integration\+\_\+polynomial()}{integration\_polynomial()}}
{\footnotesize\ttfamily real function, public polynomial\+\_\+functions\+::integration\+\_\+polynomial (\begin{DoxyParamCaption}\item[{real, intent(in)}]{xi0,  }\item[{real, intent(in)}]{xi1,  }\item[{real, dimension(\+:), intent(in)}]{Coeff,  }\item[{integer, intent(in)}]{npoly }\end{DoxyParamCaption})}



Exact integration of polynomial of degree npoly. 

The array of coefficients (Coeff) must be of size npoly+1.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em xi0} & The lower bound of the integral\\
\hline
\mbox{\tt in}  & {\em xi1} & The lower bound of the integral\\
\hline
\mbox{\tt in}  & {\em coeff} & The coefficients of the polynomial\\
\hline
\mbox{\tt in}  & {\em npoly} & The degree of the polynomial \\
\hline
\end{DoxyParams}


Definition at line 64 of file polynomial\+\_\+functions.\+F90.


\begin{DoxyCode}
64   \textcolor{keywordtype}{real},               \textcolor{keywordtype}{intent(in)} :: xi0\textcolor{comment}{   !< The lower bound of the integral}
65   \textcolor{keywordtype}{real},               \textcolor{keywordtype}{intent(in)} :: xi1\textcolor{comment}{   !< The lower bound of the integral}
66   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: coeff\textcolor{comment}{ !< The coefficients of the polynomial}
67   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)} :: npoly\textcolor{comment}{ !< The degree of the polynomial}
68   \textcolor{comment}{! Local variables}
69   \textcolor{keywordtype}{integer}                           :: k
70   \textcolor{keywordtype}{real}                              :: integral
71 
72   integral = 0.0
73 
74   \textcolor{keywordflow}{do} k = 1,npoly+1
75     integral = integral + coeff(k) * (xi1**k - xi0**k) / \textcolor{keywordtype}{real}(k)
76 \textcolor{keywordflow}{  enddo}
77 \textcolor{comment}{!}
78 \textcolor{comment}{!One non-answer-changing way of unrolling the above is:}
79 \textcolor{comment}{!  k=1}
80 \textcolor{comment}{!  integral = integral + Coeff(k) * (xi1**k - xi0**k) / real(k)}
81 \textcolor{comment}{!  if (npoly>=1) then}
82 \textcolor{comment}{!    k=2}
83 \textcolor{comment}{!    integral = integral + Coeff(k) * (xi1**k - xi0**k) / real(k)}
84 \textcolor{comment}{!  endif}
85 \textcolor{comment}{!  if (npoly>=2) then}
86 \textcolor{comment}{!    k=3}
87 \textcolor{comment}{!    integral = integral + Coeff(k) * (xi1**k - xi0**k) / real(k)}
88 \textcolor{comment}{!  endif}
89 \textcolor{comment}{!  if (npoly>=3) then}
90 \textcolor{comment}{!    k=4}
91 \textcolor{comment}{!    integral = integral + Coeff(k) * (xi1**k - xi0**k) / real(k)}
92 \textcolor{comment}{!  endif}
93 \textcolor{comment}{!  if (npoly>=4) then}
94 \textcolor{comment}{!    k=5}
95 \textcolor{comment}{!    integral = integral + Coeff(k) * (xi1**k - xi0**k) / real(k)}
96 \textcolor{comment}{!  endif}
97 \textcolor{comment}{!}
98   integration\_polynomial = integral
99 
\end{DoxyCode}
