Skip to content
Snippets Groups Projects
Commit 6dff5af0 authored by liam's avatar liam
Browse files

make-histogram now includes alloc; some examples of histogram. Put

polynomial-solve-ws after polynomial-solve.


git-svn-id: svn+ssh://pop/opt/space/mathematics/gsl/trunk@3177 a3d8a0fb-c1db-0310-ace7-a616afeb9e30
parent c4ce788c
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
; description: The histogram structure. ; description: The histogram structure.
; date: Mon Jan 1 2007 - 11:32 ; date: Mon Jan 1 2007 - 11:32
; author: Liam M. Healy ; author: Liam M. Healy
; modified: Mon Jan 1 2007 - 20:44 ; modified: Tue Jan 2 2007 - 23:03
;******************************************************** ;********************************************************
;;; $Id: $ ;;; $Id: $
...@@ -192,5 +192,11 @@ ...@@ -192,5 +192,11 @@
(defun make-histogram (size &optional from) (defun make-histogram (size &optional from)
"Make a histogram, optionally filling it with "Make a histogram, optionally filling it with
data from an existing histogram." data from an existing histogram."
(make-instance 'histogram :number-of-bins size (let ((ret
:pointer (when from (clone from)))) (make-instance 'histogram :number-of-bins size
:pointer (when from (clone from)))))
(unless (pointer ret)
(alloc ret))
ret))
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
; elements. ; elements.
; date: Mon Jan 1 2007 - 14:43 ; date: Mon Jan 1 2007 - 14:43
; author: Liam M. Healy ; author: Liam M. Healy
; modified: Mon Jan 1 2007 - 20:50 ; modified: Tue Jan 2 2007 - 21:52
;******************************************************** ;********************************************************
;;; $Id: $ ;;; $Id: $
...@@ -119,3 +119,30 @@ ...@@ -119,3 +119,30 @@
(histo-1d2d histogram histogram-find (histo-1d2d histogram histogram-find
((first values)) ((first values))
((first values) (second values)))) ((first values) (second values))))
;;; Examples and unit test
(defparameter *sample-histogram*
(let ((histo (make-histogram 10)))
(set-ranges-uniform histo 0.0d0 10.0d0)
histo))
#|
(lisp-unit:define-test histogram
(lisp-unit:assert-equal
))
(reset *sample-histogram*)
(increment *sample-histogram* 2.7d0)
(increment *sample-histogram* 6.9d0 2.0d0)
(increment *sample-histogram* -2.0d0)
(gsl-aref *sample-histogram* 1)
(gsl-aref *sample-histogram* 2)
(gsl-aref *sample-histogram* 6)
(gsl-aref *sample-histogram* 16) ; error
(gsl-min-range *sample-histogram*)
(gsl-max-range *sample-histogram*)
(bins *sample-histogram*)
(histogram-find *sample-histogram* 5.5d0)
|#
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
; description: Polynomials ; description: Polynomials
; date: Tue Mar 21 2006 - 18:33 ; date: Tue Mar 21 2006 - 18:33
; author: Liam M. Healy ; author: Liam M. Healy
; modified: Fri Jul 7 2006 - 23:11 ; modified: Tue Jan 2 2007 - 09:27
;******************************************************** ;********************************************************
;;; $Id: $ ;;; $Id: $
...@@ -150,19 +150,6 @@ ...@@ -150,19 +150,6 @@
(progn ,@body) (progn ,@body)
(complex-workspace-free ,workspace)))) (complex-workspace-free ,workspace))))
(defun-gsl polynomial-solve-ws (coefficients workspace answer-pd)
"gsl_poly_complex_solve"
(((gsl-array coefficients) :pointer) ((dim0 coefficients) :size)
(workspace :pointer) ((gsl-array answer-pd) :pointer))
:return
((loop for i from 0 below (dim0 answer-pd) by 2
collect (complex (gsl-aref answer-pd i)
(gsl-aref answer-pd (1+ i)))))
:documentation
"Arguments are:
a GSL array of coefficients, a workspace, a gsl-array of doubles."
:export nil
:index polynomial-solve)
(defun polynomial-solve (coefficients) (defun polynomial-solve (coefficients)
"The roots of the general polynomial "The roots of the general polynomial
...@@ -180,6 +167,21 @@ ...@@ -180,6 +167,21 @@
(with-poly-complex-workspace (ws len) (with-poly-complex-workspace (ws len)
(values-list (polynomial-solve-ws coef ws answer))))))) (values-list (polynomial-solve-ws coef ws answer)))))))
(defun-gsl polynomial-solve-ws (coefficients workspace answer-pd)
"gsl_poly_complex_solve"
(((gsl-array coefficients) :pointer) ((dim0 coefficients) :size)
(workspace :pointer) ((gsl-array answer-pd) :pointer))
:return
((loop for i from 0 below (dim0 answer-pd) by 2
collect (complex (gsl-aref answer-pd i)
(gsl-aref answer-pd (1+ i)))))
:documentation
"Arguments are:
a GSL array of coefficients, a workspace, a gsl-array of doubles."
:export nil
:index polynomial-solve)
;;;;**************************************************************************** ;;;;****************************************************************************
;;;; Examples and unit test ;;;; Examples and unit test
;;;;**************************************************************************** ;;;;****************************************************************************
......
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