Oakromulo Posted January 8, 2013 Report Share Posted January 8, 2013 Once LV lacks a primitive for this operation, I've written a quick & dirty VI to do random line permutations. I've tried to generate a random 1D array of I32 indexes, copy the 2D array and then do the line permutations one by one. Unfortunately, my code to generate the random I32 Array inside the VI seems to have an average O(n²) complexity. Do you know if there is a simple way to do O(n) or maybe O(n log(n) ) line permutations instead? Just out of curiosity, the randperm function from MATLAB has recently shifted from polynomial complexity to O(n log(n)), probably they've implemented some variation of the Fisher-Yates shuffle algorithm. randPerm1D.vi randPerm2D.vi evalRandPerm1D.vi Quote Link to comment

Darin Posted January 8, 2013 Report Share Posted January 8, 2013 The easiest way would be to use the Riffle VI in LV, but up until LV12 it is biased since they botched it. I would grab my replacement which is in this thread: http://forums.ni.com/t5/LabVIEW/Riffle-is-Biased/td-p/1921103 You can initialize an array to the correct size (no need to worry about the values, they can all be zero), then Riffle the array and use the index output. Or it is pretty easy to specialize the VI to simply produce the indices without the dummy array. Quote Link to comment

Oakromulo Posted January 8, 2013 Author Report Share Posted January 8, 2013 Thanks again Darin! Fortunately, when it matters to me, I never use code that I can not trace back to the source, so I have always used my own implementations. I really wish my boss could hear it. Quote Link to comment

## Recommended Posts

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.