comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Matrix operations with IDL: Avoiding for loops
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Matrix operations with IDL: Avoiding for loops [message #92487] Tue, 29 December 2015 16:57 Go to previous message
vince33600 is currently offline  vince33600
Messages: 3
Registered: December 2015
Junior Member
Dear all,

I was trying to improve the performance of some pieces of code that are taking forever to run.
Basically, I'm trying to multiply a set of n matrix (3x3) by a set of n vectors (3x1) without using any for loops. The results of these operations should give me a set of n vectors (3x1).

Let's take a simplified example where n=2. Therefore, I have 2 matrixes (let's call them a and b) that needs to be multiplied to 2 vector (let's call them u and v).

I figured out that the operation could be done by reshaping (using rebin and reform for instance) the matrixes into a bigger array (let's call it M) whose diagonal elements are the a and b matrixes, so that:

M = | a 0 |
| 0 b |

where a and b are the 3x3 matrixes, and by reshaping the n vectors into in single vector (called I), so that:

I = | u |
| v |

Then, the results would be:
R = M.I

Finally, the n vectors would be obtained by reshaping the R vector into n (3x1) vector.

Coming for fortran, I initially coded that by decomposing every single matrix multiplication in a for loop. I then tried to apply the above solution, but it seems a real stretch for me to do it without any loops.

I was thinking that someone already might have faced that problem.

Thanks for your help!
Vincent
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: How to fasten formatted printf?
Next Topic: Problem with dist function in IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:54:22 PDT 2025

Total time taken to generate the page: 0.00462 seconds