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 #71651 is a reply to message #71575] Tue, 06 July 2010 11:38 Go to previous message
James[2] is currently offline  James[2]
Messages: 44
Registered: November 2009
Member
OK, I tried using your method, but it seemed to only take the first
dimension of Y. Here's the function I used:

function pad, array, dims

;error checking, etc. removed for more compact newsgroup post

type = size(array, /type)
out = make_array(dims, type=type)

;calculate where to put the original array in the new
sz = size(array, /dimensions)
diff = (dims - sz)/2

strides = [1L, product(dims, /integer, /cumulative)]
start = total(strides*diff, /integer)

out[start] = array
return, out
end

And here is an example of its output:

IDL> test = replicate(4,3,3)
IDL> padtest = pad(test, [5,6])
IDL> print, padtest
0 0 0 0 0
0 4 4 4 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
[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: Fri Oct 10 01:51:59 PDT 2025

Total time taken to generate the page: 0.32036 seconds