Michael Koehn on Wed, 14 Oct 2009 12:19:26 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

using PARI library with arbitrary precision in C++


Dear PARi users,

please help me on my problem. I need to compute the complex gamma function to arbitrary precision and wanted to use PARI's built-in function. However I don't know how to convert the GEN value back to some arbitrary precision type that I can use for my program in C++. (I am using the arprec package.)

I am only able to convert my GEN with t_REAL back to double with rtodbl(GEN x), but then I lose the high precision. Can anybody give me please a hint on this?


Also, I am wondering why I can only compute values for gamma(x) in libpari to the 18th digit, if I print them with brute(). (See below.)

This is my example program:

-----------

#include </usr/local/include/pari/pari.h>
#include <iostream>
#include <iomanip>
using namespace std;

static GEN s;

int main()	
{
	pari_init(500000,0);
	
//	output(ggamma(gadd(dbltor(200.),gmul(gi,dbltor(10.))),50));
	brute(ggamma(dbltor(50.),50),'f',100);
cout << "\n" << setprecision(50) << rtodbl(ggamma(dbltor(50.),50)) << "\n";
}

------------

The returned values of gamma(50)
-- in gp: (19:32) gp > gamma(50) %11 = 608281864034267560872252163321295376887552831379210240000000000.0000000000000000000000000000000000000

-- from libpari with brute(ggamma(dbltor(50.),50),'f',100):
6.082818640342675609E62

-- from libpari with brute(ggamma(dbltor(50.),50),'f',100) after converting to double with rtodbl(GEN x):
6.0828186403426752248860160811673162316877754210242e+62

Please help me on this, I searched all the documentation and I am really stuck and the days go by.

Thank you very much!

Micha