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

Home » Public Forums » archive » What are the rules for automatic removal of singleton dimensions, and can I have a way of disabling them, please?
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: What are the rules for automatic removal of singleton dimensions, and can I have a way of disabling them, please? [message #82645 is a reply to message #82553] Wed, 26 December 2012 01:25 Go to previous messageGo to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den måndagen den 24:e december 2012 kl. 00:01:24 UTC+1 skrev Tom Grydeland:
> Hello all,
>
>
>
> I was trying to visualize subsections of a windowing function when this bit me.
>
>
>
> I was creating piecewise results in an array res[ix, iy, ii, jj], where the partial results were sums up to some value in the final two indices
>
>
>
> for ii = 0, Kx-1 do begin
>
> for jj = 0, Ky-1 do begin
>
> visualize, total(total(res[*,*,0:ii,0:jj], 4), 3)
>
> endfor
>
> endfor
>
>
>
> but the problem is that IDL (arbitrarily, IMO) discards trailing singleton dimensions on my indexing, so that res[*,*,0:ii,0:jj] ends up as a two-dimensional array when both ii and jj are zero, and a three-dimensional index on subsequent cases of jj being zero, which again causes the calls to 'total' to fail. The innermost portion of these loops become extraordinarily messy if trying to fix this problem.
>
>
>
> I've fixed my program by reordering the indices (to [ii, jj, ix, iy]), but I am still miffed that this should be necessary.
>
>
>
> Similarly, when I concatenate arrays of dimensions [x, j] and [y, j], I expect a result with dimensions [x+y, j], even when j is equal to 1. I'm trying to write programs independent of the actual value of j, but these arbitrary removals of singleton dimensions make my task that much harder.
>
>
>
> Is there a way to disable this stripping of singleton dimensions?

I thought the idea with the stripping of dimensions was that it shouldn't matter whether these dimensions are there or not. I mena, you can still address a[2,2,0] when a=fltarr(5,5). So shouldn't the fix really be to make total() work for non-existing trailing dimensions?

(Or, if just to make your code less messy, to write a mytotal() function that takes care of the exceptions.)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Undocumented behavior of TRANSPOSE
Next Topic: Putting an overbar on text in a plot

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

Current Time: Sat Nov 29 05:55:40 PST 2025

Total time taken to generate the page: 2.00677 seconds