#16683: gray code for integer vectors and combinations
-------------------------------------+-------------------------------------
       Reporter:  vdelecroix         |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.3
      Component:  combinatorics      |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Vincent Delecroix  |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/vdelecroix/16683                 |  4d2136a6d0505c15c0b1af4fb4c7ea22aa4980f6
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by vdelecroix):

 Replying to [comment:8 ncohen]:
 > If I make no mistake :

 You did.

 > With a gray code that makes you change two coordinates for each vector,
 you need to do `2n^k` to enumerate the elements of `n^k`

 It is only one change at a time. So it is `n^k`.

 Result :
 {{{
 sage: n^k # number of changes with a gray code
 810000
 sage: (1-n^(k+1))/(1-n)-1 # number of changes with addition
 837930
 }}}

 > Thus if you really care about those changes, may you should build a
 function which outputs the changes that must be performed at each run,
 based on stupid addition ? Or did I make a mistake somewhere ?

 The point is not really the gain in the number of changes but rather the
 simplicity with which you can adapt more complicated stuff. If you have to
 iterate through the number of changes you need a for loop. With a gray
 code, you need nothing, just do your change!

 Vincent

--
Ticket URL: <http://trac.sagemath.org/ticket/16683#comment:9>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to