[SciPy-user] filling array without loop...
Anne Archibald
peridot.faceted at gmail.com
Sun Apr 22 19:51:04 EDT 2007
On 22/04/07, fred <fredmfp at gmail.com> wrote:
> Forget that is a convolution (because in fact, it is really not),
> simply a scalar product (inner product says scipy) in each cells of an
> array, as I wrote in my example.
>
> Does it changes something ?
Uh, maybe I'm confused - the code you sent sure looks like a
convolution to me (although KW has for some reason been flattened).
Are you saying that the code you sent is not doing a convolution, or
are you asking me to optimize code I haven't seen?
Assuming the latter, dot() and tensordot() work fine on
higher-dimensional arrays; just transpose() your arrays so that the
indices you're contracting along are in the right places.
As a general comment, it seems as if you are using flat arrays to
store multidimensional data (for example, KW in the code you posted),
and as a result have loads of reshape()s. It's generally better, when
possible, to keep multidimensional arrays multidimensional - less
error-prone, and indexing is more likely to be easy.
Anne
More information about the SciPy-User
mailing list