Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K
JAX  documentation - Home

jax.numpy.copysign

Contents

jax.numpy.copysign#

jax.numpy.copysign(x1,x2,/)[source]#

Copies the sign of each element inx2 to the corresponding element inx1.

JAX implementation ofnumpy.copysign.

Parameters:
  • x1 (ArrayLike) – Input array

  • x2 (ArrayLike) – The array whose elements will be used to determine the sign, must bebroadcast-compatible withx1

Returns:

An array object containing the potentially changed elements ofx1, always promotesto inexact dtype, and has a shape ofjnp.broadcast_shapes(x1.shape,x2.shape)

Return type:

Array

Examples

>>>x1=jnp.array([5,2,0])>>>x2=-1>>>jnp.copysign(x1,x2)Array([-5., -2., -0.], dtype=float32)
>>>x1=jnp.array([6,8,0])>>>x2=2>>>jnp.copysign(x1,x2)Array([6., 8., 0.], dtype=float32)
>>>x1=jnp.array([2,-3])>>>x2=jnp.array([[1],[-4],[5]])>>>jnp.copysign(x1,x2)Array([[ 2.,  3.],       [-2., -3.],       [ 2.,  3.]], dtype=float32)
Contents

[8]ページ先頭

©2009-2025 Movatter.jp