#10578: Coercion problem for vectors from polynomial rings over GF(2)
------------------------------+---------------------------------------------
Reporter: jonhanke | Owner: jason, was
Type: defect | Status: needs_info
Priority: minor | Milestone: sage-4.6.1
Component: linear algebra | Keywords: GF(2), coerce, polynomial ring,
vector
Author: Jonathan Hanke | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
------------------------------+---------------------------------------------
Changes (by dimpase):
* status: new => needs_info
Comment:
this is due to the call to mod 2 in
{{{
mzd_write_bit(self._entries, 0, i, x[i]%2)
}}}
(modules/vector_mod2_dense.pyx":166), where x[i]'s are the coordinates of
the vector v1. The latter are in fact polynomials, and taking polynomial
mod 2 produces a crash, as
this low-level thing cannot be applied to Sage polynomials.
The following (coersing x[i] to int before computing modulo 2) appears to
cure the problem, although I am not sure whether
this is the right fix:
{{{
diff -r 777e70039438 sage/modules/vector_mod2_dense.pyx
--- a/sage/modules/vector_mod2_dense.pyx Fri Dec 24 16:22:56 2010
+0100
+++ b/sage/modules/vector_mod2_dense.pyx Mon Jan 10 20:39:38 2011
-0800
@@ -163,7 +163,8 @@
# the if/else statement is because in some compilers,
(-1)%2 is -1
mzd_write_bit(self._entries, 0, i, 0 if xi%2==0 else
1)
else:
- mzd_write_bit(self._entries, 0, i, x[i]%2)
+ xi = x[i]
+ mzd_write_bit(self._entries, 0, i, xi%2)
return
if x != 0:
raise TypeError("can't initialize vector from nonzero non-
list")
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10578#comment:1>
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.