[MATRIX-SIG] interpolating matrices

Tim Hochberg hochberg@wwa.com
Mon, 26 Jan 1998 16:29:47 -0600



> Hello.  I would like to take a matrix of floating point numbers,
>say 200x200, representing data on a finite-difference grid,
>and change the grid to be, say 400x400, perhaps with smoothing of
>the data.  Has anyone implemented that kind of operation?


If all you need to do is double the grid size, this should be fairly easy --
something like (untested):

m2 = zeros( (2*shape(m1)[0], 2*shape(m2)[1], Float)
m2[::2,::2] = m1
m2[1::2,::2] = (m1[:-1] + m1[1:])/2
m2[:,1::2] =  (m1[:,:-1] + m1[:,1:])/2

If you need an arbitrary new matrix shape, this gets a bit more painful so
I'll leave it as an exercise for the reader.

____
 /im





_______________
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________