Yes, this is a bug in vector_modn_dense. You can fix it with
if i < 0 or i >= self._degree:
raise IndexError, 'index out of range'
else:
- n = IntegerMod_int.__new__(IntegerMod_int)
- IntegerMod_abstract.__init__(n, self.base_ring())
- n.ivalue = self._entries[i]
- return n
+ return self.base_ring()(self._entries[i])
On Jun 21, 2007, at 5:18 PM, Nils Bruin wrote:
>
> The bug below is actually a blocker for certain linear algebra
> problems over Z/dZ. From what I can see,
> apparently, elements of Integers(D) can be of one of IntegerMod_int,
> IntegerMod_int64 or IntegerMod_gmp
> and apparently they get mixed in the same parent. Coercion problems
> ensue.
> Unfortunately, resolving the problem is way beyond me. Would it be
> possible for someone who knows about the architecture to look into
> this problem?
>
> http://www.sagemath.org:9002/sage_trac/ticket/387
>
> Example:
>
> A=matrix([(70, 49, -20, -34, 57), (-49, -14, 95, 43, 85), (-95, -63,
> 68, 52, 12), (11,-16, -50, 43, 76), (-55, 83, 55, 40, -14)])
> D=A.determinant()
> R=Integers(D)
> MD=MatrixSpace(R,A.nrows(),A.ncols())
> AD=MD(A)
> # You would expect elements of R and entries of AD to be of exactly
> the same type.
> # this is not the case, however:
> print parent(AD.row(1)[1])
> print parent(R(3))
> # Indeed, the types of these are not the same:
> print type(AD.row(1)[1])
> print type(R(3))
> # and this has consequences: You'd expect the following to work, but
> it gives an error:
> R(3)*AD.row(1)
>
>
>
--~--~---------~--~----~------------~-------~--~----~
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-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---