From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Idea Exchange

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

Allow In Place Array Index/Replace Elements to work "logically" for multi-dimensional Arrays

The In Place Array Index/Replace Elements function not only can save memory by avoiding copying arrays, it can also create "neater" and more transparent Block Diagrams.  For example, here are two ways to triple the third element in an Array of 3 elements:

 

Array Index-Replace 1D.png

I needed to do the same thing, but for a 2D array (three channels of A/D data, I wanted to triple the third channel).  The Help for the In Place Array Index/Replace Subset function suggests this is possible, using language like "element or element(s) of an array", noting the similarity between this In Place Structure and the two Array Functions that form the Input and Output nodes, and in earlier versions of LabVIEW (specifically LabVIEW 2012), explicit reference to rows, columns, and pages as replacement items.  Here's what happens:

Array Index-Replace 2D.png

The Index Array left node forces you to specify both row and column, meaning you cannot operate on a single row (or single column), "breaking" the functionality with the separate Index Array/Replace Subset functions.  This also, I believe, will force an Array Copy operation, something I'm (also) trying to avoid.

 

At its most benign, there is a Documentation "Bug" that should warn users that this In Place function is only designed for single array elements (which, in my opinion, severely limits its usefulness).  I would like to suggest that this function be "fixed" to (a) for multi-dimension Arrays, allow, as with Index Array and Replace Subset, flexible choice of one or more Indices to be specified, with the unspecified Indices implying "All of the Elements", i.e. an entire Row, Column, Page, etc, and (b) maintain the "In Place" functionality by having this function generate the necessary code (behind the scenes) to access the specified elements and do whatever operation is required inside the Structure.

 

I appreciate that requirement (b) might be difficult.  For instance, operating on a row in a 2D array should be easy, as the (row) elements should be continguous, making getting and putting them simple.  However, if a column is specified, getting successive elements and putting them back becomes more complex.  To the User, it all "looks simple" -- you get a 1D wire out, operate on it (say, multiply it by 3), and stick it back "in place", but the LabVIEW compiler has to "get" elements from non-continuous locations and put them back where it got them, but that's what Compilers are for!

 

Bob Schor

4 Comments
GregSands
Active Participant
Bob_Schor
Knight of NI

Greg,

     I'm happy to "yield to your previous post".  I did search for earlier ideas, but failed to find yours.  I've added a comment and Kudo to your post, noting that, at a minimum, the Documentation and Help file for this function should be made explicitly clear, and the analogy to it being a combination of Index Array and Replace Subset should be "relaxed" if they want to make it only "single-element" for multi-dimension arrays.

 

Bob Schor

Darren
Proven Zealot
AristosQueue (NI)
NI Employee (retired)

Bob: I posted a request for that bit of documentation to get evaluated and maybe adjusted. I didn't go read it myself, but it does sound like our phrasing could be better.