On Oct 28, 2008, at 12:38 PM, John Cremona wrote: > 2008/10/28 Robert Bradshaw <[EMAIL PROTECTED]>: >> >> On Oct 27, 2008, at 2:15 PM, cesarnda wrote: >> >>> is there a way to do that in a fancy way in pure cython? >> >> No, the cartesian_product_iterator will still work in the context of >> Sage though, as will Georg's solution. >> >> If I needed to do this loop super fast for an arbitrary number of k, >> I might either implement it as a map ZZ -> {-2,...,2}^n and iterate >> over ZZ, or implement a manual "add and carry." > > Here's a similar alternative: > > sage: A = AbelianGroup([2]*3); A > Multiplicative Abelian Group isomorphic to C2 x C2 x C2 > sage: for a in A: > print [[5,6][i] for i in a.list()] > ....: > [5, 5, 5] > [5, 5, 6] > [5, 6, 5] > [5, 6, 6] > [6, 5, 5] > [6, 5, 6] > [6, 6, 5] > [6, 6, 6]
This would work too, though I was thinking in terms of manipulating c ints alone for cython-like speed. - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---