square

Contents

square#

class brainunit.math.square(x, **kwargs)#

Compute the square of each element.

When the input carries a unit, the resulting unit is the square of that unit (e.g. meter becomes meter ** 2).

Parameters:

x (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Input data.

Returns:

out – Element-wise x * x, of the same shape and dtype as x. This is a scalar if x is a scalar. If x carries a unit, the result is a Quantity whose unit is x.unit ** 2.

Return type:

saiunit.Quantity | Array

Examples

>>> import saiunit as u
>>> q = u.math.array([2.0, 3.0, 4.0]) * u.meter
>>> u.math.square(q)  # Quantity with unit meter ** 2