[GiNaC-devel] Custom power evaluation

Richard B. Kreckel kreckel at ginac.de
Fri Oct 27 22:26:44 CEST 2006


Hi Vladimir,

You wrote:

>		In my GiNaC code I oftenly use some objects which have special
>  properties with respect to power. For example, if values of a symbol s
>  are assumed to be only -1, 0, or 1, then s^3=s. Another example is
>  provided by "imaginary units" for double and dual numbers.
>  
>

Thanks a lot for your input, but this time I am not convinced it would 
be good to include your contribution.

About five years ago, I was doing something very similar. I had 
polynomials of theta functions of different (symbolic) arguments and it 
was convenient enough to write tree traversers and convert the theta 
functions to individual symbols and back again to theta functions. Just 
replacing s^2 by s was not hard. But it also was hardly enough! This 
was, because theta functions offer a number of other, very useful 
identities:

1) If the argument of theta factorizes, one can transform theta(P*Q) -> 
theta(P)*theta(Q)+theta(-P)*theta(-Q).
2) One can find arguments that differ in sign only and transform 
theta(-P) -> 1-theta(P).
3) One can easily proof that square free factorization of polynomials of 
idempotent things is equal to the full factorization and do fine things 
with GiNaC's sqrfree function.
n) ...

My point is that with objects as specialized as theta functions or, 
equivalently, step functions, many specialized rules suddenly hold and 
it does not appear to make much sense adding virtual functions to the 
basic class in order to support just a few of them. I suggest doing 
these things in specialized code.

Best wishes
  -richy.

-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>




More information about the GiNaC-devel mailing list