Following on from a discussion of the most efficient way to shift a 2-D array (equivalent to the rotate 1-D array native LV function), I created the attached VI, which shifts the array left, right, up or down by a specified number of indices.
My question is, what is the best strategy for generalizing this function? Should I make a polymorphic or a variant-based version of the VI? The variant may be the easiest to code, but would it be slower? Before going down the polymorphic path (to possibly no real benefit to me, though maybe fun!), I thought I'd ask for an expert opinion.
Well, this is getting no traction, but I'll go ahead an post an imprved version that is about 30% faster for up and down shifts.
This function, incidentally, is the 2-D equivalent of the rotate 1-D array primitive. The attempts here are to make a 2-D version that minimized memory usage (copies of the array) and should work quickly for fairly large arrays. I already have a function for rotate (and flip) of 2-D arrays, so I shose to call this "shift" to avoid confutiong myself. Maybe there's a better way to describe this operation.
My way to see this is that variants are an option if you need to pass values between programs from different environments not sharing the same data types as they basically translate the information by sinding both metadata and value. If this is your idea for the end use of your VI, I would say go variant.
If not, I really don't see a reason not to go for a polymorphic VI. My guess is that turning the array into a variant on the entrance and back to array at the exit , should be slower than just leting the array of doubles stay as an array of doubles. I did not really do any benchmarking so this is just what "common sense" makes me think.
I would say polymorphic.