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,
167 ElemType MinDistance(
const CellBound& other)
const;
174 template<
typename VecType>
175 ElemType MaxDistance(
const VecType& point,
184 ElemType MaxDistance(
const CellBound& other)
const;
200 template<
typename VecType>
202 const VecType& point,
212 template<
typename MatType>
213 CellBound& operator|=(
const MatType& data);
218 CellBound& operator|=(
const CellBound& other);
223 template<
typename VecType>
224 bool Contains(
const VecType& point)
const;
232 template<
typename MatType>
233 void UpdateAddressBounds(
const MatType& data);
238 ElemType Diameter()
const;
243 template<
typename Archive>
244 void serialize(Archive& ar,
const unsigned int version);
248 static constexpr
size_t order =
sizeof(AddressElemType) * CHAR_BIT;
250 const size_t maxNumBounds = 10;
256 arma::Mat<ElemType> loBound;
258 arma::Mat<ElemType> hiBound;
262 arma::Col<AddressElemType> loAddress;
264 arma::Col<AddressElemType> hiAddress;
275 template<
typename MatType>
276 void AddBound(
const arma::Col<ElemType>& loCorner,
277 const arma::Col<ElemType>& hiCorner,
278 const MatType& data);
287 template<
typename MatType>
288 void InitHighBound(
size_t numEqualBits,
const MatType& data);
298 template<
typename MatType>
299 void InitLowerBound(
size_t numEqualBits,
const MatType& data);
303 template<
typename MetricType,
typename ElemType>
313 #include "cellbound_impl.hpp"
315 #endif // MLPACK_CORE_TREE_CELLBOUND_HPP
typename enable_if< B, T >::type enable_if_t
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.