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

Merge branch 'master' into multiple-systems

parents 0b408437 b2f6ae1f
No related branches found
No related tags found
No related merge requests found
;; The histogram structure
;; Liam Healy, Mon Jan 1 2007 - 11:32
;; Time-stamp: <2013-05-03 15:46:46EDT histogram.lisp>
;; Time-stamp: <2013-10-04 10:40:54EDT histogram.lisp>
;;
;; Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -129,3 +129,29 @@
(if destination
(histo2d-copy destination source)
(histo2d-clone destination)))
;;;;****************************************************************************
;;; Experimental direct access to vector
;;; Note this does not grovel.
(cffi:defcstruct histogram-c
(n :sizet)
(range :pointer)
(bin :pointer))
(defun view-bin-as-foreign-array (histogram)
"A view of the histogram bin counts as a foreign array. The two objects point to the same foreign data."
;; 1D histograms only so far
(grid:make-foreign-array-from-pointer
(cffi:foreign-slot-value (mpointer histogram) '(:struct histogram-c) 'bin)
(grid:dimensions histogram)
'double-float
nil))
(defun view-range-as-foreign-array (histogram)
"A view of the histogram range as a foreign array. This vector has one more element than the number of bins; the first element is the lower bound of the first bin, and the last element is the upper bound of the last bin. The two objects point to the same foreign data."
;; 1D histograms only so far
(grid:make-foreign-array-from-pointer
(cffi:foreign-slot-value (mpointer histogram) '(:struct histogram-c) 'range)
(list (1+ (grid:dim0 histogram)))
'double-float
nil))
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