diff --git a/HISTORY.md b/HISTORY.md index 3e93518e1b8..288ea6d5343 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -38,6 +38,8 @@ * Refactor LSH to allow loading and saving of models. + * ToString() is removed entirely. + ### mlpack 1.0.11 ###### 2014-12-11 * Proper handling of dimension calculation in PCA. diff --git a/src/mlpack/core.hpp b/src/mlpack/core.hpp index dc9a8c2604a..c7076a25cfc 100644 --- a/src/mlpack/core.hpp +++ b/src/mlpack/core.hpp @@ -159,7 +159,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mlpack/core/dists/discrete_distribution.cpp b/src/mlpack/core/dists/discrete_distribution.cpp index 8441bae8300..f68a7d91416 100644 --- a/src/mlpack/core/dists/discrete_distribution.cpp +++ b/src/mlpack/core/dists/discrete_distribution.cpp @@ -103,21 +103,3 @@ void DiscreteDistribution::Estimate(const arma::mat& observations, else probabilities.fill(1 / probabilities.n_elem); // Force normalization. } - -/** - * Returns a string representation of this object. - */ -std::string DiscreteDistribution::ToString() const -{ - std::ostringstream convert; - convert << "DiscreteDistribution [" << this << "]" << std::endl; - - // Secondary object so we can indent the probabilities. - std::ostringstream prob; - prob << "Probabilities:" << std::endl; - prob << probabilities; - - convert << util::Indent(prob.str()); - return convert.str(); -} - diff --git a/src/mlpack/core/dists/discrete_distribution.hpp b/src/mlpack/core/dists/discrete_distribution.hpp index 05cbd95f246..ef8cc55589c 100644 --- a/src/mlpack/core/dists/discrete_distribution.hpp +++ b/src/mlpack/core/dists/discrete_distribution.hpp @@ -163,11 +163,6 @@ class DiscreteDistribution ar & data::CreateNVP(probabilities, "probabilities"); } - /* - * Returns a string representation of this object. - */ - std::string ToString() const; - private: arma::vec probabilities; }; diff --git a/src/mlpack/core/dists/gaussian_distribution.cpp b/src/mlpack/core/dists/gaussian_distribution.cpp index 0d7eb6cf4fa..02c69bc8b5f 100644 --- a/src/mlpack/core/dists/gaussian_distribution.cpp +++ b/src/mlpack/core/dists/gaussian_distribution.cpp @@ -201,20 +201,3 @@ void GaussianDistribution::Estimate(const arma::mat& observations, FactorCovariance(); } - -/** - * Returns a string representation of this object. - */ -std::string GaussianDistribution::ToString() const -{ - std::ostringstream convert; - convert << "GaussianDistribution [" << this << "]" << std::endl; - - // Secondary ostringstream so things can be indented right. - std::ostringstream data; - data << "Mean: " << std::endl << mean; - data << "Covariance: " << std::endl << covariance; - - convert << util::Indent(data.str()); - return convert.str(); -} diff --git a/src/mlpack/core/dists/gaussian_distribution.hpp b/src/mlpack/core/dists/gaussian_distribution.hpp index e84aff10c36..88844c301be 100644 --- a/src/mlpack/core/dists/gaussian_distribution.hpp +++ b/src/mlpack/core/dists/gaussian_distribution.hpp @@ -153,14 +153,8 @@ class GaussianDistribution ar & CreateNVP(logDetCov, "logDetCov"); } - /** - * Returns a string representation of this object. - */ - std::string ToString() const; - private: void FactorCovariance(); - }; /** diff --git a/src/mlpack/core/dists/laplace_distribution.cpp b/src/mlpack/core/dists/laplace_distribution.cpp index 9bdea5968e5..213c8251896 100644 --- a/src/mlpack/core/dists/laplace_distribution.cpp +++ b/src/mlpack/core/dists/laplace_distribution.cpp @@ -75,17 +75,3 @@ void LaplaceDistribution::Estimate(const arma::mat& observations, scale += probabilities(i) * arma::norm(observations.col(i) - mean, 2); scale /= arma::accu(probabilities); } - -//! Returns a string representation of this object. -std::string LaplaceDistribution::ToString() const -{ - std::ostringstream convert; - convert << "LaplaceDistribution [" << this << "]" << std::endl; - - std::ostringstream data; - data << "Mean: " << std::endl << mean.t(); - data << "Scale: " << scale << "." << std::endl; - - convert << util::Indent(data.str()); - return convert.str(); -} diff --git a/src/mlpack/core/dists/laplace_distribution.hpp b/src/mlpack/core/dists/laplace_distribution.hpp index 96fe911babc..52d86a55f9c 100644 --- a/src/mlpack/core/dists/laplace_distribution.hpp +++ b/src/mlpack/core/dists/laplace_distribution.hpp @@ -145,9 +145,6 @@ class LaplaceDistribution ar & data::CreateNVP(scale, "scale"); } - //! Return a string representation of the object. - std::string ToString() const; - private: //! Mean of the distribution. arma::vec mean; diff --git a/src/mlpack/core/dists/regression_distribution.cpp b/src/mlpack/core/dists/regression_distribution.cpp index 39b29cc6e73..7406f91bd0a 100644 --- a/src/mlpack/core/dists/regression_distribution.cpp +++ b/src/mlpack/core/dists/regression_distribution.cpp @@ -10,24 +10,6 @@ using namespace mlpack; using namespace mlpack::distribution; -/** - * Returns a string representation of this object. - */ -std::string RegressionDistribution::ToString() const -{ - std::ostringstream convert; - convert << "HMMRegression [" << this << "]" << std::endl; - - // Secondary ostringstream so things can be indented right. - std::ostringstream data; - data << "Conditional mean function: " << std::endl << rf.ToString(); - data << "Parameters: " << std::endl << rf.Parameters(); - data << "Error distribution: " << std::endl << err.ToString(); - - convert << util::Indent(data.str()); - return convert.str(); -} - /** * Estimate parameters using provided observation weights * diff --git a/src/mlpack/core/dists/regression_distribution.hpp b/src/mlpack/core/dists/regression_distribution.hpp index 3c81e3f5e43..e59c08684f1 100644 --- a/src/mlpack/core/dists/regression_distribution.hpp +++ b/src/mlpack/core/dists/regression_distribution.hpp @@ -63,11 +63,6 @@ class RegressionDistribution ar & data::CreateNVP(err, "err"); } - /** - * Returns a string representation of this object. - */ - std::string ToString() const; - //! Return regression function. const regression::LinearRegression& Rf() const { return rf; } //! Modify regression function. diff --git a/src/mlpack/core/kernels/cosine_distance.hpp b/src/mlpack/core/kernels/cosine_distance.hpp index 1f5f428356b..2f672d18d18 100644 --- a/src/mlpack/core/kernels/cosine_distance.hpp +++ b/src/mlpack/core/kernels/cosine_distance.hpp @@ -35,16 +35,6 @@ class CosineDistance template static double Evaluate(const VecTypeA& a, const VecTypeB& b); - /** - * Returns a string representation of this object. - */ - std::string ToString() const - { - std::ostringstream convert; - convert << "CosineDistance [" << this << "]" << std::endl; - return convert.str(); - } - //! Serialize the class (there's nothing to save). template void Serialize(Archive& /* ar */, const unsigned int /* version */) const { } diff --git a/src/mlpack/core/kernels/epanechnikov_kernel.cpp b/src/mlpack/core/kernels/epanechnikov_kernel.cpp index cc3bcef39ad..5707f44e0fc 100644 --- a/src/mlpack/core/kernels/epanechnikov_kernel.cpp +++ b/src/mlpack/core/kernels/epanechnikov_kernel.cpp @@ -63,14 +63,3 @@ double EpanechnikovKernel::GradientForSquaredDistance(const double return arma::datum::nan; } } - -// Return string of object. -std::string EpanechnikovKernel::ToString() const -{ - std::ostringstream convert; - convert << "EpanechnikovKernel [" << this << "]" << std::endl; - convert << " Bandwidth: " << bandwidth << std::endl; - convert << " Inverse squared bandwidth: "; - convert << inverseBandwidthSquared << std::endl; - return convert.str(); -} diff --git a/src/mlpack/core/kernels/epanechnikov_kernel.hpp b/src/mlpack/core/kernels/epanechnikov_kernel.hpp index 24826e9cdd5..324900f811a 100644 --- a/src/mlpack/core/kernels/epanechnikov_kernel.hpp +++ b/src/mlpack/core/kernels/epanechnikov_kernel.hpp @@ -89,9 +89,6 @@ class EpanechnikovKernel template void Serialize(Archive& ar, const unsigned int version); - //! Returns string representation of object. - std::string ToString() const; - private: //! Bandwidth of the kernel. double bandwidth; diff --git a/src/mlpack/core/kernels/example_kernel.hpp b/src/mlpack/core/kernels/example_kernel.hpp index 09f92a6c2b0..04fd66f0a37 100644 --- a/src/mlpack/core/kernels/example_kernel.hpp +++ b/src/mlpack/core/kernels/example_kernel.hpp @@ -104,18 +104,6 @@ class ExampleKernel template void Serialize(Archive& /* ar */, const unsigned int /* version */) const { } - /** - * Returns a string for the kernel object; in this case, with only the memory - * address for the kernel. If your kernel has any members, your ToString() - * method should include those as neccessary as well. - **/ - std::string ToString() const - { - std::ostringstream convert; - convert << "ExampleKernel [" << this << "]" << std::endl; - return convert.str(); - } - /** * Obtains the convolution integral [integral K(||x-a||)K(||b-x||)dx] * for the two vectors. In this case, because diff --git a/src/mlpack/core/kernels/gaussian_kernel.hpp b/src/mlpack/core/kernels/gaussian_kernel.hpp index 4977d3065de..dbe5fe9b3e2 100644 --- a/src/mlpack/core/kernels/gaussian_kernel.hpp +++ b/src/mlpack/core/kernels/gaussian_kernel.hpp @@ -147,15 +147,6 @@ class GaussianKernel ar & data::CreateNVP(gamma, "gamma"); } - //! Convert object to string. - std::string ToString() const - { - std::ostringstream convert; - convert << "GaussianKernel [" << this << "]" << std::endl; - convert << " Bandwidth: " << bandwidth << std::endl; - return convert.str(); - } - private: //! Kernel bandwidth. double bandwidth; diff --git a/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp b/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp index 1fd35ecebca..3018b300e13 100644 --- a/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp +++ b/src/mlpack/core/kernels/hyperbolic_tangent_kernel.hpp @@ -75,16 +75,6 @@ class HyperbolicTangentKernel ar & data::CreateNVP(offset, "offset"); } - //! Convert object to string. - std::string ToString() const - { - std::ostringstream convert; - convert << "HyperbolicTangentKernel [" << this << "]" << std::endl; - convert << " Scale: " << scale << std::endl; - convert << " Offset: " << offset << std::endl; - return convert.str(); - } - private: double scale; double offset; diff --git a/src/mlpack/core/kernels/laplacian_kernel.hpp b/src/mlpack/core/kernels/laplacian_kernel.hpp index 7625e4396da..92e92316fc1 100644 --- a/src/mlpack/core/kernels/laplacian_kernel.hpp +++ b/src/mlpack/core/kernels/laplacian_kernel.hpp @@ -98,15 +98,6 @@ class LaplacianKernel ar & data::CreateNVP(bandwidth, "bandwidth"); } - //! Return a string representation of the kernel. - std::string ToString() const - { - std::ostringstream convert; - convert << "LaplacianKernel [" << this << "]" << std::endl; - convert << " Bandwidth: " << bandwidth << std::endl; - return convert.str(); - } - private: //! Kernel bandwidth. double bandwidth; diff --git a/src/mlpack/core/kernels/linear_kernel.hpp b/src/mlpack/core/kernels/linear_kernel.hpp index bed74a12144..0aac392fc86 100644 --- a/src/mlpack/core/kernels/linear_kernel.hpp +++ b/src/mlpack/core/kernels/linear_kernel.hpp @@ -53,14 +53,6 @@ class LinearKernel //! Serialize the kernel (it has no members... do nothing). template void Serialize(Archive& /* ar */, const unsigned int /* version */) const { } - - //! Return a string representation of the kernel. - std::string ToString() const - { - std::ostringstream convert; - convert << "LinearKernel [" << this << "]" << std::endl; - return convert.str(); - } }; } // namespace kernel diff --git a/src/mlpack/core/kernels/polynomial_kernel.hpp b/src/mlpack/core/kernels/polynomial_kernel.hpp index 1e06a77df50..cbed23dee54 100644 --- a/src/mlpack/core/kernels/polynomial_kernel.hpp +++ b/src/mlpack/core/kernels/polynomial_kernel.hpp @@ -70,16 +70,6 @@ class PolynomialKernel ar & data::CreateNVP(offset, "offset"); } - //! Return a string representation of the kernel. - std::string ToString() const - { - std::ostringstream convert; - convert << "PolynomialKernel [" << this << "]" << std::endl; - convert << " Degree: " << degree << std::endl; - convert << " Offset: " << offset << std::endl; - return convert.str(); - } - private: //! The degree of the polynomial. double degree; diff --git a/src/mlpack/core/kernels/pspectrum_string_kernel.hpp b/src/mlpack/core/kernels/pspectrum_string_kernel.hpp index d17475fb214..524488e3edc 100644 --- a/src/mlpack/core/kernels/pspectrum_string_kernel.hpp +++ b/src/mlpack/core/kernels/pspectrum_string_kernel.hpp @@ -95,20 +95,6 @@ class PSpectrumStringKernel //! Modify the value of p. size_t& P() { return p; } - /* - * Returns a string representation of this object. - */ - std::string ToString() const{ - std::ostringstream convert; - convert << "PSpectrumStringKernel [" << this << "]" << std::endl; - convert << " p used: " << p << std::endl; - convert << " Dataset:" << datasets.size() << std::endl; - std::ostringstream convertb; - for (size_t ind=0; ind < datasets.size(); ind++) - convertb << datasets[ind].size(); - convert << mlpack::util::Indent(convertb.str(),2); - return convert.str(); - } private: //! The datasets. const std::vector >& datasets; diff --git a/src/mlpack/core/kernels/spherical_kernel.hpp b/src/mlpack/core/kernels/spherical_kernel.hpp index 30481f12926..9959987fc44 100644 --- a/src/mlpack/core/kernels/spherical_kernel.hpp +++ b/src/mlpack/core/kernels/spherical_kernel.hpp @@ -107,15 +107,6 @@ class SphericalKernel ar & data::CreateNVP(bandwidthSquared, "bandwidthSquared"); } - //! Return a string representation of the kernel. - std::string ToString() const - { - std::ostringstream convert; - convert << "SphericalKernel [" << this << "]" << std::endl; - convert << " Bandwidth: " << bandwidth << std::endl; - return convert.str(); - } - private: double bandwidth; double bandwidthSquared; diff --git a/src/mlpack/core/kernels/triangular_kernel.hpp b/src/mlpack/core/kernels/triangular_kernel.hpp index c59e9035f40..d14014b2c2f 100644 --- a/src/mlpack/core/kernels/triangular_kernel.hpp +++ b/src/mlpack/core/kernels/triangular_kernel.hpp @@ -87,15 +87,6 @@ class TriangularKernel ar & data::CreateNVP(bandwidth, "bandwidth"); } - //! Return a string representation of the kernel. - std::string ToString() const - { - std::ostringstream convert; - convert << "TriangularKernel [" << this << "]" << std::endl; - convert << " Bandwidth: " << bandwidth << std::endl; - return convert.str(); - } - private: //! The bandwidth of the kernel. double bandwidth; diff --git a/src/mlpack/core/math/range.hpp b/src/mlpack/core/math/range.hpp index 09112e06d91..70afa63dee5 100644 --- a/src/mlpack/core/math/range.hpp +++ b/src/mlpack/core/math/range.hpp @@ -161,12 +161,6 @@ class Range */ template void Serialize(Archive& ar, const unsigned int version); - - /** - * Returns a string representation of an object. - */ - inline std::string ToString() const; - }; } // namespace math diff --git a/src/mlpack/core/math/range_impl.hpp b/src/mlpack/core/math/range_impl.hpp index ec2d406bc4e..28631db224a 100644 --- a/src/mlpack/core/math/range_impl.hpp +++ b/src/mlpack/core/math/range_impl.hpp @@ -182,15 +182,6 @@ void Range::Serialize(Archive& ar, const unsigned int /* version */) ar & data::CreateNVP(lo, "lo"); } -/** - * Returns a string representation of an object. - */ -std::string Range::ToString() const -{ - std::ostringstream convert; - convert << "[" << lo << ", " << hi << "]"; - return convert.str(); -} } // namespace math } // namespace mlpack diff --git a/src/mlpack/core/metrics/ip_metric.hpp b/src/mlpack/core/metrics/ip_metric.hpp index a0d1cddf273..7cfc0fc1b92 100644 --- a/src/mlpack/core/metrics/ip_metric.hpp +++ b/src/mlpack/core/metrics/ip_metric.hpp @@ -57,9 +57,6 @@ class IPMetric template void Serialize(Archive& ar, const unsigned int version); - //! Returns a string representation of this object. - std::string ToString() const; - private: //! The kernel we are using. KernelType* kernel; diff --git a/src/mlpack/core/metrics/ip_metric_impl.hpp b/src/mlpack/core/metrics/ip_metric_impl.hpp index 244ff78f241..27a78199eab 100644 --- a/src/mlpack/core/metrics/ip_metric_impl.hpp +++ b/src/mlpack/core/metrics/ip_metric_impl.hpp @@ -68,17 +68,6 @@ void IPMetric::Serialize(Archive& ar, ar & data::CreateNVP(kernel, "kernel"); } -// Convert object to string. -template -std::string IPMetric::ToString() const -{ - std::ostringstream convert; - convert << "IPMetric [" << this << "]" << std::endl; - convert << " Kernel: " << std::endl; - convert << util::Indent(kernel->ToString(), 2); - return convert.str(); -} - // A specialization for the linear kernel, which actually just turns out to be // the Euclidean distance. template<> diff --git a/src/mlpack/core/metrics/lmetric.hpp b/src/mlpack/core/metrics/lmetric.hpp index e96e94d2ae9..fa13da23c73 100644 --- a/src/mlpack/core/metrics/lmetric.hpp +++ b/src/mlpack/core/metrics/lmetric.hpp @@ -77,9 +77,6 @@ class LMetric template static double Evaluate(const VecTypeA& a, const VecTypeB& b); - //! Return a string representation of the object. - std::string ToString() const; - //! Serialize the metric (nothing to do). template void Serialize(Archive& /* ar */, const unsigned int /* version */) { } diff --git a/src/mlpack/core/metrics/lmetric_impl.hpp b/src/mlpack/core/metrics/lmetric_impl.hpp index 7625b2f0f6a..2df35c2b480 100644 --- a/src/mlpack/core/metrics/lmetric_impl.hpp +++ b/src/mlpack/core/metrics/lmetric_impl.hpp @@ -29,17 +29,6 @@ double LMetric::Evaluate(const VecTypeA& a, return pow(sum, (1.0 / Power)); } -// String conversion. -template -std::string LMetric::ToString() const -{ - std::ostringstream convert; - convert << "LMetric [" << this << "]" << std::endl; - convert << " Power: " << Power << std::endl; - convert << " TakeRoot: " << (TakeRoot ? "true" : "false") << std::endl; - return convert.str(); -} - // L1-metric specializations; the root doesn't matter. template<> template diff --git a/src/mlpack/core/metrics/mahalanobis_distance.hpp b/src/mlpack/core/metrics/mahalanobis_distance.hpp index 4350a950b7c..d7000ff26c6 100644 --- a/src/mlpack/core/metrics/mahalanobis_distance.hpp +++ b/src/mlpack/core/metrics/mahalanobis_distance.hpp @@ -101,8 +101,6 @@ class MahalanobisDistance template void Serialize(Archive& ar, const unsigned int version); - //! Return string representation of object. - std::string ToString() const; private: //! The covariance matrix associated with this distance. arma::mat covariance; diff --git a/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp b/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp index 44a9a1a949a..a72c2526a72 100644 --- a/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp +++ b/src/mlpack/core/metrics/mahalanobis_distance_impl.hpp @@ -51,30 +51,6 @@ void MahalanobisDistance::Serialize(Archive& ar, ar & data::CreateNVP(covariance, "covariance"); } -// Convert object into string. -template -std::string MahalanobisDistance::ToString() const -{ - std::ostringstream convert; - std::ostringstream convertb; - convert << "MahalanobisDistance [" << this << "]" << std::endl; - if (TakeRoot) - convert << " TakeRoot: TRUE" << std::endl; - if (covariance.size() < 65) - { - convert << " Covariance: " << std::endl; - convertb << covariance << std::endl; - convert << mlpack::util::Indent(convertb.str(),2); - } - else - { - convert << " Covariance matrix: " << covariance.n_rows << "x" ; - convert << covariance.n_cols << std::endl << " Range: [" ; - convert << covariance.min() << "," << covariance.max() << "]" << std::endl; - } - return convert.str(); -} - } // namespace metric } // namespace mlpack diff --git a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian.hpp b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian.hpp index 1224e22023a..8bc414ec9e4 100644 --- a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian.hpp +++ b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian.hpp @@ -118,9 +118,6 @@ class AugLagrangian //! Modify the penalty parameter. double& Sigma() { return augfunc.Sigma(); } - // convert the obkect into a string - std::string ToString() const; - private: //! Function to be optimized. LagrangianFunction& function; diff --git a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_function.hpp b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_function.hpp index f088dceff4e..36ec3dae3ae 100644 --- a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_function.hpp +++ b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_function.hpp @@ -94,9 +94,6 @@ class AugLagrangianFunction //! Modify the Lagrangian function. LagrangianFunction& Function() { return function; } - // convert the obkect into a string - std::string ToString() const; - private: //! Instantiation of the function to be optimized. LagrangianFunction& function; diff --git a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_function_impl.hpp b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_function_impl.hpp index 7db9d02a386..2a9b07275b2 100644 --- a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_function_impl.hpp +++ b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_function_impl.hpp @@ -95,18 +95,6 @@ const arma::mat& AugLagrangianFunction::GetInitialPoint() return function.GetInitialPoint(); } -// Convert the object to a string. -template -std::string AugLagrangianFunction::ToString() const -{ - std::ostringstream convert; - convert << "AugLagrangianFunction [" << this << "]" << std::endl; - convert << " Lagrange multipliers:" << std::endl; - convert << lambda; - convert << " Penalty parameter: " << sigma << std::endl; - return convert.str(); -} - } // namespace optimization } // namespace mlpack diff --git a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_impl.hpp b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_impl.hpp index 59fb72e2b88..06bf2e9709b 100644 --- a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_impl.hpp +++ b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_impl.hpp @@ -49,19 +49,6 @@ bool AugLagrangian::Optimize(arma::mat& coordinates, return Optimize(coordinates, maxIterations); } -// Convert the object to a string. -template -std::string AugLagrangian::ToString() const -{ - std::ostringstream convert; - convert << "AugLagrangian [" << this << "]" << std::endl; - convert << " Function:" << std::endl; - convert << mlpack::util::Indent(function.ToString(), 2); - convert << " L-BFGS optimizer:" << std::endl; - convert << mlpack::util::Indent(lbfgs.ToString(), 2); - return convert.str(); -} - template bool AugLagrangian::Optimize(arma::mat& coordinates, const size_t maxIterations) diff --git a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp index e2d0dbb5eb6..53efd0fc653 100644 --- a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp +++ b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.cpp @@ -366,11 +366,3 @@ const arma::mat& LovaszThetaSDP::GetInitialPoint() return initialPoint; } - -std::string AugLagrangianTestFunction::ToString() const -{ - // The actual output is unimportant -- this object is only for testing anyway. - std::ostringstream convert; - convert << "AugLagrangianTestFunction [" << this << "]" << std::endl; - return convert.str(); -} diff --git a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.hpp b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.hpp index 8410ec8a142..e27b46b6e87 100644 --- a/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.hpp +++ b/src/mlpack/core/optimizers/aug_lagrangian/aug_lagrangian_test_functions.hpp @@ -38,9 +38,6 @@ class AugLagrangianTestFunction const arma::mat& GetInitialPoint() const { return initialPoint; } - // convert the obkect into a string - std::string ToString() const; - private: arma::mat initialPoint; }; diff --git a/src/mlpack/core/optimizers/lbfgs/lbfgs.hpp b/src/mlpack/core/optimizers/lbfgs/lbfgs.hpp index 2a91db9241e..b54392e1b9c 100644 --- a/src/mlpack/core/optimizers/lbfgs/lbfgs.hpp +++ b/src/mlpack/core/optimizers/lbfgs/lbfgs.hpp @@ -145,9 +145,6 @@ class L_BFGS //! Modify the maximum line search step size. double& MaxStep() { return maxStep; } - // convert the obkect into a string - std::string ToString() const; - private: //! Internal reference to the function we are optimizing. FunctionType& function; diff --git a/src/mlpack/core/optimizers/lbfgs/lbfgs_impl.hpp b/src/mlpack/core/optimizers/lbfgs/lbfgs_impl.hpp index 9f36896e87f..1a8ca4999cf 100644 --- a/src/mlpack/core/optimizers/lbfgs/lbfgs_impl.hpp +++ b/src/mlpack/core/optimizers/lbfgs/lbfgs_impl.hpp @@ -451,26 +451,6 @@ double L_BFGS::Optimize(arma::mat& iterate, return function.Evaluate(iterate); } -// Convert the object to a string. -template -std::string L_BFGS::ToString() const -{ - std::ostringstream convert; - convert << "L_BFGS [" << this << "]" << std::endl; - convert << " Function:" << std::endl; - convert << util::Indent(function.ToString(), 2); - convert << " Memory size: " << numBasis << std::endl; - convert << " Cube size: " << s.n_rows << "x" << s.n_cols << "x" - << s.n_slices << std::endl; - convert << " Maximum iterations: " << maxIterations << std::endl; - convert << " Armijo condition constant: " << armijoConstant << std::endl; - convert << " Wolfe parameter: " << wolfe << std::endl; - convert << " Minimum gradient norm: " << minGradientNorm << std::endl; - convert << " Minimum step for line search: " << minStep << std::endl; - convert << " Maximum step for line search: " << maxStep << std::endl; - return convert.str(); -} - } // namespace optimization } // namespace mlpack diff --git a/src/mlpack/core/optimizers/sa/sa.hpp b/src/mlpack/core/optimizers/sa/sa.hpp index 1d3f876bffe..73f57b34ca9 100644 --- a/src/mlpack/core/optimizers/sa/sa.hpp +++ b/src/mlpack/core/optimizers/sa/sa.hpp @@ -148,8 +148,6 @@ class SA //! Modify move size of each parameter. arma::mat& MoveSize() { return moveSize; } - //! Return a string representation of this object. - std::string ToString() const; private: //! The function to be optimized. FunctionType& function; diff --git a/src/mlpack/core/optimizers/sa/sa_impl.hpp b/src/mlpack/core/optimizers/sa/sa_impl.hpp index 46271a5483c..dcb8a192c76 100644 --- a/src/mlpack/core/optimizers/sa/sa_impl.hpp +++ b/src/mlpack/core/optimizers/sa/sa_impl.hpp @@ -199,30 +199,6 @@ void SA::MoveControl(const size_t nMoves, accept.zeros(); } -template< - typename FunctionType, - typename CoolingScheduleType -> -std::string SA:: -ToString() const -{ - std::ostringstream convert; - convert << "SA [" << this << "]" << std::endl; - convert << " Function:" << std::endl; - convert << util::Indent(function.ToString(), 2); - convert << " Cooling Schedule:" << std::endl; - convert << util::Indent(coolingSchedule.ToString(), 2); - convert << " Temperature: " << temperature << std::endl; - convert << " Initial moves: " << initMoves << std::endl; - convert << " Sweeps per move control: " << moveCtrlSweep << std::endl; - convert << " Tolerance: " << tolerance << std::endl; - convert << " Maximum sweeps below tolerance: " << maxToleranceSweep - << std::endl; - convert << " Move control gain: " << gain << std::endl; - convert << " Maximum iterations: " << maxIterations << std::endl; - return convert.str(); -} - } // namespace optimization } // namespace mlpack diff --git a/src/mlpack/core/optimizers/sdp/lrsdp.hpp b/src/mlpack/core/optimizers/sdp/lrsdp.hpp index b315877382a..53d5970174d 100644 --- a/src/mlpack/core/optimizers/sdp/lrsdp.hpp +++ b/src/mlpack/core/optimizers/sdp/lrsdp.hpp @@ -72,9 +72,6 @@ class LRSDP //! Modify the augmented Lagrangian object. AugLagrangian>& AugLag() { return augLag; } - //! Return a string representation of the object. - std::string ToString() const; - private: //! Function to optimize, which the AugLagrangian object holds. LRSDPFunction function; diff --git a/src/mlpack/core/optimizers/sdp/lrsdp_function.hpp b/src/mlpack/core/optimizers/sdp/lrsdp_function.hpp index 56e1fc1e35b..12ddce2803b 100644 --- a/src/mlpack/core/optimizers/sdp/lrsdp_function.hpp +++ b/src/mlpack/core/optimizers/sdp/lrsdp_function.hpp @@ -84,9 +84,6 @@ class LRSDPFunction //! Modify the SDP object representing the problem. SDPType& SDP() { return sdp; } - //! Return string representation of object. - std::string ToString() const; - private: //! SDP object representing the problem diff --git a/src/mlpack/core/optimizers/sdp/lrsdp_function_impl.hpp b/src/mlpack/core/optimizers/sdp/lrsdp_function_impl.hpp index 2f13b0890a8..0c751061dbe 100644 --- a/src/mlpack/core/optimizers/sdp/lrsdp_function_impl.hpp +++ b/src/mlpack/core/optimizers/sdp/lrsdp_function_impl.hpp @@ -74,20 +74,6 @@ void LRSDPFunction::GradientConstraint(const size_t /* index */, << "optimizers!" << std::endl; } -// Return a string representation of the object. -template -std::string LRSDPFunction::ToString() const -{ - std::ostringstream convert; - convert << "LRSDPFunction [" << this << "]" << std::endl; - convert << " Number of constraints: " << SDP().NumConstraints() << std::endl; - convert << " Problem size: n=" << initialPoint.n_rows << ", r=" - << initialPoint.n_cols << std::endl; - convert << " Sparse Constraint b_i values: " << SDP().SparseB().t(); - convert << " Dense Constraint b_i values: " << SDP().DenseB().t(); - return convert.str(); -} - //! Utility function for calculating part of the objective when AugLagrangian is //! used with an LRSDPFunction. template diff --git a/src/mlpack/core/optimizers/sdp/lrsdp_impl.hpp b/src/mlpack/core/optimizers/sdp/lrsdp_impl.hpp index 6b6389f5d56..a7affdd447b 100644 --- a/src/mlpack/core/optimizers/sdp/lrsdp_impl.hpp +++ b/src/mlpack/core/optimizers/sdp/lrsdp_impl.hpp @@ -30,16 +30,6 @@ double LRSDP::Optimize(arma::mat& coordinates) return augLag.Function().Evaluate(coordinates); } -// Convert the object to a string. -template -std::string LRSDP::ToString() const -{ - std::ostringstream convert; - convert << "LRSDP [" << this << "]" << std::endl; - convert << " Optimizer: " << util::Indent(augLag.ToString(), 1) << std::endl; - return convert.str(); -} - } // namespace optimization } // namespace mlpack diff --git a/src/mlpack/core/optimizers/sgd/sgd.hpp b/src/mlpack/core/optimizers/sgd/sgd.hpp index 7a06416c039..767cc8280a2 100644 --- a/src/mlpack/core/optimizers/sgd/sgd.hpp +++ b/src/mlpack/core/optimizers/sgd/sgd.hpp @@ -123,9 +123,6 @@ class SGD //! Modify whether or not the individual functions are shuffled. bool& Shuffle() { return shuffle; } - //! Return a string representation of the object. - std::string ToString() const; - private: //! The instantiated function. DecomposableFunctionType& function; diff --git a/src/mlpack/core/optimizers/sgd/sgd_impl.hpp b/src/mlpack/core/optimizers/sgd/sgd_impl.hpp index 01fac6faf4b..dacf5e5b47f 100644 --- a/src/mlpack/core/optimizers/sgd/sgd_impl.hpp +++ b/src/mlpack/core/optimizers/sgd/sgd_impl.hpp @@ -109,21 +109,6 @@ double SGD::Optimize(arma::mat& iterate) return overallObjective; } -// Convert the object to a string. -template -std::string SGD::ToString() const -{ - std::ostringstream convert; - convert << "SGD [" << this << "]" << std::endl; - convert << " Function:" << std::endl; - convert << util::Indent(function.ToString(), 2); - convert << " Step size: " << stepSize << std::endl; - convert << " Maximum iterations: " << maxIterations << std::endl; - convert << " Tolerance: " << tolerance << std::endl; - convert << " Shuffle points: " << (shuffle ? "true" : "false") << std::endl; - return convert.str(); -} - } // namespace optimization } // namespace mlpack diff --git a/src/mlpack/core/tree/ballbound.hpp b/src/mlpack/core/tree/ballbound.hpp index b3de6138ded..2201fc4d166 100644 --- a/src/mlpack/core/tree/ballbound.hpp +++ b/src/mlpack/core/tree/ballbound.hpp @@ -183,11 +183,6 @@ class BallBound //! Serialize the bound. template void Serialize(Archive& ar, const unsigned int version); - - /** - * Returns a string representation of this object. - */ - std::string ToString() const; }; //! A specialization of BoundTraits for this bound type. diff --git a/src/mlpack/core/tree/ballbound_impl.hpp b/src/mlpack/core/tree/ballbound_impl.hpp index 4cfe1d37fc6..95fbf22f12e 100644 --- a/src/mlpack/core/tree/ballbound_impl.hpp +++ b/src/mlpack/core/tree/ballbound_impl.hpp @@ -287,21 +287,6 @@ void BallBound::Serialize( ar & data::CreateNVP(ownsMetric, "ownsMetric"); } -/** - * Returns a string representation of this object. - */ -template -std::string BallBound::ToString() const -{ - std::ostringstream convert; - convert << "BallBound [" << this << "]" << std::endl; - convert << " Radius: " << radius << std::endl; - convert << " Center:" << std::endl << center; - convert << " ownsMetric: " << ownsMetric << std::endl; - convert << " Metric:" << std::endl << metric->ToString(); - return convert.str(); -} - } // namespace bound } // namespace mlpack diff --git a/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp b/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp index 6d6f212cffe..21e789d7d35 100644 --- a/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp +++ b/src/mlpack/core/tree/binary_space_tree/binary_space_tree.hpp @@ -492,11 +492,6 @@ class BinarySpaceTree */ template void Serialize(Archive& ar, const unsigned int version); - - /** - * Returns a string representation of this object. - */ - std::string ToString() const; }; } // namespace tree diff --git a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp index 34bca4e012e..492373e8ead 100644 --- a/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp +++ b/src/mlpack/core/tree/binary_space_tree/binary_space_tree_impl.hpp @@ -838,42 +838,6 @@ void BinarySpaceTree:: } } -/** - * Returns a string representation of this object. - */ -template class BoundType, - template - class SplitType> -std::string BinarySpaceTree:: - ToString() const -{ - std::ostringstream convert; - convert << "BinarySpaceTree [" << this << "]" << std::endl; - convert << " First point: " << begin << std::endl; - convert << " Number of descendants: " << count << std::endl; - convert << " Bound: " << std::endl; - convert << mlpack::util::Indent(bound.ToString(), 2); - convert << " Statistic: " << std::endl; - convert << mlpack::util::Indent(stat.ToString(), 2); - - // How many levels should we print? This will print the top two tree levels. - if (left != NULL && parent == NULL) - { - convert << " Left child:" << std::endl; - convert << mlpack::util::Indent(left->ToString(), 2); - } - if (right != NULL && parent == NULL) - { - convert << " Right child:" << std::endl; - convert << mlpack::util::Indent(right->ToString(), 2); - } - return convert.str(); -} - } // namespace tree } // namespace mlpack diff --git a/src/mlpack/core/tree/cover_tree/cover_tree.hpp b/src/mlpack/core/tree/cover_tree/cover_tree.hpp index bbec68ce537..f2ded5b2936 100644 --- a/src/mlpack/core/tree/cover_tree/cover_tree.hpp +++ b/src/mlpack/core/tree/cover_tree/cover_tree.hpp @@ -500,11 +500,6 @@ class CoverTree friend class boost::serialization::access; public: - /** - * Returns a string representation of this object. - */ - std::string ToString() const; - /** * Serialize the tree. */ diff --git a/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp b/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp index 65a2d63c675..991f0719efc 100644 --- a/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp +++ b/src/mlpack/core/tree/cover_tree/cover_tree_impl.hpp @@ -1337,41 +1337,6 @@ CoverTree::CoverTree() : // Nothing to do. } -/** - * Returns a string representation of this object. - */ -template< - typename MetricType, - typename StatisticType, - typename MatType, - typename RootPointPolicy -> -std::string CoverTree:: - ToString() const -{ - std::ostringstream convert; - convert << "CoverTree [" << this << "]" << std::endl; - convert << " dataset: " << dataset << std::endl; - convert << " point: " << point << std::endl; - convert << " scale: " << scale << std::endl; - convert << " base: " << base << std::endl; - convert << " parent distance : " << parentDistance << std::endl; - convert << " furthest descendant distance: " << furthestDescendantDistance; - convert << std::endl; - convert << " children:"; - - // How many levels should we print? This will print the top two tree levels. - if (IsLeaf() == false && parent == NULL) - for (size_t i = 0; i < children.size(); i++) - convert << std::endl << mlpack::util::Indent(children.at(i)->ToString()); - convert << std::endl; - convert << " descendants: " << NumDescendants() << std::endl; - - convert << "StatisticType: " << stat << std::endl; - - return convert.str(); -} - /** * Serialize to/from a boost::serialization archive. */ diff --git a/src/mlpack/core/tree/hrectbound.hpp b/src/mlpack/core/tree/hrectbound.hpp index 330b0e4606b..2f6c3eeacc5 100644 --- a/src/mlpack/core/tree/hrectbound.hpp +++ b/src/mlpack/core/tree/hrectbound.hpp @@ -192,11 +192,6 @@ class HRectBound template void Serialize(Archive& ar, const unsigned int version); - /** - * Returns a string representation of this object. - */ - std::string ToString() const; - private: //! The dimensionality of the bound. size_t dim; diff --git a/src/mlpack/core/tree/hrectbound_impl.hpp b/src/mlpack/core/tree/hrectbound_impl.hpp index 36e611977fd..5b6420fc11a 100644 --- a/src/mlpack/core/tree/hrectbound_impl.hpp +++ b/src/mlpack/core/tree/hrectbound_impl.hpp @@ -458,26 +458,6 @@ void HRectBound::Serialize(Archive& ar, ar & data::CreateNVP(minWidth, "minWidth"); } -/** - * Returns a string representation of this object. - */ -template -std::string HRectBound::ToString() const -{ - std::ostringstream convert; - convert << "HRectBound [" << this << "]" << std::endl; - convert << " Power: " << MetricType::Power << std::endl; - convert << " TakeRoot: " << (MetricType::TakeRoot ? "true" : "false") - << std::endl; - convert << " Dimensionality: " << dim << std::endl; - convert << " Bounds: " << std::endl; - for (size_t i = 0; i < dim; ++i) - convert << util::Indent(bounds[i].ToString()) << std::endl; - convert << " Minimum width: " << minWidth << std::endl; - - return convert.str(); -} - } // namespace bound } // namespace mlpack diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp index 77021cdffb8..f718845a6b1 100644 --- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp +++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree.hpp @@ -598,11 +598,6 @@ class RectangleTree */ RectangleTree* ExactClone(); - /** - * Returns a string representation of this object. - */ - std::string ToString() const; - /** * Serialize the tree. */ diff --git a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp index 8e4fa4d3c38..0d0fbb9472e 100644 --- a/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp +++ b/src/mlpack/core/tree/rectangle_tree/rectangle_tree_impl.hpp @@ -934,41 +934,6 @@ bool RectangleTree:: return sum != sum2; } -/** - * Returns a string representation of this object. - */ -template -std::string RectangleTree::ToString() const -{ - std::ostringstream convert; - convert << "RectangleTree [" << this << "]" << std::endl; - convert << " First point: " << begin << std::endl; - convert << " Number of descendants: " << numChildren << std::endl; - convert << " Number of points: " << count << std::endl; - convert << " Bound: " << std::endl; - convert << mlpack::util::Indent(bound.ToString(), 2); - convert << " Statistic: " << std::endl; - //convert << mlpack::util::Indent(stat.ToString(), 2); - convert << " Max leaf size: " << maxLeafSize << std::endl; - convert << " Min leaf size: " << minLeafSize << std::endl; - convert << " Max num of children: " << maxNumChildren << std::endl; - convert << " Min num of children: " << minNumChildren << std::endl; - convert << " Parent address: " << parent << std::endl; - - // How many levels should we print? This will print the top 3 levels - // (counting the root). - if (parent == NULL || parent->Parent() == NULL) - for (int i = 0; i < numChildren; i++) - convert << children[i]->ToString(); - - return convert.str(); -} - /** * Serialize the tree. */ diff --git a/src/mlpack/core/tree/statistic.hpp b/src/mlpack/core/tree/statistic.hpp index a7f5104520f..b1309217fe9 100644 --- a/src/mlpack/core/tree/statistic.hpp +++ b/src/mlpack/core/tree/statistic.hpp @@ -38,16 +38,6 @@ class EmptyStatistic template void Serialize(Archive& /* ar */, const unsigned int /* version */) { } - - /** - * Returns a string representation of this object. - */ - std::string ToString() const - { - std::stringstream convert; - convert << "EmptyStatistic [" << this << "]" << std::endl; - return convert.str(); - } }; } // namespace tree diff --git a/src/mlpack/core/util/CMakeLists.txt b/src/mlpack/core/util/CMakeLists.txt index 67b549cd544..2db60eb238a 100644 --- a/src/mlpack/core/util/CMakeLists.txt +++ b/src/mlpack/core/util/CMakeLists.txt @@ -14,7 +14,6 @@ set(SOURCES option.hpp option.cpp option_impl.hpp - ostream_extra.hpp prefixedoutstream.hpp prefixedoutstream.cpp prefixedoutstream_impl.hpp diff --git a/src/mlpack/core/util/ostream_extra.hpp b/src/mlpack/core/util/ostream_extra.hpp deleted file mode 100644 index c96cb70f1b0..00000000000 --- a/src/mlpack/core/util/ostream_extra.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @file ostream_extra.hpp - * @author Ryan Curtin - * - * Allow ostream::operator<<(T&) for mlpack objects that have ToString - * implemented. - */ -#ifndef __MLPACK_CORE_UTIL_OSTREAM_EXTRA_HPP -#define __MLPACK_CORE_UTIL_OSTREAM_EXTRA_HPP - -#include "sfinae_utility.hpp" - -// Hide in a namespace so we don't pollute the global namespace. - -namespace mlpack { -namespace util { -namespace misc { - -HAS_MEM_FUNC(ToString, HasToString); - -} // namespace misc -} // namespace util -} // namespace mlpack - -template< - typename T, - typename junk1 = typename boost::enable_if >::type, - typename junk2 = typename boost::enable_if< - mlpack::util::misc::HasToString >::type -> -std::ostream& operator<<(std::ostream& stream, const T& t) -{ - stream << t.ToString(); - return stream; -} - -#endif diff --git a/src/mlpack/core/util/prefixedoutstream.hpp b/src/mlpack/core/util/prefixedoutstream.hpp index 4f75759e3cc..7af45407812 100644 --- a/src/mlpack/core/util/prefixedoutstream.hpp +++ b/src/mlpack/core/util/prefixedoutstream.hpp @@ -120,36 +120,6 @@ class PrefixedOutStream bool ignoreInput; private: - HAS_MEM_FUNC(ToString, HasToString) - - //! This handles forwarding all primitive types transparently. - template - void CallBaseLogic(const T& s, - typename boost::disable_if< - boost::is_class - >::type* = 0); - - //! Forward all objects that do not implement a ToString() method. - template - void CallBaseLogic(const T& s, - typename boost::enable_if< - boost::is_class - >::type* = 0, - typename boost::disable_if< - HasToString - >::type* = 0); - - //! Call ToString() on all objects that implement ToString() before - //! forwarding. - template - void CallBaseLogic(const T& s, - typename boost::enable_if< - boost::is_class - >::type* = 0, - typename boost::enable_if< - HasToString - >::type* = 0); - /** * Conducts the base logic required in all the operator << overloads. Mostly * just a good idea to reduce copy-pasta. diff --git a/src/mlpack/core/util/prefixedoutstream_impl.hpp b/src/mlpack/core/util/prefixedoutstream_impl.hpp index dd7bc81ce65..d86763fed88 100644 --- a/src/mlpack/core/util/prefixedoutstream_impl.hpp +++ b/src/mlpack/core/util/prefixedoutstream_impl.hpp @@ -17,46 +17,9 @@ namespace util { template PrefixedOutStream& PrefixedOutStream::operator<<(const T& s) -{ - CallBaseLogic(s); - return *this; -} - -//! This handles forwarding all primitive types transparently. -template -void PrefixedOutStream::CallBaseLogic(const T& s, - typename boost::disable_if< - boost::is_class - >::type*) { BaseLogic(s); -} - -// Forward all objects that do not implement a ToString() method transparently. -template -void PrefixedOutStream::CallBaseLogic(const T& s, - typename boost::enable_if< - boost::is_class - >::type*, - typename boost::disable_if< - HasToString - >::type*) -{ - BaseLogic(s); -} - -// Call ToString() on all objects that implement ToString() before forwarding. -template -void PrefixedOutStream::CallBaseLogic(const T& s, - typename boost::enable_if< - boost::is_class - >::type*, - typename boost::enable_if< - HasToString - >::type*) -{ - std::string result = s.ToString(); - BaseLogic(result); + return *this; } template diff --git a/src/mlpack/methods/cf/cf.hpp b/src/mlpack/methods/cf/cf.hpp index f451003413d..e2165e9bc71 100644 --- a/src/mlpack/methods/cf/cf.hpp +++ b/src/mlpack/methods/cf/cf.hpp @@ -215,11 +215,6 @@ class CF void Predict(const arma::Mat& combinations, arma::vec& predictions) const; - /** - * Returns a string representation of this object. - */ - std::string ToString() const; - private: //! Number of users for similarity. size_t numUsersForSimilarity; diff --git a/src/mlpack/methods/cf/cf_impl.hpp b/src/mlpack/methods/cf/cf_impl.hpp index 8ac19e21b62..75a43b903de 100644 --- a/src/mlpack/methods/cf/cf_impl.hpp +++ b/src/mlpack/methods/cf/cf_impl.hpp @@ -388,19 +388,6 @@ void CF::InsertNeighbor(const size_t queryIndex, recommendations(pos, queryIndex) = neighbor; } -// Return string of object. -template -std::string CF::ToString() const -{ - std::ostringstream convert; - convert << "Collaborative Filtering [" << this << "]" << std::endl; - //convert << " Number of Recommendations: " << numRecs << std::endl; - //convert << " Number of Users for Similarity: " << numUsersForSimilarity; - //convert << std::endl; - //convert << " Data: " << data.n_rows << "x" << data.n_cols << std::endl; - return convert.str(); -} - } // namespace mlpack } // namespace cf diff --git a/src/mlpack/methods/det/dtree.cpp b/src/mlpack/methods/det/dtree.cpp index 39ae88bca6a..ef27704b7a5 100644 --- a/src/mlpack/methods/det/dtree.cpp +++ b/src/mlpack/methods/det/dtree.cpp @@ -691,19 +691,3 @@ void DTree::ComputeVariableImportance(arma::vec& importances) const nodes.push(curNode.Right()); } } - -// Return string of object. -std::string DTree::ToString() const -{ - std::ostringstream convert; - convert << "Density Estimation Tree [" << this << "]" << std::endl; - convert << " Start Node Index: " << start <::Cleanup() CleanupHelper(tree); } -// convert the object to a string -template< - typename MetricType, - typename MatType, - template class TreeType> -std::string DualTreeBoruvka::ToString() const -{ - std::ostringstream convert; - convert << "DualTreeBoruvka [" << this << "]" << std::endl; - convert << " Data: " << data.n_rows << "x" << data.n_cols <::InsertNeighbor( indices(pos, queryIndex) = neighbor; } -// Return string of object. -template class TreeType> -std::string FastMKS::ToString() const -{ - std::ostringstream convert; - convert << "FastMKS [" << this << "]" << std::endl; - convert << " Naive: " << naive << std::endl; - convert << " Single: " << singleMode << std::endl; - convert << " Metric: " << std::endl; - convert << mlpack::util::Indent(metric.ToString(),2); - convert << std::endl; - return convert.str(); -} - } // namespace fastmks } // namespace mlpack diff --git a/src/mlpack/methods/gmm/gmm.hpp b/src/mlpack/methods/gmm/gmm.hpp index 6317706099a..83c8e04ad6b 100644 --- a/src/mlpack/methods/gmm/gmm.hpp +++ b/src/mlpack/methods/gmm/gmm.hpp @@ -326,11 +326,6 @@ class GMM void Classify(const arma::mat& observations, arma::Col& labels) const; - /** - * Returns a string representation of this object. - */ - std::string ToString() const; - /** * Serialize the GMM. */ diff --git a/src/mlpack/methods/gmm/gmm_impl.hpp b/src/mlpack/methods/gmm/gmm_impl.hpp index 8e870e42836..02298f9fdb5 100644 --- a/src/mlpack/methods/gmm/gmm_impl.hpp +++ b/src/mlpack/methods/gmm/gmm_impl.hpp @@ -394,35 +394,6 @@ double GMM::LogLikelihood( return loglikelihood; } -/** -* Returns a string representation of this object. -*/ -template -std::string GMM::ToString() const -{ - std::ostringstream convert; - std::ostringstream data; - convert << "GMM [" << this << "]" << std::endl; - convert << " Gaussians: " << gaussians << std::endl; - convert << " Dimensionality: "<::Backward(const arma::mat& dataSeq, } } -template -std::string HMM::ToString() const -{ - std::ostringstream convert; - convert << "HMM [" << this << "]" << std::endl; - convert << " Dimensionality: " << dimensionality < template diff --git a/src/mlpack/methods/kernel_pca/kernel_pca.hpp b/src/mlpack/methods/kernel_pca/kernel_pca.hpp index 68162d69c02..7617f36b8f7 100644 --- a/src/mlpack/methods/kernel_pca/kernel_pca.hpp +++ b/src/mlpack/methods/kernel_pca/kernel_pca.hpp @@ -111,9 +111,6 @@ class KernelPCA //! Return whether or not the transformed data is centered. bool& CenterTransformedData() { return centerTransformedData; } - // Returns a string representation of this object. - std::string ToString() const; - private: //! The instantiated kernel. KernelType kernel; diff --git a/src/mlpack/methods/kernel_pca/kernel_pca_impl.hpp b/src/mlpack/methods/kernel_pca/kernel_pca_impl.hpp index e9f800acf3b..2f2bfb42191 100644 --- a/src/mlpack/methods/kernel_pca/kernel_pca_impl.hpp +++ b/src/mlpack/methods/kernel_pca/kernel_pca_impl.hpp @@ -76,19 +76,6 @@ void KernelPCA::Apply(arma::mat& data, data.shed_rows(newDimension, data.n_rows - 1); } -//! Returns a string representation of the object. -template -std::string KernelPCA::ToString() const -{ - std::ostringstream convert; - convert << "KernelPCA [" << this << "]" << std::endl; - convert << " Center Transformed: " << centerTransformedData < void Serialize(Archive& ar, const unsigned int version); diff --git a/src/mlpack/methods/kmeans/kmeans_impl.hpp b/src/mlpack/methods/kmeans/kmeans_impl.hpp index 354b13a9afb..0e0942b4612 100644 --- a/src/mlpack/methods/kmeans/kmeans_impl.hpp +++ b/src/mlpack/methods/kmeans/kmeans_impl.hpp @@ -265,26 +265,6 @@ Cluster(const MatType& data, } } -template class LloydStepType, - typename MatType> -std::string KMeans::ToString() const -{ - std::ostringstream convert; - convert << "KMeans [" << this << "]" << std::endl; - convert << " Max Iterations: " << maxIterations << std::endl; - convert << " Metric: " << std::endl; - convert << mlpack::util::Indent(metric.ToString(), 2); - convert << std::endl; - return convert.str(); -} - template::Objective( double froNormResidual = norm(data - dictionary * codes, "fro"); return std::pow(froNormResidual, 2.0) + lambda * weightedL1NormZ; } -template -std::string LocalCoordinateCoding::ToString() const -{ - std::ostringstream convert; - convert << "Local Coordinate Coding [" << this << "]" << std::endl; - convert << " Number of Atoms: " << atoms << std::endl; - convert << " Data: " << data.n_rows << "x" << data.n_cols << std::endl; - convert << " Lambda: " << lambda << std::endl; - return convert.str(); -} } // namespace lcc } // namespace mlpack diff --git a/src/mlpack/methods/logistic_regression/logistic_regression.hpp b/src/mlpack/methods/logistic_regression/logistic_regression.hpp index d828efcf0c7..8accd0bb54b 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression.hpp @@ -193,9 +193,6 @@ class LogisticRegression template void Serialize(Archive& ar, const unsigned int /* version */); - //! Returns a string representation of this object. - std::string ToString() const; - private: //! Vector of trained parameters (size: dimensionality plus one). arma::vec parameters; diff --git a/src/mlpack/methods/logistic_regression/logistic_regression_impl.hpp b/src/mlpack/methods/logistic_regression/logistic_regression_impl.hpp index ebfb39282f9..69d93e0c70a 100644 --- a/src/mlpack/methods/logistic_regression/logistic_regression_impl.hpp +++ b/src/mlpack/methods/logistic_regression/logistic_regression_impl.hpp @@ -148,16 +148,6 @@ void LogisticRegression::Serialize( ar & data::CreateNVP(lambda, "lambda"); } -template -std::string LogisticRegression::ToString() const -{ - std::ostringstream convert; - convert << "Logistic Regression [" << this << "]" << std::endl; - convert << " Parameters: " << parameters.n_rows << std::endl; - convert << " Lambda: " << lambda << std::endl; - return convert.str(); -} - } // namespace regression } // namespace mlpack diff --git a/src/mlpack/methods/lsh/lsh_search.hpp b/src/mlpack/methods/lsh/lsh_search.hpp index 01f77440996..d4ff0629eff 100644 --- a/src/mlpack/methods/lsh/lsh_search.hpp +++ b/src/mlpack/methods/lsh/lsh_search.hpp @@ -149,9 +149,6 @@ class LSHSearch template void Serialize(Archive& ar, const unsigned int /* version */); - //! Returns a string representation of this object. - std::string ToString() const; - //! Return the number of distance evaluations performed. size_t DistanceEvaluations() const { return distanceEvaluations; } //! Modify the number of distance evaluations performed. diff --git a/src/mlpack/methods/lsh/lsh_search_impl.hpp b/src/mlpack/methods/lsh/lsh_search_impl.hpp index f74c11f30f8..1db8ab197f7 100644 --- a/src/mlpack/methods/lsh/lsh_search_impl.hpp +++ b/src/mlpack/methods/lsh/lsh_search_impl.hpp @@ -532,19 +532,6 @@ void LSHSearch::Serialize(Archive& ar, ar & CreateNVP(distanceEvaluations, "distanceEvaluations"); } -template -std::string LSHSearch::ToString() const -{ - std::ostringstream convert; - convert << "LSHSearch [" << this << "]" << std::endl; - convert << " Reference set: " << referenceSet->n_rows << "x" ; - convert << referenceSet->n_cols << std::endl; - convert << " Number of Projections: " << numProj << std::endl; - convert << " Number of Tables: " << numTables << std::endl; - convert << " Hash Width: " << hashWidth << std::endl; - return convert.str(); -} - } // namespace neighbor } // namespace mlpack diff --git a/src/mlpack/methods/nca/nca.hpp b/src/mlpack/methods/nca/nca.hpp index 49cba7c9a41..298d64e82b2 100644 --- a/src/mlpack/methods/nca/nca.hpp +++ b/src/mlpack/methods/nca/nca.hpp @@ -83,9 +83,6 @@ class NCA OptimizerType >& Optimizer() { return optimizer; } - // Returns a string representation of this object. - std::string ToString() const; - private: //! Dataset reference. const arma::mat& dataset; diff --git a/src/mlpack/methods/nca/nca_impl.hpp b/src/mlpack/methods/nca/nca_impl.hpp index aba623d9cc8..49ff29da389 100644 --- a/src/mlpack/methods/nca/nca_impl.hpp +++ b/src/mlpack/methods/nca/nca_impl.hpp @@ -40,19 +40,6 @@ void NCA::LearnDistance(arma::mat& outputMatrix) Timer::Stop("nca_sgd_optimization"); } -template class OptimizerType> -std::string NCA::ToString() const -{ - std::ostringstream convert; - convert << "NCA [" << this << "]" << std::endl; - convert << " Dataset: " << dataset.n_rows << "x" << dataset.n_cols - << std::endl; - convert << " Metric: " << std::endl << - mlpack::util::Indent(metric.ToString(),2); - return convert.str(); -} - - } // namespace nca } // namespace mlpack diff --git a/src/mlpack/methods/nca/nca_softmax_error_function.hpp b/src/mlpack/methods/nca/nca_softmax_error_function.hpp index 54c9934b2b8..4d162cd77e3 100644 --- a/src/mlpack/methods/nca/nca_softmax_error_function.hpp +++ b/src/mlpack/methods/nca/nca_softmax_error_function.hpp @@ -108,9 +108,6 @@ class SoftmaxErrorFunction */ size_t NumFunctions() const { return dataset.n_cols; } - // convert the obkect into a string - std::string ToString() const; - private: //! The dataset. const arma::mat& dataset; diff --git a/src/mlpack/methods/nca/nca_softmax_error_function_impl.hpp b/src/mlpack/methods/nca/nca_softmax_error_function_impl.hpp index 346457f4d72..de97ace3b71 100644 --- a/src/mlpack/methods/nca/nca_softmax_error_function_impl.hpp +++ b/src/mlpack/methods/nca/nca_softmax_error_function_impl.hpp @@ -267,18 +267,6 @@ void SoftmaxErrorFunction::Precalculate( precalculated = true; } -template -std::string SoftmaxErrorFunction::ToString() const{ - std::ostringstream convert; - convert << "Sofmax Error Function [" << this << "]" << std::endl; - convert << " Dataset: " << dataset.n_rows << "x" << dataset.n_cols - << std::endl; - convert << " Labels: " << labels.n_elem << std::endl; - //convert << "Metric: " << metric << std::endl; - convert << " Precalculated: " << precalculated << std::endl; - return convert.str(); -} - } // namespace nca } // namespace mlpack diff --git a/src/mlpack/methods/neighbor_search/neighbor_search.hpp b/src/mlpack/methods/neighbor_search/neighbor_search.hpp index 1c74393aaef..d2055a1208b 100644 --- a/src/mlpack/methods/neighbor_search/neighbor_search.hpp +++ b/src/mlpack/methods/neighbor_search/neighbor_search.hpp @@ -248,9 +248,6 @@ class NeighborSearch arma::Mat& neighbors, arma::mat& distances); - //! Returns a string representation of this object. - std::string ToString() const; - //! Return the total number of base case evaluations performed during the last //! search. size_t BaseCases() const { return baseCases; } diff --git a/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp b/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp index 6f01c0f48d5..2657f5f8371 100644 --- a/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp +++ b/src/mlpack/methods/neighbor_search/neighbor_search_impl.hpp @@ -689,30 +689,6 @@ Search(const size_t k, } } -// Return a String of the Object. -template class TreeType, - template class TraversalType> -std::string NeighborSearch::ToString() const -{ - std::ostringstream convert; - convert << "NeighborSearch [" << this << "]" << std::endl; - convert << " Reference set: " << referenceSet->n_rows << "x" ; - convert << referenceSet->n_cols << std::endl; - if (referenceTree) - convert << " Reference tree: " << referenceTree << std::endl; - convert << " Tree owner: " << treeOwner << std::endl; - convert << " Naive: " << naive << std::endl; - convert << " Metric: " << std::endl; - convert << mlpack::util::Indent(metric.ToString(),2); - return convert.str(); -} - //! Serialize the NeighborSearch model. template void Serialize(Archive& ar, const unsigned int version); - //! Returns a string representation of this object. - std::string ToString() const; - //! Return the reference set. const MatType& ReferenceSet() const { return *referenceSet; } diff --git a/src/mlpack/methods/range_search/range_search_impl.hpp b/src/mlpack/methods/range_search/range_search_impl.hpp index 3ac24f25d3a..cc67146dfcc 100644 --- a/src/mlpack/methods/range_search/range_search_impl.hpp +++ b/src/mlpack/methods/range_search/range_search_impl.hpp @@ -695,24 +695,6 @@ void RangeSearch::Serialize( } } -template class TreeType> -std::string RangeSearch::ToString() const -{ - std::ostringstream convert; - convert << "Range Search [" << this << "]" << std::endl; - if (treeOwner) - convert << " Tree Owner: TRUE" << std::endl; - if (naive) - convert << " Naive: TRUE" << std::endl; - convert << " Metric: " << std::endl << - mlpack::util::Indent(metric.ToString(),2); - return convert.str(); -} - } // namespace range } // namespace mlpack diff --git a/src/mlpack/methods/rann/ra_search.hpp b/src/mlpack/methods/rann/ra_search.hpp index 40a4c0f3780..594fa67960a 100644 --- a/src/mlpack/methods/rann/ra_search.hpp +++ b/src/mlpack/methods/rann/ra_search.hpp @@ -287,9 +287,6 @@ class RASearch //! Modify the limit on the size of a node that can be approximation. size_t& SingleSampleLimit() { return singleSampleLimit; } - //! Returns a string representation of this object. - std::string ToString() const; - //! Serialize the object. template void Serialize(Archive& ar, const unsigned int /* version */); diff --git a/src/mlpack/methods/rann/ra_search_impl.hpp b/src/mlpack/methods/rann/ra_search_impl.hpp index 0c60234b255..f6da87cb0a5 100644 --- a/src/mlpack/methods/rann/ra_search_impl.hpp +++ b/src/mlpack/methods/rann/ra_search_impl.hpp @@ -481,51 +481,6 @@ void RASearch::ResetQueryTree( ResetQueryTree(&queryNode->Child(i)); } -// Returns a string representation of the object. -template class TreeType> -std::string RASearch::ToString() - const -{ - std::ostringstream convert; - convert << "RASearch [" << this << "]" << std::endl; - convert << " referenceSet: " << referenceSet->n_rows << "x" - << referenceSet->n_cols << std::endl; - - convert << " naive: "; - if (naive) - convert << "true" << std::endl; - else - convert << "false" << std::endl; - - convert << " singleMode: "; - if (singleMode) - convert << "true" << std::endl; - else - convert << "false" << std::endl; - - convert << " tau: " << tau << std::endl; - convert << " alpha: " << alpha << std::endl; - convert << " sampleAtLeaves: "; - if (sampleAtLeaves) - convert << "true" << std::endl; - else - convert << "false" << std::endl; - - convert << " firstLeafExact: "; - if (firstLeafExact) - convert << "true" << std::endl; - else - convert << "false" << std::endl; - convert << " singleSampleLimit: " << singleSampleLimit << std::endl; - convert << " metric: " << std::endl << util::Indent(metric.ToString(), 2); - return convert.str(); -} - template::Objective() const } } -template -std::string SparseCoding::ToString() const -{ - std::ostringstream convert; - convert << "Sparse Coding [" << this << "]" << std::endl; - convert << " Data: " << data.n_rows << "x" ; - convert << data.n_cols << std::endl; - convert << " Atoms: " << atoms << std::endl; - convert << " Lambda 1: " << lambda1 << std::endl; - convert << " Lambda 2: " << lambda2 << std::endl; - return convert.str(); -} - } // namespace sparse_coding } // namespace mlpack diff --git a/src/mlpack/tests/CMakeLists.txt b/src/mlpack/tests/CMakeLists.txt index b4f3a374ea5..ab66e76d86a 100644 --- a/src/mlpack/tests/CMakeLists.txt +++ b/src/mlpack/tests/CMakeLists.txt @@ -63,7 +63,6 @@ add_executable(mlpack_test sparse_autoencoder_test.cpp sparse_coding_test.cpp termination_policy_test.cpp - to_string_test.cpp tree_test.cpp tree_traits_test.cpp union_find_test.cpp diff --git a/src/mlpack/tests/to_string_test.cpp b/src/mlpack/tests/to_string_test.cpp deleted file mode 100644 index ffd774d8931..00000000000 --- a/src/mlpack/tests/to_string_test.cpp +++ /dev/null @@ -1,533 +0,0 @@ -/** - * @file to_string_test.cpp - * @author Ryan Birmingham - * - * Test of the toString functionality. - **/ - -#include -#include -#include "old_boost_test_definitions.hpp" - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace mlpack; -using namespace mlpack::kernel; -using namespace mlpack::distribution; -using namespace mlpack::metric; -using namespace mlpack::nca; -using namespace mlpack::bound; -using namespace mlpack::tree; -using namespace mlpack::neighbor; - -//using namespace mlpack::optimization; - -BOOST_AUTO_TEST_SUITE(ToStringTest); - -std::ostringstream testOstream; - -BOOST_AUTO_TEST_CASE(DiscreteDistributionString) -{ - DiscreteDistribution d("0.4 0.5 0.1"); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(GaussianDistributionString) -{ - GaussianDistribution d("0.1 0.3", "1.0 0.1; 0.1 1.0"); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(CosineDistanceString) -{ - CosineDistance d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(EpanechnikovKernelString) -{ - EpanechnikovKernel d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(ExampleKernelString) -{ - ExampleKernel d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(GaussianKernelString) -{ - GaussianKernel d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(HyperbolicTangentKernelString) -{ - HyperbolicTangentKernel d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(LaplacianKernelString) -{ - LaplacianKernel d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(LinearKernelString) -{ - LinearKernel d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(PolynomialKernelString) -{ - PolynomialKernel d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(PSpectrumStringKernelString) -{ - const std::vector > s; - const size_t t = 1; - PSpectrumStringKernel d(s, t); - Log::Debug << d; - testOstream << d; - std::string sttm = d.ToString(); - BOOST_REQUIRE_NE(sttm, ""); -} - -BOOST_AUTO_TEST_CASE(SphericalKernelString) -{ - SphericalKernel d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(TriangularKernelString) -{ - TriangularKernel d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(IPMetricString) -{ - IPMetric d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(LMetricString) -{ - LMetric<1> d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(MahalanobisDistanceString) -{ - MahalanobisDistance<> d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(SGDString) -{ - const arma::mat g(2, 2); - const arma::Col v(2); - SoftmaxErrorFunction<> a(g, v); - mlpack::optimization::SGD > d(a); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(L_BFGSString) -{ - const arma::mat g(2, 2); - const arma::Col v(2); - SoftmaxErrorFunction<> a(g, v); - mlpack::optimization::L_BFGS > d(a); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(AugLagString) -{ - mlpack::optimization::AugLagrangianTestFunction a; - mlpack::optimization::AugLagrangian< - mlpack::optimization::AugLagrangianTestFunction> d(a); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(LRSDPString) -{ - arma::mat c(40, 40); - c.randn(); - const size_t b=3; - mlpack::optimization::LRSDP> d(b,b,c); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(BallBoundString) -{ - BallBound<> d(3.5, "1.0 2.0"); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(BinSpaceString) -{ - arma::mat q(2, 50); - q.randu(); - KDTree d(q); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(CoverTreeString) -{ - arma::mat q(2, 50); - q.randu(); - StandardCoverTree d(q); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(CFString) -{ - arma::mat c(3, 3); - c(0, 0) = 1; - c(1, 0) = 2; - c(2, 0) = 1.5; - c(0, 1) = 2; - c(1, 1) = 3; - c(2, 1) = 2.0; - c(0, 2) = 1; - c(1, 2) = 3; - c(2, 2) = 0.7; - mlpack::cf::CF<> d(c); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(DetString) -{ - arma::mat c(4, 4); - c.randn(); - mlpack::det::DTree d(c); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(EmstString) -{ - arma::mat c(4, 4); - c.randu(); - mlpack::emst::DualTreeBoruvka<> d(c); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(FastMKSString) -{ - arma::mat c(4, 4); - c.randn(); - mlpack::fastmks::FastMKS d(c); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(GMMString) -{ - arma::mat c(400, 40); - c.randn(); - mlpack::gmm::GMM<> d(5, 4); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(HMMString) -{ - mlpack::hmm::HMM<> d(5, 4); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(KPCAString) -{ - LinearKernel k; - mlpack::kpca::KernelPCA d(k, false); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(KMeansString) -{ - mlpack::kmeans::KMeans d(100); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(LarsString) -{ - mlpack::regression::LARS d(false); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(LinRegString) -{ - arma::mat c(40, 40); - arma::mat b(40, 1); - c.randn(); - b.randn(); - mlpack::regression::LinearRegression d(c, b); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(LCCString) -{ - arma::mat c(40,40); - const size_t b=3; - const double a=1; - c.randn(); - mlpack::lcc::LocalCoordinateCoding<> d(c, b, a); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(LogRegString) -{ - arma::mat c(40, 40); - arma::Row b(40); - c.randn(); - b.randu(); - mlpack::regression::LogisticRegression<> d(c, b); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(LSHString) -{ - arma::mat c(40, 40); - const size_t b=3; - c.randn(); - mlpack::neighbor::LSHSearch d(c, b, b); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(NeighborString) -{ - arma::mat c(40, 40); - c.randn(); - mlpack::neighbor::NeighborSearch<> d(c); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -/* -BOOST_AUTO_TEST_CASE(NMFString) -{ - arma::mat c(40, 40); - c.randn(); - mlpack::amf::AMF<> d; - Log::Debug << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} -*/ - -BOOST_AUTO_TEST_CASE(NCAString) -{ - arma::mat c(40, 40); - arma::Col b(3); - c.randn(); - mlpack::nca::NCA<> d(c, b); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(PCAString) -{ - mlpack::pca::PCA d(true); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(RadicalString) -{ - mlpack::radical::Radical d; - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(RangeSearchString) -{ - arma::mat c(40, 40); - c.randn(); - mlpack::range::RangeSearch<> d(c); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(RannString) -{ - arma::mat c(40, 40); - c.randn(); - mlpack::neighbor::RASearch<> d(c); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_CASE(SparseCodingString) -{ - arma::mat c(40, 40); - c.randn(); - const size_t b=3; - double a=0.1; - mlpack::sparse_coding::SparseCoding<> d(c,b,a); - Log::Debug << d; - testOstream << d; - std::string s = d.ToString(); - BOOST_REQUIRE_NE(s, ""); -} - -BOOST_AUTO_TEST_SUITE_END(); -