#6567 Remove use of GNU GSL

This commit is contained in:
Gaute Lindkvist
2020-09-23 15:48:19 +02:00
parent 2741b24e27
commit 9afac51bca
15 changed files with 32 additions and 231 deletions

View File

@@ -25,10 +25,6 @@
#include "cafAssert.h"
#ifdef USE_GSL
#include "gsl/statistics/gsl_statistics_double.h"
#endif
#include <QString>
//--------------------------------------------------------------------------------------------------
@@ -68,32 +64,6 @@ double RiaStatisticsTools::pearsonCorrelation( const std::vector<double>& xValue
RigStatisticsMath::calculateBasicStatistics( yValues, nullptr, nullptr, nullptr, &rangeY, nullptr, nullptr );
if ( rangeX < eps || rangeY < eps ) return 0.0;
#ifdef USE_GSL
return pearsonCorrelationGSL( xValues, yValues );
#else
return pearsonCorrelationOwn( xValues, yValues );
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaStatisticsTools::pearsonCorrelationGSL( const std::vector<double>& xValues, const std::vector<double>& yValues )
{
#ifdef USE_GSL
return gsl_stats_correlation( xValues.data(), 1, yValues.data(), 1, xValues.size() );
#else
CAF_ASSERT( false );
return std::numeric_limits<double>::infinity();
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaStatisticsTools::pearsonCorrelationOwn( const std::vector<double>& xValues, const std::vector<double>& yValues )
{
const double eps = 1.0e-8;
if ( xValues.size() != yValues.size() ) return 0.0;
if ( xValues.empty() ) return 0.0;
@@ -124,22 +94,3 @@ double RiaStatisticsTools::pearsonCorrelationOwn( const std::vector<double>& xVa
return sumNumerator / ( std::sqrt( sumxDiffSquared ) * std::sqrt( sumyDiffSquared ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaStatisticsTools::spearmanCorrelation( const std::vector<double>& xValues, const std::vector<double>& yValues )
{
const double eps = 1.0e-8;
double rangeX = 0.0, rangeY = 0.0;
RigStatisticsMath::calculateBasicStatistics( xValues, nullptr, nullptr, nullptr, &rangeX, nullptr, nullptr );
RigStatisticsMath::calculateBasicStatistics( yValues, nullptr, nullptr, nullptr, &rangeY, nullptr, nullptr );
if ( rangeX < eps || rangeY < eps ) return 0.0;
#ifdef USE_GSL
std::vector<double> work( 2 * xValues.size() );
return gsl_stats_spearman( xValues.data(), 1, yValues.data(), 1, xValues.size(), work.data() );
#else
return 0.0;
#endif
}

View File

@@ -52,7 +52,4 @@ public:
}
static double pearsonCorrelation( const std::vector<double>& xValues, const std::vector<double>& yValues );
static double pearsonCorrelationGSL( const std::vector<double>& xValues, const std::vector<double>& yValues );
static double pearsonCorrelationOwn( const std::vector<double>& xValues, const std::vector<double>& yValues );
static double spearmanCorrelation( const std::vector<double>& xValues, const std::vector<double>& yValues );
};