\section{N\+M\+F\+A\+L\+S\+Update Class Reference}
\label{classmlpack_1_1amf_1_1NMFALSUpdate}\index{N\+M\+F\+A\+L\+S\+Update@{N\+M\+F\+A\+L\+S\+Update}}


This class implements a method titled \textquotesingle{}Alternating Least Squares\textquotesingle{} described in the following paper\+:  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ N\+M\+F\+A\+L\+S\+Update} ()
\begin{DoxyCompactList}\small\item\em Empty constructor required for the Update\+Rule template. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Mat\+Type $>$ }\\void \textbf{ Initialize} (const Mat\+Type \&, const size\+\_\+t)
\begin{DoxyCompactList}\small\item\em Set initial values for the factorization. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Archive $>$ }\\void \textbf{ serialize} (Archive \&, const unsigned int)
\begin{DoxyCompactList}\small\item\em Serialize the object (in this case, there is nothing to serialize). \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename Mat\+Type $>$ }\\static void \textbf{ H\+Update} (const Mat\+Type \&V, const arma\+::mat \&W, arma\+::mat \&H)
\begin{DoxyCompactList}\small\item\em The update rule for the encoding matrix H. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Mat\+Type $>$ }\\static void \textbf{ W\+Update} (const Mat\+Type \&V, arma\+::mat \&W, const arma\+::mat \&H)
\begin{DoxyCompactList}\small\item\em The update rule for the basis matrix W. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
This class implements a method titled \textquotesingle{}Alternating Least Squares\textquotesingle{} described in the following paper\+: 


\begin{DoxyCode}
@article\{paatero1994positive,
 title=\{Positive matrix factorization: A non-negative factor model with
     optimal utilization of error estimates of data values\},
 author=\{Paatero, P. and Tapper, U.\},
 journal=\{Environmetrics\},
 volume=\{5\},
 number=\{2\},
 pages=\{111--126\},
 year=\{1994\}
\}
\end{DoxyCode}


It uses the least squares projection formula to reduce the error value of $ \sqrt{\sum_i \sum_j(V-WH)^2} $ by alternately calculating W and H respectively while holding the other matrix constant. 

Definition at line 41 of file nmf\+\_\+als.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1amf_1_1NMFALSUpdate_a3482d9d8fc18996cee80de1f698b3a09}} 
\index{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update@{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update}!N\+M\+F\+A\+L\+S\+Update@{N\+M\+F\+A\+L\+S\+Update}}
\index{N\+M\+F\+A\+L\+S\+Update@{N\+M\+F\+A\+L\+S\+Update}!mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update@{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update}}
\subsubsection{N\+M\+F\+A\+L\+S\+Update()}
{\footnotesize\ttfamily \textbf{ N\+M\+F\+A\+L\+S\+Update} (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Empty constructor required for the Update\+Rule template. 



Definition at line 45 of file nmf\+\_\+als.\+hpp.



\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1amf_1_1NMFALSUpdate_ad2a433d7e149001f0f44caa8967d20a6}} 
\index{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update@{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update}!H\+Update@{H\+Update}}
\index{H\+Update@{H\+Update}!mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update@{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update}}
\subsubsection{H\+Update()}
{\footnotesize\ttfamily static void H\+Update (\begin{DoxyParamCaption}\item[{const Mat\+Type \&}]{V,  }\item[{const arma\+::mat \&}]{W,  }\item[{arma\+::mat \&}]{H }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



The update rule for the encoding matrix H. 

The formula used is

\[ H = \frac{W^T V}{W^T W} \]

The function takes in all the matrices and only changes the value of the H matrix.


\begin{DoxyParams}{Parameters}
{\em V} & Input matrix to be factorized. \\
\hline
{\em W} & Basis matrix. \\
\hline
{\em H} & Encoding matrix to be updated. \\
\hline
\end{DoxyParams}


Definition at line 105 of file nmf\+\_\+als.\+hpp.

\mbox{\label{classmlpack_1_1amf_1_1NMFALSUpdate_aac5af164b10635addd7ff7bb934a4db3}} 
\index{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update@{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update}!Initialize@{Initialize}}
\index{Initialize@{Initialize}!mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update@{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update}}
\subsubsection{Initialize()}
{\footnotesize\ttfamily void Initialize (\begin{DoxyParamCaption}\item[{const Mat\+Type \&}]{,  }\item[{const size\+\_\+t}]{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Set initial values for the factorization. 

In this case, we don\textquotesingle{}t need to set anything. 

Definition at line 52 of file nmf\+\_\+als.\+hpp.

\mbox{\label{classmlpack_1_1amf_1_1NMFALSUpdate_aa5b3dd8336182f751ebec27167c22415}} 
\index{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update@{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update}!serialize@{serialize}}
\index{serialize@{serialize}!mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update@{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update}}
\subsubsection{serialize()}
{\footnotesize\ttfamily void serialize (\begin{DoxyParamCaption}\item[{Archive \&}]{,  }\item[{const unsigned}]{int }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Serialize the object (in this case, there is nothing to serialize). 



Definition at line 123 of file nmf\+\_\+als.\+hpp.

\mbox{\label{classmlpack_1_1amf_1_1NMFALSUpdate_a79b17bfdd69326a4f9f7d17c698ee6af}} 
\index{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update@{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update}!W\+Update@{W\+Update}}
\index{W\+Update@{W\+Update}!mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update@{mlpack\+::amf\+::\+N\+M\+F\+A\+L\+S\+Update}}
\subsubsection{W\+Update()}
{\footnotesize\ttfamily static void W\+Update (\begin{DoxyParamCaption}\item[{const Mat\+Type \&}]{V,  }\item[{arma\+::mat \&}]{W,  }\item[{const arma\+::mat \&}]{H }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



The update rule for the basis matrix W. 

The formula used isa

\[ W^T = \frac{H V^T}{H H^T} \]

The function takes in all the matrices and only changes the value of the W matrix.


\begin{DoxyParams}{Parameters}
{\em V} & Input matrix to be factorized. \\
\hline
{\em W} & Basis matrix to be updated. \\
\hline
{\em H} & Encoding matrix. \\
\hline
\end{DoxyParams}


Definition at line 72 of file nmf\+\_\+als.\+hpp.



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/update\+\_\+rules/\textbf{ nmf\+\_\+als.\+hpp}\end{DoxyCompactItemize}
