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

Home » Public Forums » archive » Re: vector matrix multipication
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: vector matrix multipication [message #43413] Mon, 11 April 2005 08:28
Benjamin Luethi is currently offline  Benjamin Luethi
Messages: 22
Registered: December 2004
Junior Member
you could write out the matrix multiplication:

result = [ G[0,0,*]*V[0]+G[1,0,*]*V[1], G[0,1,*]*V[0]+G[1,1,*]*V[1] ]

but this looks pretty ugly and I don't know if it's an improvement...

Ben

On 11 Apr 2005 07:00:20 -0700, pete <schuck@ppdmail.nrl.navy.mil> wrote:

> Is there any way to do vector matrix operations in IDL?
>
> For example I have an array of N 2x2 matrics: G[0:1,0:1,N] and
> a vector V[0:1]. I wouled like G[0:1,0:1,i]##V at each location "i"
> WITHOUT using a for loop. Is that possible?
>
> thanks,
>
> -- Pete
>



--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Re: vector matrix multipication [message #43418 is a reply to message #43413] Mon, 11 April 2005 07:54 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"pete" <schuck@ppdmail.nrl.navy.mil> writes:

> Is there any way to do vector matrix operations in IDL?
>
> For example I have an array of N 2x2 matrics: G[0:1,0:1,N] and
> a vector V[0:1]. I wouled like G[0:1,0:1,i]##V at each location "i"
> WITHOUT using a for loop. Is that possible?

Since your matrix multiplications are so simple, it is straightforward
to do the matrix multiplication "by hand".

result = dblarr(2,N)
for i = 0, 1 do result(i,*) = g(0,i,*)*v(0) + g(1,i,*)*v(1)

Which results in only two loop iterations.
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: array subscripting problem
Next Topic: how do I erase old data when using plots?

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

Current Time: Wed Oct 08 19:19:19 PDT 2025

Total time taken to generate the page: 0.00550 seconds