Note on pseries::power_const() method.

Richard B. Kreckel kreckel at thep.physik.uni-mainz.de
Wed Nov 28 13:37:46 CET 2001


Hi,

On Tue, 27 Nov 2001, Pearu Peterson wrote:
> pseries::power_const() has second argument
> 	int deg
> that allows negative values of deg. If one calls this method with negative
> deg then the line
> 	co.reserve(deg);
> will cause MemoryError as (unsigned)deg gets really big.
> 
> My questions are:
> 1) Is there any sense using negative deg? If yes, then the above indicates 
> a bug. If no, then an exception should be thrown.
> 2) In case negative deg is valid, then is there a reason why
> power_const() method needs this argument (and methods mul_const(),etc
> don't)? In the interface to python, I have used the following rule to
> find the default value for deg:
> If p==pseries(...) and n is integer, then deg in p.power_const(n,deg) is
> found as follows
>    ldeg = abs(n * p.ldegree(p.get_var()))
>    deg = abs(n * p.degree(p.get_var()))
>    deg = max(ldeg,deg) + 2
> With this rule, I have found that equation
> 	(p^n)^m == p^(n*m)      for all integers m,n (also negative).
> holds (and therefore seems sensible to me).
> 
> Do you see any faults in this rule?

The rule itself look very interesting.  I think I shall play with it
when I find time...

...however, why are you calling pseries::power_const() and all this?  It
should only be called from within power::series() and if you look there
you will see that the second argument is just passed along.  Err, maybe
pseries::power_const shouldn't have been public in the first place.  :^)

Regards
    -richy.
-- 
Richard B. Kreckel
<Richard.Kreckel at Uni-Mainz.DE>
<http://wwwthep.physik.uni-mainz.de/~kreckel/>





More information about the GiNaC-devel mailing list