Changeset View
Changeset View
Standalone View
Standalone View
science/kst2/files/patch-git_a9d24f9
- This file was added.
Property | Old Value | New Value |
---|---|---|
fbsd:nokeywords | null | yes \ No newline at end of property |
svn:eol-style | null | native \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
Backport of: | |||||
https://github.com/Kst-plot/kst/commit/a9d24f91057441bbd2e3ed9e7536b071121526cb | |||||
From a9d24f91057441bbd2e3ed9e7536b071121526cb Mon Sep 17 00:00:00 2001 | |||||
From: "D. V. Wiebe" <dvw@ketiltrout.net> | |||||
Date: Thu, 10 Mar 2016 14:09:26 -0800 | |||||
Subject: [PATCH] GSL-2.x support. | |||||
--- src/plugins/fits/non_linear.h.orig 2014-02-13 09:41:44 UTC | |||||
+++ src/plugins/fits/non_linear.h | |||||
@@ -18,6 +18,7 @@ | |||||
#include <gsl/gsl_blas.h> | |||||
#include <gsl/gsl_multifit_nlin.h> | |||||
#include <gsl/gsl_statistics.h> | |||||
+#include <gsl/gsl_version.h> | |||||
#include "common.h" | |||||
struct data { | |||||
@@ -100,6 +101,7 @@ bool kstfit_nonlinear( | |||||
gsl_multifit_function_fdf function; | |||||
gsl_vector_view vectorViewInitial; | |||||
gsl_matrix* pMatrixCovariance; | |||||
+ gsl_matrix* pMatrixJacobian; | |||||
struct data d; | |||||
double dXInitial[NUM_PARAMS]; | |||||
double* pInputX; | |||||
@@ -177,7 +179,16 @@ bool kstfit_nonlinear( | |||||
} | |||||
iIterations++; | |||||
} while( iStatus == GSL_CONTINUE && iIterations < MAX_NUM_ITERATIONS ); | |||||
- gsl_multifit_covar( pSolver->J, 0.0, pMatrixCovariance ); | |||||
+#if GSL_MAJOR_VERSION >= 2 | |||||
+ pMatrixJacobian = gsl_matrix_alloc( iLength, NUM_PARAMS ); | |||||
+#else | |||||
+ pMatrixJacobian = pSolver->J; | |||||
+#endif | |||||
+ if ( pMatrixJacobian != NULL ) { | |||||
+#if GSL_MAJOR_VERSION >= 2 | |||||
+ gsl_multifit_fdfsolver_jac( pSolver, pMatrixJacobian ); | |||||
+#endif | |||||
+ gsl_multifit_covar( pMatrixJacobian, 0.0, pMatrixCovariance ); | |||||
// | |||||
// determine the fitted values... | |||||
@@ -207,7 +218,10 @@ bool kstfit_nonlinear( | |||||
scalarOutChi->setValue(gsl_blas_dnrm2( pSolver->f )); | |||||
bReturn = true; | |||||
- | |||||
+#if GSL_MAJOR_VERSION >= 2 | |||||
+ gsl_matrix_free( pMatrixJacobian ); | |||||
+#endif | |||||
+ } | |||||
gsl_matrix_free( pMatrixCovariance ); | |||||
} | |||||
gsl_multifit_fdfsolver_free( pSolver ); | |||||
--- src/plugins/fits/non_linear_weighted.h.orig 2014-02-13 09:41:44 UTC | |||||
+++ src/plugins/fits/non_linear_weighted.h | |||||
@@ -18,6 +18,7 @@ | |||||
#include <gsl/gsl_blas.h> | |||||
#include <gsl/gsl_multifit_nlin.h> | |||||
#include <gsl/gsl_statistics.h> | |||||
+#include <gsl/gsl_version.h> | |||||
#include "common.h" | |||||
struct data { | |||||
@@ -101,6 +102,7 @@ bool kstfit_nonlinear_weighted( | |||||
gsl_multifit_function_fdf function; | |||||
gsl_vector_view vectorViewInitial; | |||||
gsl_matrix* pMatrixCovariance; | |||||
+ gsl_matrix *pMatrixJacobian; | |||||
struct data d; | |||||
double dXInitial[NUM_PARAMS]; | |||||
double* pInputs[3]; | |||||
@@ -192,9 +194,19 @@ bool kstfit_nonlinear_weighted( | |||||
iIterations++; | |||||
} | |||||
while( iStatus == GSL_CONTINUE && iIterations < MAX_NUM_ITERATIONS ); | |||||
+ | |||||
+#if GSL_MAJOR_VERSION >= 2 | |||||
+ pMatrixJacobian = gsl_matrix_alloc( iLength, NUM_PARAMS ); | |||||
+#else | |||||
+ pMatrixJacobian = pSolver->J; | |||||
+#endif | |||||
- gsl_multifit_covar( pSolver->J, 0.0, pMatrixCovariance ); | |||||
- | |||||
+ if ( pMatrixJacobian != NULL ) { | |||||
+#if GSL_MAJOR_VERSION >= 2 | |||||
+ gsl_multifit_fdfsolver_jac( pSolver, pMatrixJacobian ); | |||||
+#endif | |||||
+ gsl_multifit_covar( pMatrixJacobian, 0.0, pMatrixCovariance ); | |||||
+ | |||||
// | |||||
// determine the fitted values... | |||||
// | |||||
@@ -223,7 +235,10 @@ bool kstfit_nonlinear_weighted( | |||||
scalarOutChi->setValue(gsl_blas_dnrm2( pSolver->f )); | |||||
bReturn = true; | |||||
- | |||||
+#if GSL_VERSION_MAJOR >= 2 | |||||
+ gsl_matrix_free( pMatrixJacobian ); | |||||
+#endif | |||||
+ } | |||||
gsl_matrix_free( pMatrixCovariance ); | |||||
} | |||||
gsl_multifit_fdfsolver_free( pSolver ); |