diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:31 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:31 -0800 |
commit | 5145dd3aa0c02c9fc496d1432fc4410674206e1d (patch) | |
tree | 540afc30c51da085f5bd8ec3f4c89f6496e7900d /charplot.scm | |
parent | 8466d8cfa486fb30d1755c4261b781135083787b (diff) | |
download | slib-5145dd3aa0c02c9fc496d1432fc4410674206e1d.tar.gz slib-5145dd3aa0c02c9fc496d1432fc4410674206e1d.zip |
Import Upstream version 3a2upstream/3a2
Diffstat (limited to 'charplot.scm')
-rw-r--r-- | charplot.scm | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/charplot.scm b/charplot.scm index 890fca0..31d0fea 100644 --- a/charplot.scm +++ b/charplot.scm @@ -85,7 +85,7 @@ (output-port-height (current-output-port)))) (width (or (and charplot:dimensions (cadr charplot:dimensions)) (output-port-width (current-output-port))))) - (define pra (create-array " " height width)) + (define pra (make-array " " height width)) ;;Put newlines on right edge (do ((idx (+ -1 height) (+ -1 idx))) ((negative? idx)) @@ -166,20 +166,24 @@ (define (charplot:array->list ra) (define dims (array-dimensions ra)) - (do ((idx (+ -1 (car dims)) (+ -1 idx)) - (cols '() (cons (do ((jdx (+ -1 (cadr dims)) (+ -1 jdx)) - (row '() (cons (array-ref ra idx jdx) row))) - ((negative? jdx) row)) - cols))) - ((negative? idx) cols))) + (if (= 2 (length dims)) + (do ((idx (+ -1 (car dims)) (+ -1 idx)) + (cols '() (cons (do ((jdx (+ -1 (cadr dims)) (+ -1 jdx)) + (row '() (cons (array-ref ra idx jdx) row))) + ((negative? jdx) row)) + cols))) + ((negative? idx) cols)) + (do ((idx (+ -1 (car dims)) (+ -1 idx)) + (cols '() (cons (array-ref ra idx) cols))) + ((negative? idx) cols)))) ;;;Converts data to list of coordinates (list). (define (charplot:data->lists data) (cond ((array? data) (case (array-rank data) ((1) (set! data (map list - (let ((ra (apply create-array '#() - (array-shape data)))) + (let ((ra (apply make-array '#() + (array-dimensions data)))) (array-index-map! ra identity) (charplot:array->list ra)) (charplot:array->list data)))) @@ -279,12 +283,13 @@ data) (array-for-each write-char pra) (if (not (eqv? #\newline (apply array-ref pra - (map cadr (array-shape pra))))) + (map (lambda (x) (+ -1 x)) + (array-dimensions pra))))) (newline)))) (define (charplot:plot-function func vlo vhi . npts) (set! npts (if (null? npts) 64 (car npts))) - (let ((dats (create-array (Ar64) npts 2))) + (let ((dats (make-array (A:floR64b) npts 2))) (array-index-map! (make-shared-array dats (lambda (idx) (list idx 0)) npts) (lambda (idx) (+ vlo (* (- vhi vlo) (/ idx (+ -1 npts)))))) |