Эх сурвалжийг харах

fixed ambiguous math function call (type cast)

unknown 12 жил өмнө
parent
commit
b793466f59

+ 1 - 1
classifier/fpclassifier/randomforest/FPCRandomForestTransfer.cpp

@@ -192,7 +192,7 @@ void FPCRandomForestTransfer::extendMapTree ( FeaturePool & fp,
 		continue;
 		continue;
 	}
 	}
 	
 	
-	double avgentropy = leaf->distribution.entropy() / log(leaf->distribution.size());
+	double avgentropy = leaf->distribution.entropy() / log( (double)leaf->distribution.size());
 	if ( examplesTransferLeafs.find(leaf) == examplesTransferLeafs.end() )
 	if ( examplesTransferLeafs.find(leaf) == examplesTransferLeafs.end() )
 	{
 	{
 	    /*fprintf (stderr, "FPCRandomForestTransfer: leaf owned by %d (normalized entropy %f)\n", maxClass, avgentropy );
 	    /*fprintf (stderr, "FPCRandomForestTransfer: leaf owned by %d (normalized entropy %f)\n", maxClass, avgentropy );

+ 1 - 1
classifier/kernelclassifier/KCGPLaplace.cpp

@@ -45,7 +45,7 @@ KCGPLaplace::KCGPLaplace( const Config *conf, Kernel *kernel, const string & sec
 	}
 	}
 
 
 	// the only one supported by now
 	// the only one supported by now
-	likelihoodFunction = new LHCumulativeGauss( conf->gD(section, "likelihood_lengthscale", sqrt(2)) );
+	likelihoodFunction = new LHCumulativeGauss( conf->gD(section, "likelihood_lengthscale", sqrt(2.0f)) );
 
 
 	verbose = conf->gB(section, "verbose", true );
 	verbose = conf->gB(section, "verbose", true );
 
 

+ 1 - 1
classifier/kernelclassifier/KCGPLaplaceOneVsAll.cpp

@@ -40,7 +40,7 @@ KCGPLaplaceOneVsAll::KCGPLaplaceOneVsAll( const Config *conf, Kernel *kernelFunc
 
 
 
 
 	// the only one supported by now
 	// the only one supported by now
-	likelihoodFunction = new LHCumulativeGauss( conf->gD(section, "likelihood_lengthscale", sqrt(2)) );
+	likelihoodFunction = new LHCumulativeGauss( conf->gD(section, "likelihood_lengthscale", sqrt(2.0f)) );
 
 
 	useLooParameters = conf->gB( section, "use_loo_parameters", false );
 	useLooParameters = conf->gB( section, "use_loo_parameters", false );
 }
 }

+ 1 - 1
features/fpfeatures/ColorHistogramFeature.cpp

@@ -23,7 +23,7 @@ ColorHistogramFeature::ColorHistogramFeature ( const Config *conf )
 {
 {
   window_size_x = conf->gI ( "ColorHistogramFeature", "window_size_x", 21 );
   window_size_x = conf->gI ( "ColorHistogramFeature", "window_size_x", 21 );
   window_size_y = conf->gI ( "ColorHistogramFeature", "window_size_y", 21 );
   window_size_y = conf->gI ( "ColorHistogramFeature", "window_size_y", 21 );
-  scaleStep = conf->gD ( "ColorHistogramFeature", "scale_step", sqrt ( 2 ) );
+  scaleStep = conf->gD ( "ColorHistogramFeature", "scale_step", sqrt ( 2.0f ) );
   numScales = conf->gI ( "ColorHistogramFeature", "num_scales", 5 );
   numScales = conf->gI ( "ColorHistogramFeature", "num_scales", 5 );
 
 
   int numBinsH = conf->gI ( "ColorHistogramFeature", "num_bins_h", 4 );
   int numBinsH = conf->gI ( "ColorHistogramFeature", "num_bins_h", 4 );

+ 1 - 1
features/fpfeatures/EOHFeature.cpp

@@ -23,7 +23,7 @@ EOHFeature::EOHFeature ( const Config *conf )
 {
 {
   window_size_x = conf->gI ( "EOHFeature", "window_size_x", 21 );
   window_size_x = conf->gI ( "EOHFeature", "window_size_x", 21 );
   window_size_y = conf->gI ( "EOHFeature", "window_size_y", 21 );
   window_size_y = conf->gI ( "EOHFeature", "window_size_y", 21 );
-  scaleStep = conf->gD ( "EOHFeature", "scale_step", sqrt ( 2 ) );
+  scaleStep = conf->gD ( "EOHFeature", "scale_step", sqrt ( 2.0f ) );
   numScales = conf->gI ( "EOHFeature", "num_scales", 5 );
   numScales = conf->gI ( "EOHFeature", "num_scales", 5 );
   numBins = conf->gI ( "EOHFeature", "num_bins", 9 );
   numBins = conf->gI ( "EOHFeature", "num_bins", 9 );
 
 

+ 1 - 1
features/fpfeatures/HOGFeature.cpp

@@ -23,7 +23,7 @@ HOGFeature::HOGFeature ( const Config *conf )
 {
 {
   window_size_x = conf->gI ( "HOGFeature", "window_size_x", 21 );
   window_size_x = conf->gI ( "HOGFeature", "window_size_x", 21 );
   window_size_y = conf->gI ( "HOGFeature", "window_size_y", 21 );
   window_size_y = conf->gI ( "HOGFeature", "window_size_y", 21 );
-  scaleStep = conf->gD ( "HOGFeature", "scale_step", sqrt ( 2 ) );
+  scaleStep = conf->gD ( "HOGFeature", "scale_step", sqrt ( 2.0f ) );
   numScales = conf->gI ( "HOGFeature", "num_scales", 5 );
   numScales = conf->gI ( "HOGFeature", "num_scales", 5 );
   flexibleGrid = conf->gB ( "HOGFeature", "flexible_grid", false );
   flexibleGrid = conf->gB ( "HOGFeature", "flexible_grid", false );
 
 

+ 1 - 1
features/fpfeatures/HistFeature.cpp

@@ -28,7 +28,7 @@ HistFeature::HistFeature ( const Config *conf,
 {
 {
   window_size_x = conf->gI ( section, "window_size_x", 21 );
   window_size_x = conf->gI ( section, "window_size_x", 21 );
   window_size_y = conf->gI ( section, "window_size_y", 21 );
   window_size_y = conf->gI ( section, "window_size_y", 21 );
-  scaleStep = conf->gD ( section, "scale_step", sqrt ( 2 ) );
+  scaleStep = conf->gD ( section, "scale_step", sqrt ( 2.0f ) );
   numScales = conf->gI ( section, "num_scales", 5 );
   numScales = conf->gI ( section, "num_scales", 5 );
 
 
   flexibleGrid = conf->gB ( section, "flexible_grid", false );
   flexibleGrid = conf->gB ( section, "flexible_grid", false );

+ 1 - 1
features/fpfeatures/PixelPairFeature.cpp

@@ -145,7 +145,7 @@ double PixelPairFeature::val ( const Example *example ) const
     if ( type == PPTYPE_DIFF )
     if ( type == PPTYPE_DIFF )
       return v1 - v2;
       return v1 - v2;
     else if ( type == PPTYPE_ABSDIFF )
     else if ( type == PPTYPE_ABSDIFF )
-      return fabs ( v1 -v2 );
+      return fabs ( (double)(v1 -v2) );
     else if ( type == PPTYPE_SUM )
     else if ( type == PPTYPE_SUM )
       return v1 + v2;
       return v1 + v2;
     else
     else

+ 1 - 1
features/fpfeatures/SemanticFeature.cpp

@@ -24,7 +24,7 @@ SemanticFeature::SemanticFeature ( const Config *conf,
 {
 {
   window_size_x = conf->gI ( "SemanticFeature", "window_size_x", 21 );
   window_size_x = conf->gI ( "SemanticFeature", "window_size_x", 21 );
   window_size_y = conf->gI ( "SemanticFeature", "window_size_y", 21 );
   window_size_y = conf->gI ( "SemanticFeature", "window_size_y", 21 );
-  scaleStep = conf->gD ( "SemanticFeature", "scale_step", sqrt ( 2 ) );
+  scaleStep = conf->gD ( "SemanticFeature", "scale_step", sqrt ( 2.0f ) );
   numScales = conf->gI ( "SemanticFeature", "num_scales", 5 );
   numScales = conf->gI ( "SemanticFeature", "num_scales", 5 );
   end_shiftx = conf->gI ( "SemanticFeature", "end_shift_x", 40 );
   end_shiftx = conf->gI ( "SemanticFeature", "end_shift_x", 40 );
   end_shifty = conf->gI ( "SemanticFeature", "end_shift_y", 40 );
   end_shifty = conf->gI ( "SemanticFeature", "end_shift_y", 40 );

+ 1 - 1
features/gradientfeatures/Image_tools.cpp

@@ -208,7 +208,7 @@ void Image_tools::calculateGradientOrientations(const NICE::GrayImage16s & grad_
 		for (int x = 0; x < grad_x_Image.width(); x++) 
 		for (int x = 0; x < grad_x_Image.width(); x++) 
 		{
 		{
 
 
-			double angle = (atan2(grad_x_Image.getPixel(x,y),grad_y_Image.getPixel(x,y)) + M_PI)*180/M_PI;
+			double angle = (atan2( (double)grad_x_Image.getPixel(x,y),(double)grad_y_Image.getPixel(x,y)) + M_PI)*180/M_PI;
 //NOTE It would be better, if we would subtract 1/2 binsize, but Anna Bosch hasn't done it in her original paper, so we won't do it as well
 //NOTE It would be better, if we would subtract 1/2 binsize, but Anna Bosch hasn't done it in her original paper, so we won't do it as well
 // 			angle = abs (angle*180/M_PI -0.5*bin_width); //atan2 and - 1/2 bin
 // 			angle = abs (angle*180/M_PI -0.5*bin_width); //atan2 and - 1/2 bin
 
 

+ 6 - 6
features/gradientfeatures/PHOGFeature.cpp

@@ -82,8 +82,8 @@ void PHOGFeature::calculate_PHOG_Pyramide(const NICE::Image & gradient_orientati
 		if (verbose) cerr << "PHOGFeature::calculate_PHOG_Pyramide -- working on level "<< level << endl;
 		if (verbose) cerr << "PHOGFeature::calculate_PHOG_Pyramide -- working on level "<< level << endl;
 		if (like_AnnaBosch)
 		if (like_AnnaBosch)
 		{
 		{
-			int step_x = (int) floor(gradient_orientations.width() / pow(2,level) );
-			int step_y = (int) floor(gradient_orientations.height() / pow(2,level) );
+			int step_x = (int) floor(gradient_orientations.width() / pow(2.0f,level) );
+			int step_y = (int) floor(gradient_orientations.height() / pow(2.0f,level) );
 
 
 			vector<float> PHoG_level;
 			vector<float> PHoG_level;
 
 
@@ -191,18 +191,18 @@ void PHOGFeature::calculate_PHOG_Pyramide(const NICE::Image & gradient_orientati
 		}
 		}
 		else //better than anna bosch
 		else //better than anna bosch
 		{
 		{
-			int step_x = (int) ceil(gradient_orientations.width() / pow(2.0,level) );
-			int step_y = (int) ceil(gradient_orientations.height() / pow(2.0,level) );
+			int step_x = (int) ceil(gradient_orientations.width() / pow(2.0f,level) );
+			int step_y = (int) ceil(gradient_orientations.height() / pow(2.0f,level) );
 			if (verbose) cerr << "step_x: " << step_x << " step_y: " << step_y << endl;
 			if (verbose) cerr << "step_x: " << step_x << " step_y: " << step_y << endl;
 
 
 			std::vector<float> PHoG_level;
 			std::vector<float> PHoG_level;
 	
 	
 			int run_y = 0;
 			int run_y = 0;
-			for (int y_counter = 0; y_counter < pow(2,level) ; y_counter++) 
+			for (int y_counter = 0; y_counter < pow(2.0f,level) ; y_counter++) 
 			{
 			{
 				int run_x = 0;
 				int run_x = 0;
 				if (verbose) cerr << "run_y: " << run_y << endl;
 				if (verbose) cerr << "run_y: " << run_y << endl;
-				for (int x_counter = 0; x_counter < pow(2,level) ; x_counter++)
+				for (int x_counter = 0; x_counter < pow(2.0f,level) ; x_counter++)
 				{
 				{
 					if (verbose) cerr << "run_x: " << run_x << endl;
 					if (verbose) cerr << "run_x: " << run_x << endl;
 					float sum_of_hog(0.0);
 					float sum_of_hog(0.0);

+ 1 - 1
features/localfeatures/LFPatches.cpp

@@ -29,7 +29,7 @@ LFPatches::LFPatches(const Config *conf, int _numPatches) :
 	xsize = conf->gI("Patches", "xsize", 11);
 	xsize = conf->gI("Patches", "xsize", 11);
 	ysize = conf->gI("Patches", "ysize", 11);
 	ysize = conf->gI("Patches", "ysize", 11);
 	maxLevels = conf->gI("Patches", "levels", 10);
 	maxLevels = conf->gI("Patches", "levels", 10);
-	scaleSpacing = conf->gD("Patches", "scale_spacing", sqrt(sqrt(2)));
+	scaleSpacing = conf->gD("Patches", "scale_spacing", sqrt(sqrt(2.0f)));
 	detectormode = conf->gI("Patches", "detector", 0);
 	detectormode = conf->gI("Patches", "detector", 0);
 	std::string normalization_s = conf->gS("Patches", "normalization", "n01");
 	std::string normalization_s = conf->gS("Patches", "normalization", "n01");
 
 

+ 1 - 1
features/simplefeatures/CodebookPrototypes.cpp

@@ -126,7 +126,7 @@ void CodebookPrototypes::displayCodebook ( int xsize, int ysize ) const
     for ( int k = 0 ; k < (int)size() ; k++ )
     for ( int k = 0 ; k < (int)size() ; k++ )
     {
     {
 	NICE::Vector vimg = *(begin() + k);
 	NICE::Vector vimg = *(begin() + k);
-	NICE::Image img ((int)sqrt(vimg.size()), (int)sqrt(vimg.size()));
+	NICE::Image img ((int)sqrt((double)vimg.size()), (int)sqrt((double)vimg.size()));
 	int i = 0;
 	int i = 0;
 	double max = - numeric_limits<double>::max();
 	double max = - numeric_limits<double>::max();
 	double min = numeric_limits<double>::min();
 	double min = numeric_limits<double>::min();

+ 1 - 1
math/fit/FitSigmoid.cpp

@@ -152,7 +152,7 @@ void FitSigmoid::fitProbabilities ( const vector<pair<int, double> > & results,
 	out[index] = j->second;
 	out[index] = j->second;
     }
     }
     A = 0;
     A = 0;
-    B = log(prior0+1)-log(prior1+1);
+    B = log( (float)(prior0+1))-log( (float)(prior1+1) );
     double startp = (prior1+1)/(double)(prior0+prior1+2);
     double startp = (prior1+1)/(double)(prior0+prior1+2);
 
 
     fitSigmoid ( t, out, startp, A, B );
     fitSigmoid ( t, out, startp, A, B );

+ 1 - 1
math/kernels/KernelLinCombNormalized.cpp

@@ -22,7 +22,7 @@ KernelLinCombNormalized::KernelLinCombNormalized( uint num, bool _exponential )
 	: alpha ( num ), exponential(_exponential)
 	: alpha ( num ), exponential(_exponential)
 {
 {
 	for ( uint i = 0 ; i < num ; i++ )
 	for ( uint i = 0 ; i < num ; i++ )
-		alpha[i] = - log(num);
+		alpha[i] = - log((double)num);
 }
 }
 
 
 KernelLinCombNormalized::KernelLinCombNormalized ( const KernelLinCombNormalized & src )
 KernelLinCombNormalized::KernelLinCombNormalized ( const KernelLinCombNormalized & src )

+ 1 - 1
math/kernels/KernelLinearCombination.cpp

@@ -21,7 +21,7 @@ KernelLinearCombination::KernelLinearCombination( uint num, bool _exponential )
 	: alpha ( num ), exponential(_exponential)
 	: alpha ( num ), exponential(_exponential)
 {
 {
 	for ( uint i = 0 ; i < num ; i++ )
 	for ( uint i = 0 ; i < num ; i++ )
-		alpha[i] = - log(num);
+		alpha[i] = - log((double)num);
 }
 }
 
 
 KernelLinearCombination::KernelLinearCombination ( const KernelLinearCombination & src )
 KernelLinearCombination::KernelLinearCombination ( const KernelLinearCombination & src )

+ 3 - 3
math/kernels/TraceApproximation.cpp

@@ -92,7 +92,7 @@ double TraceApproximation::getApproximateTraceTerm ( const KernelData *kernelDat
 	cerr << endl;
 	cerr << endl;
 	stddev /= (numTraceSamples-1);
 	stddev /= (numTraceSamples-1);
 	stddev = sqrt(stddev);
 	stddev = sqrt(stddev);
-	double standard_error = stddev / sqrt(numTraceSamples);
+	double standard_error = stddev / sqrt((double)numTraceSamples);
 	double rel_standard_error = standard_error / fabs(trace_approx);
 	double rel_standard_error = standard_error / fabs(trace_approx);
 
 
 	cerr << "TraceApproximation: relative error " << rel_standard_error << endl;
 	cerr << "TraceApproximation: relative error " << rel_standard_error << endl;
@@ -137,7 +137,7 @@ double TraceApproximation::getApproximateTraceTermKronecker ( const KernelData *
 	cerr << endl;
 	cerr << endl;
 	stddev /= (numTraceSamples-1);
 	stddev /= (numTraceSamples-1);
 	stddev = sqrt(stddev);
 	stddev = sqrt(stddev);
-	double standard_error = stddev / sqrt(numTraceSamples);
+	double standard_error = stddev / sqrt((double)numTraceSamples);
 	double rel_standard_error = standard_error / fabs(trace_approx);
 	double rel_standard_error = standard_error / fabs(trace_approx);
 
 
 	cerr << "TraceApproximation: relative error " << rel_standard_error << endl;
 	cerr << "TraceApproximation: relative error " << rel_standard_error << endl;
@@ -176,7 +176,7 @@ double TraceApproximation::getApproxTraceTermKroneckerPre ( Matrix & samples, Ma
 	cerr << endl;
 	cerr << endl;
 	stddev /= (numTraceSamples-1);
 	stddev /= (numTraceSamples-1);
 	stddev = sqrt(stddev);
 	stddev = sqrt(stddev);
-	double standard_error = stddev / sqrt(numTraceSamples);
+	double standard_error = stddev / sqrt( (double)numTraceSamples);
 	double rel_standard_error = standard_error / fabs(trace_approx);
 	double rel_standard_error = standard_error / fabs(trace_approx);
 
 
 	cerr << "TraceApproximation: relative error " << rel_standard_error << endl;
 	cerr << "TraceApproximation: relative error " << rel_standard_error << endl;

+ 2 - 2
regression/gpregression/modelselcrit/GPMSCLooEstimates.cpp

@@ -144,7 +144,7 @@ double GPMSCLooLikelihoodClassificationOptProb::computeObjective ()
 			continue;
 			continue;
 
 
 		double inner = labels[l] * ( alpha * looMu[l] + beta ) / sqrt( 1 + alpha*alpha*looVariance[l] );
 		double inner = labels[l] * ( alpha * looMu[l] + beta ) / sqrt( 1 + alpha*alpha*looVariance[l] );
-		nloglike -= log ( (erf(inner/sqrt(2)) + 1)/2.0 ); 
+		nloglike -= log ( (erf(inner/sqrt(2.0f)) + 1)/2.0 ); 
 	}
 	}
 
 
 	if ( verbose )
 	if ( verbose )
@@ -169,7 +169,7 @@ void GPMSCLooLikelihoodClassificationOptProb::computeGradient ( NICE::Vector & n
 		double ri = ( alpha*looMu[i] + beta) / sqrtPart;
 		double ri = ( alpha*looMu[i] + beta) / sqrtPart;
 		double betaGrad2ndPart = (labels[i]/sqrtPart);
 		double betaGrad2ndPart = (labels[i]/sqrtPart);
 		double alphaGrad2ndPart = betaGrad2ndPart * ( looMu[i] - beta*alpha*looVariance[i] ) / (sqrtPart*sqrtPart);
 		double alphaGrad2ndPart = betaGrad2ndPart * ( looMu[i] - beta*alpha*looVariance[i] ) / (sqrtPart*sqrtPart);
-		double firstPart = (exp(-ri*ri/2.0)/sqrt(2*M_PI)) * ( 2.0 / (erf(labels[i] * ri / sqrt(2)) + 1) );
+		double firstPart = (exp(-ri*ri/2.0)/sqrt(2.0f*M_PI)) * ( 2.0 / (erf(labels[i] * ri / sqrt(2.0f)) + 1) );
 		newGradient[0] -= alphaGrad2ndPart * firstPart;
 		newGradient[0] -= alphaGrad2ndPart * firstPart;
 		newGradient[1] -= betaGrad2ndPart * firstPart;
 		newGradient[1] -= betaGrad2ndPart * firstPart;
 	}
 	}