pub fn square<T: Tensor<Dtype = f32>>(t: T) -> T
Expand description

t^2

The derivative is 2 * t.

Examples:

let t = tensor([-1.0, 0.0, 1.0, 2.0]);

// use function version
let r = square(t.clone());

// or the tensor method!
let r2 = t.square();