Clean up BallBound code; now, expand things in batch because that's better.
This commit is contained in:
@@ -113,9 +113,15 @@ class BallBound
|
||||
const BallBound& operator|=(const BallBound& other);
|
||||
|
||||
/**
|
||||
* Expand the bound to include the given point.
|
||||
* Expand the bound to include the given point. The centroid is recalculated
|
||||
* to be the center of all of the given points.
|
||||
*
|
||||
* @tparam MatType Type of matrix; could be arma::mat, arma::spmat, or a
|
||||
* vector.
|
||||
* @tparam data Data points to add.
|
||||
*/
|
||||
const BallBound& operator|=(const VecType& point);
|
||||
template<typename MatType>
|
||||
const BallBound& operator|=(const MatType& data);
|
||||
};
|
||||
|
||||
}; // namespace bound
|
||||
|
||||
@@ -110,7 +110,7 @@ math::Range BallBound<VecType>::RangeDistance(
|
||||
|
||||
/**
|
||||
* Expand the bound to include the given bound.
|
||||
*/
|
||||
*
|
||||
template<typename VecType>
|
||||
const BallBound<VecType>&
|
||||
BallBound<VecType>::operator|=(
|
||||
@@ -123,14 +123,15 @@ BallBound<VecType>::operator|=(
|
||||
radius = dist;
|
||||
|
||||
return *this;
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Expand the bound to include the given point.
|
||||
*/
|
||||
template<typename VecType>
|
||||
template<typename MatType>
|
||||
const BallBound<VecType>&
|
||||
BallBound<VecType>::operator|=(const VecType& point)
|
||||
BallBound<VecType>::operator|=(const MatType& point)
|
||||
{
|
||||
double dist = metric::EuclideanDistance::Evaluate(center, point);
|
||||
|
||||
|
||||
@@ -389,10 +389,8 @@ inline size_t BinarySpaceTree<BoundType, StatisticType, MatType>::Count() const
|
||||
template<typename BoundType, typename StatisticType, typename MatType>
|
||||
void BinarySpaceTree<BoundType, StatisticType, MatType>::SplitNode(MatType& data)
|
||||
{
|
||||
// This should be a single function for Bound.
|
||||
// We need to expand the bounds of this node properly.
|
||||
for (size_t i = begin; i < (begin + count); i++)
|
||||
bound |= data.col(i);
|
||||
bound |= data.cols(begin, begin + count - 1);
|
||||
|
||||
// Now, check if we need to split at all.
|
||||
if (count <= leafSize)
|
||||
@@ -441,8 +439,7 @@ void BinarySpaceTree<BoundType, StatisticType, MatType>::SplitNode(
|
||||
{
|
||||
// This should be a single function for Bound.
|
||||
// We need to expand the bounds of this node properly.
|
||||
for (size_t i = begin; i < (begin + count); i++)
|
||||
bound |= data.col(i);
|
||||
bound |= data.cols(begin, begin + count - 1);
|
||||
|
||||
// First, check if we need to split at all.
|
||||
if (count <= leafSize)
|
||||
|
||||
@@ -106,10 +106,14 @@ class HRectBound
|
||||
math::Range RangeDistance(const VecType& point) const;
|
||||
|
||||
/**
|
||||
* Expands this region to include a new point.
|
||||
* 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 VecType>
|
||||
HRectBound& operator|=(const VecType& vector);
|
||||
template<typename MatType>
|
||||
HRectBound& operator|=(const MatType& data);
|
||||
|
||||
/**
|
||||
* Expands this region to encompass another bound.
|
||||
|
||||
@@ -310,13 +310,16 @@ math::Range HRectBound<t_pow>::RangeDistance(const VecType& point) const
|
||||
* Expands this region to include a new point.
|
||||
*/
|
||||
template<int t_pow>
|
||||
template<typename VecType>
|
||||
HRectBound<t_pow>& HRectBound<t_pow>::operator|=(const VecType& vector)
|
||||
template<typename MatType>
|
||||
HRectBound<t_pow>& HRectBound<t_pow>::operator|=(const MatType& data)
|
||||
{
|
||||
Log::Assert(vector.n_elem == dim);
|
||||
Log::Assert(data.n_rows == dim);
|
||||
|
||||
arma::vec mins = min(data, 1);
|
||||
arma::vec maxs = max(data, 1);
|
||||
|
||||
for (size_t i = 0; i < dim; i++)
|
||||
bounds[i] |= vector[i];
|
||||
bounds[i] |= math::Range(mins[i], maxs[i]);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user