diff --git a/ApplicationCode/Application/Tools/RiaStatisticsTools.cpp b/ApplicationCode/Application/Tools/RiaStatisticsTools.cpp index 28df7c48da..5a72e901e9 100644 --- a/ApplicationCode/Application/Tools/RiaStatisticsTools.cpp +++ b/ApplicationCode/Application/Tools/RiaStatisticsTools.cpp @@ -57,7 +57,9 @@ const QString RiaStatisticsTools::replacePercentileByPValueText( const QString& //-------------------------------------------------------------------------------------------------- double RiaStatisticsTools::pearsonCorrelation( const std::vector& xValues, const std::vector& 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& 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& xValue //-------------------------------------------------------------------------------------------------- double RiaStatisticsTools::spearmanCorrelation( const std::vector& xValues, const std::vector& yValues ) { +#ifdef USE_GSL std::vector work( 2 * xValues.size() ); return gsl_stats_spearman( xValues.data(), 1, yValues.data(), 1, xValues.size(), work.data() ); +#else + return 0.0; +#endif } diff --git a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp index fa26d094ba..968b496896 100644 --- a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp +++ b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationMatrixPlot.cpp @@ -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, diff --git a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp index 9364c14a76..eb434620f1 100644 --- a/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/CorrelationPlots/RimCorrelationPlot.cpp @@ -49,7 +49,9 @@ template <> void caf::AppEnum::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", "", "", "" ); } diff --git a/CMakeLists.txt b/CMakeLists.txt index c3ea600e29..77c4972428 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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