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

Coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 #3103

Closed
ncalexan mannequin opened this issue May 5, 2008 · 12 comments
Closed

Coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 #3103

ncalexan mannequin opened this issue May 5, 2008 · 12 comments

Comments

@ncalexan
Copy link
Mannequin

ncalexan mannequin commented May 5, 2008

With

sage: version()
'SAGE Version 3.0.1.alpha0, Release Date: 2008-04-26'

I get the following coercion errors:

sage: vector(CDF, [2, 2]) * vector(ZZ, [1, 3])
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

/Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/<ipython console> in <module>()

/Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/element.pyx in sage.structure.element.Vector.__mul__ (sage/structure/element.c:10413)()

/Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/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 dimension 2 over Complex Double Field' and 'Ambient free module of rank 2 over the principal ideal domain Integer Ring'
sage: vector(CDF, [2, 2]) * vector(QQ, [1, 3])
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

/Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/<ipython console> in <module>()

/Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/element.pyx in sage.structure.element.Vector.__mul__ (sage/structure/element.c:10413)()

/Users/ncalexan/sage-3.0.1.alpha0/devel/sage-nca/sage/rings/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 dimension 2 over Complex Double Field' and 'Vector space of dimension 2 over Rational Field'

CC: @ncalexan @robertwb @jasongrout

Component: linear algebra

Keywords: vector CDF coerce

Author: Charles Bouillaguet

Reviewer: Robert Bradshaw

Merged: sage-5.7.beta1

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

@ncalexan ncalexan mannequin assigned williamstein May 5, 2008
@sagetrac-mabshoff sagetrac-mabshoff mannequin added this to the sage-3.0.2 milestone May 5, 2008
@robertwb
Copy link
Contributor

robertwb commented May 8, 2008

comment:2

This is not due to coercion, but rather that dot product is not implemented for CDF^n.

sage: (CDF^2)([1,2]) * (CDF^2)([2,3])
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
  File "element.pyx", line 1884, in sage.structure.element.Vector.__mul__ (sage/structure/element.c:10398)
  File "element.pyx", line 1898, in sage.structure.element.Vector._dot_product_c (sage/structure/element.c:10564)
  File "element.pyx", line 1904, in sage.structure.element.Vector._dot_product_c_impl (sage/structure/element.c:10649)
<type 'exceptions.TypeError'>: unsupported operand parent(s) for '*': 'Vector space of dimension 2 over Complex Double Field' and 'Vector space of dimension 2 over Complex Double Field'

Which, looking at element.pyx line 1904 shows that _dot_product_c_impl was never implemented for CDF. This should almost certainly be a NotImplementedError, or something like that, not a TypeError. In fact, there should just be a generic implementation.

@ncalexan
Copy link
Mannequin Author

ncalexan mannequin commented Jun 18, 2008

comment:3

The attached patch fixes the errors (they were in fact dot_product errors and not coercion) and adds doctests and functionality for preserving inner product matrices.

@ncalexan ncalexan mannequin added s: needs review and removed s: needs work labels Jun 18, 2008
@robertwb
Copy link
Contributor

comment:4

The patch solves the problem and cleans up a lot of old code.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Jun 23, 2008

comment:5

This patch causes a number of doctest failures:

        sage -t -long devel/sage/sage/modular/modsym/space.py # 5 doctests failed
        sage -t -long devel/sage/sage/modular/modform/constructor.py # 3 doctests failed
        sage -t -long devel/sage/sage/modular/hecke/module.py # 12 doctests failed
        sage -t -long devel/sage/sage/modular/abvar/abvar_newform.py # 19 doctests failed
        sage -t -long devel/sage/sage/modular/abvar/abvar_ambient_jacobian.py # 2 doctests failed
        sage -t -long devel/sage/sage/modular/abvar/abvar.py # 3 doctests failed
        sage -t -long devel/sage/sage/modular/abvar/homspace.py # 2 doctests failed

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin changed the title coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 [needs works] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 Jun 23, 2008
@aghitza aghitza changed the title [needs works] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 Jan 22, 2009
@jasongrout
Copy link
Member

comment:9

In Sage 3.4.1.rc2, this works:

----------------------------------------------------------------------
| Sage Version 3.4.1.rc2, Release Date: 2009-04-10                   |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: vector(CDF, [2, 2]) * vector(ZZ, [1, 3])
8.0

So this sounds like it is fixed. However, are there nice doctests from the above patch that could be added to the current code? Nick?

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Apr 15, 2009

comment:10

Yes, I agree with Jason. Once we add a patch that adds a doctest this ticket can be merged and closed. By maybe someone ought to check out if Nick's patch contains anything else.

Cheers,

Michael

@sagetrac-Bouillaguet
Copy link
Mannequin

sagetrac-Bouillaguet mannequin commented Jan 12, 2013

comment:11

Since the problem has been fixed, here is a very simple doctest that enforces it won't happen again.

Patchbot !

apply trac_3103_add_doctest.patch

@sagetrac-Bouillaguet
Copy link
Mannequin

sagetrac-Bouillaguet mannequin commented Jan 12, 2013

Author: Charles Bouillaguet

@sagetrac-Bouillaguet
Copy link
Mannequin

sagetrac-Bouillaguet mannequin commented Jan 20, 2013

comment:12

Attachment: trac_3103_add_doctest.patch.gz

took care of stupid TAB in the patch

@robertwb
Copy link
Contributor

comment:13

Apply only trac_3103_add_doctest.patch

@jdemeyer
Copy link

Reviewer: Robert Bradshaw

@jdemeyer jdemeyer removed this from the sage-5.6 milestone Jan 22, 2013
@jdemeyer jdemeyer added this to the sage-5.7 milestone Jan 22, 2013
@jdemeyer jdemeyer changed the title coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 Coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 Jan 22, 2013
@jdemeyer
Copy link

Merged: sage-5.7.beta1

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

5 participants