warp icon indicating copy to clipboard operation
warp copied to clipboard

FeatureRequest: wp.clamp that works on vectors

Open jc211 opened this issue 2 years ago • 2 comments

Currently wp.clamp is only defined on scalars, would be good to have one on vectors too.

jc211 avatar Jul 18 '23 01:07 jc211

Thanks for the feature request. This sounds reasonable at first glance, but I'm a bit concerned about feature creep and bloat. There are additional types that could potentially have their own clamp function, and it's difficult to determine where to draw the line. Each of them should ideally be continuously tested, it causes maintenance overhead, and JIT-compile time would be negatively affected.

Is it reasonable to just define your own @wp.func functions that perform vector clamping using wp.clamp(), instead? Note this is also the expectation when writing CUDA code, although helper header libraries exist.

c0d1f1ed avatar Jul 24 '23 19:07 c0d1f1ed

Thank you for considering the request. I think not including it to avoid feature creep is fair enough. Writing the function is simple enough that it doesn't need to be included I suppose.

jc211 avatar Jul 24 '23 21:07 jc211