From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Discrete Math not showing Cartesian Product of Lists

Solved!
Go to solution

Hello all,

 

I would like to access "Cartesian Product of Lists.vi" in "NI_Gmath.lvlib", however, it will not show up in the standard LabVIEW palettes.

 

I've had to add the library to my project and navigate to it manually:

NI_Gmath.lvlib>public>discrete math>Cartesian Product of Lists.vi

 

Is there some reason for this? Why does it not show up in the typical discrete math palette? 

0 Kudos
Message 1 of 6
(1,190 Views)
Solution
Accepted by topic author Gryffin

That is kind of annoying that it isn't in palettes, haven't the foggiest why it isn't. There is this dirty workaround to get to it though. Basically get the library into your dependencies somehow (I did by doing what is shown on the right), and navigate to it there.

Spoiler
FireFist-Redhawk_0-1606154324884.png

 

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 2 of 6
(1,179 Views)

Yeah, weird that it doesn't show up in the discrete math palette.

 

In my case, in my project I did:

 

Right Click "My Computer" > Add > Add File

 

Navigated to the NI_Gmath.lvlib, and added the Cartesian Product of Lists.vi manually.

 

Please, NI, add it to the discrete math palette!

0 Kudos
Message 3 of 6
(1,155 Views)

This VI hasn't really been polished up to be in the public palettes (e.g. missing help description etc).

 

Curiously, I made my own long ago and the result is identical. Theirs might be more efficient (only N Q&R operations total) but mine is probably easier to reads and debug. 😄 Not sure if you want to use this on very large input arrays anyway. 😉

 

YMMV...

 

(Of course if you are not interested in any specific output order, you can eliminate my two reverse array operations)

 

altenbach_0-1606161061428.png

 

0 Kudos
Message 4 of 6
(1,139 Views)

Of course my Q&R can be replaced with a simple comparison in this specific scenario. (there are so many ways to do that!)

 

altenbach_0-1606162903181.png

 

0 Kudos
Message 5 of 6
(1,131 Views)

The bad news is that my code was about 10x slower. It seems the autoidexing output tunnel is very expensive compared to preallocate&replace. This surprised me because I would have thought that the compiler can tell the final size before the loop starts and basically generate the same binary code....

 

Here is my tuned version which is competitive with the stock and faster (typically 50-70%, depending on data, only tested in LabVIEW 2020) as soon as the input array has more than about 6-7  elements. I am sure there is more slack left, but I am pretty happy with this one, especially since to code is so much simpler than the stock tool.

 

(Note that the stock VI has debugging enabled, so it could possibly speed up slightly if this is changed. Not tested.)

 

altenbach_0-1606179618117.png

 

 

Look ma, no really high pyramid of FOR loops! 😄

 

 

0 Kudos
Message 6 of 6
(1,114 Views)