Skip to content
Snippets Groups Projects
Commit fc8a8ad5 authored by Liam M. Healy's avatar Liam M. Healy
Browse files

For combinations, foreign slot name 'range instead of 'choice-of

For combinations, name the foreign slot 'range instead of 'choice-of
and eliminate the separate CL slot and method, using
#'combination-range instead.
parent add07a4f
No related branches found
No related tags found
No related merge requests found
;; CFFI-Grovel definitions for unix systems. ;; CFFI-Grovel definitions for unix systems.
;; Liam Healy 2009-06-06 09:36:29EDT array-structs.lisp ;; Liam Healy 2009-06-06 09:36:29EDT array-structs.lisp
;; Time-stamp: <2009-12-27 09:42:07EST array-structs.lisp> ;; Time-stamp: <2010-06-30 10:16:32EDT array-structs.lisp>
;; ;;
;; Copyright 2009 Liam M. Healy ;; Copyright 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
...@@ -62,6 +62,6 @@ ...@@ -62,6 +62,6 @@
(include "gsl/gsl_combination.h") (include "gsl/gsl_combination.h")
(cstruct gsl-combination-c "gsl_combination" (cstruct gsl-combination-c "gsl_combination"
(choice-of "n" :type sizet) (range "n" :type sizet)
(size "k" :type sizet) (size "k" :type sizet)
(data "data" :type :pointer)) (data "data" :type :pointer))
;; Combinations ;; Combinations
;; Liam Healy, Sun Mar 26 2006 - 11:51 ;; Liam Healy, Sun Mar 26 2006 - 11:51
;; Time-stamp: <2010-06-29 19:48:55EDT combination.lisp> ;; Time-stamp: <2010-06-30 10:17:52EDT combination.lisp>
;; ;;
;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy ;; Copyright 2006, 2007, 2008, 2009 Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
...@@ -28,19 +28,18 @@ ...@@ -28,19 +28,18 @@
(defclass combination (defclass combination
(#+int64 grid:vector-unsigned-byte-64 #+int32 grid:vector-unsigned-byte-32) (#+int64 grid:vector-unsigned-byte-64 #+int32 grid:vector-unsigned-byte-32)
((choice-of :initarg :choice-of :reader choice-of :type (integer 0) ()
:documentation "Maximum possible value; n in the (n k) notation."))
(:documentation "GSL combinations.")) (:documentation "GSL combinations."))
(defmethod initialize-instance :after (defmethod initialize-instance :after
((object combination) &key choice-of dimensions &allow-other-keys) ((object combination) &key range dimensions &allow-other-keys)
(let ((mptr (cffi:foreign-alloc 'gsl-combination-c))) (let ((mptr (cffi:foreign-alloc 'gsl-combination-c)))
(setf (metadata-slot object 'mpointer) (setf (metadata-slot object 'mpointer)
mptr mptr
(cffi:foreign-slot-value mptr 'gsl-combination-c 'data) (cffi:foreign-slot-value mptr 'gsl-combination-c 'data)
(foreign-pointer object) (foreign-pointer object)
(cffi:foreign-slot-value mptr 'gsl-combination-c 'choice-of) (cffi:foreign-slot-value mptr 'gsl-combination-c 'range)
choice-of range
(cffi:foreign-slot-value mptr 'gsl-combination-c 'size) (cffi:foreign-slot-value mptr 'gsl-combination-c 'size)
(first dimensions)) (first dimensions))
(tg:finalize object (lambda () (cffi:foreign-free mptr))))) (tg:finalize object (lambda () (cffi:foreign-free mptr)))))
...@@ -57,11 +56,11 @@ ...@@ -57,11 +56,11 @@
(make-instance (make-instance
'combination 'combination
:element-type '(unsigned-byte #+int64 64 #+int32 32) :element-type '(unsigned-byte #+int64 64 #+int32 32)
:choice-of (choice-of n) :dimensions (dimensions k)) :range (combination-range n) :dimensions (dimensions k))
(make-instance (make-instance
'combination 'combination
:element-type '(unsigned-byte #+int64 64 #+int32 32) :element-type '(unsigned-byte #+int64 64 #+int32 32)
:choice-of n :dimensions (list k))))) :range n :dimensions (list k)))))
(when initialize (when initialize
(if (typep n 'combination) (if (typep n 'combination)
(error "not available yet") ; (copy comb n) (error "not available yet") ; (copy comb n)
...@@ -70,7 +69,7 @@ ...@@ -70,7 +69,7 @@
(defmethod print-object ((object combination) stream) (defmethod print-object ((object combination) stream)
(print-unreadable-object (object stream :type t) (print-unreadable-object (object stream :type t)
;(format stream " choice of ~d " (choice-of object)) (format stream "range ~d: " (combination-range object))
(princ (grid:contents object) stream))) (princ (grid:contents object) stream)))
;;;;**************************************************************************** ;;;;****************************************************************************
...@@ -120,7 +119,8 @@ ...@@ -120,7 +119,8 @@
:c-return sizet :c-return sizet
:inputs (c) :inputs (c)
:documentation ; FDL :documentation ; FDL
"The range (n) of the combination c.") "The range (n), or maximum possible value (n in the (n k) notation)
of the combination c.")
(defmfun size ((c combination)) (defmfun size ((c combination))
"gsl_combination_k" "gsl_combination_k"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment