Skip to main content

poly_eval

Fast polynomial evaluation powered by Cython and NumPy.

Features

  • Polynomial — real-valued coefficients and exponents
  • StrictPolynomial — exponents constrained to non-negative integers
  • Real evaluation — evaluate_real(inp, mag_only=False)
  • Complex evaluation — evaluate_complex(real, imag, mag_only=False)
  • Real→complex — evaluate_real_to_complex(inp, mag_only=False)
  • Magnitude-only mode — applies exponent to |x| while preserving sign/direction
  • Addition — O(n+m) merge of sorted exponent arrays
  • Multiplication — convolution via dict merge
  • Cython nogil kernels for all evaluation paths

Installation

pip install numpy Cython
python setup.py install

Quickstart

import numpy as np
from pyevalpoly import Polynomial

p = Polynomial([(1.0, 2.0), (2.0, 1.0), (0.5, 0.0)])
# 0.5 + 2x + x²

x = np.array([1.0, 2.0, 3.0])
print(p.evaluate_real(x))
# [3.5  8.5 15.5]

# Magnitude-only (|x|^e * sign(x))
print(p.evaluate_real(x, mag_only=True))

# Complex evaluation
re = np.array([1.0, -1.0])
im = np.array([2.0, -2.0])
out = p.evaluate_complex(re, im)  # shape (2, 2)

# Arithmetic
q = Polynomial([(3.0, 1.0), (1.0, 0.0)])
r = p + q  # terms with matching exponents are summed
s = p * q  # convolution

Classes

Polynomial(terms)          — terms: list of (coeff, exp) or PolyComponent
StrictPolynomial(terms)   — same, but exponents must be non-negative integers
PolyComponent(coeff, exp)  — named tuple for term construction
StrictPolyComponent(...)   — named tuple for strict construction

Evaluation methods

Each method preserves the input shape on the real axis and appends a final dimension of size 2 for complex outputs.

Method Input shape Output shape
evaluate_real(inp) (...,) (...,)
evaluate_complex(re, im) (...,) + (...,) (..., 2)
evaluate_real_to_complex(inp) (...,) (..., 2)

All methods accept the keyword argument mag_only=False. When True, each term c·x^e is evaluated as c·sgn(x)·|x|^e, keeping the direction but applying the exponent only to the magnitude.

License

MIT

Metadata

Release files for pyevalpoly 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyevalpoly 0.1.0
File Size Uploaded Provenance
pyevalpoly-0.1.0.tar.gz 214.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyevalpoly 0.1.0
File Interpreter ABI Platform
pyevalpoly-0.1.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details

Total release size: 528.7 kB

Release files / pyevalpoly-0.1.0.tar.gz

Download URL pyevalpoly-0.1.0.tar.gz
Size 214.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2a3971b7f0d2cc2461cdc9cade9d6fa37c44a836fb05c6004f282f16c521685c
BLAKE2b-256 checksum
How to use checksums
56431026cbee7e083bfe7e66b728bb9d2a991b5e5037cd45fe9dee9988d588f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / pyevalpoly-0.1.0-cp314-cp314-win_amd64.whl

Download URL pyevalpoly-0.1.0-cp314-cp314-win_amd64.whl
Size 314.6 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
aeb85ff5f083729cb20b9e69312622ec553ec3f8804c1e10fdf068f870c48a4e
BLAKE2b-256 checksum
How to use checksums
dd3d75b153c34d84640542ac2c7f8d53d960ce06062d857c19e988dc30856dfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for pyevalpoly 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page