Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K
JAX  documentation - Home

jax.numpy.polydiv

Contents

jax.numpy.polydiv#

jax.numpy.polydiv(u,v,*,trim_leading_zeros=False)[source]#

Returns the quotient and remainder of polynomial division.

JAX implementation ofnumpy.polydiv().

Parameters:
  • u (ArrayLike) – Array of dividend polynomial coefficients.

  • v (ArrayLike) – Array of divisor polynomial coefficients.

  • trim_leading_zeros (bool) – Default isFalse. IfTrue removes the leadingzeros in the return value to match the result of numpy. But prevents thefunction from being able to be used in compiled code. Due to differencesin accumulation of floating point arithmetic errors, the cutoff for valuesto be considered zero may lead to inconsistent results between NumPy andJAX, and even between different JAX backends. The result may lead toinconsistent output shapes whentrim_leading_zeros=True.

Returns:

A tuple of quotient and remainder arrays. The dtype of the output is alwayspromoted to inexact.

Return type:

tuple[Array,Array]

Note

jax.numpy.polydiv() only accepts arrays as input unlikenumpy.polydiv() which accepts scalar inputs as well.

See also

Examples

>>>x1=jnp.array([5,7,9])>>>x2=jnp.array([4,1])>>>np.polydiv(x1,x2)(array([1.25  , 1.4375]), array([7.5625]))>>>jnp.polydiv(x1,x2)(Array([1.25  , 1.4375], dtype=float32), Array([0.    , 0.    , 7.5625], dtype=float32))

Iftrim_leading_zeros=True, the result matches withnp.polydiv’s.

>>>jnp.polydiv(x1,x2,trim_leading_zeros=True)(Array([1.25  , 1.4375], dtype=float32), Array([7.5625], dtype=float32))
Contents

[8]ページ先頭

©2009-2025 Movatter.jp