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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: IDL removes dimensions of size 1 automatically [message #41132] Wed, 29 September 2004 17:07 Go to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
Reimar Bauer wrote:
> David Fanning wrote:
>
>> Mark Hadfield writes:
>>
>>
>>> I support the idea of a compiler option to turn this behaviour off. I
>>> suspect, however, that implementing it would open up a Pandora's box
>>> of worms, as the saying goes.
>>
>>
>> I think you must be doing a literal translation from the German. :-)
>>
>
>
> Die B�chse der Pandora

Mit Wurmen?

--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: IDL removes dimensions of size 1 automatically [message #41145 is a reply to message #41132] Wed, 29 September 2004 11:46 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Reimar Bauer writes:

> David, did you have enjoyed the soccer match yesterday?

Nein, ich habe nicht der Television and ich muss Duetsch
gelernen fur zwei ur drei Uhrs. :-(

Prost,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
Re: IDL removes dimensions of size 1 automatically [message #41148 is a reply to message #41145] Wed, 29 September 2004 08:01 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
David Fanning wrote:
> Mark Hadfield writes:
>
>
>> I support the idea of a compiler option to turn this behaviour off. I
>> suspect, however, that implementing it would open up a Pandora's box of
>> worms, as the saying goes.
>
>
> I think you must be doing a literal translation from
> the German. :-)
>


Die B�chse der Pandora


Nach der griechischen Mythologie wurde die verf�hrerische Pandora von
Hephaistos erschaffen. Zeus gab ihr ein Gef�� mit, die B�chse der
Pandora, das zahlreiche �bel enthielt, als Bestrafung f�r den Diebstahl
des Prometheus, der den Menschen das Feuer gebracht hatte. Als Pandora
das Gef�� �ffnete, verteilten sich sofort diese �bel �ber die gesamte
Erde. Einzig die Hoffung blieb in Pandoras B�chse zur�ck.

( http://www.noeastro.de/Astrologie/Astro_Aktuell/Astro_News/s tammzellen.jsp)



David, did you have enjoyed the soccer match yesterday?




Reimar
Re: IDL removes dimensions of size 1 automatically [message #41178 is a reply to message #41148] Mon, 27 September 2004 00:20 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mark Hadfield writes:

> I support the idea of a compiler option to turn this behaviour off. I
> suspect, however, that implementing it would open up a Pandora's box of
> worms, as the saying goes.

I think you must be doing a literal translation from
the German. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
Re: IDL removes dimensions of size 1 automatically [message #41179 is a reply to message #41178] Sun, 26 September 2004 15:46 Go to previous messageGo to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
Benjamin Hornberger wrote:
> I had a hard time finding a bug which came from IDL's behaviour to
> remove dimensions of size 1 automatically sometimes.
>
> ...
>
> I found this very annoying. Does anyone know more about it? Why is it
> like that?

Since others have already responded on these points I will be brief:

So do I.
No, I think you know as much as anyone.
Why indeed?

> In which situations will IDL do that?

I think the only answer you can rely on is "Whenever you don't want it to".

Seriously, you can *create* arrays with a trailing dimension of size 1
and you can pass them in and out of routines, but beyond that you should
assume that IDL will lose the trailing dimension.

I support the idea of a compiler option to turn this behaviour off. I
suspect, however, that implementing it would open up a Pandora's box of
worms, as the saying goes.


--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: IDL removes dimensions of size 1 automatically [message #41183 is a reply to message #41179] Sun, 26 September 2004 01:36 Go to previous messageGo to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
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?
>
> Thanks for any comments,
>
> Benjamin


Dear Benjamin

this is regular discussed here. It's not a bug because this is described in
all documents about array handling from RSI.

I have had a lot of problems by this too. You could do a feature request to
to get a compiler option implemented which controls this too.

Here are an additional examples about this:

IDL> c=reform(make_array(10,1),10,1)
IDL> help,c
C FLOAT = Array[10, 1]
IDL> D=C
IDL> help,D
D FLOAT = Array[10]

The solution is:
IDL> c=reform(make_array(10,1),10,1)
IDL> s=size(c,/dim)
IDL> d=reform(c,s)
IDL> help,d
D FLOAT = Array[10, 1]


Reimar


--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
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 next 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
Re: IDL removes dimensions of size 1 automatically [message #41190 is a reply to message #41189] Fri, 24 September 2004 11:14 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
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.

paulv
Re: IDL removes dimensions of size 1 automatically [message #41283 is a reply to message #41132] Sun, 03 October 2004 00:14 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Mark Hadfield wrote:

> Reimar Bauer wrote:
>> David Fanning wrote:
>>
>>> Mark Hadfield writes:
>>>
>>>
>>>> I support the idea of a compiler option to turn this behaviour off. I
>>>> suspect, however, that implementing it would open up a Pandora's box
>>>> of worms, as the saying goes.
>>>
>>>
>>> I think you must be doing a literal translation from the German. :-)
>>>
>>
>>
>> Die Bᅵchse der Pandora
>
> Mit Wurmen?

Ja (Wᅵrmer), und anderem ᅵbel.
Reimar


--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Sat Oct 11 11:48:38 PDT 2025

Total time taken to generate the page: 0.32262 seconds