#12453: Refactor integer vectors using ClonableIntArray Cython data structure
-------------------------------------+-------------------------------------
       Reporter:  nborie             |        Owner:  nborie
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.2
      Component:  combinatorics      |   Resolution:
       Keywords:  Integer, vectors,  |    Merged in:
  cython, clone, Cernay2012          |    Reviewers:
        Authors:  Travis Scrimshaw   |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:                     |  3008ee6a34c023370071bfe1fb324f2b479462ed
  public/refactor_integer_vectors-12453|     Stopgaps:
   Dependencies:  #10193 #14101      |
-------------------------------------+-------------------------------------

Comment (by ncohen):

 > By your convention, I mean revlex.

 Me and quite a lot of people (wikipedia, dictionaries, phone books,
 Python) seem to agree on what a lexicographic ordering is `:-P`

 It looks like `IntegerVector` returns them in decreasing lexicographic
 order, so I guess that's what you call "revlex" (sorry I always mix colex
 and revlex).

 What about computing the complement of x ? In Python  it wastes a lot of
 time, but the algorithm works.... `:-P`

 {{{
 def integervectors(n,k):
     L = n+k-1
     for x in combinations(range(L),L-(k-1)):
         x_complement = []
         j = 0
         for i in range(L):
             if x[j] == i:
                 if j < L-(k-1)-1:
                     j += 1
                 continue
             else:
                 x_complement.append(i)
         x = x_complement
         l = [x[i] - x[i-1]-1 for i in range(1,k-1)]
         l.insert(0,x[0])
         l.append(L-x[-1]-1)
         yield l

 sage: list(integervectors(5,5)) == [list(map(int,x)) for x in
 IntegerVectors(5,5)]
 True
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/12453#comment:21>
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