[mlpack-svn] r10872 - mlpack/trunk/src/mlpack/core/tree
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Dec 16 18:12:35 EST 2011
Author: vlad321
Date: 2011-12-16 18:12:35 -0500 (Fri, 16 Dec 2011)
New Revision: 10872
Modified:
mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp
mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp
Log:
Formatted /tree
Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp 2011-12-16 22:35:11 UTC (rev 10871)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp 2011-12-16 23:12:35 UTC (rev 10872)
@@ -309,7 +309,8 @@
}
template<typename BoundType, typename StatisticType, typename MatType>
-inline const BoundType& BinarySpaceTree<BoundType, StatisticType, MatType>::Bound() const
+inline const
+ BoundType& BinarySpaceTree<BoundType, StatisticType, MatType>::Bound() const
{
return bound;
}
@@ -321,8 +322,8 @@
}
template<typename BoundType, typename StatisticType, typename MatType>
-inline const StatisticType& BinarySpaceTree<BoundType, StatisticType, MatType>::Stat()
- const
+inline const StatisticType&
+ BinarySpaceTree<BoundType, StatisticType, MatType>::Stat() const
{
return stat;
}
@@ -344,7 +345,7 @@
*/
template<typename BoundType, typename StatisticType, typename MatType>
inline BinarySpaceTree<BoundType, StatisticType, MatType>*
-BinarySpaceTree<BoundType, StatisticType, MatType>::Left() const
+ BinarySpaceTree<BoundType, StatisticType, MatType>::Left() const
{
return left;
}
@@ -354,7 +355,7 @@
*/
template<typename BoundType, typename StatisticType, typename MatType>
inline BinarySpaceTree<BoundType, StatisticType, MatType>*
-BinarySpaceTree<BoundType, StatisticType, MatType>::Right() const
+ BinarySpaceTree<BoundType, StatisticType, MatType>::Right() const
{
return right;
}
@@ -387,7 +388,8 @@
}
template<typename BoundType, typename StatisticType, typename MatType>
-void BinarySpaceTree<BoundType, StatisticType, MatType>::SplitNode(MatType& data)
+void
+ BinarySpaceTree<BoundType, StatisticType, MatType>::SplitNode(MatType& data)
{
// We need to expand the bounds of this node properly.
bound |= data.cols(begin, begin + count - 1);
Modified: mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp 2011-12-16 22:35:11 UTC (rev 10871)
+++ mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp 2011-12-16 23:12:35 UTC (rev 10872)
@@ -44,9 +44,8 @@
box_(other.box())
{
bounds_ = new math::Range[other.Dim()];
- for (size_t i = 0; i < dim_; i++) {
- bounds_[i] |= other[i];
- }
+ for (size_t i = 0; i < dim_; i++)
+ bounds_[i] |= other[i];
}
/***
@@ -149,12 +148,10 @@
for (int k = 0; k < 3; k++){
arma::vec point3 = point2;
- if (k == 1) {
- point3[i] += box[i];
- }
- else if (k == 2) {
- point3[i] -= box[i];
- }
+ if (k == 1)
+ point3[i] += box[i];
+ else if (k == 2)
+ point3[i] -= box[i];
double tempMin;
double sum = 0;
@@ -163,7 +160,8 @@
lower = bounds_[i].Lo() - point3[i];
higher = point3[i] - bounds_[i].Hi();
- sum += pow((lower + fabs(lower)) + (higher + fabs(higher)), (double) t_pow);
+ sum += pow((lower + fabs(lower)) +
+ (higher + fabs(higher)), (double) t_pow);
tempMin = pow(sum, 2.0 / (double) t_pow) / 4.0;
if (tempMin < min)
@@ -193,27 +191,31 @@
PeriodicHRectBound<2> a(other);
- for (int i = 0; i < dim_; i++){
+ for (int i = 0; i < dim_; i++)
+ {
double min = 100000000;
- if (box[i] < 0) {
+ if (box[i] < 0)
box[i] = abs(box[i]);
- }
- if (box[i] != 0) {
- if (abs(other[i].Lo()) > box[i]) {
+
+ if (box[i] != 0)
+ {
+ if (abs(other[i].Lo()) > box[i])
a[i].Lo() = fmod(a[i].Lo(),box[i]);
- }
- if (abs(other[i].Hi()) > box[i]) {
- a[i].Hi() = fmod(a[i].Hi(),box[i]);
- }
+
+ if (abs(other[i].Hi()) > box[i])
+ a[i].Hi() = fmod(a[i].Hi(),box[i]);
}
- for (int k = 0; k < 3; k++){
+ for (int k = 0; k < 3; k++)
+ {
PeriodicHRectBound<2> b = a;
- if (k == 1) {
+ if (k == 1)
+ {
b[i].Lo() += box[i];
b[i].Hi() += box[i];
}
- else if (k == 2) {
+ else if (k == 2)
+ {
b[i].Lo() -= box[i];
b[i].Hi() -= box[i];
}
@@ -228,17 +230,20 @@
//If the bound corsses over the box, split ito two seperate bounds and
//find thhe minimum distance between them.
- if( b[i].Hi() < b[i].Lo()) {
+ if( b[i].Hi() < b[i].Lo())
+ {
PeriodicHRectBound<2> d(b);
PeriodicHRectBound<2> c(b);
d[i].Lo() = 0;
c[i].Hi() = box[i];
- if (k == 1) {
+ if (k == 1)
+ {
d[i].Lo() += box[i];
c[i].Hi() += box[i];
}
- else if (k == 2) {
+ else if (k == 2)
+ {
d[i].Lo() -= box[i];
c[i].Hi() -= box[i];
}
@@ -258,13 +263,10 @@
sumHigher += pow((lowerHigher + fabs(lowerHigher)) +
(higherHigher + fabs(higherHigher)), (double) t_pow);
- if (sumLower > sumHigher) {
- tempMin = pow(sumHigher, 2.0 / (double) t_pow) / 4.0;
- }
- else {
- tempMin = pow(sumLower, 2.0 / (double) t_pow) / 4.0;
- }
-
+ if (sumLower > sumHigher)
+ tempMin = pow(sumHigher, 2.0 / (double) t_pow) / 4.0;
+ else
+ tempMin = pow(sumLower, 2.0 / (double) t_pow) / 4.0;
}
else {
lower = b[i].Lo() - bounds_[i].Hi();
@@ -272,7 +274,8 @@
// We invoke the following:
// x + fabs(x) = max(x * 2, 0)
// (x * 2)^2 / 4 = x^2
- sum += pow((lower + fabs(lower)) + (higher + fabs(higher)), (double) t_pow);
+ sum += pow((lower + fabs(lower)) +
+ (higher + fabs(higher)), (double) t_pow);
tempMin = pow(sum, 2.0 / (double) t_pow) / 4.0;
}
@@ -297,34 +300,33 @@
//Create the mirrored images. The minimum distance from the bound to a
//mirrored point is the minimum periodic distance.
arma::vec box = box_;
- for (int i = 0; i < dim_; i++){
+ for (int i = 0; i < dim_; i++)
+ {
point2 = point;
double max = 0;
//Mod the point within the box
- if (box[i] < 0){
+ if (box[i] < 0)
box[i] = abs(box[i]);
- }
- if (box[i] != 0){
- if (abs(point[i]) > box[i]) {
- point2[i] = fmod(point2[i],box[i]);
- }
- }
-
- for (int k = 0; k < 3; k++){
+
+ if (box[i] != 0)
+ if (abs(point[i]) > box[i])
+ point2[i] = fmod(point2[i],box[i]);
+
+ for (int k = 0; k < 3; k++)
+ {
arma::vec point3 = point2;
- if (k == 1) {
- point3[i] += box[i];
- }
- else if (k == 2) {
+
+ if (k == 1)
+ point3[i] += box[i];
+ else if (k == 2)
point3[i] -= box[i];
- }
-
+
double tempMax;
double sum = 0;
double v = fabs(std::max(point3[i] - bounds_[i].Lo(),
- bounds_[i].Hi() - point3[i]));
+ bounds_[i].Hi() - point3[i]));
sum += pow(v, (double) t_pow);
tempMax = pow(sum, 2.0 / (double) t_pow) / 4.0;
@@ -353,27 +355,31 @@
PeriodicHRectBound<2> a(other);
- for (int i = 0; i < dim_; i++){
+ for (int i = 0; i < dim_; i++)
+ {
double max = 0;
- if (box[i] < 0) {
+ if (box[i] < 0)
box[i] = abs(box[i]);
- }
- if (box[i] != 0) {
- if (abs(other[i].Lo()) > box[i]) {
+
+ if (box[i] != 0)
+ {
+ if (abs(other[i].Lo()) > box[i])
a[i].Lo() = fmod(a[i].Lo(),box[i]);
- }
- if (abs(other[i].Hi()) > box[i]) {
- a[i].Hi() = fmod(a[i].Hi(),box[i]);
- }
+
+ if (abs(other[i].Hi()) > box[i])
+ a[i].Hi() = fmod(a[i].Hi(),box[i]);
}
- for (int k = 0; k < 3; k++){
+ for (int k = 0; k < 3; k++)
+ {
PeriodicHRectBound<2> b = a;
- if (k == 1) {
+ if (k == 1)
+ {
b[i].Lo() += box[i];
b[i].Hi() += box[i];
}
- else if (k == 2) {
+ else if (k == 2)
+ {
b[i].Lo() -= box[i];
b[i].Hi() -= box[i];
}
@@ -386,17 +392,20 @@
//If the bound corsses over the box, split ito two seperate bounds and
//find thhe minimum distance between them.
- if( b[i].Hi() < b[i].Lo()) {
+ if( b[i].Hi() < b[i].Lo())
+ {
PeriodicHRectBound<2> d(b);
PeriodicHRectBound<2> c(b);
a[i].Lo() = 0;
c[i].Hi() = box[i];
- if (k == 1) {
+ if (k == 1)
+ {
d[i].Lo() += box[i];
c[i].Hi() += box[i];
}
- else if (k == 2) {
+ else if (k == 2)
+ {
d[i].Lo() -= box[i];
c[i].Hi() -= box[i];
}
@@ -404,25 +413,23 @@
c[i].Lo() = b[i].Lo();
double vLower = fabs(std::max(d.bounds_[i].Hi() - bounds_[i].Lo(),
- bounds_[i].Hi() - d.bounds_[i].Lo()));
+ bounds_[i].Hi() - d.bounds_[i].Lo()));
double vHigher = fabs(std::max(c.bounds_[i].Hi() - bounds_[i].Lo(),
- bounds_[i].Hi() - c.bounds_[i].Lo()));
+ bounds_[i].Hi() - c.bounds_[i].Lo()));
sumLower += pow(vLower, (double) t_pow);
sumHigher += pow(vHigher, (double) t_pow);
- if (sumLower > sumHigher) {
+ if (sumLower > sumHigher)
tempMax = pow(sumHigher, 2.0 / (double) t_pow) / 4.0;
- }
- else {
- tempMax = pow(sumLower, 2.0 / (double) t_pow) / 4.0;
- }
-
+ else
+ tempMax = pow(sumLower, 2.0 / (double) t_pow) / 4.0;
}
- else {
+ else
+ {
double v = fabs(std::max(b.bounds_[i].Hi() - bounds_[i].Lo(),
- bounds_[i].Hi() - b.bounds_[i].Lo()));
+ bounds_[i].Hi() - b.bounds_[i].Lo()));
sum += pow(v, (double) t_pow); // v is non-negative.
tempMax = pow(sum, 2.0 / (double) t_pow);
}
More information about the mlpack-svn
mailing list