Commit 453f3364 authored by Liam Healy's avatar Liam Healy

Generic function #'size

A new generic function #'size replaces the old ordinary functions
#'size (for Chebyshev) and #'combination-size, #'permutation-size,
#'rng-size, and #'mfminimizer-size.
parent 09648af2
;; Chebyshev Approximations
;; Liam Healy Sat Nov 17 2007 - 20:36
;; Time-stamp: <2009-04-26 23:25:30EDT chebyshev.lisp>
;; Time-stamp: <2009-05-25 09:44:54EDT chebyshev.lisp>
;; $Id$
(in-package :gsl)
......@@ -30,9 +30,10 @@
:c-return sizet
:gsl-version (1 12))
(defmfun size (chebyshev)
(defmfun size ((chebyshev chebyshev))
"gsl_cheb_size"
(((mpointer chebyshev) :pointer))
:definition :method
:c-return sizet
:gsl-version (1 12))
......
;; Combinations
;; Liam Healy, Sun Mar 26 2006 - 11:51
;; Time-stamp: <2009-01-12 09:40:18EST combination.lisp>
;; Time-stamp: <2009-05-25 10:04:32EDT combination.lisp>
;; $Id$
(in-package :gsl)
......@@ -104,9 +104,10 @@
:documentation ; FDL
"The range (n) of the combination c.")
(defmfun combination-size (c)
(defmfun size ((c combination))
"gsl_combination_k"
(((mpointer c) :pointer))
:definition :method
:c-return sizet
:inputs (c)
:documentation ; FDL
......@@ -168,8 +169,8 @@
(save-test combination
(let ((comb (make-combination 4 2))) ; combination-range
(combination-range comb))
(let ((comb (make-combination 4 2))) ; combination-size
(combination-size comb))
(let ((comb (make-combination 4 2))) ; size
(size comb))
(let ((comb (make-combination 4 2))) ; init-first, combination-next
(init-first comb)
(loop collect (copy-seq (cl-array comb))
......
;; Permutations
;; Liam Healy, Sun Mar 26 2006 - 11:51
;; Time-stamp: <2009-04-26 22:47:28EDT permutation.lisp>
;; Time-stamp: <2009-05-25 09:47:14EDT permutation.lisp>
;; $Id$
(in-package :gsl)
......@@ -90,9 +90,10 @@
;;;; Permutation properties
;;;;****************************************************************************
(defmfun permutation-size (p)
(defmfun size ((p permutation))
"gsl_permutation_size"
(((mpointer p) :pointer))
:definition :method
:c-return sizet
:inputs (p)
:documentation ; FDL
......
;; Definition of GSL objects and ways to use them.
;; Liam Healy, Sun Dec 3 2006 - 10:21
;; Time-stamp: <2009-04-04 22:00:21EDT mobject.lisp>
;; Time-stamp: <2009-05-25 09:59:03EDT mobject.lisp>
;;; GSL objects are represented in GSLL as and instance of a 'mobject.
;;; The macro demobject takes care of defining the appropriate
......@@ -268,6 +268,12 @@
(defgeneric name (object)
(:documentation "The name given to the GSL object."))
(export 'size)
(defgeneric size (object)
(:documentation "The size of the GSL object.")
(:method ((object array))
(array-total-size object)))
(export 'evaluate)
(defgeneric evaluate (object point &key #+sbcl &allow-other-keys)
(:documentation "Evaluate the GSL object."))
......
;; Generators of random numbers.
;; Liam Healy, Sat Jul 15 2006 - 14:43
;; Time-stamp: <2009-05-24 22:50:40EDT generators.lisp>
;; Time-stamp: <2009-05-25 10:07:43EDT generators.lisp>
;; $Id$
(in-package :gsl)
......@@ -136,15 +136,10 @@
:definition :method
:index gsl-random-state)
(export 'rng-size)
(defgeneric rng-size (rng-instance)
(:documentation ; FDL
"The size of the generator."))
(defmfun rng-size ((rng-instance random-number-generator))
(defmfun size ((rng-instance random-number-generator))
"gsl_rng_size" (((mpointer rng-instance) :pointer))
:c-return sizet
:definition :method
:c-return sizet
:index gsl-random-state)
(export 'gsl-random-state)
......@@ -153,7 +148,7 @@
as a vector of bytes."
(let* ((gen rng-instance)
(ans
(make-array (rng-size gen)
(make-array (size gen)
:element-type '(unsigned-byte 8))))
(loop for i from 0 below (length ans)
do
......
;; Quasi-random sequences in arbitrary dimensions.
;; Liam Healy, Sun Jul 16 2006 - 15:54
;; Time-stamp: <2009-02-17 21:14:50EST quasi.lisp>
;; Time-stamp: <2009-05-25 09:44:53EDT quasi.lisp>
;; $Id$
(in-package :gsl)
......@@ -36,15 +36,15 @@
(defmfun rng-state ((instance quasi-random-number-generator))
"gsl_qrng_state" (((mpointer instance) :pointer))
:c-return :pointer
:definition :method
:c-return :pointer
:export nil
:index gsl-random-state)
(defmfun rng-size ((instance quasi-random-number-generator))
(defmfun size ((instance quasi-random-number-generator))
"gsl_qrng_size" (((mpointer instance) :pointer))
:c-return sizet
:definition :method
:c-return sizet
:export nil
:index gsl-random-state)
......
;; Multivariate minimization.
;; Liam Healy <Tue Jan 8 2008 - 21:28>
;; Time-stamp: <2009-04-04 22:29:11EDT minimization-multi.lisp>
;; Time-stamp: <2009-05-25 10:04:32EDT minimization-multi.lisp>
;; $Id$
(in-package :gsl)
......@@ -153,9 +153,10 @@
:documentation ; FDL
"The current best estimate of the value of the minimum.")
(defmfun mfminimizer-size (minimizer)
(defmfun size ((minimizer multi-dimensional-minimizer-f))
"gsl_multimin_fminimizer_size"
(((mpointer minimizer) :pointer))
:definition :method
:c-return :double
:documentation ; FDL
"A minimizer-specific characteristic size for the minimizer.")
......@@ -362,7 +363,7 @@
while status
do (iterate minimizer)
(setf size
(mfminimizer-size minimizer)
(size minimizer)
status
(not (min-test-size size 1.0d-2)))
(when print-steps
......
......@@ -3,43 +3,39 @@
(in-package :gsl)
(LISP-UNIT:DEFINE-TEST COMBINATION
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL (LIST 4)
(MULTIPLE-VALUE-LIST
(LET ((COMB
(MAKE-COMBINATION
4 2)))
(COMBINATION-RANGE
COMB))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL (LIST 2)
(MULTIPLE-VALUE-LIST
(LET ((COMB
(MAKE-COMBINATION
4 2)))
(COMBINATION-SIZE
COMB))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST (LIST #(0 1) #(0 2) #(0 3) #(1 2) #(1 3) #(2 3)))
(MULTIPLE-VALUE-LIST
(LET ((COMB (MAKE-COMBINATION 4 2)))
(INIT-FIRST COMB)
(LOOP COLLECT (COPY-SEQ (CL-ARRAY COMB)) WHILE
(COMBINATION-NEXT COMB)))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST (LIST #(2 3) #(1 3) #(1 2) #(0 3) #(0 2) #(0 1)))
(MULTIPLE-VALUE-LIST
(LET ((COMB (MAKE-COMBINATION 4 2)))
(INIT-LAST COMB)
(LOOP COLLECT (COPY-SEQ (CL-ARRAY COMB)) WHILE
(COMBINATION-PREVIOUS COMB)))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST
(LIST #() #(0) #(1) #(2) #(3) #(0 1) #(0 2) #(0 3)
#(1 2) #(1 3) #(2 3) #(0 1 2) #(0 1 3) #(0 2 3)
#(1 2 3) #(0 1 2 3)))
(MULTIPLE-VALUE-LIST
(LOOP FOR I FROM 0 TO 4 APPEND
(LET ((COMB (MAKE-COMBINATION 4 I)))
(INIT-FIRST COMB)
(LOOP COLLECT (COPY-SEQ (CL-ARRAY COMB)) WHILE
(COMBINATION-NEXT COMB)))))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST 4)
(MULTIPLE-VALUE-LIST
(LET ((COMB (MAKE-COMBINATION 4 2)))
(COMBINATION-RANGE COMB))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST 2)
(MULTIPLE-VALUE-LIST
(LET ((COMB (MAKE-COMBINATION 4 2)))
(SIZE COMB))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST (LIST #(0 1) #(0 2) #(0 3) #(1 2) #(1 3) #(2 3)))
(MULTIPLE-VALUE-LIST
(LET ((COMB (MAKE-COMBINATION 4 2)))
(INIT-FIRST COMB)
(LOOP COLLECT (COPY-SEQ (CL-ARRAY COMB)) WHILE
(COMBINATION-NEXT COMB)))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST (LIST #(2 3) #(1 3) #(1 2) #(0 3) #(0 2) #(0 1)))
(MULTIPLE-VALUE-LIST
(LET ((COMB (MAKE-COMBINATION 4 2)))
(INIT-LAST COMB)
(LOOP COLLECT (COPY-SEQ (CL-ARRAY COMB)) WHILE
(COMBINATION-PREVIOUS COMB)))))
(LISP-UNIT::ASSERT-NUMERICAL-EQUAL
(LIST
(LIST #() #(0) #(1) #(2) #(3) #(0 1) #(0 2) #(0 3)
#(1 2) #(1 3) #(2 3) #(0 1 2) #(0 1 3) #(0 2 3)
#(1 2 3) #(0 1 2 3)))
(MULTIPLE-VALUE-LIST
(LOOP FOR I FROM 0 TO 4 APPEND
(LET ((COMB (MAKE-COMBINATION 4 I)))
(INIT-FIRST COMB)
(LOOP COLLECT (COPY-SEQ (CL-ARRAY COMB)) WHILE
(COMBINATION-NEXT COMB)))))))
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