(math-map-binop): Declare as a function.
authorJay Belanger <jay.p.belanger@gmail.com>
Tue, 27 Nov 2007 04:57:57 +0000 (04:57 +0000)
committerJay Belanger <jay.p.belanger@gmail.com>
Tue, 27 Nov 2007 04:57:57 +0000 (04:57 +0000)
(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'.

lisp/calc/calc-nlfit.el

index 3a1502f..2d84b15 100644 (file)
 ;;; Code:
 
 (require 'calc-arith)
+(require 'calcalg3)
 
 ;; Declare functions which are defined elsewhere.
 (declare-function calc-get-fit-variables "calcalg3" (nv nc &optional defv defc with-y homog))
-
+(declare-function math-map-binop "calclalg3" (binop args1 args2))
 
 (defun math-nlfit-least-squares (xdata ydata &optional sdata sigmas)
   "Return the parameters A and B for the best least squares fit y=a+bx."
 ;;; the maximum value of q.
 
 (defun math-nlfit-find-qmax (qdata pdata tdata)
-  (let* ((ratios (mapcar* 'math-div pdata qdata))
+  (let* ((ratios (math-map-binop 'math-div pdata qdata))
          (lsdata (math-nlfit-least-squares ratios tdata))
          (qmax (math-max-list (car qdata) (cdr qdata)))
          (a (math-neg (math-div (nth 1 lsdata) (nth 0 lsdata)))))
         (mat nil)
         (k 0))
     (while (< k i)
-      (setq mat (cons (copy-list row) mat))
+      (setq mat (cons (copy-sequence row) mat))
       (setq k (1+ k)))
     mat))
 
           (let* ((Ctilda (math-nlfit-make-Ctilda C lambda))
                  (dtilda (math-nlfit-make-dtilda d (length (car C))))
                  (zeta (math-nlfit-givens Ctilda dtilda))
-                 (newparms (mapcar* 'math-add (copy-tree parms) zeta))
+                 (newparms (math-map-binop 'math-add (copy-tree parms) zeta))
                  (newchisq (math-nlfit-chi-sq xlist ylist newparms fn slist)))
             (if (math-lessp newchisq chisq)
                 (progn
                (nth 0 sigmacovar)))
           (finalparms 
            (if sigmas
-               (mapcar* (lambda (x y) (list 'sdev x y)) finalparms sigmas)
+               (math-map-binop 
+                (lambda (x y) (list 'sdev x y)) finalparms sigmas)
              finalparms))
           (soln (funcall solnexpr finalparms var)))
      (let ((calc-fit-to-trail t)
                      (mapcar (lambda (x) (math-get-sdev x t)) pdata)
                    nil))
           (pdata (mapcar (lambda (x) (math-get-value x)) pdata))
-          (poverqdata (mapcar* 'math-div pdata qdata))
+          (poverqdata (math-map-binop 'math-div pdata qdata))
           (parmvals (math-nlfit-least-squares qdata poverqdata sdata sdevv))
           (finalparms (list (nth 0 parmvals)
                             (math-neg