From 898260bd147d92765d300e04cad0d2835d6b5f31 Mon Sep 17 00:00:00 2001
From: "Liam M. Healy" <lhealy@common-lisp.net>
Date: Mon, 12 Sep 2011 18:03:52 -0400
Subject: [PATCH] Use generic functions for histogram

Define methods for existing generic functions for histogram:
grid:dimensions (replacing #'bins), set-zero (replacing #'reset).
Also, add a comment that the functions for 2D histogram have not been
defined as a "to be done" reminder.
---
 histogram/updating-accessing.lisp | 18 ++++++++++++------
 tests/histogram.lisp              |  2 +-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/histogram/updating-accessing.lisp b/histogram/updating-accessing.lisp
index ca3f81b1..1c83e56d 100644
--- a/histogram/updating-accessing.lisp
+++ b/histogram/updating-accessing.lisp
@@ -1,8 +1,8 @@
 ;; Updating and accessing histogram elements.
 ;; Liam Healy, Mon Jan  1 2007 - 14:43
-;; Time-stamp: <2011-05-26 12:37:35EDT updating-accessing.lisp>
+;; Time-stamp: <2011-09-12 17:35:27EDT updating-accessing.lisp>
 ;;
-;; Copyright 2007, 2008, 2009 Liam M. Healy
+;; Copyright 2007, 2008, 2009, 2011 Liam M. Healy
 ;; Distributed under the terms of the GNU General Public License
 ;;
 ;; This program is free software: you can redistribute it and/or modify
@@ -23,6 +23,9 @@
 ;;; /usr/include/gsl/gsl_histogram.h
 ;;; /usr/include/gsl/gsl_histogram2d.h
 
+;;; Missing: 2D functions/methods; the 1D functions will need to be made into methods if not already.
+;;; http://www.gnu.org/s/gsl/manual/html_node/Updating-and-accessing-2D-histogram-elements.html
+
 (defmfun increment (histogram value &optional weight)
   ("gsl_histogram_increment" "gsl_histogram_accumulate")
   ((((mpointer histogram) :pointer) (value :double))
@@ -82,16 +85,19 @@
   :documentation			; FDL
   "The minimum lower range limit of the histogram.")
 
-(defmfun bins (histogram)
+(defmfun grid:dimensions ((histogram histogram))
   "gsl_histogram_bins"
   (((mpointer histogram) :pointer))
-  :c-return sizet
+  :definition :method
+  :c-return (dim sizet)
+  :return ((list dim))
   :documentation			; FDL
   "The number of bins in the histogram.")
 
-(defmfun reset (histogram)
+(defmfun set-zero ((histogram histogram))
   "gsl_histogram_reset"
   (((mpointer histogram) :pointer))
+  :definition :method
   :c-return :void
   :documentation			; FDL
   "Reset all the bins in the histogram to zero.")
@@ -153,7 +159,7 @@
    (set-ranges-uniform histo 0.0d0 10.0d0)
    (increment histo 2.7d0)
    (increment histo 6.9d0 2.0d0)
-   (bins histo))
+   (grid:dimensions histo))
  (let ((histo (make-histogram 10)))
    (set-ranges-uniform histo 0.0d0 10.0d0)
    (increment histo 2.7d0)
diff --git a/tests/histogram.lisp b/tests/histogram.lisp
index d37108b1..993c6c0a 100644
--- a/tests/histogram.lisp
+++ b/tests/histogram.lisp
@@ -107,7 +107,7 @@
                                                              (INCREMENT HISTO
                                                                         6.9d0
                                                                         2.0d0)
-                                                             (BINS HISTO))))
+                                                             (first (grid:dimensions HISTO)))))
                        (LISP-UNIT::ASSERT-NUMERICAL-EQUAL (LIST 5)
                                                           (MULTIPLE-VALUE-LIST
                                                            (LET ((HISTO
-- 
GitLab