Gmpy2 How to use the installation

Source: Internet
Author: User
Tags gmp

GMP (GNU multiple Precision Arithmetic library, the GNU High Precision Arithmetic database), is an open source high-precision computing library, which not only has ordinary integers, real numbers, floating-point numbers of high-precision operations, as well as random number generation, In particular, it provides a very complete computational interface in number theory, such as miller-rabin Prime number test algorithm, large prime number generation, Euclidean algorithm, inverse of elements in the domain, Jacobi symbols, Legendre symbols, etc.
Gmpy2 is an extended library of Python, a GMP-compliant package, formerly known as the Gmpy, which was adapted and packaged by its authors, making the use of gmpy2 much easier.

-------

1. Install Gmpy2 on Windows

It's much easier to install wheel files directly on Windows.

Https://pypi.python.org/pypi/gmpy2

There are python2.6, 2.7, 3.2, 3.3, 3.4 version of the wheel file, download after the installation with PIP. (3.5 versions are not available for the time being)

2. Install Gmpy2 on Linux

Gmpy2 is dependent on the GMP, MPFR, MPC three libraries, so install the 3 libraries before installing on Linux.

For the convenience of subsequent installations, set up 2 folders first.

mkdir -P $HOME/srcmkdir -P $HOME/static

3. Installation of GMP

GMP (The GNU multiple Precision arithmetic library) is a free Library for arbitrary Precision arithmetic, operating on sign Ed integers, rational numbers, and floating-point numbers.
https://gmplib.org/

Now the newest is 6.1.1

CD $HOME/srcwget https://gmplib.org/download/gmp/gmp-6.1.1.tar.bz2tar -JXVF gmp-6.1. 1. Tar . BZ2CD GMP-6.1. 1 . /configure--prefix= $HOME/static--enable-static--disable-shared--with-picmake make  makeinstall

4, Installation MPFR

The

The MPFR library is a C library for multiple-precision floating-point computations with correct rounding.
http://www.mpfr.org/mpfr-current/#download
is currently the latest 3.1.4

CD $HOME/srcwget http://www.mpfr.org/mpfr-current/mpfr-3.1.4.tar.bz2tar -JXVF mpfr-3.1. 4. Tar . BZ2CD MPFR-3.1. 4 . /configure--prefix= $HOME/static--enable-static--disable-shared--with-pic--with-gmp= $HOME/static  Make  Make  Make Install

5. Installing MPC

GNU MPC is a C library for the arithmetic of complex numbers with arbitrarily high precision and correct rounding of th E result.
Http://www.multiprecision.org/index.php?prog=mpc&page=download
is currently the latest 1.0.3

CD $HOME/srcwgetFTP://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gztar -zxvf mpc-1.0. 3. Tar . GZCD MPC-1.0. 3 . /configure--prefix= $HOME/static--enable-static--disable-shared--with-pic--with-gmp= $HOME/static--with-mpfr=$ home/staticmake make doinstall

6, Installation Gmpy2

CD $HOME/srcgit clone https://github.com/aleaxit/gmpyInstall

After the installation, the command line enters the python mode, enters the import gmpy2 does not have the error to be successful.

7. How to use Gmpy2

Here Pcat is introduced to find the prime number within 100, more gmpy2 use their own search bar, or later to add (←_←).

Import Gmpy2  for  in xrange (100+1):    if  gmpy2.is_prime (i):        Print i

Gmpy2 How to install using

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.