#15820: Implement sequences of bounded integers
-------------------------------------+-------------------------------------
       Reporter:  SimonKing          |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.4
      Component:  algebra            |   Resolution:
       Keywords:  sequence bounded   |    Merged in:
  integer                            |    Reviewers:
        Authors:  Simon King         |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:                     |  93546db866564a80d80df30de48934697e2b0d1d
  u/SimonKing/ticket/15820           |     Stopgaps:
   Dependencies:                     |
-------------------------------------+-------------------------------------

Comment (by SimonKing):

 Since I cannot reproduce the problem myself, could you please help me by
 providing some internal data? Perhaps there are different architectures
 (32bit or 64bit, big or little endian) at work?

 Please add the following as a method of `BoundedIntegerSequence`:
 {{{
 #!python
     def inspect(self):
         cdef __mpz_struct seq
         seq = deref(<__mpz_struct*>self.data.data)
         print "bitsize",self.data.bitsize
         print "itembitsize",self.data.itembitsize
         print "mask_item", Integer(self.data.mask_item).binary()
         print "length", self.data.length
         print "GMP size", seq._mp_size
         print "GMP alloc", seq._mp_alloc
         print
 '.'.join([Integer(seq._mp_d[limb]).binary().rjust(mp_bits_per_limb,'0')
 for limb in range(seq._mp_size-1,-1,-1)])
 }}}
 With this, I get
 {{{
 sage: from sage.misc.bounded_integer_sequences import
 BoundedIntegerSequence
 sage: S = BoundedIntegerSequence(21, [4,1,6,2,7,20,9])
 sage: S.inspect()
 bitsize 35
 itembitsize 5
 mask_item 11111
 length 7
 GMP size 2
 GMP alloc 3
 00000000000000000000000000000010.01101000011100010001100000100100
 sage: S[1::2]
 <1, 2, 20>
 sage: (S[1::2]).inspect()
 bitsize 15
 itembitsize 5
 mask_item 11111
 length 3
 GMP size 1
 GMP alloc 2
 00000000000000000101000001000001
 sage: S[-1::-2]
 <9, 7, 6, 4>
 sage: (S[-1::-2]).inspect()
 bitsize 20
 itembitsize 5
 mask_item 11111
 length 4
 GMP size 1
 GMP alloc 2
 00000000000000100001100011101001
 }}}
 What do you get instead?

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