From: Richard Kreckel Date: Mon, 31 Jul 2000 18:15:29 +0000 (+0000) Subject: - Bernard Parisse's patch for Order_eval(). X-Git-Tag: release_0-6-4~10 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=1c288c22278ea56673eaf96c3c9885a7b5d854a8;ds=sidebyside - Bernard Parisse's patch for Order_eval(). --- diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp index b560100f..855c7317 100644 --- a/ginac/inifcns.cpp +++ b/ginac/inifcns.cpp @@ -377,21 +377,19 @@ REGISTER_FUNCTION(binomial, eval_func(binomial_eval). static ex Order_eval(const ex & x) { - if (is_ex_exactly_of_type(x, numeric)) { - - // O(c)=O(1) - return Order(_ex1()).hold(); - - } else if (is_ex_exactly_of_type(x, mul)) { - - mul *m = static_cast(x.bp); - if (is_ex_exactly_of_type(m->op(m->nops() - 1), numeric)) { - - // O(c*expr)=O(expr) - return Order(x / m->op(m->nops() - 1)).hold(); - } - } - return Order(x).hold(); + if (is_ex_exactly_of_type(x, numeric)) { + // O(c) -> O(1) or 0 + if (!x.is_zero()) + return Order(_ex1()).hold(); + else + return _ex0(); + } else if (is_ex_exactly_of_type(x, mul)) { + mul *m = static_cast(x.bp); + // O(c*expr) -> O(expr) + if (is_ex_exactly_of_type(m->op(m->nops() - 1), numeric)) + return Order(x / m->op(m->nops() - 1)).hold(); + } + return Order(x).hold(); } static ex Order_series(const ex & x, const relational & r, int order, unsigned options)