python package implementing a multivariate Horner scheme for efficiently evaluating multivariate polynomials
Project description
multivar_horner is a python package implementing a multivariate Horner scheme (“Horner’s method”, “Horner’s rule”) for efficiently evaluating multivariate polynomials.
Quick Guide:
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:
pip install multivar_horner[numba]
Simple example:
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)
For more refer to the documentation.
Also see: GitHub, PyPI, arXiv paper
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
multivar_horner-3.0.5.tar.gz
(44.8 kB
view hashes)
Built Distribution
Close
Hashes for multivar_horner-3.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 378a4c1f081a9f3d27070987c8df0f4d2e3ed1f16b5a1c9eebafec0d3cb5ae7c |
|
MD5 | d89e2c77f139deb9077ed18257d8bbaa |
|
BLAKE2b-256 | bad8b4e9597b6e57a5a0638817ee5d8ae95d9114f21cb079794c75344bd2a22e |