[SciPy-user] SciPy-user Digest, Vol 70, Issue 6
Thu Jun 4 10:47:26 CDT 2009
Thanks David, that's kind of what I figured but I wanted to make sure I
wasn't missing anything. It does make a difference to not use the constantly
updated array, so it seems weave is the only way to really speed this up.
Is there a built in function for doing this circular padding?
> Message: 4
> Date: Wed, 3 Jun 2009 14:48:53 -0700 (PDT)
> From: David Baddeley <firstname.lastname@example.org>
> Subject: Re: [SciPy-user] can this be vectorized?
> To: email@example.com
> Message-ID: <firstname.lastname@example.org>
> Content-Type: text/plain; charset=utf-8
> Hi Ranjit,
> I think this is going to be hard to vectorise your code as it is, as the
> array s (which is used to calculate field) changes within the loop.
> r = numpy.random.random((self.N,self.N))
> field= scipy.ndimage.convolve(s, numpy.array([[0,1,0],[1,0,1],[0,1,0]]),
> s = s*2*(0.5 - (boltzmann_factor>r))
> would give you similar results with a few subtle differences (the 'field'
> is calculated with the initial s rather than the constantly updated s) which
> may or may not be important depending on how large you expect your boltzmann
> factor to be. Also note that the convolution the way I've written it doesn't
> wrap at the edges - you could achieve this by circularly padding s before
> the convolution and then cropping back down to the original size.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-user