volk icon indicating copy to clipboard operation
volk copied to clipboard

clamp function call

Open Ka-zam opened this issue 3 years ago • 2 comments

I quite often find myself wanting to clamp a vector to specific values, i.e:

for all x:
   if x > max_val
      x = max_val
   else if x < min_val
      x = min_val
   end
end

Would this be worthwhile to implement?

Ka-zam avatar Jun 07 '21 14:06 Ka-zam

Generally, I'd say all kernels are a welcome addition. There are some type conversion kernels that already implement this function for specific values. You're welcome to open a PR for such a kernel.

jdemel avatar Jun 07 '21 14:06 jdemel

I second this. Some function like this on f32 would be a very welcome addition.

Aang23 avatar Aug 01 '22 12:08 Aang23

See PR that implements this.

Ka-zam avatar Sep 25 '23 13:09 Ka-zam