From c6f0a081d186de96b8832e284f8436657b6a4508 Mon Sep 17 00:00:00 2001 From: Chris Dams Date: Mon, 13 Mar 2006 17:21:47 +0000 Subject: [PATCH] Make step(0)=1/2 again and remove step_power. --- doc/tutorial/ginac.texi | 2 +- ginac/inifcns.cpp | 11 +---------- ginac/numeric.cpp | 4 ++-- ginac/numeric.h | 4 ++-- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index 5c3cdef9..23956d77 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -1394,7 +1394,7 @@ evaluated immediately: @item @code{csgn(z)} @tab complex sign (returns an @code{int}) @item @code{step(x)} -@tab step function (returns an @code{int}) +@tab step function (returns an @code{numeric}) @item @code{numer(z)} @tab numerator of rational or complex rational number @item @code{denom(z)} diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp index 830b1bff..47252a8f 100644 --- a/ginac/inifcns.cpp +++ b/ginac/inifcns.cpp @@ -180,14 +180,6 @@ static ex step_series(const ex & arg, return pseries(rel,seq); } -static ex step_power(const ex & arg, const ex & exp) -{ - if (exp.info(info_flags::positive)) - return step(arg); - - return power(step(arg), exp).hold(); -} - static ex step_conjugate(const ex& arg) { return step(arg); @@ -196,8 +188,7 @@ static ex step_conjugate(const ex& arg) REGISTER_FUNCTION(step, eval_func(step_eval). evalf_func(step_evalf). series_func(step_series). - conjugate_func(step_conjugate). - power_func(step_power)); + conjugate_func(step_conjugate)); ////////// // Complex sign diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index 18943d3f..b8170e71 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -931,10 +931,10 @@ const numeric numeric::inverse() const * ignored because the step function is generally considered real but * a numeric may develop a small imaginary part due to rounding errors. */ -int numeric::step() const +numeric numeric::step() const { cln::cl_R r = cln::realpart(value); if(cln::zerop(r)) - return 1; + return numeric(1,2); if(cln::plusp(r)) return 1; return 0; diff --git a/ginac/numeric.h b/ginac/numeric.h index 2cf93480..f0e3362f 100644 --- a/ginac/numeric.h +++ b/ginac/numeric.h @@ -148,7 +148,7 @@ public: const numeric & operator=(double d); const numeric & operator=(const char *s); const numeric inverse() const; - int step() const; + numeric step() const; int csgn() const; int compare(const numeric &other) const; bool is_equal(const numeric &other) const; @@ -251,7 +251,7 @@ inline const numeric pow(const numeric &x, const numeric &y) inline const numeric inverse(const numeric &x) { return x.inverse(); } -inline int step(const numeric &x) +inline numeric step(const numeric &x) { return x.step(); } inline int csgn(const numeric &x) -- 2.44.0