New mpz functions...
David Cleaver
wraithx at morpheus.net
Thu Jul 14 06:00:32 CEST 2011
Hello all,
Not too long ago I needed some mathematical functions that I couldn't really
find implemented anywhere. I eventually stumbled on someone's implementation
and was able to code it up with GMP. I was wondering, would there be any
interest in including these functions in the official GMP? The functions are
the Lucas U and Lucas V sequences, defined with parameters p and q. Here are
the prototypes:
int mpz_lucasu(mpz_t rop, int p, int q, int k)
int mpz_lucasumod(mpz_t rop, int p, int q, int k, mpz_t n)
int mpz_lucasv(mpz_t rop, int p, int q, int k)
int mpz_lucasvmod(mpz_t rop, int p, int q, int k, mpz_t n)
With these functions, you can generate several familiar sequences, like:
U[k](1,-1) : Fibonacci Numbers
V[k](1,-1) : Lucas Numbers
U[k](2,-1) : Pell Numbers
U[k](3,2) : Mersenne Numbers
It uses Lucas Chains to calculate the values, so it should be pretty quick. On
my computer it takes about 0.03 seconds to calculate the 1000000th Fibonacci Number.
I have a c file already written, but wanted to see if there was interest before
sending it out. Please let me know what you think of this proposal, and thanks
for your time.
-David C.
More information about the gmp-discuss
mailing list