in reply to Re: PDL, applying function
in thread PDL, applying function

clip is nice. I think first 2 lines can be shorter and more efficient: no need to generate possibly ginormous random array and then index into

$view = $x->whereND($x == 0) $view .= $view->random < .5

Replies are listed 'Best First'.
Re^3: PDL, applying function
by etj (Priest) on May 22, 2022 at 17:32 UTC
    A great option! I'll confess I was a bit tired, so after figuring out something that would broadcast over n-dimensional inputs better than using where, I stopped. Your code is clearly better.