From cl-gsl-cvs at common-lisp.net Wed May 4 02:47:02 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 4 May 2005 04:47:02 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/package.lisp Message-ID: <20050504024702.B8BF98871F@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv30055 Modified Files: package.lisp Log Message: Change symbol valid to isvalid. Add symbol with-permutation. Date: Wed May 4 04:47:02 2005 Author: edenny Index: cl-gsl/package.lisp diff -u cl-gsl/package.lisp:1.10 cl-gsl/package.lisp:1.11 --- cl-gsl/package.lisp:1.10 Sun May 1 00:36:03 2005 +++ cl-gsl/package.lisp Wed May 4 04:47:01 2005 @@ -162,7 +162,7 @@ ;; from permutation #:permutation-init - #:valid + #:isvalid #:reverse-permutation #:next #:prev @@ -171,6 +171,7 @@ #:permute-vector #:permute-vector-inverse #:make-permutation + #:with-permutation #:with-permutation-copy #:with-permutation-mul #:linear->canonical From cl-gsl-cvs at common-lisp.net Wed May 4 02:48:37 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 4 May 2005 04:48:37 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/permutation.lisp Message-ID: <20050504024837.E3EB08871F@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv30115 Modified Files: permutation.lisp Log Message: Completed adding the wrappers. Date: Wed May 4 04:48:37 2005 Author: edenny Index: cl-gsl/permutation.lisp diff -u cl-gsl/permutation.lisp:1.1 cl-gsl/permutation.lisp:1.2 --- cl-gsl/permutation.lisp:1.1 Sun May 1 00:41:10 2005 +++ cl-gsl/permutation.lisp Wed May 4 04:48:37 2005 @@ -21,7 +21,8 @@ (defclass gsl-permutation () ((ptr :accessor ptr :initarg :ptr) - (size :accessor size :initarg :size))) + (size :accessor size :initarg :size) + (element-type :accessor element-type :initform 'integer))) ;; ---------------------------------------------------------------------- @@ -85,8 +86,12 @@ ((p gsl-permutation-ptr)) :int) -(defmethod valid ((o gsl-permutation)) - (1/0->t/nil (gsl-permutation-valid (ptr o)))) +(defmethod isvalid ((o gsl-permutation)) + ;; The C function gsl_permutation_valid does not return when the + ;; permutation is invalid - instead it calls GSL_ERROR. + ;; It only returns a value when the permutation is valid. + (ignore-errors + (= (gsl-permutation-valid (ptr o)) +success+))) ;; ---------------------------------------------------------------------- @@ -266,26 +271,38 @@ (i 0 (1+ i))) ((= i size)) (set-element p i (car x))) - (unless (valid p) + (unless (isvalid p) (error "intitial contents are not a valid permutation."))) ((vectorp initial-contents) (do ((i 0 (1+ i))) ((= i size)) (set-element p i (aref initial-contents i))) - (unless (valid p) + (unless (isvalid p) (error "intitial contents are not a valid permutation."))) (t (error "initial-contents must be either a list or a vector.")))) (from-file (read-from-file p from-file) - (unless (valid p) + (unless (isvalid p) (error "file contents are not a valid permutation."))) (from-binary-file (read-from-binary-file p from-binary-file) - (unless (valid p) - (error "file contents are not a valid permutation.")))) + (unless (isvalid p) + (error "file contents are not a valid permutation."))) + (t + (permutation-init p))) p)) +(defmacro with-permutation ((p size &key initial-contents from-file + from-binary-file) + &body body) + `(let ((,p (make-permutation ,size :initial-contents ,initial-contents + :from-file ,from-file + :from-binary-file ,from-binary-file))) + (unwind-protect + (progn , at body) + (free ,p)))) + ;; ---------------------------------------------------------------------- (defun-foreign "gsl_permutation_memcpy" @@ -330,16 +347,18 @@ (p gsl-permutation-ptr)) :int) -(defmethod linear->canonical ((p gsl-permutation)) - (let* ((q (make-permutation (size p))) - (status (gsl-permutation-linear-to-canonical (ptr q) (ptr p)))) - (values q status))) - -(defmacro with-permutation-linear->canonical ((q p) &body body) - `(let ((,q (linear->canonical ,p))) +(defmethod linear->canonical ((p-can gsl-permutation) (p-lin gsl-permutation)) + (let ((status (gsl-permutation-linear-to-canonical (ptr p-can) (ptr p-lin)))) + (values p-can status))) + +(defmacro with-permutation-linear->canonical ((p-can p-lin) &body body) + (let ((p (gensym))) + `(let* ((,p ,p-lin) + (,p-can (make-permutation (size ,p)))) + (linear->canonical ,p-can ,p) (unwind-protect , at body - (free ,q)))) + (free ,p-can))))) ;; ---------------------------------------------------------------------- @@ -348,16 +367,18 @@ (q gsl-permutation-ptr)) :int) -(defmethod canonical->linear ((q gsl-permutation)) - (let* ((p (make-permutation (size q))) - (status (gsl-permutation-linear-to-canonical (ptr p) (ptr q)))) - (values p status))) - -(defmacro with-permutation-canonical->linear ((p q) &body body) - `(let ((,p (linear->canonical ,q))) - (unwind-protect - , at body - (free ,p)))) +(defmethod canonical->linear ((p-lin gsl-permutation) (p-can gsl-permutation)) + (let ((status (gsl-permutation-canonical-to-linear (ptr p-lin) (ptr p-can)))) + (values p-lin status))) + +(defmacro with-permutation-canonical->linear ((p-lin p-can) &body body) + (let ((p (gensym))) + `(let* ((,p ,p-can) + (,p-lin (make-permutation (size ,p)))) + (canonical->linear ,p-lin ,p) + (unwind-protect + , at body + (free ,p-lin))))) ;; ---------------------------------------------------------------------- @@ -386,3 +407,10 @@ (defmethod canonical-cycles ((o gsl-permutation)) (gsl-permutation-linear-cycles (ptr o))) +;; ---------------------------------------------------------------------- + +(defmethod set-element ((p gsl-permutation) i &optional x dummy) + (assert (typep x 'integer)) + (assert (and (typep i 'integer) (>= i 0) (< i (size p)))) + (let ((data-ptr (uffi:get-slot-pointer (ptr p) '(* size-t) 'cl-gsl::data))) + (setf (uffi:deref-array data-ptr 'size-t i) x))) From cl-gsl-cvs at common-lisp.net Wed May 4 02:50:44 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 4 May 2005 04:50:44 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/c/cwrapperstub.c Message-ID: <20050504025044.E4B118871F@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl/c In directory common-lisp.net:/tmp/cvs-serv30194 Modified Files: cwrapperstub.c Log Message: Minor modifications to the wrappers for reading and writing permutations to file. Date: Wed May 4 04:50:44 2005 Author: edenny Index: cl-gsl/c/cwrapperstub.c diff -u cl-gsl/c/cwrapperstub.c:1.5 cl-gsl/c/cwrapperstub.c:1.6 --- cl-gsl/c/cwrapperstub.c:1.5 Sun May 1 00:38:43 2005 +++ cl-gsl/c/cwrapperstub.c Wed May 4 04:50:44 2005 @@ -820,49 +820,49 @@ /* ----------------------------------------------------------------- */ -int wrap_gsl_permutation_fwrite(char *fn, const gsl_permutation *m) +int wrap_gsl_permutation_fwrite(char *fn, const gsl_permutation *p) { FILE* stream; int ret; stream = fopen(fn, "wb"); - ret = gsl_permutation_fwrite(stream, m); + ret = gsl_permutation_fwrite(stream, p); fclose(stream); return ret; } -int wrap_gsl_permutation_fread(char *fn, gsl_permutation *m) +int wrap_gsl_permutation_fread(char *fn, gsl_permutation *p) { FILE* stream; int ret; stream = fopen(fn, "rb"); - ret = gsl_permutation_fread(stream, m); + ret = gsl_permutation_fread(stream, p); fclose(stream); return ret; } -int wrap_gsl_permutation_fprintf(char *fn, const gsl_permutation *m) +int wrap_gsl_permutation_fprintf(char *fn, const gsl_permutation *p) { FILE* stream; int ret; stream = fopen(fn, "w"); - ret = gsl_permutation_fprintf(stream, m, "%d"); + ret = gsl_permutation_fprintf(stream, p, "%u\n"); fclose(stream); return ret; } -int wrap_gsl_permutation_fscanf(char *fn, gsl_permutation *m) +int wrap_gsl_permutation_fscanf(char *fn, gsl_permutation *p) { FILE* stream; int ret; stream = fopen(fn, "r"); - ret = gsl_permutation_fscanf(stream, m); + ret = gsl_permutation_fscanf(stream, p); fclose(stream); return ret; From cl-gsl-cvs at common-lisp.net Wed May 4 02:51:42 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 4 May 2005 04:51:42 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/test/cl-gsl-test.asd Message-ID: <20050504025142.7D2B68871F@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl/test In directory common-lisp.net:/tmp/cvs-serv30237 Modified Files: cl-gsl-test.asd Log Message: Added test-permutation to lsit of files in defsystem. Date: Wed May 4 04:51:41 2005 Author: edenny Index: cl-gsl/test/cl-gsl-test.asd diff -u cl-gsl/test/cl-gsl-test.asd:1.4 cl-gsl/test/cl-gsl-test.asd:1.5 --- cl-gsl/test/cl-gsl-test.asd:1.4 Mon Apr 25 04:14:32 2005 +++ cl-gsl/test/cl-gsl-test.asd Wed May 4 04:51:41 2005 @@ -35,6 +35,7 @@ (:file "tolerance" :depends-on ("package")) (:file "test-sf" :depends-on ("tolerance")) (:file "test-poly" :depends-on ("tolerance")) - (:file "test-vector" :depends-on ("tolerance")) - (:file "test-matrix" :depends-on ("tolerance")) + (:file "test-vector" :depends-on ("package")) + (:file "test-matrix" :depends-on ("package")) + (:file "test-permutation" :depends-on ("package")) )) From cl-gsl-cvs at common-lisp.net Wed May 4 02:52:26 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 4 May 2005 04:52:26 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/test/test-permutation.lisp Message-ID: <20050504025226.DC5BC8871F@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl/test In directory common-lisp.net:/tmp/cvs-serv30295 Added Files: test-permutation.lisp Log Message: Initial checkin. Date: Wed May 4 04:52:26 2005 Author: edenny From cl-gsl-cvs at common-lisp.net Wed May 4 02:54:46 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 4 May 2005 04:54:46 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/ChangeLog Message-ID: <20050504025446.46E4E8871F@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv30374 Modified Files: ChangeLog Log Message: *** empty log message *** Date: Wed May 4 04:54:45 2005 Author: edenny Index: cl-gsl/ChangeLog diff -u cl-gsl/ChangeLog:1.20 cl-gsl/ChangeLog:1.21 --- cl-gsl/ChangeLog:1.20 Sun May 1 00:41:36 2005 +++ cl-gsl/ChangeLog Wed May 4 04:54:45 2005 @@ -1,3 +1,45 @@ +2005-05-04 Edgar Denny + + * test/test-permutation.lisp: Initial checkin. + + * test/cl-gsl-test.asd: + Added test-permutation to list of files in defsystem. + + * c/cwrapperstub.c: + Minor modifications to the wrappers for reading and writing + permutations to file. + + * permutation.lisp: Completed adding the wrappers. + + * package.lisp: + Change symbol valid to isvalid. Add symbol with-permutation. + +2005-04-30 Edgar Denny + + * permutation.lisp: Initial checkin. + + * test/test-vector.lisp: Slight sylistic changes to a few unit tests. + + * c/cwrapperstub.c: + Added wrappers to read and write permutations from file. + + * c/Makefile: Changed cwrapperstub to gsl_cwrapper. + + * build/Makefile: Changed cwrappersub to gsl_cwrapper. + + * vector.lisp: Added a TODO note. + + * package.lisp: + Added symbols to be exported from cl-array due to permutations. + + * load-libraries.lisp: changed cwrappersub to gsl_cwrapper. + + * ffi.lisp: Added permutation structure and pointer. + + * cl-gsl.asd: Added permutation to the defsystem. + + * Makefile.common: Changed name of cwrapperstub.so to gsl_cwrapper.so + 2005-04-30 Edgar Denny * permutation.lisp: Initial checkin. From cl-gsl-cvs at common-lisp.net Wed May 11 02:41:39 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 11 May 2005 04:41:39 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/cl-gsl.asd Message-ID: <20050511024139.5607488736@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv9051 Modified Files: cl-gsl.asd Log Message: Add sort file. Date: Wed May 11 04:41:36 2005 Author: edenny Index: cl-gsl/cl-gsl.asd diff -u cl-gsl/cl-gsl.asd:1.3 cl-gsl/cl-gsl.asd:1.4 --- cl-gsl/cl-gsl.asd:1.3 Sun May 1 00:33:10 2005 +++ cl-gsl/cl-gsl.asd Wed May 11 04:41:36 2005 @@ -41,6 +41,7 @@ (:file "poly" :depends-on ("util" "ffi")) (:file "sf" :depends-on ("util" "ffi")) (:file "vector" :depends-on ("util" "ffi")) - (:file "matrix" :depends-on ("util" "ffi")) - (:file "permutation" :depends-on ("util" "ffi")) + (:file "matrix" :depends-on ("util" "ffi" "vector")) + (:file "permutation" :depends-on ("util" "ffi" "vector")) + (:file "sort" :depends-on ("util" "ffi" "permutation")) )) From cl-gsl-cvs at common-lisp.net Wed May 11 02:42:25 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 11 May 2005 04:42:25 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/package.lisp Message-ID: <20050511024225.35B3588736@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv9100 Modified Files: package.lisp Log Message: Add symbols to be exported from sort. Date: Wed May 11 04:42:25 2005 Author: edenny Index: cl-gsl/package.lisp diff -u cl-gsl/package.lisp:1.11 cl-gsl/package.lisp:1.12 --- cl-gsl/package.lisp:1.11 Wed May 4 04:47:01 2005 +++ cl-gsl/package.lisp Wed May 11 04:42:24 2005 @@ -181,4 +181,9 @@ #:inversions #:linear-cycles #:canonical-cycles + + ;; from sort + #:sort-vector + #:sort-vector-index + #:with-sort-vector-index )) From cl-gsl-cvs at common-lisp.net Wed May 11 02:43:03 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 11 May 2005 04:43:03 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/test/cl-gsl-test.asd Message-ID: <20050511024303.4970788736@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl/test In directory common-lisp.net:/tmp/cvs-serv9143 Modified Files: cl-gsl-test.asd Log Message: Add test-sort file. Date: Wed May 11 04:43:02 2005 Author: edenny Index: cl-gsl/test/cl-gsl-test.asd diff -u cl-gsl/test/cl-gsl-test.asd:1.5 cl-gsl/test/cl-gsl-test.asd:1.6 --- cl-gsl/test/cl-gsl-test.asd:1.5 Wed May 4 04:51:41 2005 +++ cl-gsl/test/cl-gsl-test.asd Wed May 11 04:43:02 2005 @@ -38,4 +38,5 @@ (:file "test-vector" :depends-on ("package")) (:file "test-matrix" :depends-on ("package")) (:file "test-permutation" :depends-on ("package")) + (:file "test-sort" :depends-on ("package")) )) From cl-gsl-cvs at common-lisp.net Wed May 11 02:45:35 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 11 May 2005 04:45:35 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/sort.lisp Message-ID: <20050511024535.10E4E88736@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv9610 Added Files: sort.lisp Log Message: Initial checkin. Date: Wed May 11 04:45:34 2005 Author: edenny From cl-gsl-cvs at common-lisp.net Wed May 11 02:46:37 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 11 May 2005 04:46:37 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/test/test-sort.lisp Message-ID: <20050511024637.20F0788736@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl/test In directory common-lisp.net:/tmp/cvs-serv9818 Added Files: test-sort.lisp Log Message: Initial checkin. Date: Wed May 11 04:46:36 2005 Author: edenny From cl-gsl-cvs at common-lisp.net Wed May 11 02:48:28 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Wed, 11 May 2005 04:48:28 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/ChangeLog Message-ID: <20050511024828.279A088736@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv10188 Modified Files: ChangeLog Log Message: *** empty log message *** Date: Wed May 11 04:48:27 2005 Author: edenny Index: cl-gsl/ChangeLog diff -u cl-gsl/ChangeLog:1.21 cl-gsl/ChangeLog:1.22 --- cl-gsl/ChangeLog:1.21 Wed May 4 04:54:45 2005 +++ cl-gsl/ChangeLog Wed May 11 04:48:27 2005 @@ -1,3 +1,13 @@ +2005-05-11 Edgar Denny + + * test/test-sort.lisp, sort.lisp: Initial checkin. + + * test/cl-gsl-test.asd: Add test-sort file. + + * package.lisp: Add symbols to be exported from sort. + + * cl-gsl.asd: Add sort file. + 2005-05-04 Edgar Denny * test/test-permutation.lisp: Initial checkin. From cl-gsl-cvs at common-lisp.net Mon May 16 01:24:19 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Mon, 16 May 2005 03:24:19 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/random-number-generator.lisp Message-ID: <20050516012419.D6526880A4@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv355 Added Files: random-number-generator.lisp Log Message: Initial check in. Date: Mon May 16 03:24:19 2005 Author: edenny From cl-gsl-cvs at common-lisp.net Mon May 16 01:25:06 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Mon, 16 May 2005 03:25:06 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/cl-gsl.asd Message-ID: <20050516012506.53656880A4@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv377 Modified Files: cl-gsl.asd Log Message: Add random-number-generator to list of files. Date: Mon May 16 03:25:05 2005 Author: edenny Index: cl-gsl/cl-gsl.asd diff -u cl-gsl/cl-gsl.asd:1.4 cl-gsl/cl-gsl.asd:1.5 --- cl-gsl/cl-gsl.asd:1.4 Wed May 11 04:41:36 2005 +++ cl-gsl/cl-gsl.asd Mon May 16 03:25:05 2005 @@ -44,4 +44,5 @@ (:file "matrix" :depends-on ("util" "ffi" "vector")) (:file "permutation" :depends-on ("util" "ffi" "vector")) (:file "sort" :depends-on ("util" "ffi" "permutation")) + (:file "random-number-generator" :depends-on ("util" "ffi")) )) From cl-gsl-cvs at common-lisp.net Mon May 16 01:29:37 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Mon, 16 May 2005 03:29:37 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/ffi.lisp Message-ID: <20050516012937.1A055880A4@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv420 Modified Files: ffi.lisp Log Message: Add random-number-generator foreign types. Date: Mon May 16 03:29:36 2005 Author: edenny Index: cl-gsl/ffi.lisp diff -u cl-gsl/ffi.lisp:1.6 cl-gsl/ffi.lisp:1.7 --- cl-gsl/ffi.lisp:1.6 Sun May 1 00:34:25 2005 +++ cl-gsl/ffi.lisp Mon May 16 03:29:36 2005 @@ -140,6 +140,9 @@ (size-t-ptr '(* size-t)) (gsl-permutation-ptr '(* gsl-permutation-struct)) + + (gsl-rng-type-ptr '(* :void)) + (gsl-rng-ptr '(* :void)) )))) (register-foreign-types) From cl-gsl-cvs at common-lisp.net Mon May 16 01:30:25 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Mon, 16 May 2005 03:30:25 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/package.lisp Message-ID: <20050516013025.59BC4880A4@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv708 Modified Files: package.lisp Log Message: Add cgl-gsl-rng defpackage and symbols. Date: Mon May 16 03:30:23 2005 Author: edenny Index: cl-gsl/package.lisp diff -u cl-gsl/package.lisp:1.12 cl-gsl/package.lisp:1.13 --- cl-gsl/package.lisp:1.12 Wed May 11 04:42:24 2005 +++ cl-gsl/package.lisp Mon May 16 03:30:23 2005 @@ -187,3 +187,24 @@ #:sort-vector-index #:with-sort-vector-index )) + +(defpackage #:cl-gsl-rng + (:nicknames #:gsl-rng) + (:use #:cl #:cl-gsl) + (:export + #:make-generator + #:free-generator + #:with-generator + #:seed + #:get-integer + #:get-double-float + #:get-double-float-pos + #:get-integer-in-range + #:generator-name + #:generator-max + #:generator-min + #:clone + #:with-clone + #:write-state-to-file + #:read-state-from-file + )) From cl-gsl-cvs at common-lisp.net Mon May 16 01:31:23 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Mon, 16 May 2005 03:31:23 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/c/cwrapperstub.c Message-ID: <20050516013123.A6AC4880A4@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl/c In directory common-lisp.net:/tmp/cvs-serv1293 Modified Files: cwrapperstub.c Log Message: Add wrappers for random-number-generator functions. Date: Mon May 16 03:31:17 2005 Author: edenny Index: cl-gsl/c/cwrapperstub.c diff -u cl-gsl/c/cwrapperstub.c:1.6 cl-gsl/c/cwrapperstub.c:1.7 --- cl-gsl/c/cwrapperstub.c:1.6 Wed May 4 04:50:44 2005 +++ cl-gsl/c/cwrapperstub.c Mon May 16 03:31:16 2005 @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -863,6 +864,164 @@ stream = fopen(fn, "r"); ret = gsl_permutation_fscanf(stream, p); + fclose(stream); + + return ret; +} + +gsl_rng *wrap_gsl_rng_set_type(char *tp) +{ + gsl_rng *r; + + if (strncmp( "borosh13", tp, 8) == 0) + r = gsl_rng_alloc (gsl_rng_borosh13); + else if (strncmp( "coveyou", tp, 7) == 0) + r = gsl_rng_alloc(gsl_rng_coveyou); + else if (strncmp( "cmrg", tp, 4) == 0) + r = gsl_rng_alloc(gsl_rng_cmrg); + else if (strncmp( "fishman18", tp, 9) == 0) + r = gsl_rng_alloc(gsl_rng_fishman18); + else if (strncmp( "fishman20", tp, 9) == 0) + r = gsl_rng_alloc(gsl_rng_fishman20); + else if (strncmp( "fishman2x", tp, 9) == 0) + r = gsl_rng_alloc(gsl_rng_fishman2x); + else if (strncmp( "gfsr4", tp, 5) == 0) + r = gsl_rng_alloc(gsl_rng_gfsr4); + else if (strncmp( "knuthran", tp, 8) == 0) + r = gsl_rng_alloc(gsl_rng_knuthran); + else if (strncmp( "knuthran2", tp, 9) == 0) + r = gsl_rng_alloc(gsl_rng_knuthran2); + else if (strncmp( "lecuyer21", tp, 9) == 0) + r = gsl_rng_alloc(gsl_rng_lecuyer21); + else if (strncmp( "minstd", tp, 6) == 0) + r = gsl_rng_alloc(gsl_rng_minstd); + else if (strncmp( "mrg", tp, 3) == 0) + r = gsl_rng_alloc(gsl_rng_mrg); + else if (strncmp( "mt19937", tp, 7) == 0) + r = gsl_rng_alloc(gsl_rng_mt19937); + else if (strncmp( "mt19937-1999", tp, 12) == 0) + r = gsl_rng_alloc(gsl_rng_mt19937_1999); + else if (strncmp( "mt19937-1998", tp, 12) == 0) + r = gsl_rng_alloc(gsl_rng_mt19937_1998); + else if (strncmp( "r250", tp, 4) == 0) + r = gsl_rng_alloc(gsl_rng_r250); + else if (strncmp( "ran0", tp, 4) == 0) + r = gsl_rng_alloc(gsl_rng_ran0); + else if (strncmp( "ran1", tp, 4) == 0) + r = gsl_rng_alloc(gsl_rng_ran1); + else if (strncmp( "ran2", tp, 4) == 0) + r = gsl_rng_alloc(gsl_rng_ran2); + else if (strncmp( "ran3", tp, 4) == 0) + r = gsl_rng_alloc(gsl_rng_ran3); + else if (strncmp( "rand", tp, 4) == 0) + r = gsl_rng_alloc(gsl_rng_rand); + else if (strncmp( "rand48", tp, 6) == 0) + r = gsl_rng_alloc(gsl_rng_rand48); + else if (strncmp( "random128-bsd", tp, 13) == 0) + r = gsl_rng_alloc(gsl_rng_random128_bsd); + else if (strncmp( "random128-glibc2", tp, 16) == 0) + r = gsl_rng_alloc(gsl_rng_random128_glibc2); + else if (strncmp( "random128-libc5", tp, 15) == 0) + r = gsl_rng_alloc(gsl_rng_random128_libc5); + else if (strncmp( "random256-bsd", tp, 13) == 0) + r = gsl_rng_alloc(gsl_rng_random256_bsd); + else if (strncmp( "random256-glibc2", tp, 16) == 0) + r = gsl_rng_alloc(gsl_rng_random256_glibc2); + else if (strncmp( "random256-libc5", tp, 15) == 0) + r = gsl_rng_alloc(gsl_rng_random256_libc5); + else if (strncmp( "random32-bsd", tp, 12) == 0) + r = gsl_rng_alloc(gsl_rng_random32_bsd); + else if (strncmp( "random32-glibc2", tp, 15) == 0) + r = gsl_rng_alloc(gsl_rng_random32_glibc2); + else if (strncmp( "random32-libc5", tp, 14) == 0) + r = gsl_rng_alloc(gsl_rng_random32_libc5); + else if (strncmp( "random64-bsd", tp, 12) == 0) + r = gsl_rng_alloc(gsl_rng_random64_bsd); + else if (strncmp( "random64-glibc2", tp, 15) == 0) + r = gsl_rng_alloc(gsl_rng_random64_glibc2); + else if (strncmp( "random64-libc5", tp, 14) == 0) + r = gsl_rng_alloc(gsl_rng_random64_libc5); + else if (strncmp( "random8-bsd", tp, 11) == 0) + r = gsl_rng_alloc(gsl_rng_random8_bsd); + else if (strncmp( "random8-glibc2", tp, 14) == 0) + r = gsl_rng_alloc(gsl_rng_random8_glibc2); + else if (strncmp( "random8-libc5", tp, 13) == 0) + r = gsl_rng_alloc(gsl_rng_random8_libc5); + else if (strncmp( "random-bsd", tp, 10) == 0) + r = gsl_rng_alloc(gsl_rng_random_bsd); + else if (strncmp( "random-glibc2", tp, 13) == 0) + r = gsl_rng_alloc(gsl_rng_random_glibc2); + else if (strncmp( "random-libc5", tp, 12) == 0) + r = gsl_rng_alloc(gsl_rng_random_libc5); + else if (strncmp( "randu", tp, 5) == 0) + r = gsl_rng_alloc(gsl_rng_randu); + else if (strncmp( "ranf", tp, 4) == 0) + r = gsl_rng_alloc(gsl_rng_ranf); + else if (strncmp( "ranlux", tp, 6) == 0) + r = gsl_rng_alloc(gsl_rng_ranlux); + else if (strncmp( "ranlux389", tp, 9) == 0) + r = gsl_rng_alloc(gsl_rng_ranlux389); + else if (strncmp( "ranlxd1", tp, 7) == 0) + r = gsl_rng_alloc(gsl_rng_ranlxd1); + else if (strncmp( "ranlxd2", tp, 7) == 0) + r = gsl_rng_alloc(gsl_rng_ranlxd2); + else if (strncmp( "ranlxs0", tp, 7) == 0) + r = gsl_rng_alloc(gsl_rng_ranlxs0); + else if (strncmp( "ranlxs1", tp, 7) == 0) + r = gsl_rng_alloc(gsl_rng_ranlxs1); + else if (strncmp( "ranlxs2", tp, 7) == 0) + r = gsl_rng_alloc(gsl_rng_ranlxs2); + else if (strncmp( "ranmar", tp, 6) == 0) + r = gsl_rng_alloc(gsl_rng_ranmar); + else if (strncmp( "slatec", tp, 6) == 0) + r = gsl_rng_alloc(gsl_rng_slatec); + else if (strncmp( "taus", tp, 4) == 0) + r = gsl_rng_alloc(gsl_rng_taus); + else if (strncmp( "taus2", tp, 5) == 0) + r = gsl_rng_alloc(gsl_rng_taus2); + else if (strncmp( "taus113", tp, 7) == 0) + r = gsl_rng_alloc(gsl_rng_taus113); + else if (strncmp( "transputer", tp, 10) == 0) + r = gsl_rng_alloc(gsl_rng_transputer); + else if (strncmp( "tt800", tp, 5) == 0) + r = gsl_rng_alloc(gsl_rng_tt800); + else if (strncmp( "uni", tp, 3) == 0) + r = gsl_rng_alloc(gsl_rng_uni); + else if (strncmp( "uni32", tp, 5) == 0) + r = gsl_rng_alloc(gsl_rng_uni32); + else if (strncmp( "vax", tp, 3) == 0) + r = gsl_rng_alloc(gsl_rng_vax); + else if (strncmp( "waterman14", tp, 10) == 0) + r = gsl_rng_alloc(gsl_rng_waterman14); + else if (strncmp( "zuf", tp, 3) == 0) + r = gsl_rng_alloc(gsl_rng_zuf); + else + r = gsl_rng_alloc(gsl_rng_default); + + return r; +} + +/* ----------------------------------------------------------------- */ + +int wrap_gsl_rng_fwrite(char *fn, const gsl_rng *r) +{ + FILE* stream; + int ret; + + stream = fopen(fn, "wb"); + ret = gsl_rng_fwrite(stream, r); + fclose(stream); + + return ret; +} + +int wrap_gsl_rng_fread(char *fn, gsl_rng *r) +{ + FILE* stream; + int ret; + + stream = fopen(fn, "rb"); + ret = gsl_rng_fread(stream, r); fclose(stream); return ret; From cl-gsl-cvs at common-lisp.net Mon May 16 01:32:50 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Mon, 16 May 2005 03:32:50 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/ChangeLog Message-ID: <20050516013250.16E38880A4@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl In directory common-lisp.net:/tmp/cvs-serv1330 Modified Files: ChangeLog Log Message: *** empty log message *** Date: Mon May 16 03:32:49 2005 Author: edenny Index: cl-gsl/ChangeLog diff -u cl-gsl/ChangeLog:1.22 cl-gsl/ChangeLog:1.23 --- cl-gsl/ChangeLog:1.22 Wed May 11 04:48:27 2005 +++ cl-gsl/ChangeLog Mon May 16 03:32:49 2005 @@ -1,3 +1,15 @@ +2005-05-16 Edgar Denny + + * c/cwrapperstub.c: Add wrappers for random-number-generator functions. + + * package.lisp: Add cgl-gsl-rng defpackage and symbols. + + * ffi.lisp: Add random-number-generator foreign types. + + * cl-gsl.asd: Add random-number-generator to list of files. + + * random-number-generator.lisp: Initial check in. + 2005-05-11 Edgar Denny * test/test-sort.lisp, sort.lisp: Initial checkin. @@ -24,7 +36,7 @@ * package.lisp: Change symbol valid to isvalid. Add symbol with-permutation. -2005-04-30 Edgar Denny +2005-04-30 Edgar Denny * permutation.lisp: Initial checkin. From cl-gsl-cvs at common-lisp.net Tue May 17 00:53:36 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Tue, 17 May 2005 02:53:36 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/test/test-random-number-generator.lisp Message-ID: <20050517005336.5BB518871A@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl/test In directory common-lisp.net:/tmp/cvs-serv23241 Added Files: test-random-number-generator.lisp Log Message: Initial check in. Date: Tue May 17 02:53:35 2005 Author: edenny From cl-gsl-cvs at common-lisp.net Tue May 17 00:54:03 2005 From: cl-gsl-cvs at common-lisp.net (cl-gsl-cvs at common-lisp.net) Date: Tue, 17 May 2005 02:54:03 +0200 (CEST) Subject: [cl-gsl-cvs] CVS update: cl-gsl/c/cwrapperstub.c Message-ID: <20050517005403.080308871A@common-lisp.net> Update of /project/cl-gsl/cvsroot/cl-gsl/c In directory common-lisp.net:/tmp/cvs-serv23262 Modified Files: cwrapperstub.c Log Message: Fixes for random-number-generator. Date: Tue May 17 02:54:03 2005 Author: edenny Index: cl-gsl/c/cwrapperstub.c diff -u cl-gsl/c/cwrapperstub.c:1.7 cl-gsl/c/cwrapperstub.c:1.8 --- cl-gsl/c/cwrapperstub.c:1.7 Mon May 16 03:31:16 2005 +++ cl-gsl/c/cwrapperstub.c Tue May 17 02:54:03 2005 @@ -887,22 +887,22 @@ r = gsl_rng_alloc(gsl_rng_fishman2x); else if (strncmp( "gfsr4", tp, 5) == 0) r = gsl_rng_alloc(gsl_rng_gfsr4); - else if (strncmp( "knuthran", tp, 8) == 0) - r = gsl_rng_alloc(gsl_rng_knuthran); else if (strncmp( "knuthran2", tp, 9) == 0) r = gsl_rng_alloc(gsl_rng_knuthran2); + else if (strncmp( "knuthran", tp, 8) == 0) + r = gsl_rng_alloc(gsl_rng_knuthran); else if (strncmp( "lecuyer21", tp, 9) == 0) r = gsl_rng_alloc(gsl_rng_lecuyer21); else if (strncmp( "minstd", tp, 6) == 0) r = gsl_rng_alloc(gsl_rng_minstd); else if (strncmp( "mrg", tp, 3) == 0) r = gsl_rng_alloc(gsl_rng_mrg); - else if (strncmp( "mt19937", tp, 7) == 0) - r = gsl_rng_alloc(gsl_rng_mt19937); else if (strncmp( "mt19937-1999", tp, 12) == 0) r = gsl_rng_alloc(gsl_rng_mt19937_1999); else if (strncmp( "mt19937-1998", tp, 12) == 0) r = gsl_rng_alloc(gsl_rng_mt19937_1998); + else if (strncmp( "mt19937", tp, 7) == 0) + r = gsl_rng_alloc(gsl_rng_mt19937); else if (strncmp( "r250", tp, 4) == 0) r = gsl_rng_alloc(gsl_rng_r250); else if (strncmp( "ran0", tp, 4) == 0) @@ -913,8 +913,8 @@ r = gsl_rng_alloc(gsl_rng_ran2); else if (strncmp( "ran3", tp, 4) == 0) r = gsl_rng_alloc(gsl_rng_ran3); - else if (strncmp( "rand", tp, 4) == 0) - r = gsl_rng_alloc(gsl_rng_rand); + else if (strncmp( "randu", tp, 5) == 0) + r = gsl_rng_alloc(gsl_rng_randu); else if (strncmp( "rand48", tp, 6) == 0) r = gsl_rng_alloc(gsl_rng_rand48); else if (strncmp( "random128-bsd", tp, 13) == 0) @@ -953,14 +953,14 @@ r = gsl_rng_alloc(gsl_rng_random_glibc2); else if (strncmp( "random-libc5", tp, 12) == 0) r = gsl_rng_alloc(gsl_rng_random_libc5); - else if (strncmp( "randu", tp, 5) == 0) - r = gsl_rng_alloc(gsl_rng_randu); + else if (strncmp( "rand", tp, 4) == 0) + r = gsl_rng_alloc(gsl_rng_rand); else if (strncmp( "ranf", tp, 4) == 0) r = gsl_rng_alloc(gsl_rng_ranf); - else if (strncmp( "ranlux", tp, 6) == 0) - r = gsl_rng_alloc(gsl_rng_ranlux); else if (strncmp( "ranlux389", tp, 9) == 0) r = gsl_rng_alloc(gsl_rng_ranlux389); + else if (strncmp( "ranlux", tp, 6) == 0) + r = gsl_rng_alloc(gsl_rng_ranlux); else if (strncmp( "ranlxd1", tp, 7) == 0) r = gsl_rng_alloc(gsl_rng_ranlxd1); else if (strncmp( "ranlxd2", tp, 7) == 0) @@ -975,20 +975,20 @@ r = gsl_rng_alloc(gsl_rng_ranmar); else if (strncmp( "slatec", tp, 6) == 0) r = gsl_rng_alloc(gsl_rng_slatec); - else if (strncmp( "taus", tp, 4) == 0) - r = gsl_rng_alloc(gsl_rng_taus); - else if (strncmp( "taus2", tp, 5) == 0) - r = gsl_rng_alloc(gsl_rng_taus2); else if (strncmp( "taus113", tp, 7) == 0) r = gsl_rng_alloc(gsl_rng_taus113); + else if (strncmp( "taus2", tp, 5) == 0) + r = gsl_rng_alloc(gsl_rng_taus2); + else if (strncmp( "taus", tp, 4) == 0) + r = gsl_rng_alloc(gsl_rng_taus); else if (strncmp( "transputer", tp, 10) == 0) r = gsl_rng_alloc(gsl_rng_transputer); else if (strncmp( "tt800", tp, 5) == 0) r = gsl_rng_alloc(gsl_rng_tt800); - else if (strncmp( "uni", tp, 3) == 0) - r = gsl_rng_alloc(gsl_rng_uni); else if (strncmp( "uni32", tp, 5) == 0) r = gsl_rng_alloc(gsl_rng_uni32); + else if (strncmp( "uni", tp, 3) == 0) + r = gsl_rng_alloc(gsl_rng_uni); else if (strncmp( "vax", tp, 3) == 0) r = gsl_rng_alloc(gsl_rng_vax); else if (strncmp( "waterman14", tp, 10) == 0)