Skip to content

Commit

Permalink
v1.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Jul 4, 2023
1 parent b8798e1 commit d25b268
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions agrolib/mathFunctions/gammaFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <limits.h> // required for LONG_MAX
#include "commonConstants.h"
#include "gammaFunction.h"
#include "basicMath.h"
#include "furtherMathFunctions.h"


Expand Down Expand Up @@ -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;
Expand All @@ -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)
{

Expand All @@ -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<float> series, int n, std::vector<float> &probWeightedMoments, float a, float b, bool isBeta)
Expand Down
2 changes: 1 addition & 1 deletion bin/CRITERIA1D/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d25b268

Please sign in to comment.