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

Home » Public Forums » archive » Swap even/odd elements in array
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: Swap even/odd elements in array [message #44589 is a reply to message #44507] Wed, 22 June 2005 06:22 Go to previous messageGo to previous message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <1119428174.330105.170110@o13g2000cwo.googlegroups.com>,
photosalex@freenetname.co.uk wrote:

> Hi All,
> sorry if the question is trivial:
> how could I swap even and odd elements of a 1-D 16-bit INT array
> without using loops? That is, if the source array is
>
> [a0,a1,a2,a3,..]
>
> I want it to be
>
> [a1,a0,a3,a2,..]
>
> Thanks!

IDL> x = lindgen(16)
IDL> print, x
0 1 2 3 4 5
6 7
8 9 10 11 12 13
14 15
IDL> x = reform(reverse(reform(x, 2, 8), 1), 16)
IDL> print, x
1 0 3 2 5 4
7 6
9 8 11 10 13 12
15 14


Cheers, Ken Bowman
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Histogram shift
Next Topic: background transparency in tvscl?

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

Current Time: Fri Oct 10 15:28:44 PDT 2025

Total time taken to generate the page: 0.80133 seconds