- Timestamp:
- 03/28/08 03:12:26 (8 months ago)
- Location:
- trunk
- Files:
-
- 9 modified
-
documentation/index.html (modified) (2 diffs)
-
histogram/updating-accessing.lisp (modified) (4 diffs)
-
init/conditions.lisp (modified) (2 diffs)
-
init/interface.lisp (modified) (2 diffs)
-
numerical-integration.lisp (modified) (2 diffs)
-
special-functions/elliptic-functions.lisp (modified) (2 diffs)
-
special-functions/exponential-integrals.lisp (modified) (2 diffs)
-
special-functions/gamma.lisp (modified) (3 diffs)
-
special-functions/legendre.lisp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/documentation/index.html
r32 r47 70 70 <pre> 71 71 (jacobian-elliptic-functions 0.61802d0 1.5d0) 72 debugger invoked on a GSL-ERROR in thread #<THREAD "initial thread" {10032258C1}>: 73 Input domain error (EDOM), |m| > 1.0 in elljac.c at line 4672 Input domain error |m| > 1.0 in elljac.c at line 46 73 [Condition of type EDOM] 74 74 </pre> 75 75 </div> … … 159 159 <!-- hhmts start --> 160 160 <small> 161 Time-stamp: <2008-03- 08 11:22:52EST index.html>161 Time-stamp: <2008-03-27 23:08:11EDT index.html> 162 162 </small> 163 163 <!-- hhmts end --> -
trunk/histogram/updating-accessing.lisp
r26 r47 1 1 ;; Updating and accessing histogram elements. 2 2 ;; Liam Healy, Mon Jan 1 2007 - 14:43 3 ;; Time-stamp: <2008-0 2-23 18:49:16EST updating-accessing.lisp>3 ;; Time-stamp: <2008-03-27 23:09:26EDT updating-accessing.lisp> 4 4 ;; $Id$ 5 5 … … 117 117 ((first values) (second values)))) 118 118 119 ;;; Examples and unit test120 121 #|122 (make-tests histogram123 119 (letm ((histo (histogram 10))) ; should be a gsl-warning here, how to check? 124 120 (set-ranges-uniform histo 0.0d0 10.0d0) 125 121 (increment histo -2.0d0)) 122 ;;; Examples and unit test 123 124 #| 125 (make-tests histogram 126 ;; The first one gives a warning while compiling in SBCL, 127 ;; should only give a warning while runnin. 128 (letm ((histo (histogram 10))) 129 (set-ranges-uniform histo 0.0d0 10.0d0) 130 (increment histo -2.0d0)) 126 131 (letm ((histo (histogram 10))) 127 132 (set-ranges-uniform histo 0.0d0 10.0d0) … … 162 167 163 168 (LISP-UNIT:DEFINE-TEST HISTOGRAM 164 (LISP-UNIT::ASSERT-NUMERICAL-EQUAL 165 (LIST) 166 (MULTIPLE-VALUE-LIST 167 (LETM ((HISTO (HISTOGRAM 10))) 168 (SET-RANGES-UNIFORM HISTO 0.0d0 10.0d0) 169 (INCREMENT HISTO -2.0d0)))) 169 (LISP-UNIT:ASSERT-ERROR 170 'GSL-CONDITION 171 (LETM ((HISTO (HISTOGRAM 10))) 172 (SET-RANGES-UNIFORM HISTO 0.0d0 10.0d0) 173 (INCREMENT HISTO -2.0d0))) 170 174 (LISP-UNIT::ASSERT-NUMERICAL-EQUAL 171 175 (LIST 0.0d0) … … 193 197 (MAREF HISTO 6)))) 194 198 (LISP-UNIT:ASSERT-ERROR 195 'GSL- ERROR199 'GSL-CONDITION 196 200 (LETM ((HISTO (HISTOGRAM 10))) 197 201 (SET-RANGES-UNIFORM HISTO 0.0d0 10.0d0) -
trunk/init/conditions.lisp
r33 r47 1 1 ;; GSL errors 2 2 ;; Liam Healy Sat Mar 4 2006 - 18:33 3 ;; Time-stamp: <2008-03- 08 12:39:50EST conditions.lisp>3 ;; Time-stamp: <2008-03-27 23:07:29EDT conditions.lisp> 4 4 ;; $Id$ 5 5 6 6 (in-package :gsl) 7 7 8 (cffi:defcenum gsl-errorno 9 "Error codes for GSL, from /usr/include/gsl/gsl_errno.h." 10 (:CONTINUE -2) 11 :FAILURE :SUCCESS :EDOM :ERANGE :EFAULT :EINVAL :EFAILED :EFACTOR 12 :ESANITY :ENOMEM :EBADFUNC :ERUNAWAY :EMAXITER :EZERODIV :EBADTOL 13 :ETOL :EUNDRFLW :EOVRFLW :ELOSS :EROUND :EBADLEN :ENOTSQR :ESING 14 :EDIVERGE :EUNSUP :EUNIMPL :ECACHE :ETABLE :ENOPROG :ENOPROGJ 15 :ETOLF :ETOLX :ETOLG :EOF) 8 ;;;;**************************************************************************** 9 ;;;; GSL conditions 10 ;;;;**************************************************************************** 16 11 17 (defparameter *gsl-error-alist* 18 '((-2 . "Iteration has not converged") 19 (-1 . "Failure") 20 (0 . "Success") 21 (1 . "Input domain error") 22 (2 . "Output range error") 23 (3 . "Invalid pointer") 24 (4 . "Invalid argument") 25 (5 . "Generic failure") 26 (6 . "Factorization failed") 27 (7 . "Sanity check failed - shouldn't happen") 28 (8 . "Malloc failed") 29 (9 . "Problem with user-supplied function") 30 (10 . "Iterative process is out of control") 31 (11 . "Exceeded max number of iterations") 32 (12 . "Tried to divide by zero") 33 (13 . "User specified an invalid tolerance") 34 (14 . "Failed to reach the specified tolerance") 35 (15 . "Underflow") 36 (16 . "Overflow ") 37 (17 . "Loss of accuracy") 38 (18 . "Failed because of roundoff error") 39 (19 . "Matrix, vector lengths are not conformant") 40 (20 . "Matrix not square") 41 (21 . "Apparent singularity detected") 42 (22 . "Integral or series is divergent") 43 (23 . "Requested feature is not supported by the hardware") 44 (24 . "Requested feature not (yet) implemented") 45 (25 . "Cache limit exceeded") 46 (26 . "Table limit exceeded") 47 (27 . "Iteration is not making progress towards solution") 48 (28 . "Jacobian evaluations are not improving the solution") 49 (29 . "Cannot reach the specified tolerance in F") 50 (30 . "Cannot reach the specified tolerance in X") 51 (31 . "Cannot reach the specified tolerance in gradient") 52 (32 . "End of file"))) 53 54 ;;; It would be nice to be able to return, or give the option to return, 55 ;;; the portable equivalent of #.SB-EXT:DOUBLE-FLOAT-POSITIVE-INFINITY 56 ;;; for :EOVRFLW. 57 58 (define-condition gsl-error (arithmetic-error) 59 ((gsl-errno :initarg :gsl-errno :reader gsl-errno) 60 (gsl-reason :initarg :gsl-reason :reader gsl-reason) 61 (gsl-source-file :initform nil :initarg :gsl-source-file :reader gsl-source-file) 62 (gsl-line-number :initform 0 :initarg :gsl-line-number :reader gsl-line-number)) 12 (export 'gsl-condition) 13 (define-condition gsl-condition (arithmetic-error warning) 14 ((error-number :initarg :error-number :reader error-number) 15 (error-text :initarg :error-text :reader error-text) 16 (explanation :initarg :explanation :reader explanation) 17 (source-file :initform nil :initarg :source-file :reader source-file) 18 (line-number :initform 0 :initarg :line-number :reader line-number)) 63 19 (:report 64 20 (lambda (condition stream) 65 (format stream "~a (~a), ~a ~@[in ~a at line ~d~]" 66 (rest (assoc (gsl-errno condition) *gsl-error-alist*)) 67 (cffi:foreign-enum-keyword 'gsl-errorno (gsl-errno condition)) 68 (gsl-reason condition) 69 (gsl-source-file condition) 70 (gsl-line-number condition)))) 21 (format stream "~a ~a ~@[in ~a at line ~d~]" 22 (error-text condition) 23 (explanation condition) 24 (source-file condition) 25 (line-number condition)))) 71 26 (:documentation 72 "A n errorthat has been signalled by the GNU Scientific Library."))27 "A condition that has been signalled by the GNU Scientific Library.")) 73 28 74 (define-condition gsl-warning (warning) 75 ((gsl-errno :initarg :gsl-errno :reader gsl-errno) 76 (gsl-context :initarg :gsl-context :reader gsl-context)) 77 (:report 78 (lambda (condition stream) 79 (format stream "GSL condition ~a (~d), ~a in ~a" 80 (cffi:foreign-enum-keyword 'gsl-errorno (gsl-errno condition)) 81 (gsl-errno condition) 82 (rest (assoc (gsl-errno condition) *gsl-error-alist*)) 83 (gsl-context condition)))) 84 (:documentation 85 "An warning that has been signalled by the GNU Scientific Library.")) 29 (defparameter *errorno-keyword* nil) 30 31 (defmacro define-gsl-condition (keyword number text) 32 `(progn 33 (define-condition ,keyword (gsl-condition) 34 ((error-number :initform ,number :reader error-number :allocation :class) 35 (error-text :initform ,text :reader error-text :allocation :class)) 36 (:documentation 37 (format nil 38 "The condition ~a, ~a, signalled by the GNU Scientific Library." 39 ',keyword ,text))) 40 (setf *errorno-keyword* (acons ,number ',keyword *errorno-keyword*)) 41 (export ',keyword))) 42 43 (define-gsl-condition EDOM 1 "Input domain error") 44 (define-gsl-condition ERANGE 2 "Output range error") 45 (define-gsl-condition EFAULT 3 "Invalid pointer") 46 (define-gsl-condition EINVAL 4 "Invalid argument") 47 (define-gsl-condition EFAILED 5 "Generic failure") 48 (define-gsl-condition EFACTOR 6 "Factorization failed") 49 (define-gsl-condition ESANITY 7 "Sanity check failed - shouldn't happen") 50 (define-gsl-condition ENOMEM 8 "Malloc failed") 51 (define-gsl-condition EBADFUNC 9 "Problem with user-supplied function") 52 (define-gsl-condition ERUNAWAY 10 "Iterative process is out of control") 53 (define-gsl-condition EMAXITER 11 "Exceeded max number of iterations") 54 (define-gsl-condition EZERODIV 12 "Tried to divide by zero") 55 (define-gsl-condition EBADTOL 13 "User specified an invalid tolerance") 56 (define-gsl-condition ETOL 14 "Failed to reach the specified tolerance") 57 (define-gsl-condition EUNDRFLW 15 "Underflow") 58 (define-gsl-condition EOVRFLW 16 "Overflow") 59 (define-gsl-condition ELOSS 17 "Loss of accuracy") 60 (define-gsl-condition EROUND 18 "Failed because of roundoff error") 61 (define-gsl-condition EBADLEN 19 "Matrix, vector lengths are not conformant") 62 (define-gsl-condition ENOTSQR 20 "Matrix not square") 63 (define-gsl-condition ESING 21 "Apparent singularity detected") 64 (define-gsl-condition EDIVERGE 22 "Integral or series is divergent") 65 (define-gsl-condition EUNSUP 23 "Requested feature is not supported by the hardware") 66 (define-gsl-condition EUNIMPL 24 "Requested feature not (yet) implemented") 67 (define-gsl-condition ECACHE 25 "Cache limit exceeded") 68 (define-gsl-condition ETABLE 26 "Table limit exceeded") 69 (define-gsl-condition ENOPROG 27 "Iteration is not making progress towards solution") 70 (define-gsl-condition ENOPROGJ 28 "Jacobian evaluations are not improving the solution") 71 (define-gsl-condition ETOLF 29 "Cannot reach the specified tolerance in F") 72 (define-gsl-condition ETOLX 30 "Cannot reach the specified tolerance in X") 73 (define-gsl-condition ETOLG 31 "Cannot reach the specified tolerance in gradient") 74 (define-gsl-condition EOF 32 "End of file") 75 ;;; It is possible to return +positive-infinity+ 76 ;;; by defining a handler for :EOVRFLW. 77 78 (defun lookup-condition (number) 79 (or (rest (assoc number *errorno-keyword*)) 80 ;; go for "Generic failure" of the code doesn't come up 81 'EFAILED)) 82 83 (defun signal-gsl-error (number explanation &optional file line) 84 "Signal an error from the GSL library." 85 (error (lookup-condition number) 86 :explanation explanation 87 :source-file file 88 :line-number line)) 89 90 (defun signal-gsl-warning (number explanation &optional file line) 91 "Signal a warning from the GSL library." 92 (warn (lookup-condition number) 93 :explanation explanation 94 :source-file file 95 :line-number line)) 86 96 87 97 (cffi:defcallback gsl-error :void 88 98 ((reason :string) (file :string) (line :int) (error-number :int)) 89 (error 'gsl-error 90 :gsl-errno error-number 91 :gsl-reason reason 92 :gsl-source-file file 93 :gsl-line-number line)) 99 (signal-gsl-error error-number reason file line)) 94 100 95 101 (defun establish-handler () … … 104 110 #+sbcl (push 'establish-handler sb-ext:*init-hooks*) 105 111 112 ;;;;**************************************************************************** 113 ;;;; Define non-error C codes 114 ;;;;**************************************************************************** 115 116 (cffi:defcenum gsl-errorno 117 "Error codes for GSL, from /usr/include/gsl/gsl_errno.h." 118 ;; We really only need the first three here; the rest are handled 119 ;; above. 120 (:CONTINUE -2) 121 :FAILURE :SUCCESS :EDOM :ERANGE :EFAULT :EINVAL :EFAILED :EFACTOR 122 :ESANITY :ENOMEM :EBADFUNC :ERUNAWAY :EMAXITER :EZERODIV :EBADTOL 123 :ETOL :EUNDRFLW :EOVRFLW :ELOSS :EROUND :EBADLEN :ENOTSQR :ESING 124 :EDIVERGE :EUNSUP :EUNIMPL :ECACHE :ETABLE :ENOPROG :ENOPROGJ 125 :ETOLF :ETOLX :ETOLG :EOF) 126 106 127 (defmacro gsl-errorno-sm (keyword) 107 128 `(define-symbol-macro -
trunk/init/interface.lisp
r37 r47 1 1 ;; Macros to interface GSL functions. 2 2 ;; Liam Healy 3 ;; Time-stamp: <2008-03- 15 21:51:07EDT interface.lisp>3 ;; Time-stamp: <2008-03-27 22:36:35EDT interface.lisp> 4 4 ;; $Id$ 5 5 … … 74 74 "Check the return status code from a GSL function and signal a warning 75 75 if it is not :SUCCESS." 76 (unless (eql :success (cffi:foreign-enum-keyword 'gsl-errorno status-code)) 77 (warn 'gsl-warning 78 :gsl-errno status-code :gsl-context context))) 76 (unless (eql status-code success) 77 (signal-gsl-warning status-code (format nil "in ~a" context)))) 79 78 80 79 (defun check-null-pointer (pointer error-code reason) 81 80 (when (cffi:null-pointer-p pointer) 82 (error 'gsl-error 83 :gsl-errno (cffi:foreign-enum-value 'gsl-errorno error-code) 84 :gsl-reason reason))) 81 (signal-gsl-error error-code reason))) 85 82 86 83 (defun success-failure (value) -
trunk/numerical-integration.lisp
r26 r47 1 1 ;; Numerical integration 2 2 ;; Liam Healy, Wed Jul 5 2006 - 23:14 3 ;; Time-stamp: <2008-0 2-17 11:43:47EST numerical-integration.lisp>3 ;; Time-stamp: <2008-03-27 21:30:20EDT numerical-integration.lisp> 4 4 ;; $Id$ 5 5 … … 247 247 WS)))) 248 248 (LISP-UNIT:ASSERT-ERROR 249 'GSL- ERROR249 'GSL-CONDITION 250 250 (LETM ((WS (INTEGRATION-WORKSPACE 20))) 251 251 (INTEGRATION-QAG ONE-SINE 0.0d0 PI :GAUSS15 50 WS)))) -
trunk/special-functions/elliptic-functions.lisp
r26 r47 1 1 ;; Jacobian elliptic functions 2 2 ;; Liam Healy, Mon Mar 20 2006 - 22:21 3 ;; Time-stamp: <2008-0 2-16 20:42:55EST elliptic-functions.lisp>3 ;; Time-stamp: <2008-03-27 21:29:35EDT elliptic-functions.lisp> 4 4 ;; $Id$ 5 5 … … 38 38 (MULTIPLE-VALUE-LIST 39 39 (JACOBIAN-ELLIPTIC-FUNCTIONS 0.2d0 0.81d0))) 40 (LISP-UNIT:ASSERT-ERROR 'GSL- ERROR40 (LISP-UNIT:ASSERT-ERROR 'GSL-CONDITION 41 41 (JACOBIAN-ELLIPTIC-FUNCTIONS 42 42 0.61802d0 1.5d0))) -
trunk/special-functions/exponential-integrals.lisp
r26 r47 1 1 ;; Exponential integrals 2 2 ;; Liam Healy, Tue Mar 21 2006 - 17:37 3 ;; Time-stamp: <2008-0 2-16 22:16:29EST exponential-integrals.lisp>3 ;; Time-stamp: <2008-03-27 21:29:32EDT exponential-integrals.lisp> 4 4 ;; $Id$ 5 5 … … 105 105 106 106 (LISP-UNIT:DEFINE-TEST EXPONENTIAL-INTEGRALS 107 (LISP-UNIT:ASSERT-ERROR 'GSL- ERROR(EXPINT-E1 0.0d0))107 (LISP-UNIT:ASSERT-ERROR 'GSL-CONDITION (EXPINT-E1 0.0d0)) 108 108 (LISP-UNIT::ASSERT-NUMERICAL-EQUAL 109 109 (LIST 0.21938393439552029d0 2.6541220085226265d-16) -
trunk/special-functions/gamma.lisp
r26 r47 1 1 ;; Gamma functions 2 2 ;; Liam Healy, Thu Apr 27 2006 - 22:06 3 ;; Time-stamp: <2008-0 2-16 21:58:18EST gamma.lisp>3 ;; Time-stamp: <2008-03-27 21:29:36EDT gamma.lisp> 4 4 ;; $Id$ 5 5 … … 219 219 220 220 (LISP-UNIT:DEFINE-TEST GAMMA 221 (LISP-UNIT:ASSERT-ERROR 'GSL- ERROR(GAMMA -1.0d0))221 (LISP-UNIT:ASSERT-ERROR 'GSL-CONDITION (GAMMA -1.0d0)) 222 222 (LISP-UNIT::ASSERT-NUMERICAL-EQUAL 223 223 (LIST 120.0d0 2.6645352591003757d-14) 224 224 (MULTIPLE-VALUE-LIST (GAMMA 6.0d0))) 225 (LISP-UNIT:ASSERT-ERROR 'GSL- ERROR(LOG-GAMMA -100.0d0))225 (LISP-UNIT:ASSERT-ERROR 'GSL-CONDITION (LOG-GAMMA -100.0d0)) 226 226 (LISP-UNIT::ASSERT-NUMERICAL-EQUAL 227 227 (LIST 359.13420536957534d0 2.4544868717695813d-13) … … 260 260 (LIST 56.0d0 7.460698725481052d-14) 261 261 (MULTIPLE-VALUE-LIST (CHOOSE 8 3))) 262 (LISP-UNIT:ASSERT-ERROR 'GSL- ERROR(CHOOSE 3 8))262 (LISP-UNIT:ASSERT-ERROR 'GSL-CONDITION (CHOOSE 3 8)) 263 263 (LISP-UNIT::ASSERT-NUMERICAL-EQUAL 264 264 (LIST 29.422274169864693d0 1.9338924605168215d-13) -
trunk/special-functions/legendre.lisp
r34 r47 1 1 ;; Legendre functions 2 2 ;; Liam Healy, Sat Apr 29 2006 - 19:16 3 ;; Time-stamp: <2008-03- 09 19:29:17EDT legendre.lisp>3 ;; Time-stamp: <2008-03-27 21:30:02EDT legendre.lisp> 4 4 ;; $Id$ 5 5 … … 307 307 (LIST -0.38249999999999995d0 1.9984014443252816d-16) 308 308 (MULTIPLE-VALUE-LIST (LEGENDRE-P3 0.3d0))) 309 (LISP-UNIT:ASSERT-ERROR 'GSL- ERROR309 (LISP-UNIT:ASSERT-ERROR 'GSL-CONDITION 310 310 (LEGENDRE-PL -4 0.3d0)) 311 (LISP-UNIT:ASSERT-ERROR 'GSL- ERROR311 (LISP-UNIT:ASSERT-ERROR 'GSL-CONDITION 312 312 (LEGENDRE-PL 4 3.0d0)) 313 313 (LISP-UNIT::ASSERT-NUMERICAL-EQUAL
