From 18e50b48dbbdb0dfa5bb80bfcd7432d5aeaf180a Mon Sep 17 00:00:00 2001 From: Jay Belanger Date: Sat, 24 Jan 2009 02:27:04 +0000 Subject: [PATCH] (calcFunc-apart): Improve test for rational functions. --- lisp/ChangeLog | 5 +++++ lisp/calc/calc-poly.el | 32 +++++++++++++++++--------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 01e8e2dfdf2..5550a2ceb83 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2009-01-24 Jay Belanger + + * calc/calc-poly.el (calcFunc-apart): Improve test for + rational functions. + 2009-01-23 Chong Yidong * mail/rmailsum.el (rmail-summary-by-labels): Correctly handle diff --git a/lisp/calc/calc-poly.el b/lisp/calc/calc-poly.el index 7385e42c851..2246df94414 100644 --- a/lisp/calc/calc-poly.el +++ b/lisp/calc/calc-poly.el @@ -961,22 +961,24 @@ ((eq (car expr) '-) (math-sub (calcFunc-apart (nth 1 expr) var) (calcFunc-apart (nth 2 expr) var))) - ((not (math-ratpoly-p expr var)) - (math-reject-arg expr "Expected a rational function")) + ((and var (not (math-ratpoly-p expr var))) + (math-reject-arg expr "Expected a rational function")) (t - (let* ((calc-prefer-frac t) - (rat (math-to-ratpoly expr)) - (num (car rat)) - (den (cdr rat)) - (qr (math-poly-div num den)) - (q (car qr)) - (r (cdr qr))) - (or var - (setq var (math-polynomial-base den))) - (math-add q (or (and var - (math-expr-contains den var) - (math-partial-fractions r den var)) - (math-div r den))))))) + (let* ((calc-prefer-frac t) + (rat (math-to-ratpoly expr)) + (num (car rat)) + (den (cdr rat))) + (or var + (setq var (math-polynomial-base den))) + (if (not (math-ratpoly-p expr var)) + (math-reject-arg expr "Expected a rational function") + (let* ((qr (math-poly-div num den)) + (q (car qr)) + (r (cdr qr))) + (math-add q (or (and var + (math-expr-contains den var) + (math-partial-fractions r den var)) + (math-div r den))))))))) (defun math-padded-polynomial (expr var deg) -- 2.39.2