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 #44595 is a reply to message #44589] Wed, 22 June 2005 07:06 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ken Bowman writes:

>> how could I swap even and odd elements of a 1-D 16-bit INT array
>> without using loops?
>
> 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

Those of you who have been invited to answer the Test Question
(http://www.dfanning.com/misc_tips/iepa.html) at this year's
IEPA conference might want to take careful note of this answer.
I'd say the chances are pretty good you might see it again. ;-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[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: Sat Oct 11 09:50:46 PDT 2025

Total time taken to generate the page: 0.24778 seconds