From: Robert K. <rob...@gm...> - 2006-11-14 04:17:20
|
Tim Hochberg wrote: > Another little tidbit: this is not as general as where, and could > probably be considered a little too clever to be clear, but: > > b = 1 / (a + (a==0.0)) > > is faster than using where in this particular case and sidesteps the > divide by zero issue altogether. A less clever approach that does much the same thing: b = 1.0 / where(a==0, 1.0, a) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |