[mlpack-svn] r13386 - mlpack/trunk/src/mlpack/methods/det

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Aug 10 16:13:58 EDT 2012


Author: rcurtin
Date: 2012-08-10 16:13:58 -0400 (Fri, 10 Aug 2012)
New Revision: 13386

Modified:
   mlpack/trunk/src/mlpack/methods/det/dtree.cpp
Log:
Be explicit and call std::log(double) because in some compilers (icc)
std::log(size_t) doesn't exist. #239


Modified: mlpack/trunk/src/mlpack/methods/det/dtree.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/det/dtree.cpp	2012-08-10 20:10:36 UTC (rev 13385)
+++ mlpack/trunk/src/mlpack/methods/det/dtree.cpp	2012-08-10 20:13:58 UTC (rev 13386)
@@ -215,8 +215,8 @@
       }
     }
 
-    double actualMinDimError = std::log(minDimError) - 2 * std::log(data.n_cols)
-        - volumeWithoutDim;
+    double actualMinDimError = std::log(minDimError)
+        - 2 * std::log((double) data.n_cols) - volumeWithoutDim;
 
     if ((actualMinDimError > minError) && dimSplitFound)
     {
@@ -225,10 +225,10 @@
       minError = actualMinDimError;
       splitDim = dim;
       splitValue = dimSplitValue;
-      leftError = std::log(dimLeftError) - 2 * std::log(data.n_cols) -
-          volumeWithoutDim;
-      rightError = std::log(dimRightError) - 2 * std::log(data.n_cols) -
-          volumeWithoutDim;
+      leftError = std::log(dimLeftError) - 2 * std::log((double) data.n_cols)
+          - volumeWithoutDim;
+      rightError = std::log(dimRightError) - 2 * std::log((double) data.n_cols)
+          - volumeWithoutDim;
       splitFound = true;
     } // end if better split found in this dimension.
   }
@@ -379,7 +379,7 @@
 
     if (left->SubtreeLeaves() > 1)
     {
-      const double exponent = 2 * std::log(data.n_cols) + logVolume +
+      const double exponent = 2 * std::log((double) data.n_cols) + logVolume +
           left->AlphaUpper();
 
       // Whether or not this will overflow is highly dependent on the depth of
@@ -389,13 +389,14 @@
 
     if (right->SubtreeLeaves() > 1)
     {
-      const double exponent = 2 * std::log(data.n_cols) + logVolume +
+      const double exponent = 2 * std::log((double) data.n_cols) + logVolume +
           right->AlphaUpper();
 
       tmpAlphaSum += std::exp(exponent);
     }
 
-    alphaUpper = std::log(tmpAlphaSum) - 2 * std::log(data.n_cols) - logVolume;
+    alphaUpper = std::log(tmpAlphaSum) - 2 * std::log((double) data.n_cols)
+        - logVolume;
 
     double gT;
     if (useVolReg)
@@ -405,7 +406,7 @@
     }
     else
     {
-      gT = alphaUpper - std::log(subtreeLeaves - 1);
+      gT = alphaUpper - std::log((double) (subtreeLeaves - 1));
     }
 
     return std::min(gT, std::min(leftG, rightG));
@@ -434,7 +435,7 @@
     if (useVolReg)
       gT = alphaUpper;// - std::log(subtreeLeavesVTInv - vTInv);
     else
-      gT = alphaUpper - std::log(subtreeLeaves - 1);
+      gT = alphaUpper - std::log((double) (subtreeLeaves - 1));
 
     if (gT > oldAlpha)
     {
@@ -474,7 +475,7 @@
 
       if (left->SubtreeLeaves() > 1)
       {
-        const double exponent = 2 * std::log(points) + logVolume +
+        const double exponent = 2 * std::log((double) points) + logVolume +
             left->AlphaUpper();
 
         // Whether or not this will overflow is highly dependent on the depth of
@@ -484,13 +485,14 @@
 
       if (right->SubtreeLeaves() > 1)
       {
-        const double exponent = 2 * std::log(points) + logVolume +
+        const double exponent = 2 * std::log((double) points) + logVolume +
             right->AlphaUpper();
 
         tmpAlphaSum += std::exp(exponent);
       }
 
-      alphaUpper = std::log(tmpAlphaSum) - 2 * std::log(points) - logVolume;
+      alphaUpper = std::log(tmpAlphaSum) - 2 * std::log((double) points) -
+          logVolume;
 
       // Update gT value.
       if (useVolReg)
@@ -500,7 +502,7 @@
       }
       else
       {
-        gT = alphaUpper - std::log(subtreeLeaves - 1);
+        gT = alphaUpper - std::log((double) (subtreeLeaves - 1));
       }
 
       Log::Assert(gT < std::numeric_limits<double>::max());




More information about the mlpack-svn mailing list