Jump to content

2D Line Permutation / 1D Shuffle


Oakromulo

Recommended Posts

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.

 

w75fc.png

 

 j0a8lw.jpg

randPerm1D.vi

randPerm2D.vi

evalRandPerm1D.vi

Link to comment

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.

Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.