1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-15 17:00:26 +00:00

calc-vec.el (math-vector-avg): Put the vector elements in order

before computing the averages.
This commit is contained in:
Jay Belanger 2010-05-16 23:16:29 -05:00
parent 7ca1f3f981
commit 00681a3c86
2 changed files with 6 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2010-05-17 Jay Belanger <jay.p.belanger@gmail.com>
* calc/calc-vec.el (math-vector-avg): Put the vector elements in
order before computing the averages.
2010-05-16 Jay Belanger <jay.p.belanger@gmail.com>
* calc/calc-vec.el (calc-histogram):

View File

@ -1178,7 +1178,7 @@
;;; Replace a vector [a b c ...] with a vector of averages
;;; [(a+b)/2 (b+c)/2 ...]
(defun math-vector-avg (vec)
(let ((vp (cdr vec))
(let ((vp (sort (copy-sequence (cdr vec)) 'math-beforep))
(res nil))
(while (and vp (cdr vp))
(setq res (cons (math-div (math-add (car vp) (cadr vp)) 2) res)