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

Home » Public Forums » archive » Re: Padding arrays - vector subscripts not working
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: Padding arrays - vector subscripts not working [message #71576 is a reply to message #71575] Sat, 03 July 2010 13:52 Go to previous messageGo to previous message
James[2] is currently offline  James[2]
Messages: 44
Registered: November 2009
Member
On Jul 2, 1:01 pm, Paulo Penteado <pp.pente...@gmail.com> wrote:
> On Jul 2, 3:45 pm, James <donje...@gmail.com> wrote:
>
>> By the way, I would like my final program to work on arrays with any
>> number of dimensions, so I'd rather avoid a kludge like X[diff[0],
>> diff[1], diff[2]] = Y.
>
> As I wrote above, X[diff[0],diff[1],diff[2]] is not the same as
> X[diff]. What you seem to want is the equivalent of X[diff[0],
> diff[1], diff[2]] = Y, but working for any number of dimensions. That
> is, assign the elements of Y to a contiguous piece of X that starts at
> some location you calculate with the N-dimensional indexes. So it is
> just a matter of converting from those N indexes the a 1D index of
> that element:
>
> IDL> strides=[1L,product(size(x,/dimensions),/integer,/cumulative )]
> IDL> start_index=total(strides*diff,/integer)
>
> Then you can do X[start_index]=Y

Paulo, your explanation makes perfect sense. I guess I was hoping
there was a more elegant way than calculating every single 1d index
that will be used, but your method looks good. Thank you!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: How to exchange data in multi-top-level base widgets?
Next Topic: Re: REGRESS and sky background

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

Current Time: Wed Oct 08 17:03:53 PDT 2025

Total time taken to generate the page: 0.00408 seconds