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
;; CFFI-Grovel definitions for unix systems.
;; 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
;; Distributed under the terms of the GNU General Public License
......@@ -62,6 +62,6 @@
(include "gsl/gsl_combination.h")
(cstruct gsl-combination-c "gsl_combination"
(choice-of "n" :type sizet)
(range "n" :type sizet)
(size "k" :type sizet)
(data "data" :type :pointer))
;; Combinations
;; 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
;; Distributed under the terms of the GNU General Public License
......@@ -28,19 +28,18 @@
(defclass combination
(#+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."))
(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)))
(setf (metadata-slot object 'mpointer)
(cffi:foreign-slot-value mptr 'gsl-combination-c 'data)
(foreign-pointer object)
(cffi:foreign-slot-value mptr 'gsl-combination-c 'choice-of)
(cffi:foreign-slot-value mptr 'gsl-combination-c 'range)
(cffi:foreign-slot-value mptr 'gsl-combination-c 'size)
(first dimensions))
(tg:finalize object (lambda () (cffi:foreign-free mptr)))))
......@@ -57,11 +56,11 @@
:element-type '(unsigned-byte #+int64 64 #+int32 32)
:choice-of (choice-of n) :dimensions (dimensions k))
:range (combination-range n) :dimensions (dimensions k))
:element-type '(unsigned-byte #+int64 64 #+int32 32)
:choice-of n :dimensions (list k)))))
:range n :dimensions (list k)))))
(when initialize
(if (typep n 'combination)
(error "not available yet") ; (copy comb n)
......@@ -70,7 +69,7 @@
(defmethod print-object ((object combination) stream)
(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)))
......@@ -120,7 +119,8 @@
:c-return sizet
:inputs (c)
: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))
Supports Markdown
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