LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Improving this loop

Is there an easy (fast) way of changing the value of elements within a 2-D array?
 
For instance, changing all num=9 to num=88 ?
 
I do have something that works, but I'd like to learn more "trade secrets"  😉
 
However, combining the suggestions in this string improved the sub-vi by a factor of 25-times faster!  Very significant indeed!!
 
Wow!! 
 
RayR
Message 21 of 30
(1,309 Views)
I have nothing to add except to say that this is a mighty educational thread.  Great question and great answers!
LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 22 of 30
(1,300 Views)
Ray,

if your array consists of numeric values, the replacement is very fast. There is (at least afaik) no ready-to-use function. So you got to implement it on your own.
Attached there are two screenshots for one possible solution which should run ok for you (even perharps not the fastest one. I benchmarked this one with 30k lines and 16 columns with under 100 ms.... but will be slower on slower machines. Please note that there should not be any typecasts within the loops, otherwise you will slow it down "accidently".

Norbert
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Download All
0 Kudos
Message 23 of 30
(1,291 Views)
If you need to replace multiple values, follow Norbert's suggestion but wire the value directly to the selector of the case structure. This way you can have multiple cases in one structure. The default case corresponds to Norbet's False case.

Tomi
--
Tomi Maila
Message 24 of 30
(1,281 Views)
Good point, Tomi, just was too narrow minded during answering that post 😉

Norbert
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 25 of 30
(1,268 Views)

Hi Norbert,

Actually, I had already implemented a similar solution..

The elements of the array point to a case structure which populates the "string" array.  It's sufficiently fast.  I was curious if there was another trick that I was not aware of.

EDIT:  Just noticed that Tomi suggested the same <Thanks>

Once I convince them that the string array is no longer required, I will remove it.  😉

Thanks guys for all the help.  The overall progress on the older slower machine is in the magnitude of 100 times!!!  😮  - wow!!!! -

Test time dropped from 79 min to 6 min!!  I'd say that's "pretty good".. 

THANKS!!  🙂

RayR

Message Edited by JoeLabView on 02-16-2007 12:03 PM

Message 26 of 30
(1,252 Views)

Thank you Ray for the entertainment!

This thread reminds of a quote from "The Silicon Valley Guy handbook" that ascribed the following characteristic to SVG's.

"One of my favorite pass times is Gang Applience re-wiring."

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 27 of 30
(1,234 Views)

I'd suspect that the latest numeric substitution ideas would go a bit faster if you passed the array through Shift Registers and used Replace Array Subset to make changes rather than auto-indexing your output arrays.  Guess it depends how smart the LV compiler optimization is.  It'd take a fair bit of smarts for it to recognize the acceptability of reusing the same memory space in the auto-indexed output method.  With shift registers, it has no choice.

-Kevin P.

 

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW?

(Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).



0 Kudos
Message 28 of 30
(1,232 Views)


@Kevin Price wrote:

I'd suspect that the latest numeric substitution ideas would go a bit faster if you passed the array through Shift Registers and used Replace Array Subset to make changes rather than auto-indexing your output arrays.  Guess it depends how smart the LV compiler optimization is.  It'd take a fair bit of smarts for it to recognize the acceptability of reusing the same memory space in the auto-indexed output method.  With shift registers, it has no choice.


Perhaps we need a new loop tunnel type in LabVIEW that would be in-place auto-indexing. This tunnel would be a combination of shift register and auto-indexing tunnel. Like shift-register it would always be visible at both ends of the loop and it would operate in-place. Like auto-indexing tunnel it would auto-index elements from the array. It may not be a great leap for man kind but it would be a small step for LabVIEW performance tuners... 🙂

EDIT: I posted a product suggestion to NI.

Message Edited by Tomi M on 02-16-2007 07:28 PM

--
Tomi Maila
0 Kudos
Message 29 of 30
(1,228 Views)
Try converting the 2D array into a spreadsheet string, then replacing all of the 9's in text with Search and Replace, then convert it back into a 2D array.
0 Kudos
Message 30 of 30
(1,215 Views)