NVBIO
|
Given an array of length N, it's possible to build a binary tree on top of it with 2*N-1 nodes, where each internal node encodes the sum of the values associated with its leaves. The original N cells will be the leaves of such a tree. This class encodes such a tree, allowing incremental modifications of the values associated with the leaves. If N is not a power of 2, the base array is conceptually padded with zeros.
An example usage of this class is to sample CDFs that are continuously updated over time.
Definition at line 108 of file sum_tree.h.
#include <sum_tree.h>
Public Types | |
typedef Iterator | iterator_type |
typedef std::iterator_traits < Iterator >::value_type | value_type |
Static Public Methods | |
NVBIO_FORCEINLINE static NVBIO_HOST_DEVICE uint32 | node_count (const uint32 size) |
typedef Iterator nvbio::SumTree< Iterator >::iterator_type |
Definition at line 110 of file sum_tree.h.
typedef std::iterator_traits<Iterator>::value_type nvbio::SumTree< Iterator >::value_type |
Definition at line 111 of file sum_tree.h.
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE nvbio::SumTree< Iterator >::SumTree | ( | const uint32 | size, |
iterator_type | cells | ||
) |
constructor
Definition at line 51 of file sum_tree_inl.h.
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE void nvbio::SumTree< Iterator >::add | ( | const uint32 | i, |
const value_type | v | ||
) |
increment a cell's value
Definition at line 88 of file sum_tree_inl.h.
|
inline |
return a cell's value
Definition at line 161 of file sum_tree.h.
|
static |
return the number of nodes corresponding to a given number of leaves
Definition at line 36 of file sum_tree_inl.h.
|
inline |
return the total node count
Definition at line 136 of file sum_tree.h.
|
inline |
return the number of leaves, padded to the nearest power of 2
Definition at line 131 of file sum_tree.h.
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE void nvbio::SumTree< Iterator >::set | ( | const uint32 | i, |
const value_type | v | ||
) |
reset a cell's value
Definition at line 104 of file sum_tree_inl.h.
NVBIO_FORCEINLINE NVBIO_HOST_DEVICE void nvbio::SumTree< Iterator >::setup | ( | const value_type | zero = value_type(0) ) |
setup the tree structure
Definition at line 64 of file sum_tree_inl.h.
|
inline |
return the number of leaves
Definition at line 126 of file sum_tree.h.
|
inline |
return the total tree sum
Definition at line 156 of file sum_tree.h.