ldexp#

ivy.ldexp(x1, x2, /, *, out=None)[source]#

Return x1 * (2**x2), element-wise.

Parameters:
  • x1 (Union[Array, NativeArray]) – Input array.

  • x2 (Union[Array, NativeArray]) – Input array.

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Array

Returns:

ret – The next representable values of x1 in the direction of x2.

Examples

>>> x1 = ivy.array([1, 2, 3])
>>> x2 = ivy.array([0, 1, 2])
>>> ivy.ldexp(x1, x2)
ivy.array([1, 4, 12])
Array.ldexp(self, x2, /, *, out=None)[source]#

ivy.Array instance method variant of ivy.ldexp. This method simply wraps the function, and so the docstring for ivy.ldexp also applies to this method with minimal changes.

Parameters:
  • self (Array) – Input array.

  • x2 (Array) – The array of exponents.

  • out (Optional[Array], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Array

Returns:

ret – The next representable values of x1 in the direction of x2.

Examples

>>> x = ivy.array([1.0, 2.0, 3.0])
>>> y = ivy.array([3.0, 2.0, 1.0])
>>> x.ldexp(y)
ivy.array([8.0, 8.0, 6.0])
Container.ldexp(self, x2, /, *, out=None)[source]#

ivy.Container instance method variant of ivy.ldexp. This method simply wraps the function, and so the docstring for ivy.ldexp also applies to this method with minimal changes.

Parameters:
  • self (Container) – The container whose arrays should be multiplied by 2**x2.

  • x2 (Union[Array, NativeArray, Container]) – The container whose arrays should be used to multiply x1 by 2**x2.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including x1 * 2**x2.

Examples

With one ivy.Container input: >>> x1 = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([1, 5, 10])) >>> x2 = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([1, 5, 10])) >>> x1.ldexp(x2) {

a: ivy.array([2, 8, 24]), b: ivy.array([2, 160, 10240])

}