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

Home » Public Forums » archive » How multiply two arrays in IDL?
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: How multiply two arrays in IDL? [message #90867 is a reply to message #90865] Thu, 30 April 2015 08:39 Go to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
On Thursday, 30 April 2015 06:47:26 UTC-7, Madhavan Bomidi wrote:
> Hello,
>
> I have two arrays as below:
>
> a = [1, 2, 3, 4, 5, 6]
> b = [[3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20]]
>
> When I multiply a and b, I get the following
>
> a * b = [3, 8, 15, 24, 35, 48]
>
> instead of the following result
>
> [[3, 8, 15, 24, 35, 48], [9, 20, 33, 48, 65, 84], [15, 32, 51, 72, 95, 120]]
>
> Can anyone suggest me how I can obtain the result as desired?
>
> Thanks in advance,
> Madhavan

It looks like you want to extend a to match the rows of b, then multiply corresponding elements, like this:

IDL> Rebin(a, [6, 3]) * b
3 8 15 24 35 48
9 20 33 48 65 84
15 32 51 72 95 120

... or generally:
IDL> Rebin(a, Size(b, /DIMENSIONS)) * b
3 8 15 24 35 48
9 20 33 48 65 84
15 32 51 72 95 120

Hope this helps!

-Dick

Dick Jackson Software Consulting Inc.
Victoria, BC, Canada --- http://www.d-jackson.com
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Create folder below certain file
Next Topic: Copying contents of a function graphics window

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

Current Time: Wed Oct 08 11:45:49 PDT 2025

Total time taken to generate the page: 0.00545 seconds