LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
MCKman

Search 1D Array Function for array of elements?

Status: Declined

Any idea that has received less than 2 kudos within 2 years after posting will be automatically declined.

It would be cool to have the Search 1D Array Function be capable of accepting an array at the element (to search for) input. The output would be an array of indices corresponding to each array element. Of course I can just put a Search 1D Array Function in a For-Next Loop, but he Search For Elements mode should provide a performance gain since this would be one native function call instead of 1 for each array item called inside the For-Next loop, right? : )

 

I am using LabVIEW 2014 Home And Student version, so sorry if this already exists in newer versions.

8 Comments
crossrulz
Knight of NI

FYI, OpenG already has this capability.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
MCKman
Member

Hi Crossrulz,

Isn't the OpenG version a polymorphic VI with the For-Next code I described built in?

I was looking to get an array item search with the performance of a Native function.

No big deal either way. This is easy to code, I'm just suggesting a performance idea that seems like an easy Native Function improvement.

Thanks Crossrulz!

Mark

AristosQueue (NI)
NI Employee (retired)

> , but he Search For Elements mode should provide a performance gain since this

> would be one native function call instead of 1 for each array item called inside the For-Next loop, right?

 

I cannot see any reason why this would be true. The generated code is going to be pretty much identical in both cases -- I don't see anything that would be simplified if we were doing it all in one node.

X.
Trusted Enthusiast
Trusted Enthusiast

The OpenG function is using variant as inputs, so not strictly polymorphic. Moreover it doesn't really work:

 

Screen Shot 2017-03-13 at 09.13.24.png

 

I suppose you would want a result reading (2,4,6,8). The result is an empty array...

However, the other function called Filter 1D Array, does work. You just don't use its other output (the filtered array). This functions IS polymorphic (as you can see from the absence of coercion dot). Its code does what you are imagining it does (plus the extraneous filtered array construction).

 

 EDIT: and there is an XNode version of those VIs on LAVA (LAVAG)

MCKman
Member

X.,

Converting the data values to variants is a great idea. Much simpler than creating polymorphic VIs for all possible instances. I'll be stashing that method away in my mental coding library for use in similar instances.

Thanks coder X.!

MCKman
Member

I tried some experiments based on AristosQueue's response and he is right. It doesn't make much if any difference.

 

Thank you everyone!

MCKman

AristosQueue (NI)
NI Employee (retired)

Now that LabVIEW 2017 is released, please take a look at the new feature of malleable VIs. I believe it will help you here. A lot. 

Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 2 kudos within 2 years after posting will be automatically declined.