Opened 2 years ago
Last modified 2 years ago
#21777 new defect
failed coercion for vectors from spaces versus "just vectors"
Reported by: | kcrisman | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-7.5 |
Component: | linear algebra | Keywords: | |
Cc: | paulmasson, slelievre | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
In this ask.sagemath question we have the following perplexing behavior:
sage: M = matrix([[1., 1., -1.], [1., 12., -5.]]) sage: u = vector(SR,[5, 4, 2]) sage: v = M.right_kernel().basis()[0] sage: u-v TypeError: unsupported operand parent(s) for '-': 'Vector space of dimension 3 over Symbolic Ring' and 'Vector space of degree 3 and dimension 1 over Real Field with 53 bits of precision Basis matrix:[ 1.00000000000000 0.571428571428571 1.57142857142857]'
Something with coercion is failing. Ideas?
Change History (3)
comment:1 Changed 2 years ago by
- Cc paulmasson added
comment:2 Changed 2 years ago by
comment:3 Changed 2 years ago by
- Cc slelievre added
I know very little about the coercion and conversion mechanisms, but this works.
sage: u-u.parent()(v) (4.00000000000000, 3.42857142857143, 0.428571428571429)
Note: See
TracTickets for help on using
tickets.
This might be an interesting example. It shows that coercion for vectors in subspaces goes out of its way to construct as small a parent as possible. However, it does seem that it also does proper discovery on the common overparent of the base ring:
I don't quite have an explanation why SR behaves oddly in this setting, though.