Metadata-Version: 2.4
Name: multivar_horner
Version: 3.2.1
Summary: python package implementing a multivariate Horner scheme for efficiently evaluating multivariate polynomials
License: MIT
License-File: LICENSE
Keywords: mathematics,polynomials,evaluation,multivariate,horner-scheme
Author: jannikmi
Author-email: github@michelfe.it
Requires-Python: >=3.12,<4
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Physics
Provides-Extra: numba
Requires-Dist: numba (>=0.64,<1) ; extra == "numba"
Requires-Dist: numpy (>=2.2,<2.5)
Project-URL: Documentation, https://multivar-horner.readthedocs.io/en/latest/
Project-URL: Homepage, https://multivar-horner.readthedocs.io/en/latest/
Project-URL: Repository, https://github.com/jannikmi/multivar_horner
Description-Content-Type: text/x-rst

===============
multivar_horner
===============

.. image:: https://github.com/jannikmi/multivar_horner/actions/workflows/build.yml/badge.svg?branch=master
    :target: https://github.com/jannikmi/multivar_horner/actions?query=branch%3Amaster
    :alt: Build status

.. image:: https://readthedocs.org/projects/multivar_horner/badge/?version=latest
    :alt: documentation status
    :target: https://multivar_horner.readthedocs.io/en/latest/?badge=latest

.. image:: https://img.shields.io/pypi/wheel/multivar-horner.svg
    :target: https://pypi.python.org/pypi/multivar-horner

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
   :target: https://github.com/pre-commit/pre-commit
   :alt: pre-commit

.. image:: https://pepy.tech/badge/multivar-horner
    :alt: Total PyPI downloads
    :target: https://pepy.tech/project/multivar-horner

.. image:: https://img.shields.io/pypi/v/multivar_horner.svg
    :alt: latest version on PyPI
    :target: https://pypi.python.org/pypi/multivar-horner

.. image:: https://joss.theoj.org/papers/0b514c6894780f3cc81ed88c141631d4/status.svg
    :alt: JOSS status
    :target: https://joss.theoj.org/papers/0b514c6894780f3cc81ed88c141631d4

.. image:: https://zenodo.org/badge/155578190.svg
   :target: https://zenodo.org/badge/latestdoi/155578190

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black


``multivar_horner`` is a python package implementing a multivariate
`Horner scheme ("Horner's method", "Horner's rule") <https://en.wikipedia.org/wiki/Horner%27s_method>`__
for efficiently evaluating multivariate polynomials.


Supported environments
----------------------

The 3.2 series requires Python >=3.12,<4 without restricting future Python 3 minor releases,
and NumPy >=2.2,<2.5, subject to its own Python requirements.
The Python and NumPy minimums follow the three-year and two-year support
windows, respectively, recommended by
`SPEC 0 <https://scientific-python.org/specs/spec-0000/>`__.
CI covers NumPy 2.x on Python 3.12–3.14, both with and without the optional Numba
extra (Numba >=0.64,<1). Python 3.8–3.11 users should retain the 3.1 series.

Real evaluation uses a C compiler (``gcc`` or ``cc``) by default. Install
``multivar_horner[numba]`` for accelerated recipe evaluation when a compiler
is unavailable. Complex evaluation always uses the recipe backend.
Compiled evaluator caches are platform-specific, so the same installation can
be used safely on ARM64 and x86_64 systems without reusing incompatible binaries.


Quick Guide:

.. code-block:: console

    pip install multivar_horner


For efficiency this package is compiling the instructions required for polynomial evaluation to C by default.
If you don't have a C compiler (``gcc`` or ``cc``) installed you also need to install numba for using an alternative method:

.. code-block:: console

    pip install multivar_horner[numba]


Simple example:

.. code-block:: python

    import numpy as np
    from multivar_horner import HornerMultivarPolynomial

    # input parameters defining the polynomial
    #   p(x) = 5.0 + 1.0 x_1^3 x_2^1 + 2.0 x_1^2 x_3^1 + 3.0 x_1^1 x_2^1 x_3^1
    coefficients = np.array([[5.0], [1.0], [2.0], [3.0]], dtype=np.float64)
    exponents = np.array([[0, 0, 0], [3, 1, 0], [2, 0, 1], [1, 1, 1]], dtype=np.uint32)

    # [#ops=7] p(x) = x_1 (x_1 (x_1 (1.0 x_2) + 2.0 x_3) + 3.0 x_2 x_3) + 5.0
    horner_polynomial = HornerMultivarPolynomial(coefficients, exponents)
    x = np.array([-2.0, 3.0, 1.0], dtype=np.float64)
    p_x = horner_polynomial(x)



Also see:

- `Documentation <https://multivar-horner.readthedocs.io/en/latest/>`__
- `GitHub <https://github.com/jannikmi/multivar_horner>`__
- `PyPI <https://pypi.python.org/pypi/multivar_horner/>`__
- `paper (JOSS) <https://joss.theoj.org/papers/10.21105/joss.02392>`__
- `paper (arXiv) <https://arxiv.org/abs/2007.13152>`__

