05-07-2009 12:08 PM
I have a large 2by2 array, and I do a lot shifting such as deleting the top row and appending data the lowest row. The size of the array never changes, but I manipulate the data quite a bit.
My question is: How does Labview handle this manipulation? Is it smart enough just to manipulate pointers instead of copying values over and over again?
I'm looking at the interface with dll, and it seem that Labview for a 2by2 arry just have a pointer to all the number such that the number is just spread accross one block of memory. Is that all Labview does with any size array? Just store in a large chunk?
Thank you!
Solved! Go to Solution.
05-07-2009 12:30 PM
I'm kind of confused. You say it is a large 2x2 array. All 2x2 arrays are the same size, 2 by 2. So I'm not really sure what you are asking.
05-07-2009 12:35 PM
Hehe, I think he means 2D array.
MattBradley wrote:I'm kind of confused. You say it is a large 2x2 array. All 2x2 arrays are the same size, 2 by 2. So I'm not really sure what you are asking.
05-07-2009 12:36 PM
d1sturbanc3 wrote:I have a large 2by2 array, and I do a lot shifting such as deleting the top row and appending data the lowest row. The size of the array never changes, but I manipulate the data quite a bit.
My question is: How does Labview handle this manipulation? Is it smart enough just to manipulate pointers instead of copying values over and over again?
I'm looking at the interface with dll, and it seem that Labview for a 2by2 arry just have a pointer to all the number such that the number is just spread accross one block of memory. Is that all Labview does with any size array? Just store in a large chunk?
Thank you!
Yes to the one large chunk, "depends" to the rest of your questions.
THe "inplace" memory operators will let you work within a single buffer. Some of the normal array operators will do similarly (replace array sub-set for example). Build array, no.
Try using "Tools >>> Profile >>> Show Buffer Allocations...
To see where you have additional buffers in your code.
BTW: The process of using "Show Buffer..." and then re-writing to eliminate same is sometimes called "Chase the dots".
Have fun!
Ben
05-07-2009 12:39 PM - edited 05-07-2009 12:42 PM
Just some food for thought:
If your array is always going to be the same size,
and is going to act in a FIFO (first in, first out) manner,
you could use a 'queue'.
You can initially set the queue to whatever size you want, since you said it will not change.
Then you can remove elements from the front, and append elements to the end accordingly.
Specifically, look at the 'Lossy Enqueue Element' function.
Say you have a queue that has 10 elements:
As you are filling up the empty queue, all elements are added in order.
Once the 11th element is added, the 1st element is removed, and the 11th is added at the end.
This way, you are guarenteed that the memory allocated is exactly what you are expecting.
05-07-2009 12:40 PM
05-07-2009 12:46 PM
05-07-2009 12:53 PM
d1sturbanc3 wrote:
Yea I tried, but I need to able to get all the items in the queue without flushing it, and Labview doesn't offer that.
All of the queue functions operate on either the beginning or end of the queue, which would enable the exact functionality of a FIFO queue.
d1sturbanc3 wrote:
Plus the queue they offer is not a FIFO queue.
05-07-2009 12:54 PM - edited 05-07-2009 01:00 PM
In what way do you feel the LabVIEW queue implementation is not FIFO?
Also, there is a way to retrieve all the elements in a queue - use the Get Queue Status function and set the "return elements?" input to true.
Maintaining an index into the array to track the current location is pretty simple and very efficient in terms of memory and speed.
EDIT: there's an example here of using an array as a circular buffer, maintaining an index to the current position in the array.