Return the element-wise square value of the index expression.

This must be assigned to a tensor for the computation to be performed.

e1: index_expression

Input index expression

sq_exp: index_expression

An index expression representing the element wise square of the input expression.


>>> import pytaco as pt
>>> t = pt.as_tensor([-2, 2, 1])
>>> i = pt.index_var()
>>> sq_expr = pt.square(t[i])

We can then assign this description to a tensor to actually perform the computation.

The code below tells taco to compute the square of each value, sum over all those values and store it in the tensor res_t. Since i appears on the right hand side of the expression but not on the left, taco will take the sum of the values produced.

>>> res_t = pt.tensor()
>>> res_t[None] = sq_expr
>>> res_t.to_array()
array(9., dtype=float32)