Commit 4f2c390f authored by Liam Healy's avatar Liam Healy

Renamed conditions to more lisp-like names

Renamed conditions in init/conditions.lisp and elsewhere to be more
lisp like; e.g. EDOM is not 'input-domain.  All tests except one pass.
parent f42d6f00
;; The histogram structure
;; Liam Healy, Mon Jan 1 2007 - 11:32
;; Time-stamp: <2008-09-14 22:06:19EDT histogram.lisp>
;; Time-stamp: <2008-11-16 13:46:24EST histogram.lisp>
;; $Id$
(in-package :gsl)
......@@ -30,7 +30,7 @@
"Check that a GSL data pointer is not null, then assign it to the object."
(check-null-pointer
pointer
:ENOMEM
'memory-allocation-failure
(format nil "for ~a."
(with-output-to-string (stream) (princ object stream))))
(setf (mpointer object) pointer))
......
;; GSL errors
;; Liam Healy Sat Mar 4 2006 - 18:33
;; Time-stamp: <2008-11-16 13:26:03EST conditions.lisp>
;; Time-stamp: <2008-11-16 14:47:24EST conditions.lisp>
;; $Id$
(in-package :gsl)
......@@ -36,9 +36,9 @@
(defparameter *errorno-keyword* nil)
(defmacro define-gsl-condition (keyword number text)
(defmacro define-gsl-condition (keyword number text &rest superclasses)
`(progn
(define-condition ,keyword (gsl-condition)
(define-condition ,keyword (gsl-condition ,@superclasses)
((error-number :initform ,number :reader error-number :allocation :class)
(error-text :initform ,text :reader error-text :allocation :class))
(:documentation
......@@ -49,44 +49,58 @@
(export ',keyword)))
(define-gsl-condition input-domain 1 "Input domain error")
(define-gsl-condition ERANGE 2 "Output range error")
(define-gsl-condition EFAULT 3 "Invalid pointer")
(define-gsl-condition EINVAL 4 "Invalid argument")
(define-gsl-condition EFAILED 5 "Generic failure")
(define-gsl-condition EFACTOR 6 "Factorization failed")
(define-gsl-condition ESANITY 7 "Sanity check failed - shouldn't happen")
(define-gsl-condition ENOMEM 8 "Malloc failed")
(define-gsl-condition EBADFUNC 9 "Problem with user-supplied function")
(define-gsl-condition ERUNAWAY 10 "Iterative process is out of control")
(define-gsl-condition EMAXITER 11 "Exceeded max number of iterations")
(define-gsl-condition EZERODIV 12 "Tried to divide by zero")
(define-gsl-condition EBADTOL 13 "User specified an invalid tolerance")
(define-gsl-condition ETOL 14 "Failed to reach the specified tolerance")
(define-gsl-condition EUNDRFLW 15 "Underflow")
(define-gsl-condition EOVRFLW 16 "Overflow")
(define-gsl-condition ELOSS 17 "Loss of accuracy")
(define-gsl-condition EROUND 18 "Failed because of roundoff error")
(define-gsl-condition EBADLEN 19 "Matrix, vector lengths are not conformant")
(define-gsl-condition ENOTSQR 20 "Matrix not square")
(define-gsl-condition ESING 21 "Apparent singularity detected")
(define-gsl-condition EDIVERGE 22 "Integral or series is divergent")
(define-gsl-condition EUNSUP 23 "Requested feature is not supported by the hardware")
(define-gsl-condition EUNIMPL 24 "Requested feature not (yet) implemented")
(define-gsl-condition ECACHE 25 "Cache limit exceeded")
(define-gsl-condition ETABLE 26 "Table limit exceeded")
(define-gsl-condition ENOPROG 27 "Iteration is not making progress towards solution")
(define-gsl-condition ENOPROGJ 28 "Jacobian evaluations are not improving the solution")
(define-gsl-condition ETOLF 29 "Cannot reach the specified tolerance in F")
(define-gsl-condition ETOLX 30 "Cannot reach the specified tolerance in X")
(define-gsl-condition ETOLG 31 "Cannot reach the specified tolerance in gradient")
(define-gsl-condition EOF 32 "End of file")
(define-gsl-condition input-range 2 "Output range error")
(define-gsl-condition invalid-pointer 3 "Invalid pointer")
(define-gsl-condition invalid-argument 4 "Invalid argument")
(define-gsl-condition generic-failure 5 "Generic failure")
(define-gsl-condition factorization-failure 6 "Factorization failed")
(define-gsl-condition sanity-check-failure
7 "Sanity check failed - shouldn't happen")
(define-gsl-condition memory-allocation-failure 8 "Malloc failed")
(define-gsl-condition bad-function-supplied
9 "Problem with user-supplied function")
(define-gsl-condition runaway-iteration
10 "Iterative process is out of control")
(define-gsl-condition exceeded-maximum-iterations
11 "Exceeded max number of iterations")
(define-gsl-condition gsl-division-by-zero
12 "Tried to divide by zero" division-by-zero)
(define-gsl-condition invalid-tolerance 13 "User specified an invalid tolerance")
(define-gsl-condition failure-to-reach-tolerance
14 "Failed to reach the specified tolerance")
(define-gsl-condition underflow 15 "Underflow")
(define-gsl-condition overflow 16 "Overflow")
(define-gsl-condition loss-of-accuracy 17 "Loss of accuracy")
(define-gsl-condition roundoff-failure 18 "Failed because of roundoff error")
(define-gsl-condition nonconformant-dimensions
19 "Matrix, vector lengths are not conformant")
(define-gsl-condition nonsquare-matrix 20 "Matrix not square")
(define-gsl-condition singularity 21 "Apparent singularity detected")
(define-gsl-condition divergence 22 "Integral or series is divergent")
(define-gsl-condition unsupported-feature
23 "Requested feature is not supported by the hardware")
(define-gsl-condition unimplemented-feature
24 "Requested feature not (yet) implemented")
(define-gsl-condition cache-limit-exceeded 25 "Cache limit exceeded")
(define-gsl-condition table-limit-exceeded 26 "Table limit exceeded")
(define-gsl-condition no-progress 27
"Iteration is not making progress towards solution")
(define-gsl-condition jacobian-not-improving
28 "Jacobian evaluations are not improving the solution")
(define-gsl-condition failure-to-reach-tolerance-f
29 "Cannot reach the specified tolerance in F")
(define-gsl-condition failure-to-reach-tolerance-x
30 "Cannot reach the specified tolerance in X")
(define-gsl-condition failure-to-reach-tolerance-g
31 "Cannot reach the specified tolerance in gradient")
(define-gsl-condition gsl-eof 32 "End of file" end-of-file)
;;; It is possible to return +positive-infinity+
;;; by defining a handler for :EOVRFLW.
;;; by defining a handler for 'overflow.
(defun lookup-condition (number)
(or (rest (assoc number *errorno-keyword*))
;; go for "Generic failure" of the code doesn't come up
'EFAILED))
'generic-failure))
(defun signal-gsl-error (number explanation &optional file line)
"Signal an error from the GSL library."
......
;; Macro for defining GSL functions.
;; Liam Healy 2008-04-16 20:49:50EDT defmfun.lisp
;; Time-stamp: <2008-11-11 21:37:46EST defmfun.lisp>
;; Time-stamp: <2008-11-16 14:51:48EST defmfun.lisp>
;; $Id$
(in-package :gsl)
......@@ -586,9 +586,10 @@
#-native
,@(when outputs `(,(mapcar (lambda (x) `(setf (cl-invalid ,x) t))) outputs))
,@(when (or null-pointer-info (eq c-return :pointer))
`((check-null-pointer ,cret-name
,@(or null-pointer-info
'(:ENOMEM "No memory allocated")))))
`((check-null-pointer
,cret-name
,@(or null-pointer-info
'('memory-allocation-failure "No memory allocated")))))
,@after
(values
,@(defmfun-return
......
;; Univariate minimization
;; Liam Healy Tue Jan 8 2008 - 21:02
;; Time-stamp: <2008-02-17 18:37:39EST minimization-one.lisp>
;; Time-stamp: <2008-11-16 14:25:08EST minimization-one.lisp>
;; $Id$
(in-package :gsl)
......@@ -72,7 +72,7 @@
:c-return :success-continue
:documentation ; FDL
"Perform a single iteration of the minimizer. The following
errors may be signalled: :EBADFUNC,
errors may be signalled: 'bad-function-supplied,
the iteration encountered a singular point where the function or its
derivative evaluated to infinity or NaN, or
:FAILURE, the algorithm could not improve the current best approximation or
......
;; Nonlinear least squares fitting.
;; Liam Healy, 2008-02-09 12:59:16EST nonlinear-least-squares.lisp
;; Time-stamp: <2008-08-31 15:13:29EDT nonlinear-least-squares.lisp>
;; Time-stamp: <2008-11-16 14:49:15EST nonlinear-least-squares.lisp>
;; $Id$
(in-package :gsl)
......@@ -256,14 +256,17 @@
the trust region, then the size of the trust region is decreased and
another trial step is computed.
The algorithm also monitors the progress of the solution and returns an
error if the changes in the solution are smaller than the machine
precision. The possible error codes are,
:ETOLF the decrease in the function falls below machine precision,
:ETOLX the change in the position vector falls below machine precision,
:ETOLG the norm of the gradient, relative to the norm of the function,
The algorithm also monitors the progress of the solution and
returns an error if the changes in the solution are smaller than
the machine precision. The possible errors signalled are:
'failure-to-reach-tolerance-f the decrease in the function falls
below machine precision,
'failure-to-reach-tolerance-x
the change in the position vector falls below machine precision,
'failure-to-reach-tolerance-g
the norm of the gradient, relative to the norm of the function,
falls below machine precision.
These error codes indicate that further iterations will be unlikely to
These errors indicate that further iterations would be unlikely to
change the solution from its current value.")
(defmpar *levenberg-marquardt-unscaled* "gsl_multifit_fdfsolver_lmder"
......
;;; Multivariate roots.
;;; Liam Healy 2008-01-12 12:49:08
;;; Time-stamp: <2008-08-23 23:04:50EDT roots-multi.lisp>
;;; Time-stamp: <2008-11-16 14:44:38EST roots-multi.lisp>
;;; $Id$
(in-package :gsl)
......@@ -130,23 +130,23 @@
"gsl_multiroot_fsolver_iterate"
((solver :pointer))
:documentation ; FDL
"Perform a single iteration of the solver. The following
errors may be signalled: :EBADFUNC,
the iteration encountered a singular point where the function or its
derivative evaluated to infinity or NaN, or
:EZERODIV, the derivative of the function vanished at the iteration point,
preventing the algorithm from continuing without a division by zero.")
"Perform a single iteration of the solver. The following errors may
be signalled: 'bad-function-supplied, the iteration encountered a
singular point where the function or its derivative evaluated to
infinity or NaN, or 'gsl-division-by-zero, the derivative of the
function vanished at the iteration point, preventing the algorithm
from continuing without a division by zero.")
(defmfun iterate-mfdfsolver (solver)
"gsl_multiroot_fdfsolver_iterate"
((solver :pointer))
:documentation ; FDL
"Perform a single iteration of the solver. The following
errors may be signalled: :EBADFUNC,
the iteration encountered a singular point where the function or its
derivative evaluated to infinity or NaN, or
:EZERODIV, the derivative of the function vanished at the iteration point,
preventing the algorithm from continuing without a division by zero.")
"Perform a single iteration of the solver. The following errors may
be signalled: 'bad-function-supplied, the iteration encountered a
singular point where the function or its derivative evaluated to
infinity or NaN, or 'gsl-division-by-zero, the derivative of the
function vanished at the iteration point, preventing the algorithm
from continuing without a division by zero.")
(defmfun mfsolver-root (solver)
"gsl_multiroot_fsolver_root"
......@@ -285,10 +285,10 @@
attempts fail to reduce the residual then the full Jacobian is
recomputed. The algorithm also monitors the progress of the solution
and returns an error if several steps fail to make any improvement,
:ENOPROG
'no-progress
the iteration is not making any progress, preventing the algorithm from
continuing.
:ENOPROGJ
'jacobian-not-improving
re-evaluations of the Jacobian indicate that the iteration is not
making any progress, preventing the algorithm from continuing.")
......
;; One-dimensional root solver.
;; Liam Healy
;; Time-stamp: <2008-02-17 18:13:47EST roots-one.lisp>
;; Time-stamp: <2008-11-16 14:34:13EST roots-one.lisp>
;; $Id$
(in-package :gsl)
......@@ -126,23 +126,23 @@
"gsl_root_fsolver_iterate"
((solver :pointer))
:documentation ; FDL
"Perform a single iteration of the solver. The following
errors may be signalled: :EBADFUNC,
the iteration encountered a singular point where the function or its
derivative evaluated to infinity or NaN, or
:EZERODIV, the derivative of the function vanished at the iteration point,
preventing the algorithm from continuing without a division by zero.")
"Perform a single iteration of the solver. The following errors may
be signalled: 'bad-function-supplied, the iteration encountered a
singular point where the function or its derivative evaluated to
infinity or NaN, or 'gsl-division-by-zero, the derivative of the
function vanished at the iteration point, preventing the algorithm
from continuing without a division by zero.")
(defmfun iterate-fdfsolver (solver)
"gsl_root_fdfsolver_iterate"
((solver :pointer))
:documentation ; FDL
"Perform a single iteration of the solver. The following
errors may be signalled: :EBADFUNC,
the iteration encountered a singular point where the function or its
derivative evaluated to infinity or NaN, or
:EZERODIV, the derivative of the function vanished at the iteration point,
preventing the algorithm from continuing without a division by zero.")
"Perform a single iteration of the solver. The following errors may
be signalled: 'bad-function-supplied, the iteration encountered a
singular point where the function or its derivative evaluated to
infinity or NaN, or 'gsl-division-by-zero, the derivative of the
function vanished at the iteration point, preventing the algorithm
from continuing without a division by zero.")
(defmfun fsolver-root (solver)
"gsl_root_fsolver_root"
......
;; Coulumb functions
;; Liam Healy, Sat Mar 18 2006 - 23:23
;; Time-stamp: <2008-10-21 22:46:00EDT coulomb.lisp>
;; Time-stamp: <2008-11-16 14:39:08EST coulomb.lisp>
;; $Id$
(in-package :gsl)
......@@ -29,8 +29,6 @@
;;;; Coulomb Wave Functions
;;;;****************************************************************************
;;; Comments are direct from GSL and aren't lispized yet.
(defmfun coulomb-wave-FG (eta x L-F k)
"gsl_sf_coulomb_wave_FG_e"
((eta :double) (x :double) (L-F :double) (k :int)
......@@ -42,14 +40,13 @@
(err F) (err Fp) (err G) (err Gp))
:documentation ; FDL
"The Coulomb wave functions F_L(\eta,x),
G_{L-k}(\eta,x) and their derivatives F'_L(\eta,x),
G'_{L-k}(\eta,x) with respect to x. The parameters are restricted to
L, L-k > -1/2}, x > 0 and integer k. Note that L
itself is not restricted to being an integer. The results are stored in
the parameters F, G for the function values and Fp,
Gp for the derivative values. If an overflow occurs,
:EOVRFLW is signalled and scaling exponents are stored in
the modifiable parameters exp-F, exp-G.")
G_{L-k}(\eta,x) and their derivatives F'_L(\eta,x), G'_{L-k}(\eta,x)
with respect to x. The parameters are restricted to L, L-k > -1/2},
x > 0 and integer k. Note that L itself is not restricted to being
an integer. The results are stored in the parameters F, G for the
function values and Fp, Gp for the derivative values. If an
overflow occurs, the condition 'overflow is signalled and scaling
exponents are stored in the modifiable parameters exp-F, exp-G.")
(defmfun coulomb-wave-F-array (L-min eta x fc-array)
"gsl_sf_coulomb_wave_F_array"
......
;; Hypergeometric function
;; Liam Healy, Fri Apr 28 2006 - 23:00
;; Time-stamp: <2008-10-23 23:11:41EDT hypergeometric.lisp>
;; Time-stamp: <2008-11-16 14:27:48EST hypergeometric.lisp>
;; $Id$
(in-package :gsl)
......@@ -75,7 +75,7 @@
"The Gauss hypergeometric function
2F1(a,b,c,x) for |x| < 1. If the arguments
(a,b,c,x) are too close to a singularity then the function can
return the error code :EMAXITER when the series
signal the error 'exceeded-maximum-iterations when the series
approximation converges too slowly. This occurs in the region of
x=1, c - a - b = m for integer m.")
......
;; Legendre functions
;; Liam Healy, Sat Apr 29 2006 - 19:16
;; Time-stamp: <2008-10-25 11:02:54EDT legendre.lisp>
;; Time-stamp: <2008-11-16 14:39:40EST legendre.lisp>
;; $Id$
(in-package :gsl)
......@@ -78,7 +78,7 @@
;;; l and can overflow for l larger than about 150. There is
;;; no trouble for small m, but overflow occurs when m and
;;; l are both large. Rather than allow overflows, these functions
;;; refuse to calculate P_l^m(x) and return :EOVRFLW when
;;; refuse to calculate P_l^m(x) and signal 'overflow when
;;; they can sense that l and m are too big.
;;; If you want to calculate a spherical harmonic, then do not use
......
......@@ -13,7 +13,7 @@
(LETM ((WS (INTEGRATION-WORKSPACE 20)))
(INTEGRATION-QAG ONE-SINE 0.0d0 PI :GAUSS15 20
WS))))
(LISP-UNIT:ASSERT-ERROR 'EINVAL
(LISP-UNIT:ASSERT-ERROR 'invalid-argument
(LETM
((WS
(INTEGRATION-WORKSPACE 20)))
......
;; Wavelet transforms.
;; Liam Healy, Mon Nov 26 2007 - 20:43
;; Time-stamp: <2008-08-23 11:45:54EDT wavelet.lisp>
;; Time-stamp: <2008-11-16 13:46:02EST wavelet.lisp>
;; $Id$
(in-package :gsl)
......@@ -29,10 +29,10 @@
:export nil
:index (letm wavelet)
:documentation ; FDL
"Allocate and initialize a wavelet object of type
'type. The parameter 'member selects the specific member of the
wavelet family. An error of :ENOMEM indicates either lack
of memory or an unsupported member requested.")
"Allocate and initialize a wavelet object of type 'type. The
parameter 'member selects the specific member of the wavelet
family. A memory-allocation-failure error indicates either
lack of memory or an unsupported member requested.")
(defmfun free-wavelet (wavelet)
"gsl_wavelet_free"
......@@ -203,7 +203,7 @@
workspace of the appropriate size must be provided. On exit,
the appropriate elements of the array data are replaced by their
two-dimensional wavelet transform.
An error :EINVAL is signalled if the matrix is not square
An error invalid-argument is signalled if the matrix is not square
with dimension a power of 2, or if insufficient
workspace is provided.")
......@@ -221,7 +221,7 @@
workspace of the appropriate size must be provided. On exit,
the appropriate elements of the array data are replaced by their
two-dimensional wavelet transform.
An error :EINVAL is signalled if the matrix is not square
An error invalid-argument is signalled if the matrix is not square
with dimension a power of 2, or if insufficient
workspace is provided.")
......@@ -238,7 +238,7 @@
and are restricted to powers of two. A workspace of the appropriate
size must be provided. On exit, the appropriate elements of the array
data are replaced by their two-dimensional wavelet transform. An
error :EINVAL is signalled if the matrix is not square with dimension
error invalid-argument is signalled if the matrix is not square with dimension
a power of 2, or if insufficient workspace is provided.")
(defmfun wavelet-2d-transform-matrix (wavelet data direction workspace)
......
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