How to transform negative elements to zero without a loop?
I would do this:
a[a < 0] = 0
If you want to keep the original a
and only set the negative elements to zero in a copy, you can copy the array first:
c = a.copy()
c[c < 0] = 0
a = a.clip(min=0)