Bill Allombert on Wed, 27 Jan 2016 14:57:56 +0100


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

Re: Precision in the PARI library (gp_read_str)


On Wed, Jan 27, 2016 at 02:38:01PM +0100, Rafael Guglielmetti wrote:
> Dear PARI users,
> I would like to compute the eigenvalues of a real symmetric matrix
> with PARI in a C++ program. To create the matrix, I use several
> information I read in a text file, create a string and use
> gp_read_str.
> 
> My problem: if one of the entry of the matrix is "sqrt(3)" for
> example, then the correspondent t_GEN has DEFAULTPREC and I'd like
> BIGDEFAULTPREC.
> My question is the following: how can I increase the precision of
> gp_read_str?

You need to increase the default precision.

If you use the stable version you can do
long prec;
setrealprecision(57,&prec);
gp_read_str(....)

If you use the master branch you can change the
default precision locally with:

push_localprec(BIGDEFAULTPREC);
gp_read_str(....)
pop_localprec();

Cheers,
Bill.