#10250: segfault when multiplying QQ constant and SR vector (with user basis)
------------------------------+---------------------------------------------
Reporter: jason | Owner: jason, was
Type: defect | Status: needs_work
Priority: major | Milestone:
Component: linear algebra | Keywords:
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
------------------------------+---------------------------------------------
Comment(by jason):
I think I see the problem. Here is the code in question:
{{{
if check:
V = ambient.ambient_vector_space()
for i in range(len(basis)):
x = basis[i]
if x not in V:
try:
basis[i] = V(x)
except TypeError:
raise TypeError("each element of basis must be in
"
"the ambient vector space")
}}}
Notice that a basis element is only converted to V if it's not already in
V. The problem is that the test "x in V" may succeed, even if x is not a
vector in V. In this case, when you try to construct a basis vector for
SR^2^, you're handed the vector (1,1) as a rational vector. The test "x
not in V" fails, since the rational vector (1,1) *is* in V. So it is put
in as a basis vector. You need the initial conversion to first convert
vectors to the same type of vectors as live in V, because you need those
basis elements to actually be vectors with parent SR^2^.
I.e., we are handed a basis vector in QQ^2^, and we fail to convert it to
a vector in SR^2^ because the if statement fails:
{{{
sage: (QQ^2)([1,1]) not in (SR^2)
False
}}}
The initial conversion using ambient.ambient_vector_space is to ensure
that the vectors are actually vectors in SR^2^ (in this case).
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10250#comment:19>
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.