diff options
| author | Jay Belanger | 2007-11-27 04:57:57 +0000 |
|---|---|---|
| committer | Jay Belanger | 2007-11-27 04:57:57 +0000 |
| commit | adf78b0c8fccb6d6512c9cf58276587d912eab35 (patch) | |
| tree | c66ed577853d9c36a3ccc0f1bb683c66946296d1 | |
| parent | e5a5704e499899fa73aa0d93613d140b4d4fb7c4 (diff) | |
| download | emacs-adf78b0c8fccb6d6512c9cf58276587d912eab35.tar.gz emacs-adf78b0c8fccb6d6512c9cf58276587d912eab35.zip | |
(math-map-binop): Declare as a function.
(math-nlfit-make-matrix, math-nlfit-find-qmax, math-nlfit-fit)
(math-nlfit-fit-curve, calc-fit-hubbert-linear-curve):
Replace `mapcar*' by `math-map-binop'.
(math-nlfit-make-matrix): Replace `copy-list' with `copy-sequence'.
| -rw-r--r-- | lisp/calc/calc-nlfit.el | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/calc/calc-nlfit.el b/lisp/calc/calc-nlfit.el index 3a1502fada2..2d84b1570ae 100644 --- a/lisp/calc/calc-nlfit.el +++ b/lisp/calc/calc-nlfit.el | |||
| @@ -61,10 +61,11 @@ | |||
| 61 | ;;; Code: | 61 | ;;; Code: |
| 62 | 62 | ||
| 63 | (require 'calc-arith) | 63 | (require 'calc-arith) |
| 64 | (require 'calcalg3) | ||
| 64 | 65 | ||
| 65 | ;; Declare functions which are defined elsewhere. | 66 | ;; Declare functions which are defined elsewhere. |
| 66 | (declare-function calc-get-fit-variables "calcalg3" (nv nc &optional defv defc with-y homog)) | 67 | (declare-function calc-get-fit-variables "calcalg3" (nv nc &optional defv defc with-y homog)) |
| 67 | 68 | (declare-function math-map-binop "calclalg3" (binop args1 args2)) | |
| 68 | 69 | ||
| 69 | (defun math-nlfit-least-squares (xdata ydata &optional sdata sigmas) | 70 | (defun math-nlfit-least-squares (xdata ydata &optional sdata sigmas) |
| 70 | "Return the parameters A and B for the best least squares fit y=a+bx." | 71 | "Return the parameters A and B for the best least squares fit y=a+bx." |
| @@ -192,7 +193,7 @@ | |||
| 192 | ;;; the maximum value of q. | 193 | ;;; the maximum value of q. |
| 193 | 194 | ||
| 194 | (defun math-nlfit-find-qmax (qdata pdata tdata) | 195 | (defun math-nlfit-find-qmax (qdata pdata tdata) |
| 195 | (let* ((ratios (mapcar* 'math-div pdata qdata)) | 196 | (let* ((ratios (math-map-binop 'math-div pdata qdata)) |
| 196 | (lsdata (math-nlfit-least-squares ratios tdata)) | 197 | (lsdata (math-nlfit-least-squares ratios tdata)) |
| 197 | (qmax (math-max-list (car qdata) (cdr qdata))) | 198 | (qmax (math-max-list (car qdata) (cdr qdata))) |
| 198 | (a (math-neg (math-div (nth 1 lsdata) (nth 0 lsdata))))) | 199 | (a (math-neg (math-div (nth 1 lsdata) (nth 0 lsdata))))) |
| @@ -299,7 +300,7 @@ | |||
| 299 | (mat nil) | 300 | (mat nil) |
| 300 | (k 0)) | 301 | (k 0)) |
| 301 | (while (< k i) | 302 | (while (< k i) |
| 302 | (setq mat (cons (copy-list row) mat)) | 303 | (setq mat (cons (copy-sequence row) mat)) |
| 303 | (setq k (1+ k))) | 304 | (setq k (1+ k))) |
| 304 | mat)) | 305 | mat)) |
| 305 | 306 | ||
| @@ -517,7 +518,7 @@ | |||
| 517 | (let* ((Ctilda (math-nlfit-make-Ctilda C lambda)) | 518 | (let* ((Ctilda (math-nlfit-make-Ctilda C lambda)) |
| 518 | (dtilda (math-nlfit-make-dtilda d (length (car C)))) | 519 | (dtilda (math-nlfit-make-dtilda d (length (car C)))) |
| 519 | (zeta (math-nlfit-givens Ctilda dtilda)) | 520 | (zeta (math-nlfit-givens Ctilda dtilda)) |
| 520 | (newparms (mapcar* 'math-add (copy-tree parms) zeta)) | 521 | (newparms (math-map-binop 'math-add (copy-tree parms) zeta)) |
| 521 | (newchisq (math-nlfit-chi-sq xlist ylist newparms fn slist))) | 522 | (newchisq (math-nlfit-chi-sq xlist ylist newparms fn slist))) |
| 522 | (if (math-lessp newchisq chisq) | 523 | (if (math-lessp newchisq chisq) |
| 523 | (progn | 524 | (progn |
| @@ -696,7 +697,8 @@ | |||
| 696 | (nth 0 sigmacovar))) | 697 | (nth 0 sigmacovar))) |
| 697 | (finalparms | 698 | (finalparms |
| 698 | (if sigmas | 699 | (if sigmas |
| 699 | (mapcar* (lambda (x y) (list 'sdev x y)) finalparms sigmas) | 700 | (math-map-binop |
| 701 | (lambda (x y) (list 'sdev x y)) finalparms sigmas) | ||
| 700 | finalparms)) | 702 | finalparms)) |
| 701 | (soln (funcall solnexpr finalparms var))) | 703 | (soln (funcall solnexpr finalparms var))) |
| 702 | (let ((calc-fit-to-trail t) | 704 | (let ((calc-fit-to-trail t) |
| @@ -756,7 +758,7 @@ | |||
| 756 | (mapcar (lambda (x) (math-get-sdev x t)) pdata) | 758 | (mapcar (lambda (x) (math-get-sdev x t)) pdata) |
| 757 | nil)) | 759 | nil)) |
| 758 | (pdata (mapcar (lambda (x) (math-get-value x)) pdata)) | 760 | (pdata (mapcar (lambda (x) (math-get-value x)) pdata)) |
| 759 | (poverqdata (mapcar* 'math-div pdata qdata)) | 761 | (poverqdata (math-map-binop 'math-div pdata qdata)) |
| 760 | (parmvals (math-nlfit-least-squares qdata poverqdata sdata sdevv)) | 762 | (parmvals (math-nlfit-least-squares qdata poverqdata sdata sdevv)) |
| 761 | (finalparms (list (nth 0 parmvals) | 763 | (finalparms (list (nth 0 parmvals) |
| 762 | (math-neg | 764 | (math-neg |