summaryrefslogtreecommitdiff
path: root/lisp/calc
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2007-08-03 05:58:06 +0000
committerMiles Bader <miles@gnu.org>2007-08-03 05:58:06 +0000
commit2ca773ca40d2c1896757e6382aefff6d9de1c5cc (patch)
tree846419ece5e5d8bc8f11e9786598678af9c78f00 /lisp/calc
parent49b23c2a404cf31fb1aeecc7932a7304aaf16a67 (diff)
parent0896d93184a719bc994a3e699de27190aac0acb1 (diff)
downloademacs-2ca773ca40d2c1896757e6382aefff6d9de1c5cc.tar.gz
emacs-2ca773ca40d2c1896757e6382aefff6d9de1c5cc.tar.bz2
emacs-2ca773ca40d2c1896757e6382aefff6d9de1c5cc.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 843-845) - Update from CVS - Merge from emacs--rel--22 * emacs--rel--22 (patch 84-87) - Update from CVS - Change capitalization of VC backend names for new backends Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-30
Diffstat (limited to 'lisp/calc')
-rw-r--r--lisp/calc/calc-ext.el19
-rw-r--r--lisp/calc/calc-graph.el74
2 files changed, 68 insertions, 25 deletions
diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el
index b517a54c6f0..5a334778aa5 100644
--- a/lisp/calc/calc-ext.el
+++ b/lisp/calc/calc-ext.el
@@ -2213,6 +2213,25 @@ calc-kill calc-kill-region calc-yank))))
a
(math-reject-arg a 'constp)))
+;;; Some functions for working with error forms.
+(defun math-get-value (x)
+ "Get the mean value of the error form X.
+If X is not an error form, return X."
+ (if (eq (car-safe x) 'sdev)
+ (nth 1 x)
+ x))
+
+(defun math-get-sdev (x &optional one)
+ "Get the standard deviation of the error form X.
+If X is not an error form, return 1."
+ (if (eq (car-safe x) 'sdev)
+ (nth 2 x)
+ (if one 1 0)))
+
+(defun math-contains-sdev-p (ls)
+ "Non-nil if the list LS contains an error form."
+ (let ((ls (if (eq (car-safe ls) 'vec) (cdr ls) ls)))
+ (memq t (mapcar (lambda (x) (eq (car-safe x) 'sdev)) ls))))
;;; Coerce integer A to be a small integer. [S I]
(defun math-fixnum (a)
diff --git a/lisp/calc/calc-graph.el b/lisp/calc/calc-graph.el
index 48bdecf59a6..a7e85d9fa85 100644
--- a/lisp/calc/calc-graph.el
+++ b/lisp/calc/calc-graph.el
@@ -218,7 +218,8 @@
0)
(or (and (Math-num-integerp pstyle) (math-trunc pstyle))
(if (eq (car-safe (calc-var-value (nth 2 ydata))) 'vec)
- 0 -1)))))
+ 0 -1))
+ (math-contains-sdev-p (eval (nth 2 ydata))))))
(defun calc-graph-lookup (thing)
(if (and (eq (car-safe thing) 'var)
@@ -792,6 +793,10 @@
calc-graph-numsteps (1- (* calc-graph-numsteps (1+ calc-graph-numsteps3))))))
(defun calc-graph-format-data ()
+ (if (math-contains-sdev-p calc-graph-yp)
+ (let ((yp calc-graph-yp))
+ (setq calc-graph-yp (cons 'vec (mapcar 'math-get-value (cdr yp))))
+ (setq calc-graph-zp (cons 'vec (mapcar 'math-get-sdev (cdr yp))))))
(while (<= (setq calc-graph-stepcount (1+ calc-graph-stepcount)) calc-graph-numsteps)
(if calc-graph-xvec
(setq calc-graph-xp (cdr calc-graph-xp)
@@ -1059,7 +1064,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
(interactive "P")
(calc-graph-set-styles t (and style (prefix-numeric-value style))))
-(defun calc-graph-set-styles (lines points)
+(defun calc-graph-set-styles (lines points &optional yerr)
(calc-graph-init)
(save-excursion
(set-buffer calc-gnuplot-input)
@@ -1067,7 +1072,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
(error "No data points have been set!"))
(let ((base (point))
(mode nil) (lstyle nil) (pstyle nil)
- start end lenbl penbl)
+ start end lenbl penbl errform)
(re-search-forward "[,\n]")
(forward-char -1)
(setq end (point) start end)
@@ -1087,29 +1092,48 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
(setq pstyle (string-to-number
(buffer-substring (match-beginning 1)
(match-end 1)))))))
- (setq lenbl (or (equal mode "lines") (equal mode "linespoints"))
- penbl (or (equal mode "points") (equal mode "linespoints")))
- (if lines
- (or (eq lines t)
- (setq lstyle lines
- lenbl (>= lines 0)))
- (setq lenbl (not lenbl)))
- (if points
- (or (eq points t)
- (setq pstyle points
- penbl (>= points 0)))
- (setq penbl (not penbl)))
- (delete-region start end)
+ (unless yerr
+ (setq lenbl (or (equal mode "lines")
+ (equal mode "linespoints"))
+ penbl (or (equal mode "points")
+ (equal mode "linespoints")))
+ (if lines
+ (or (eq lines t)
+ (setq lstyle lines
+ lenbl (>= lines 0)))
+ (setq lenbl (not lenbl)))
+ (if points
+ (or (eq points t)
+ (setq pstyle points
+ penbl (>= points 0)))
+ (setq penbl (not penbl))))
+ (delete-region start end)
(goto-char start)
- (insert " with "
- (if lenbl
- (if penbl "linespoints" "lines")
- (if penbl "points" "dots")))
- (if (and pstyle (> pstyle 0))
- (insert " " (if (and lstyle (> lstyle 0)) (int-to-string lstyle) "1")
- " " (int-to-string pstyle))
- (if (and lstyle (> lstyle 0))
- (insert " " (int-to-string lstyle))))))
+ (setq errform
+ (condition-case nil
+ (math-contains-sdev-p
+ (eval (intern
+ (concat "var-"
+ (save-excursion
+ (re-search-backward ":\\(.*\\)\\}")
+ (match-string 1))))))
+ (error nil)))
+ (if yerr
+ (insert " with yerrorbars")
+ (insert " with "
+ (if (and errform
+ (equal mode "dots")
+ (eq lines t))
+ "yerrorbars"
+ (if lenbl
+ (if penbl "linespoints" "lines")
+ (if penbl "points" "dots"))))
+ (if (and pstyle (> pstyle 0))
+ (insert " "
+ (if (and lstyle (> lstyle 0)) (int-to-string lstyle) "1")
+ " " (int-to-string pstyle))
+ (if (and lstyle (> lstyle 0))
+ (insert " " (int-to-string lstyle)))))))
(calc-graph-view-commands))
(defun calc-graph-zero-x (flag)