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 #33708 is a reply to message #33704] Thu, 16 January 2003 13:30 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Sean Raffuse" <sean@me.wustl.edu> writes:

> Hello.
>
> Here is what I believe will be a pretty simple question.
>
>>> 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]]
>
> assuming my arithmatic is correct.

x = ([1,1,1]##b) * a

A more stylistically correct way to do it would be to REBIN/REFORM the
variable B into the proper dimensions.

Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[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 15:28:39 PDT 2025

Total time taken to generate the page: 0.00399 seconds