[mlpack-svn] r10884 - in mlpack/trunk/src/mlpack: core/math core/optimizers/aug_lagrangian core/optimizers/lbfgs core/tree core/util methods/gmm methods/kernel_pca methods/lars methods/pca methods/radical tests
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Sat Dec 17 03:21:01 EST 2011
Author: rcurtin
Date: 2011-12-17 03:21:00 -0500 (Sat, 17 Dec 2011)
New Revision: 10884
Modified:
mlpack/trunk/src/mlpack/core/math/lin_alg.hpp
mlpack/trunk/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp
mlpack/trunk/src/mlpack/core/optimizers/lbfgs/lbfgs_impl.hpp
mlpack/trunk/src/mlpack/core/optimizers/lbfgs/test_functions.hpp
mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp
mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp
mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp
mlpack/trunk/src/mlpack/core/util/cli.cpp
mlpack/trunk/src/mlpack/core/util/cli.hpp
mlpack/trunk/src/mlpack/core/util/cli_impl.hpp
mlpack/trunk/src/mlpack/core/util/log.cpp
mlpack/trunk/src/mlpack/core/util/log.hpp
mlpack/trunk/src/mlpack/core/util/nulloutstream.hpp
mlpack/trunk/src/mlpack/core/util/option_impl.hpp
mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp
mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp
mlpack/trunk/src/mlpack/methods/kernel_pca/kernel_pca_impl.hpp
mlpack/trunk/src/mlpack/methods/lars/lars.cpp
mlpack/trunk/src/mlpack/methods/pca/pca.cpp
mlpack/trunk/src/mlpack/methods/radical/radical.cpp
mlpack/trunk/src/mlpack/methods/radical/radical_main.cpp
mlpack/trunk/src/mlpack/tests/aug_lagrangian_test.cpp
mlpack/trunk/src/mlpack/tests/lars_test.cpp
mlpack/trunk/src/mlpack/tests/tree_test.cpp
Log:
Fix braces.
Modified: mlpack/trunk/src/mlpack/core/math/lin_alg.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/math/lin_alg.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/math/lin_alg.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -130,7 +130,7 @@
v[i + 1] = first_term * sin(second_term);
}
- if((v.n_elem % 2) == 1)
+ if ((v.n_elem % 2) == 1)
{
v[v.n_elem - 1] = sqrt(-2 * log(drand48())) * cos(2 * M_PI * drand48());
}
Modified: mlpack/trunk/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -63,7 +63,8 @@
// gradient.
gradient.zeros(2, 1);
- if (index == 0) {
+ if (index == 0)
+ {
// c'_x1(x) = 1
// c'_x2(x) = 1
gradient.ones(2, 1); // Use a shortcut instead of assigning individually.
Modified: mlpack/trunk/src/mlpack/core/optimizers/lbfgs/lbfgs_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/optimizers/lbfgs/lbfgs_impl.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/optimizers/lbfgs/lbfgs_impl.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -137,7 +137,8 @@
// Check Wolfe's condition.
double searchDirectionDotGradient = arma::dot(gradient, searchDirection);
- if(searchDirectionDotGradient < wolfe * initialSearchDirectionDotGradient)
+ if (searchDirectionDotGradient < wolfe *
+ initialSearchDirectionDotGradient)
{
width = inc;
}
@@ -356,7 +357,7 @@
function.Evaluate(iterate) << "." << std::endl;
// Break when the norm of the gradient becomes too small.
- if(GradientNormTooSmall(gradient))
+ if (GradientNormTooSmall(gradient))
{
success = true; // We have found the minimum.
Log::Info << "L-BFGS gradient norm too small (terminating)."
Modified: mlpack/trunk/src/mlpack/core/optimizers/lbfgs/test_functions.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/optimizers/lbfgs/test_functions.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/optimizers/lbfgs/test_functions.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -75,7 +75,8 @@
* "A comparative study of nonlinear programming codes."
* A.R. Colville. 1968. Rep. 320-2949, IBM N.Y. Scientific Center.
*/
-class WoodFunction {
+class WoodFunction
+{
public:
WoodFunction(); // initialize initial point
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-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree_impl.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -503,7 +503,7 @@
while ((data(splitDim, right) >= splitVal) && (left <= right))
right--;
- while(left <= right)
+ while (left <= right)
{
// Swap columns.
data.swap_cols(left, right);
@@ -548,7 +548,7 @@
while ((data(splitDim, right) >= splitVal) && (left <= right))
right--;
- while(left <= right)
+ while (left <= right)
{
// Swap columns.
data.swap_cols(left, right);
Modified: mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/tree/periodichrectbound.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -47,14 +47,14 @@
~PeriodicHRectBound();
/**
- * Modifies the box_size_ to the desired dimenstions.
+ * Modifies the boxsize_ to the desired dimenstions.
*/
void SetBoxSize(arma::vec box);
/**
- * Returns the box_size_ vector.
+ * Returns the boxsize_ vector.
*/
- const arma::vec& box() const { return box_; }
+ const arma::vec& box() const { return box; }
/**
* Resets all dimensions to the empty set.
@@ -62,7 +62,7 @@
void Clear();
/** Gets the dimensionality */
- size_t Dim() const { return dim_; }
+ size_t Dim() const { return dim; }
/**
* Sets and gets the range for a particular dimension.
@@ -132,9 +132,9 @@
bool Contains(const arma::vec& point) const;
private:
- math::Range *bounds_;
- size_t dim_;
- arma::vec box_;
+ math::Range *bounds;
+ size_t dim;
+ arma::vec box;
};
}; // namespace bound
Modified: mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/tree/periodichrectbound_impl.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -20,9 +20,9 @@
*/
template<int t_pow>
PeriodicHRectBound<t_pow>::PeriodicHRectBound() :
- bounds_(NULL),
- dim_(0),
- box_(/* empty */)
+ bounds(NULL),
+ dim(0),
+ box(/* empty */)
{ /* nothing to do */ }
/**
@@ -30,9 +30,9 @@
*/
template<int t_pow>
PeriodicHRectBound<t_pow>::PeriodicHRectBound(arma::vec box) :
- bounds_(new math::Range[box.n_rows]),
- dim_(box.n_rows),
- box_(box)
+ bounds(new math::Range[box.n_rows]),
+ dim(box.n_rows),
+ box(box)
{ /* nothing to do */ }
/***
@@ -40,12 +40,12 @@
*/
template<int t_pow>
PeriodicHRectBound<t_pow>::PeriodicHRectBound(const PeriodicHRectBound& other) :
- dim_(other.Dim()),
- box_(other.box())
+ dim(other.Dim()),
+ box(other.box())
{
- bounds_ = new math::Range[other.Dim()];
- for (size_t i = 0; i < dim_; i++)
- bounds_[i] |= other[i];
+ bounds = new math::Range[other.Dim()];
+ for (size_t i = 0; i < dim; i++)
+ bounds[i] |= other[i];
}
/***
@@ -66,17 +66,17 @@
template<int t_pow>
PeriodicHRectBound<t_pow>::~PeriodicHRectBound()
{
- if(bounds_)
- delete[] bounds_;
+ if (bounds)
+ delete[] bounds;
}
/**
- * Modifies the box_ to the desired dimenstions.
+ * Modifies the box to the desired dimenstions.
*/
template<int t_pow>
void PeriodicHRectBound<t_pow>::SetBoxSize(arma::vec box)
{
- box_ = box;
+ box = box;
}
/**
@@ -85,8 +85,8 @@
template<int t_pow>
void PeriodicHRectBound<t_pow>::Clear()
{
- for (size_t i = 0; i < dim_; i++)
- bounds_[i] = math::Range();
+ for (size_t i = 0; i < dim; i++)
+ bounds[i] = math::Range();
}
/**
@@ -95,7 +95,7 @@
template<int t_pow>
const math::Range PeriodicHRectBound<t_pow>::operator[](size_t i) const
{
- return bounds_[i];
+ return bounds[i];
}
/**
@@ -104,7 +104,7 @@
template<int t_pow>
math::Range& PeriodicHRectBound<t_pow>::operator[](size_t i)
{
- return bounds_[i];
+ return bounds[i];
}
/** Calculates the midpoint of the range */
@@ -112,11 +112,11 @@
void PeriodicHRectBound<t_pow>::Centroid(arma::vec& centroid) const
{
// set size correctly if necessary
- if (!(centroid.n_elem == dim_))
- centroid.set_size(dim_);
+ if (!(centroid.n_elem == dim))
+ centroid.set_size(dim);
- for (size_t i = 0; i < dim_; i++)
- centroid(i) = bounds_[i].Mid();
+ for (size_t i = 0; i < dim; i++)
+ centroid(i) = bounds[i].Mid();
}
/**
@@ -131,8 +131,8 @@
double totalMin = 0;
// 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++)
+ arma::vec box = box;
+ for (int i = 0; i < dim; i++)
{
point2 = point;
double min = 100000000;
@@ -163,8 +163,8 @@
double sum = 0;
double lower, higher;
- lower = bounds_[i].Lo() - point3[i];
- higher = point3[i] - bounds_[i].Hi();
+ lower = bounds[i].Lo() - point3[i];
+ higher = point3[i] - bounds[i].Hi();
sum += pow((lower + fabs(lower)) +
(higher + fabs(higher)), (double) t_pow);
@@ -192,10 +192,10 @@
double totalMin = 0;
// Create the mirrored images. The minimum distance from the bound to a
// mirrored point is the minimum periodic distance.
- arma::vec box = box_;
+ arma::vec box = box;
PeriodicHRectBound<2> a(other);
- for (int i = 0; i < dim_; i++)
+ for (int i = 0; i < dim; i++)
{
double min = DBL_MAX;
if (box[i] < 0)
@@ -255,11 +255,11 @@
d[i].Hi() = b[i].Hi();
c[i].Lo() = b[i].Lo();
- lowerLower = d[i].Lo() - bounds_[i].Hi();
- higherLower = bounds_[i].Lo() - d[i].Hi();
+ lowerLower = d[i].Lo() - bounds[i].Hi();
+ higherLower = bounds[i].Lo() - d[i].Hi();
- lowerHigher = c[i].Lo() - bounds_[i].Hi();
- higherHigher = bounds_[i].Lo() - c[i].Hi();
+ lowerHigher = c[i].Lo() - bounds[i].Hi();
+ higherHigher = bounds[i].Lo() - c[i].Hi();
sumLower += pow((lowerLower + fabs(lowerLower)) +
(higherLower + fabs(higherLower)), (double) t_pow);
@@ -274,8 +274,8 @@
}
else
{
- lower = b[i].Lo() - bounds_[i].Hi();
- higher = bounds_[i].Lo() - b[i].Hi();
+ lower = b[i].Lo() - bounds[i].Hi();
+ higher = bounds[i].Lo() - b[i].Hi();
// We invoke the following:
// x + fabs(x) = max(x * 2, 0)
// (x * 2)^2 / 4 = x^2
@@ -303,8 +303,8 @@
double totalMax = 0;
//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++)
+ arma::vec box = box;
+ for (int i = 0; i < dim; i++)
{
point2 = point;
double max = 0;
@@ -329,8 +329,8 @@
double tempMax;
double sum = 0;
- double v = fabs(std::max(point3[i] - bounds_[i].Lo(),
- bounds_[i].Hi() - point3[i]));
+ double v = fabs(std::max(point3[i] - bounds[i].Lo(),
+ bounds[i].Hi() - point3[i]));
sum += pow(v, (double) t_pow);
tempMax = pow(sum, 2.0 / (double) t_pow) / 4.0;
@@ -355,11 +355,11 @@
double totalMax = 0;
//Create the mirrored images. The minimum distance from the bound to a
//mirrored point is the minimum periodic distance.
- arma::vec box = box_;
+ arma::vec box = box;
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)
@@ -417,11 +417,11 @@
d[i].Hi() = b[i].Hi();
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()));
+ double vLower = fabs(std::max(d.bounds[i].Hi() - 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()));
+ double vHigher = fabs(std::max(c.bounds[i].Hi() - bounds[i].Lo(),
+ bounds[i].Hi() - c.bounds[i].Lo()));
sumLower += pow(vLower, (double) t_pow);
sumHigher += pow(vHigher, (double) t_pow);
@@ -433,8 +433,8 @@
}
else
{
- double v = fabs(std::max(b.bounds_[i].Hi() - bounds_[i].Lo(),
- bounds_[i].Hi() - b.bounds_[i].Lo()));
+ double v = fabs(std::max(b.bounds[i].Hi() - 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);
}
@@ -458,13 +458,13 @@
double sum_lo = 0;
double sum_hi = 0;
- Log::Assert(point.n_elem == dim_);
+ Log::Assert(point.n_elem == dim);
double v1, v2, v_lo, v_hi;
- for (size_t d = 0; d < dim_; d++)
+ for (size_t d = 0; d < dim; d++)
{
- v1 = bounds_[d].Lo() - point[d];
- v2 = point[d] - bounds_[d].Hi();
+ v1 = bounds[d].Lo() - point[d];
+ v2 = point[d] - bounds[d].Hi();
// One of v1 or v2 is negative.
if (v1 >= 0)
{
@@ -495,13 +495,13 @@
double sum_lo = 0;
double sum_hi = 0;
- Log::Assert(dim_ == other.dim_);
+ Log::Assert(dim == other.dim);
double v1, v2, v_lo, v_hi;
- for (size_t d = 0; d < dim_; d++)
+ for (size_t d = 0; d < dim; d++)
{
- v1 = other.bounds_[d].Lo() - bounds_[d].Hi();
- v2 = bounds_[d].Lo() - other.bounds_[d].Hi();
+ v1 = other.bounds[d].Lo() - bounds[d].Hi();
+ v2 = bounds[d].Lo() - other.bounds[d].Hi();
// One of v1 or v2 is negative.
if (v1 >= v2)
{
@@ -529,10 +529,10 @@
PeriodicHRectBound<t_pow>& PeriodicHRectBound<t_pow>::operator|=(
const arma::vec& vector)
{
- Log::Assert(vector.n_elem == dim_);
+ Log::Assert(vector.n_elem == dim);
- for (size_t i = 0; i < dim_; i++)
- bounds_[i] |= vector[i];
+ for (size_t i = 0; i < dim; i++)
+ bounds[i] |= vector[i];
return *this;
}
@@ -544,10 +544,10 @@
PeriodicHRectBound<t_pow>& PeriodicHRectBound<t_pow>::operator|=(
const PeriodicHRectBound& other)
{
- Log::Assert(other.dim_ == dim_);
+ Log::Assert(other.dim == dim);
- for (size_t i = 0; i < dim_; i++)
- bounds_[i] |= other.bounds_[i];
+ for (size_t i = 0; i < dim; i++)
+ bounds[i] |= other.bounds[i];
return *this;
}
@@ -559,7 +559,7 @@
bool PeriodicHRectBound<t_pow>::Contains(const arma::vec& point) const
{
for (size_t i = 0; i < point.n_elem; i++)
- if (!bounds_[i].Contains(point(i)))
+ if (!bounds[i].Contains(point(i)))
return false;
return true;
Modified: mlpack/trunk/src/mlpack/core/util/cli.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/cli.cpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/util/cli.cpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -43,7 +43,7 @@
/* Constructors, Destructors, Copy */
/* Make the constructor private, to preclude unauthorized instances */
-CLI::CLI() : desc("Allowed Options") , did_parse(false), doc(&emptyProgramDoc)
+CLI::CLI() : desc("Allowed Options") , didParse(false), doc(&emptyProgramDoc)
{
return;
}
@@ -54,14 +54,14 @@
* @param optionsName Name of the module, as far as boost is concerned.
*/
CLI::CLI(std::string& optionsName) :
- desc(optionsName.c_str()), did_parse(false), doc(&emptyProgramDoc)
+ desc(optionsName.c_str()), didParse(false), doc(&emptyProgramDoc)
{
return;
}
// Private copy constructor; don't want copies floating around.
CLI::CLI(const CLI& other) : desc(other.desc),
- did_parse(false), doc(&emptyProgramDoc)
+ didParse(false), doc(&emptyProgramDoc)
{
return;
}
@@ -92,7 +92,7 @@
// Notify the user if we are debugging, but only if we actually parsed the
// options. This way this output doesn't show up inexplicably for someone who
// may not have wanted it there (i.e. in Boost unit tests).
- if (did_parse)
+ if (didParse)
Log::Debug << "Compiled with debugging symbols." << std::endl;
return;
@@ -153,7 +153,8 @@
* @param alias The alias we will use for the parameter.
* @param original The name of the actual parameter we will be mapping to.
*/
-void CLI::AddAlias(std::string alias, std::string original) {
+void CLI::AddAlias(std::string alias, std::string original)
+{
//Conduct the mapping
if (alias.length())
{
@@ -276,7 +277,7 @@
// Check if the parameter is boolean; if it is, we just want to see if it was
// passed.
- if(isInGmap)
+ if (isInGmap)
return gmap[key].wasPassed;
// The parameter was not passed in; return false.
@@ -348,7 +349,7 @@
name = amap[name];
- if(gmap.count(name))
+ if (gmap.count(name))
return gmap[name].desc;
else
return "";
@@ -443,7 +444,7 @@
if (data.tname == TYPENAME(std::string))
{
std::string value = GetParam<std::string>(key.c_str());
- if(value == "")
+ if (value == "")
Log::Info << "\"\"";
Log::Info << value;
}
@@ -530,7 +531,7 @@
}
// Print out the descriptions.
- if(docs.programName != "")
+ if (docs.programName != "")
{
std::cout << docs.programName << std::endl << std::endl;
std::cout << " " << HyphenateString(docs.documentation, 2) << std::endl
Modified: mlpack/trunk/src/mlpack/core/util/cli.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/cli.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/util/cli.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -464,7 +464,8 @@
* call to ParseCommandLine() is necessary:
*
* @code
- * int main(int argc, char** argv) {
+ * int main(int argc, char** argv)
+ * {
* CLI::ParseCommandLine(argc, argv);
*
* ...
@@ -639,7 +640,7 @@
/**
* Print out the help info of the hierarchy.
*/
- static void PrintHelp(std::string param="");
+ static void PrintHelp(std::string param = "");
/**
* Registers a ProgramDoc object, which contains documentation about the
@@ -677,7 +678,7 @@
static CLI* singleton;
//! True, if CLI was used to parse command line options.
- bool did_parse;
+ bool didParse;
//! Holds the timer objects.
Timers timer;
Modified: mlpack/trunk/src/mlpack/core/util/cli_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/cli_impl.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/util/cli_impl.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -88,12 +88,12 @@
std::string key = std::string(identifier);
gmap_t& gmap = GetSingleton().globalValues;
- // Now check if we have an alias.
+ // Now check if we have an alias.
amap_t& amap = GetSingleton().aliasValues;
if (amap.count(key))
key = amap[key];
- //What if we don't actually have any value?
+ // What if we don't actually have any value?
if (!gmap.count(key))
{
gmap[key] = ParamData();
@@ -101,12 +101,11 @@
*boost::any_cast<T>(&gmap[key].value) = tmp;
}
- //What if we have meta-data, but no data?
+ // What if we have meta-data, but no data?
boost::any val = gmap[key].value;
- if(val.empty())
+ if (val.empty())
gmap[key].value = boost::any(tmp);
-
return *boost::any_cast<T>(&gmap[key].value);
}
Modified: mlpack/trunk/src/mlpack/core/util/log.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/log.cpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/util/log.cpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -40,7 +40,7 @@
#ifdef DEBUG
void Log::Assert(bool condition, const char* message)
{
- if(!condition)
+ if (!condition)
{
void* array[25];
size_t size = backtrace (array, sizeof(array)/sizeof(void*));
Modified: mlpack/trunk/src/mlpack/core/util/log.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/log.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/util/log.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -32,7 +32,8 @@
* if (!someCondition())
* Log::Warn << "someCondition() is not satisfied!" << std::endl;
* Log::Info << "Checking an important condition." << std::endl;
- * if (!someImportantCondition()) {
+ * if (!someImportantCondition())
+ * {
* Log::Fatal << "someImportantCondition() is not satisfied! Terminating.";
* Log::Fatal << std::endl;
* }
Modified: mlpack/trunk/src/mlpack/core/util/nulloutstream.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/nulloutstream.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/util/nulloutstream.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -19,7 +19,8 @@
* Used for Log::Debug when not compiled with debugging symbols. This class
* does nothing and should be optimized out entirely by the compiler.
*/
-class NullOutStream {
+class NullOutStream
+{
public:
/**
* Does nothing.
Modified: mlpack/trunk/src/mlpack/core/util/option_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/option_impl.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/core/util/option_impl.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -26,14 +26,14 @@
{
if (ignoreTemplate)
{
- if(alias == NULL)
+ if (alias == NULL)
alias = "";
CLI::Add(identifier, description, alias, required);
}
else
{
- if(alias == NULL)
+ if (alias == NULL)
alias = "";
CLI::Add<N>(identifier, description, alias, required);
@@ -51,7 +51,7 @@
const char* description,
const char* alias)
{
- if(alias == NULL)
+ if (alias == NULL)
alias = "";
CLI::AddFlag(identifier, description, alias);
Modified: mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -39,7 +39,8 @@
* arma::vec observation = g.Random();
* @endcode
*/
-class GMM {
+class GMM
+{
private:
//! The number of Gaussians in the model.
size_t gaussians;
Modified: mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -22,7 +22,8 @@
using namespace mlpack::gmm;
using namespace mlpack::utilities;
-int main(int argc, char* argv[]) {
+int main(int argc, char* argv[])
+{
CLI::ParseCommandLine(argc, argv);
// Check parameters and load data.
Modified: mlpack/trunk/src/mlpack/methods/kernel_pca/kernel_pca_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/kernel_pca/kernel_pca_impl.hpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/methods/kernel_pca/kernel_pca_impl.hpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -44,7 +44,7 @@
{
arma::mat transData = trans(data);
- if(centerData)
+ if (centerData)
{
arma::rowvec means = arma::mean(transData, 0);
transData = transData - arma::ones<arma::colvec>(transData.n_rows) * means;
@@ -72,7 +72,7 @@
transData = kernelMat; // Use the kernel matrix to do the transformations
// after this point.
- if(scaleData)
+ if (scaleData)
{
transData = transData / (arma::ones<arma::colvec>(transData.n_rows) *
stddev(transData, 0, 0));
@@ -126,7 +126,7 @@
Apply(data, data, eigVal, coeffs);
- if(newDimension < coeffs.n_rows && newDimension > 0)
+ if (newDimension < coeffs.n_rows && newDimension > 0)
data.shed_rows(newDimension, data.n_rows - 1);
}
Modified: mlpack/trunk/src/mlpack/methods/lars/lars.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/lars/lars.cpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/methods/lars/lars.cpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -39,7 +39,8 @@
lambda2(lambda2)
{ /* nothing left to do */ }
-void LARS::SetGram(const mat& matGram) {
+void LARS::SetGram(const mat& matGram)
+{
this->matGram = matGram;
}
@@ -80,7 +81,7 @@
bool lassocond = false;
// used for elastic net
- if(!elasticNet)
+ if (!elasticNet)
{
lambda2 = 0; // just in case it is accidentally used, the code still will be correct
}
@@ -130,9 +131,9 @@
{
vec newGramCol = vec(nActive);
for (u32 i = 0; i < nActive; i++)
- {
+ {
newGramCol[i] = dot(matX.col(activeSet[i]), matX.col(changeInd));
- }
+ }
CholeskyInsert(matX.col(changeInd), newGramCol);
}
@@ -212,13 +213,13 @@
double val1 = (maxCorr - corr(ind)) / (normalization - dirCorr);
double val2 = (maxCorr + corr(ind)) / (normalization + dirCorr);
if ((val1 > 0) && (val1 < gamma))
- {
- gamma = val1;
- }
- if((val2 > 0) && (val2 < gamma))
- {
- gamma = val2;
- }
+ {
+ gamma = val1;
+ }
+ if ((val2 > 0) && (val2 < gamma))
+ {
+ gamma = val2;
+ }
}
}
@@ -377,7 +378,8 @@
}
}
-void LARS::CholeskyInsert(const vec& newX, const vec& newGramCol) {
+void LARS::CholeskyInsert(const vec& newX, const vec& newGramCol)
+{
int n = matUtriCholFactor.n_rows;
if (n == 0)
@@ -412,7 +414,8 @@
matNewR(span(0, n - 1), span(0, n - 1)) = matUtriCholFactor;
matNewR(span(0, n - 1), n) = matUtriCholFactork;
matNewR(n, span(0, n - 1)).fill(0.0);
- matNewR(n, n) = sqrt(sqNormNewX - dot(matUtriCholFactork, matUtriCholFactork));
+ matNewR(n, n) = sqrt(sqNormNewX - dot(matUtriCholFactork,
+ matUtriCholFactork));
matUtriCholFactor = matNewR;
}
@@ -465,8 +468,8 @@
matUtriCholFactor(span(k, k + 1), k) = rotatedVec;
if (k < n - 1)
{
- matUtriCholFactor(span(k, k + 1), span(k + 1, n - 1)) =
- matG * matUtriCholFactor(span(k, k + 1), span(k + 1, n - 1));
+ matUtriCholFactor(span(k, k + 1), span(k + 1, n - 1)) =
+ matG * matUtriCholFactor(span(k, k + 1), span(k + 1, n - 1));
}
}
matUtriCholFactor.shed_row(n);
Modified: mlpack/trunk/src/mlpack/methods/pca/pca.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/pca/pca.cpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/methods/pca/pca.cpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -33,13 +33,13 @@
{
arma::mat transData = trans(data);
- if(centerData)
+ if (centerData)
{
arma::rowvec means = arma::mean(transData, 0);
transData = transData - arma::ones<arma::colvec>(transData.n_rows) * means;
}
- if(scaleData)
+ if (scaleData)
{
transData = transData / (arma::ones<arma::colvec>(transData.n_rows) *
stddev(transData, 0, 0));
Modified: mlpack/trunk/src/mlpack/methods/radical/radical.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/radical/radical.cpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/methods/radical/radical.cpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -37,13 +37,15 @@
}
-void Radical::CopyAndPerturb(mat& matXNew, const mat& matX) {
+void Radical::CopyAndPerturb(mat& matXNew, const mat& matX)
+{
matXNew = repmat(matX, nReplicates, 1) + noiseStdDev *
randn(nReplicates * matX.n_rows, matX.n_cols);
}
-double Radical::Vasicek(vec& z) {
+double Radical::Vasicek(vec& z)
+{
z = sort(z);
// Apparently slower
@@ -63,7 +65,8 @@
}
-double Radical::DoRadical2D(const mat& matX) {
+double Radical::DoRadical2D(const mat& matX)
+{
mat matXMod;
CopyAndPerturb(matXMod, matX);
@@ -96,7 +99,8 @@
}
-void Radical::DoRadical(const mat& matXT, mat& matY, mat& matW) {
+void Radical::DoRadical(const mat& matXT, mat& matY, mat& matW)
+{
// matX is nPoints by nDims (although less intuitive than columns being
// points, and although this is the transpose of the ICA literature, this
@@ -107,7 +111,7 @@
// if m was not specified, initialize m as recommended in
// (Learned-Miller and Fisher, 2003)
- if(m < 1) {
+ if (m < 1) {
m = floor(sqrt(matX.n_rows));
}
@@ -131,23 +135,26 @@
mat matEye = eye(nDims, nDims);
- for(size_t sweepNum = 0; sweepNum < nSweeps; sweepNum++) {
- for(size_t i = 0; i < nDims - 1; i++) {
- for(size_t j = i + 1; j < nDims; j++) {
- matYSubspace.col(0) = matY.col(i);
- matYSubspace.col(1) = matY.col(j);
- double thetaOpt = DoRadical2D(matYSubspace);
- mat matJ = matEye;
- double cosThetaOpt = cos(thetaOpt);
- double sinThetaOpt = sin(thetaOpt);
- matJ(i,i) = cosThetaOpt;
- matJ(j,i) = -sinThetaOpt;
- matJ(i,j) = sinThetaOpt;
- matJ(j,j) = cosThetaOpt;
- matW = matW * matJ;
- matY = matX * matW; // to avoid any issues of mismatch between matW
- // and matY, do not use matY = matY * matJ,
- // even though it may be much more efficient
+ for(size_t sweepNum = 0; sweepNum < nSweeps; sweepNum++)
+ {
+ for(size_t i = 0; i < nDims - 1; i++)
+ {
+ for(size_t j = i + 1; j < nDims; j++)
+ {
+ matYSubspace.col(0) = matY.col(i);
+ matYSubspace.col(1) = matY.col(j);
+ double thetaOpt = DoRadical2D(matYSubspace);
+ mat matJ = matEye;
+ double cosThetaOpt = cos(thetaOpt);
+ double sinThetaOpt = sin(thetaOpt);
+ matJ(i, i) = cosThetaOpt;
+ matJ(j, i) = -sinThetaOpt;
+ matJ(i, j) = sinThetaOpt;
+ matJ(j, j) = cosThetaOpt;
+ matW = matW * matJ;
+ matY = matX * matW; // to avoid any issues of mismatch between matW
+ // and matY, do not use matY = matY * matJ,
+ // even though it may be much more efficient
}
}
}
@@ -162,7 +169,8 @@
void WhitenFeatureMajorMatrix(const mat& matX,
mat& matXWhitened,
- mat& matWhitening) {
+ mat& matWhitening)
+{
mat matU, matV;
vec s;
svd(matU, s, matV, cov(matX));
Modified: mlpack/trunk/src/mlpack/methods/radical/radical_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/radical/radical_main.cpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/methods/radical/radical_main.cpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -46,7 +46,8 @@
using namespace std;
using namespace arma;
-int main(int argc, char* argv[]) {
+int main(int argc, char* argv[])
+{
// Handle parameters.
CLI::ParseCommandLine(argc, argv);
@@ -61,7 +62,7 @@
size_t nAngles = CLI::GetParam<int>("angles");
size_t nSweeps = CLI::GetParam<int>("sweeps");
- if(nSweeps == 0)
+ if (nSweeps == 0)
{
nSweeps = matX.n_rows - 1;
}
Modified: mlpack/trunk/src/mlpack/tests/aug_lagrangian_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/aug_lagrangian_test.cpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/tests/aug_lagrangian_test.cpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -28,7 +28,7 @@
arma::vec coords = f.GetInitialPoint();
- if(!aug.Optimize(0, coords))
+ if (!aug.Optimize(0, coords))
BOOST_FAIL("Optimization reported failure.");
double finalValue = f.Evaluate(coords);
@@ -48,7 +48,7 @@
arma::vec coords = f.GetInitialPoint();
- if(!aug.Optimize(0, coords))
+ if (!aug.Optimize(0, coords))
BOOST_FAIL("Optimization reported failure.");
double finalValue = f.Evaluate(coords);
@@ -101,7 +101,7 @@
arma::mat coords = ltsdp.GetInitialPoint();
- if(!aug.Optimize(0, coords))
+ if (!aug.Optimize(0, coords))
BOOST_FAIL("Optimization reported failure.");
double finalValue = ltsdp.Evaluate(coords);
Modified: mlpack/trunk/src/mlpack/tests/lars_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/lars_test.cpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/tests/lars_test.cpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -18,7 +18,7 @@
BOOST_AUTO_TEST_SUITE(LARSTest);
-void GenerateProblem(arma::mat& X, arma::vec& y, size_t nPoints, size_t nDims)
+void GenerateProblem(arma::mat& X, arma::vec& y, size_t nPoints, size_t nDims)
{
X = arma::randn(nPoints, nDims);
arma::vec beta = arma::randn(nDims, 1);
@@ -26,20 +26,24 @@
}
-void VerifyCorrectness(arma::vec beta, arma::vec errCorr, double lambda)
+void VerifyCorrectness(arma::vec beta, arma::vec errCorr, double lambda)
{
size_t nDims = beta.n_elem;
const double tol = 1e-12;
- for(size_t j = 0; j < nDims; j++) {
- if(beta(j) == 0) {
+ for(size_t j = 0; j < nDims; j++)
+ {
+ if (beta(j) == 0)
+ {
// make sure that errCorr(j) <= lambda
BOOST_REQUIRE_SMALL(std::max(errCorr(j) - lambda, 0.0), tol);
}
- else if(beta(j) < 0) {
+ else if (beta(j) < 0)
+ {
// make sure that errCorr(j) == lambda
BOOST_REQUIRE_SMALL(errCorr(j) - lambda, tol);
}
- else { // beta(j) > 0
+ else
+ { // beta(j) > 0
// make sure that errCorr(j) == -lambda
BOOST_REQUIRE_SMALL(errCorr(j) + lambda, tol);
}
@@ -47,57 +51,57 @@
}
-void LassoTest(size_t nPoints, size_t nDims, bool elasticNet, bool useCholesky)
+void LassoTest(size_t nPoints, size_t nDims, bool elasticNet, bool useCholesky)
{
arma::mat X;
arma::vec y;
-
- for(size_t i = 0; i < 100; i++)
+
+ for(size_t i = 0; i < 100; i++)
{
GenerateProblem(X, y, nPoints, nDims);
-
+
// Armadillo's median is broken, so...
arma::vec sortedAbsCorr = sort(abs(trans(X) * y));
double lambda1 = sortedAbsCorr(nDims/2);
double lambda2;
if (elasticNet)
- lambda2 = lambda1 / 2;
- else
+ lambda2 = lambda1 / 2;
+ else
lambda2 = 0;
-
-
+
+
LARS lars(useCholesky, lambda1, lambda2);
lars.DoLARS(X, y);
-
+
arma::vec betaOpt;
lars.Solution(betaOpt);
- arma::vec errCorr = (arma::trans(X) * X + lambda2 *
+ arma::vec errCorr = (arma::trans(X) * X + lambda2 *
arma::eye(nDims, nDims)) * betaOpt - arma::trans(X) * y;
-
+
VerifyCorrectness(betaOpt, errCorr, lambda1);
}
}
-BOOST_AUTO_TEST_CASE(LARSTestLassoCholesky)
+BOOST_AUTO_TEST_CASE(LARSTestLassoCholesky)
{
LassoTest(100, 10, true, false);
}
-BOOST_AUTO_TEST_CASE(LARSTestLassoGram)
+BOOST_AUTO_TEST_CASE(LARSTestLassoGram)
{
LassoTest(100, 10, false, false);
}
-BOOST_AUTO_TEST_CASE(LARSTestElasticNetCholesky)
+BOOST_AUTO_TEST_CASE(LARSTestElasticNetCholesky)
{
LassoTest(100, 10, true, true);
}
-BOOST_AUTO_TEST_CASE(LARSTestElasticNetGram)
+BOOST_AUTO_TEST_CASE(LARSTestElasticNetGram)
{
LassoTest(100, 10, true, false);
}
Modified: mlpack/trunk/src/mlpack/tests/tree_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/tree_test.cpp 2011-12-17 07:25:13 UTC (rev 10883)
+++ mlpack/trunk/src/mlpack/tests/tree_test.cpp 2011-12-17 08:21:00 UTC (rev 10884)
@@ -1309,7 +1309,8 @@
bool DoBoundsIntersect(HRectBound<t_pow>& a,
HRectBound<t_pow>& b,
size_t ia,
- size_t ib) {
+ size_t ib)
+{
size_t dimensionality = a.Dim();
Range r_a;
More information about the mlpack-svn
mailing list