Re: [Numpy-discussion] Optimize evaluation of function on matrix

2017-03-31 Thread Florian Lindner
Hey, Am 27.03.2017 um 16:09 schrieb Sebastian Berg: > On Mon, 2017-03-27 at 13:06 +0200, Florian Lindner wrote: >> Hey, >> >> I've timed the two versions, one basisfunction being a function: >> >> 1 loop, best of 3: 17.3 s per loop >> >> the other one, basisfunction being a list of functions: >> >

Re: [Numpy-discussion] Optimize evaluation of function on matrix

2017-03-27 Thread Matthew Harrigan
The best way to get good optimized code is to find it. Does this do what you want? https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.Rbf.html For some advice here, first avoid loops in Python and instead stick to ufuncs and broadcasting. It looks like the matrix is symmetri

Re: [Numpy-discussion] Optimize evaluation of function on matrix

2017-03-27 Thread Sebastian Berg
On Mon, 2017-03-27 at 13:06 +0200, Florian Lindner wrote: > Hey, > > I've timed the two versions, one basisfunction being a function: > > 1 loop, best of 3: 17.3 s per loop > > the other one, basisfunction being a list of functions: > > 1 loop, best of 3: 33.5 s per loop > > > To be honest, I

Re: [Numpy-discussion] Optimize evaluation of function on matrix

2017-03-27 Thread Florian Lindner
Hey, I've timed the two versions, one basisfunction being a function: 1 loop, best of 3: 17.3 s per loop the other one, basisfunction being a list of functions: 1 loop, best of 3: 33.5 s per loop > To be honest, I am a bit surprised that its a problem, since "basis > function" sounds a bit lik

Re: [Numpy-discussion] Optimize evaluation of function on matrix

2017-03-25 Thread Sebastian Berg
On Sat, 2017-03-25 at 18:46 +0100, Florian Lindner wrote: > Hello, > > I have this function: > > def eval_BF(self, meshA, meshB): > """ Evaluates single BF or list of BFs on the meshes. """ > if type(self.basisfunction) is list: > A = np.empty((len(meshA), len(meshB)))

[Numpy-discussion] Optimize evaluation of function on matrix

2017-03-25 Thread Florian Lindner
Hello, I have this function: def eval_BF(self, meshA, meshB): """ Evaluates single BF or list of BFs on the meshes. """ if type(self.basisfunction) is list: A = np.empty((len(meshA), len(meshB))) for i, row in enumerate(meshA): for j, col in