pub fn clamp<T: Tensor<Dtype = f32>>(t: T, min: T::Dtype, max: T::Dtype) -> T
Expand description

Clamp all elements between the provided min and max values.

Example:

let t = Tensor1D::new([-1.0, -0.5, 0.0, 0.5, 1.0]);
let r = t.clamp(-0.5, 0.5);
assert_eq!(r.data(), &[-0.5, -0.5, 0.0, 0.5, 0.5]);