Commit 898260bd authored by Liam M. Healy's avatar Liam M. Healy Committed by Liam M. Healy
Browse files

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.
parent 972ceacf
;; 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)
......
......@@ -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
......
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