From d412396267bc6c52079e5b5b397caa8aa4a7cf99 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Thu, 15 Dec 2011 07:44:03 +0000 Subject: [PATCH] Remove unnecessary 'normalizer' variable and add accessor for gamma. No mutator because those two variables are codependent. --- src/mlpack/core/kernels/gaussian_kernel.hpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/mlpack/core/kernels/gaussian_kernel.hpp b/src/mlpack/core/kernels/gaussian_kernel.hpp index 152c45b61b..721f8c4b6c 100644 --- a/src/mlpack/core/kernels/gaussian_kernel.hpp +++ b/src/mlpack/core/kernels/gaussian_kernel.hpp @@ -30,7 +30,8 @@ class GaussianKernel /** * Default constructor; sets bandwidth to 1.0. */ - GaussianKernel() : bandwidth(1.0), normalizer(sqrt(2.0 * M_PI)), gamma(-0.5) { } + GaussianKernel() : bandwidth(1.0), gamma(-0.5) + { } /** * Construct the Gaussian kernel with a custom bandwidth. @@ -39,7 +40,6 @@ class GaussianKernel */ GaussianKernel(double bandwidth) : bandwidth(bandwidth), - normalizer(bandwidth * sqrt(2.0 * M_PI)), gamma(-0.5 * pow(bandwidth, -2.0)) { } @@ -74,16 +74,15 @@ class GaussianKernel return exp(gamma * t * t); } - const double& Normalizer() { return normalizer; } - const double& Bandwidth() { return bandwidth; } + //! Get the bandwidth. + const double& Bandwidth() const { return bandwidth; } + //! Get the precalculated constant. + const double& Gamma() const { return gamma; } private: //! Kernel bandwidth. double bandwidth; - //! Normalizing constant. - double normalizer; - //! Precalculated constant depending on the bandwidth; //! @f$ \gamma = -\frac{1}{2 \mu^2} @f$. double gamma;