]> code.delx.au - gnu-emacs/blobdiff - lisp/calc/calc-alg.el
Update copyright year to 2015
[gnu-emacs] / lisp / calc / calc-alg.el
index 8e41b175321b61eba3f2b429de70bab827749eff..ebc5ba66ec672ea64e7c77565ba4081e3f75d89b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; calc-alg.el --- algebraic functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2015 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainer: Jay Belanger  <jay.p.belanger@gmail.com>
         (Math-objectp a))
        ((eq (car a) 'var)
         (if (eq (car b) 'var)
-            (string-lessp (symbol-name (nth 1 a)) (symbol-name (nth 1 b)))
+            (string-lessp (nth 1 a) (nth 1 b))
           (not (Math-numberp b))))
        ((eq (car b) 'var) (Math-numberp a))
        ((eq (car a) (car b))
         (and b
              (or (null a)
                  (math-beforep (car a) (car b)))))
-       (t (string-lessp (symbol-name (car a)) (symbol-name (car b))))))
+       (t (string-lessp (car a) (car b)))))
 
 
 (defsubst math-simplify-extended (a)
 ;; math-simplify-step, which is called by math-simplify.
 (defvar math-top-only)
 
+;; math-normalize-error is declared in calc.el.
+(defvar math-normalize-error)
 (defun math-simplify (top-expr)
   (let ((math-simplifying t)
        (math-top-only (consp calc-simplify-mode))
       (calc-with-default-simplification
        (while (let ((r simp-rules))
                (setq res (math-normalize top-expr))
-               (while r
-                 (setq res (math-rewrite res (car r))
-                       r (cdr r)))
-               (not (equal top-expr (setq res (math-simplify-step res)))))
+                (if (not math-normalize-error)
+                    (progn
+                      (while r
+                        (setq res (math-rewrite res (car r))
+                              r (cdr r)))
+                      (not (equal top-expr (setq res (math-simplify-step res)))))))
         (setq top-expr res)))))
   top-expr)
 
                            (not (Math-realp (nth 1 math-simplify-expr))))
                       (math-common-constant-factor (nth 1 math-simplify-expr))))
          (if (and (eq (car-safe nn) 'frac) (eq (nth 1 nn) 1) (not n))
-             (progn
+             (unless (and (eq (car-safe math-simplify-expr) 'calcFunc-eq)
+                           (eq (car-safe (nth 1 math-simplify-expr)) 'var)
+                           (not (math-expr-contains (nth 2 math-simplify-expr) 
+                                                    (nth 1 math-simplify-expr))))
                (setcar (cdr math-simplify-expr)
                         (math-mul (nth 2 nn) (nth 1 math-simplify-expr)))
                (setcar (cdr (cdr math-simplify-expr))