summaryrefslogtreecommitdiffstats
path: root/charplot.scm
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:31 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:31 -0800
commit5145dd3aa0c02c9fc496d1432fc4410674206e1d (patch)
tree540afc30c51da085f5bd8ec3f4c89f6496e7900d /charplot.scm
parent8466d8cfa486fb30d1755c4261b781135083787b (diff)
downloadslib-5145dd3aa0c02c9fc496d1432fc4410674206e1d.tar.gz
slib-5145dd3aa0c02c9fc496d1432fc4410674206e1d.zip
Import Upstream version 3a2upstream/3a2
Diffstat (limited to 'charplot.scm')
-rw-r--r--charplot.scm27
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))))))