summaryrefslogtreecommitdiff
blob: 5d9fb102b73cfc78b6d5f1a475df2ee2bfa58d1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
commit ee9964210c56e7c1868618a4434c5340fef38fe4
Author: Pere Mato <pere.mato@cern.ch>
Date:   Tue Dec 15 11:58:24 2015 +0100

    Fix for ROOT-7776 - Integrate GSL 2.0 in ROOT. Changed the version used when option builtin_gsl=ON to 2.1 (latest production).

diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake
index 6f04dad..309a8de 100644
--- a/cmake/modules/SearchInstalledSoftware.cmake
+++ b/cmake/modules/SearchInstalledSoftware.cmake
@@ -332,7 +332,7 @@ if(mathmore OR builtin_gsl)
       endif()
     endif()
   else()
-    set(gsl_version 1.15)
+    set(gsl_version 2.1)
     message(STATUS "Downloading and building GSL version ${gsl_version}")
     ExternalProject_Add(
       GSL
diff --git a/math/mathmore/src/GSLMultiFit.h b/math/mathmore/src/GSLMultiFit.h
index 1d86da5..5b5a887 100644
--- a/math/mathmore/src/GSLMultiFit.h
+++ b/math/mathmore/src/GSLMultiFit.h
@@ -31,6 +31,7 @@
 #include "gsl/gsl_matrix.h"
 #include "gsl/gsl_multifit_nlin.h"
 #include "gsl/gsl_blas.h"
+#include "gsl/gsl_version.h"
 #include "GSLMultiFitFunctionWrapper.h"
 
 #include "Math/IFunction.h"
@@ -143,7 +144,11 @@ public:
    /// gradient value at the minimum
    const double * Gradient() const {
       if (fSolver == 0) return 0;
+#if GSL_MAJOR_VERSION  > 1
+      fType->gradient(fSolver->state, fVec);
+#else
       gsl_multifit_gradient(fSolver->J, fSolver->f,fVec);
+#endif
       return fVec->data;
    }
 
@@ -154,7 +159,14 @@ public:
       unsigned int npar = fSolver->fdf->p;
       fCov = gsl_matrix_alloc( npar, npar );
       static double kEpsrel = 0.0001;
+#if GSL_MAJOR_VERSION > 1
+      gsl_matrix* J = gsl_matrix_alloc(npar,npar);
+      gsl_multifit_fdfsolver_jac (fSolver, J);
+      int ret = gsl_multifit_covar(J, kEpsrel, fCov);
+      gsl_matrix_free(J);
+#else
       int ret = gsl_multifit_covar(fSolver->J, kEpsrel, fCov);
+#endif
       if (ret != GSL_SUCCESS) return 0;
       return fCov->data;
    }