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

Re: Predict Random Numbers

by johannz (Hermit)
on Mar 14, 2002 at 13:36 UTC ( #151666=note: print w/ replies, xml ) Need Help??


in reply to Predict Random Numbers

<This did not run on my ActiveState Perl Install. I tried installing Math::BigInt and Math::BigRat via ppm, was only able to get Math::BigInt. And could not find the other modules, Math::BigInt::Pari or Math::BigInt::GMP.

Results for perl -v:

This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 626 provided by ActiveState Tool Corp. http://www.ActiveState.com Built 01:31:15 May 2 2001

So, do you have ppd files for these modules or did you just build them yourself. I am assuming that these involve xs code?

Later...

So, it looks like Math::BigInt::Pari is a perl-only module, but requires Math::Pari, which is a c module and not available through PPM.

Math::BigInt::GMP is a c interface to another library and also is not available through PPM.

And Math::BigRat requires Math::BigFloat, which is in a later version of Math::BigInt than is on PPM.

So you have to get the latest Math::BigInt from CPAN, install it, install the latest Math::BigRat from CPAN, and then have a compiler so you can either install Math::BigInt::GMP, or the prerequisites for Math::BigInt::Pari.

Even more later...

So I installed Math::BigInt and Math::BigRat from CPAN. I did not install Math::BigInt::Pari or Math::BigInt::GMP but was able to run the code.

It hasn't finished, but it is running. :)

ps. I have a P3 500mhz, with 384M ram running Win2K. So we will see how it goes.


Update: He's right about needing a fast Math::BigInt library, the perl-only versions are too slow. It's been about 2 hrs and no results yet.


Comment on Re: Predict Random Numbers
Really Fast Big Integer Library In C - Re: Re: Predict Random Numbers
by metadoktor (Hermit) on Mar 14, 2002 at 15:42 UTC
    He's right about needing a fast Math::BigInt library, the perl-only versions are too slow. It's been about 2 hrs and no results yet.

    If you want really fast code with which to manipulate large integers then I recommend getting Crandall's giants.c and giants.h C code from Perfectly Scientific. This code is used as a base library for the factorization of large composite numbers.

    You will, of course, need a C compiler. If you want to actually hack the library you will need some patience as there is very little documentation and the code is very terse. Using the library functions though is relatively easy to do.

    metadoktor

    "The doktor is in."

      Yes, compiled C code is much faster than perl for this task, I'm afraid. I have a C version that runs over 100 times faster than the perl, so it completes in a fraction of a second. I used GMP, which provides a wide variety of functions and has optimized assembly code for many platforms. Pari seems to be a bit faster, but the documentation is way over my head.

      I see Math::BigIntFast is available in PPM form. Someone who was feeling ambitious could probably make that work, but the rational number support would have to be written.

        Yes, compiled C code is much faster than perl for this task, I'm afraid. I have a C version that runs over 100 times faster than the perl, so it completes in a fraction of a second.

        Math::BigInt::Lite should help to address this problem, but the normal Perl overhead will always remain. Unless you use large numbers, where the most time will be spent in the GMP/Pari etc library, Perl will be always much slower, I am afraid.

        I see Math::BigIntFast is available in PPM form. Someone who was feeling ambitious could probably make that work, but the rational number support would have to be written.

        Math::BigIntFast is just a *very* thin (read: empty) wrapper around Bit::Vector. Besides that Bit::Vector is slower than GMP and Pari, it also has the problem that it only works with "fixed" sized numbers, e.g. you need to determine what the max. will be in front and than use that for all numbers - or do costly resizing all the time. And if you make it really so that it works with numbers of any size in mixed ways, you will just re-invent Math::BigInt::BitVector ;) HTH, Tels PS: Next time please sent me bug reports or feature requests, it is quite embarrassing reading about things that don't work on some random website you stumble over with google. I could have easily missed it for months or years. Thanx in advance!

Re: Predict Random Numbers
by Anonymous Monk on Mar 15, 2002 at 21:07 UTC
    quote:
    Update: He's right about needing a fast Math::BigInt library, the perl-only versions are too slow. It's been about 2 hrs and no results yet.

    You might also try and see if Math::BigInt::BitVect is available for Windows - although not as fast as GMP or Pari, they might speed it up ;) Math::BigInt::Lite will make this hopefully a bit faster (since it is faster for small numbers), but it is not finished yet (see here)

    Thanx for the fun, you guys rock ;)

    If anybody wan't to chat to me about this, please drop me an email, I would love to ;)

    Tels

Re: Re: Predict Random Numbers
by no_slogan (Deacon) on Mar 16, 2002 at 20:41 UTC
    He's right about needing a fast Math::BigInt library, the perl-only versions are too slow. It's been about 2 hrs and no results yet.
    Actually, it runs in about 10 minutes with the perl-only version on my machine. The problem is, there's a bug in some versions of the pure perl BigInt module, and the L3 algorithm isn't guaranteed to terminate in that situation. Try the latest version from the author's web page.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2014-08-23 15:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (174 votes), past polls