Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
The stupid question is the question not asked
 
PerlMonks  

Re^4: RFC: Getting Started with PDL (the Perl Data Language)

by syphilis (Canon)
on Feb 05, 2007 at 15:03 UTC ( #598316=note: print w/ replies, xml ) Need Help??


in reply to Re^3: RFC: Getting Started with PDL (the Perl Data Language)
in thread RFC: Getting Started with PDL (the Perl Data Language)

Eventually, I found mpfr which lets you set how many digits of precision you want to use.

Then there's really no need to look further - it's an excellent library. Incidentally, I placed a module (Math::MPFR) on CPAN that wraps the documented mpfr functions. I think I'm the only person that uses it. If you ever take a look at it, I'd be interested on any feedback. I believe it functions well, but there are aspects which bother me - eg, the documentation, the naming of the functions, and the fact that I wrote all of the XS functions "longhand" (as opposed to using a typemap).

Anyway ... back to the consideration of long doubles. Recent versions of mpfr allow you to convert directly from an mpfr_t to a long double, so one could do something like the following:

mpfr_t mpfr_pi; long double ld_pi; mpfr_set_default_prec(sizeof(long double) * 8); mpfr_init(mpfr_pi); mpfr_const_pi(mpfr_pi, GMP_RNDN); ld_pi = mpfr_get_ld(mpfr_pi, GMP_RNDN);
I would expect that ld_pi and mpfr_pi would contain the same value, though there's no guarantee that I'm correct. I was actually hoping to have a bit of a play with this at work tonight, but a last minute breakdown made a complete mess of that plan. (I may yet take a closer look and send you an /msg, as it's not really on-topic for either this forum or this particular thread).

Perhaps long doubles don't provide the precision that I expect - I've never checked. Or perhaps it's just an issue with printf or a general problem with C (as you suggested). Or perhaps it's just an issue with Glib. It would be interesting to know ....

Cheers,
Rob


Comment on Re^4: RFC: Getting Started with PDL (the Perl Data Language)
Download Code
Re^5: RFC: Getting Started with PDL (the Perl Data Language)
by zentara (Archbishop) on Feb 05, 2007 at 17:31 UTC
    If you ever take a look at it, I'd be interested on any feedback.

    Yeah, it built well for me, and I'm looking at it now. Actually, I think your docs are bit better than the c-libs docs, and hope to learn the library usage better by using your module. I'm running into alot of glitches though, like trying to make arrays of mpfr_t...... they don't seem to return stored values properly, but I'm probably making a small error somewhere.

    It certainly has made me appreciate the "ease of Perl" , in doing this stuff. I use Perl (which I can trust), to verify the output of the c. :-)


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re^5: RFC: Getting Started with PDL (the Perl Data Language)
by zentara (Archbishop) on Feb 05, 2007 at 22:10 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://598316]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2014-04-23 22:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (556 votes), past polls