Metadata-Version: 2.1
Name: nutils-poly
Version: 1.0.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Dist: numpy
Summary: Low-level functions for evaluating and manipulating polynomials (Python bindings)
Author: Evalf <info@evalf.com>
Author-email: Evalf <info@evalf.com>
License: MIT
Requires-Python: >=3.7
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: repository, https://github.com/nutils/poly-py

Low-level functions for evaluating and manipulating polynomials.

# Examples

The vector of coefficients for the polynomial `f(x, y) = 3 x y + x^2` is
`[0, 3, 0, 1, 0, 0]`.

With `eval()` we can evaluate this polynomial:

```python
import nutils_poly
import numpy

coeffs = numpy.array([0, 3, 0, 1, 0, 0], dtype=float)
# array of three `x` and `y` pairs (last axis)
values = numpy.array([[1, 0], [1, 1], [2, 3]], dtype=float)
numpy.testing.assert_allclose(nutils_poly.eval(coeffs, values), [1, 4, 22])
```

`PartialDerivPlan::apply()` computes the coefficients for the partial
derivative of a polynomial to one of the variables. The partial derivative
of `f` to `x`, the first variable, is `∂_x f(x, y) = 3 y + 2 x`
(coefficients: `[3, 2, 0]`):

```python
import nutils_poly
import numpy

coeffs = numpy.array([0, 3, 0, 1, 0, 0], dtype=float)
pd = nutils_poly.PartialDerivPlan(
    2, # number of variables
    2, # degree
    0, # variable to compute the partial derivative to
)
numpy.testing.assert_allclose(pd(coeffs), [3, 2, 0])
```

# Further reading

This package is a Python interface for the Rust crate
[`nutils-poly`][crate:nutils-poly] using [PyO3].

This package is part of the [Nutils project].

[crate:nutils-poly]: https://crates.io/crates/nutils-poly
[PyO3]: https://pyo3.rs
[Nutils project]: https://nutils.org

