Implementation of SumTree.
More...
#include <sumtree.hpp>
|
| SumTree () |
| Default constructor.
|
|
| SumTree (const size_t capacity) |
| Construct an instance of SumTree class. More...
|
|
void | Set (size_t idx, const T value) |
| Set the data array with idx. 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...
|
|
T | Get (size_t idx) |
| Get the data array with idx. 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...
|
|
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.
|
|
size_t | FindPrefixSum (T mass) |
| Find the highest index idx in the array such that sum(arr[0] + arr[1] + ... More...
|
|
template<typename T>
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. |
◆ SumTree()
Construct an instance of SumTree class.
- Parameters
-
◆ BatchUpdate()
template<typename T>
void mlpack::rl::SumTree< T >::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. |
◆ FindPrefixSum()
Find the highest index idx
in the array such that sum(arr[0] + arr[1] + ...
- Parameters
-
mass | The upper bound of segment array sum. |
◆ Get()
Get the data array with idx.
- Parameters
-
idx | The array idx to get data. |
◆ Set()
Set the data array with idx.
- Parameters
-
idx | The array idx to be changed. |
value | The data that array with idx to be. |
◆ Sum()
Calculate the sum of contiguous subsequence of the array.
- Parameters
-
start | The starting position of subsequence. |
end | The end position of subsequence. |
◆ SumHelper()
template<typename T>
T mlpack::rl::SumTree< 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. |
The documentation for this class was generated from the following file:
- src/mlpack/methods/reinforcement_learning/replay/sumtree.hpp