From b1035bdfb8d6075c1212b6cc30fd29d2e87cbaeb Mon Sep 17 00:00:00 2001 From: Julien Malik <julien.malik@c-s.fr> Date: Sat, 7 May 2011 22:25:13 +0200 Subject: [PATCH] ENH: use already implemented boost gamma function --- Code/Markov/otbMRFEnergyFisherClassification.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Code/Markov/otbMRFEnergyFisherClassification.h b/Code/Markov/otbMRFEnergyFisherClassification.h index 8f702e63f1..0b0a6f0cb2 100644 --- a/Code/Markov/otbMRFEnergyFisherClassification.h +++ b/Code/Markov/otbMRFEnergyFisherClassification.h @@ -23,6 +23,7 @@ #include "otbMRFEnergy.h" #include "otbMath.h" #include "otbGamma.h" +#include <boost/math/special_functions/gamma.hpp> namespace otb { @@ -75,11 +76,12 @@ public: double l = this->m_Parameters[3*static_cast<double>(value2)+1]; double m = this->m_Parameters[3*static_cast<double>(value2)+2]; - double result = -vcl_log((g.gamma(l+m)/(g.gamma(l)*g.gamma(m))) * (2/(mu)) * (vcl_sqrt(l/m)) * - ((pow((vcl_sqrt(l/m)*(val1/mu)), ((2*l)-1))) / - (pow(1+(vcl_sqrt(l/m)*(val1/mu)*vcl_sqrt(l/m)*(val1/mu)), (l+m))))); + double result = -vcl_log((boost::math::tgamma(l+m)/(boost::math::tgamma(l)*boost::math::tgamma(m))) + * (2/(mu)) * (vcl_sqrt(l/m)) * + ((vcl_pow((vcl_sqrt(l/m)*(val1/mu)), ((2*l)-1))) / + (vcl_pow(1+(vcl_sqrt(l/m)*(val1/mu)*vcl_sqrt(l/m)*(val1/mu)), (l+m))))); - return static_cast<double>( result ); + return result; } protected: -- GitLab