LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Efficiency of Transpose 2D Array

The online documentation of Reshape Array indicates that "This function does not physically move the data in memory, but the memory is re-interpreted according to the reshaped array dimensions." Is Transpose 2D Array similar?

Specifically, I am writing a program which must manipulate large arrays quickly. I need to know if, when I call Transpose 2D Array, a copy is made of the contents of the original array, or does LabVIEW just change the order in which indices are used to extract elements from the original block of memory. That is, does Transpose 2D Array run in constant time, or is the time proportional to the number of elements in the 2D array?

Thanks,
Jason
Jason Rolfe
0 Kudos
Message 1 of 2
(3,675 Views)
I did some quick testing and transpose execution time seems to behave linear with the number of elements (3000x3000 array in about 4.5ms on a 1GHz PIII), so it is pretty fast. (see attached quick benchmark). Of course reshape is independent of array size and many orders of magnitude faster. They don't do the same thing.

I would think that transpose is pretty optimized. Unlike reshape, it needs to swap array elements around to function, but this can be done "in place".

Check your code for buffer allocations to make sure you don't create extra copies of the array if you only need to retain the transposed version.
0 Kudos
Message 2 of 2
(3,675 Views)