bug(?): psi() Aborts

Richard B. Kreckel kreckel at thep.physik.uni-mainz.de
Wed Nov 21 14:46:02 CET 2001


Hi,

On Wed, 21 Nov 2001, Pearu Peterson wrote:
> #include <iostream>
> #include <ginac/ginac.h>
> using namespace std;
> using namespace GiNaC;
> 
> int main()
> {
>     numeric x("2");
>     cout << "psi("<<x<<")="<<psi(x) << endl;
>     return 0;
> }
> 
> just Aborts when running it (when replacing psi->sin, it runs fine). Does
> it happen to you? I am using
> 	ginac-1.0.0 (from a week old CVS)
> 	cln-1.1.3
> 	gmp-3.1.1,
> 	gcc version 2.95.4 20011006 (Debian prerelease)
> on woody debian.
> 
> Any ideas what is wrong with calling psi?

The problem is that psi(numeric) is overloaded because we thought we could
just implement tgamma(x), lgamma(x), psi(x), zeta(x), zeta(n,x) and so
forth.  This was a bit naive, though, and up to now only Li2(), i.e. the
dilogarithm, is implemented.  So, when you call psi(2) you end up calling
    template<typename T1> inline const GiNaC::function psi(const T1 & p1) {
        return function(function_index_psi1, ex(p1));
    }
with T1 being a plain int.  It thus is equivalent to calling psi(const ex &)
which ends up in psi1_eval().  In contrast, looking into numeric.cpp, we
see the stub
    const numeric psi(const numeric &x)
    {
        throw dunno();
    }
which explains why your program aborts.  That dunno class is meant to
signal (possibly partial) unimplemented behaviour and if you look at
psi1_evalf() you'll see that class dunno is caught there.

Bottom line: we are currently stuck with the somewhat irritating fact that
evalf(psi(2)) correctly returns 0.42278 because it just evalf(1-Euler)
while psi(numeric(2)) sets your PC on fire.   :-(

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





More information about the GiNaC-devel mailing list