Multiprecision arithmetic library question.

M

Michael Press

I already compiled and installed the GNU multiprecision library
on Mac OS X, and link to it in C programs.
How do I link to the library from Python?
I do not want to download and install redundant material.
(I am new to Python)
 
M

Mark Wooding

Michael Press said:
I already compiled and installed the GNU multiprecision library
on Mac OS X, and link to it in C programs.
How do I link to the library from Python?

You know that Python already supports multiprecision integer arithmetic,
right? If you desperately want GMP, though, there's the gmpy module
(q.g.).

-- [mdw]
 
M

Michael Press

Mark Wooding said:
You know that Python already supports multiprecision integer arithmetic,
right? If you desperately want GMP, though, there's the gmpy module
(q.g.).

No, I do not know that. Define desperate.
Does Python support the extended Euclidean algorithm
and other number theory functions?
How fast does Python multiply?
Not that the latter is particularly important,
as C is built for speed.

I've been fooling around. Ran dir(gmpy), and
it does not show the full complement of GMP
library functions, such as the various division
functions. e.g. mpz_tdiv_qr.
 
D

duncan smith

Michael said:
No, I do not know that. Define desperate.
Does Python support the extended Euclidean algorithm
and other number theory functions?
How fast does Python multiply?
Not that the latter is particularly important,
as C is built for speed.

I've been fooling around. Ran dir(gmpy), and
it does not show the full complement of GMP
library functions, such as the various division
functions. e.g. mpz_tdiv_qr.

There's also
http://www.egenix.com/products/python/mxExperimental/mxNumber/. I'm not
sure how the functionality compares to GMPY.

Duncan
 
C

casevh

No, I do not know that. Define desperate.
Does Python support the extended Euclidean algorithm
and other number theory functions?
No.

How fast does Python multiply?

Python uses the Karatsuba algorithm which O(n^1.585). Division is
still O(n^2).
Not that the latter is particularly important,
as C is built for speed.

I've been fooling around. Ran dir(gmpy), and
it does not show the full complement of GMP
library functions, such as the various division
functions. e.g. mpz_tdiv_qr.

gmpy implements the Python numeric model using GMP and exposes some of
the high-level functions. Are you looking for low-level wrapper that
exposes all the GMP library functions?
 
M

M.-A. Lemburg

duncan said:
There's also
http://www.egenix.com/products/python/mxExperimental/mxNumber/. I'm not
sure how the functionality compares to GMPY.

mxNumber is a implementation of number types that use GMP for the
internals. It doesn't expose all APIs available in GMP and also doesn't
use a 1-1 mapping. Instead, it wraps the basic types available in GMP
in Python objects which can be used just like normal Python numbers.

--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source________________________________________________________________________
2008-07-07: EuroPython 2008, Vilnius, Lithuania

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top