LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Replace negative values from 2d array

Solved!
Go to solution

It's about 5 times faster according to my tests on a 100k*100 array of random values (about 50% negatives). How did you test it?

0 Kudos
Message 11 of 19
(1,612 Views)

On a 1e5 x 100 2D array as given in the original problem description, the code shown in the image below seems slightly (120ms vs.130ms, or about 10%) faster than IR&C. (Somewhat surpising since there are extra arrays allocated)

 

 

Mads: If you post benchmarks, please also attach your test program. (Make sure to avoide accidental folding or deadstripping and disable debugging). Thanks!

 

Here is my benchmark (LabVIEW 2010). Most likely exact results will depend on the CPU architecture and other factors, such as the LabVIEW version. 

 

Download All
Message 12 of 19
(1,602 Views)

 

Mads,

 

I have attached captures of the vis used to benchmark..If you have any objections I would be glad to know since you're most definitely more experienced in Labview than myself..

 

Harry

Download All
0 Kudos
Message 13 of 19
(1,588 Views)

Altenbach - the code you have seems 10% slower on my machine, not faster. Here's a benchmark VI.

0 Kudos
Message 14 of 19
(1,585 Views)

 

Maybe the difference between your test and my test was the percentage of negatives... My sample array only had about 2-3% negatives since this is typically what I usually get...

0 Kudos
Message 15 of 19
(1,576 Views)

The percentage of negative values does not seem to have any effect on the timing, nor does the range of the input values.

Message 16 of 19
(1,568 Views)

Interesting results-  don't you ever sleep?Smiley Very Happy

 

I have to admit I thought of using IR&C but thought the math processor might be faster.  Dropping the IR&C inside the looped in-place shows how much time penalty there is for a loop.  Looks like a place to work on the optomizer since the loops really are not necessary. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 17 of 19
(1,551 Views)

It helps to be in another time zone...but with a 3 month old baby at home - No Smiley Wink

 

It was rather late when I posted the first reply though, so I did wonder if I was just too tired and had overlooked something when the solution seemed to be simpler than the ones that had already been suggestedSmiley Happy

0 Kudos
Message 18 of 19
(1,545 Views)

On my older machine, AB's comparison method is significantly slower than IR&C (almost twice as slow).

 

This is comparable to IR&C on my machine:

 

CoerceNegativeValues2.png

 

Max&Min seems to have caught chicken pox.

 

 

Message 19 of 19
(1,526 Views)