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

Home » Public Forums » archive » operating on 3-D arrays
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
operating on 3-D arrays [message #8408] Fri, 07 March 1997 00:00 Go to next message
John Keck is currently offline  John Keck
Messages: 10
Registered: August 1996
Junior Member
The IDL manual encourages avoiding FOR...NEXT loops by using the vaunted
matrix capabilities of IDL, so I have been trying to handle
three-dimensional arrays with these facilities.

I need to multiply three vectors to produce a three-dimensional array.
One would think that it would suffice to use the matrix multiplication
operator (#) as one does with a pair of vectors to get a two-dimensional
array. However with three vectors, IDL gives the error message

% Operands of matrix multiply have incompatible dimensions...

Anyone have a simple way to manipulate three (and higher) dimensional
arrays in IDL?

Thanks,

John Keck
Re: operating on 3-d arrays [message #8489 is a reply to message #8408] Mon, 10 March 1997 00:00 Go to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
John Keck <jwk@phys.columbia.edu> writes:

> The IDL manual encourages avoiding FOR...NEXT loops by using the vaunted
> matrix capabilities of IDL, so I have been trying to handle
> three-dimensional arrays.
>
> I need to multiply three vectors to produce a three-dimensional array.
> One would think that it would suffice to use the matrix multiplication
> operator (#) as one does with a pair of vectors to get a two-dimensional
> array. However with three vectors, IDL gives the error message
>
> % Operands of matrix multiply have incompatible dimensions...
>
> Anyone have a simple way to manipulate three (and higher) dimensional
> arrays in IDL?
>

This might do what you want. Suppose you had three vectors, called A, B, and C
that you wanted to multiply together such that the result R had the property

R(i,j,k) = A(i) * B(j) * C(k)

You could then use the following commands:

R = A # B
R = R(*) # C
R = REFORM(R, N_ELEMENTS(A), N_ELEMENTS(B), N_ELEMENTS(C))

Bill Thompson
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Books on IDL (Was Re: Want reference for IDL widgets)
Next Topic: Tephigram

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

Current Time: Wed Oct 08 13:44:47 PDT 2025

Total time taken to generate the page: 0.00540 seconds