Re: vector matrix multipication [message #43413] |
Mon, 11 April 2005 08:28 |
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  |
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
------------------------------------------------------------ --------------
|
|
|