Function: math-do-poly-div

math-do-poly-div is a byte-compiled function defined in calc-poly.el.gz.

Signature

(math-do-poly-div U V)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-poly.el.gz
(defun math-do-poly-div (u v)
  (cond ((math-constp u)
	 (if (math-constp v)
	     (cons (math-div u v) 0)
	   (cons 0 u)))
	((math-constp v)
	 (cons (if (eq v 1)
		   u
		 (if (memq (car-safe u) '(+ -))
		     (math-add-or-sub (math-poly-div-exact (nth 1 u) v)
				      (math-poly-div-exact (nth 2 u) v)
				      nil (eq (car u) '-))
		   (math-div u v)))
	       0))
	((Math-equal u v)
	 (cons math-poly-modulus 0))
	((and (math-atomic-factorp u) (math-atomic-factorp v))
	 (cons (math-simplify (math-div u v)) 0))
	(t
	 (let ((base (or math-poly-div-base
			 (math-poly-div-base u v)))
	       vp up res)
	   (if (or (null base)
		   (null (setq vp (math-is-polynomial v base nil 'gen))))
	       (cons 0 u)
	     (setq up (math-is-polynomial u base nil 'gen)
		   res (math-poly-div-coefs up vp))
	     (cons (math-build-polynomial-expr (car res) base)
		   (math-build-polynomial-expr (cdr res) base)))))))