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

Home » Public Forums » archive » Re: zero-padding an array of arbitrary dimensionality (replacing execute in vm)
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: zero-padding an array of arbitrary dimensionality (replacing execute in vm) [message #54984 is a reply to message #54894] Thu, 19 July 2007 15:11 Go to previous messageGo to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Jul 19, 11:37 am, Allan Whiteford
<allan.rem...@phys.remove.strath.ac.remove.uk> wrote:
> Vince,
>
> data=fltarr(43,45,23,12) ; <-- arbitrary
> data[1,1,1,1]=1000. ; <-- so we know we get the right answer
>
> tmp=size(data)
> tmp=tmp[1:tmp[0]]
> idx=1
> for i=0,n_elements(tmp)-2 do idx=idx+product(tmp[0:i])
>
> print,data[idx] ; We get element [1,1,1,1]
>
> Helpful?
>
> Probably doesn't work for 1D arrays.
>
> Thanks,
>
> Allan
>
> hradilv wrote:
>> I would like to zero-pad an array programmatically without knowing in
>> advance what the dimensionality is of the array.
>
>> For example, in 2D, for data = some fltarr (31,31) I could do
>> dims = size(data,/dimensions)
>> zpad = fltarr(dims[0]+1,dims[1]+1)
>> zpad[1,1] = data
>
>> For arb. dimensionality I have:
>
>> dsize = size(data)
>> ndim = dsize[0]
>> dim = dsize[1:ndim]
>> dtmp = make_array(dim+2,value=0,type=dsize[ndim+1])
>
>> cmd = 'dtmp['
>> for n=0L, ndim-1 do cmd = cmd+'1,'
>> cmd = strmid(cmd,0,strlen(cmd)-1)+']=data'
>> result = execute(cmd)
>
>> But this won't work in the vm. So I need to somehow figure out the
>> position of the [1,1,1,...] index for an arbitrary dimensionality.
>
>> Clear enough? TIA!
>> Vince

Yes. I was just having some trouble wrapping my head around it.
Thanks!
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: xrange woes
Next Topic: making DIALOG_MESSAGE jump out

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

Current Time: Fri Oct 24 14:09:54 PDT 2025

Total time taken to generate the page: 3.76348 seconds