34#ifndef MLPACK_CORE_TREE_CELLBOUND_HPP
35#define MLPACK_CORE_TREE_CELLBOUND_HPP
73template<
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;
115 size_t Dim()
const {
return dim; }
122 {
return bounds[i]; }
125 arma::Col<AddressElemType>& LoAddress() {
return loAddress; }
127 const arma::Col<AddressElemType>& LoAddress()
const {
return loAddress; }
130 arma::Col<AddressElemType>& HiAddress() {
return hiAddress; }
132 const arma::Col<AddressElemType>& HiAddress()
const {
return hiAddress; }
135 const arma::Mat<ElemType>& LoBound()
const {
return loBound; }
137 const arma::Mat<ElemType>& HiBound()
const {
return hiBound; }
140 size_t NumBounds()
const {
return numBounds; }
143 ElemType MinWidth()
const {
return minWidth; }
145 ElemType& MinWidth() {
return minWidth; }
148 const MetricType& Metric()
const {
return metric; }
150 MetricType& Metric() {
return metric; }
157 void Center(arma::Col<ElemType>& center)
const;
164 template<
typename VecType>
165 ElemType MinDistance(
const VecType& point,
174 ElemType MinDistance(
const CellBound& other)
const;
181 template<
typename VecType>
182 ElemType MaxDistance(
const VecType& point,
191 ElemType MaxDistance(
const CellBound& other)
const;
207 template<
typename VecType>
209 const VecType& point,
219 template<
typename MatType>
220 CellBound& operator|=(
const MatType& data);
234 template<
typename VecType>
235 bool Contains(
const VecType& point)
const;
243 template<
typename MatType>
244 void UpdateAddressBounds(
const MatType& data);
249 ElemType Diameter()
const;
254 template<
typename Archive>
255 void serialize(Archive& ar,
const unsigned int version);
259 static constexpr size_t order =
sizeof(AddressElemType) * CHAR_BIT;
261 const size_t maxNumBounds = 10;
267 arma::Mat<ElemType> loBound;
269 arma::Mat<ElemType> hiBound;
273 arma::Col<AddressElemType> loAddress;
275 arma::Col<AddressElemType> hiAddress;
288 template<
typename MatType>
289 void AddBound(
const arma::Col<ElemType>& loCorner,
290 const arma::Col<ElemType>& hiCorner,
291 const MatType& data);
300 template<
typename MatType>
301 void InitHighBound(
size_t numEqualBits,
const MatType& data);
311 template<
typename MatType>
312 void InitLowerBound(
size_t numEqualBits,
const MatType& data);
316template<
typename MetricType,
typename ElemType>
326#include "cellbound_impl.hpp"
The CellBound class describes a bound that consists of a number of hyperrectangles.
Simple real-valued range.
bool Contains(const AddressType1 &address, const AddressType2 &loBound, const AddressType3 &hiBound)
Returns true if an address is contained between two other addresses.
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 ...
Linear algebra utility functions, generally performed on matrices or vectors.
typename enable_if< B, T >::type enable_if_t
The core includes that mlpack expects; standard C++ includes and Armadillo.
Definition of the Range class, which represents a simple range with a lower and upper bound.
If value == true, then VecType is some sort of Armadillo vector or subview.
A class to obtain compile-time traits about BoundType classes.
static const bool HasTightBounds
If true, then the bounds for each dimension are tight.