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

Home » Public Forums » archive » 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
zero-padding an array of arbitrary dimensionality (replacing execute in vm) [message #54897] Thu, 19 July 2007 08:51 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
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
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Tab completion of variables and routines at the IDL command line
Next Topic: I've got rings around my iPlot!

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

Current Time: Wed Oct 08 19:51:35 PDT 2025

Total time taken to generate the page: 0.00437 seconds