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

Home » Public Forums » archive » Re: IDL removes dimensions of size 1 automatically
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: IDL removes dimensions of size 1 automatically [message #41189 is a reply to message #41183] Fri, 24 September 2004 13:16 Go to previous messageGo to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Paul Van Delst wrote:
> Benjamin Hornberger wrote:
>
>> Hi all,
>>
>> I had a hard time finding a bug which came from IDL's behaviour to
>> remove dimensions of size 1 automatically sometimes.
>>
>> IDL> a=[[1u,1u]]
>> IDL> help,a
>> A UINT = Array[2]
>> IDL> ;; IDL doesn't even let me specify this (2,1) element array
>> IDL> a=reform(a,2,1)
>> IDL> help,a
>> A UINT = Array[2, 1]
>> IDL> b=fix(a)
>> IDL> help,b
>> B INT = Array[2]
>> IDL> ;; IDL removed my second dimension even though I just wanted to
>> change the type
>> IDL> c=2*a
>> IDL> help,c
>> C INT = Array[2]
>> IDL> print,c
>> 2 2
>> IDL> ;; again IDL kicked out my second dimension
>>
>> I found this very annoying. Does anyone know more about it? Why is it
>> like that? In which situations will IDL do that?
>
>
> Only trailing dimensions of size 1 are removed.
>
> IDL> x=fltarr(20,1,1,1,1)
> IDL> help, x
> X FLOAT = Array[20]
> IDL> x=fltarr(1,1,1,1,20)
> IDL> help, x
> X FLOAT = Array[1, 1, 1, 1, 20]
> IDL> x=fltarr(20,1,3,1,1)
> IDL> help, x
> X FLOAT = Array[20, 1, 3]
>
> This has always been the case (in my experience) - much to the
> consternation of some IDL users, and to the joy to others. YMMV.
>

And,... when you think that the trailing dimension is important then use REFORM
liberally...

IDL> a = reform(intarr(2,1),2,1)
IDL> help, a
A INT = Array[2, 1]
IDL> dim = SIZE(a, /dim)
IDL> b = REFORM(a,dim)
IDL> help, b
B INT = Array[2, 1]
IDL> b = REFORM(a*2,dim)
IDL> help, b
B INT = Array[2, 1]

Ben
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: memory/buffer overload?
Next Topic: anonymous structure as member of named event structure

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

Current Time: Sun Oct 12 05:50:04 PDT 2025

Total time taken to generate the page: 2.08010 seconds