Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coercing a vector to symbolic entries doesn't work when the vector's parent has a user-defined basis #3058

Closed
jasongrout opened this issue Apr 29, 2008 · 3 comments

Comments

@jasongrout
Copy link
Member

The title is what I think is the real issue here:

sage: a=(QQ3).subspace([[1,0,1]])
sage: b=a.basis()[0]
sage: b/b.norm()
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

/home/grout/<ipython console> in <module>()

/home/grout/element.pyx in sage.structure.element.Vector.__div__ 
(sage/structure/element.c:10962)()

/home/grout/element.pyx in sage.structure.element.Vector.__mul__ 
(sage/structure/element.c:10413)()

/home/grout/coerce.pyx in 
sage.structure.coerce.CoercionModel_cache_maps.bin_op_c 
(sage/structure/coerce.c:5292)()

<type 'exceptions.TypeError'>: unsupported operand parent(s) for '*': 
'Vector space of degree 3 and dimension 1 over Rational Field
Basis matrix:
[1 0 1]' and 'Symbolic Ring'

Note that the following does work:

sage: b=vector(QQ,[1,0,1])
sage: b/b.norm()
(1/sqrt(2), 0, 1/sqrt(2))

Component: coercion

Issue created by migration from https://trac.sagemath.org/ticket/3058

@jasongrout
Copy link
Member Author

comment:1

This seems fixed now (in 3.2.1). However there are other similar issues, like:

sage: a=(QQ^3).subspace([[1,0,1]])
sage: b=a.basis()[0]
sage: b/b.norm()
(1/sqrt(2), 0, 1/sqrt(2))
sage: b-b/b.norm()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/grout/<ipython console> in <module>()

/home/grout/sage/local/lib/python2.5/site-packages/sage/structure/element.so in sage.structure.element.ModuleElement.__sub__ (sage/structure/element.c:6073)()

/home/grout/sage/local/lib/python2.5/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:5805)()

TypeError: unsupported operand parent(s) for '-': 'Vector space of degree 3 and dimension 1 over Rational Field
Basis matrix:
[1 0 1]' and 'Vector space of degree 3 and dimension 1 over Symbolic Ring
User basis matrix:
[1 0 1]'

@jasongrout
Copy link
Member Author

comment:2

It also seems like the operation above takes way too long:

sage: %time b/b.norm()  
CPU times: user 0.48 s, sys: 0.14 s, total: 0.62 s
Wall time: 2.02 s
(1/sqrt(2), 0, 1/sqrt(2))
sage: %time b.norm()
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
sqrt(2)

@mwhansen
Copy link
Contributor

mwhansen commented Jun 4, 2009

comment:3

This looks good with 4.0.1.rc1:

----------------------------------------------------------------------
| Sage Version 4.0.1.rc1, Release Date: 2009-06-04                   |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: sage: a=(QQ^3).subspace([[1,0,1]])
sage: sage: b=a.basis()[0]
sage: %time b/b.norm()
CPU times: user 0.01 s, sys: 0.00 s, total: 0.01 s
Wall time: 0.01 s
(1/2*sqrt(2), 0, 1/2*sqrt(2))
sage: b-b/b.norm()
(-1/2*sqrt(2) + 1, 0, -1/2*sqrt(2) + 1)

@mwhansen mwhansen removed this from the sage-4.0.1 milestone Jun 4, 2009
@mwhansen mwhansen closed this as completed Jun 4, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants