mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Make GNU GSL optional
This commit is contained in:
parent
78015fa19d
commit
87b631a23e
@ -57,7 +57,9 @@ const QString RiaStatisticsTools::replacePercentileByPValueText( const QString&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RiaStatisticsTools::pearsonCorrelation( const std::vector<double>& xValues, const std::vector<double>& yValues )
|
||||
{
|
||||
#ifdef OWN_IMPLEMENTATION
|
||||
#ifdef USE_GSL
|
||||
return gsl_stats_correlation( xValues.data(), 1, yValues.data(), 1, xValues.size() );
|
||||
#else
|
||||
const double eps = 1.0e-8;
|
||||
if ( xValues.size() != yValues.size() ) return 0.0;
|
||||
if ( xValues.empty() ) return 0.0;
|
||||
@ -88,8 +90,6 @@ double RiaStatisticsTools::pearsonCorrelation( const std::vector<double>& xValue
|
||||
if ( sumxDiffSquared < eps || sumyDiffSquared < eps ) return 0.0;
|
||||
|
||||
return sumNumerator / ( std::sqrt( sumxDiffSquared ) * std::sqrt( sumyDiffSquared ) );
|
||||
#else
|
||||
return gsl_stats_correlation( xValues.data(), 1, yValues.data(), 1, xValues.size() );
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -98,6 +98,10 @@ double RiaStatisticsTools::pearsonCorrelation( const std::vector<double>& xValue
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RiaStatisticsTools::spearmanCorrelation( const std::vector<double>& xValues, const std::vector<double>& yValues )
|
||||
{
|
||||
#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
|
||||
}
|
||||
|
@ -243,13 +243,13 @@ void RimCorrelationMatrixPlot::updateAxes()
|
||||
{
|
||||
if ( !m_plotWidget ) return;
|
||||
|
||||
m_plotWidget->setAxisScaleDraw( QwtPlot::yLeft, new TextScaleDraw( m_resultLabels ) );
|
||||
m_plotWidget->setAxisScaleEngine( QwtPlot::yLeft, new RiuQwtLinearScaleEngine );
|
||||
m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Result Vector" );
|
||||
m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true );
|
||||
m_plotWidget->setAxisFontsAndAlignment( QwtPlot::yLeft, 11, 7, false, Qt::AlignCenter );
|
||||
m_plotWidget->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft, true, false );
|
||||
m_plotWidget->setAxisRange( QwtPlot::yLeft, 0.0, (double)m_resultLabels.size() + 1 );
|
||||
m_plotWidget->setAxisScaleDraw( QwtPlot::yLeft, new TextScaleDraw( m_resultLabels ) );
|
||||
m_plotWidget->setMajorAndMinorTickIntervalsAndRange( QwtPlot::yLeft,
|
||||
1.0,
|
||||
0.0,
|
||||
|
@ -49,7 +49,9 @@ template <>
|
||||
void caf::AppEnum<RimCorrelationPlot::CorrelationFactor>::setUp()
|
||||
{
|
||||
addItem( RimCorrelationPlot::CorrelationFactor::PEARSON, "PEARSON", "Pearson Correlation Coefficient" );
|
||||
#ifdef USE_GSL
|
||||
addItem( RimCorrelationPlot::CorrelationFactor::SPEARMAN, "SPEARMAN", "Spearman's Rank Correlation Coefficient" );
|
||||
#endif
|
||||
setDefault( RimCorrelationPlot::CorrelationFactor::PEARSON );
|
||||
}
|
||||
} // namespace caf
|
||||
@ -66,7 +68,7 @@ RimCorrelationPlot::RimCorrelationPlot()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_correlationFactor, "CorrelationFactor", "Correlation Factor", "", "", "" );
|
||||
m_correlationFactor.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
||||
CAF_PDM_InitField( &m_showAbsoluteValues, "CorrelationAbsValues", true, "Show Absolute Values", "", "", "" );
|
||||
CAF_PDM_InitField( &m_showAbsoluteValues, "CorrelationAbsValues", false, "Show Absolute Values", "", "", "" );
|
||||
CAF_PDM_InitField( &m_sortByAbsoluteValues, "CorrelationAbsSorting", true, "Sort by Absolute Values", "", "", "" );
|
||||
}
|
||||
|
||||
|
@ -327,15 +327,17 @@ list(APPEND THIRD_PARTY_LIBRARIES
|
||||
# GNU GSL
|
||||
################################################################################
|
||||
|
||||
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/ThirdParty/gsl/CMakeLists.txt")
|
||||
message(FATAL_ERROR "The GSL submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
||||
option(GSL_ENABLE "Enable the GNU Scientific Library for Statistics" ON)
|
||||
if(GSL_ENABLE)
|
||||
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/ThirdParty/gsl/CMakeLists.txt")
|
||||
message(FATAL_ERROR "The GSL submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
||||
endif()
|
||||
option(GSL_DISABLE_TESTS "Disable the GSL tests" ON)
|
||||
add_subdirectory(ThirdParty/gsl)
|
||||
add_definitions(-DUSE_GSL)
|
||||
list(APPEND THIRD_PARTY_LIBRARIES gsl)
|
||||
endif()
|
||||
|
||||
add_subdirectory(ThirdParty/gsl)
|
||||
|
||||
list(APPEND THIRD_PARTY_LIBRARIES
|
||||
gsl
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Thirdparty libraries are put in ThirdParty solution folder
|
||||
|
Loading…
Reference in New Issue
Block a user