diff --git a/agrolib/mathFunctions/gammaFunction.cpp b/agrolib/mathFunctions/gammaFunction.cpp index 031a1cf7..243fece0 100644 --- a/agrolib/mathFunctions/gammaFunction.cpp +++ b/agrolib/mathFunctions/gammaFunction.cpp @@ -3,6 +3,7 @@ #include // required for LONG_MAX #include "commonConstants.h" #include "gammaFunction.h" +#include "basicMath.h" #include "furtherMathFunctions.h" @@ -569,14 +570,14 @@ float generalizedGammaCDF(float x, double beta, double alpha, double pZero) { - - float gammaCDF = NODATA; - - if (fabs(x - NODATA) < EPSILON || fabs(beta - NODATA)< EPSILON || fabs(alpha - NODATA) < EPSILON || fabs(pZero - NODATA) < EPSILON || beta == 0) + if ( isEqual(x, NODATA) || isEqual(beta, NODATA) || isEqual(alpha, NODATA) + || isEqual(pZero, NODATA) || isEqual(beta, 0) ) { - return gammaCDF; + return NODATA; } + double gammaCDF; + if (x <= 0) { gammaCDF = pZero; @@ -585,10 +586,11 @@ { gammaCDF = pZero + (1 - pZero) * incompleteGamma(alpha, double(x) / beta); } - return gammaCDF; + return float(gammaCDF); } + double generalizedGammaCDF(double x, double beta, double alpha, double pZero) { @@ -613,12 +615,12 @@ float probabilityGamma(float x, double alfa, double gamma, float gammaFunc) { - return ( exp(-alfa * x) *( pow(x,(gamma - 1)) * pow(alfa,gamma) / gammaFunc) ); + return float(exp(-alfa * x) *( pow(x,(gamma - 1)) * pow(alfa,gamma) / gammaFunc)); } float probabilityGamma(float x, double alpha, double beta) { - return exp(-x/beta) * pow(x,(alpha - 1)) / pow(beta,alpha) / gammaFunction(alpha); + return float(exp(-x/beta) * pow(x,(alpha - 1)) / pow(beta,alpha) / gammaFunction(alpha)); } void probabilityWeightedMoments(std::vector series, int n, std::vector &probWeightedMoments, float a, float b, bool isBeta) diff --git a/bin/CRITERIA1D/main.cpp b/bin/CRITERIA1D/main.cpp index b1304bf9..08252432 100644 --- a/bin/CRITERIA1D/main.cpp +++ b/bin/CRITERIA1D/main.cpp @@ -32,7 +32,7 @@ void usage() int main(int argc, char *argv[]) { QCoreApplication myApp(argc, argv); - std::cout << "CRITERIA-1D agro-hydrological model v1.7.1\n" << std::endl; + std::cout << "CRITERIA-1D agro-hydrological model v1.7.2\n" << std::endl; Crit1DProject myProject;