pymc.math.sqr#
- pymc.math.sqr = Elemwise(scalar_op=sqr,inplace_pattern=<frozendict {}>)[source]#
square of a
Computes element-wise square (x²) of a tensor.
- Parameters:
- a
TensorLike
Input tensor
- a
- Returns:
TensorVariable
Output tensor with the square of each element in a
Notes
This is equivalent to a**2 or a*a, but may be computed more efficiently.
Examples
>>> import pytensor >>> import pytensor.tensor as pt >>> x = pt.vector("x") >>> f = pytensor.function([x], pt.sqr(x)) >>> f([-2, 0, 3]) array([4, 0, 9])