mars.tensor.ldexp

mars.tensor.ldexp(x1, x2, out=None, where=None, **kwargs)[source]

Returns x1 * 2**x2, element-wise.

The mantissas x1 and twos exponents x2 are used to construct floating point numbers x1 * 2**x2.

x1 : array_like
Tensor of multipliers.
x2 : array_like, int
Tensor of twos exponents.
out : Tensor, None, or tuple of Tensor and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated tensor is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
where : array_like, optional
Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone.

**kwargs

y : Tensor or scalar
The result of x1 * 2**x2.

frexp : Return (y1, y2) from x = y1 * 2**y2, inverse to ldexp.

Complex dtypes are not supported, they will raise a TypeError.

ldexp is useful as the inverse of frexp, if used by itself it is more clear to simply use the expression x1 * 2**x2.

>>> import mars.tensor as mt
>>> mt.ldexp(5, mt.arange(4)).execute()
array([  5.,  10.,  20.,  40.], dtype=float32)
>>> x = mt.arange(6)
>>> mt.ldexp(*mt.frexp(x)).execute()
array([ 0.,  1.,  2.,  3.,  4.,  5.])