--- /srv/rebuilderd/tmp/rebuilderd7gY6ub/inputs/python-gmpy2-doc_2.2.1-2_all.deb +++ /srv/rebuilderd/tmp/rebuilderd7gY6ub/out/python-gmpy2-doc_2.2.1-2_all.deb ├── file list │ @@ -1,3 +1,3 @@ │ -rw-r--r-- 0 0 0 4 2024-09-13 02:08:43.000000 debian-binary │ --rw-r--r-- 0 0 0 2016 2024-09-13 02:08:43.000000 control.tar.xz │ --rw-r--r-- 0 0 0 91288 2024-09-13 02:08:43.000000 data.tar.xz │ +-rw-r--r-- 0 0 0 2012 2024-09-13 02:08:43.000000 control.tar.xz │ +-rw-r--r-- 0 0 0 90676 2024-09-13 02:08:43.000000 data.tar.xz ├── control.tar.xz │ ├── control.tar │ │ ├── ./control │ │ │ @@ -1,13 +1,13 @@ │ │ │ Package: python-gmpy2-doc │ │ │ Source: python-gmpy2 │ │ │ Version: 2.2.1-2 │ │ │ Architecture: all │ │ │ Maintainer: Martin Kelly │ │ │ -Installed-Size: 1100 │ │ │ +Installed-Size: 1061 │ │ │ Depends: libjs-jquery (>= 3.6.0), libjs-sphinxdoc (>= 7.4), sphinx-rtd-theme-common (>= 2.0.0+dfsg) │ │ │ Recommends: python3-gmpy2 │ │ │ Section: doc │ │ │ Priority: optional │ │ │ Multi-Arch: foreign │ │ │ Homepage: https://github.com/aleaxit/gmpy │ │ │ Description: documentation for python-gmpy2 │ │ ├── ./md5sums │ │ │ ├── ./md5sums │ │ │ │┄ Files differ ├── data.tar.xz │ ├── data.tar │ │ ├── file list │ │ │ @@ -32,34 +32,34 @@ │ │ │ -rw-r--r-- 0 root (0) root (0) 328 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/_static/documentation_options.js │ │ │ -rw-r--r-- 0 root (0) root (0) 286 2024-08-23 06:32:51.000000 ./usr/share/doc/python-gmpy2-doc/html/_static/file.png │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/_static/fonts/ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/_static/js/ │ │ │ -rw-r--r-- 0 root (0) root (0) 90 2024-08-23 06:32:51.000000 ./usr/share/doc/python-gmpy2-doc/html/_static/minus.png │ │ │ -rw-r--r-- 0 root (0) root (0) 90 2024-08-23 06:32:51.000000 ./usr/share/doc/python-gmpy2-doc/html/_static/plus.png │ │ │ -rw-r--r-- 0 root (0) root (0) 4902 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/_static/pygments.css │ │ │ --rw-r--r-- 0 root (0) root (0) 73099 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/advmpz.html │ │ │ --rw-r--r-- 0 root (0) root (0) 178921 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/contexts.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 67709 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/advmpz.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 172724 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/contexts.html │ │ │ -rw-r--r-- 0 root (0) root (0) 12561 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/conversion.html │ │ │ -rw-r--r-- 0 root (0) root (0) 15031 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/cython.html │ │ │ -rw-r--r-- 0 root (0) root (0) 9398 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/exceptions.html │ │ │ --rw-r--r-- 0 root (0) root (0) 20308 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/generic.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 20188 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/generic.html │ │ │ -rw-r--r-- 0 root (0) root (0) 55185 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/genindex.html │ │ │ --rw-r--r-- 0 root (0) root (0) 74392 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/history.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 72262 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/history.html │ │ │ -rw-r--r-- 0 root (0) root (0) 21678 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/index.html │ │ │ -rw-r--r-- 0 root (0) root (0) 9320 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/install.html │ │ │ --rw-r--r-- 0 root (0) root (0) 17331 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/misc.html │ │ │ --rw-r--r-- 0 root (0) root (0) 60027 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/mpc.html │ │ │ --rw-r--r-- 0 root (0) root (0) 138658 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/mpfr.html │ │ │ --rw-r--r-- 0 root (0) root (0) 18862 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/mpq.html │ │ │ --rw-r--r-- 0 root (0) root (0) 136630 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/mpz.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 16126 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/misc.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 56283 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/mpc.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 130050 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/mpfr.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 18104 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/mpq.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 124722 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/mpz.html │ │ │ -rw-r--r-- 0 root (0) root (0) 2884 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/objects.inv │ │ │ --rw-r--r-- 0 root (0) root (0) 8835 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/overview.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 8334 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/overview.html │ │ │ -rw-r--r-- 0 root (0) root (0) 5108 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/search.html │ │ │ -rw-r--r-- 0 root (0) root (0) 82559 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/searchindex.js │ │ │ --rw-r--r-- 0 root (0) root (0) 22073 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/tutorial.html │ │ │ +-rw-r--r-- 0 root (0) root (0) 21691 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/tutorial.html │ │ │ -rw-r--r-- 0 root (0) root (0) 13286 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/win_build.html │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2024-09-13 02:08:43.000000 ./usr/share/doc-base/ │ │ │ -rw-r--r-- 0 root (0) root (0) 287 2024-08-31 21:55:34.000000 ./usr/share/doc-base/python-gmpy2-doc.python-gmpy2-doc │ │ │ lrwxrwxrwx 0 root (0) root (0) 0 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/_static/css/badge_only.css -> ../../../../../sphinx_rtd_theme/static/css/badge_only.css │ │ │ lrwxrwxrwx 0 root (0) root (0) 0 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/_static/css/theme.css -> ../../../../../sphinx_rtd_theme/static/css/theme.css │ │ │ lrwxrwxrwx 0 root (0) root (0) 0 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/_static/doctools.js -> ../../../../javascript/sphinxdoc/1.0/doctools.js │ │ │ lrwxrwxrwx 0 root (0) root (0) 0 2024-09-13 02:08:43.000000 ./usr/share/doc/python-gmpy2-doc/html/_static/fonts/Lato-Bold.ttf -> ../../../../../sphinx_rtd_theme/static/fonts/Lato-Bold.ttf │ │ ├── ./usr/share/doc/python-gmpy2-doc/html/advmpz.html │ │ │ @@ -252,15 +252,15 @@ │ │ │

Return a mutable integer constructed from a numeric value n │ │ │ or a string s made of digits in the given base. Every input, │ │ │ that is accepted by the mpz type constructor is also accepted.

│ │ │

Note: This type can be faster when used for augmented assignment │ │ │ (+=, -=, etc), but xmpz objects cannot be used as dictionary keys.

│ │ │
│ │ │
│ │ │ -__format__(fmt) str
│ │ │ +__format__(fmt) str │ │ │

Return a Python string by formatting mpz 'x' using the format string │ │ │ 'fmt'. A valid format string consists of:

│ │ │
│ │ │

optional alignment code:

│ │ │
│ │ │

'<' -> left shifted in field │ │ │ '>' -> right shifted in field │ │ │ @@ -293,58 +293,58 @@ │ │ │

│ │ │ bit_clear(n, /) mpz
│ │ │

Return a copy of x with the n-th bit cleared.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -bit_count() int
│ │ │ +bit_count() int │ │ │

Return the number of 1-bits set in abs(x).

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ bit_flip(n, /) mpz
│ │ │

Return a copy of x with the n-th bit inverted.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -bit_length() int
│ │ │ +bit_length() int │ │ │

Return the number of significant bits in the radix-2 │ │ │ representation of x. Note: mpz(0).bit_length() returns 0.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -bit_scan0(n=0, /) int | None
│ │ │ +bit_scan0(n=0, /) int | None │ │ │

Return the index of the first 0-bit of x with index >= n. n >= 0. │ │ │ If there are no more 0-bits in x at or above index n (which can │ │ │ only happen for x<0, assuming an infinitely long 2's complement │ │ │ -format), then None is returned.

│ │ │ +format), then None is returned.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -bit_scan1(n=0, /) int | None
│ │ │ +bit_scan1(n=0, /) int | None │ │ │

Return the index of the first 1-bit of x with index >= n. n >= 0. │ │ │ If there are no more 1-bits in x at or above index n (which can │ │ │ only happen for x>=0, assuming an infinitely long 2's complement │ │ │ -format), then None is returned.

│ │ │ +format), then None is returned.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ bit_set(n, /) mpz
│ │ │

Return a copy of x with the n-th bit set.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -bit_test(n, /) bool
│ │ │ +bit_test(n, /) bool │ │ │

Return the value of the n-th bit of x.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ conjugate() mpz
│ │ │

Return the conjugate of x (which is just a new reference to x since x is │ │ │ @@ -355,79 +355,79 @@ │ │ │

│ │ │ copy() xmpz
│ │ │

Return a copy of a x.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -digits(base=10, /) str
│ │ │ +digits(base=10, /) str │ │ │

Return Python string representing x in the given base. Values for │ │ │ base can range between 2 to 62. A leading '-' is present if x<0 │ │ │ but no leading '+' is present if x>=0.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -iter_bits(start=0, stop=-1) collections.abc.Iterator
│ │ │ -

Return True or False for each bit position in x beginning at │ │ │ +iter_bits(start=0, stop=-1) collections.abc.Iterator │ │ │ +

Return True or False for each bit position in x beginning at │ │ │ 'start'. If a positive value is specified for 'stop', iteration is │ │ │ continued until 'stop' is reached. If a negative value is specified, │ │ │ iteration is continued until the last 1-bit. Note: the value of the │ │ │ underlying xmpz object can change during iteration.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -iter_clear(start=0, stop=-1) collections.abc.Iterator
│ │ │ +iter_clear(start=0, stop=-1) collections.abc.Iterator │ │ │

Return every bit position that is clear in x, beginning at │ │ │ 'start'. If a positive value is specified for 'stop', iteration │ │ │ is continued until 'stop' is reached. If a negative value is specified, │ │ │ iteration is continued until the last 1-bit. Note: the value of the │ │ │ underlying xmpz object can change during iteration.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -iter_set(start=0, stop=-1) collections.abc.Iterator
│ │ │ +iter_set(start=0, stop=-1) collections.abc.Iterator │ │ │

Return an iterator yielding the bit position for every bit that │ │ │ is set in x, beginning at 'start'. If a positive value is │ │ │ specified for 'stop', iteration is continued until 'stop' is │ │ │ reached. To match the behavior of slicing, 'stop' is not included. │ │ │ If a negative value is specified, iteration is continued until │ │ │ the last 1-bit. Note: the value of the underlying xmpz object can │ │ │ change during iteration.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -limbs_finish(n, /) None
│ │ │ +limbs_finish(n, /) None │ │ │

Must be called after writing to the address returned by │ │ │ x.limbs_write(n) or x.limbs_modify(n) to update │ │ │ the limbs of x.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -limbs_modify(n, /) int
│ │ │ +limbs_modify(n, /) int │ │ │

Returns the address of a mutable buffer representing the limbs │ │ │ of x, resized so that it may hold at least n limbs. │ │ │ Must be followed by a call to x.limbs_finish(n) after writing to │ │ │ the returned address in order for the changes to take effect.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -limbs_read() int
│ │ │ +limbs_read() int │ │ │

Returns the address of the immutable buffer representing the │ │ │ limbs of x.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -limbs_write(n, /) int
│ │ │ +limbs_write(n, /) int │ │ │

Returns the address of a mutable buffer representing the limbs │ │ │ of x, resized so that it may hold at least n limbs. │ │ │ Must be followed by a call to x.limbs_finish(n) after writing to │ │ │ the returned address in order for the changes to take effect. │ │ │ WARNING: this operation is destructive and may destroy the old │ │ │ value of x.

│ │ │
│ │ │ @@ -437,23 +437,23 @@ │ │ │ make_mpz() mpz │ │ │

Return an mpz by converting x as quickly as possible.

│ │ │

NOTE: Optimized for speed so the original xmpz value is set to 0!

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -num_digits(base=10, /) int
│ │ │ +num_digits(base=10, /) int │ │ │

Return length of string representing the absolute value of x in │ │ │ the given base. Values for base can range between 2 and 62. The │ │ │ value returned may be 1 too large.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -num_limbs() int
│ │ │ +num_limbs() int │ │ │

Return the number of limbs of x.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ denominator
│ │ │

the denominator of a rational number in lowest terms

│ │ │ @@ -478,24 +478,24 @@ │ │ │

Advanced Number Theory Functions

│ │ │

The following functions are based on mpz_lucas.c and mpz_prp.c by David │ │ │ Cleaver.

│ │ │

A good reference for probable prime testing is │ │ │ http://www.pseudoprime.com/pseudo.html

│ │ │
│ │ │
│ │ │ -gmpy2.is_bpsw_prp(n, /) bool
│ │ │ -

Return True if n is a Baillie-Pomerance-Selfridge-Wagstaff probable │ │ │ +gmpy2.is_bpsw_prp(n, /) bool │ │ │ +

Return True if n is a Baillie-Pomerance-Selfridge-Wagstaff probable │ │ │ prime. A BPSW probable prime passes the is_strong_prp() test with base │ │ │ 2 and the is_selfridge_prp() test.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.is_euler_prp(n, a, /) bool
│ │ │ -

Return True if n is an Euler (also known as Solovay-Strassen) │ │ │ +gmpy2.is_euler_prp(n, a, /) bool │ │ │ +

Return True if n is an Euler (also known as Solovay-Strassen) │ │ │ probable prime to the base a. │ │ │ Assuming:

│ │ │
│ │ │

gcd(n,a) == 1 │ │ │ n is odd

│ │ │
│ │ │

Then an Euler probable prime requires:

│ │ │ @@ -503,16 +503,16 @@ │ │ │

a**((n-1)/2) == (a/n) (mod n)

│ │ │
│ │ │

where (a/n) is the Jacobi symbol.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.is_extra_strong_lucas_prp(n, p, /) bool
│ │ │ -

Return True if n is an extra strong Lucas probable prime with parameters │ │ │ +gmpy2.is_extra_strong_lucas_prp(n, p, /) bool │ │ │ +

Return True if n is an extra strong Lucas probable prime with parameters │ │ │ (p,1). Assuming:

│ │ │
│ │ │

n is odd │ │ │ D = p*p - 4, D != 0 │ │ │ gcd(n, 2*D) == 1 │ │ │ n = s*(2**r) + Jacobi(D,n), s odd

│ │ │
│ │ │ @@ -522,80 +522,80 @@ │ │ │ or │ │ │ lucasv(p,1,s*(2**t)) == 0 (mod n) for some t, 0 <= t < r

│ │ │ │ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.is_fermat_prp(n, a, /) bool
│ │ │ -

Return True if n is a Fermat probable prime to the base a. │ │ │ +gmpy2.is_fermat_prp(n, a, /) bool │ │ │ +

Return True if n is a Fermat probable prime to the base a. │ │ │ Assuming:

│ │ │
│ │ │

gcd(n,a) == 1

│ │ │
│ │ │

Then a Fermat probable prime requires:

│ │ │
│ │ │

a**(n-1) == 1 (mod n)

│ │ │
│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.is_fibonacci_prp(n, p, q, /) bool
│ │ │ -

Return True if n is a Fibonacci probable prime with parameters (p,q). │ │ │ +gmpy2.is_fibonacci_prp(n, p, q, /) bool │ │ │ +

Return True if n is a Fibonacci probable prime with parameters (p,q). │ │ │ Assuming:

│ │ │
│ │ │

n is odd │ │ │ p > 0, q = +/-1 │ │ │ p*p - 4*q != 0

│ │ │
│ │ │

Then a Fibonacci probable prime requires:

│ │ │
│ │ │

lucasv(p,q,n) == p (mod n).

│ │ │
│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.is_lucas_prp(n, p, q, /) bool
│ │ │ -

Return True if n is a Lucas probable prime with parameters (p,q). │ │ │ +gmpy2.is_lucas_prp(n, p, q, /) bool │ │ │ +

Return True if n is a Lucas probable prime with parameters (p,q). │ │ │ Assuming:

│ │ │
│ │ │

n is odd │ │ │ D = p*p - 4*q, D != 0 │ │ │ gcd(n, 2*q*D) == 1

│ │ │
│ │ │

Then a Lucas probable prime requires:

│ │ │
│ │ │

lucasu(p,q,n - Jacobi(D,n)) == 0 (mod n)

│ │ │
│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.is_selfridge_prp(n, /) bool
│ │ │ -

Return True if n is a Lucas probable prime with Selfidge parameters │ │ │ +gmpy2.is_selfridge_prp(n, /) bool │ │ │ +

Return True if n is a Lucas probable prime with Selfidge parameters │ │ │ (p,q). The Selfridge parameters are chosen by finding the first │ │ │ element D in the sequence {5, -7, 9, -11, 13, ...} such that │ │ │ Jacobi(D,n) == -1. Then let p=1 and q = (1-D)/4. Then perform │ │ │ a Lucas probable prime test.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.is_strong_bpsw_prp(n, /) bool
│ │ │ -

Return True if n is a strong Baillie-Pomerance-Selfridge-Wagstaff │ │ │ +gmpy2.is_strong_bpsw_prp(n, /) bool │ │ │ +

Return True if n is a strong Baillie-Pomerance-Selfridge-Wagstaff │ │ │ probable prime. A strong BPSW probable prime passes the is_strong_prp() │ │ │ test with base and the is_strong_selfridge_prp() test.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.is_strong_lucas_prp(n, p, q, /) bool
│ │ │ -

Return True if n is a strong Lucas probable prime with parameters (p,q). │ │ │ +gmpy2.is_strong_lucas_prp(n, p, q, /) bool │ │ │ +

Return True if n is a strong Lucas probable prime with parameters (p,q). │ │ │ Assuming:

│ │ │
│ │ │

n is odd │ │ │ D = p*p - 4*q, D != 0 │ │ │ gcd(n, 2*q*D) == 1 │ │ │ n = s*(2**r) + Jacobi(D,n), s odd

│ │ │
│ │ │ @@ -605,16 +605,16 @@ │ │ │ or │ │ │ lucasv(p,q,s*(2**t)) == 0 (mod n) for some t, 0 <= t < r

│ │ │ │ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.is_strong_prp(n, a, /) bool
│ │ │ -

Return True if n is a strong (also known as Miller-Rabin) │ │ │ +gmpy2.is_strong_prp(n, a, /) bool │ │ │ +

Return True if n is a strong (also known as Miller-Rabin) │ │ │ probable prime to the base a. │ │ │ Assuming:

│ │ │
│ │ │

gcd(n,a) == 1 │ │ │ n is odd │ │ │ n = s*(2**r) + 1, with s odd

│ │ │
│ │ │ @@ -624,16 +624,16 @@ │ │ │ or │ │ │ a**(s*(2**t)) == -1 (mod n) for some t, 0 <= t < r.

│ │ │ │ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.is_strong_selfridge_prp(n, /) bool
│ │ │ -

Return True if n is a strong Lucas probable prime with Selfidge │ │ │ +gmpy2.is_strong_selfridge_prp(n, /) bool │ │ │ +

Return True if n is a strong Lucas probable prime with Selfidge │ │ │ parameters (p,q). The Selfridge parameters are chosen by finding │ │ │ the first element D in the sequence {5, -7, 9, -11, 13, ...} such │ │ │ that Jacobi(D,n) == -1. Then let p=1 and q = (1-D)/4. Then perform │ │ │ a strong Lucas probable prime test.

│ │ │
│ │ │ │ │ │
│ │ │ ├── html2text {} │ │ │ │ @@ -158,15 +158,15 @@ │ │ │ │ ccllaassss gmpy2.xmpz(nn==00, //)_ │ │ │ │ ccllaassss gmpy2.xmpz(ss, //, bbaassee==00) │ │ │ │ Return a mutable integer constructed from a numeric value n or a string s │ │ │ │ made of digits in the given base. Every input, that is accepted by the │ │ │ │ _m_p_z type constructor is also accepted. │ │ │ │ Note: This type can be faster when used for augmented assignment (+=, -=, │ │ │ │ etc), but _x_m_p_z objects cannot be used as dictionary keys. │ │ │ │ - __format__(ffmmtt) → _s_t_r_ │ │ │ │ + __format__(ffmmtt) → str_ │ │ │ │ Return a Python string by formatting _m_p_z 'x' using the format │ │ │ │ string 'fmt'. A valid format string consists of: │ │ │ │ optional alignment code: │ │ │ │ '<' -> left shifted in field '>' -> right │ │ │ │ shifted in field '^' -> centered in field │ │ │ │ optional leading sign code: │ │ │ │ '+' -> always display leading sign '-' -> only │ │ │ │ @@ -179,163 +179,163 @@ │ │ │ │ optional conversion code: │ │ │ │ 'd' -> decimal format 'b' -> binary format 'o' │ │ │ │ -> octal format 'x' -> hex format 'X' -> upper- │ │ │ │ case hex format │ │ │ │ The default format is 'd'. │ │ │ │ bit_clear(nn, //) → _m_p_z_ │ │ │ │ Return a copy of x with the n-th bit cleared. │ │ │ │ - bit_count() → _i_n_t_ │ │ │ │ + bit_count() → int_ │ │ │ │ Return the number of 1-bits set in abs(x). │ │ │ │ bit_flip(nn, //) → _m_p_z_ │ │ │ │ Return a copy of x with the n-th bit inverted. │ │ │ │ - bit_length() → _i_n_t_ │ │ │ │ + bit_length() → int_ │ │ │ │ Return the number of significant bits in the radix-2 representation │ │ │ │ of x. Note: mpz(0).bit_length() returns 0. │ │ │ │ - bit_scan0(nn==00, //) → _i_n_t | _N_o_n_e_ │ │ │ │ + bit_scan0(nn==00, //) → int | None_ │ │ │ │ Return the index of the first 0-bit of x with index >= n. n >= 0. │ │ │ │ If there are no more 0-bits in x at or above index n (which can │ │ │ │ only happen for x<0, assuming an infinitely long 2's complement │ │ │ │ - format), then _N_o_n_e is returned. │ │ │ │ - bit_scan1(nn==00, //) → _i_n_t | _N_o_n_e_ │ │ │ │ + format), then None is returned. │ │ │ │ + bit_scan1(nn==00, //) → int | None_ │ │ │ │ Return the index of the first 1-bit of x with index >= n. n >= 0. │ │ │ │ If there are no more 1-bits in x at or above index n (which can │ │ │ │ only happen for x>=0, assuming an infinitely long 2's complement │ │ │ │ - format), then _N_o_n_e is returned. │ │ │ │ + format), then None is returned. │ │ │ │ bit_set(nn, //) → _m_p_z_ │ │ │ │ Return a copy of x with the n-th bit set. │ │ │ │ - bit_test(nn, //) → _b_o_o_l_ │ │ │ │ + bit_test(nn, //) → bool_ │ │ │ │ Return the value of the n-th bit of x. │ │ │ │ conjugate() → _m_p_z_ │ │ │ │ Return the conjugate of x (which is just a new reference to x since │ │ │ │ x is not a complex number). │ │ │ │ copy() → _x_m_p_z_ │ │ │ │ Return a copy of a x. │ │ │ │ - digits(bbaassee==1100, //) → _s_t_r_ │ │ │ │ + digits(bbaassee==1100, //) → str_ │ │ │ │ Return Python string representing x in the given base. Values for │ │ │ │ base can range between 2 to 62. A leading '-' is present if x<0 but │ │ │ │ no leading '+' is present if x>=0. │ │ │ │ - iter_bits(ssttaarrtt==00, ssttoopp==--11) → _c_o_l_l_e_c_t_i_o_n_s_._a_b_c_._I_t_e_r_a_t_o_r_ │ │ │ │ - Return _T_r_u_e or _F_a_l_s_e for each bit position in x beginning at │ │ │ │ + iter_bits(ssttaarrtt==00, ssttoopp==--11) → collections.abc.Iterator_ │ │ │ │ + Return True or False for each bit position in x beginning at │ │ │ │ 'start'. If a positive value is specified for 'stop', iteration is │ │ │ │ continued until 'stop' is reached. If a negative value is │ │ │ │ specified, iteration is continued until the last 1-bit. Note: the │ │ │ │ value of the underlying _x_m_p_z object can change during iteration. │ │ │ │ - iter_clear(ssttaarrtt==00, ssttoopp==--11) → _c_o_l_l_e_c_t_i_o_n_s_._a_b_c_._I_t_e_r_a_t_o_r_ │ │ │ │ + iter_clear(ssttaarrtt==00, ssttoopp==--11) → collections.abc.Iterator_ │ │ │ │ Return every bit position that is clear in x, beginning at 'start'. │ │ │ │ If a positive value is specified for 'stop', iteration is continued │ │ │ │ until 'stop' is reached. If a negative value is specified, │ │ │ │ iteration is continued until the last 1-bit. Note: the value of the │ │ │ │ underlying _x_m_p_z object can change during iteration. │ │ │ │ - iter_set(ssttaarrtt==00, ssttoopp==--11) → _c_o_l_l_e_c_t_i_o_n_s_._a_b_c_._I_t_e_r_a_t_o_r_ │ │ │ │ + iter_set(ssttaarrtt==00, ssttoopp==--11) → collections.abc.Iterator_ │ │ │ │ Return an iterator yielding the bit position for every bit that is │ │ │ │ set in x, beginning at 'start'. If a positive value is specified │ │ │ │ for 'stop', iteration is continued until 'stop' is reached. To │ │ │ │ match the behavior of slicing, 'stop' is not included. If a │ │ │ │ negative value is specified, iteration is continued until the last │ │ │ │ 1-bit. Note: the value of the underlying _x_m_p_z object can change │ │ │ │ during iteration. │ │ │ │ - limbs_finish(nn, //) → _N_o_n_e_ │ │ │ │ + limbs_finish(nn, //) → None_ │ │ │ │ Must be called after writing to the address returned by │ │ │ │ x.limbs_write(n) or x.limbs_modify(n) to update the limbs of x. │ │ │ │ - limbs_modify(nn, //) → _i_n_t_ │ │ │ │ + limbs_modify(nn, //) → int_ │ │ │ │ Returns the address of a mutable buffer representing the limbs of │ │ │ │ x, resized so that it may hold at least n limbs. Must be followed │ │ │ │ by a call to x.limbs_finish(n) after writing to the returned │ │ │ │ address in order for the changes to take effect. │ │ │ │ - limbs_read() → _i_n_t_ │ │ │ │ + limbs_read() → int_ │ │ │ │ Returns the address of the immutable buffer representing the limbs │ │ │ │ of x. │ │ │ │ - limbs_write(nn, //) → _i_n_t_ │ │ │ │ + limbs_write(nn, //) → int_ │ │ │ │ Returns the address of a mutable buffer representing the limbs of │ │ │ │ x, resized so that it may hold at least n limbs. Must be followed │ │ │ │ by a call to x.limbs_finish(n) after writing to the returned │ │ │ │ address in order for the changes to take effect. WARNING: this │ │ │ │ operation is destructive and may destroy the old value of x. │ │ │ │ make_mpz() → _m_p_z_ │ │ │ │ Return an _m_p_z by converting x as quickly as possible. │ │ │ │ NOTE: Optimized for speed so the original _x_m_p_z value is set to 0! │ │ │ │ - num_digits(bbaassee==1100, //) → _i_n_t_ │ │ │ │ + num_digits(bbaassee==1100, //) → int_ │ │ │ │ Return length of string representing the absolute value of x in the │ │ │ │ given base. Values for base can range between 2 and 62. The value │ │ │ │ returned may be 1 too large. │ │ │ │ - num_limbs() → _i_n_t_ │ │ │ │ + num_limbs() → int_ │ │ │ │ Return the number of limbs of x. │ │ │ │ denominator_ │ │ │ │ the denominator of a rational number in lowest terms │ │ │ │ numerator_ │ │ │ │ the numerator of a rational number in lowest terms │ │ │ │ real_ │ │ │ │ the real part of a complex number │ │ │ │ ********** AAddvvaanncceedd NNuummbbeerr TThheeoorryy FFuunnccttiioonnss_? ********** │ │ │ │ The following functions are based on mpz_lucas.c and mpz_prp.c by David │ │ │ │ Cleaver. │ │ │ │ A good reference for probable prime testing is _h_t_t_p_:_/_/_w_w_w_._p_s_e_u_d_o_p_r_i_m_e_._c_o_m_/ │ │ │ │ _p_s_e_u_d_o_._h_t_m_l │ │ │ │ - gmpy2.is_bpsw_prp(nn, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if n is a Baillie-Pomerance-Selfridge-Wagstaff probable │ │ │ │ + gmpy2.is_bpsw_prp(nn, //) → bool_ │ │ │ │ + Return True if n is a Baillie-Pomerance-Selfridge-Wagstaff probable │ │ │ │ prime. A BPSW probable prime passes the _i_s___s_t_r_o_n_g___p_r_p_(_) test with base 2 │ │ │ │ and the _i_s___s_e_l_f_r_i_d_g_e___p_r_p_(_) test. │ │ │ │ - gmpy2.is_euler_prp(nn, aa, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if n is an Euler (also known as Solovay-Strassen) probable │ │ │ │ + gmpy2.is_euler_prp(nn, aa, //) → bool_ │ │ │ │ + Return True if n is an Euler (also known as Solovay-Strassen) probable │ │ │ │ prime to the base a. Assuming: │ │ │ │ gcd(n,a) == 1 n is odd │ │ │ │ Then an Euler probable prime requires: │ │ │ │ a**((n-1)/2) == (a/n) (mod n) │ │ │ │ where (a/n) is the Jacobi symbol. │ │ │ │ - gmpy2.is_extra_strong_lucas_prp(nn, pp, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if n is an extra strong Lucas probable prime with parameters │ │ │ │ + gmpy2.is_extra_strong_lucas_prp(nn, pp, //) → bool_ │ │ │ │ + Return True if n is an extra strong Lucas probable prime with parameters │ │ │ │ (p,1). Assuming: │ │ │ │ n is odd D = p*p - 4, D != 0 gcd(n, 2*D) == 1 n = s*(2**r) + │ │ │ │ Jacobi(D,n), s odd │ │ │ │ Then an extra strong Lucas probable prime requires: │ │ │ │ lucasu(p,1,s) == 0 (mod n) and lucasv(p,1,s) == +/-2 (mod n) or │ │ │ │ lucasv(p,1,s*(2**t)) == 0 (mod n) for some t, 0 <= t < r │ │ │ │ - gmpy2.is_fermat_prp(nn, aa, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if n is a Fermat probable prime to the base a. Assuming: │ │ │ │ + gmpy2.is_fermat_prp(nn, aa, //) → bool_ │ │ │ │ + Return True if n is a Fermat probable prime to the base a. Assuming: │ │ │ │ gcd(n,a) == 1 │ │ │ │ Then a Fermat probable prime requires: │ │ │ │ a**(n-1) == 1 (mod n) │ │ │ │ - gmpy2.is_fibonacci_prp(nn, pp, qq, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if n is a Fibonacci probable prime with parameters (p,q). │ │ │ │ + gmpy2.is_fibonacci_prp(nn, pp, qq, //) → bool_ │ │ │ │ + Return True if n is a Fibonacci probable prime with parameters (p,q). │ │ │ │ Assuming: │ │ │ │ n is odd p > 0, q = +/-1 p*p - 4*q != 0 │ │ │ │ Then a Fibonacci probable prime requires: │ │ │ │ lucasv(p,q,n) == p (mod n). │ │ │ │ - gmpy2.is_lucas_prp(nn, pp, qq, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if n is a Lucas probable prime with parameters (p,q). │ │ │ │ + gmpy2.is_lucas_prp(nn, pp, qq, //) → bool_ │ │ │ │ + Return True if n is a Lucas probable prime with parameters (p,q). │ │ │ │ Assuming: │ │ │ │ n is odd D = p*p - 4*q, D != 0 gcd(n, 2*q*D) == 1 │ │ │ │ Then a Lucas probable prime requires: │ │ │ │ lucasu(p,q,n - Jacobi(D,n)) == 0 (mod n) │ │ │ │ - gmpy2.is_selfridge_prp(nn, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if n is a Lucas probable prime with Selfidge parameters │ │ │ │ + gmpy2.is_selfridge_prp(nn, //) → bool_ │ │ │ │ + Return True if n is a Lucas probable prime with Selfidge parameters │ │ │ │ (p,q). The Selfridge parameters are chosen by finding the first element D │ │ │ │ in the sequence {5, -7, 9, -11, 13, ...} such that Jacobi(D,n) == -1. │ │ │ │ Then let p=1 and q = (1-D)/4. Then perform a Lucas probable prime test. │ │ │ │ - gmpy2.is_strong_bpsw_prp(nn, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if n is a strong Baillie-Pomerance-Selfridge-Wagstaff │ │ │ │ + gmpy2.is_strong_bpsw_prp(nn, //) → bool_ │ │ │ │ + Return True if n is a strong Baillie-Pomerance-Selfridge-Wagstaff │ │ │ │ probable prime. A strong BPSW probable prime passes the _i_s___s_t_r_o_n_g___p_r_p_(_) │ │ │ │ test with base and the _i_s___s_t_r_o_n_g___s_e_l_f_r_i_d_g_e___p_r_p_(_) test. │ │ │ │ - gmpy2.is_strong_lucas_prp(nn, pp, qq, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if n is a strong Lucas probable prime with parameters (p,q). │ │ │ │ + gmpy2.is_strong_lucas_prp(nn, pp, qq, //) → bool_ │ │ │ │ + Return True if n is a strong Lucas probable prime with parameters (p,q). │ │ │ │ Assuming: │ │ │ │ n is odd D = p*p - 4*q, D != 0 gcd(n, 2*q*D) == 1 n = s*(2**r) │ │ │ │ + Jacobi(D,n), s odd │ │ │ │ Then a strong Lucas probable prime requires: │ │ │ │ lucasu(p,q,s) == 0 (mod n) or lucasv(p,q,s*(2**t)) == 0 (mod n) │ │ │ │ for some t, 0 <= t < r │ │ │ │ - gmpy2.is_strong_prp(nn, aa, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if n is a strong (also known as Miller-Rabin) probable prime │ │ │ │ + gmpy2.is_strong_prp(nn, aa, //) → bool_ │ │ │ │ + Return True if n is a strong (also known as Miller-Rabin) probable prime │ │ │ │ to the base a. Assuming: │ │ │ │ gcd(n,a) == 1 n is odd n = s*(2**r) + 1, with s odd │ │ │ │ Then a strong probable prime requires one of the following is true: │ │ │ │ a**s == 1 (mod n) or a**(s*(2**t)) == -1 (mod n) for some t, 0 │ │ │ │ <= t < r. │ │ │ │ - gmpy2.is_strong_selfridge_prp(nn, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if n is a strong Lucas probable prime with Selfidge │ │ │ │ + gmpy2.is_strong_selfridge_prp(nn, //) → bool_ │ │ │ │ + Return True if n is a strong Lucas probable prime with Selfidge │ │ │ │ parameters (p,q). The Selfridge parameters are chosen by finding the │ │ │ │ first element D in the sequence {5, -7, 9, -11, 13, ...} such that Jacobi │ │ │ │ (D,n) == -1. Then let p=1 and q = (1-D)/4. Then perform a strong Lucas │ │ │ │ probable prime test. │ │ │ │ gmpy2.lucasu(pp, qq, kk, //) → _m_p_z_ │ │ │ │ Return the k-th element of the Lucas U sequence defined by p,q. p*p - 4*q │ │ │ │ must not equal 0; k must be greater than or equal to 0. │ │ ├── ./usr/share/doc/python-gmpy2-doc/html/contexts.html │ │ │ @@ -344,15 +344,15 @@ │ │ │ check_range(x, /) mpfr │ │ │

Return a new mpfr with exponent that lies within the range of emin │ │ │ and emax specified by context.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -clear_flags() None
│ │ │ +clear_flags() None │ │ │

Clear all MPFR exception flags.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ const_catalan() mpfr
│ │ │

Return the catalan constant using the context's precision.

│ │ │ @@ -441,15 +441,15 @@ │ │ │
│ │ │ div_2exp(x, n, /) mpfr | mpc
│ │ │

Return mpfr or mpc divided by 2**n.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -divmod(x, y, /) tuple[mpz | mpfr, mpz | mpq | mpfr]
│ │ │ +divmod(x, y, /) tuple[mpz | mpfr, mpz | mpq | mpfr] │ │ │

Return divmod(x, y).

│ │ │

Note: overflow, underflow, and inexact exceptions are not supported for │ │ │ mpfr arguments.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ @@ -546,16 +546,16 @@ │ │ │
│ │ │ frac(x, /) mpfr
│ │ │

Return fractional part of x.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -frexp(x, /) tuple[int, mpfr]
│ │ │ -

Return a tuple containing the exponent and mantissa of x.

│ │ │ +frexp(x, /) tuple[int, mpfr] │ │ │ +

Return a tuple containing the exponent and mantissa of x.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ fsum(iterable, /) mpfr
│ │ │

Return an accurate sum of the values in the iterable.

│ │ │
│ │ │ @@ -576,54 +576,54 @@ │ │ │
│ │ │ hypot(x, y, /) mpfr
│ │ │

Return square root of (x**2 + y**2).

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -is_finite(x, /) bool
│ │ │ -

Return True if x is an actual number (i.e. non NaN or Infinity). If x is │ │ │ -an mpc, return True if both x.real and x.imag are finite.

│ │ │ +is_finite(x, /) bool │ │ │ +

Return True if x is an actual number (i.e. non NaN or Infinity). If x is │ │ │ +an mpc, return True if both x.real and x.imag are finite.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -is_infinite(x, /) bool
│ │ │ -

Return True if x is +Infinity or -Infinity. If x is an mpc, return True │ │ │ -if either x.real or x.imag is infinite. Otherwise return False.

│ │ │ +is_infinite(x, /) bool │ │ │ +

Return True if x is +Infinity or -Infinity. If x is an mpc, return True │ │ │ +if either x.real or x.imag is infinite. Otherwise return False.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -is_integer(x, /) bool
│ │ │ -

Return True if x is an integer; False otherwise.

│ │ │ +is_integer(x, /) bool │ │ │ +

Return True if x is an integer; False otherwise.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -is_nan(x, /) bool
│ │ │ -

Return True if x is NaN (Not-A-Number) else False.

│ │ │ +is_nan(x, /) bool │ │ │ +

Return True if x is NaN (Not-A-Number) else False.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -is_regular(x, /) bool
│ │ │ -

Return True if x is not zero, NaN, or Infinity; False otherwise.

│ │ │ +is_regular(x, /) bool │ │ │ +

Return True if x is not zero, NaN, or Infinity; False otherwise.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -is_signed(x, /) bool
│ │ │ -

Return True if the sign bit of x is set.

│ │ │ +is_signed(x, /) bool │ │ │ +

Return True if the sign bit of x is set.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -is_zero(x, /) bool
│ │ │ -

Return True if x is equal to 0. If x is an mpc, return True if both x.real │ │ │ +is_zero(x, /) bool │ │ │ +

Return True if x is equal to 0. If x is an mpc, return True if both x.real │ │ │ and x.imag are equal to 0.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ j0(x, /) mpfr
│ │ │

Return first kind Bessel function of order 0 of x.

│ │ │ @@ -640,16 +640,16 @@ │ │ │ jn(n, x, /) mpfr │ │ │

Return the first kind Bessel function of order n of x. │ │ │ Note: the order of the arguments changed in gmpy2 2.2.0a2

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -lgamma(x, /) tuple[mpfr, int]
│ │ │ -

Return a tuple containing the logarithm of the absolute value of │ │ │ +lgamma(x, /) tuple[mpfr, int] │ │ │ +

Return a tuple containing the logarithm of the absolute value of │ │ │ gamma(x) and the sign of gamma(x)

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ li2(x, /) mpfr
│ │ │

Return real part of dilogarithm of x.

│ │ │ @@ -713,16 +713,16 @@ │ │ │

Return mod(x, y). │ │ │ Note: overflow, underflow, and inexact exceptions are not supported for │ │ │ mpfr arguments.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -modf(x, /) tuple[mpfr, mpfr]
│ │ │ -

Return a tuple containing the integer and fractional portions │ │ │ +modf(x, /) tuple[mpfr, mpfr] │ │ │ +

Return a tuple containing the integer and fractional portions │ │ │ of x.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ mul(x, y, /) mpz | mpq | mpfr | mpc
│ │ │

Return x * y.

│ │ │ @@ -770,15 +770,15 @@ │ │ │
│ │ │ plus(x, /) mpz | mpq | mpfr | mpc
│ │ │

Return +x, the context is applied to the result.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -polar(x, /) tuple[mpfr, mpfr]
│ │ │ +polar(x, /) tuple[mpfr, mpfr] │ │ │

Return the polar coordinate form of a complex x that is in │ │ │ rectangular form.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ pow(x, y, /) mpz | mpq | mpfr | mpc
│ │ │ @@ -823,16 +823,16 @@ │ │ │ remainder(x, y, /) mpfr │ │ │

Return x - n*y where n is the integer quotient of x/y, rounded to │ │ │ the nearest integer and ties rounded to even.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -remquo(x, y, /) tuple[mpfr, int]
│ │ │ -

Return a tuple containing the remainder(x,y) and the low bits of the │ │ │ +remquo(x, y, /) tuple[mpfr, int] │ │ │ +

Return a tuple containing the remainder(x,y) and the low bits of the │ │ │ quotient.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ rint(x, /) mpfr
│ │ │

Return x rounded to the nearest integer using the context rounding │ │ │ @@ -921,28 +921,28 @@ │ │ │

│ │ │ sin(x, /) mpfr | mpc
│ │ │

Return sine of x; x in radians.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -sin_cos(x, /) tuple[mpfr | mpc, mpfr | mpc]
│ │ │ +sin_cos(x, /) tuple[mpfr | mpc, mpfr | mpc] │ │ │

Return a tuple containing the sine and cosine of x; x in radians.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ sinh(x, /) mpfr | mpc
│ │ │

Return hyperbolic sine of x.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -sinh_cosh(x, /) tuple[mpfr, mpfr]
│ │ │ -

Return a tuple containing the hyperbolic sine and cosine of x.

│ │ │ +sinh_cosh(x, /) tuple[mpfr, mpfr] │ │ │ +

Return a tuple containing the hyperbolic sine and cosine of x.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ sqrt(x, /) mpfr | mpc
│ │ │

Return the square root of x.

│ │ │
│ │ │ @@ -1009,15 +1009,15 @@ │ │ │

This attribute controls whether or not an mpc result can be returned │ │ │ if an mpfr result would normally not be possible.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ allow_release_gil
│ │ │ -

If set to True, many mpz and mpq computations will release the GIL.

│ │ │ +

If set to True, many mpz and mpq computations will release the GIL.

│ │ │

This is considered an experimental feature.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ divzero
│ │ │

This flag is not user controllable. It is automatically set if a │ │ │ @@ -1076,15 +1076,15 @@ │ │ │ invalid (Not-A-Number) result is returned.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ overflow
│ │ │

This flag is not user controllable. It is automatically set if a │ │ │ -result overflowed to +/-Infinity and trap_overflow is False.

│ │ │ +result overflowed to +/-Infinity and trap_overflow is False.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ precision
│ │ │

This attribute controls the precision of an mpfr result. The │ │ │ precision is specified in bits, not decimal digits. The maximum │ │ │ @@ -1093,15 +1093,15 @@ │ │ │

Note: Specifying a value for precision that is too close to the │ │ │ maximum precision will cause the MPFR library to fail.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ rational_division
│ │ │ -

If set to True, mpz / mpz will return an mpq instead of an mpfr.

│ │ │ +

If set to True, mpz / mpz will return an mpq instead of an mpfr.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ real_prec
│ │ │

This attribute controls the precision of the real part of an mpc │ │ │ result. If the value is Default, then the value of the precision │ │ │ @@ -1139,23 +1139,23 @@ │ │ │

│ │ │ │ │ │
│ │ │
│ │ │ trap_divzero
│ │ │

This attribute controls whether or not a DivisionByZeroError exception │ │ │ is raised if division by 0 occurs. The DivisionByZeroError is a │ │ │ -sub-class of Python’s ZeroDivisionError.

│ │ │ +sub-class of Python’s ZeroDivisionError.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ trap_erange
│ │ │

This attribute controls whether or not a RangeError exception is │ │ │ raised when certain operations are performed on NaN and/or Infinity │ │ │ -values. Setting trap_erange to True can be used to raise an exception │ │ │ +values. Setting trap_erange to True can be used to raise an exception │ │ │ if comparisons are attempted with a NaN.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ trap_inexact
│ │ │

This attribute controls whether or not an InexactResultError exception │ │ │ @@ -1167,41 +1167,41 @@ │ │ │

│ │ │
│ │ │ trap_invalid
│ │ │

This attribute controls whether or not an InvalidOperationError │ │ │ exception is raised if a numerical result is not defined. A │ │ │ special NaN (Not-A-Number) value will be returned if an exception │ │ │ is not raised. The InvalidOperationError is a sub-class of │ │ │ -Python’s ValueError.

│ │ │ +Python’s ValueError.

│ │ │

For example, gmpy2.sqrt(-2) will normally │ │ │ -return mpfr(‘nan’). However, if allow_complex is set to True, │ │ │ +return mpfr(‘nan’). However, if allow_complex is set to True, │ │ │ then an mpc result will be returned.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ trap_overflow
│ │ │ -

If set to False, a result that is larger than the largest possible │ │ │ +

If set to False, a result that is larger than the largest possible │ │ │ mpfr given the current exponent range will be replaced by +/-Infinity. │ │ │ -If set to True, an OverflowResultError exception is raised.

│ │ │ +If set to True, an OverflowResultError exception is raised.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ trap_underflow
│ │ │ -

If set to False, a result that is smaller than the smallest possible │ │ │ +

If set to False, a result that is smaller than the smallest possible │ │ │ mpfr given the current exponent range will be replaced by +/-0.0. │ │ │ -If set to True, an UnderflowResultError exception is raised.

│ │ │ +If set to True, an UnderflowResultError exception is raised.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ underflow
│ │ │

This flag is not user controllable. It is automatically set if a │ │ │ -result underflowed to +/-0.0 and trap_underflow is False.

│ │ │ +result underflowed to +/-0.0 and trap_underflow is False.

│ │ │
│ │ │ │ │ │
│ │ │ │ │ │ │ │ │
│ │ │

Context Functions

│ │ │ @@ -1227,15 +1227,15 @@ │ │ │

Return a new context for controlling gmpy2 arithmetic, based either │ │ │ on the current context or on a ctx value. Context options additionally │ │ │ can be overridden by keyword arguments.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.set_context(context, /) None
│ │ │ +gmpy2.set_context(context, /) None │ │ │

Activate a context object controlling gmpy2 arithmetic.

│ │ │
│ │ │ │ │ │
│ │ │ │ │ │ ├── html2text {} │ │ │ │ @@ -207,15 +207,15 @@ │ │ │ │ cbrt(xx, //) → _m_p_f_r_ │ │ │ │ Return the cube root of x. │ │ │ │ ceil(xx, //) → _m_p_f_r_ │ │ │ │ Return an _m_p_f_r that is the smallest integer >= x. │ │ │ │ check_range(xx, //) → _m_p_f_r_ │ │ │ │ Return a new _m_p_f_r with exponent that lies within the range of emin │ │ │ │ and emax specified by context. │ │ │ │ - clear_flags() → _N_o_n_e_ │ │ │ │ + clear_flags() → None_ │ │ │ │ Clear all MPFR exception flags. │ │ │ │ const_catalan() → _m_p_f_r_ │ │ │ │ Return the catalan constant using the context's precision. │ │ │ │ const_euler() → _m_p_f_r_ │ │ │ │ Return the euler constant using the context's precision. │ │ │ │ const_log2() → _m_p_f_r_ │ │ │ │ Return the log2 constant using the context's precision. │ │ │ │ @@ -240,15 +240,15 @@ │ │ │ │ result may not be correctly rounded. │ │ │ │ digamma(xx, //) → _m_p_f_r_ │ │ │ │ Return digamma of x. │ │ │ │ div(xx, yy, //) → _m_p_z | _m_p_q | _m_p_f_r | _m_p_c_ │ │ │ │ Return x / y; uses true division. │ │ │ │ div_2exp(xx, nn, //) → _m_p_f_r | _m_p_c_ │ │ │ │ Return _m_p_f_r or _m_p_c divided by 2**n. │ │ │ │ - divmod(xx, yy, //) → _t_u_p_l_e[_m_p_z | _m_p_f_r, _m_p_z | _m_p_q | _m_p_f_r]_ │ │ │ │ + divmod(xx, yy, //) → tuple[_m_p_z | _m_p_f_r, _m_p_z | _m_p_q | _m_p_f_r]_ │ │ │ │ Return divmod(x, y). │ │ │ │ Note: overflow, underflow, and inexact exceptions are not supported │ │ │ │ for _m_p_f_r arguments. │ │ │ │ eint(xx, //) → _m_p_f_r_ │ │ │ │ Return exponential integral of x. │ │ │ │ erf(xx, //) → _m_p_f_r_ │ │ │ │ Return error function of x. │ │ │ │ @@ -278,51 +278,51 @@ │ │ │ │ fmod(xx, yy, //) → _m_p_f_r_ │ │ │ │ Return x - n*y where n is the integer quotient of x/y, rounded to │ │ │ │ 0. │ │ │ │ fms(xx, yy, zz, //) → _m_p_z | _m_p_q | _m_p_f_r | _m_p_c_ │ │ │ │ Return correctly rounded result of (x * y) - z. │ │ │ │ frac(xx, //) → _m_p_f_r_ │ │ │ │ Return fractional part of x. │ │ │ │ - frexp(xx, //) → _t_u_p_l_e[_i_n_t, _m_p_f_r]_ │ │ │ │ - Return a _t_u_p_l_e containing the exponent and mantissa of x. │ │ │ │ + frexp(xx, //) → tuple[int, _m_p_f_r]_ │ │ │ │ + Return a tuple containing the exponent and mantissa of x. │ │ │ │ fsum(iitteerraabbllee, //) → _m_p_f_r_ │ │ │ │ Return an accurate sum of the values in the iterable. │ │ │ │ gamma(xx, //) → _m_p_f_r_ │ │ │ │ Return gamma of x. │ │ │ │ gamma_inc(aa, xx, //) → _m_p_f_r_ │ │ │ │ Return (upper) incomplete gamma of a and x. │ │ │ │ hypot(xx, yy, //) → _m_p_f_r_ │ │ │ │ Return square root of (x**2 + y**2). │ │ │ │ - is_finite(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is an actual number (i.e. non NaN or Infinity). If │ │ │ │ - x is an _m_p_c, return _T_r_u_e if both x.real and x.imag are finite. │ │ │ │ - is_infinite(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is +Infinity or -Infinity. If x is an _m_p_c, return │ │ │ │ - _T_r_u_e if either x.real or x.imag is infinite. Otherwise return │ │ │ │ - _F_a_l_s_e. │ │ │ │ - is_integer(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is an integer; _F_a_l_s_e otherwise. │ │ │ │ - is_nan(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is NaN (Not-A-Number) else _F_a_l_s_e. │ │ │ │ - is_regular(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is not zero, NaN, or Infinity; _F_a_l_s_e otherwise. │ │ │ │ - is_signed(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if the sign bit of x is set. │ │ │ │ - is_zero(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is equal to 0. If x is an _m_p_c, return _T_r_u_e if both │ │ │ │ + is_finite(xx, //) → bool_ │ │ │ │ + Return True if x is an actual number (i.e. non NaN or Infinity). If │ │ │ │ + x is an _m_p_c, return True if both x.real and x.imag are finite. │ │ │ │ + is_infinite(xx, //) → bool_ │ │ │ │ + Return True if x is +Infinity or -Infinity. If x is an _m_p_c, return │ │ │ │ + True if either x.real or x.imag is infinite. Otherwise return │ │ │ │ + False. │ │ │ │ + is_integer(xx, //) → bool_ │ │ │ │ + Return True if x is an integer; False otherwise. │ │ │ │ + is_nan(xx, //) → bool_ │ │ │ │ + Return True if x is NaN (Not-A-Number) else False. │ │ │ │ + is_regular(xx, //) → bool_ │ │ │ │ + Return True if x is not zero, NaN, or Infinity; False otherwise. │ │ │ │ + is_signed(xx, //) → bool_ │ │ │ │ + Return True if the sign bit of x is set. │ │ │ │ + is_zero(xx, //) → bool_ │ │ │ │ + Return True if x is equal to 0. If x is an _m_p_c, return True if both │ │ │ │ x.real and x.imag are equal to 0. │ │ │ │ j0(xx, //) → _m_p_f_r_ │ │ │ │ Return first kind Bessel function of order 0 of x. │ │ │ │ j1(xx, //) → _m_p_f_r_ │ │ │ │ Return first kind Bessel function of order 1 of x. │ │ │ │ jn(nn, xx, //) → _m_p_f_r_ │ │ │ │ Return the first kind Bessel function of order n of x. Note: the │ │ │ │ order of the arguments changed in gmpy2 2.2.0a2 │ │ │ │ - lgamma(xx, //) → _t_u_p_l_e[_m_p_f_r, _i_n_t]_ │ │ │ │ - Return a _t_u_p_l_e containing the logarithm of the absolute value of │ │ │ │ + lgamma(xx, //) → tuple[_m_p_f_r, int]_ │ │ │ │ + Return a tuple containing the logarithm of the absolute value of │ │ │ │ gamma(x) and the sign of gamma(x) │ │ │ │ li2(xx, //) → _m_p_f_r_ │ │ │ │ Return real part of dilogarithm of x. │ │ │ │ lngamma(xx, //) → _m_p_f_r_ │ │ │ │ Return natural logarithm of gamma(x). │ │ │ │ log(xx, //) → _m_p_f_r | _m_p_c_ │ │ │ │ Return the natural logarithm of x. │ │ │ │ @@ -343,16 +343,16 @@ │ │ │ │ context. If only one of x or y is a number, then that number is │ │ │ │ returned. │ │ │ │ minus(xx, //) → _m_p_z | _m_p_q | _m_p_f_r | _m_p_c_ │ │ │ │ Return -x. The context is applied to the result. │ │ │ │ mod(xx, yy, //) → _m_p_z | _m_p_q | _m_p_f_r_ │ │ │ │ Return mod(x, y). Note: overflow, underflow, and inexact exceptions │ │ │ │ are not supported for _m_p_f_r arguments. │ │ │ │ - modf(xx, //) → _t_u_p_l_e[_m_p_f_r, _m_p_f_r]_ │ │ │ │ - Return a _t_u_p_l_e containing the integer and fractional portions of x. │ │ │ │ + modf(xx, //) → tuple[_m_p_f_r, _m_p_f_r]_ │ │ │ │ + Return a tuple containing the integer and fractional portions of x. │ │ │ │ mul(xx, yy, //) → _m_p_z | _m_p_q | _m_p_f_r | _m_p_c_ │ │ │ │ Return x * y. │ │ │ │ mul_2exp(xx, nn, //) → _m_p_f_r | _m_p_c_ │ │ │ │ Return _m_p_f_r or _m_p_c multiplied by 2**n. │ │ │ │ next_above(xx, //) → _m_p_f_r_ │ │ │ │ Return the next _m_p_f_r from x toward +Infinity. │ │ │ │ next_below(xx, //) → _m_p_f_r_ │ │ │ │ @@ -363,15 +363,15 @@ │ │ │ │ norm(xx, //) → _m_p_f_r_ │ │ │ │ Return the norm of a complex x. The norm(x) is defined as x.real**2 │ │ │ │ + x.imag**2. abs(x) is the square root of norm(x). │ │ │ │ phase(xx, //) → _m_p_f_r_ │ │ │ │ Return the phase angle, also known as argument, of a complex x. │ │ │ │ plus(xx, //) → _m_p_z | _m_p_q | _m_p_f_r | _m_p_c_ │ │ │ │ Return +x, the context is applied to the result. │ │ │ │ - polar(xx, //) → _t_u_p_l_e[_m_p_f_r, _m_p_f_r]_ │ │ │ │ + polar(xx, //) → tuple[_m_p_f_r, _m_p_f_r]_ │ │ │ │ Return the polar coordinate form of a complex x that is in │ │ │ │ rectangular form. │ │ │ │ pow(xx, yy, //) → _m_p_z | _m_p_q | _m_p_f_r | _m_p_c_ │ │ │ │ Return x ** y. │ │ │ │ proj(xx, //) → _m_p_c_ │ │ │ │ Returns the projection of a complex x on to the Riemann sphere. │ │ │ │ radians(xx, //) → _m_p_f_r_ │ │ │ │ @@ -384,16 +384,16 @@ │ │ │ │ given in polar form. │ │ │ │ reldiff(xx, yy, //) → _m_p_f_r_ │ │ │ │ Return the relative difference between x and y. Result is equal to │ │ │ │ abs(x-y)/x. │ │ │ │ remainder(xx, yy, //) → _m_p_f_r_ │ │ │ │ Return x - n*y where n is the integer quotient of x/y, rounded to │ │ │ │ the nearest integer and ties rounded to even. │ │ │ │ - remquo(xx, yy, //) → _t_u_p_l_e[_m_p_f_r, _i_n_t]_ │ │ │ │ - Return a _t_u_p_l_e containing the remainder(x,y) and the low bits of │ │ │ │ + remquo(xx, yy, //) → tuple[_m_p_f_r, int]_ │ │ │ │ + Return a tuple containing the remainder(x,y) and the low bits of │ │ │ │ the quotient. │ │ │ │ rint(xx, //) → _m_p_f_r_ │ │ │ │ Return x rounded to the nearest integer using the context rounding │ │ │ │ mode. │ │ │ │ rint_ceil(xx, //) → _m_p_f_r_ │ │ │ │ Return x rounded to the nearest integer by first rounding to the │ │ │ │ next higher or equal integer and then, if needed, using the context │ │ │ │ @@ -427,20 +427,20 @@ │ │ │ │ rounded away from 0. │ │ │ │ sec(xx, //) → _m_p_f_r_ │ │ │ │ Return secant of x; x in radians. │ │ │ │ sech(xx, //) → _m_p_f_r_ │ │ │ │ Return hyperbolic secant of x. │ │ │ │ sin(xx, //) → _m_p_f_r | _m_p_c_ │ │ │ │ Return sine of x; x in radians. │ │ │ │ - sin_cos(xx, //) → _t_u_p_l_e[_m_p_f_r | _m_p_c, _m_p_f_r | _m_p_c]_ │ │ │ │ + sin_cos(xx, //) → tuple[_m_p_f_r | _m_p_c, _m_p_f_r | _m_p_c]_ │ │ │ │ Return a tuple containing the sine and cosine of x; x in radians. │ │ │ │ sinh(xx, //) → _m_p_f_r | _m_p_c_ │ │ │ │ Return hyperbolic sine of x. │ │ │ │ - sinh_cosh(xx, //) → _t_u_p_l_e[_m_p_f_r, _m_p_f_r]_ │ │ │ │ - Return a _t_u_p_l_e containing the hyperbolic sine and cosine of x. │ │ │ │ + sinh_cosh(xx, //) → tuple[_m_p_f_r, _m_p_f_r]_ │ │ │ │ + Return a tuple containing the hyperbolic sine and cosine of x. │ │ │ │ sqrt(xx, //) → _m_p_f_r | _m_p_c_ │ │ │ │ Return the square root of x. │ │ │ │ square(xx, //) → _m_p_z | _m_p_q | _m_p_f_r | _m_p_c_ │ │ │ │ Return x * x. │ │ │ │ sub(xx, yy, //) → _m_p_z | _m_p_q | _m_p_f_r | _m_p_c_ │ │ │ │ Return x - y. │ │ │ │ tan(xx, //) → _m_p_f_r | _m_p_c_ │ │ │ │ @@ -459,15 +459,15 @@ │ │ │ │ order of the arguments changed in gmpy2 2.2.0a2 │ │ │ │ zeta(xx, //) → _m_p_f_r_ │ │ │ │ Return Riemann zeta of x. │ │ │ │ allow_complex_ │ │ │ │ This attribute controls whether or not an _m_p_c result can be │ │ │ │ returned if an _m_p_f_r result would normally not be possible. │ │ │ │ allow_release_gil_ │ │ │ │ - If set to _T_r_u_e, many _m_p_z and _m_p_q computations will release the GIL. │ │ │ │ + If set to True, many _m_p_z and _m_p_q computations will release the GIL. │ │ │ │ This is considered an experimental feature. │ │ │ │ divzero_ │ │ │ │ This flag is not user controllable. It is automatically set if a │ │ │ │ division by zero occurred and NaN result was returned. │ │ │ │ emax_ │ │ │ │ This attribute controls the maximum allowed exponent of an _m_p_f_r │ │ │ │ result. The maximum exponent is platform dependent and can be │ │ │ │ @@ -492,24 +492,24 @@ │ │ │ │ This flag is not user controllable. It is automatically set if an │ │ │ │ inexact result is returned. │ │ │ │ invalid_ │ │ │ │ This flag is not user controllable. It is automatically set if an │ │ │ │ invalid (Not-A-Number) result is returned. │ │ │ │ overflow_ │ │ │ │ This flag is not user controllable. It is automatically set if a │ │ │ │ - result overflowed to +/-Infinity and _t_r_a_p___o_v_e_r_f_l_o_w is _F_a_l_s_e. │ │ │ │ + result overflowed to +/-Infinity and _t_r_a_p___o_v_e_r_f_l_o_w is False. │ │ │ │ precision_ │ │ │ │ This attribute controls the precision of an _m_p_f_r result. The │ │ │ │ precision is specified in bits, not decimal digits. The maximum │ │ │ │ precision that can be specified is platform dependent and can be │ │ │ │ retrieved with _g_e_t___m_a_x___p_r_e_c_i_s_i_o_n_(_). │ │ │ │ Note: Specifying a value for precision that is too close to the │ │ │ │ maximum precision will cause the MPFR library to fail. │ │ │ │ rational_division_ │ │ │ │ - If set to _T_r_u_e, _m_p_z / _m_p_z will return an _m_p_q instead of an _m_p_f_r. │ │ │ │ + If set to True, _m_p_z / _m_p_z will return an _m_p_q instead of an _m_p_f_r. │ │ │ │ real_prec_ │ │ │ │ This attribute controls the precision of the real part of an _m_p_c │ │ │ │ result. If the value is Default, then the value of the _p_r_e_c_i_s_i_o_n │ │ │ │ attribute is used. │ │ │ │ real_round_ │ │ │ │ This attribute controls the rounding mode for the real part of an │ │ │ │ _m_p_c result. If the value is Default, then the value of the round │ │ │ │ @@ -528,58 +528,58 @@ │ │ │ │ underflow when the minimum exponent is reached. The MFPR library │ │ │ │ does not enable gradual underflow by default but it can be enabled │ │ │ │ to precisely mimic the results of IEEE-754 floating point │ │ │ │ operations. │ │ │ │ trap_divzero_ │ │ │ │ This attribute controls whether or not a _D_i_v_i_s_i_o_n_B_y_Z_e_r_o_E_r_r_o_r │ │ │ │ exception is raised if division by 0 occurs. The │ │ │ │ - _D_i_v_i_s_i_o_n_B_y_Z_e_r_o_E_r_r_o_r is a sub-class of Python’s _Z_e_r_o_D_i_v_i_s_i_o_n_E_r_r_o_r. │ │ │ │ + _D_i_v_i_s_i_o_n_B_y_Z_e_r_o_E_r_r_o_r is a sub-class of Python’s ZeroDivisionError. │ │ │ │ trap_erange_ │ │ │ │ This attribute controls whether or not a _R_a_n_g_e_E_r_r_o_r exception is │ │ │ │ raised when certain operations are performed on NaN and/or Infinity │ │ │ │ - values. Setting _t_r_a_p___e_r_a_n_g_e to _T_r_u_e can be used to raise an │ │ │ │ + values. Setting _t_r_a_p___e_r_a_n_g_e to True can be used to raise an │ │ │ │ exception if comparisons are attempted with a NaN. │ │ │ │ trap_inexact_ │ │ │ │ This attribute controls whether or not an _I_n_e_x_a_c_t_R_e_s_u_l_t_E_r_r_o_r │ │ │ │ exception is raised if an inexact result is returned. To check if │ │ │ │ the result is greater or less than the exact result, check the rc │ │ │ │ attribute of the _m_p_f_r result. │ │ │ │ trap_invalid_ │ │ │ │ This attribute controls whether or not an _I_n_v_a_l_i_d_O_p_e_r_a_t_i_o_n_E_r_r_o_r │ │ │ │ exception is raised if a numerical result is not defined. A special │ │ │ │ NaN (Not-A-Number) value will be returned if an exception is not │ │ │ │ raised. The _I_n_v_a_l_i_d_O_p_e_r_a_t_i_o_n_E_r_r_o_r is a sub-class of Python’s │ │ │ │ - _V_a_l_u_e_E_r_r_o_r. │ │ │ │ + ValueError. │ │ │ │ For example, gmpy2.sqrt(-2) will normally return mpfr(‘nan’). │ │ │ │ - However, if _a_l_l_o_w___c_o_m_p_l_e_x is set to _T_r_u_e, then an _m_p_c result will │ │ │ │ + However, if _a_l_l_o_w___c_o_m_p_l_e_x is set to True, then an _m_p_c result will │ │ │ │ be returned. │ │ │ │ trap_overflow_ │ │ │ │ - If set to _F_a_l_s_e, a result that is larger than the largest possible │ │ │ │ + If set to False, a result that is larger than the largest possible │ │ │ │ _m_p_f_r given the current exponent range will be replaced by +/- │ │ │ │ - Infinity. If set to _T_r_u_e, an _O_v_e_r_f_l_o_w_R_e_s_u_l_t_E_r_r_o_r exception is │ │ │ │ + Infinity. If set to True, an _O_v_e_r_f_l_o_w_R_e_s_u_l_t_E_r_r_o_r exception is │ │ │ │ raised. │ │ │ │ trap_underflow_ │ │ │ │ - If set to _F_a_l_s_e, a result that is smaller than the smallest │ │ │ │ + If set to False, a result that is smaller than the smallest │ │ │ │ possible _m_p_f_r given the current exponent range will be replaced by │ │ │ │ - +/-0.0. If set to _T_r_u_e, an _U_n_d_e_r_f_l_o_w_R_e_s_u_l_t_E_r_r_o_r exception is │ │ │ │ + +/-0.0. If set to True, an _U_n_d_e_r_f_l_o_w_R_e_s_u_l_t_E_r_r_o_r exception is │ │ │ │ raised. │ │ │ │ underflow_ │ │ │ │ This flag is not user controllable. It is automatically set if a │ │ │ │ - result underflowed to +/-0.0 and _t_r_a_p___u_n_d_e_r_f_l_o_w is _F_a_l_s_e. │ │ │ │ + result underflowed to +/-0.0 and _t_r_a_p___u_n_d_e_r_f_l_o_w is False. │ │ │ │ ********** CCoonntteexxtt FFuunnccttiioonnss_? ********** │ │ │ │ gmpy2.get_context() → _c_o_n_t_e_x_t_ │ │ │ │ Return a reference to the current context. │ │ │ │ gmpy2.ieee(ssiizzee, //, ssuubbnnoorrmmaalliizzee==TTrruuee) → _c_o_n_t_e_x_t_ │ │ │ │ Return a new context corresponding to a standard IEEE floating point │ │ │ │ format. The supported sizes are 16, 32, 64, 128, and multiples of 32 │ │ │ │ greater than 128. │ │ │ │ gmpy2.local_context(****kkwwaarrggss) → _c_o_n_t_e_x_t_ │ │ │ │ gmpy2.local_context(ccoonntteexxtt, //, ****kkwwaarrggss) → _c_o_n_t_e_x_t │ │ │ │ Return a new context for controlling gmpy2 arithmetic, based either on │ │ │ │ the current context or on a ctx value. Context options additionally can │ │ │ │ be overridden by keyword arguments. │ │ │ │ - gmpy2.set_context(ccoonntteexxtt, //) → _N_o_n_e_ │ │ │ │ + gmpy2.set_context(ccoonntteexxtt, //) → None_ │ │ │ │ Activate a context object controlling gmpy2 arithmetic. │ │ │ │ _P_r_e_v_i_o_u_s _N_e_x_t │ │ │ │ =============================================================================== │ │ │ │ © Copyright 2024 - 2024, Case Van Horsen. │ │ │ │ Built with _S_p_h_i_n_x using a _t_h_e_m_e provided by _R_e_a_d_ _t_h_e_ _D_o_c_s. │ │ ├── ./usr/share/doc/python-gmpy2-doc/html/generic.html │ │ │ @@ -148,15 +148,15 @@ │ │ │
│ │ │ gmpy2.fms(x, y, z, /) mpz | mpq | mpfr | mpc
│ │ │

Return correctly rounded result of (x * y) - z.

│ │ │
│ │ │ │ │ │
│ │ │
│ │ │ -gmpy2.cmp_abs(x, y, /) int
│ │ │ +gmpy2.cmp_abs(x, y, /) int │ │ │

Return -1 if abs(x) < abs(y); 0 if abs(x) = abs(y); or 1 else.

│ │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ @@ -45,13 +45,13 @@ │ │ │ │ Default is the precision of x. Uses Stern-Brocot tree to find the 'best' │ │ │ │ approximation. An _m_p_z object is returned if the denominator is 1. If │ │ │ │ err<0, relative error is 2.0 ** err. │ │ │ │ gmpy2.fma(xx, yy, zz, //) → _m_p_z | _m_p_q | _m_p_f_r | _m_p_c_ │ │ │ │ Return correctly rounded result of (x * y) + z. │ │ │ │ gmpy2.fms(xx, yy, zz, //) → _m_p_z | _m_p_q | _m_p_f_r | _m_p_c_ │ │ │ │ Return correctly rounded result of (x * y) - z. │ │ │ │ - gmpy2.cmp_abs(xx, yy, //) → _i_n_t_ │ │ │ │ + gmpy2.cmp_abs(xx, yy, //) → int_ │ │ │ │ Return -1 if abs(x) < abs(y); 0 if abs(x) = abs(y); or 1 else. │ │ │ │ _P_r_e_v_i_o_u_s _N_e_x_t │ │ │ │ =============================================================================== │ │ │ │ © Copyright 2024 - 2024, Case Van Horsen. │ │ │ │ Built with _S_p_h_i_n_x using a _t_h_e_m_e provided by _R_e_a_d_ _t_h_e_ _D_o_c_s. │ │ ├── ./usr/share/doc/python-gmpy2-doc/html/history.html │ │ │ @@ -293,15 +293,15 @@ │ │ │
  • Many bug fixes.

  • │ │ │ │ │ │ │ │ │
    │ │ │

    Changes in gmpy2 2.1.0b1

    │ │ │ │ │ │
    │ │ │
    │ │ │

    Changes in gmpy2 2.1.a05

    │ │ │
    │ │ │
    │ │ │

    Changes in gmpy2 2.0.0

    │ │ │ │ │ │
    │ │ │ @@ -430,15 +430,15 @@ │ │ │
  • Added __complex__() to mpc type. (casevh)

  • │ │ │
  • round(mpfr) now correctly returns an mpz type. (casevh)

  • │ │ │
  • Add mpz.denominator and mpz.numerator. (casevh)

  • │ │ │
  • If no arguments are given to mpz, mpq, mpfr, mpc, and xmpz, │ │ │ return 0 of the appropriate type. (casevh)

  • │ │ │
  • Fix broken comparison between mpz and mpq when mpz is on │ │ │ the left. (casevh)

  • │ │ │ -
  • Added __sizeof__() to all types. Note: sys.getsizeof() calls │ │ │ +

  • Added __sizeof__() to all types. Note: sys.getsizeof() calls │ │ │ __sizeof__() to get the memory size of a gmpy2 object. The returned │ │ │ value reflects the size of the allocated memory which may be larger than │ │ │ the actual minimum memory required by the object. (casevh)

  • │ │ │ │ │ │ │ │ │
    │ │ │

    Known issues in gmpy2 2.0.0b4

    │ │ │ @@ -449,56 +449,56 @@ │ │ │
    │ │ │
    │ │ │

    Changes in gmpy2 2.0.0b3

    │ │ │ │ │ │
    │ │ │
    │ │ │

    Changes in gmpy2 2.0.0b2

    │ │ │ │ │ │
    │ │ │
    │ │ │

    Changes in gmpy2 2.0.0b1

    │ │ │
    │ │ │ │ │ │ ├── html2text {} │ │ │ │ @@ -142,25 +142,25 @@ │ │ │ │ A string can be with fraction-part (with a period as a separator) and/or │ │ │ │ exponent-part with an exponent marker 'e' or 'E' for bases up to 10, else │ │ │ │ '@' in any base. In bases 2 and 16, the exponent prefix can also be 'p' │ │ │ │ or 'P', in which case the exponent indicates a multiplication by a power │ │ │ │ of 2 instead of the base. The value of an exponent is always written in │ │ │ │ base 10. The fractional-part digits are parsed the same as the _m_p_z type │ │ │ │ constructor does and both the whole number and exponent-part optionally │ │ │ │ - can be preceded by ‘+’ or ‘-’. Every input, accepted by the _f_l_o_a_t type │ │ │ │ - constructor or the _f_l_o_a_t_._f_r_o_m_h_e_x method is also accepted. │ │ │ │ + can be preceded by ‘+’ or ‘-’. Every input, accepted by the float type │ │ │ │ + constructor or the float.fromhex method is also accepted. │ │ │ │ If a precision greater than or equal to 2 is specified, then it is used. │ │ │ │ A precision of 0 (the default) implies the precision of either the │ │ │ │ specified context or the current context is used. A precision of 1 │ │ │ │ minimizes the loss of precision by following these rules: │ │ │ │ 1. If n is a radix-2 floating point number, then the full │ │ │ │ precision of n is retained. │ │ │ │ 2. If n is an integer, then the precision is the bit length │ │ │ │ of the integer. │ │ │ │ - __format__(ffmmtt) → _s_t_r_ │ │ │ │ + __format__(ffmmtt) → str_ │ │ │ │ Return a Python string by formatting 'x' using the format string │ │ │ │ 'fmt'. A valid format string consists of: │ │ │ │ optional alignment code: │ │ │ │ '<' -> left shifted in field '>' -> right │ │ │ │ shifted in field '^' -> centered in field │ │ │ │ optional leading sign code │ │ │ │ '+' -> always display leading sign '-' -> only │ │ │ │ @@ -173,49 +173,49 @@ │ │ │ │ zero 'Z' -> round toward zero 'N' -> round to │ │ │ │ nearest │ │ │ │ optional conversion code: │ │ │ │ 'a','A' -> hex format 'b' -> binary format │ │ │ │ 'e','E' -> scientific format 'f','F' -> fixed │ │ │ │ point format 'g','G' -> fixed or float format │ │ │ │ The default format is '.6f'. │ │ │ │ - as_integer_ratio() → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ - Return the exact rational equivalent of an _m_p_f_r. Value is a _t_u_p_l_e │ │ │ │ - for compatibility with Python's _f_l_o_a_t_._a_s___i_n_t_e_g_e_r___r_a_t_i_o. │ │ │ │ - as_mantissa_exp() → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + as_integer_ratio() → tuple[_m_p_z, _m_p_z]_ │ │ │ │ + Return the exact rational equivalent of an _m_p_f_r. Value is a tuple │ │ │ │ + for compatibility with Python's float.as_integer_ratio. │ │ │ │ + as_mantissa_exp() → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return the mantissa and exponent of an _m_p_f_r. │ │ │ │ as_simple_fraction(pprreecciissiioonn==00) → _m_p_q_ │ │ │ │ Return a simple rational approximation to x. The result will be │ │ │ │ accurate to 'precision' bits. If 'precision' is 0, the precision of │ │ │ │ 'x' will be used. │ │ │ │ conjugate() → _m_p_z_ │ │ │ │ Return the conjugate of x (which is just a new reference to x since │ │ │ │ x is not a complex number). │ │ │ │ - digits(bbaassee==1100, pprreecc==00, //) → _t_u_p_l_e[_s_t_r, _i_n_t, _i_n_t]_ │ │ │ │ + digits(bbaassee==1100, pprreecc==00, //) → tuple[str, int, int]_ │ │ │ │ Returns up to 'prec' digits in the given base. If 'prec' is 0, as │ │ │ │ many digits that are available are returned. No more digits than │ │ │ │ available given x's precision are returned. 'base' must be between │ │ │ │ - 2 and 62, inclusive. The result is a three element _t_u_p_l_e containing │ │ │ │ + 2 and 62, inclusive. The result is a three element tuple containing │ │ │ │ the mantissa, the exponent, and the number of bits of precision. │ │ │ │ - is_finite() → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is an actual number (i.e. non NaN or Infinity). If │ │ │ │ - x is an _m_p_c, return _T_r_u_e if both x.real and x.imag are finite. │ │ │ │ - is_infinite() → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is +Infinity or -Infinity. If x is an _m_p_c, return │ │ │ │ - _T_r_u_e if either x.real or x.imag is infinite. Otherwise return │ │ │ │ - _F_a_l_s_e. │ │ │ │ - is_integer() → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is an integer; _F_a_l_s_e otherwise. │ │ │ │ - is_nan() → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is NaN (Not-A-Number) else _F_a_l_s_e. │ │ │ │ - is_regular() → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is not zero, NaN, or Infinity; _F_a_l_s_e otherwise. │ │ │ │ - is_signed() → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if the sign bit of x is set. │ │ │ │ - is_zero() → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is equal to 0. If x is an _m_p_c, return _T_r_u_e if both │ │ │ │ + is_finite() → bool_ │ │ │ │ + Return True if x is an actual number (i.e. non NaN or Infinity). If │ │ │ │ + x is an _m_p_c, return True if both x.real and x.imag are finite. │ │ │ │ + is_infinite() → bool_ │ │ │ │ + Return True if x is +Infinity or -Infinity. If x is an _m_p_c, return │ │ │ │ + True if either x.real or x.imag is infinite. Otherwise return │ │ │ │ + False. │ │ │ │ + is_integer() → bool_ │ │ │ │ + Return True if x is an integer; False otherwise. │ │ │ │ + is_nan() → bool_ │ │ │ │ + Return True if x is NaN (Not-A-Number) else False. │ │ │ │ + is_regular() → bool_ │ │ │ │ + Return True if x is not zero, NaN, or Infinity; False otherwise. │ │ │ │ + is_signed() → bool_ │ │ │ │ + Return True if the sign bit of x is set. │ │ │ │ + is_zero() → bool_ │ │ │ │ + Return True if x is equal to 0. If x is an _m_p_c, return True if both │ │ │ │ x.real and x.imag are equal to 0. │ │ │ │ imag_ │ │ │ │ imaginary component │ │ │ │ precision_ │ │ │ │ precision in bits │ │ │ │ rc_ │ │ │ │ return code │ │ │ │ @@ -231,15 +231,15 @@ │ │ │ │ gmpy2.cbrt(xx, //) → _m_p_f_r_ │ │ │ │ Return the cube root of x. │ │ │ │ gmpy2.ceil(xx, //) → _m_p_f_r_ │ │ │ │ Return an 'mpfr' that is the smallest integer >= x. │ │ │ │ gmpy2.check_range(xx, //) → _m_p_f_r_ │ │ │ │ Return a new _m_p_f_r with exponent that lies within the current range of │ │ │ │ emin and emax. │ │ │ │ - gmpy2.cmp(xx, yy, //) → _i_n_t_ │ │ │ │ + gmpy2.cmp(xx, yy, //) → int_ │ │ │ │ Return -1 if x < y; 0 if x = y; or 1 if x > y. Both x and y must be │ │ │ │ integer, rational or real. Note: 0 is returned (and exception flag set) │ │ │ │ if either argument is NaN. │ │ │ │ gmpy2.const_catalan(pprreecciissiioonn==00) → _m_p_f_r_ │ │ │ │ Return the catalan constant using the specified precision. If no │ │ │ │ precision is specified, the default precision is used. │ │ │ │ gmpy2.const_euler(pprreecciissiioonn==00) → _m_p_f_r_ │ │ │ │ @@ -285,52 +285,52 @@ │ │ │ │ Return correctly rounded result of (x * y) + (z + t). │ │ │ │ gmpy2.fmms(xx, yy, zz, tt, //) → _m_p_f_r_ │ │ │ │ Return correctly rounded result of (x * y) - (z + t). │ │ │ │ gmpy2.fmod(xx, yy, //) → _m_p_f_r_ │ │ │ │ Return x - n*y where n is the integer quotient of x/y, rounded to 0. │ │ │ │ gmpy2.frac(xx, //) → _m_p_f_r_ │ │ │ │ Return fractional part of x. │ │ │ │ - gmpy2.frexp(xx, //) → _t_u_p_l_e[_i_n_t, _m_p_f_r]_ │ │ │ │ - Return a _t_u_p_l_e containing the exponent and mantissa of x. │ │ │ │ + gmpy2.frexp(xx, //) → tuple[int, _m_p_f_r]_ │ │ │ │ + Return a tuple containing the exponent and mantissa of x. │ │ │ │ gmpy2.fsum(iitteerraabbllee, //) → _m_p_f_r_ │ │ │ │ Return an accurate sum of the values in the iterable. │ │ │ │ gmpy2.gamma(xx, //) → _m_p_f_r_ │ │ │ │ Return gamma of x. │ │ │ │ gmpy2.gamma_inc(aa, xx, //) → _m_p_f_r_ │ │ │ │ Return (upper) incomplete gamma of a and x. │ │ │ │ - gmpy2.get_exp(xx, //) → _i_n_t_ │ │ │ │ + gmpy2.get_exp(xx, //) → int_ │ │ │ │ Return the exponent of x. Returns 0 for NaN or Infinity and sets the │ │ │ │ _c_o_n_t_e_x_t_._e_r_a_n_g_e flag of the current context and will raise an exception if │ │ │ │ _c_o_n_t_e_x_t_._t_r_a_p___e_r_a_n_g_e is set. │ │ │ │ gmpy2.hypot(xx, yy, //) → _m_p_f_r_ │ │ │ │ Return square root of (x**2 + y**2). │ │ │ │ gmpy2.inf(nn, //) → _m_p_f_r_ │ │ │ │ Return an _m_p_f_r initialized to Infinity with the same sign as n. If n is │ │ │ │ not given, +Infinity is returned. │ │ │ │ - gmpy2.is_finite(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is an actual number (i.e. non NaN or Infinity). If x is │ │ │ │ - an _m_p_c, return _T_r_u_e if both x.real and x.imag are finite. │ │ │ │ - gmpy2.is_infinite(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is +Infinity or -Infinity. If x is an _m_p_c, return _T_r_u_e │ │ │ │ - if either x.real or x.imag is infinite. Otherwise return _F_a_l_s_e. │ │ │ │ - gmpy2.is_regular(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is not zero, NaN, or Infinity; _F_a_l_s_e otherwise. │ │ │ │ - gmpy2.is_signed(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if the sign bit of x is set. │ │ │ │ - gmpy2.is_unordered(xx, yy, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if either x and/or y is NaN. │ │ │ │ + gmpy2.is_finite(xx, //) → bool_ │ │ │ │ + Return True if x is an actual number (i.e. non NaN or Infinity). If x is │ │ │ │ + an _m_p_c, return True if both x.real and x.imag are finite. │ │ │ │ + gmpy2.is_infinite(xx, //) → bool_ │ │ │ │ + Return True if x is +Infinity or -Infinity. If x is an _m_p_c, return True │ │ │ │ + if either x.real or x.imag is infinite. Otherwise return False. │ │ │ │ + gmpy2.is_regular(xx, //) → bool_ │ │ │ │ + Return True if x is not zero, NaN, or Infinity; False otherwise. │ │ │ │ + gmpy2.is_signed(xx, //) → bool_ │ │ │ │ + Return True if the sign bit of x is set. │ │ │ │ + gmpy2.is_unordered(xx, yy, //) → bool_ │ │ │ │ + Return True if either x and/or y is NaN. │ │ │ │ gmpy2.j0(xx, //) → _m_p_f_r_ │ │ │ │ Return first kind Bessel function of order 0 of x. │ │ │ │ gmpy2.j1(xx, //) → _m_p_f_r_ │ │ │ │ Return first kind Bessel function of order 1 of x. │ │ │ │ gmpy2.jn(nn, xx, //) → _m_p_f_r_ │ │ │ │ Return the first kind Bessel function of order n of x. Note: the order of │ │ │ │ the arguments changed in gmpy2 2.2.0a2 │ │ │ │ - gmpy2.lgamma(xx, //) → _t_u_p_l_e[_m_p_f_r, _i_n_t]_ │ │ │ │ - Return a _t_u_p_l_e containing the logarithm of the absolute value of gamma(x) │ │ │ │ + gmpy2.lgamma(xx, //) → tuple[_m_p_f_r, int]_ │ │ │ │ + Return a tuple containing the logarithm of the absolute value of gamma(x) │ │ │ │ and the sign of gamma(x) │ │ │ │ gmpy2.li2(xx, //) → _m_p_f_r_ │ │ │ │ Return real part of dilogarithm of x. │ │ │ │ gmpy2.lngamma(xx, //) → _m_p_f_r_ │ │ │ │ Return natural logarithm of gamma(x). │ │ │ │ gmpy2.log1p(xx, //) → _m_p_f_r_ │ │ │ │ Return natural logarithm of (1+x). │ │ │ │ @@ -340,19 +340,19 @@ │ │ │ │ Return the maximum number of x and y. If x and y are not _m_p_f_r, they are │ │ │ │ converted to _m_p_f_r. The result is rounded to match the current context. If │ │ │ │ only one of x or y is a number, then that number is returned. │ │ │ │ gmpy2.minnum(xx, yy, //) → _m_p_f_r_ │ │ │ │ Return the minimum number of x and y. If x and y are not _m_p_f_r, they are │ │ │ │ converted to _m_p_f_r. The result is rounded to match the current context. If │ │ │ │ only one of x or y is a number, then that number is returned. │ │ │ │ - gmpy2.modf(xx, //) → _t_u_p_l_e[_m_p_f_r, _m_p_f_r]_ │ │ │ │ - Return a _t_u_p_l_e containing the integer and fractional portions of x. │ │ │ │ + gmpy2.modf(xx, //) → tuple[_m_p_f_r, _m_p_f_r]_ │ │ │ │ + Return a tuple containing the integer and fractional portions of x. │ │ │ │ gmpy2.mpfr_from_old_binary(ssttrriinngg, //) → _m_p_f_r_ │ │ │ │ Return an _m_p_f_r from a GMPY 1.x binary mpf format. │ │ │ │ - gmpy2.mpfr_grandom(rraannddoomm__ssttaattee, //) → _t_u_p_l_e[_m_p_f_r, _m_p_f_r]_ │ │ │ │ + gmpy2.mpfr_grandom(rraannddoomm__ssttaattee, //) → tuple[_m_p_f_r, _m_p_f_r]_ │ │ │ │ Return two random numbers with gaussian distribution. │ │ │ │ gmpy2.mpfr_nrandom(rraannddoomm__ssttaattee, //)_ │ │ │ │ Return a random number with gaussian distribution. │ │ │ │ gmpy2.mpfr_random(rraannddoomm__ssttaattee, //) → _m_p_f_r_ │ │ │ │ Return uniformly distributed number between [0,1]. │ │ │ │ gmpy2.nan() → _m_p_f_r_ │ │ │ │ Return an _m_p_f_r initialized to NaN (Not-A-Number). │ │ │ │ @@ -367,16 +367,16 @@ │ │ │ │ Return the reciprocal of the square root of x. │ │ │ │ gmpy2.reldiff(xx, yy, //) → _m_p_f_r_ │ │ │ │ Return the relative difference between x and y. Result is equal to abs(x- │ │ │ │ y)/x. │ │ │ │ gmpy2.remainder(xx, yy, //) → _m_p_f_r_ │ │ │ │ Return x - n*y where n is the integer quotient of x/y, rounded to the │ │ │ │ nearest integer and ties rounded to even. │ │ │ │ - gmpy2.remquo(xx, yy, //) → _t_u_p_l_e[_m_p_f_r, _i_n_t]_ │ │ │ │ - Return a _t_u_p_l_e containing the remainder(x,y) and the low bits of the │ │ │ │ + gmpy2.remquo(xx, yy, //) → tuple[_m_p_f_r, int]_ │ │ │ │ + Return a tuple containing the remainder(x,y) and the low bits of the │ │ │ │ quotient. │ │ │ │ gmpy2.rint(xx, //) → _m_p_f_r_ │ │ │ │ Return x rounded to the nearest integer using the current rounding mode. │ │ │ │ gmpy2.rint_ceil(xx, //) → _m_p_f_r_ │ │ │ │ Return x rounded to the nearest integer by first rounding to the next │ │ │ │ higher or equal integer and then, if needed, using the current rounding │ │ │ │ mode. │ │ │ │ @@ -409,19 +409,19 @@ │ │ │ │ Return hyperbolic secant of x. │ │ │ │ gmpy2.set_exp(xx, nn, //) → _m_p_f_r_ │ │ │ │ Set the exponent of x to n. If n is outside the range of valid exponents, │ │ │ │ _s_e_t___e_x_p_(_) will set the _c_o_n_t_e_x_t_._e_r_a_n_g_e flag of the current context and │ │ │ │ either return the original value or raise an exception if │ │ │ │ _c_o_n_t_e_x_t_._t_r_a_p___e_r_a_n_g_e is set. │ │ │ │ gmpy2.set_sign(xx, ss, //) → _m_p_f_r_ │ │ │ │ - If s is _T_r_u_e, then return x with the sign bit set. │ │ │ │ - gmpy2.sign(xx, //) → _i_n_t_ │ │ │ │ + If s is True, then return x with the sign bit set. │ │ │ │ + gmpy2.sign(xx, //) → int_ │ │ │ │ Return -1 if x < 0, 0 if x == 0, or +1 if x >0. │ │ │ │ - gmpy2.sinh_cosh(xx, //) → _t_u_p_l_e[_m_p_f_r, _m_p_f_r]_ │ │ │ │ - Return a _t_u_p_l_e containing the hyperbolic sine and cosine of x. │ │ │ │ + gmpy2.sinh_cosh(xx, //) → tuple[_m_p_f_r, _m_p_f_r]_ │ │ │ │ + Return a tuple containing the hyperbolic sine and cosine of x. │ │ │ │ gmpy2.trunc(xx, //) → _m_p_f_r_ │ │ │ │ Return an _m_p_f_r that is x truncated towards 0. Same as x.floor() if x>=0 │ │ │ │ or x.ceil() if x<0. │ │ │ │ gmpy2.y0(xx, //) → _m_p_f_r_ │ │ │ │ Return second kind Bessel function of order 0 of x. │ │ │ │ gmpy2.y1(xx, //) → _m_p_f_r_ │ │ │ │ Return second kind Bessel function of order 1 of x. │ │ │ │ @@ -429,28 +429,28 @@ │ │ │ │ Return the second kind Bessel function of order n of x. Note: the order │ │ │ │ of the arguments changed in gmpy2 2.2.0a2 │ │ │ │ gmpy2.zero(nn, //) → _m_p_f_r_ │ │ │ │ Return an _m_p_f_r initialized to 0.0 with the same sign as n. If n is not │ │ │ │ given, +0.0 is returned. │ │ │ │ gmpy2.zeta(xx, //) → _m_p_f_r_ │ │ │ │ Return Riemann zeta of x. │ │ │ │ - gmpy2.get_max_precision() → _i_n_t_ │ │ │ │ + gmpy2.get_max_precision() → int_ │ │ │ │ Return the maximum bits of precision that can be used for calculations. │ │ │ │ Note: to allow extra precision for intermediate calculations, avoid │ │ │ │ setting precision close the maximum precision. │ │ │ │ - gmpy2.get_emax_max() → _i_n_t_ │ │ │ │ + gmpy2.get_emax_max() → int_ │ │ │ │ Return the maximum possible exponent that can be set for _m_p_f_r. │ │ │ │ - gmpy2.get_emin_min() → _i_n_t_ │ │ │ │ + gmpy2.get_emin_min() → int_ │ │ │ │ Return the minimum possible exponent that can be set for _m_p_f_r. │ │ │ │ gmpy2.copy_sign(xx, yy, //) → _m_p_f_r_ │ │ │ │ Return an _m_p_f_r composed of x with the sign of y. │ │ │ │ - gmpy2.can_round(bb, eerrrr, rrnndd11, rrnndd22, pprreecc, //) → _b_o_o_l_ │ │ │ │ + gmpy2.can_round(bb, eerrrr, rrnndd11, rrnndd22, pprreecc, //) → bool_ │ │ │ │ Let b be an approximation to an unknown number x that is rounded │ │ │ │ according to rnd1. Assume the b has an error at most two to the power of │ │ │ │ - E(b)-err where E(b) is the exponent of b. Then return _T_r_u_e if x can be │ │ │ │ + E(b)-err where E(b) is the exponent of b. Then return True if x can be │ │ │ │ rounded correctly to prec bits with rounding mode rnd2. │ │ │ │ - gmpy2.free_cache() → _N_o_n_e_ │ │ │ │ + gmpy2.free_cache() → None_ │ │ │ │ Free the internal cache of constants maintained by MPFR. │ │ │ │ _P_r_e_v_i_o_u_s _N_e_x_t │ │ │ │ =============================================================================== │ │ │ │ © Copyright 2024 - 2024, Case Van Horsen. │ │ │ │ Built with _S_p_h_i_n_x using a _t_h_e_m_e provided by _R_e_a_d_ _t_h_e_ _D_o_c_s. │ │ ├── ./usr/share/doc/python-gmpy2-doc/html/mpq.html │ │ │ @@ -115,51 +115,51 @@ │ │ │
    │ │ │ class gmpy2.mpq(n=0, /)
    │ │ │
    │ │ │ class gmpy2.mpq(n, m, /)
    │ │ │
    │ │ │ class gmpy2.mpq(s, /, base=10)
    │ │ │

    Return a rational number constructed from a non-complex number n │ │ │ -exactly or from a pair of Rational values n and m or │ │ │ +exactly or from a pair of Rational values n and m or │ │ │ from a string s made up of digits in the given base. │ │ │ -Every input, that is accepted by the Fraction type │ │ │ +Every input, that is accepted by the Fraction type │ │ │ constructor is also accepted.

    │ │ │

    A string may be made up to two integers in the same base separated │ │ │ by a '/' character, both parsed the same as the mpz type constructor │ │ │ does. If base is 0 then the leading characters are used to recognize the │ │ │ base, this is done separately for the numerator and denominator. If │ │ │ base=10, any string that represents a finite value and is accepted by │ │ │ -the float constructor is also accepted.

    │ │ │ +the float constructor is also accepted.

    │ │ │
    │ │ │
    │ │ │ -as_integer_ratio() tuple[mpz, mpz]
    │ │ │ +as_integer_ratio() tuple[mpz, mpz] │ │ │

    Return a pair of integers, whose ratio is exactly equal to the │ │ │ original number. The ratio is in lowest terms and has a │ │ │ positive denominator.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ conjugate() mpz
    │ │ │

    Return the conjugate of x (which is just a new reference to x since x is │ │ │ not a complex number).

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -digits(base=10, /) str
    │ │ │ +digits(base=10, /) str │ │ │

    Return a Python string representing x in the given base (2 to 62, │ │ │ default is 10). A leading '-' is present if x<0, but no leading '+' │ │ │ is present if x>=0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ from_decimal(dec, /) mpq
    │ │ │ -

    Converts a finite decimal.Decimal instance to a rational number, exactly.

    │ │ │ +

    Converts a finite decimal.Decimal instance to a rational number, exactly.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ from_float(f, /) mpq
    │ │ │

    Converts a finite float to a rational number, exactly.

    │ │ │
    │ │ │ ├── html2text {} │ │ │ │ @@ -35,36 +35,36 @@ │ │ │ │ =============================================================================== │ │ │ │ ************ RRaattiioonnaallss_? ************ │ │ │ │ ********** mmppqq ttyyppee_? ********** │ │ │ │ ccllaassss gmpy2.mpq(nn==00, //)_ │ │ │ │ ccllaassss gmpy2.mpq(nn, mm, //) │ │ │ │ ccllaassss gmpy2.mpq(ss, //, bbaassee==1100) │ │ │ │ Return a rational number constructed from a non-complex number n exactly │ │ │ │ - or from a pair of _R_a_t_i_o_n_a_l values n and m or from a string s made up of │ │ │ │ - digits in the given base. Every input, that is accepted by the _F_r_a_c_t_i_o_n │ │ │ │ + or from a pair of Rational values n and m or from a string s made up of │ │ │ │ + digits in the given base. Every input, that is accepted by the Fraction │ │ │ │ type constructor is also accepted. │ │ │ │ A string may be made up to two integers in the same base separated by a │ │ │ │ '/' character, both parsed the same as the _m_p_z type constructor does. If │ │ │ │ base is 0 then the leading characters are used to recognize the base, │ │ │ │ this is done separately for the numerator and denominator. If base=10, │ │ │ │ - any string that represents a finite value and is accepted by the _f_l_o_a_t │ │ │ │ + any string that represents a finite value and is accepted by the float │ │ │ │ constructor is also accepted. │ │ │ │ - as_integer_ratio() → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + as_integer_ratio() → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return a pair of integers, whose ratio is exactly equal to the │ │ │ │ original number. The ratio is in lowest terms and has a positive │ │ │ │ denominator. │ │ │ │ conjugate() → _m_p_z_ │ │ │ │ Return the conjugate of x (which is just a new reference to x since │ │ │ │ x is not a complex number). │ │ │ │ - digits(bbaassee==1100, //) → _s_t_r_ │ │ │ │ + digits(bbaassee==1100, //) → str_ │ │ │ │ Return a Python string representing x in the given base (2 to 62, │ │ │ │ default is 10). A leading '-' is present if x<0, but no leading '+' │ │ │ │ is present if x>=0. │ │ │ │ from_decimal(ddeecc, //) → _m_p_q_ │ │ │ │ - Converts a finite _d_e_c_i_m_a_l_._D_e_c_i_m_a_l instance to a rational number, │ │ │ │ + Converts a finite decimal.Decimal instance to a rational number, │ │ │ │ exactly. │ │ │ │ from_float(ff, //) → _m_p_q_ │ │ │ │ Converts a finite float to a rational number, exactly. │ │ │ │ denominator_ │ │ │ │ the denominator of a rational number in lowest terms │ │ │ │ imag_ │ │ │ │ the imaginary part of a complex number │ │ ├── ./usr/share/doc/python-gmpy2-doc/html/mpz.html │ │ │ @@ -204,25 +204,25 @@ │ │ │
    │ │ │
    │ │ │ class gmpy2.mpz(n=0, /)
    │ │ │
    │ │ │ class gmpy2.mpz(s, /, base=0)
    │ │ │

    Return an immutable integer constructed from a numeric value n (truncating │ │ │ n to its integer part) or a string s made of digits in the given base. │ │ │ -Every input, that is accepted by the int type constructor is also accepted.

    │ │ │ +Every input, that is accepted by the int type constructor is also accepted.

    │ │ │

    The base may vary from 2 to 62, or if base is 0, then binary, octal, or │ │ │ hexadecimal strings are recognized by leading '0b', '0o', or '0x' │ │ │ characters (case is ignored), otherwise the string is assumed to be │ │ │ decimal. For bases up to 36, digits case is ignored. For bases 37 │ │ │ to 62, upper-case letter represent the usual 10..35 range, while │ │ │ lower-case letter represent 36..61. Optionally the string can be │ │ │ preceded by '+' or '-'. White space and underscore is simply ignored.

    │ │ │
    │ │ │
    │ │ │ -__format__(fmt) str
    │ │ │ +__format__(fmt) str │ │ │

    Return a Python string by formatting mpz 'x' using the format string │ │ │ 'fmt'. A valid format string consists of:

    │ │ │
    │ │ │

    optional alignment code:

    │ │ │
    │ │ │

    '<' -> left shifted in field │ │ │ '>' -> right shifted in field │ │ │ @@ -249,193 +249,193 @@ │ │ │

    │ │ │
    │ │ │

    The default format is 'd'.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -as_integer_ratio() tuple[mpz, mpz]
    │ │ │ +as_integer_ratio() tuple[mpz, mpz] │ │ │

    Return a pair of integers, whose ratio is exactly equal to the │ │ │ original number. The ratio is in lowest terms and has a │ │ │ positive denominator.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ bit_clear(n, /) mpz
    │ │ │

    Return a copy of x with the n-th bit cleared.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -bit_count() int
    │ │ │ +bit_count() int │ │ │

    Return the number of 1-bits set in abs(x).

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ bit_flip(n, /) mpz
    │ │ │

    Return a copy of x with the n-th bit inverted.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -bit_length() int
    │ │ │ +bit_length() int │ │ │

    Return the number of significant bits in the radix-2 │ │ │ representation of x. Note: mpz(0).bit_length() returns 0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -bit_scan0(n=0, /) int | None
    │ │ │ +bit_scan0(n=0, /) int | None │ │ │

    Return the index of the first 0-bit of x with index >= n. n >= 0. │ │ │ If there are no more 0-bits in x at or above index n (which can │ │ │ only happen for x<0, assuming an infinitely long 2's complement │ │ │ -format), then None is returned.

    │ │ │ +format), then None is returned.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -bit_scan1(n=0, /) int | None
    │ │ │ +bit_scan1(n=0, /) int | None │ │ │

    Return the index of the first 1-bit of x with index >= n. n >= 0. │ │ │ If there are no more 1-bits in x at or above index n (which can │ │ │ only happen for x>=0, assuming an infinitely long 2's complement │ │ │ -format), then None is returned.

    │ │ │ +format), then None is returned.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ bit_set(n, /) mpz
    │ │ │

    Return a copy of x with the n-th bit set.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -bit_test(n, /) bool
    │ │ │ +bit_test(n, /) bool │ │ │

    Return the value of the n-th bit of x.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ conjugate() mpz
    │ │ │

    Return the conjugate of x (which is just a new reference to x since x is │ │ │ not a complex number).

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -digits(base=10, /) str
    │ │ │ +digits(base=10, /) str │ │ │

    Return Python string representing x in the given base. Values for │ │ │ base can range between 2 to 62. A leading '-' is present if x<0 │ │ │ but no leading '+' is present if x>=0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ from_bytes(bytes, byteorder='big', *, signed=False) mpz
    │ │ │

    Return the integer represented by the given array of bytes.

    │ │ │
    │ │ │
    │ │ │
    bytes

    Holds the array of bytes to convert. The argument must either │ │ │ support the buffer protocol or be an iterable object producing bytes. │ │ │ -bytes and bytearray are examples of built-in objects that support │ │ │ +bytes and bytearray are examples of built-in objects that support │ │ │ the buffer protocol.

    │ │ │
    │ │ │
    byteorder

    The byte order used to represent the integer. If byteorder is 'big', │ │ │ the most significant byte is at the beginning of the byte array. If │ │ │ byteorder is 'little', the most significant byte is at the end of the │ │ │ byte array. To request the native byte order of the host system, use │ │ │ -sys.byteorder as the byte order value.

    │ │ │ +sys.byteorder as the byte order value.

    │ │ │
    │ │ │
    signed

    Indicates whether two's complement is used to represent the integer.

    │ │ │
    │ │ │
    │ │ │
    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -is_congruent(y, m, /) bool
    │ │ │ -

    Returns True if x is congruent to y modulo m, else return False.

    │ │ │ +is_congruent(y, m, /) bool │ │ │ +

    Returns True if x is congruent to y modulo m, else return False.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -is_divisible(d, /) bool
    │ │ │ -

    Returns True if x is divisible by d, else return False.

    │ │ │ +is_divisible(d, /) bool │ │ │ +

    Returns True if x is divisible by d, else return False.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -is_even() bool
    │ │ │ -

    Return True if x is even, False otherwise.

    │ │ │ +is_even() bool │ │ │ +

    Return True if x is even, False otherwise.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -is_odd() bool
    │ │ │ -

    Return True if x is odd, False otherwise.

    │ │ │ +is_odd() bool │ │ │ +

    Return True if x is odd, False otherwise.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -is_power() bool
    │ │ │ -

    Return True if x is a perfect power (there exists a y and an │ │ │ -n > 1, such that x=y**n), else return False.

    │ │ │ +is_power() bool │ │ │ +

    Return True if x is a perfect power (there exists a y and an │ │ │ +n > 1, such that x=y**n), else return False.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -is_prime(n=25, /) bool
    │ │ │ -

    Return True if x is probably prime, else False if x is │ │ │ +is_prime(n=25, /) bool │ │ │ +

    Return True if x is probably prime, else False if x is │ │ │ definitely composite. x is checked for small divisors and up │ │ │ to n Miller-Rabin tests are performed.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -is_probab_prime(n=25, /) int
    │ │ │ +is_probab_prime(n=25, /) int │ │ │

    Return 2 if x is definitely prime, 1 if x is probably prime, │ │ │ or return 0 if x is definitely non-prime. x is checked for small │ │ │ divisors and up to n Miller-Rabin tests are performed. Reasonable │ │ │ values of n are between 15 and 50.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -is_square() bool
    │ │ │ -

    Returns True if x is a perfect square, else return False.

    │ │ │ +is_square() bool │ │ │ +

    Returns True if x is a perfect square, else return False.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -num_digits(base=10, /) int
    │ │ │ +num_digits(base=10, /) int │ │ │

    Return length of string representing the absolute value of x in │ │ │ the given base. Values for base can range between 2 and 62. The │ │ │ value returned may be 1 too large.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -to_bytes(length=1, byteorder='big', *, signed=False) bytes
    │ │ │ +to_bytes(length=1, byteorder='big', *, signed=False) bytes │ │ │

    Return an array of bytes representing an integer.

    │ │ │
    │ │ │
    │ │ │ -
    length

    Length of bytes object to use. An OverflowError is raised if the │ │ │ +

    length

    Length of bytes object to use. An OverflowError is raised if the │ │ │ integer is not representable with the given number of bytes.

    │ │ │
    │ │ │
    byteorder

    The byte order used to represent the integer. If byteorder is │ │ │ 'big', the most significant byte is at the beginning of the byte │ │ │ array. If byteorder is 'little', the most significant byte is at │ │ │ the end of the byte array. To request the native byte order of the │ │ │ -host system, use sys.byteorder as the byte order value.

    │ │ │ +host system, use sys.byteorder as the byte order value.

    │ │ │
    │ │ │
    signed

    Determines whether two's complement is used to represent the │ │ │ -integer. If signed is False and a negative integer is given, │ │ │ -an OverflowError is raised.

    │ │ │ +integer. If signed is False and a negative integer is given, │ │ │ +an OverflowError is raised.

    │ │ │
    │ │ │
    │ │ │
    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ @@ -476,64 +476,64 @@ │ │ │
    │ │ │ gmpy2.bit_clear(x, n, /) mpz
    │ │ │

    Return a copy of x with the n-th bit cleared.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.bit_count(x, /) int
    │ │ │ +gmpy2.bit_count(x, /) int │ │ │

    Return the number of 1-bits set in abs(x).

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.bit_flip(x, n, /) mpz
    │ │ │

    Return a copy of x with the n-th bit inverted.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.bit_length(x, /) int
    │ │ │ +gmpy2.bit_length(x, /) int │ │ │

    Return the number of significant bits in the radix-2 │ │ │ representation of x. Note: bit_length(0) returns 0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.bit_mask(n, /) mpz
    │ │ │

    Return an mpz exactly n bits in length with all bits set.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.bit_scan0(x, n=0, /) int | None
    │ │ │ +gmpy2.bit_scan0(x, n=0, /) int | None │ │ │

    Return the index of the first 0-bit of x with index >= n. n >= 0. │ │ │ If there are no more 0-bits in x at or above index n (which can │ │ │ only happen for x<0, assuming an infinitely long 2's complement │ │ │ -format), then None is returned.

    │ │ │ +format), then None is returned.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.bit_scan1(x, n=0, /) int | None
    │ │ │ +gmpy2.bit_scan1(x, n=0, /) int | None │ │ │

    Return the index of the first 1-bit of x with index >= n. n >= 0. │ │ │ If there are no more 1-bits in x at or above index n (which can │ │ │ only happen for x>=0, assuming an infinitely long 2's complement │ │ │ -format), then None is returned.

    │ │ │ +format), then None is returned.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.bit_set(x, n, /) mpz
    │ │ │

    Return a copy of x with the n-th bit set.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.bit_test(x, n, /) bool
    │ │ │ +gmpy2.bit_test(x, n, /) bool │ │ │

    Return the value of the n-th bit of x.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.c_div(x, y, /) mpz
    │ │ │

    Return the quotient of x divided by y. The quotient is rounded │ │ │ @@ -545,23 +545,23 @@ │ │ │ gmpy2.c_div_2exp(x, n, /) mpz │ │ │

    Returns the quotient of x divided by 2**n. The quotient is rounded │ │ │ towards +Inf (ceiling rounding). x must be an integer. n must be >0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.c_divmod(x, y, /) tuple[mpz, mpz]
    │ │ │ +gmpy2.c_divmod(x, y, /) tuple[mpz, mpz] │ │ │

    Return the quotient and remainder of x divided by y. The quotient │ │ │ is rounded towards +Inf (ceiling rounding) and the remainder will │ │ │ have the opposite sign of y. x and y must be integers.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.c_divmod_2exp(x, n, /) tuple[mpz, mpz]
    │ │ │ +gmpy2.c_divmod_2exp(x, n, /) tuple[mpz, mpz] │ │ │

    Return the quotient and remainder of x divided by 2**n. The quotient │ │ │ is rounded towards +Inf (ceiling rounding) and the remainder will │ │ │ be negative. x must be an integer. n must be >0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ @@ -590,15 +590,15 @@ │ │ │

    Return the quotient of x divided by y. Faster than standard │ │ │ division but requires the remainder is zero!

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.divm(a, b, m, /) mpz
    │ │ │ -

    Return x such that b*x == a mod m. Raises a ZeroDivisionError │ │ │ +

    Return x such that b*x == a mod m. Raises a ZeroDivisionError │ │ │ exception if no such value x exists.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.double_fac(n, /) mpz
    │ │ │

    Return the exact double factorial (n!!) of n. The double │ │ │ @@ -617,23 +617,23 @@ │ │ │ gmpy2.f_div_2exp(x, n, /) mpz │ │ │

    Return the quotient of x divided by 2**n. The quotient is rounded │ │ │ towards -Inf (floor rounding). x must be an integer. n must be >0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.f_divmod(x, y, /) tuple[mpz, mpz]
    │ │ │ +gmpy2.f_divmod(x, y, /) tuple[mpz, mpz] │ │ │

    Return the quotient and remainder of x divided by y. The quotient │ │ │ is rounded towards -Inf (floor rounding) and the remainder will │ │ │ have the same sign as y. x and y must be integers.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.f_divmod_2exp(x, n, /) tuple[mpz, mpz]
    │ │ │ +gmpy2.f_divmod_2exp(x, n, /) tuple[mpz, mpz] │ │ │

    Return quotient and remainder after dividing x by 2**n. The quotient │ │ │ is rounded towards -Inf (floor rounding) and the remainder will be │ │ │ positive. x must be an integer. n must be >0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ @@ -660,111 +660,111 @@ │ │ │
    │ │ │ gmpy2.fib(n, /) mpz
    │ │ │

    Return the n-th Fibonacci number.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.fib2(n, /) tuple[mpz, mpz]
    │ │ │ +gmpy2.fib2(n, /) tuple[mpz, mpz] │ │ │

    Return a 2-tuple with the (n-1)-th and n-th Fibonacci numbers.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.gcd(*integers, /) mpz
    │ │ │

    Return the greatest common divisor of integers.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.gcdext(a, b, /) tuple[mpz, mpz, mpz]
    │ │ │ +gmpy2.gcdext(a, b, /) tuple[mpz, mpz, mpz] │ │ │

    Return a 3-element tuple (g,s,t) such that g == gcd(a,b) │ │ │ and g == a*s + b*t.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.hamdist(x, y, /) int
    │ │ │ +gmpy2.hamdist(x, y, /) int │ │ │

    Return the Hamming distance (number of bit-positions where the │ │ │ bits differ) between integers x and y.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.invert(x, m, /) mpz
    │ │ │ -

    Return y such that x*y == 1 modulo m. Raises ZeroDivisionError if no │ │ │ +

    Return y such that x*y == 1 modulo m. Raises ZeroDivisionError if no │ │ │ inverse exists.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.iroot(x, n, /) tuple[mpz, bool]
    │ │ │ -

    Return the integer n-th root of x and boolean value that is True │ │ │ +gmpy2.iroot(x, n, /) tuple[mpz, bool] │ │ │ +

    Return the integer n-th root of x and boolean value that is True │ │ │ iff the root is exact. x >= 0. n > 0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.iroot_rem(x, n, /) tuple[mpz, mpz]
    │ │ │ +gmpy2.iroot_rem(x, n, /) tuple[mpz, mpz] │ │ │

    Return a 2-element tuple (y,r), such that y is the integer n-th │ │ │ root of x and x=y**n + r. x >= 0. n > 0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.is_congruent(x, y, m, /) bool
    │ │ │ -

    Returns True if x is congruent to y modulo m, else return False.

    │ │ │ +gmpy2.is_congruent(x, y, m, /) bool │ │ │ +

    Returns True if x is congruent to y modulo m, else return False.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.is_divisible(x, d, /) bool
    │ │ │ -

    Returns True if x is divisible by d, else return False.

    │ │ │ +gmpy2.is_divisible(x, d, /) bool │ │ │ +

    Returns True if x is divisible by d, else return False.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.is_even(x, /) bool
    │ │ │ -

    Return True if x is even, False otherwise.

    │ │ │ +gmpy2.is_even(x, /) bool │ │ │ +

    Return True if x is even, False otherwise.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.is_odd(x, /) bool
    │ │ │ -

    Return True if x is odd, False otherwise.

    │ │ │ +gmpy2.is_odd(x, /) bool │ │ │ +

    Return True if x is odd, False otherwise.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.is_power(x, /) bool
    │ │ │ -

    Return True if x is a perfect power (there exists a y and an │ │ │ -n > 1, such that x=y**n), else return False.

    │ │ │ +gmpy2.is_power(x, /) bool │ │ │ +

    Return True if x is a perfect power (there exists a y and an │ │ │ +n > 1, such that x=y**n), else return False.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.is_prime(x, n=25, /) bool
    │ │ │ -

    Return True if x is probably prime, else False if x is │ │ │ +gmpy2.is_prime(x, n=25, /) bool │ │ │ +

    Return True if x is probably prime, else False if x is │ │ │ definitely composite. x is checked for small divisors and up │ │ │ to n Miller-Rabin tests are performed.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.is_probab_prime(x, n=25, /) int
    │ │ │ +gmpy2.is_probab_prime(x, n=25, /) int │ │ │

    Return 2 if x is definitely prime, 1 if x is probably prime, │ │ │ or return 0 if x is definitely non-prime. x is checked for small │ │ │ divisors and up to n Miller-Rabin tests are performed. Reasonable │ │ │ values of n are between 15 and 50.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.is_square(x, /) bool
    │ │ │ -

    Returns True if x is a perfect square, else return False.

    │ │ │ +gmpy2.is_square(x, /) bool │ │ │ +

    Returns True if x is a perfect square, else return False.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.isqrt(x, /) mpz
    │ │ │

    Return the integer square root of a non-negative integer x.

    │ │ │
    │ │ │ @@ -804,15 +804,15 @@ │ │ │
    │ │ │ gmpy2.lucas(n, /) mpz
    │ │ │

    Return the n-th Lucas number.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.lucas2(n, /) tuple[mpz, mpz]
    │ │ │ +gmpy2.lucas2(n, /) tuple[mpz, mpz] │ │ │

    Return a 2-tuple with the (n-1)-th and n-th Lucas numbers.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.mpz_random(random_state, int, /) mpz
    │ │ │

    Return uniformly distributed random integer between 0 and n-1.

    │ │ │ @@ -842,15 +842,15 @@ │ │ │
    │ │ │ gmpy2.next_prime(x, /) mpz
    │ │ │

    Return the next probable prime number > x.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.num_digits(x, base=10, /) int
    │ │ │ +gmpy2.num_digits(x, base=10, /) int │ │ │

    Return length of string representing the absolute value of x in │ │ │ the given base. Values for base can range between 2 and 62. The │ │ │ value returned may be 1 too large.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ @@ -859,36 +859,36 @@ │ │ │ each integer element of lst after padding to length n bits. Raises │ │ │ an error if any integer is negative or greater than n bits in │ │ │ length.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.popcount(x, /) int
    │ │ │ +gmpy2.popcount(x, /) int │ │ │

    Return the number of 1-bits set in x. If x<0, the number of │ │ │ 1-bits is infinite so -1 is returned in that case.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.powmod(x, y, m, /) mpz
    │ │ │

    Return (x**y) mod m. Same as the three argument version of Python's │ │ │ -built-in pow, but converts all three arguments to mpz.

    │ │ │ +built-in pow, but converts all three arguments to mpz.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.powmod_exp_list(base, exp_lst, mod, /) list[mpz, ...]
    │ │ │ +gmpy2.powmod_exp_list(base, exp_lst, mod, /) list[mpz, ...] │ │ │

    Returns list(powmod(base, i, mod) for i in exp_lst). Will always release │ │ │ the GIL. (Experimental in gmpy2 2.1.x).

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.powmod_base_list(base_lst, exp, mod, /) list[mpz, ...]
    │ │ │ +gmpy2.powmod_base_list(base_lst, exp, mod, /) list[mpz, ...] │ │ │

    Returns list(powmod(i, exp, mod) for i in base_lst). Will always release │ │ │ the GIL. (Experimental in gmpy2 2.1.x).

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ gmpy2.powmod_sec(x, y, m, /) mpz
    │ │ │ @@ -909,15 +909,15 @@ │ │ │ gmpy2.primorial(n, /) mpz │ │ │

    Return the product of all positive prime numbers less than or │ │ │ equal to n.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.remove(x, f, /) tuple[mpz, mpz]
    │ │ │ +gmpy2.remove(x, f, /) tuple[mpz, mpz] │ │ │

    Return a 2-element tuple (y,m) such that x=y*(f**m) and f does │ │ │ not divide y. Remove the factor f from x as many times as │ │ │ possible. m is the multiplicity f in x. f > 1.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ @@ -931,23 +931,23 @@ │ │ │ gmpy2.t_div_2exp(x, n, /) mpz
    │ │ │

    Return the quotient of x divided by 2**n. The quotient is rounded │ │ │ towards zero (truncation). n must be >0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.t_divmod(x, y, /) tuple[mpz, mpz]
    │ │ │ +gmpy2.t_divmod(x, y, /) tuple[mpz, mpz] │ │ │

    Return the quotient and remainder of x divided by y. The quotient │ │ │ is rounded towards zero (truncation) and the remainder will have │ │ │ the same sign as x. x and y must be integers.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.t_divmod_2exp(x, n, /) tuple[mpz, mpz]
    │ │ │ +gmpy2.t_divmod_2exp(x, n, /) tuple[mpz, mpz] │ │ │

    Return the quotient and remainder of x divided by 2**n. The quotient │ │ │ is rounded towards zero (truncation) and the remainder will have the │ │ │ same sign as x. x must be an integer. n must be >0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ @@ -961,15 +961,15 @@ │ │ │ gmpy2.t_mod_2exp(x, n, /) mpz
    │ │ │

    Return the remainder of x divided by 2**n. The remainder will have │ │ │ the same sign as x. x must be an integer. n must be >0.

    │ │ │
    │ │ │ │ │ │
    │ │ │
    │ │ │ -gmpy2.unpack(x, n, /) list
    │ │ │ +gmpy2.unpack(x, n, /) list │ │ │

    Unpack an integer x into a list of n-bit values. Equivalent to │ │ │ repeated division by 2**n. Raises error if x is negative.

    │ │ │
    │ │ │ │ │ │ │ │ │ │ │ │ ├── html2text {} │ │ │ │ @@ -125,24 +125,24 @@ │ │ │ │ =============================================================================== │ │ │ │ ************ IInntteeggeerrss_? ************ │ │ │ │ ********** mmppzz ttyyppee_? ********** │ │ │ │ ccllaassss gmpy2.mpz(nn==00, //)_ │ │ │ │ ccllaassss gmpy2.mpz(ss, //, bbaassee==00) │ │ │ │ Return an immutable integer constructed from a numeric value n │ │ │ │ (truncating n to its integer part) or a string s made of digits in the │ │ │ │ - given base. Every input, that is accepted by the _i_n_t type constructor is │ │ │ │ + given base. Every input, that is accepted by the int type constructor is │ │ │ │ also accepted. │ │ │ │ The base may vary from 2 to 62, or if base is 0, then binary, octal, or │ │ │ │ hexadecimal strings are recognized by leading '0b', '0o', or '0x' │ │ │ │ characters (case is ignored), otherwise the string is assumed to be │ │ │ │ decimal. For bases up to 36, digits case is ignored. For bases 37 to 62, │ │ │ │ upper-case letter represent the usual 10..35 range, while lower-case │ │ │ │ letter represent 36..61. Optionally the string can be preceded by '+' or │ │ │ │ '-'. White space and underscore is simply ignored. │ │ │ │ - __format__(ffmmtt) → _s_t_r_ │ │ │ │ + __format__(ffmmtt) → str_ │ │ │ │ Return a Python string by formatting _m_p_z 'x' using the format │ │ │ │ string 'fmt'. A valid format string consists of: │ │ │ │ optional alignment code: │ │ │ │ '<' -> left shifted in field '>' -> right │ │ │ │ shifted in field '^' -> centered in field │ │ │ │ optional leading sign code: │ │ │ │ '+' -> always display leading sign '-' -> only │ │ │ │ @@ -153,159 +153,159 @@ │ │ │ │ 0o or 0x │ │ │ │ optional width │ │ │ │ optional conversion code: │ │ │ │ 'd' -> decimal format 'b' -> binary format 'o' │ │ │ │ -> octal format 'x' -> hex format 'X' -> upper- │ │ │ │ case hex format │ │ │ │ The default format is 'd'. │ │ │ │ - as_integer_ratio() → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + as_integer_ratio() → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return a pair of integers, whose ratio is exactly equal to the │ │ │ │ original number. The ratio is in lowest terms and has a positive │ │ │ │ denominator. │ │ │ │ bit_clear(nn, //) → _m_p_z_ │ │ │ │ Return a copy of x with the n-th bit cleared. │ │ │ │ - bit_count() → _i_n_t_ │ │ │ │ + bit_count() → int_ │ │ │ │ Return the number of 1-bits set in abs(x). │ │ │ │ bit_flip(nn, //) → _m_p_z_ │ │ │ │ Return a copy of x with the n-th bit inverted. │ │ │ │ - bit_length() → _i_n_t_ │ │ │ │ + bit_length() → int_ │ │ │ │ Return the number of significant bits in the radix-2 representation │ │ │ │ of x. Note: mpz(0).bit_length() returns 0. │ │ │ │ - bit_scan0(nn==00, //) → _i_n_t | _N_o_n_e_ │ │ │ │ + bit_scan0(nn==00, //) → int | None_ │ │ │ │ Return the index of the first 0-bit of x with index >= n. n >= 0. │ │ │ │ If there are no more 0-bits in x at or above index n (which can │ │ │ │ only happen for x<0, assuming an infinitely long 2's complement │ │ │ │ - format), then _N_o_n_e is returned. │ │ │ │ - bit_scan1(nn==00, //) → _i_n_t | _N_o_n_e_ │ │ │ │ + format), then None is returned. │ │ │ │ + bit_scan1(nn==00, //) → int | None_ │ │ │ │ Return the index of the first 1-bit of x with index >= n. n >= 0. │ │ │ │ If there are no more 1-bits in x at or above index n (which can │ │ │ │ only happen for x>=0, assuming an infinitely long 2's complement │ │ │ │ - format), then _N_o_n_e is returned. │ │ │ │ + format), then None is returned. │ │ │ │ bit_set(nn, //) → _m_p_z_ │ │ │ │ Return a copy of x with the n-th bit set. │ │ │ │ - bit_test(nn, //) → _b_o_o_l_ │ │ │ │ + bit_test(nn, //) → bool_ │ │ │ │ Return the value of the n-th bit of x. │ │ │ │ conjugate() → _m_p_z_ │ │ │ │ Return the conjugate of x (which is just a new reference to x since │ │ │ │ x is not a complex number). │ │ │ │ - digits(bbaassee==1100, //) → _s_t_r_ │ │ │ │ + digits(bbaassee==1100, //) → str_ │ │ │ │ Return Python string representing x in the given base. Values for │ │ │ │ base can range between 2 to 62. A leading '-' is present if x<0 but │ │ │ │ no leading '+' is present if x>=0. │ │ │ │ from_bytes(bbyytteess, bbyytteeoorrddeerr==''bbiigg'', **, ssiiggnneedd==FFaallssee) → _m_p_z_ │ │ │ │ Return the integer represented by the given array of bytes. │ │ │ │ bytes │ │ │ │ Holds the array of bytes to convert. The argument │ │ │ │ must either support the buffer protocol or be an │ │ │ │ - iterable object producing bytes. _b_y_t_e_s and │ │ │ │ - _b_y_t_e_a_r_r_a_y are examples of built-in objects that │ │ │ │ + iterable object producing bytes. bytes and │ │ │ │ + bytearray are examples of built-in objects that │ │ │ │ support the buffer protocol. │ │ │ │ byteorder │ │ │ │ The byte order used to represent the integer. If │ │ │ │ byteorder is 'big', the most significant byte is at │ │ │ │ the beginning of the byte array. If byteorder is │ │ │ │ 'little', the most significant byte is at the end │ │ │ │ of the byte array. To request the native byte order │ │ │ │ - of the host system, use _s_y_s_._b_y_t_e_o_r_d_e_r as the byte │ │ │ │ + of the host system, use sys.byteorder as the byte │ │ │ │ order value. │ │ │ │ signed │ │ │ │ Indicates whether two's complement is used to │ │ │ │ represent the integer. │ │ │ │ - is_congruent(yy, mm, //) → _b_o_o_l_ │ │ │ │ - Returns _T_r_u_e if x is congruent to y modulo m, else return _F_a_l_s_e. │ │ │ │ - is_divisible(dd, //) → _b_o_o_l_ │ │ │ │ - Returns _T_r_u_e if x is divisible by d, else return _F_a_l_s_e. │ │ │ │ - is_even() → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is even, _F_a_l_s_e otherwise. │ │ │ │ - is_odd() → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is odd, _F_a_l_s_e otherwise. │ │ │ │ - is_power() → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is a perfect power (there exists a y and an n > 1, │ │ │ │ - such that x=y**n), else return _F_a_l_s_e. │ │ │ │ - is_prime(nn==2255, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is pprroobbaabbllyy prime, else _F_a_l_s_e if x is definitely │ │ │ │ + is_congruent(yy, mm, //) → bool_ │ │ │ │ + Returns True if x is congruent to y modulo m, else return False. │ │ │ │ + is_divisible(dd, //) → bool_ │ │ │ │ + Returns True if x is divisible by d, else return False. │ │ │ │ + is_even() → bool_ │ │ │ │ + Return True if x is even, False otherwise. │ │ │ │ + is_odd() → bool_ │ │ │ │ + Return True if x is odd, False otherwise. │ │ │ │ + is_power() → bool_ │ │ │ │ + Return True if x is a perfect power (there exists a y and an n > 1, │ │ │ │ + such that x=y**n), else return False. │ │ │ │ + is_prime(nn==2255, //) → bool_ │ │ │ │ + Return True if x is pprroobbaabbllyy prime, else False if x is definitely │ │ │ │ composite. x is checked for small divisors and up to n Miller-Rabin │ │ │ │ tests are performed. │ │ │ │ - is_probab_prime(nn==2255, //) → _i_n_t_ │ │ │ │ + is_probab_prime(nn==2255, //) → int_ │ │ │ │ Return 2 if x is definitely prime, 1 if x is probably prime, or │ │ │ │ return 0 if x is definitely non-prime. x is checked for small │ │ │ │ divisors and up to n Miller-Rabin tests are performed. Reasonable │ │ │ │ values of n are between 15 and 50. │ │ │ │ - is_square() → _b_o_o_l_ │ │ │ │ - Returns _T_r_u_e if x is a perfect square, else return _F_a_l_s_e. │ │ │ │ - num_digits(bbaassee==1100, //) → _i_n_t_ │ │ │ │ + is_square() → bool_ │ │ │ │ + Returns True if x is a perfect square, else return False. │ │ │ │ + num_digits(bbaassee==1100, //) → int_ │ │ │ │ Return length of string representing the absolute value of x in the │ │ │ │ given base. Values for base can range between 2 and 62. The value │ │ │ │ returned may be 1 too large. │ │ │ │ - to_bytes(lleennggtthh==11, bbyytteeoorrddeerr==''bbiigg'', **, ssiiggnneedd==FFaallssee) → _b_y_t_e_s_ │ │ │ │ + to_bytes(lleennggtthh==11, bbyytteeoorrddeerr==''bbiigg'', **, ssiiggnneedd==FFaallssee) → bytes_ │ │ │ │ Return an array of bytes representing an integer. │ │ │ │ length │ │ │ │ - Length of bytes object to use. An _O_v_e_r_f_l_o_w_E_r_r_o_r is │ │ │ │ + Length of bytes object to use. An OverflowError is │ │ │ │ raised if the integer is not representable with the │ │ │ │ given number of bytes. │ │ │ │ byteorder │ │ │ │ The byte order used to represent the integer. If │ │ │ │ byteorder is 'big', the most significant byte is at │ │ │ │ the beginning of the byte array. If byteorder is │ │ │ │ 'little', the most significant byte is at the end │ │ │ │ of the byte array. To request the native byte order │ │ │ │ - of the host system, use _s_y_s_._b_y_t_e_o_r_d_e_r as the byte │ │ │ │ + of the host system, use sys.byteorder as the byte │ │ │ │ order value. │ │ │ │ signed │ │ │ │ Determines whether two's complement is used to │ │ │ │ - represent the integer. If signed is _F_a_l_s_e and a │ │ │ │ - negative integer is given, an _O_v_e_r_f_l_o_w_E_r_r_o_r is │ │ │ │ + represent the integer. If signed is False and a │ │ │ │ + negative integer is given, an OverflowError is │ │ │ │ raised. │ │ │ │ denominator_ │ │ │ │ the denominator of a rational number in lowest terms │ │ │ │ imag_ │ │ │ │ the imaginary part of a complex number │ │ │ │ numerator_ │ │ │ │ the numerator of a rational number in lowest terms │ │ │ │ real_ │ │ │ │ the real part of a complex number │ │ │ │ ********** mmppzz FFuunnccttiioonnss_? ********** │ │ │ │ gmpy2.bincoef(nn, kk, //) → _m_p_z_ │ │ │ │ Return the binomial coefficient ('n choose k'). k >= 0. │ │ │ │ gmpy2.bit_clear(xx, nn, //) → _m_p_z_ │ │ │ │ Return a copy of x with the n-th bit cleared. │ │ │ │ - gmpy2.bit_count(xx, //) → _i_n_t_ │ │ │ │ + gmpy2.bit_count(xx, //) → int_ │ │ │ │ Return the number of 1-bits set in abs(x). │ │ │ │ gmpy2.bit_flip(xx, nn, //) → _m_p_z_ │ │ │ │ Return a copy of x with the n-th bit inverted. │ │ │ │ - gmpy2.bit_length(xx, //) → _i_n_t_ │ │ │ │ + gmpy2.bit_length(xx, //) → int_ │ │ │ │ Return the number of significant bits in the radix-2 representation of x. │ │ │ │ Note: bit_length(0) returns 0. │ │ │ │ gmpy2.bit_mask(nn, //) → _m_p_z_ │ │ │ │ Return an _m_p_z exactly n bits in length with all bits set. │ │ │ │ - gmpy2.bit_scan0(xx, nn==00, //) → _i_n_t | _N_o_n_e_ │ │ │ │ + gmpy2.bit_scan0(xx, nn==00, //) → int | None_ │ │ │ │ Return the index of the first 0-bit of x with index >= n. n >= 0. If │ │ │ │ there are no more 0-bits in x at or above index n (which can only happen │ │ │ │ - for x<0, assuming an infinitely long 2's complement format), then _N_o_n_e is │ │ │ │ + for x<0, assuming an infinitely long 2's complement format), then None is │ │ │ │ returned. │ │ │ │ - gmpy2.bit_scan1(xx, nn==00, //) → _i_n_t | _N_o_n_e_ │ │ │ │ + gmpy2.bit_scan1(xx, nn==00, //) → int | None_ │ │ │ │ Return the index of the first 1-bit of x with index >= n. n >= 0. If │ │ │ │ there are no more 1-bits in x at or above index n (which can only happen │ │ │ │ - for x>=0, assuming an infinitely long 2's complement format), then _N_o_n_e │ │ │ │ + for x>=0, assuming an infinitely long 2's complement format), then None │ │ │ │ is returned. │ │ │ │ gmpy2.bit_set(xx, nn, //) → _m_p_z_ │ │ │ │ Return a copy of x with the n-th bit set. │ │ │ │ - gmpy2.bit_test(xx, nn, //) → _b_o_o_l_ │ │ │ │ + gmpy2.bit_test(xx, nn, //) → bool_ │ │ │ │ Return the value of the n-th bit of x. │ │ │ │ gmpy2.c_div(xx, yy, //) → _m_p_z_ │ │ │ │ Return the quotient of x divided by y. The quotient is rounded towards │ │ │ │ +Inf (ceiling rounding). x and y must be integers. │ │ │ │ gmpy2.c_div_2exp(xx, nn, //) → _m_p_z_ │ │ │ │ Returns the quotient of x divided by 2**n. The quotient is rounded │ │ │ │ towards +Inf (ceiling rounding). x must be an integer. n must be >0. │ │ │ │ - gmpy2.c_divmod(xx, yy, //) → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + gmpy2.c_divmod(xx, yy, //) → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return the quotient and remainder of x divided by y. The quotient is │ │ │ │ rounded towards +Inf (ceiling rounding) and the remainder will have the │ │ │ │ opposite sign of y. x and y must be integers. │ │ │ │ - gmpy2.c_divmod_2exp(xx, nn, //) → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + gmpy2.c_divmod_2exp(xx, nn, //) → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return the quotient and remainder of x divided by 2**n. The quotient is │ │ │ │ rounded towards +Inf (ceiling rounding) and the remainder will be │ │ │ │ negative. x must be an integer. n must be >0. │ │ │ │ gmpy2.c_mod(xx, yy, //) → _m_p_z_ │ │ │ │ Return the remainder of x divided by y. The remainder will have the │ │ │ │ opposite sign of y. x and y must be integers. │ │ │ │ gmpy2.c_mod_2exp(xx, nn, //) → _m_p_z_ │ │ │ │ @@ -314,166 +314,166 @@ │ │ │ │ gmpy2.comb(nn, kk, //) → _m_p_z_ │ │ │ │ Return the number of combinations of 'n things, taking k at a time'. k >= │ │ │ │ 0. Same as bincoef(n, k) │ │ │ │ gmpy2.divexact(xx, yy, //) → _m_p_z_ │ │ │ │ Return the quotient of x divided by y. Faster than standard division but │ │ │ │ requires the remainder is zero! │ │ │ │ gmpy2.divm(aa, bb, mm, //) → _m_p_z_ │ │ │ │ - Return x such that b*x == a mod m. Raises a _Z_e_r_o_D_i_v_i_s_i_o_n_E_r_r_o_r exception │ │ │ │ + Return x such that b*x == a mod m. Raises a ZeroDivisionError exception │ │ │ │ if no such value x exists. │ │ │ │ gmpy2.double_fac(nn, //) → _m_p_z_ │ │ │ │ Return the exact double factorial (n!!) of n. The double factorial is │ │ │ │ defined as n*(n-2)*(n-4)... │ │ │ │ gmpy2.f_div(xx, yy, //) → _m_p_z_ │ │ │ │ Return the quotient of x divided by y. The quotient is rounded towards - │ │ │ │ Inf (floor rounding). x and y must be integers. │ │ │ │ gmpy2.f_div_2exp(xx, nn, //) → _m_p_z_ │ │ │ │ Return the quotient of x divided by 2**n. The quotient is rounded towards │ │ │ │ -Inf (floor rounding). x must be an integer. n must be >0. │ │ │ │ - gmpy2.f_divmod(xx, yy, //) → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + gmpy2.f_divmod(xx, yy, //) → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return the quotient and remainder of x divided by y. The quotient is │ │ │ │ rounded towards -Inf (floor rounding) and the remainder will have the │ │ │ │ same sign as y. x and y must be integers. │ │ │ │ - gmpy2.f_divmod_2exp(xx, nn, //) → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + gmpy2.f_divmod_2exp(xx, nn, //) → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return quotient and remainder after dividing x by 2**n. The quotient is │ │ │ │ rounded towards -Inf (floor rounding) and the remainder will be positive. │ │ │ │ x must be an integer. n must be >0. │ │ │ │ gmpy2.f_mod(xx, yy, //) → _m_p_z_ │ │ │ │ Return the remainder of x divided by y. The remainder will have the same │ │ │ │ sign as y. x and y must be integers. │ │ │ │ gmpy2.f_mod_2exp(xx, nn, //) → _m_p_z_ │ │ │ │ Return remainder of x divided by 2**n. The remainder will be positive. x │ │ │ │ must be an integer. n must be >0. │ │ │ │ gmpy2.fac(nn, //) → _m_p_z_ │ │ │ │ Return the exact factorial of n. │ │ │ │ See factorial(n) to get the floating-point approximation. │ │ │ │ gmpy2.fib(nn, //) → _m_p_z_ │ │ │ │ Return the n-th Fibonacci number. │ │ │ │ - gmpy2.fib2(nn, //) → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + gmpy2.fib2(nn, //) → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return a 2-tuple with the (n-1)-th and n-th Fibonacci numbers. │ │ │ │ gmpy2.gcd(**iinntteeggeerrss, //) → _m_p_z_ │ │ │ │ Return the greatest common divisor of integers. │ │ │ │ - gmpy2.gcdext(aa, bb, //) → _t_u_p_l_e[_m_p_z, _m_p_z, _m_p_z]_ │ │ │ │ + gmpy2.gcdext(aa, bb, //) → tuple[_m_p_z, _m_p_z, _m_p_z]_ │ │ │ │ Return a 3-element tuple (g,s,t) such that g == gcd(a,b) and g == a*s + │ │ │ │ b*t. │ │ │ │ - gmpy2.hamdist(xx, yy, //) → _i_n_t_ │ │ │ │ + gmpy2.hamdist(xx, yy, //) → int_ │ │ │ │ Return the Hamming distance (number of bit-positions where the bits │ │ │ │ differ) between integers x and y. │ │ │ │ gmpy2.invert(xx, mm, //) → _m_p_z_ │ │ │ │ - Return y such that x*y == 1 modulo m. Raises _Z_e_r_o_D_i_v_i_s_i_o_n_E_r_r_o_r if no │ │ │ │ + Return y such that x*y == 1 modulo m. Raises ZeroDivisionError if no │ │ │ │ inverse exists. │ │ │ │ - gmpy2.iroot(xx, nn, //) → _t_u_p_l_e[_m_p_z, _b_o_o_l]_ │ │ │ │ - Return the integer n-th root of x and boolean value that is _T_r_u_e iff the │ │ │ │ + gmpy2.iroot(xx, nn, //) → tuple[_m_p_z, bool]_ │ │ │ │ + Return the integer n-th root of x and boolean value that is True iff the │ │ │ │ root is exact. x >= 0. n > 0. │ │ │ │ - gmpy2.iroot_rem(xx, nn, //) → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + gmpy2.iroot_rem(xx, nn, //) → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return a 2-element tuple (y,r), such that y is the integer n-th root of x │ │ │ │ and x=y**n + r. x >= 0. n > 0. │ │ │ │ - gmpy2.is_congruent(xx, yy, mm, //) → _b_o_o_l_ │ │ │ │ - Returns _T_r_u_e if x is congruent to y modulo m, else return _F_a_l_s_e. │ │ │ │ - gmpy2.is_divisible(xx, dd, //) → _b_o_o_l_ │ │ │ │ - Returns _T_r_u_e if x is divisible by d, else return _F_a_l_s_e. │ │ │ │ - gmpy2.is_even(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is even, _F_a_l_s_e otherwise. │ │ │ │ - gmpy2.is_odd(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is odd, _F_a_l_s_e otherwise. │ │ │ │ - gmpy2.is_power(xx, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is a perfect power (there exists a y and an n > 1, such │ │ │ │ - that x=y**n), else return _F_a_l_s_e. │ │ │ │ - gmpy2.is_prime(xx, nn==2255, //) → _b_o_o_l_ │ │ │ │ - Return _T_r_u_e if x is pprroobbaabbllyy prime, else _F_a_l_s_e if x is definitely │ │ │ │ + gmpy2.is_congruent(xx, yy, mm, //) → bool_ │ │ │ │ + Returns True if x is congruent to y modulo m, else return False. │ │ │ │ + gmpy2.is_divisible(xx, dd, //) → bool_ │ │ │ │ + Returns True if x is divisible by d, else return False. │ │ │ │ + gmpy2.is_even(xx, //) → bool_ │ │ │ │ + Return True if x is even, False otherwise. │ │ │ │ + gmpy2.is_odd(xx, //) → bool_ │ │ │ │ + Return True if x is odd, False otherwise. │ │ │ │ + gmpy2.is_power(xx, //) → bool_ │ │ │ │ + Return True if x is a perfect power (there exists a y and an n > 1, such │ │ │ │ + that x=y**n), else return False. │ │ │ │ + gmpy2.is_prime(xx, nn==2255, //) → bool_ │ │ │ │ + Return True if x is pprroobbaabbllyy prime, else False if x is definitely │ │ │ │ composite. x is checked for small divisors and up to n Miller-Rabin tests │ │ │ │ are performed. │ │ │ │ - gmpy2.is_probab_prime(xx, nn==2255, //) → _i_n_t_ │ │ │ │ + gmpy2.is_probab_prime(xx, nn==2255, //) → int_ │ │ │ │ Return 2 if x is definitely prime, 1 if x is probably prime, or return 0 │ │ │ │ if x is definitely non-prime. x is checked for small divisors and up to n │ │ │ │ Miller-Rabin tests are performed. Reasonable values of n are between 15 │ │ │ │ and 50. │ │ │ │ - gmpy2.is_square(xx, //) → _b_o_o_l_ │ │ │ │ - Returns _T_r_u_e if x is a perfect square, else return _F_a_l_s_e. │ │ │ │ + gmpy2.is_square(xx, //) → bool_ │ │ │ │ + Returns True if x is a perfect square, else return False. │ │ │ │ gmpy2.isqrt(xx, //) → _m_p_z_ │ │ │ │ Return the integer square root of a non-negative integer x. │ │ │ │ gmpy2.isqrt_rem(xx, //)_ │ │ │ │ Return a 2-element tuple (s,t) such that s=isqrt(x) and t=x-s*s. x >=0. │ │ │ │ gmpy2.jacobi(xx, yy, //) → _m_p_z_ │ │ │ │ Return the Jacobi symbol (x|y). y must be odd and >0. │ │ │ │ gmpy2.kronecker(xx, yy, //) → _m_p_z_ │ │ │ │ Return the Kronecker-Jacobi symbol (x|y). │ │ │ │ gmpy2.lcm(**iinntteeggeerrss, //) → _m_p_z_ │ │ │ │ Return the lowest common multiple of integers. │ │ │ │ gmpy2.legendre(xx, yy, //) → _m_p_z_ │ │ │ │ Return the Legendre symbol (x|y). y is assumed to be an odd prime. │ │ │ │ gmpy2.lucas(nn, //) → _m_p_z_ │ │ │ │ Return the n-th Lucas number. │ │ │ │ - gmpy2.lucas2(nn, //) → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + gmpy2.lucas2(nn, //) → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return a 2-tuple with the (n-1)-th and n-th Lucas numbers. │ │ │ │ gmpy2.mpz_random(rraannddoomm__ssttaattee, iinntt, //) → _m_p_z_ │ │ │ │ Return uniformly distributed random integer between 0 and n-1. │ │ │ │ gmpy2.mpz_rrandomb(rraannddoomm__ssttaattee, bbiitt__ccoouunntt, //) → _m_p_z_ │ │ │ │ Return a random integer between 0 and 2**bit_count-1 with long sequences │ │ │ │ of zeros and one in its binary representation. │ │ │ │ gmpy2.mpz_urandomb(rraannddoomm__ssttaattee, bbiitt__ccoouunntt, //) → _m_p_z_ │ │ │ │ Return uniformly distributed random integer between 0 and 2**bit_count-1. │ │ │ │ gmpy2.multi_fac(nn, mm, //) → _m_p_z_ │ │ │ │ Return the exact m-multi factorial of n. The m-multifactorial is defined │ │ │ │ as n*(n-m)*(n-2m)... │ │ │ │ gmpy2.next_prime(xx, //) → _m_p_z_ │ │ │ │ Return the next pprroobbaabbllee prime number > x. │ │ │ │ - gmpy2.num_digits(xx, bbaassee==1100, //) → _i_n_t_ │ │ │ │ + gmpy2.num_digits(xx, bbaassee==1100, //) → int_ │ │ │ │ Return length of string representing the absolute value of x in the given │ │ │ │ base. Values for base can range between 2 and 62. The value returned may │ │ │ │ be 1 too large. │ │ │ │ gmpy2.pack(llsstt, nn, //) → _m_p_z_ │ │ │ │ Pack a list of integers lst into a single _m_p_z by concatenating each │ │ │ │ integer element of lst after padding to length n bits. Raises an error if │ │ │ │ any integer is negative or greater than n bits in length. │ │ │ │ - gmpy2.popcount(xx, //) → _i_n_t_ │ │ │ │ + gmpy2.popcount(xx, //) → int_ │ │ │ │ Return the number of 1-bits set in x. If x<0, the number of 1-bits is │ │ │ │ infinite so -1 is returned in that case. │ │ │ │ gmpy2.powmod(xx, yy, mm, //) → _m_p_z_ │ │ │ │ Return (x**y) mod m. Same as the three argument version of Python's │ │ │ │ - built-in _p_o_w, but converts all three arguments to _m_p_z. │ │ │ │ - gmpy2.powmod_exp_list(bbaassee, eexxpp__llsstt, mmoodd, //) → _l_i_s_t[_m_p_z, ...]_ │ │ │ │ + built-in pow, but converts all three arguments to _m_p_z. │ │ │ │ + gmpy2.powmod_exp_list(bbaassee, eexxpp__llsstt, mmoodd, //) → list[_m_p_z, ...]_ │ │ │ │ Returns list(powmod(base, i, mod) for i in exp_lst). Will always release │ │ │ │ the GIL. (Experimental in gmpy2 2.1.x). │ │ │ │ - gmpy2.powmod_base_list(bbaassee__llsstt, eexxpp, mmoodd, //) → _l_i_s_t[_m_p_z, ...]_ │ │ │ │ + gmpy2.powmod_base_list(bbaassee__llsstt, eexxpp, mmoodd, //) → list[_m_p_z, ...]_ │ │ │ │ Returns list(powmod(i, exp, mod) for i in base_lst). Will always release │ │ │ │ the GIL. (Experimental in gmpy2 2.1.x). │ │ │ │ gmpy2.powmod_sec(xx, yy, mm, //) → _m_p_z_ │ │ │ │ Return (x**y) mod m. Calculates x ** y (mod m) but using a constant time │ │ │ │ algorithm to reduce the risk of side channel attacks. y must be an │ │ │ │ integer >0. m must be an odd integer. │ │ │ │ gmpy2.prev_prime(xx, //) → _m_p_z_ │ │ │ │ Return the previous pprroobbaabbllee prime number < x. Only present when compiled │ │ │ │ with GMP 6.3.0 or later. │ │ │ │ gmpy2.primorial(nn, //) → _m_p_z_ │ │ │ │ Return the product of all positive prime numbers less than or equal to n. │ │ │ │ - gmpy2.remove(xx, ff, //) → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + gmpy2.remove(xx, ff, //) → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return a 2-element tuple (y,m) such that x=y*(f**m) and f does not divide │ │ │ │ y. Remove the factor f from x as many times as possible. m is the │ │ │ │ multiplicity f in x. f > 1. │ │ │ │ gmpy2.t_div(xx, yy, //) → _m_p_z_ │ │ │ │ Return the quotient of x divided by y. The quotient is rounded towards 0. │ │ │ │ x and y must be integers. │ │ │ │ gmpy2.t_div_2exp(xx, nn, //) → _m_p_z_ │ │ │ │ Return the quotient of x divided by 2**n. The quotient is rounded towards │ │ │ │ zero (truncation). n must be >0. │ │ │ │ - gmpy2.t_divmod(xx, yy, //) → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + gmpy2.t_divmod(xx, yy, //) → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return the quotient and remainder of x divided by y. The quotient is │ │ │ │ rounded towards zero (truncation) and the remainder will have the same │ │ │ │ sign as x. x and y must be integers. │ │ │ │ - gmpy2.t_divmod_2exp(xx, nn, //) → _t_u_p_l_e[_m_p_z, _m_p_z]_ │ │ │ │ + gmpy2.t_divmod_2exp(xx, nn, //) → tuple[_m_p_z, _m_p_z]_ │ │ │ │ Return the quotient and remainder of x divided by 2**n. The quotient is │ │ │ │ rounded towards zero (truncation) and the remainder will have the same │ │ │ │ sign as x. x must be an integer. n must be >0. │ │ │ │ gmpy2.t_mod(xx, yy, //) → _m_p_z_ │ │ │ │ Return the remainder of x divided by y. The remainder will have the same │ │ │ │ sign as x. x and y must be integers. │ │ │ │ gmpy2.t_mod_2exp(xx, nn, //) → _m_p_z_ │ │ │ │ Return the remainder of x divided by 2**n. The remainder will have the │ │ │ │ same sign as x. x must be an integer. n must be >0. │ │ │ │ - gmpy2.unpack(xx, nn, //) → _l_i_s_t_ │ │ │ │ + gmpy2.unpack(xx, nn, //) → list_ │ │ │ │ Unpack an integer x into a list of n-bit values. Equivalent to repeated │ │ │ │ division by 2**n. Raises error if x is negative. │ │ │ │ _P_r_e_v_i_o_u_s _N_e_x_t │ │ │ │ =============================================================================== │ │ │ │ © Copyright 2024 - 2024, Case Van Horsen. │ │ │ │ Built with _S_p_h_i_n_x using a _t_h_e_m_e provided by _R_e_a_d_ _t_h_e_ _D_o_c_s. │ │ ├── ./usr/share/doc/python-gmpy2-doc/html/overview.html │ │ │ @@ -86,15 +86,15 @@ │ │ │
    │ │ │
    │ │ │ │ │ │
    │ │ │

    Overview

    │ │ │

    The mpz and mpq types support arbitrary precision integers and rationals │ │ │ via the GMP library. These types should be drop-in replacements for Python's │ │ │ -int's and Fraction's, but are significantly faster for large │ │ │ +int's and Fraction's, but are significantly faster for large │ │ │ values. The cutover point for performance varies, but can be as low as 20 to │ │ │ 40 digits. All the special integer functions in the GMP are supported.

    │ │ │
    │ │ │

    Warning

    │ │ │

    gmpy2 can crash the Python interpreter in case of memory allocation │ │ │ failure. To mitigate this feature of memory management in the GMP library, │ │ │ you should estimate the size of all results and prevent calculations that │ │ │ @@ -102,15 +102,15 @@ │ │ │

    │ │ │

    The mpfr and mpc types provide support for correctly rounded multiple │ │ │ precision real and complex arithmetic via the MPFR and MPC libraries. The │ │ │ context type is used to control precision, rounding modes, and exceptional │ │ │ conditions. For example, division by zero can either return an Infinity or │ │ │ raise an exception. It is possible to specify different precision and rounding │ │ │ modes for both the real and imaginary components of an mpc. The default │ │ │ -precision is 53 bits --- just same as for Python's float and complex types.

    │ │ │ +precision is 53 bits --- just same as for Python's float and complex types.

    │ │ │

    Operator overloading is fully supported. Coversion from native Python types is │ │ │ optimized for performance.

    │ │ │
    │ │ │ │ │ │ │ │ │
    │ │ │
    │ │ │ ├── html2text {} │ │ │ │ @@ -18,29 +18,29 @@ │ │ │ │ * _R_e_l_e_a_s_e_ _N_o_t_e_s │ │ │ │ _g_m_p_y_2 │ │ │ │ * Overview │ │ │ │ * _V_i_e_w_ _p_a_g_e_ _s_o_u_r_c_e │ │ │ │ =============================================================================== │ │ │ │ ************ OOvveerrvviieeww_? ************ │ │ │ │ The _m_p_z and _m_p_q types support arbitrary precision integers and rationals via │ │ │ │ -the GMP library. These types should be drop-in replacements for Python's _i_n_t's │ │ │ │ -and _F_r_a_c_t_i_o_n's, but are significantly faster for large values. The cutover │ │ │ │ +the GMP library. These types should be drop-in replacements for Python's int's │ │ │ │ +and Fraction's, but are significantly faster for large values. The cutover │ │ │ │ point for performance varies, but can be as low as 20 to 40 digits. All the │ │ │ │ special integer functions in the GMP are supported. │ │ │ │ Warning │ │ │ │ gmpy2 can crash the Python interpreter in case of memory allocation failure. To │ │ │ │ mitigate this feature of memory management in the GMP library, you should │ │ │ │ estimate the size of all results and prevent calculations that can exaust │ │ │ │ available memory. │ │ │ │ The _m_p_f_r and _m_p_c types provide support for correctly rounded multiple precision │ │ │ │ real and complex arithmetic via the MPFR and MPC libraries. The _c_o_n_t_e_x_t type is │ │ │ │ used to control precision, rounding modes, and exceptional conditions. For │ │ │ │ example, division by zero can either return an Infinity or raise an exception. │ │ │ │ It is possible to specify different precision and rounding modes for both the │ │ │ │ real and imaginary components of an _m_p_c. The default precision is 53 bits -- │ │ │ │ -- just same as for Python's _f_l_o_a_t and _c_o_m_p_l_e_x types. │ │ │ │ +- just same as for Python's float and complex types. │ │ │ │ Operator overloading is fully supported. Coversion from native Python types is │ │ │ │ optimized for performance. │ │ │ │ _P_r_e_v_i_o_u_s _N_e_x_t │ │ │ │ =============================================================================== │ │ │ │ © Copyright 2024 - 2024, Case Van Horsen. │ │ │ │ Built with _S_p_h_i_n_x using a _t_h_e_m_e provided by _R_e_a_d_ _t_h_e_ _D_o_c_s. │ │ ├── ./usr/share/doc/python-gmpy2-doc/html/tutorial.html │ │ │ @@ -177,26 +177,26 @@ │ │ │ gmpy2.DivisionByZeroError: division by zero │ │ │ >>> ctx.divzero │ │ │ True │ │ │ │ │ │ │ │ │

    Exceptions are normally raised in Python when the result of a real operation is │ │ │ not defined over the reals; for example, math.sqrt(-2) will raise a │ │ │ -ValueError exception. The default context in gmpy2 implements similar │ │ │ +ValueError exception. The default context in gmpy2 implements similar │ │ │ behavior, but by setting allow_complex flag, complex results │ │ │ will be returned.

    │ │ │
    >>> sqrt(mpfr(-2))
    │ │ │  mpfr('nan')
    │ │ │  >>> ctx.allow_complex = True
    │ │ │  >>> sqrt(mpfr(-2))
    │ │ │  mpc('0.0+1.4142135623730951j')
    │ │ │  
    │ │ │
    │ │ │

    Contexts can also be used as context managers in conjunction with Python's │ │ │ -with statement to temporarily change the current context settings │ │ │ +with statement to temporarily change the current context settings │ │ │ for a block of code.

    │ │ │
    >>> print(const_pi())
    │ │ │  3.1415926535897931
    │ │ │  >>> with context(precision=100) as ctx:
    │ │ │  ...   print(const_pi())
    │ │ │  ...   ctx.precision += 20
    │ │ │  ...   print(const_pi())
    │ │ │ @@ -214,15 +214,15 @@
    │ │ │  >>> ctx.imag_prec = 70
    │ │ │  >>> sqrt(mpc('1+2j'))
    │ │ │  mpc('1.272019649514068965+0.78615137775742328606947j',(60,70))
    │ │ │  
    │ │ │
    │ │ │

    All gmpy2 numeric types support Python's "new style" string formatting │ │ │ available in formatted string literals or with │ │ │ -str.format(); see Format Specification Mini-Language for a description │ │ │ +str.format(); see Format Specification Mini-Language for a description │ │ │ of the standard formatting syntax. The precision value optionally can be │ │ │ followed by the rounding mode type ('U' to round toward plus infinity, 'D' to │ │ │ round toward minus infinity, 'Y' to round away from zero, 'Z' to round toward │ │ │ zero and 'N' - round to the nearest value.

    │ │ │
    >>> a = mpfr("1.23456")
    │ │ │  >>> "{0:15.3f}".format(a)
    │ │ │  '          1.235'
    │ │ │ ├── html2text {}
    │ │ │ │ @@ -99,23 +99,23 @@
    │ │ │ │  >>> mpfr(1)/0
    │ │ │ │  Traceback (most recent call last):
    │ │ │ │  ...
    │ │ │ │  gmpy2.DivisionByZeroError: division by zero
    │ │ │ │  >>> ctx.divzero
    │ │ │ │  True
    │ │ │ │  Exceptions are normally raised in Python when the result of a real operation is
    │ │ │ │ -not defined over the reals; for example, math.sqrt(-2) will raise a _V_a_l_u_e_E_r_r_o_r
    │ │ │ │ +not defined over the reals; for example, math.sqrt(-2) will raise a ValueError
    │ │ │ │  exception. The default context in gmpy2 implements similar behavior, but by
    │ │ │ │  setting _a_l_l_o_w___c_o_m_p_l_e_x flag, complex results will be returned.
    │ │ │ │  >>> sqrt(mpfr(-2))
    │ │ │ │  mpfr('nan')
    │ │ │ │  >>> ctx.allow_complex = True
    │ │ │ │  >>> sqrt(mpfr(-2))
    │ │ │ │  mpc('0.0+1.4142135623730951j')
    │ │ │ │ -Contexts can also be used as context managers in conjunction with Python's _w_i_t_h
    │ │ │ │ +Contexts can also be used as context managers in conjunction with Python's with
    │ │ │ │  statement to temporarily change the current context settings for a block of
    │ │ │ │  code.
    │ │ │ │  >>> print(const_pi())
    │ │ │ │  3.1415926535897931
    │ │ │ │  >>> with context(precision=100) as ctx:
    │ │ │ │  ...   print(const_pi())
    │ │ │ │  ...   ctx.precision += 20
    │ │ │ │ @@ -129,15 +129,15 @@
    │ │ │ │  components.
    │ │ │ │  >>> ctx = get_context()
    │ │ │ │  >>> ctx.real_prec = 60
    │ │ │ │  >>> ctx.imag_prec = 70
    │ │ │ │  >>> sqrt(mpc('1+2j'))
    │ │ │ │  mpc('1.272019649514068965+0.78615137775742328606947j',(60,70))
    │ │ │ │  All gmpy2 numeric types support Python's "new style" string formatting
    │ │ │ │ -available in _f_o_r_m_a_t_t_e_d_ _s_t_r_i_n_g_ _l_i_t_e_r_a_l_s or with _s_t_r_._f_o_r_m_a_t_(_); see _F_o_r_m_a_t
    │ │ │ │ +available in _f_o_r_m_a_t_t_e_d_ _s_t_r_i_n_g_ _l_i_t_e_r_a_l_s or with str.format(); see _F_o_r_m_a_t
    │ │ │ │  _S_p_e_c_i_f_i_c_a_t_i_o_n_ _M_i_n_i_-_L_a_n_g_u_a_g_e for a description of the standard formatting
    │ │ │ │  syntax. The precision value optionally can be followed by the rounding mode
    │ │ │ │  type ('U' to round toward plus infinity, 'D' to round toward minus infinity,
    │ │ │ │  'Y' to round away from zero, 'Z' to round toward zero and 'N' - round to the
    │ │ │ │  nearest value.
    │ │ │ │  >>> a = mpfr("1.23456")
    │ │ │ │  >>> "{0:15.3f}".format(a)