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

Home » Public Forums » archive » Re: Reversing a multi-dimensional array
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: Reversing a multi-dimensional array [message #35591] Mon, 07 July 2003 09:30
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
Hi Andy,

"Andy Loughe ( remove OMITs )" <Andrew.LougheOMIT@noaaOMIT.govOMIT>
wrote in message news:3F04BF29.7030406@noaaOMIT.govOMIT...
> Hello,
>
> I have a 4-dimensional array, but it could someday grow to become
> 6 or 7 dimensions. What I would like to do is reverse the entire
> array, so that if it is now: a(i,j,k,l) it becomes a(l,k,j,i).
>
> What is the most efficient method for accomplishing this in IDL?

While I wouldn't call this a reversal of the array (rather, a
transposition reversing the dimensions of the array), I think what
you're looking for is:

a = Transpose(a)

The reversal of dimensions is the default behaviour of Transpose,
equivalent to:

a = Transpose(a, [3, 2, 1, 0])

If you needed some other ordering, you would give a different ordering
of values in the array.

Cheers,
--
-Dick

Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
Re: Reversing a multi-dimensional array [message #35606 is a reply to message #35591] Thu, 03 July 2003 17:06 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Andy Loughe ( remove OMITs )" <Andrew.LougheOMIT@noaaOMIT.govOMIT> writes:
> Hello,
>
> I have a 4-dimensional array, but it could someday grow to become
> 6 or 7 dimensions. What I would like to do is reverse the entire
> array, so that if it is now: a(i,j,k,l) it becomes a(l,k,j,i).
>
> What is the most efficient method for accomplishing this in IDL?

Greetings--

I think you don't actually want to reverse the array, but rather
change the order of the dimensions. This is exactly what TRANSPOSE
will do for you with its mysterious optional permutation vector
parameter. Explaining it is much harder than showing how you would
use it:

aprime = transpose(a, [3,2,1,0])

(which is actually the default). Unfortunately this is a case where
RSI used 0-based dimension numbering instead of 1-based (as is used in
TOTAL, MIN etc).

Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Reversing a multi-dimensional array [message #35607 is a reply to message #35606] Thu, 03 July 2003 16:59 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Andy Loughe ( remove OMITs ) writes:

> I have a 4-dimensional array, but it could someday grow to become
> 6 or 7 dimensions. What I would like to do is reverse the entire
> array, so that if it is now: a(i,j,k,l) it becomes a(l,k,j,i).
>
> What is the most efficient method for accomplishing this in IDL?

A histogram, of course! But, uh, I don't have time
to work out the details. I'm off on a backpacking
holiday. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Variable y-axis sizes in multiplot/ladder?
Next Topic: Slider Question

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

Current Time: Fri Oct 10 09:24:40 PDT 2025

Total time taken to generate the page: 0.88300 seconds