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

Home » Public Forums » archive » Array multiplication: implicit loop query
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Array Multiplication [message #79657 is a reply to message #26191] Sun, 25 March 2012 12:58 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Sunday, March 25, 2012 5:22:00 AM UTC-4, IDL beginner wrote:
> Dear All,
>
> I have the following question. Let's say we have a vector A and matrix
> array B so that:
>
> A = [1, 2, 5, 2, 3]
>
> B = [[2, 4], [1, 9]]
>
> I want to multiply each element of the vector A with the matrix array
> B but WITHOUT using a FOR loop. Is that possible??? I need to do so in
> order to save execution time.
>
> The output result should be an array C with dimensions C[2, 2, 5, 1].

C = intarr(2,2,5,1)
C[0,0,*,*] = B[0,0]*A
C[0,1,*,*] = B[0,1]*A
C[1,0,*,*] = B[1,0]*A
C[1,1,*,*] = B[1,1]*A

Since there are only four elements, there are no FOR loops needed.

I suppose that you are trying to frame a more generic problem. My recommendation is at first, don't worry about whether you are using FOR loops or not. Make each iteration of the loop do as much work as possible, and you should be fine.

Craig
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Coyote Library Updates
Next Topic: Ask Mr. Cosmology

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

Current Time: Fri Oct 10 04:26:28 PDT 2025

Total time taken to generate the page: 0.07785 seconds