Our online shopping is experiencing intermittent service disruptions.
Support teams are actively working on the resolution.
Our online shopping is experiencing intermittent service disruptions.
Support teams are actively working on the resolution.
07-12-2007 05:46 PM
07-12-2007 08:13 PM
07-12-2007 10:06 PM
Yes, if the size does not change, reshaping an array does not need to move the data in memory, so it should be very efficient.
In LabVIEW 8.0 and earlier, the help actually mentioned that "This function does not physically move the data in memory, but the memory is re-interpreted according to the reshaped array dimensions.". This sentence has been removed from the online help in 8.20. The problem might be that it can also be used to pad and truncate arrays, in which case an allocation might be needed.
So, Yes, in the most ideal case, the function should not need a new buffer allocation. I haven't studied if it is possible to achieve that.
@Yuri33 wrote:
Is it simply faster to use nested loops and do operations one element at a time?
Remember that you can also do a hybrid approach where you would eliminate the innermost nested loop and operate on a 1D array for each iteration.
In general, don't trust your instincts if performance is very critical. Wire up a few alternatives and benchmark them to be sure. 😉
07-13-2007 01:09 AM - edited 07-13-2007 01:09 AM
Message Edited by Yuri33 on 07-13-2007 01:11 AM
07-13-2007 03:34 AM
07-13-2007 09:56 AM - edited 07-13-2007 09:56 AM
@Yuri33 wrote:
I'm referring specifically to this discussion.
Sorry, I haven't seen that thread yet, but just quickly glancing at it, there are a few things that stick out:
The Stock "2D Cartesian Coordinate rotate" is really optimized to rotate arrays of x and with with a single angle. Now we don't even need a loop and it is quite fast (If you disable debugging and set it ti subroutine, it is even faster, but I would not recommend that).
Of course, if we are dealing with 2D rotations and transformations, using complex numbers comes immediately to mind. We would represent our two arrays (x and y) as a single complex number array.
A primitive, more explicit rotation attempt is shown (cmplx1 graph), but if we think about it a bit harder, rotation is a single complex multiplication that can be very fast (cmplx2 graph).
All three algoritms shown (2D rotate, cmplx1, complx2) produce the same result.
If we don't count the conversion time to complex (and we shouldn't need to if the program handles everything else natively in complex! :)), the last method (multiplication) seems very competitive to everything discussed in the thread mentioned above. (after some very casual testing).
So, overall we should always remember to think slightly out of the box and look for creative solutions. They're out there!
Back to the reshape issue. What kind of operations are you trying to do on your multidimensional arrays?
Message Edited by altenbach on 07-13-2007 07:58 AM
07-13-2007 07:52 PM