115 Commits

Author SHA1 Message Date
Sergey B Kirpichev 27a1fe7f6d Merge pull request #1115 from skirpichev/shortest-repr/1028
Use shortest decimal representations for str/repr
2026-08-21 04:34:47 +03:00
Ayush Baranwal ffcaef924a Add fft()/invfft() functions for DFT calculation (#1152)
Addresses #707

Implements the Radix-2 Cooley-Tukey Fast Fourier Transform (FFT) algorithm to
compute the discrete fourier transform and inverse discrete fourier transform of a signal.

Inputs are currently restricted to lengths of powers of 2.
2026-08-21 04:23:58 +03:00
Sergey B Kirpichev 70b722800f Use shortest decimal representations for str/repr
Was:
```
$ python -m mpmath
>>> 0.1
0.10000000000000001
```

Now:
```
$ python -m mpmath --shortest-str
>>> 0.1
0.1
```

Closes #1028
2026-08-20 12:46:40 +03:00
Sergey B Kirpichev 017cc473fb Merge pull request #1154 from skirpichev/document-pretty_dps
Document pretty_dps context's option
2026-08-06 06:32:14 +03:00
Sergey B Kirpichev 24538751aa Document pretty_dps context's option
This amends a14901da.
2026-08-06 05:07:36 +03:00
Sergey B Kirpichev 4a3af8ef2b Use round_nearest in repr/str and as default mpf's rounding mode
Better alternative to #1137 (which was partially reverted).

Closes #1129
2026-08-05 09:47:43 +03:00
Sergey B Kirpichev fb69943530 Use explicit kwargs in public API, where possible
Following functions kept:
```pycon
>>> import inspect
... with_args = []
... with_kwargs = []
... for n in dir(mpmath):
...     m = getattr(mpmath, n)
...     try:
...         s = inspect.signature(m)
...     except:
...         continue
...     if any(_.kind == inspect._ParameterKind.VAR_POSITIONAL for _ in s.parameters.values()):
...         for name in s.parameters:
...             if s.parameters[name].kind == inspect._ParameterKind.VAR_POSITIONAL and name == 'args':
...                 with_args.append(n)
...                 break
...     if any(_.kind == inspect._ParameterKind.VAR_KEYWORD for _ in s.parameters.values()):
...         with_kwargs.append(n)
... print(with_args)
... print(with_kwargs)
...
['arange', 'ellipe', 'ellippi', 'linspace', 'matrix', 'ones', 'timing', 'zeros']
['multiplicity', 'timing']
```

We need support for multiple signatures in the first case.  In the
second - it's impossible to implement these functions without kwargs.

Closes #1056
2026-08-04 06:40:53 +03:00
Sergey B Kirpichev 3e73240699 Merge pull request #1146 from HeskethGD/g2-g3-omega-from
test / linter (push) Failing after 1s
test / coverage (push) Failing after 0s
test / docs (push) Failing after 0s
Publish on PyPI / Build distributions (push) Has been cancelled
test / frozen-version (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
test / tests (false, false, 3.10) (push) Has been cancelled
test / tests (false, false, 3.11) (push) Has been cancelled
test / tests (false, false, 3.12) (push) Has been cancelled
test / tests (false, false, 3.13) (push) Has been cancelled
test / tests (false, false, 3.14) (push) Has been cancelled
test / tests (false, false, 3.14t) (push) Has been cancelled
test / tests (false, false, 3.15) (push) Has been cancelled
test / tests (false, false, 3.15t) (push) Has been cancelled
test / tests (true, pypy3.11) (push) Has been cancelled
test / tests (true, 3.x) (push) Has been cancelled
Standardise Weierstrass from param functions
2026-07-27 03:54:00 +03:00
Sergey B Kirpichev 460c289f90 Update repo link (git -> https)
Publish on PyPI / Build distributions (push) Has been cancelled
test / frozen-version (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
test / tests (false, false, 3.10) (push) Has been cancelled
test / tests (false, false, 3.11) (push) Has been cancelled
test / tests (false, false, 3.12) (push) Has been cancelled
test / tests (false, false, 3.13) (push) Has been cancelled
test / tests (false, false, 3.14) (push) Has been cancelled
test / tests (false, false, 3.14t) (push) Has been cancelled
test / tests (false, false, 3.15) (push) Has been cancelled
test / tests (false, false, 3.15t) (push) Has been cancelled
test / tests (true, pypy3.11) (push) Has been cancelled
test / coverage (push) Failing after 1s
test / docs (push) Failing after 0s
test / linter (push) Failing after 1s
test / tests (true, 3.x) (push) Has been cancelled
Closes #1145
2026-07-26 03:07:07 +03:00
HeskethGD 1f3e9bf593 Rename Weierstrass parameter converters 2026-07-25 17:32:21 +01:00
HeskethGD 534dd479f0 Expand Weierstrass parameter conversions 2026-07-25 17:32:06 +01:00
Sergey B Kirpichev d30d632c39 Use reversed rounding mode for repr
Closes #1129
2026-07-19 04:59:27 +03:00
HeskethGD 6f2a553551 Add inverse Klein j-function 2026-07-13 16:08:46 +01:00
Warren Weckesser 8d21910bba Implement the modified spherical bessel functions spherical_in() and spherical_kn(). (#1121) 2026-07-08 04:13:53 +03:00
Sergey B Kirpichev c44efa2ca2 Remove py2 remnants (cast round() to int) 2026-07-01 08:08:19 +03:00
Sergey B Kirpichev 6f1fbd275d Fix repr_dps() to produce a correct estimate
That should work at lest for 32-bit integers.  Though, I think that
the repr/str representation loses all sence for precisions much
less than that ;-)

Closes #1116
2026-07-01 05:36:13 +03:00
Graham Hesketh aa205a2821 Add Weierstrass elliptic functions (#1113)
* Weierstrass $\wp$: `weierp`
* inverse Weierstrass $\wp$: `weierpinv`
* derivative of Weierstrass $\wp$: `weierpprime`
* Weierstrass zeta: `weierzeta`
* Weierstrass sigma: `weiersigma`

Also adds parameter conversion functions:

* Weierstrass invariants $g_2, g_3$: `weierinvariants`
* half-periods $\omega_1, \omega_2$: `weierhalfperiods`

The idea for this PR was inspired by the `pyweierstrass` package by @stla / Stéphane Laurent:

* https://pyweierstrass.readthedocs.io/en/latest/
* https://github.com/stla/pyweierstrass

The code implementation in this PR is different to that in `pyweierstrass` although both packages derive from similar well known mathematical formulas. Differences between `pyweierstrass` and this `mpmath` implementation include but are not limited to:

* function names adapted to `mpmath` conventions;
* tau normalization: `tau` specifies the normalized period lattice `(1, tau)`, corresponding to half-periods `(1/2, tau/2)`; this differs from `pyweierstrass`, where `tau` denotes half-periods `(1, tau)`;
* support for disambiguating inverse values of Weierstrass $\wp$ by optionally passing the corresponding derivative value;
* internal refactoring of helper functions for integration with `mpmath`.

Dedicated to Stéphane Laurent who opened the original PR to request this functionality in `mpmath` and whose `pyweierstrass` package provided great utility to the author of this PR in the years since.

Co-authored-by: Stéphane Laurent <stla@users.noreply.github.com>

Closes #612
2026-06-30 03:43:58 +03:00
Sergey B Kirpichev 6dfd359ed6 Merge pull request #1106 from skirpichev/misc
Misc fixes
2026-06-21 12:39:33 +03:00
Sergey B Kirpichev b62c4173d1 Support CPython v3.15 2026-06-20 09:10:21 +03:00
Ayush Baranwal a2e0351345 Add Brent root-finding algorithm (#1103)
Closes #1095
2026-06-19 03:31:16 +03:00
Ayush Baranwal 44ad9908cc Add ModAB rootfinding algorithm (#1093)
closes #1075
2026-06-07 04:30:24 +03:00
Sergey B Kirpichev d1e52ed28d Adapt doctests
Was:
```pycon
>>> A = mp.matrix([[3, -1, 2], [2, 5, -5], [-2, -3, 7]])
>>> Q, R = mp.schur(A)
>>> mp.norm(Q.T*A*Q-R, inf)
1.8166878507717441e-15
```

Now:
```pycon
>>> A = mp.matrix([[3, -1, 2], [2, 5, -5], [-2, -3, 7]])
>>> Q, R = mp.schur(A)
>>> mp.norm(Q.T*A*Q-R, inf)
1.3322676295501878e-15
```
2026-05-25 04:05:28 +03:00
Sergey B Kirpichev 87cfbc42a8 Correct to_float() conversion for subnormals
Closes #1078
2026-05-18 07:46:12 +03:00
Sergey B Kirpichev eefbdcb6ad Improve documentation about rounding in the mp context
See #1076

Also (small optimization) unify _normalize and normalize.
2026-05-13 07:55:29 +03:00
Sergey B Kirpichev 2f6a5d52f3 Drop support for CPython 3.9
(Following https://github.com/sympy/sympy/pull/28816)
2026-03-04 07:14:17 +03:00
Sergey B Kirpichev aed6aecdcd Fix year in conf.py 2026-02-22 08:40:58 +03:00
Sergey B Kirpichev e95bf2a22a Fix some found formatting issues with docs 2026-02-22 07:42:46 +03:00
Sergey B Kirpichev b6b535bc72 Drop OpenSUSE note (looks outdated) 2026-02-22 05:18:47 +03:00
Sergey B Kirpichev f3edc81705 Document python-gmp usage 2026-02-01 04:18:39 +03:00
Sergey B Kirpichev ffda440b4d Update copyright
test / linter (push) Failing after 0s
test / coverage (push) Failing after 0s
test / tests (false, false, 3.10) (push) Has been skipped
test / tests (false, false, 3.11) (push) Has been skipped
test / tests (false, false, 3.12) (push) Has been skipped
test / tests (false, false, 3.13) (push) Has been skipped
test / tests (false, false, 3.13t) (push) Has been skipped
test / tests (false, false, 3.14) (push) Has been skipped
test / docs (push) Failing after 0s
test / tests (false, false, 3.14t) (push) Has been skipped
test / tests (false, false, 3.9) (push) Has been skipped
test / tests (true, pypy3.11) (push) Has been skipped
test / tests (true, 3.14) (push) Has been skipped
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
2026-01-01 09:57:52 +03:00
Sergey B Kirpichev a03719f2fe Drop outdated reference to Sage's Cython-based context 2025-09-03 07:51:28 +03:00
Sergey B Kirpichev 8042d8eb95 Document support for free-threading builds
Closes #975
2025-09-01 05:24:36 +03:00
Sergey B Kirpichev f5b3e07ce4 Drop pypy3.10 from testing matrix (not supported by upstream) 2025-08-06 07:31:42 +03:00
Sergey B Kirpichev 1ad7c87381 Fix "citation not referenced" warnings
Closes #979
2025-08-06 07:15:09 +03:00
Sergey B Kirpichev 657ef46356 Cleanup docs/general.rst (use signatures from autofunction)
Closes #986
2025-08-06 04:30:39 +03:00
Hongren Zheng 9ac078ca7c Add Fox H-function with rational A and B parameters (#982)
Closes #980
2025-07-27 19:03:23 +03:00
Doug Torrance a28bcd5eec Fix citation warning due to typo
WARNING: citation not found: Homeier [ref.ref]
2025-07-19 22:21:17 -04:00
Sergey B Kirpichev 2cad89428e Move references to docs/references.rst
Closes #224
2025-06-18 18:03:46 +03:00
Sergey B Kirpichev 4582b13795 Support rounding property for the mp context 2025-06-01 13:28:51 +03:00
Sergey B Kirpichev 065746d7de Cleanup optimization.rst 2025-05-30 06:05:03 +03:00
Sergey B Kirpichev 8778568951 Avoid using ";" in doctests, esp with side effects
The new CPython repl hide all output, except for the last statement.
See https://github.com/python/cpython/issues/131217.
2025-05-01 10:41:48 +03:00
Sergey B Kirpichev 4edff338a2 Add exp2() and log2()
Closes #947
2025-04-26 19:10:40 +03:00
Sergey B Kirpichev 6c51c9d898 Fix new-style formatting without type specifier (repr_dps vs dps)
Closes #943
2025-04-23 07:04:24 +03:00
Sergey B Kirpichev 33bf8a48f4 Merge pull request #933 from skirpichev/repr_dps
Add pretty_dps context property to control number of printed digits
2025-04-05 06:53:18 +03:00
Sergey B Kirpichev 5294dd9ddd Support spherical Bessel functions (jn/yn)
Naming scheme follows to SciPy.  Closes #319
2025-04-02 07:12:47 +03:00
Sergey B Kirpichev a14901da43 Add pretty_dps context property to control number of printed digits
Closes #921
2025-03-30 09:13:43 +03:00
Sergey B Kirpichev 65247c70df Merge pull request #911 from skirpichev/drop-3.8
Drop support for CPython 3.8
2025-01-30 05:24:54 +03:00
Sergey B Kirpichev 5a52ee2867 Update copyright years 2025-01-30 05:19:47 +03:00
Sergey B Kirpichev 5c719770ae Drop support for CPython 3.8
Closes #910
2025-01-29 10:35:48 +03:00
Sergey B Kirpichev 380f2f30d5 Cleanup docs for functions (using better signatures) 2025-01-22 09:17:21 +03:00