LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ragged edge arrays in LabVIEW?

Hi all,
I'd like to implement a ragged edge array in LabVIEW (that is, an array of arrays, each of different length). LabVIEW only supports symmetric arrays (rectangular) in their standard array types. While I could implement this as an array of clusters, with each cluster having a single array, I was hoping there was a slightly less clunky method of doing this...anyone have any ideas?

Thanks!
0 Kudos
Message 1 of 10
(2,947 Views)
Hello,

It is not possible to have an array of arrays in LabVIEW...the best method I can think of is the one you have already proposed...an array of clusters of arrays...I can't imagine this implementation would be too terribly difficult to manipulate.

We'll see if anybody else has any suggestions.

Darren
0 Kudos
Message 2 of 10
(2,947 Views)
Underflow wrote:
>
> Hi all,
> I'd like to implement a ragged edge array in LabVIEW (that is, an
> array of arrays, each of different length). LabVIEW only supports
> symmetric arrays (rectangular) in their standard array types. While I
> could implement this as an array of clusters, with each cluster having
> a single array, I was hoping there was a slightly less clunky method
> of doing this...anyone have any ideas?

Try a cluster of arrays, each of which can have a different length.

Less elegant, but should get you going.

Mark
0 Kudos
Message 3 of 10
(2,947 Views)
Unfortunately, the top level array size is not known in advance, so a cluster won't work...
0 Kudos
Message 4 of 10
(2,947 Views)
Another posibility is to use flags in your data, if it is well known. For example, let say you arrange your data in columns. If all your data is positive, then the end of the data array can be marked with a negative number:

2 3 3 2 4
4 5 -1 4 7
3 2 0 3 2
-1 5 0 0 -1
0 6 0 -1 0
0 -1 0 0 0

Here the "-1" indicates where the data in the column ends.

A variation can be that the first element in the columns indicates how many valid elements are in the column.

Obviously, these approaches may need more coding, but can work.

-Enrique
www.vartortech.com
0 Kudos
Message 5 of 10
(2,947 Views)
An excellent idea! Thanks!
0 Kudos
Message 6 of 10
(2,947 Views)
Hi,
another solution is to use NaNs at the end of each array. It will not decrease the memory usage but in any case the work with such 2D array will be faster then with array of clusters.
The more complicated structure of your data (array of clusters of arrays with different sizes) the slower your program.

Good luck.

Oleg Chutko.
0 Kudos
Message 7 of 10
(2,947 Views)
Indeed, I'm attempting to minimize the memory and processing required to run this little program. Thanks for the advice!
0 Kudos
Message 8 of 10
(2,947 Views)
By the way the use of NaNs is more convenient then the use of some marks like negative numbers. Every operation with NaN will give you the NaN as a result so you don't need to take care about interpretation of marks after some operations.

Oleg Chutko.
0 Kudos
Message 10 of 10
(2,947 Views)
> I'd like to implement a ragged edge array in LabVIEW (that is, an
> array of arrays, each of different length). LabVIEW only supports
> symmetric arrays (rectangular) in their standard array types. While I
> could implement this as an array of clusters, with each cluster having
> a single array, I was hoping there was a slightly less clunky method
> of doing this...anyone have any ideas?
>


All the times I've wanted to do this, I've used an array of cluster
of array of ???. It didn't seem clunky to me. Multidimensional
arrays will always square off. Direct arrays of arrays are not
allowed, and clusters the typical way of isolating them from one
another.

Greg McKaskle
0 Kudos
Message 9 of 10
(2,947 Views)