[Numpy-discussion] Extracting all the possible combinations of a grid
Charles R Harris
charlesr.harris@gmail....
Fri Sep 21 15:58:43 CDT 2007
On 9/21/07, Gael Varoquaux <gael.varoquaux@normalesup.org> wrote:
>
> On Fri, Sep 21, 2007 at 02:33:42PM -0600, Charles R Harris wrote:
> > I wrote up some of the combinatorial algorithms in python a few years
> ago
> > for my own use in writing a paper, ( Harris, C. R. Solution of the
> > aliasing and least squares problems of spaced antenna interferometric
> > measurements using lattice methods, Radio Sci. 38, 2003). I even
> thought I
> > had found an error and have a letter from Knuth pointing out that I
> was
> > mistaken ;) Anyway, there are a lot of neat things in volume 4 and it
> is
> > well worth the read.
>
> It is. I did my homework, and now I understand why you point this out.
> Basically array programming is really not suited for these kind of
> things. The problem with my solution is that is blows up the memory
> really quickly. It is actually a pretty poor solution. It is obvious when
> you think about this a bit that the problem diverges really quickly if
> you try the brute force approach. It is actually really quick, until it
> blows the memory.
I found generators a good approach to this sort of thing:
for (i,j,k) in triplets(n) :
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070921/b74af97f/attachment.html
More information about the Numpy-discussion
mailing list