LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Keeping Unique 1D Size in 2D array

Battler., the In Place Element Structure is essentially a compiler hint.  It is normally used to avoid making data copies when extracting or manipulating data in complex data structures (as in the example given above).  Complex usually means anything with more than one layer of hierarchy (e.g. cluster containing clusters, cluster with arrays, array of clusters, etc.).  Traditional techniques fail in these situations.  However, if you always use the In Place Element Structure for data manipulation, you will not need to worry about traditional techniques, such as the "magic pattern" for clusters.  On the flip side, overuse of the In Place Element Structure can cause LabVIEW to not optimize its code well, since you may put constraints on the code which do not need to be there.  This is rare, but possible.  I use the In Place Element Structure when I need it.  I find out when I need it by using the buffer viewer.  How much time does it save?  That depends on how many data copies you avoid and how big the data being copied is.  Sometimes it is dramatic.  At other times, it amounts to almost nothing.  It is another tool to help you build better LabVIEW programs.

 

Fragger Fox, be careful when using Delete from Array.  It is usually very slow.  In this case, you are better off determining what portion of the 2D array is needed and indexing the exact subset you rather than indexing the whole 1D array and deleting parts of it.  Searching for zeroes is also fraught with danger, since zero is a valid number.  The suggestion above to put the number of array elements in the first element is a good one.  It makes extracting the portion you need painless.  Note that internally, LabVIEW keeps the array size in the array header information.  See the LabVIEW documentation for details if you are interested.

 

Message 11 of 14
(758 Views)

Thanks DFgray.

 

"LabVIEW keeps the array size in the array header information."

 

How can this info be accessed?

0 Kudos
Message 12 of 14
(754 Views)
The easiest way is to use the Array Size primitive.  An obsolete method is to get the type descriptor (e.g. by flattening to a string) and parse that (see LabVIEW help for details).
0 Kudos
Message 13 of 14
(738 Views)

Thanks DFGray.  I didn't realise you work for NI.

 

Can you please take a look at my FG/AE problem:

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=489302#M489302

0 Kudos
Message 14 of 14
(728 Views)