/usr/include/mlpack/core/tree/hrectbound.hpp is in libmlpack-dev 1.0.10-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | /**
* @file hrectbound.hpp
*
* Bounds that are useful for binary space partitioning trees.
*
* This file describes the interface for the HRectBound class, which implements
* a hyperrectangle bound.
*
* This file is part of MLPACK 1.0.10.
*
* MLPACK is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* MLPACK is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details (LICENSE.txt).
*
* You should have received a copy of the GNU General Public License along with
* MLPACK. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MLPACK_CORE_TREE_HRECTBOUND_HPP
#define __MLPACK_CORE_TREE_HRECTBOUND_HPP
#include <mlpack/core.hpp>
#include <mlpack/core/math/range.hpp>
#include <mlpack/core/metrics/lmetric.hpp>
namespace mlpack {
namespace bound {
/**
* Hyper-rectangle bound for an L-metric. This should be used in conjunction
* with the LMetric class. Be sure to use the same template parameters for
* LMetric as you do for HRectBound -- otherwise odd results may occur.
*
* @tparam Power The metric to use; use 2 for Euclidean (L2).
* @tparam TakeRoot Whether or not the root should be taken (see LMetric
* documentation).
*/
template<int Power = 2, bool TakeRoot = true>
class HRectBound
{
public:
//! This is the metric type that this bound is using.
typedef metric::LMetric<Power, TakeRoot> MetricType;
/**
* Empty constructor; creates a bound of dimensionality 0.
*/
HRectBound();
/**
* Initializes to specified dimensionality with each dimension the empty
* set.
*/
HRectBound(const size_t dimension);
//! Copy constructor; necessary to prevent memory leaks.
HRectBound(const HRectBound& other);
//! Same as copy constructor; necessary to prevent memory leaks.
HRectBound& operator=(const HRectBound& other);
//! Destructor: clean up memory.
~HRectBound();
/**
* Resets all dimensions to the empty set (so that this bound contains
* nothing).
*/
void Clear();
//! Gets the dimensionality.
size_t Dim() const { return dim; }
//! Get the range for a particular dimension. No bounds checking. Be
//! careful: this may make MinWidth() invalid.
math::Range& operator[](const size_t i) { return bounds[i]; }
//! Modify the range for a particular dimension. No bounds checking.
const math::Range& operator[](const size_t i) const { return bounds[i]; }
//! Get the minimum width of the bound.
double MinWidth() const { return minWidth; }
//! Modify the minimum width of the bound.
double& MinWidth() { return minWidth; }
/**
* Calculates the centroid of the range, placing it into the given vector.
*
* @param centroid Vector which the centroid will be written to.
*/
void Centroid(arma::vec& centroid) const;
/**
* Calculates minimum bound-to-point distance.
*
* @param point Point to which the minimum distance is requested.
*/
template<typename VecType>
double MinDistance(const VecType& point,
typename boost::enable_if<IsVector<VecType> >* = 0) const;
/**
* Calculates minimum bound-to-bound distance.
*
* @param other Bound to which the minimum distance is requested.
*/
double MinDistance(const HRectBound& other) const;
/**
* Calculates maximum bound-to-point squared distance.
*
* @param point Point to which the maximum distance is requested.
*/
template<typename VecType>
double MaxDistance(const VecType& point,
typename boost::enable_if<IsVector<VecType> >* = 0) const;
/**
* Computes maximum distance.
*
* @param other Bound to which the maximum distance is requested.
*/
double MaxDistance(const HRectBound& other) const;
/**
* Calculates minimum and maximum bound-to-bound distance.
*
* @param other Bound to which the minimum and maximum distances are
* requested.
*/
math::Range RangeDistance(const HRectBound& other) const;
/**
* Calculates minimum and maximum bound-to-point distance.
*
* @param point Point to which the minimum and maximum distances are
* requested.
*/
template<typename VecType>
math::Range RangeDistance(const VecType& point,
typename boost::enable_if<IsVector<VecType> >* = 0)
const;
/**
* Expands this region to include new points.
*
* @tparam MatType Type of matrix; could be Mat, SpMat, a subview, or just a
* vector.
* @param data Data points to expand this region to include.
*/
template<typename MatType>
HRectBound& operator|=(const MatType& data);
/**
* Expands this region to encompass another bound.
*/
HRectBound& operator|=(const HRectBound& other);
/**
* Determines if a point is within this bound.
*/
template<typename VecType>
bool Contains(const VecType& point) const;
/**
* Returns the diameter of the hyperrectangle (that is, the longest diagonal).
*/
double Diameter() const;
/**
* Returns a string representation of this object.
*/
std::string ToString() const;
/**
* Return the metric associated with this bound. Because it is an LMetric, it
* cannot store state, so we can make it on the fly. It is also static
* because the metric is only dependent on the template arguments.
*/
static MetricType Metric() { return metric::LMetric<Power, TakeRoot>(); }
private:
//! The dimensionality of the bound.
size_t dim;
//! The bounds for each dimension.
math::Range* bounds;
//! Cached minimum width of bound.
double minWidth;
};
}; // namespace bound
}; // namespace mlpack
#include "hrectbound_impl.hpp"
#endif // __MLPACK_CORE_TREE_HRECTBOUND_HPP
|