Ticket #3103 (new defect)

Opened 8 months ago

Last modified 2 months ago

[with patch, needs works] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2

Reported by: ncalexan Assigned to: was
Priority: major Milestone: sage-3.4
Component: linear algebra Keywords: vector CDF coerce
Cc: ncalexan, rbradshaw, jason

Description

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'

Attachments

3103-ncalexan-complex-vector-dotproduct-1.patch (10.9 kB) - added by ncalexan on 06/17/2008 09:38:27 PM.

Change History

05/05/2008 03:52:35 AM changed by mabshoff

  • milestone set to sage-3.0.2.

05/08/2008 09:28:36 AM changed by robertwb

This is not due to coercion, but rather that dot product is not implemented for CDFn.

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.

06/17/2008 09:37:33 PM changed by ncalexan

  • cc changed from ncalexan to ncalexan, rbradshaw.
  • summary changed from coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 to [with patch, needs review] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2.

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.

06/17/2008 09:38:27 PM changed by ncalexan

  • attachment 3103-ncalexan-complex-vector-dotproduct-1.patch added.

06/18/2008 01:56:21 AM changed by robertwb

  • summary changed from [with patch, needs review] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 to [with patch, positive review] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2.

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

06/22/2008 09:32:43 PM changed by mabshoff

  • summary changed from [with patch, positive review] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 to [with patch, positive review, needs works] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2.

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

06/23/2008 01:48:16 AM changed by mabshoff

  • summary changed from [with patch, positive review, needs works] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2 to [with patch, needs works] coercion errors of vectors from ZZ^2 and QQ^2 into CDF^2.

11/13/2008 09:48:43 PM changed by jason

  • cc changed from ncalexan, rbradshaw to ncalexan, rbradshaw, jason.