One-sided clamp?


Suppose I have an array of different values, Result.

Usually one would write; clamp!(Result,LowerLimit,HigherLimit). Is there a way to make it “one-sided” such that I only specify a lower limit?

Kind regards

There’s an example in the docs:

julia> clamp.((-4:4)', 0, Inf)
 1×9 Matrix{Float64}:
   0.0  0.0  0.0  0.0  0.0  1.0  2.0  3.0  4.0
1 Like

Thanks! Had not realized it was this simple :slight_smile: I was trying “nothing” instead of Inf

Kind regards

1 Like

The right way to do this is not to use clamp, but max:

max.((-4:4)', 0)