[mlpack-git] master: BUG: Misplaced parenthesis in comparison of absolute values (b7a01eb)
gitdub at mlpack.org
gitdub at mlpack.org
Thu Apr 21 17:30:16 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/d2e353468b8fce9fc1ee46799860f3860c4c8db9...ebf77f8b13323a87c433b6f639deb2369188b00c
>---------------------------------------------------------------
commit b7a01eb8acce2c35c5822c97729cc7cb471ed8f9
Author: Alexander Leinoff <alexander-leinoff at uiowa.edu>
Date: Thu Apr 21 16:30:16 2016 -0500
BUG: Misplaced parenthesis in comparison of absolute values
The misplaced parenthesis around the comparison of the absolute
values of bandwidth and distance could cause erronus results. In
addition, this caused a "-Wabsolute-value" warning:
src/mlpack/core/kernels/epanechnikov_kernel.cpp:41:14:
warning: taking the absolute value of unsigned type 'bool' has no effect [-Wabsolute-value]
} else if (std::abs(bandwidth > std::abs(distance)))
>---------------------------------------------------------------
b7a01eb8acce2c35c5822c97729cc7cb471ed8f9
src/mlpack/core/kernels/epanechnikov_kernel.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mlpack/core/kernels/epanechnikov_kernel.cpp b/src/mlpack/core/kernels/epanechnikov_kernel.cpp
index a8ccb20..9f9bc96 100644
--- a/src/mlpack/core/kernels/epanechnikov_kernel.cpp
+++ b/src/mlpack/core/kernels/epanechnikov_kernel.cpp
@@ -38,7 +38,7 @@ double EpanechnikovKernel::Evaluate(const double distance) const
double EpanechnikovKernel::Gradient(const double distance) const {
if (std::abs(bandwidth) < std::abs(distance)) {
return 0;
- } else if (std::abs(bandwidth > std::abs(distance))) {
+ } else if (std::abs(bandwidth) > std::abs(distance)) {
return -2 * inverseBandwidthSquared * distance;
} else {
// The gradient doesn't exist.
More information about the mlpack-git
mailing list