#8889: multidim'l enumeration over variable length tuples
---------------------------+------------------------------------------------
   Reporter:  ecurry       |       Owner:  jason        
       Type:  enhancement  |      Status:  new          
   Priority:  minor        |   Milestone:  sage-wishlist
  Component:  misc         |    Keywords:               
     Author:  Eva Curry    |    Upstream:  N/A          
   Reviewer:               |      Merged:               
Work_issues:               |  
---------------------------+------------------------------------------------
 I would like a function that takes
 Input: range (a list)
        dim (a positive integer)
 Output: a list of vectors or tuples of length dim including all
 combinations of range, but with replacement

 Example: generate the vertices of the centered unit cube [-1/2,1/2]^dim,
 where dim is variable

 The functions in sage.misc.mrange almost do this, except it seems that
 they require having dim specified ahead of time, whereas I want a function
 that I can call in another function where dim will vary.

 The function Arrangements in sage.combinat.permutation almost does what I
 want, but the list that the digits of the tuple are chosen from must be
 larger than dim, and Arrangements selects without replacement.  I can
 solve my example problem using Arrangements as follows:
 {{{
 prelist=[]
 for i in range(2**d):
     if i-2**(d-1) >= 0: prelist.append(1)
         else: prelist.append(-1)
 list = (1/2)*matrix(Arrangements(prelist,d).list())
 }}}
 but it seems like there should be one specific function for this.

 (Combinations and Permutations are also related, but don't quite do what I
 want.)

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8889>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to