LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to quickly transpose 3d array?

Dear all:
I just  run into a strange problem. I have a 3d array, say, 400(page) x 55(rows) x 512(columns), and I would like to transpose it to 55(pages) x 512(rows) x 400(columns). I used the code as attached to this message. The speed is too slow. It takes more than 1.5 minutes in my machine. Can someone modify my code or give me some suggestion how to increase the speed? Thank you very much for your help.
0 Kudos
Message 1 of 8
(8,630 Views)
Hi
 
Do you really have to transpose it? Isn't it possible to just build it in an other way? Or maybe read it differently?
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 2 of 8
(8,624 Views)
Hi ccyang,

your code was unnecesarily slow.
And it was exponential (the more elements, the slower it got) because you resized the array at every for-loop iteration.
On a 40x40x40 array your solution is 6 times slower, at 80x80x80 it is 12.

Here's my solution:


Ton

Message Edited by TonP on 12-06-2006 08:26 AM

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 3 of 8
(8,620 Views)

I was also working on a solution that looks like the one TonP posted. I then had problems with memory. Basically the way that is visible in TonP's picture is correct - rather replace array elements than add new elements (because this causes a rebuild of the array every time).

So if you really have this amount of data, you need enough memory or you should think about other modifications.

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 4 of 8
(8,615 Views)
Yes memory problems are available,

I profiled my solution and i had an overhead of 6!
My 50x50x50 array of dbl (1 MB of memory) used 6 megs....

And I can only see three buffer allocations?
Anyone?
Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 5 of 8
(8,607 Views)
ccyang,

I hope you are doing well! Try the solution provided in the link below. Be sure to let me know if this solution works best in terms of usage and memory.

How can you transpose a 3D array?

Have a great day!
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 6 of 8
(8,572 Views)

Thank you all! I need to do this transpose because of other user's need. TonP gave me some good idea although I can't open the code in v8.2. I am still using v8.0 and no time to upgrade it. I have looked at the discussion mentioned by AdnanZ and got some idea for my posted code but I still got slow speed. I took more than 90 seconds to transpose 500x55x512 array in 3.5GHz machine on WinXP. Very weird, and that's why I post my problem and look for help.

Thank you all again for your suggestions and discussions.

0 Kudos
Message 7 of 8
(8,554 Views)

Ton wrote "Anyone?"

I don't have time (or enough coffee in my head) to takle this challenge now but I believe strategic use of "re-shape array" and "transpose 2-d array" may help (think Rubic's cube).

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 8
(8,534 Views)