Implementation of SumTree.
More...
|
| | SumTree () |
| | Default constructor. More...
|
| |
| | SumTree (const size_t capacity) |
| | Construct an instance of SumTree class. More...
|
| |
| void | BatchUpdate (const arma::ucolvec &indices, const arma::Col< T > &data) |
| | Update the data with batch rather loop over the indices with set method. More...
|
| |
| size_t | FindPrefixSum (T mass) |
| | Find the highest index idx in the array such that sum(arr[0] + arr[1] + ... More...
|
| |
| T | Get (size_t idx) |
| | Get the data array with idx. More...
|
| |
| void | Set (size_t idx, const T value) |
| | Set the data array with idx. More...
|
| |
| T | Sum (const size_t start, size_t end) |
| | Calculate the sum of contiguous subsequence of the array. More...
|
| |
| T | Sum () |
| | Shortcut for calculating the sum of whole array. More...
|
| |
| T | SumHelper (const size_t start, const size_t end, const size_t node, const size_t nodeStart, const size_t nodeEnd) |
| | Help function for the sum function. More...
|
| |
class mlpack::rl::SumTree< T >
Implementation of SumTree.
Build a Segment Tree like data structure. https://en.wikipedia.org/wiki/Segment_tree
Used to maintain prefix-sum of an array.
- Template Parameters
-
| T | The array's element type. |
Definition at line 32 of file sumtree.hpp.
◆ SumTree() [1/2]
◆ SumTree() [2/2]
◆ BatchUpdate()
| void BatchUpdate |
( |
const arma::ucolvec & |
indices, |
|
|
const arma::Col< T > & |
data |
|
) |
| |
|
inline |
Update the data with batch rather loop over the indices with set method.
- Parameters
-
| indices | The indices of data to be changed. |
| data | The data that array with indices to be. |
Definition at line 75 of file sumtree.hpp.
◆ FindPrefixSum()
| size_t FindPrefixSum |
( |
T |
mass | ) |
|
|
inline |
Find the highest index idx in the array such that sum(arr[0] + arr[1] + ...
- Parameters
-
| mass | The upper bound of segment array sum. |
Definition at line 163 of file sumtree.hpp.
◆ Get()
Get the data array with idx.
- Parameters
-
| idx | The array idx to get data. |
Definition at line 93 of file sumtree.hpp.
◆ Set()
| void Set |
( |
size_t |
idx, |
|
|
const T |
value |
|
) |
| |
|
inline |
Set the data array with idx.
- Parameters
-
| idx | The array idx to be changed. |
| value | The data that array with idx to be. |
Definition at line 57 of file sumtree.hpp.
◆ Sum() [1/2]
| T Sum |
( |
const size_t |
start, |
|
|
size_t |
end |
|
) |
| |
|
inline |
Calculate the sum of contiguous subsequence of the array.
- Parameters
-
| start | The starting position of subsequence. |
| end | The end position of subsequence. |
Definition at line 143 of file sumtree.hpp.
◆ Sum() [2/2]
◆ SumHelper()
| T SumHelper |
( |
const size_t |
start, |
|
|
const size_t |
end, |
|
|
const size_t |
node, |
|
|
const size_t |
nodeStart, |
|
|
const size_t |
nodeEnd |
|
) |
| |
|
inline |
Help function for the sum function.
- Parameters
-
| start | The starting position of subsequence. |
| end | The end position of subsequence. |
| node | Reference position. |
| nodeStart | Starting position of reference segment. |
| nodeEnd | End position of reference segment. |
Definition at line 108 of file sumtree.hpp.
Referenced by SumTree< double >::Sum(), and SumTree< double >::SumHelper().
The documentation for this class was generated from the following file:
- /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/methods/reinforcement_learning/replay/sumtree.hpp