Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K
JAX  documentation - Home

jax.numpy.signbit

Contents

jax.numpy.signbit#

jax.numpy.signbit(x,/)[source]#

Return the sign bit of array elements.

JAX implementation ofnumpy.signbit.

Parameters:

x (ArrayLike) – input array. Complex values are not supported.

Returns:

A boolean array of the same shape asx, containingTruewhere the sign ofx is negative, andFalse otherwise.

Return type:

Array

See also

  • jax.numpy.sign(): return the mathematical sign of array elements,i.e.-1,0, or+1.

Examples

signbit() on boolean values is alwaysFalse:

>>>x=jnp.array([True,False])>>>jnp.signbit(x)Array([False, False], dtype=bool)

signbit() on integer values is equivalent tox<0:

>>>x=jnp.array([-2,-1,0,1,2])>>>jnp.signbit(x)Array([ True,  True, False, False, False], dtype=bool)

signbit() on floating point values returns the value of the actualsign bit from the float representation, including signed zero:

>>>x=jnp.array([-1.5,-0.0,0.0,1.5])>>>jnp.signbit(x)Array([ True, True, False, False], dtype=bool)

This also returns the sign bit for special values such as signed NaNand signed infinity:

>>>x=jnp.array([jnp.nan,-jnp.nan,jnp.inf,-jnp.inf])>>>jnp.signbit(x)Array([False,  True, False,  True], dtype=bool)
Contents

[8]ページ先頭

©2009-2025 Movatter.jp