Reverse function and degenerate dimensions [message #40664] |
Wed, 25 August 2004 08:19 |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
Hello,
This is an FYI update on IDL's behavior regarding degenerate dimensions (see
http://tinyurl.com/452xd) I just bumped into another one of those awkward (and
sometimes maddening) situations where IDL drops degenerate dimensions
automatically. It maybe old news, but I thought I should post anyway.
Buried in the REVERSE procedure is this nice option to OVERWRITE the array you
are manipulating. This works fine unless the dimension you want to reverse is
the degenerate one. Here is the line...
b = KEYWORD_SET(overwrite) ? TEMPORARY(a) : a
Here is what happens in each case...
IDL> a = REFORM(fltarr(4,3,1), 4,3,1)
IDL> help, a
A FLOAT = Array[4, 3, 1]
IDL> b = a
IDL> help, b
B FLOAT = Array[4, 3]
IDL> c = temporary(a)
IDL> help, c
C FLOAT = Array[4, 3, 1]
So, it looks like simply copying the array drops the degenerate dimension but
copying with TEMPORARY does not.
My solution is to replace the offending line in REVERSE with ...
b = KEYWORD_SET(overwrite) ? TEMPORARY(a) : Reform(a, size(a, /dim))
Now you might ask why I might want to reverse that particular dimension of such
an array - but please don't ask 'cause I can't explain it.
Cheers,
Ben
|
|
|