kynn on Sun, 14 Aug 2005 02:53:45 +0200


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

PARI support for fcmp



Hi!  I'm new to PARI, and am still trying to find my way around.

I want to write a Perl extension to take care of approximate floating
point number (FPN) comparisons of PARI FPNs (or more specifically,
Math::Pari::PARI FPNs).  The idea is to give users some control over
the tolerance to be used in this comparison, as well as the type of
"error" (absolute vs. relative) to use in the comparison.

For starters, I just want to port the GSL's gsl_fcmp function so that
it can be applied to Math::Pari::PARI FPNs.  This function is a C
implementation of D. E. Knuth's proposed algorithm for approximate FPN
comparisons (TAOCP, v.2 (3d ed), 4.4.2).

This is a very simple function, that calls only standard C library
functions (namely frexp and ldexp).  In fact, it would be sufficient
to write a helper function that takes 5 integers as arguments: the
(normalized) exponent and fractional parts (e, f) of the two FPN to be
compared, plus a tolerance, expressed as a power of 2.  Then the API
function would extract the desired two integers (e, f) from each
operand, and pass them to the helper function.

All I need is to figure out how to extract the exponent and fractional
part of a Math::Pari::PARI FPN.  From reading the source code I gather
that the objects I need to manipulate have type GEN, but I have not
been able to figure out how to extract the two integers (e, f) I need
from each.  I would appreciate any guidance I could get on how to
proceed.

I spent some time searching for documentation of the PARI library, but
all I was able find was documentation on the PARI/GP front end.  Is
there any documentation aimed at developers for the PARI library?

I also searched for a Math::Pari-specific mail list, and didn't find
one, but if there's a better forum for this question, please let me
know.

Best regards!

kynn jones