Returns the coefficients of a polynomial for the given sequence of roots.
JAX implementation of numpy.poly()
.
seq_of_zeros (ArrayLike) – A scalar or an array of roots of the polynomial of shape (M,)
or (M, M)
.
An array containing the coefficients of the polynomial. The dtype of the output is always promoted to inexact.
Note
jax.numpy.poly()
differs from numpy.poly()
:
When the input is a scalar, np.poly
raises a TypeError
, whereas jnp.poly
treats scalars the same as length-1 arrays.
For complex-valued or square-shaped inputs, jnp.poly
always returns complex coefficients, whereas np.poly
may return real or complex depending on their values.
Examples
Scalar inputs:
>>> jnp.poly(1) Array([ 1., -1.], dtype=float32)
Input array with integer values:
>>> x = jnp.array([1, 2, 3]) >>> jnp.poly(x) Array([ 1., -6., 11., -6.], dtype=float32)
Input array with complex conjugates:
>>> x = jnp.array([2, 1+2j, 1-2j]) >>> jnp.poly(x) Array([ 1.+0.j, -4.+0.j, 9.+0.j, -10.+0.j], dtype=complex64)
Input array as square matrix with real valued inputs:
>>> x = jnp.array([[2, 1, 5], ... [3, 4, 7], ... [1, 3, 5]]) >>> jnp.round(jnp.poly(x)) Array([ 1.+0.j, -11.-0.j, 9.+0.j, -15.+0.j], dtype=complex64)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3