jax.numpy.polyadd#
- jax.numpy.polyadd(a1, a2)[source]#
Returns the sum of the two polynomials.
JAX implementation of
numpy.polyadd()
.- Parameters:
a1 (ArrayLike) – Array of polynomial coefficients.
a2 (ArrayLike) – Array of polynomial coefficients.
- Returns:
An array containing the coefficients of the sum of input polynomials.
- Return type:
Note
jax.numpy.polyadd()
only accepts arrays as input unlikenumpy.polyadd()
which accepts scalar inputs as well.See also
jax.numpy.polysub()
: Computes the difference of two polynomials.jax.numpy.polymul()
: Computes the product of two polynomials.jax.numpy.polydiv()
: Computes the quotient and remainder of polynomial division.
Examples
>>> x1 = jnp.array([2, 3]) >>> x2 = jnp.array([5, 4, 1]) >>> jnp.polyadd(x1, x2) Array([5, 6, 4], dtype=int32)
>>> x3 = jnp.array([[2, 3, 1]]) >>> x4 = jnp.array([[5, 7, 3], ... [8, 2, 6]]) >>> jnp.polyadd(x3, x4) Array([[ 5, 7, 3], [10, 5, 7]], dtype=int32)
>>> x5 = jnp.array([1, 3, 5]) >>> x6 = jnp.array([[5, 7, 9], ... [8, 6, 4]]) >>> jnp.polyadd(x5, x6) Traceback (most recent call last): ... ValueError: Cannot broadcast to shape with fewer dimensions: arr_shape=(2, 3) shape=(2,) >>> x7 = jnp.array([2]) >>> jnp.polyadd(x6, x7) Array([[ 5, 7, 9], [10, 8, 6]], dtype=int32)