ldexp

Contents

ldexp#

class brainunit.math.ldexp(x, y, unit_to_scale=None, **kwargs)#

Returns x * 2**y, element-wise.

The mantissas x and twos exponents y are used to construct floating point numbers x * 2**y.

Parameters:
  • x (Union[saiunit.Quantity, Array, ndarray, number, bool]) – Array of multipliers. May carry any unit; the result keeps it, since x * 2**y only rescales the magnitude.

  • y (Union[saiunit.Quantity, Array, ndarray, number, bool]) – Array of twos exponents. Must be dimensionless with integral values. If x.shape != y.shape, they must be broadcastable to a common shape (which becomes the shape of the output).

  • unit_to_scale (Optional[saiunit.Unit]) – Unit used to convert x (not y) to a dimensionless number first (kept for backwards compatibility; the result is then a plain array).

Returns:

out – The result of x * 2**y, carrying x’s unit when x is a Quantity and unit_to_scale is not given. This is a scalar if both x and y are scalars.

Return type:

Array