Is GiNaC really that dirty?
Richard B. Kreckel
kreckel at thep.physik.uni-mainz.de
Tue Jul 17 16:33:46 CEST 2001
On Tue, 17 Jul 2001, Chris Dams wrote:
> > struct Checkdeg:public map_function
> > {
> > ex var;
> > int n;
> >
> > Checkdeg(const ex & var_, int n_) : var(var_), n(n_) {}
> >
> > ex operator()(const ex & f)
> > {
> > if (is_ex_exactly_of_type(f, add) || is_ex_exactly_of_type(f, mul))
> > return f.map(*this);
> > else if (f.is_equal(var) && n <= 1
> > || is_ex_exactly_of_type(f, power) && f.op(0).is_equal(var) && f.op(1) >= n)
> > return 0;
> > else
> > return f;
> > }
> > };
> >
> > Checkdeg mapper(var, n);
> > return mapper(f);
>
> This indeed looks much less messy. Furthermore, it is a lot faster than
> what I had originally. Seeing this, the objections I had against some of
> the design decisions of the developpers do not seem that important
> anymore; the inconveniences are not that bad after all. When taking speed
> into account they probably were the correct decisions, but I might
> need a bit more experience with GiNaC to get a feel for that. I think I
> will continue to use it if I come across some heavy algebra stuff. I might
> even recommend its use to other people. Just one thing for the maintainer
> of the manual: maybe something like the above example would be nice in
> paragraph 5.4 of the tutorial, about ``Applying a Function on
> Subexpressions''.
[...]
Hmm, considering it. However, I am curious: may I ask why one wants to
cut off powers if the exponent exceeds a certain integer? Series
expansion `abuse' (no pun intended)?
Regards
-richy.
--
Richard B. Kreckel
<Richard.Kreckel at Uni-Mainz.DE>
<http://wwwthep.physik.uni-mainz.de/~kreckel/>
More information about the GiNaC-list
mailing list