MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Setting Negatives to Zero

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82821] Re: Setting Negatives to Zero
  • From: "Kevin J. McCann" <Kevin.McCann at umbc.edu>
  • Date: Wed, 31 Oct 2007 06:24:32 -0500 (EST)
  • Organization: University System of Maryland
  • References: <fg6qha$dj0$1@smc.vnet.net> <fg7287$jv9$1@smc.vnet.net>

Thanks Steve,

I knew I would feel stupid when I say the answer.

Unfortunately, though, when this is applied to my 63465 x 583 matrix it 
takes over 69sec to execute. That other language can do it in less than 
1 second! The difference must be that this technique is a pattern 
matching? Not sure.

As an aside, I did a timing test on reading the data in in the first 
place. Timing[] reports 2.7s (approx), but my watch says 20s. Not sure 
what the difference is due to.

Thanks again,

Kevin

Steve Luttrell wrote:
> These do the sort of thing you want
> 
> {1, 2, -3, -4, 5, 6} /. {_?(# < 0 &) -> 0}
> 
> {1, 2, -3, -4, 5, 6} /. {_?NonPositive -> 0}
> 
> and both give
> 
> 

-- 

Kevin J. McCann
Research Associate Professor
JCET/Physics
Physics Building
University of Maryland, Baltimore County
1000 Hilltop Circle
Baltimore, MD 21250


  • Prev by Date: Re: library.wolfram submissions
  • Next by Date: Simplifying polynomial and rounding problems
  • Previous by thread: Re: Setting Negatives to Zero
  • Next by thread: Re: Setting Negatives to Zero