mindspore.ops.ldexp

mindspore.ops.ldexp(x, other)[source]

Multiplies input by \(2^{other}\) .

\[out_{i} = x_{i} * ( 2_{i} ^{other} )\]

Note

Typically this function can create floating point numbers by multiplying mantissas in input with powers of intger 2 from the exponents in other.

Parameters
  • x (Tensor) – The input tensor.

  • other (Tensor) – A tensor of exponents, typically integers.

Returns

Tensor, the output tensor.

Raises
  • TypeError – If x is not a Tensor.

  • TypeError – If other is not a Tensor.

  • ValueError – If the size of tensor x and other are different at non-singleton dimension, and not equal to 1.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor
>>> from mindspore import ops
>>> x = Tensor(np.array([1.]), mindspore.float32)
>>> other = Tensor(np.array([1, 2, 3, 4]), mindspore.int32)
>>> out = ops.ldexp(x, other)
>>> print(out)
[ 2.  4.  8. 16.]