Commit 2d3c6598 by Liam M. Healy

Start API changes for GSL 2.0

Release 2.0 of the GSL library changed the API for many functions, and
this means that the previous versions of GSLL will not load for this
release of the library. This is a start at handling these changes, with
an initial focus on permitting GSLL to load and not yet insuring that
the changed defintions function correctly.

There are two such updates made here:
1) The elimination of multiple arguments in gsl_multifit_linear_svd, and
consequently an internal change to #'linear-mfit-svd.
2) The elimination of the argument n in gsl_sf_ellint_D_e and
consequently in #'elliptic-integral-D.

This report is helpful in identifying the GSL API changes:
http://abi-laboratory.pro/tracker/compat_report/gsl/1.16/2.0/75ebf/abi_compat_report.html
parent 80875db6
;; Definition of GSLL system
;; Liam Healy
;; Time-stamp: <2016-06-12 16:27:11EDT gsll.asd>
;; Time-stamp: <2016-08-06 10:41:51EDT gsll.asd>
;;
;; Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2015, 2016 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -41,7 +41,8 @@
((:file "init")
(cffi-grovel:grovel-file
"libgsl" :pathname #+unix "libgsl-unix" #+windows "libgsl-unix"
:depends-on ("init"))
:depends-on ("init"))
(:file "gsl-version" :depends-on ("init"))
(:file "utility" :depends-on ("init"))
(:file "forms" :depends-on ("init"))
(:file "conditions" :depends-on ("init" "libgsl"))
......
;; GSL library version
;; Liam Healy 2016-08-06 10:37:52EDT gsl-version.lisp
;; Time-stamp: <2016-08-06 10:48:20EDT gsl-version.lisp>
;;
;; Copyright 2016 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(in-package :gsl)
(cffi:defcvar ("gsl_version" *gsl-version* :read-only t) :string
"The version of the GSL library being used.")
(export '*gsl-version*)
(defun have-at-least-gsl-version (major-minor)
"The GSL version currently running is at least the specified major/minor version."
(or (null major-minor)
(let* ((sep-pos (position #\. *gsl-version*))
(my-major
(read-from-string *gsl-version* nil nil :end sep-pos))
(my-minor
(read-from-string *gsl-version* nil nil :start (1+ sep-pos))))
(and (>= my-major (first major-minor))
(>= my-minor (second major-minor))))))
;; Macros to interface GSL functions, including definitions necessary for defmfun.
;; Liam Healy
;; Time-stamp: <2010-12-19 15:58:10EST interface.lisp>
;; Time-stamp: <2016-08-06 10:40:27EDT interface.lisp>
;;
;; Copyright 2009, 2010 Liam M. Healy
;; Copyright 2009, 2010, 2016 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -127,23 +127,5 @@
'obsolete-gsl-version :name ',cl-symbol :gsl-name
,gsl-symbol :gsl-version ',gsl-version ))))
;;;;****************************************************************************
;;;; GSL library version
;;;;****************************************************************************
(cffi:defcvar ("gsl_version" *gsl-version* :read-only t) :string
"The version of the GSL library being used.")
;;; Moved definition of *gsl-version* earlier, before map-name has been defined, so leave this here.
(map-name '*gsl-version* "gsl_version")
(export '*gsl-version*)
(defun have-at-least-gsl-version (major-minor)
"The GSL version currently running is at least the specified
major/minor version."
(or (null major-minor)
(let* ((sep-pos (position #\. *gsl-version*))
(my-major
(read-from-string *gsl-version* nil nil :end sep-pos))
(my-minor
(read-from-string *gsl-version* nil nil :start (1+ sep-pos))))
(and (>= my-major (first major-minor))
(>= my-minor (second major-minor))))))
;; Linear least squares, or linear regression
;; Liam Healy <2008-01-21 12:41:46EST linear-least-squares.lisp>
;; Time-stamp: <2013-01-03 10:14:04EST linear-least-squares.lisp>
;; Time-stamp: <2016-08-06 12:26:24EDT linear-least-squares.lisp>
;;
;; Copyright 2008, 2009, 2010, 2011, 2012, 2013 Liam M. Healy
;; Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2016 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -223,6 +223,7 @@
Any components which have zero singular value (to machine
precision) are discarded from the fit.")
#-#.(gsl::have-at-least-gsl-version '(2 0)) ; GSL v1.x
(defmfun linear-mfit-svd
(model observations parameters-or-size tolerance
&optional weight
......@@ -254,22 +255,39 @@
:export nil
:index linear-mfit
:documentation ; GSL texi
"Compute the best-fit parameters c of the weighted or unweighted
model y = X c for the observations y and weights and the model
matrix X. The covariance matrix of the model parameters is
computed with the given weights. The weighted or unweighted sum of
squares of the residuals from the best-fit, chi^2, is returned as
the first value.
"Compute the best-fit parameters c of the weighted or unweighted model y = X c for the observations y and weights and the model matrix X. The covariance matrix of the model parameters is computed with the given weights. The weighted or unweighted sum of squares of the residuals from the best-fit, chi^2, is returned as the first value.
The best-fit is found by singular value decomposition of the matrix
model using the preallocated workspace provided. The modified
Golub-Reinsch SVD algorithm is used, with column scaling to improve
the accuracy of the singular values (unweighted). Any components
which have zero singular value (to machine precision) are discarded
from the fit. In the second form of the function the components
are discarded if the ratio of singular values s_i/s_0 falls below
the user-specified tolerance, and the effective rank is returned as
the second value.")
The best-fit is found by singular value decomposition of the matrix model using the preallocated workspace provided. The modified Golub-Reinsch SVD algorithm is used, with column scaling to improve the accuracy of the singular values (unweighted). Any components which have zero singular value (to machine precision) are discarded from the fit. In the second form of the function the components are discarded if the ratio of singular values s_i/s_0 falls below the user-specified tolerance, and the effective rank is returned as the second value.")
#+#.(gsl::have-at-least-gsl-version '(2 0)) ; GSL v2.x
(defmfun linear-mfit-svd
(model observations parameters-or-size tolerance
&optional weight
(covariance (default-covariance parameters-or-size))
(workspace (default-lls-workspace observations parameters-or-size))
&aux (parameters (vdf parameters-or-size)))
("gsl_multifit_linear_svd" "gsl_multifit_wlinear_svd")
((((mpointer model) :pointer)
((mpointer workspace) :pointer))
(((mpointer model) :pointer)
((mpointer weight) :pointer)
((mpointer observations) :pointer)
(tolerance :double)
(rank (:pointer :sizet))
((mpointer parameters) :pointer)
((mpointer covariance) :pointer)
(chisq (:pointer :double))
((mpointer workspace) :pointer)))
:inputs (model weight observations)
:outputs (parameters covariance)
:switch (weight)
:return ((cffi:mem-ref chisq :double) (cffi:mem-ref rank ':sizet))
:export nil
:index linear-mfit
:documentation ; GSL texi
"Compute the best-fit parameters c of the weighted or unweighted model y = X c for the observations y and weights and the model matrix X. The covariance matrix of the model parameters is computed with the given weights. The weighted or unweighted sum of squares of the residuals from the best-fit, chi^2, is returned as the first value.
The best-fit is found by singular value decomposition of the matrix model using the preallocated workspace provided. The modified Golub-Reinsch SVD algorithm is used, with column scaling to improve the accuracy of the singular values (unweighted). Any components which have zero singular value (to machine precision) are discarded from the fit. In the second form of the function the components are discarded if the ratio of singular values s_i/s_0 falls below the user-specified tolerance, and the effective rank is returned as the second value.")
(defmfun multi-linear-estimate (x coefficients covariance)
"gsl_multifit_linear_est"
......
;; Elliptic integrals
;; Liam Healy, Mon Mar 20 2006 - 21:50
;; Time-stamp: <2011-10-29 23:36:10EDT elliptic-integrals.lisp>
;; Time-stamp: <2016-08-06 11:49:54EDT elliptic-integrals.lisp>
;;
;; Copyright 2006, 2007, 2008, 2009, 2011 Liam M. Healy
;; Copyright 2006, 2007, 2008, 2009, 2011, 2016 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -65,14 +65,19 @@
parameters m = k^2 and sin^2(alpha) = k^2, with the change of sign
n to -n.")
#-#.(gsl::have-at-least-gsl-version '(2 0)) ; GSL v1.x
(defmfun elliptic-integral-D (phi k n &optional (mode :double))
"gsl_sf_ellint_D_e"
((phi :double) (k :double) (n :double) (mode sf-mode) (ret (:pointer (:struct sf-result))))
:documentation ; FDL
"The incomplete elliptic integral D(phi,k,n) which is
defined through the Carlson form RD(x,y,z)
by the following relation:
D(phi,k,n) = RD (1-sin^2(phi), 1-k^2 sin^2(phi), 1).")
:documentation ; GSL texi
"The incomplete elliptic integral D(phi,k,n) which is defined through the Carlson form RD(x,y,z) by the relation D(phi,k,n) = RD (1-sin^2(phi), 1-k^2 sin^2(phi), 1).")
#+#.(gsl::have-at-least-gsl-version '(2 0)) ; GSL v2.x
(defmfun elliptic-integral-D (phi k &optional (mode :double))
"gsl_sf_ellint_D_e"
((phi :double) (k :double) (mode sf-mode) (ret (:pointer (:struct sf-result))))
:documentation ; GSL texi
"The incomplete elliptic integral D(phi,k) which is defined through the Carlson form RD(x,y,z) by the relation D(phi,k) = 1/3 (\sin \phi)^3 RD (1-\sin^2(\phi), 1-k^2 \sin^2(\phi), 1).")
;;;;****************************************************************************
;;;; Carlson forms
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment