From 1c288c22278ea56673eaf96c3c9885a7b5d854a8 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Mon, 31 Jul 2000 18:15:29 +0000 Subject: [PATCH] - Bernard Parisse's patch for Order_eval(). --- ginac/inifcns.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) 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) -- 2.44.0