LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

swap elements in 2d array

Solved!
Go to solution

Those IPEs are pretty handy for working on data without useing extra buffers - and they are screamming fast!  Note: my fault but, the Shift trminal should be OUTSIDE the loop.  that mod will allow the complier to assign the loop as a parrallel loop to really optimze the code.  Smiley Very Happy

 

Shift can also be turned into an array (remove both IPE's and shift 0 for data you want left alone)  this forces you to iterate for every column and will take longer but would allow you a bit of flexability for moving non sequentiaal columns


"Should be" isn't "Is" -Jay
0 Kudos
Message 11 of 17
(2,942 Views)

How might I allow certain rows in the 2d array swap their values with other rows in the array more frequently than others? I'm thinking I might need an alternative solution. I thought I had one based on this but it was only giving the swap function a chance of working instead of one row swapping with 3 others and another swapping with 2, and so on.

I still need the same number of rows in as out. 

0 Kudos
Message 12 of 17
(2,935 Views)

well lets see what you tried.


"Should be" isn't "Is" -Jay
0 Kudos
Message 13 of 17
(2,923 Views)

Not sure how to just post the picture like you did, so here's the vi.

My attempt seems kind of far off from my goal. 😕 

0 Kudos
Message 14 of 17
(2,916 Views)

I have to attmit that yur requirements are a bit vague.  Like This?  You'll get the hang of array manipulations in time.

1.png

 

And that's not just a picture---- its a vi snippet.  the difference? you can copy it and drag it to a LabVIEW block diagram- it runs.

 

Method: Edit- select all (Ctrl+A) then Edit- Create snippet from selection

To post click the tree icon in this editor browse to where you saved the snippet click insert.


"Should be" isn't "Is" -Jay
0 Kudos
Message 15 of 17
(2,909 Views)

Not entirely, unfortunately. I was trying to be as brief as possible but I'll try to explain in more detail. I'm trying to make the reproduction part of a genetic algorithm where the rows in the 2d array with the highest fitness are able to reproduce more often than those with lower fitness scores (the frequency of which being dependant on the fitness scores). However the array that comes out should be the same dimensions as the one that goes in.

I guess the word "swap" is very misleading.  

0 Kudos
Message 16 of 17
(2,903 Views)

More like this?

 

1.png


"Should be" isn't "Is" -Jay
0 Kudos
Message 17 of 17
(2,899 Views)