Re: Setting Negatives to Zero
- To: mathgroup at smc.vnet.net
- Subject: [mg82915] Re: Setting Negatives to Zero
- From: "Kevin J. McCann" <Kevin.McCann at umbc.edu>
- Date: Sat, 3 Nov 2007 03:26:01 -0500 (EST)
- Organization: University System of Maryland
- References: <firstname.lastname@example.org> <200710311118.GAA22617@smc.vnet.net> <email@example.com>
What makes Clip fast?
Carl Woll wrote:
> Ray Koopman wrote:
>> On Oct 30, 1:38 am, "Kevin J. McCann" <Kevin.McC... at umbc.edu> wrote:
>>> I have a very large data set (64000 x 583) in which negative values
>>> indicate "no data", unfortunately these negatives are not all the same.
>>> I would like to efficiently set all these negatives to zero.
>> With 10% of data missing, data*UnitStep[data]
>> is about twice as fast as data/._?Negative->0
>> for real data, and about 30 times as fast for integer data.
> The reason data*UnitStep[data] is slow for real data is because real * 1
> is a real number, while real * 0 is an integer. If UnitStep[data] has a
> mixture of 0s and 1s, then unpacking of packed arrays will occur when
> evaluating data*UnitStep[data]. To avoid this unpacking you could use
> data*N[UnitStep[data]], which will be much faster, although not as fast
> as using Clip.
> Carl Woll
> Wolfram Research
Kevin J. McCann
Research Associate Professor
University of Maryland, Baltimore County
1000 Hilltop Circle
Baltimore, MD 21250
Prev by Date:
The uses of Condition (/;)
Next by Date:
Re: Re: NumberPadding on the left
Previous by thread:
Re: Re: Re: Setting Negatives to Zero
Next by thread:
Re: FindRoot and Bose-Einstein distribution