\section{Sum\+Tree$<$ T $>$ Class Template Reference}
\label{classmlpack_1_1rl_1_1SumTree}\index{Sum\+Tree$<$ T $>$@{Sum\+Tree$<$ T $>$}}


Implementation of \doxyref{Sum\+Tree}{p.}{classmlpack_1_1rl_1_1SumTree}.  




Inheritance diagram for Sum\+Tree$<$ T $>$\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=147pt]{classmlpack_1_1rl_1_1SumTree__inherit__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ Sum\+Tree} ()
\begin{DoxyCompactList}\small\item\em Default constructor. \end{DoxyCompactList}\item 
\textbf{ Sum\+Tree} (const size\+\_\+t capacity)
\begin{DoxyCompactList}\small\item\em Construct an instance of \doxyref{Sum\+Tree}{p.}{classmlpack_1_1rl_1_1SumTree} class. \end{DoxyCompactList}\item 
void \textbf{ Batch\+Update} (const arma\+::ucolvec \&indices, const arma\+::\+Col$<$ T $>$ \&data)
\begin{DoxyCompactList}\small\item\em Update the data with batch rather loop over the indices with set method. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ Find\+Prefix\+Sum} (T mass)
\begin{DoxyCompactList}\small\item\em Find the highest index {\ttfamily idx} in the array such that sum(arr[0] + arr[1] + ... \end{DoxyCompactList}\item 
T \textbf{ Get} (size\+\_\+t idx)
\begin{DoxyCompactList}\small\item\em Get the data array with idx. \end{DoxyCompactList}\item 
void \textbf{ Set} (size\+\_\+t idx, const T value)
\begin{DoxyCompactList}\small\item\em Set the data array with idx. \end{DoxyCompactList}\item 
T \textbf{ Sum} (const size\+\_\+t start, size\+\_\+t end)
\begin{DoxyCompactList}\small\item\em Calculate the sum of contiguous subsequence of the array. \end{DoxyCompactList}\item 
T \textbf{ Sum} ()
\begin{DoxyCompactList}\small\item\em Shortcut for calculating the sum of whole array. \end{DoxyCompactList}\item 
T \textbf{ Sum\+Helper} (const size\+\_\+t start, const size\+\_\+t end, const size\+\_\+t node, const size\+\_\+t node\+Start, const size\+\_\+t node\+End)
\begin{DoxyCompactList}\small\item\em Help function for the {\ttfamily sum} function. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$typename T$>$\newline
class mlpack\+::rl\+::\+Sum\+Tree$<$ T $>$}

Implementation of \doxyref{Sum\+Tree}{p.}{classmlpack_1_1rl_1_1SumTree}. 

Build a Segment Tree like data structure. {\tt https\+://en.\+wikipedia.\+org/wiki/\+Segment\+\_\+tree}

Used to maintain prefix-\/sum of an array.


\begin{DoxyTemplParams}{Template Parameters}
{\em T} & The array\textquotesingle{}s element type. \\
\hline
\end{DoxyTemplParams}


Definition at line 32 of file sumtree.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1rl_1_1SumTree_af906043363eaf9a8b6245ee65c48879e}} 
\index{mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}!Sum\+Tree@{Sum\+Tree}}
\index{Sum\+Tree@{Sum\+Tree}!mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}}
\subsubsection{Sum\+Tree()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \textbf{ Sum\+Tree} (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Default constructor. 



Definition at line 38 of file sumtree.\+hpp.

\mbox{\label{classmlpack_1_1rl_1_1SumTree_a1320e39e7872440c0f719db04850ae60}} 
\index{mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}!Sum\+Tree@{Sum\+Tree}}
\index{Sum\+Tree@{Sum\+Tree}!mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}}
\subsubsection{Sum\+Tree()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \textbf{ Sum\+Tree} (\begin{DoxyParamCaption}\item[{const size\+\_\+t}]{capacity }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Construct an instance of \doxyref{Sum\+Tree}{p.}{classmlpack_1_1rl_1_1SumTree} class. 


\begin{DoxyParams}{Parameters}
{\em capacity} & Size of data. \\
\hline
\end{DoxyParams}


Definition at line 46 of file sumtree.\+hpp.



\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1rl_1_1SumTree_a326fbc401980f2b071d3a0f37d51be05}} 
\index{mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}!Batch\+Update@{Batch\+Update}}
\index{Batch\+Update@{Batch\+Update}!mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}}
\subsubsection{Batch\+Update()}
{\footnotesize\ttfamily void Batch\+Update (\begin{DoxyParamCaption}\item[{const arma\+::ucolvec \&}]{indices,  }\item[{const arma\+::\+Col$<$ T $>$ \&}]{data }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Update the data with batch rather loop over the indices with set method. 


\begin{DoxyParams}{Parameters}
{\em indices} & The indices of data to be changed. \\
\hline
{\em data} & The data that array with indices to be. \\
\hline
\end{DoxyParams}


Definition at line 75 of file sumtree.\+hpp.



Referenced by Prioritized\+Replay$<$ Environment\+Type $>$\+::\+Update\+Priorities().

\mbox{\label{classmlpack_1_1rl_1_1SumTree_a3cc70bfa6c4dd50a0dd99da3a60ec761}} 
\index{mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}!Find\+Prefix\+Sum@{Find\+Prefix\+Sum}}
\index{Find\+Prefix\+Sum@{Find\+Prefix\+Sum}!mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}}
\subsubsection{Find\+Prefix\+Sum()}
{\footnotesize\ttfamily size\+\_\+t Find\+Prefix\+Sum (\begin{DoxyParamCaption}\item[{T}]{mass }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Find the highest index {\ttfamily idx} in the array such that sum(arr[0] + arr[1] + ... 


\begin{DoxyItemize}
\item arr[idx]) $<$= mass.
\end{DoxyItemize}


\begin{DoxyParams}{Parameters}
{\em mass} & The upper bound of segment array sum. \\
\hline
\end{DoxyParams}


Definition at line 163 of file sumtree.\+hpp.



Referenced by Prioritized\+Replay$<$ Environment\+Type $>$\+::\+Sample\+Proportional().

\mbox{\label{classmlpack_1_1rl_1_1SumTree_a0f6adb7068497f76d7f01870c3fa32a0}} 
\index{mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}!Get@{Get}}
\index{Get@{Get}!mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}}
\subsubsection{Get()}
{\footnotesize\ttfamily T Get (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{idx }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Get the data array with idx. 


\begin{DoxyParams}{Parameters}
{\em idx} & The array idx to get data. \\
\hline
\end{DoxyParams}


Definition at line 93 of file sumtree.\+hpp.



Referenced by Prioritized\+Replay$<$ Environment\+Type $>$\+::\+Sample().

\mbox{\label{classmlpack_1_1rl_1_1SumTree_a60cd481b36347a9062b4e0c740c836ec}} 
\index{mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}!Set@{Set}}
\index{Set@{Set}!mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}}
\subsubsection{Set()}
{\footnotesize\ttfamily void Set (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{idx,  }\item[{const T}]{value }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Set the data array with idx. 


\begin{DoxyParams}{Parameters}
{\em idx} & The array idx to be changed. \\
\hline
{\em value} & The data that array with idx to be. \\
\hline
\end{DoxyParams}


Definition at line 57 of file sumtree.\+hpp.



Referenced by Prioritized\+Replay$<$ Environment\+Type $>$\+::\+Store().

\mbox{\label{classmlpack_1_1rl_1_1SumTree_ae64a6b8188bfdeecb0f6cc3ff2391528}} 
\index{mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}!Sum@{Sum}}
\index{Sum@{Sum}!mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}}
\subsubsection{Sum()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily T Sum (\begin{DoxyParamCaption}\item[{const size\+\_\+t}]{start,  }\item[{size\+\_\+t}]{end }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Calculate the sum of contiguous subsequence of the array. 


\begin{DoxyParams}{Parameters}
{\em start} & The starting position of subsequence. \\
\hline
{\em end} & The end position of subsequence. \\
\hline
\end{DoxyParams}


Definition at line 143 of file sumtree.\+hpp.



Referenced by Prioritized\+Replay$<$ Environment\+Type $>$\+::\+Sample(), and Prioritized\+Replay$<$ Environment\+Type $>$\+::\+Sample\+Proportional().

\mbox{\label{classmlpack_1_1rl_1_1SumTree_a1fc048090917da1f2202f4939aad1242}} 
\index{mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}!Sum@{Sum}}
\index{Sum@{Sum}!mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}}
\subsubsection{Sum()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily T Sum (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Shortcut for calculating the sum of whole array. 



Definition at line 152 of file sumtree.\+hpp.



Referenced by Sum\+Tree$<$ double $>$\+::\+Sum().

\mbox{\label{classmlpack_1_1rl_1_1SumTree_a5ce090154147bb27f2401d4b633d1d08}} 
\index{mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}!Sum\+Helper@{Sum\+Helper}}
\index{Sum\+Helper@{Sum\+Helper}!mlpack\+::rl\+::\+Sum\+Tree@{mlpack\+::rl\+::\+Sum\+Tree}}
\subsubsection{Sum\+Helper()}
{\footnotesize\ttfamily T Sum\+Helper (\begin{DoxyParamCaption}\item[{const size\+\_\+t}]{start,  }\item[{const size\+\_\+t}]{end,  }\item[{const size\+\_\+t}]{node,  }\item[{const size\+\_\+t}]{node\+Start,  }\item[{const size\+\_\+t}]{node\+End }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Help function for the {\ttfamily sum} function. 


\begin{DoxyParams}{Parameters}
{\em start} & The starting position of subsequence. \\
\hline
{\em end} & The end position of subsequence. \\
\hline
{\em node} & Reference position. \\
\hline
{\em node\+Start} & Starting position of reference segment. \\
\hline
{\em node\+End} & End position of reference segment. \\
\hline
\end{DoxyParams}


Definition at line 108 of file sumtree.\+hpp.



Referenced by Sum\+Tree$<$ double $>$\+::\+Sum(), and Sum\+Tree$<$ double $>$\+::\+Sum\+Helper().



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.\+1/src/mlpack/methods/reinforcement\+\_\+learning/replay/\textbf{ sumtree.\+hpp}\end{DoxyCompactItemize}
