/* Simple tests on the Psi-function (aka polygamma-function). We stuff in arguments where the result exists in closed form and check if it's ok. */ static unsigned inifcns_consist_psi() { using GiNaC::log; using GiNaC::tgamma; unsigned result = 0; symbol x; ex e, f; // We check psi(1) and psi(1/2) implicitly by calculating the curious // little identity tgamma(1)'/tgamma(1) - tgamma(1/2)'/tgamma(1/2) == 2*log(2). e += (tgamma(x).diff(x)/tgamma(x)).subs(x==numeric(1)); e -= (tgamma(x).diff(x)/tgamma(x)).subs(x==numeric(1,2)); if (e!=2*log(2)) { clog << "tgamma(1)'/tgamma(1) - tgamma(1/2)'/tgamma(1/2) erroneously returned " << e << " instead of 2*log(2)" << endl; ++result; } return result; }
/* Simple tests on the tgamma function. We stuff in arguments where the results * exists in closed form and check if it's ok. */ static unsigned inifcns_consist_gamma() { using GiNaC::tgamma; unsigned result = 0; ex e; e = tgamma(1); for (int i=2; i<8; ++i) e += tgamma(ex(i)); if (e != numeric(874)) { clog << "tgamma(1)+...+tgamma(7) erroneously returned " << e << " instead of 874" << endl; ++result; } e = tgamma(1); for (int i=2; i<8; ++i) e *= tgamma(ex(i)); if (e != numeric(24883200)) { clog << "tgamma(1)*...*tgamma(7) erroneously returned " << e << " instead of 24883200" << endl; ++result; } e = tgamma(ex(numeric(5, 2)))*tgamma(ex(numeric(9, 2)))*64; if (e != 315*Pi) { clog << "64*tgamma(5/2)*tgamma(9/2) erroneously returned " << e << " instead of 315*Pi" << endl; ++result; } e = tgamma(ex(numeric(-13, 2))); for (int i=-13; i<7; i=i+2) e += tgamma(ex(numeric(i, 2))); e = (e*tgamma(ex(numeric(15, 2)))*numeric(512)); if (e != numeric(633935)*Pi) { clog << "512*(tgamma(-13/2)+...+tgamma(5/2))*tgamma(15/2) erroneously returned " << e << " instead of 633935*Pi" << endl; ++result; } return result; }
/* F_ab(a, i, b, j, "x") is a common pattern in all vertex evaluators. */ static ex F_ab(int a, int i, int b, int j, const symbol &x) { using GiNaC::tgamma; if ((i==0 && a<=0) || (j==0 && b<=0)) return 0; else return (tgamma(2-a-(i+1)*x)* tgamma(2-b-(1+j)*x)* tgamma(a+b-2+(1+i+j)*x)/ tgamma(a+i*x)/ tgamma(b+j*x)/tgamma(4-a-b-(2+i+j)*x)); }