07-09-2010 07:03 AM
![]()
@GerdW wrote:
How should an IndexArray help here? Geeta wants to convert an array of clusters to a cluster of arrays containing all values...
I was fooled by the text "i want to get an array of clusters to a single cluster" which sounds like Op wanted a single cluster. OP's solution works but is unecessary, autoindexing should solve it!
07-09-2010 07:28 AM
Your current solution is extremely slow because it reallocates an array for every element in the cluster at every iteration of the FOR loop. This also highly fragments your program memory. It would not surprise me if you ran out of memory. You can probably get somewhere between one and three orders of magnitude speed improvement by using the following algorithm:
07-09-2010 08:45 AM
In my solution above Autoindexing knows how big the arrays will be and preallocate. 😉
/Y
07-09-2010 08:51 AM
07-09-2010 09:33 AM
@GerdW wrote:
Hi Yamaeda,
preallocation might become tricky when unbundling arrays! Each single cluster might contain a different sized array...
Can you explain how Yamaeda's code would result in cluster with different size arrays? The loop executes a certain number of times. All of the output arrays have to be of equal size.
07-09-2010 09:41 AM
@tbob wrote:
@GerdW wrote:
Hi Yamaeda,
preallocation might become tricky when unbundling arrays! Each single cluster might contain a different sized array...
Can you explain how Yamaeda's code would result in cluster with different size arrays? The loop executes a certain number of times. All of the output arrays have to be of equal size.
I had to look at that post twice myself. I suspect Gerd has a Sea-Story G-Story to go with that note.
Ben
07-10-2010 05:00 AM - edited 07-10-2010 05:03 AM
Hi,
my thoughts on pre-allocation were these:
It's not a concern of having different sized arrays after the conversion. It's the concern of having different sized arrays before conversion:
The OP has an array of clusters of arrays. The arrays in each cluster may have a different length.
When using an autoindexing FOR loop I doubt LabVIEW is able to preallocate the memory needed to store the array elements in the final 2D array. First LabVIEW would have to scan all the clusters for the biggest array elements to get the final size after autoindexing... As said: I doubt LabVIEW will do this.
Is there someone with deeper insights?
07-10-2010 10:54 AM
Well autoindexing arrays will add 1 dimension, so that part is quite easy, optimally the compiler, as you said, should scan for the longest array to preallocate a 2d array of finished size.
In this case, my previous example works, but it seems OP wants a 1D array in each cluster, which ofc. can be solved with a Array Sizes -> Multiply array elements -> Reshape array.
It seems like a mess in general though needing to switch between these two, so i'm voting to bite the bullet and correct the program and make it all use 1 version.
/Y
07-12-2010 10:51 AM
@GerdW wrote:
Hi,
The OP has an array of clusters of arrays.
Look at the OP's first posted picture, in particular, the cluster in the array on the front panel. I see a Boolean, a Numeric, and a String. I don't see any arrays.
07-12-2010 11:03 AM
Oooops. Disregard the pevious post. I was looking at the first post on this page without realizing it was the second page, not the first. The OP does have a cluster of arrays. Looks like a bad start for a Monday for me.