34 #ifndef MLPACK_CORE_TREE_CELLBOUND_HPP
35 #define MLPACK_CORE_TREE_CELLBOUND_HPP
73 template<
typename MetricType = metric::LMetric<2, true>,
74 typename ElemType =
double>
80 typedef typename std::conditional<
sizeof(ElemType) * CHAR_BIT <= 32,
82 uint64_t>::type AddressElemType;
93 CellBound(
const size_t dimension);
96 CellBound(
const CellBound& other);
98 CellBound& operator=(
const CellBound& other);
101 CellBound(CellBound&& other);
113 size_t Dim()
const {
return dim; }
120 {
return bounds[i]; }
123 arma::Col<AddressElemType>& LoAddress() {
return loAddress; }
125 const arma::Col<AddressElemType>& LoAddress()
const {
return loAddress; }
128 arma::Col<AddressElemType>& HiAddress() {
return hiAddress; }
130 const arma::Col<AddressElemType>& HiAddress()
const {
return hiAddress; }
133 const arma::Mat<ElemType>& LoBound()
const {
return loBound; }
135 const arma::Mat<ElemType>& HiBound()
const {
return hiBound; }
138 size_t NumBounds()
const {
return numBounds; }
141 ElemType MinWidth()
const {
return minWidth; }
143 ElemType& MinWidth() {
return minWidth; }
150 void Center(arma::Col<ElemType>& center)
const;
157 template<
typename VecType>
158 ElemType MinDistance(
const VecType& point,
166 ElemType MinDistance(
const CellBound& other)
const;
173 template<
typename VecType>
174 ElemType MaxDistance(
const VecType& point,
182 ElemType MaxDistance(
const CellBound& other)
const;
198 template<
typename VecType>
200 const VecType& point,
210 template<
typename MatType>
211 CellBound& operator|=(
const MatType& data);
216 CellBound& operator|=(
const CellBound& other);
221 template<
typename VecType>
222 bool Contains(
const VecType& point)
const;
230 template<
typename MatType>
231 void UpdateAddressBounds(
const MatType& data);
236 ElemType Diameter()
const;
241 template<
typename Archive>
242 void Serialize(Archive& ar,
const unsigned int version);
246 static constexpr
size_t order =
sizeof(AddressElemType) * CHAR_BIT;
248 const size_t maxNumBounds = 10;
254 arma::Mat<ElemType> loBound;
256 arma::Mat<ElemType> hiBound;
260 arma::Col<AddressElemType> loAddress;
262 arma::Col<AddressElemType> hiAddress;
273 template<
typename MatType>
274 void AddBound(
const arma::Col<ElemType>& loCorner,
275 const arma::Col<ElemType>& hiCorner,
276 const MatType& data);
285 template<
typename MatType>
286 void InitHighBound(
size_t numEqualBits,
const MatType& data);
296 template<
typename MatType>
297 void InitLowerBound(
size_t numEqualBits,
const MatType& data);
301 template<
typename MetricType,
typename ElemType>
311 #include "cellbound_impl.hpp"
313 #endif // MLPACK_CORE_TREE_CELLBOUND_HPP
A class to obtain compile-time traits about BoundType classes.
The CellBound class describes a bound that consists of a number of hyperrectangles.
The core includes that mlpack expects; standard C++ includes and Armadillo.
bool Contains(const AddressType1 &address, const AddressType2 &loBound, const AddressType3 &hiBound)
Returns true if an address is contained between two other addresses.
Definition of the Range class, which represents a simple range with a lower and upper bound...
void Center(const arma::mat &x, arma::mat &xCentered)
Creates a centered matrix, where centering is done by subtracting the sum over the columns (a column ...
static const bool HasTightBounds
If true, then the bounds for each dimension are tight.
If value == true, then VecType is some sort of Armadillo vector or subview.