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

Home » Public Forums » archive » Re: simple array math question
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: simple array math question [message #33687 is a reply to message #33685] Fri, 17 January 2003 16:51 Go to previous messageGo to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Fri, 17 Jan 2003 16:10:49 -0600, "Sean Raffuse" <sean@me.wustl.edu>
wrote:

>
> "JD Smith" <jdsmith@as.arizona.edu> wrote in message
> news:pan.2003.01.17.21.46.58.749790.29842@as.arizona.edu...
>> On Thu, 16 Jan 2003 20:47:46 -0700, Craig Markwardt wrote:
>>
>>
>>> Heinz Stege <reply_to_posting@arcor.de> writes:
>>>> On Thu, 16 Jan 2003 14:05:27 -0600, "Sean Raffuse" <sean@me.wustl.edu>
>>>> wrote:
>>>>
>>>> >>> a=[[1,2,3],[4,5,6],[7,8,9]]
>>>> >
>>>> >>> b=[1,2,3]
>>>> >
>>>> >What is the best (read, fastest) way to multiply b by each individual
>>>> >row of a? I would like to return a result of:
>>>> >
>>>> >[[1,4,9],[4,10,18],[7,14,27]]
>>>>
>>>>
>>>> result=a*b(*,intarr(3))
>>>
>>> WOW! I've never seen that! It scares me how cool that is. :-)
>>>
>>> Craig
>>
>>
>> I may have to add that to the REBIN/REFORM tutorial. I'll see how fast
>> it is first. It's definitely one of the more readeable ways to add a new
>> trailing dimension. Doesn't work for leading or in-the-middle
>> dimensions, as far as I can tell.
>>
>> JD
>
> Yes, it worked wonders for me. Plenty fast compared to what I was doing
> before. I did have to use it on some leading dimensions and so am using
> transpose(). Not sure if it is the optimal solution, but good enough for my
> needs.
>


Yes, TRANSPOSE is also my favorite for the leading dimension:
result=a*(transpose(b))(intarr(3),*)

may be, you would prefer following syntax:
temp=transpose(b)
result=a*temp(intarr(3),*)

For middle dimensions REFORM does a good job :
c=fltarr(2,3,4)
...
d=fltarr(2,4)
...
result=c*(reform(d,2,1,4))(*,intarr(3),*)

(all tested with PV-Wave)

Heinz
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: MOUSE (WHEEL) BUTTON NON-STOP SCROLLING IN IDL 5.6
Next Topic: Re: Windows XP graphics problem

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

Current Time: Wed Oct 08 17:33:04 PDT 2025

Total time taken to generate the page: 0.00464 seconds