Note on pseries::power_const() method.

Pearu Peterson pearu at cens.ioc.ee
Tue Nov 27 17:55:52 CET 2001


Hi again,

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?

Thanks,
	Pearu




More information about the GiNaC-devel mailing list