浏览代码

Fixed issues with pedantic compiler (ambigous names because of using directives, non-integral type in static initializer)

Clemens-Alexander Brust 11 年之前
父节点
当前提交
8b1b237a75

+ 7 - 7
classifier/kernelclassifier/LaplaceApproximation.cpp

@@ -6,12 +6,12 @@
 
 */
 #include <iostream>
+#include <cmath>
 
 #include "core/vector/Algorithms.h"
 #include "LaplaceApproximation.h"
 #include "LHCumulativeGauss.h"
 
-using namespace std;
 using namespace NICE;
 using namespace OBJREC;
 
@@ -24,7 +24,7 @@ LaplaceApproximation::LaplaceApproximation()
 	verbose = false;
 }
 
-LaplaceApproximation::LaplaceApproximation( const Config *conf, const string & section )
+LaplaceApproximation::LaplaceApproximation( const Config *conf, const std::string & section )
 {
 	maxiterations = conf->gI(section, "laplace_max_iterations", 40 );
 	minimumDelta = conf->gD(section, "laplace_minimum_delta", 1e-14 );
@@ -110,7 +110,7 @@ void LaplaceApproximation::approximate ( KernelData *kernelData, const Vector &
 
 		// gradient of the objective function is gradientL - a
 		if ( verbose )
-			cerr << "findModeLaplace: gradient norm = " << (gradientL - a).normL2() << endl;
+			std::cerr << "findModeLaplace: gradient norm = " << (gradientL - a).normL2() << std::endl;
 
 		mode = kernelMatrix * a;
 	
@@ -126,8 +126,8 @@ void LaplaceApproximation::approximate ( KernelData *kernelData, const Vector &
 		{
 			if ( verbose ) 
 			{
-				cerr << "findModeLaplace: log likelihood is positive infinity...we cannot optimize any more in this case." << endl;
-				cerr << "findModeLaplace: mode = " << mode << endl;
+				std::cerr << "findModeLaplace: log likelihood is positive infinity...we cannot optimize any more in this case." << std::endl;
+				std::cerr << "findModeLaplace: mode = " << mode << std::endl;
 			}
 			break;
 		}
@@ -145,11 +145,11 @@ void LaplaceApproximation::approximate ( KernelData *kernelData, const Vector &
 		objective += loglikelihood;
 
 		if ( verbose ) 
-			cerr << "findModeLaplace: objective = " << objective << endl;
+			std::cerr << "findModeLaplace: objective = " << objective << std::endl;
 
 		double delta = fabs(oldobjective-objective)/(fabs(objective)+1);
 		if ( verbose )
-			cerr << "findModeLaplace: delta = " << delta << endl;
+			std::cerr << "findModeLaplace: delta = " << delta << std::endl;
 		if ( delta < minimumDelta ) {
 			break;
 		}

+ 5 - 0
math/pdf/PDFGaussian.h

@@ -31,8 +31,13 @@ class PDFGaussian : public PDF
 	/** empty constructor */
 	PDFGaussian ( int dimension );
 
+#if __cplusplus >= 201103L
+	static constexpr double logdetEPS = 0.0;
+	static constexpr double regEPS = 1e-7;
+#else
 	static const double logdetEPS = 0.0;
 	static const double regEPS = 1e-7;
+#endif
 	static NICE::Matrix RobustInverse ( const NICE::Matrix & M, double & logdet );
 
     public:

+ 6 - 7
regression/npregression/RegKNN.cpp

@@ -18,7 +18,6 @@
 
 using namespace OBJREC;
 
-using namespace std;
 using namespace NICE;
 
 
@@ -67,7 +66,7 @@ void RegKNN::teach ( const NICE::Vector & x, const double & y )
     if ( isnan(x[i]) ) 
     {
         fprintf (stderr, "There is a NAN value within this vector: x[%d] = %f\n", (int)i, x[i]);
-        cerr << x << endl;
+        std::cerr << x << std::endl;
         exit(-1);
     }
 
@@ -96,8 +95,8 @@ double RegKNN::predict ( const NICE::Vector & x )
     if ( isnan(distance) )
     {
       fprintf (stderr, "RegKNN::predict: NAN value found !!\n");
-      cerr << x << endl;
-      cerr << dataSet[i] << endl;
+      std::cerr << x << std::endl;
+      std::cerr << dataSet[i] << std::endl;
     }
 // #pragma omp critical      
     distances[i] = distance;     
@@ -110,13 +109,13 @@ double RegKNN::predict ( const NICE::Vector & x )
     
   if ( dataSet.size() < K )
   {
-    cerr << K << endl;
+    std::cerr << K << std::endl;
     K = dataSet.size();
-    cerr<<"RegKNN: Not enough datapoints! Setting K to: "<< K <<endl;
+    std::cerr<<"RegKNN: Not enough datapoints! Setting K to: "<< K << std::endl;
   }
 
   if ( distances[ind[0]] == 0.0 ) {
-    cerr<<"RegKNN: Warning: datapoint was already seen during training... using its label as prediction."<<endl;
+    std::cerr<<"RegKNN: Warning: datapoint was already seen during training... using its label as prediction."<< std::endl;
     return labelSet[ind[0]];  
   }
 

+ 1 - 2
regression/splineregression/CRSplineReg.cpp

@@ -18,7 +18,6 @@
 
 using namespace OBJREC;
 
-using namespace std;
 using namespace NICE;
 
 CRSplineReg::CRSplineReg (  const NICE::Config *_conf )
@@ -69,7 +68,7 @@ void CRSplineReg::teach ( const NICE::Vector & x, const double & y )
       if ( isnan(x[i]) ) 
       {
           fprintf (stderr, "There is a NAN value in within this vector: x[%d] = %f\n", (int)i, x[i]);
-          cerr << x << endl;
+          std::cerr << x << std::endl;
           exit(-1);
       }