diff --git a/data/both.lisp b/data/both.lisp index 05361313524cf72ccb2cd19937b55a25c595cff9..2881e76e792bf924b911705c23d04a16740ce9b1 100644 --- a/data/both.lisp +++ b/data/both.lisp @@ -1,6 +1,6 @@ ;; Functions for both vectors and matrices. ;; Liam Healy 2008-04-26 20:48:44EDT both.lisp -;; Time-stamp: <2009-02-11 22:17:09EST both.lisp> +;; Time-stamp: <2009-02-16 18:59:47EST both.lisp> ;; $Id$ (in-package :gsl) @@ -320,3 +320,33 @@ :c-return :boolean :documentation ; FDL "All elements of a are zero.") + +(defmfun mplusp ((a both)) + ("gsl_" :category :type "_ispos") + (((mpointer a) :pointer)) + :definition :generic + :gsl-version (1 9) + :inputs (a) + :c-return :boolean + :documentation ; FDL + "All elements of a are positive.") + +(defmfun mminusp ((a both)) + ("gsl_" :category :type "_isneg") + (((mpointer a) :pointer)) + :definition :generic + :gsl-version (1 9) + :inputs (a) + :c-return :boolean + :documentation ; FDL + "All elements of a are negative.") + +(defmfun non-negative-p ((a both)) + ("gsl_" :category :type "_isnonneg") + (((mpointer a) :pointer)) + :definition :generic + :gsl-version (1 10) + :inputs (a) + :c-return :boolean + :documentation ; FDL + "All elements of a are non-negative.") diff --git a/documentation/missing-features.text b/documentation/missing-features.text index 2d7faf166b7d4e54262bf72e3d0b287e0edfc20d..0f831c7b0a8cb441499ec322fa702407f094b62f 100644 --- a/documentation/missing-features.text +++ b/documentation/missing-features.text @@ -6,21 +6,9 @@ All file input and output (fread, fwrite) functions. All submatrix functions and views. Stride is always set to 1 in GSL functions that take a stride. -Some things that have been added to GSL since 1.8 that should be added +Some things that have been added to GSL since 1.9 that should be added to GSLL: -GSL 1.9 -http://lists.gnu.org/archive/html/info-gsl/2007-02/msg00000.html -** Added a new BFGS2 minimisation method, requires substantially fewer -function and gradient evaluations that the existing BFGS minimiser. -** Added updated Knuth generator, gsl_rng_knuthran2002, from 9th -printing of "The Art of Computer Programming". Fixes various -weaknesses in the earlier version gsl_rng_knuthran. -** Added new functions for testing the sign of vectors and matrices, -gsl_vector_ispos, gsl_vector_isneg, gsl_matrix_ispos and -gsl_matrix_isneg. - - GSL 1.10 http://lists.gnu.org/archive/html/info-gsl/2007-09/msg00000.html ** Extended Cholesky routines to complex matrices (Patrick Alken) @@ -29,7 +17,6 @@ http://lists.gnu.org/archive/html/info-gsl/2007-09/msg00000.html of two datasets ** Added the new function gsl_sf_expint(n,x) for computing the n-th order exponential integral. -** Added functions gsl_vector_isnonneg and gsl_matrix_isnonneg. ** Added support in gsl_ieee_set_mode for controlling SSE exceptions and rounding through the MXCSR control word on x86 processors. [Modify existing GSLL function.] diff --git a/init/interface.lisp b/init/interface.lisp index b3abe0b468537f4b5f573b7c75427238ff6882ad..f742db8833781e6236b4d5830a3af11e399f6998 100644 --- a/init/interface.lisp +++ b/init/interface.lisp @@ -1,6 +1,6 @@ ;; Macros to interface GSL functions, including definitions necessary for defmfun. ;; Liam Healy -;; Time-stamp: <2009-02-15 12:45:17EST interface.lisp> +;; Time-stamp: <2009-02-16 18:39:59EST interface.lisp> ;; $Id$ (in-package :gsl) @@ -128,13 +128,22 @@ ;;;;**************************************************************************** (defmacro defmpar - (cl-symbol gsl-symbol documentation &optional (c-type :pointer) (read-only t)) + (cl-symbol gsl-symbol documentation + &key (c-type :pointer) (read-only t) gsl-version) "Define a library variable pointer." - `(progn - (cffi:defcvar (,gsl-symbol ,cl-symbol :read-only ,read-only) ,c-type - ,documentation) - (map-name ',cl-symbol ,gsl-symbol) - (export ',cl-symbol))) + (if (have-at-least-gsl-version gsl-version) + `(progn + (cffi:defcvar (,gsl-symbol ,cl-symbol :read-only ,read-only) ,c-type + ,documentation) + (map-name ',cl-symbol ,gsl-symbol) + (export ',cl-symbol)) + ;; Insufficient version number handled by binding a special of + ;; the same name to the condition. It would be nice to signal + ;; the error, but it least this will provide some information. + `(defparameter ,cl-symbol + (make-condition + 'obsolete-gsl-version :name ',cl-symbol :gsl-name + ,gsl-symbol :gsl-version ',gsl-version )))) ;;;;**************************************************************************** ;;;; GSL library version diff --git a/random/generators.lisp b/random/generators.lisp index f810f10c201cb50593221e79d872d72c8547a806..cbcc3fc3daa0955aad70b48ad304f3be80e0a2ed 100644 --- a/random/generators.lisp +++ b/random/generators.lisp @@ -1,6 +1,6 @@ ;; Generators of random numbers. ;; Liam Healy, Sat Jul 15 2006 - 14:43 -;; Time-stamp: <2009-02-16 10:10:32EST generators.lisp> +;; Time-stamp: <2009-02-16 18:43:36EST generators.lisp> ;; $Id$ (in-package :gsl) @@ -36,7 +36,7 @@ (defmpar +default-seed+ "gsl_rng_default_seed" "The default seed for random number generators." - :ulong nil) + :c-type :ulong :read-only nil) ;;;;**************************************************************************** ;;;; Sampling diff --git a/random/rng-types.lisp b/random/rng-types.lisp index 442eb56813e86ec2c9055d3a5aa44450c710a2df..ec1f2abce2cd8b288313eaa6bc2f7bf3a36e6fa7 100644 --- a/random/rng-types.lisp +++ b/random/rng-types.lisp @@ -1,6 +1,6 @@ ;; Random number generation ;; Liam Healy, Tue Jul 11 2006 - 23:39 -;; Time-stamp: <2009-02-16 10:24:11EST rng-types.lisp> +;; Time-stamp: <2009-02-16 18:49:40EST rng-types.lisp> ;; $Id$ ;;; Random number generator types and information functions. @@ -38,7 +38,7 @@ ;;;; Defining RNGs and default ;;;;**************************************************************************** -(defmacro def-rng-type (lisp-name &optional documentation gsl-name) +(defmacro def-rng-type (lisp-name &optional documentation gsl-name gsl-version) "Define the random number generator type." (let ((cname (or gsl-name @@ -46,7 +46,7 @@ (substitute #\_ #\- (format nil "gsl_rng_~(~a~)" lisp-name)))))) - `(defmpar ,lisp-name ,cname ,documentation))) + `(defmpar ,lisp-name ,cname ,documentation :gsl-version ,gsl-version))) (def-rng-type +default-type+ "The default random number generator type, @@ -443,6 +443,14 @@ in Seminumerical Algorithms, 3rd Ed., Section 3.6. Knuth provides its C code.") +(def-rng-type +knuthran2002+ ; FDL + "Obsolete, use only for compatibility. + A second-order multiple recursive generator described by Knuth + in Seminumerical Algorithms, 3rd Ed., Section 3.6. Knuth + provides its C code. From the revised 9th printing and corrects + some weaknesses in the earlier version, which is implemented as + +knuthran+." "gsl_rng_knuthran2002" (1 9)) + (def-rng-type +knuthran2+ ; FDL "Obsolete, use only for compatibility. A second-order multiple recursive generator described by Knuth diff --git a/solve-minimize-fit/minimization-multi.lisp b/solve-minimize-fit/minimization-multi.lisp index 7022751c2b30fb6c3e3f0199ed79f63271f6f30f..af94fff6a486bd45834449c7394fdd04dd89f9ef 100644 --- a/solve-minimize-fit/minimization-multi.lisp +++ b/solve-minimize-fit/minimization-multi.lisp @@ -1,6 +1,6 @@ ;; Multivariate minimization. ;; Liam Healy <Tue Jan 8 2008 - 21:28> -;; Time-stamp: <2009-02-16 09:54:29EST minimization-multi.lisp> +;; Time-stamp: <2009-02-16 18:58:26EST minimization-multi.lisp> ;; $Id$ (in-package :gsl) @@ -268,6 +268,27 @@ steps towards the function minimum, assuming quadratic behavior in that region.") +(defmpar +vector-bfgs2+ + "gsl_multimin_fdfminimizer_vector_bfgs2" + ;; FDL + "The vector Broyden-Fletcher-Goldfarb-Shanno (BFGS) conjugate + gradient algorithm. It is a quasi-Newton method which builds up an + approximation to the second derivatives of the function using the + difference between successive gradient vectors. By combining the + first and second derivatives the algorithm is able to take Newton-type + steps towards the function minimum, assuming quadratic behavior in + that region. + + This version is the most efficient version available, and is a + faithful implementation of the line minimization scheme described + in Fletcher's Practical Methods of Optimization, Algorithms 2.6.2 + and 2.6.4. It supercedes the original bfgs routine and requires + substantially fewer function and gradient evaluations. The + user-supplied tolerance tol corresponds to the parameter \sigma + used by Fletcher. A value of 0.1 is recommended for typical + use (larger values correspond to less accurate line searches)." + :gsl-version (1 9)) + (defmpar +simplex-nelder-mead+ "gsl_multimin_fminimizer_nmsimplex" ;; FDL @@ -414,4 +435,5 @@ (multimin-example-no-derivative +simplex-nelder-mead+ nil) (multimin-example-derivative +conjugate-fletcher-reeves+ nil) (multimin-example-derivative +conjugate-polak-ribiere+ nil) - (multimin-example-derivative +vector-bfgs+ nil)) + (multimin-example-derivative +vector-bfgs+ nil) + (multimin-example-derivative +vector-bfgs2+ nil)) diff --git a/tests/minimization-multi.lisp b/tests/minimization-multi.lisp index 54f337acb3e06e0994d698629cea47930f02b04f..fbbfb25dce85345850ac7fed25cb0e63ecbd30de 100644 --- a/tests/minimization-multi.lisp +++ b/tests/minimization-multi.lisp @@ -3,19 +3,28 @@ (in-package :gsl) (LISP-UNIT:DEFINE-TEST MINIMIZATION-MULTI - (LISP-UNIT::ASSERT-NUMERICAL-EQUAL - (LIST 0.9920430849306285d0 1.9969168063253164d0 30.000823246638923d0) - (MULTIPLE-VALUE-LIST - (MULTIMIN-EXAMPLE-NO-DERIVATIVE +SIMPLEX-NELDER-MEAD+ NIL))) - (LISP-UNIT::ASSERT-NUMERICAL-EQUAL - (LIST 0.9999999999999997d0 2.0d0 30.0d0) - (MULTIPLE-VALUE-LIST - (MULTIMIN-EXAMPLE-DERIVATIVE +CONJUGATE-FLETCHER-REEVES+ NIL))) - (LISP-UNIT::ASSERT-NUMERICAL-EQUAL - (LIST 0.9999999999999997d0 2.0d0 30.0d0) - (MULTIPLE-VALUE-LIST - (MULTIMIN-EXAMPLE-DERIVATIVE +CONJUGATE-POLAK-RIBIERE+ NIL))) - (LISP-UNIT::ASSERT-NUMERICAL-EQUAL - (LIST 0.9999999999999997d0 2.0d0 30.0d0) - (MULTIPLE-VALUE-LIST - (MULTIMIN-EXAMPLE-DERIVATIVE +VECTOR-BFGS+ NIL)))) + (LISP-UNIT::ASSERT-NUMERICAL-EQUAL + (LIST 0.9920430849306285d0 1.9969168063253164d0 + 30.000823246638923d0) + (MULTIPLE-VALUE-LIST + (MULTIMIN-EXAMPLE-NO-DERIVATIVE +SIMPLEX-NELDER-MEAD+ + NIL))) + (LISP-UNIT::ASSERT-NUMERICAL-EQUAL + (LIST 0.9999999999999997d0 2.0d0 30.0d0) + (MULTIPLE-VALUE-LIST + (MULTIMIN-EXAMPLE-DERIVATIVE + +CONJUGATE-FLETCHER-REEVES+ NIL))) + (LISP-UNIT::ASSERT-NUMERICAL-EQUAL + (LIST 0.9999999999999997d0 2.0d0 30.0d0) + (MULTIPLE-VALUE-LIST + (MULTIMIN-EXAMPLE-DERIVATIVE +CONJUGATE-POLAK-RIBIERE+ + NIL))) + (LISP-UNIT::ASSERT-NUMERICAL-EQUAL + (LIST 0.9999999999999997d0 2.0d0 30.0d0) + (MULTIPLE-VALUE-LIST + (MULTIMIN-EXAMPLE-DERIVATIVE +VECTOR-BFGS+ NIL))) + (LISP-UNIT::ASSERT-NUMERICAL-EQUAL + (LIST 0.9999999999998208d0 1.9999999999995521d0 30.0d0) + (MULTIPLE-VALUE-LIST + (MULTIMIN-EXAMPLE-DERIVATIVE +VECTOR-BFGS2+ NIL)))) +