\section{Simple\+Residue\+Termination Class Reference}
\label{classmlpack_1_1amf_1_1SimpleResidueTermination}\index{Simple\+Residue\+Termination@{Simple\+Residue\+Termination}}


This class implements a simple residue-\/based termination policy.  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ Simple\+Residue\+Termination} (const double \textbf{ min\+Residue}=1e-\/5, const size\+\_\+t max\+Iterations=10000)
\begin{DoxyCompactList}\small\item\em Construct the \doxyref{Simple\+Residue\+Termination}{p.}{classmlpack_1_1amf_1_1SimpleResidueTermination} object with the given minimum residue (or the default) and the given maximum number of iterations (or the default). \end{DoxyCompactList}\item 
const double \& \textbf{ Index} () const
\begin{DoxyCompactList}\small\item\em Get current value of residue. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Mat\+Type $>$ }\\void \textbf{ Initialize} (const Mat\+Type \&V)
\begin{DoxyCompactList}\small\item\em Initializes the termination policy before stating the factorization. \end{DoxyCompactList}\item 
bool \textbf{ Is\+Converged} (arma\+::mat \&W, arma\+::mat \&H)
\begin{DoxyCompactList}\small\item\em Check if termination criterion is met. \end{DoxyCompactList}\item 
const size\+\_\+t \& \textbf{ Iteration} () const
\begin{DoxyCompactList}\small\item\em Get current iteration count. \end{DoxyCompactList}\item 
const size\+\_\+t \& \textbf{ Max\+Iterations} () const
\begin{DoxyCompactList}\small\item\em Access max iteration count. \end{DoxyCompactList}\item 
size\+\_\+t \& \textbf{ Max\+Iterations} ()
\item 
const double \& \textbf{ Min\+Residue} () const
\begin{DoxyCompactList}\small\item\em Access minimum residue value. \end{DoxyCompactList}\item 
double \& \textbf{ Min\+Residue} ()
\end{DoxyCompactItemize}
\subsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item 
size\+\_\+t \textbf{ iteration}
\begin{DoxyCompactList}\small\item\em current iteration count \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ max\+Iterations}
\begin{DoxyCompactList}\small\item\em iteration threshold \end{DoxyCompactList}\item 
double \textbf{ min\+Residue}
\begin{DoxyCompactList}\small\item\em residue threshold \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ nm}
\item 
double \textbf{ norm\+Old}
\begin{DoxyCompactList}\small\item\em norm of previous iteration \end{DoxyCompactList}\item 
double \textbf{ residue}
\begin{DoxyCompactList}\small\item\em current value of residue \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
This class implements a simple residue-\/based termination policy. 

The termination decision depends on two factors\+: the value of the residue (the difference between the norm of WH this iteration and the previous iteration), and the number of iterations. If the current value of residue drops below the threshold or the number of iterations goes above the iteration limit, \doxyref{Is\+Converged()}{p.}{classmlpack_1_1amf_1_1SimpleResidueTermination_a21aa00d1db37e94076e46c66313514df} will return true. This class is meant for use with the \doxyref{A\+MF}{p.}{classmlpack_1_1amf_1_1AMF} (alternating matrix factorization) class.

\begin{DoxySeeAlso}{See also}
\doxyref{A\+MF}{p.}{classmlpack_1_1amf_1_1AMF} 
\end{DoxySeeAlso}


Definition at line 31 of file simple\+\_\+residue\+\_\+termination.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_a570ec59973b912241a25071038088bd8}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!Simple\+Residue\+Termination@{Simple\+Residue\+Termination}}
\index{Simple\+Residue\+Termination@{Simple\+Residue\+Termination}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{Simple\+Residue\+Termination()}
{\footnotesize\ttfamily \textbf{ Simple\+Residue\+Termination} (\begin{DoxyParamCaption}\item[{const double}]{min\+Residue = {\ttfamily 1e-\/5},  }\item[{const size\+\_\+t}]{max\+Iterations = {\ttfamily 10000} }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Construct the \doxyref{Simple\+Residue\+Termination}{p.}{classmlpack_1_1amf_1_1SimpleResidueTermination} object with the given minimum residue (or the default) and the given maximum number of iterations (or the default). 

0 indicates no iteration limit.


\begin{DoxyParams}{Parameters}
{\em min\+Residue} & Minimum residue for termination. \\
\hline
{\em max\+Iterations} & Maximum number of iterations. \\
\hline
\end{DoxyParams}


Definition at line 42 of file simple\+\_\+residue\+\_\+termination.\+hpp.



\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_a866b70f9202a81d2bdbb116bc2683eb2}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!Index@{Index}}
\index{Index@{Index}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{Index()}
{\footnotesize\ttfamily const double\& Index (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Get current value of residue. 



Definition at line 90 of file simple\+\_\+residue\+\_\+termination.\+hpp.



References Simple\+Residue\+Termination\+::residue.

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_a7cd2df552c1f471b3248ac66291133f3}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!Initialize@{Initialize}}
\index{Initialize@{Initialize}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{Initialize()}
{\footnotesize\ttfamily void Initialize (\begin{DoxyParamCaption}\item[{const Mat\+Type \&}]{V }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Initializes the termination policy before stating the factorization. 


\begin{DoxyParams}{Parameters}
{\em V} & Input matrix being factorized. \\
\hline
\end{DoxyParams}


Definition at line 52 of file simple\+\_\+residue\+\_\+termination.\+hpp.



References Simple\+Residue\+Termination\+::iteration, Simple\+Residue\+Termination\+::nm, Simple\+Residue\+Termination\+::norm\+Old, and Simple\+Residue\+Termination\+::residue.

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_a21aa00d1db37e94076e46c66313514df}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!Is\+Converged@{Is\+Converged}}
\index{Is\+Converged@{Is\+Converged}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{Is\+Converged()}
{\footnotesize\ttfamily bool Is\+Converged (\begin{DoxyParamCaption}\item[{arma\+::mat \&}]{W,  }\item[{arma\+::mat \&}]{H }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Check if termination criterion is met. 


\begin{DoxyParams}{Parameters}
{\em W} & Basis matrix of output. \\
\hline
{\em H} & Encoding matrix of output. \\
\hline
\end{DoxyParams}


Definition at line 68 of file simple\+\_\+residue\+\_\+termination.\+hpp.



References Log\+::\+Info, Simple\+Residue\+Termination\+::iteration, Simple\+Residue\+Termination\+::max\+Iterations, Simple\+Residue\+Termination\+::min\+Residue, Simple\+Residue\+Termination\+::norm\+Old, and Simple\+Residue\+Termination\+::residue.

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_a5226c80136390904f5893e72749211e6}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!Iteration@{Iteration}}
\index{Iteration@{Iteration}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{Iteration()}
{\footnotesize\ttfamily const size\+\_\+t\& Iteration (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Get current iteration count. 



Definition at line 93 of file simple\+\_\+residue\+\_\+termination.\+hpp.



References Simple\+Residue\+Termination\+::iteration.

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_a26b939a18b15788ad266b8eda3f301e6}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!Max\+Iterations@{Max\+Iterations}}
\index{Max\+Iterations@{Max\+Iterations}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{Max\+Iterations()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily const size\+\_\+t\& Max\+Iterations (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Access max iteration count. 



Definition at line 96 of file simple\+\_\+residue\+\_\+termination.\+hpp.



References Simple\+Residue\+Termination\+::max\+Iterations.

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_acda675ab4ab86b95c92bc33bc391a61b}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!Max\+Iterations@{Max\+Iterations}}
\index{Max\+Iterations@{Max\+Iterations}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{Max\+Iterations()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily size\+\_\+t\& Max\+Iterations (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Definition at line 97 of file simple\+\_\+residue\+\_\+termination.\+hpp.



References Simple\+Residue\+Termination\+::max\+Iterations.

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_a66770866442706127d463aa30f80b2be}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!Min\+Residue@{Min\+Residue}}
\index{Min\+Residue@{Min\+Residue}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{Min\+Residue()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily const double\& Min\+Residue (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Access minimum residue value. 



Definition at line 100 of file simple\+\_\+residue\+\_\+termination.\+hpp.



References Simple\+Residue\+Termination\+::min\+Residue.

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_a4233be9459e245d771ff723b0bfa3b77}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!Min\+Residue@{Min\+Residue}}
\index{Min\+Residue@{Min\+Residue}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{Min\+Residue()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily double\& Min\+Residue (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Definition at line 101 of file simple\+\_\+residue\+\_\+termination.\+hpp.



References Simple\+Residue\+Termination\+::min\+Residue.



\subsection{Member Data Documentation}
\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_a5e82034717bd8738680b6efc7165182d}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!iteration@{iteration}}
\index{iteration@{iteration}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{iteration}
{\footnotesize\ttfamily size\+\_\+t iteration}



current iteration count 



Definition at line 112 of file simple\+\_\+residue\+\_\+termination.\+hpp.



Referenced by Simple\+Residue\+Termination\+::\+Initialize(), Simple\+Residue\+Termination\+::\+Is\+Converged(), and Simple\+Residue\+Termination\+::\+Iteration().

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_adb3fa2e38847b23885acf3833f28538e}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!max\+Iterations@{max\+Iterations}}
\index{max\+Iterations@{max\+Iterations}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{max\+Iterations}
{\footnotesize\ttfamily size\+\_\+t max\+Iterations}



iteration threshold 



Definition at line 107 of file simple\+\_\+residue\+\_\+termination.\+hpp.



Referenced by Simple\+Residue\+Termination\+::\+Is\+Converged(), and Simple\+Residue\+Termination\+::\+Max\+Iterations().

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_aa626b3a82fbec8cdaf543b7a182f0f24}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!min\+Residue@{min\+Residue}}
\index{min\+Residue@{min\+Residue}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{min\+Residue}
{\footnotesize\ttfamily double min\+Residue}



residue threshold 



Definition at line 105 of file simple\+\_\+residue\+\_\+termination.\+hpp.



Referenced by Simple\+Residue\+Termination\+::\+Is\+Converged(), and Simple\+Residue\+Termination\+::\+Min\+Residue().

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_a29e240dd3e893cad23a191cae244bbe9}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!nm@{nm}}
\index{nm@{nm}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{nm}
{\footnotesize\ttfamily size\+\_\+t nm}



Definition at line 116 of file simple\+\_\+residue\+\_\+termination.\+hpp.



Referenced by Simple\+Residue\+Termination\+::\+Initialize().

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_acdf05c025498f6ff125ceb7e76ee9980}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!norm\+Old@{norm\+Old}}
\index{norm\+Old@{norm\+Old}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{norm\+Old}
{\footnotesize\ttfamily double norm\+Old}



norm of previous iteration 



Definition at line 114 of file simple\+\_\+residue\+\_\+termination.\+hpp.



Referenced by Simple\+Residue\+Termination\+::\+Initialize(), and Simple\+Residue\+Termination\+::\+Is\+Converged().

\mbox{\label{classmlpack_1_1amf_1_1SimpleResidueTermination_a1482cb31e6b6b5b272baf532461b9ffb}} 
\index{mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}!residue@{residue}}
\index{residue@{residue}!mlpack\+::amf\+::\+Simple\+Residue\+Termination@{mlpack\+::amf\+::\+Simple\+Residue\+Termination}}
\subsubsection{residue}
{\footnotesize\ttfamily double residue}



current value of residue 



Definition at line 110 of file simple\+\_\+residue\+\_\+termination.\+hpp.



Referenced by Simple\+Residue\+Termination\+::\+Index(), Simple\+Residue\+Termination\+::\+Initialize(), and Simple\+Residue\+Termination\+::\+Is\+Converged().



The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/var/www/mlpack.\+ratml.\+org/mlpack.\+org/\+\_\+src/mlpack-\/3.\+3.\+2/src/mlpack/methods/amf/termination\+\_\+policies/\textbf{ simple\+\_\+residue\+\_\+termination.\+hpp}\end{DoxyCompactItemize}
