Opened 3 years ago
Last modified 3 years ago
#24031 new defect
Coercion between Matrices over orders and over the number field
Reported by: | sbrandhorst | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-8.2 |
Component: | coercion | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | u/sbrandhorst/coercion_between_matrices_over_orders_and_over_the_number_field (Commits) | Commit: | bc45dab36e11d82fbd1a150e60544b408b50f3fa |
Dependencies: | Stopgaps: |
Description
sage: L.<a> = CyclotomicField(5) sage: OL= L.ring_of_integers() sage: OL Maximal Order in Cyclotomic Field of order 5 and degree 4 sage: M=Matrix(OL,2,[1-a,0,a,1+a]) sage: a.parent() Cyclotomic Field of order 5 and degree 4 sage: a*M --------------------------------------------------------------------------- .... TypeError: unsupported operand parent(s) for *: 'Cyclotomic Field of order 5 and degree 4' and 'Full MatrixSpace of 2 by 2 dense matrices over Maximal Order in Cyclotomic Field of order 5 and degree 4' sage: M=Matrix(L,2,[1-a,0,a,1+a]) sage: a*M [-a^2 + a 0] [ a^2 a^2 + a]
Change History (10)
comment:1 Changed 3 years ago by
- Component changed from PLEASE CHANGE to coercion
- Milestone changed from sage-8.1 to sage-8.2
- Type changed from PLEASE CHANGE to defect
comment:2 Changed 3 years ago by
comment:3 Changed 3 years ago by
The bug only occurs if calling a*M first, not if there is an M*a call:
sage: L.<a> = CyclotomicField(5) sage: OL= L.ring_of_integers() sage: M=Matrix(OL,2,[1-a,0,a,1+a]) sage: a*M --------------------------------------------------------------------------- ... TypeError: unsupported operand parent(s) for *: 'Cyclotomic Field of order 5 and degree 4' and 'Full MatrixSpace of 2 by 2 dense matrices over Maximal Order in Cyclotomic Field of order 5 and degree 4' sage: M*a --------------------------------------------------------------------------- .... TypeError: unsupported operand parent(s) for *: 'Full MatrixSpace of 2 by 2 dense matrices over Maximal Order in Cyclotomic Field of order 5 and degree 4' and 'Cyclotomic Field of order 5 and degree 4' sage: exit Exiting Sage (CPU time 0m0.56s, Wall time 0m24.20s). [simon@Quadrator sage]$ ./sage .... sage: L.<a> = CyclotomicField(5) sage: OL= L.ring_of_integers() sage: M=Matrix(OL,2,[1-a,0,a,1+a]) sage: M*a [-a^2 + a 0] [ a^2 a^2 + a] sage: a*M [-a^2 + a 0] [ a^2 a^2 + a]
comment:4 Changed 3 years ago by
There we go...
sage: L.<a> = CyclotomicField(5) sage: OL= L.ring_of_integers() sage: M=Matrix(OL,2,[1-a,0,a,1+a]) sage: coercion_model.explain(M,a) Coercion on left operand via Call morphism: From: Full MatrixSpace of 2 by 2 dense matrices over Maximal Order in Cyclotomic Field of order 5 and degree 4 To: Full MatrixSpace of 2 by 2 dense matrices over Cyclotomic Field of order 5 and degree 4 Coercion on right operand via Call morphism: From: Cyclotomic Field of order 5 and degree 4 To: Full MatrixSpace of 2 by 2 dense matrices over Cyclotomic Field of order 5 and degree 4 Arithmetic performed after coercions. Result lives in Full MatrixSpace of 2 by 2 dense matrices over Cyclotomic Field of order 5 and degree 4 Full MatrixSpace of 2 by 2 dense matrices over Cyclotomic Field of order 5 and degree 4 sage: coercion_model.explain(a,M) Will try _r_action and _l_action Unknown result parent.
comment:5 Changed 3 years ago by
- Branch set to u/sbrandhorst/coercion_between_matrices_over_orders_and_over_the_number_field
comment:6 Changed 3 years ago by
- Commit set to a2e82e15a240f1e095c100d8cdb0f928373c6a68
Can you give me a brief synopsis of what you know, what you want, and where you're stuck?
From a quick look at your branch, you are doing conversion maps, which are not coercion maps and do not automatically get invoked with actions.
Also, I don't like the hack with the category on ResidueLiftingMap
. I suspect you should implement a proper Homset
parent.
comment:7 Changed 3 years ago by
- Commit changed from a2e82e15a240f1e095c100d8cdb0f928373c6a68 to bc45dab36e11d82fbd1a150e60544b408b50f3fa
Branch pushed to git repo; I updated commit sha1. New commits:
comment:8 Changed 3 years ago by
Huh. I guess that branch was an accident. I do not recall doing anything on this ticket. Looks quite unrelated too. So basically I did nothing.
Well I do know the difference between/coercion and conversion.
So I have to teach sage a conversion here. Namely to extend the base ring to the quotient field. Where do I do that? Where is left / right multiplication even defined? Where do I start?
comment:9 Changed 3 years ago by
It seems the bug lies in the following example. This is good
sage: L.<a> = NumberField(x^3+x-1) sage: OL = L.ring_of_integers() sage: P = MatrixSpace(OL,1,1) sage: from sage.categories.pushout import pushout sage: pushout(P,L) Full MatrixSpace of 1 by 1 dense matrices over Number Field in a with defining polynomial x^3 + x - 1
and here comes the bug
sage: pushout(L,P) --------------------------------------------------------------------------- CoercionException Traceback (most recent call last) <ipython-input-13-50299fa24306> in <module>() ----> 1 pushout(L,P) /home/simon/sage_working/local/lib/python2.7/site-packages/sage/categories/pushout.pyc in pushout(R, S) 3992 # make sense, and in this case simply want to return that a pushout 3993 # couldn't be found. -> 3994 raise CoercionException(ex) 3995 3996 CoercionException: base field and extension cannot have the same name 'a'
If I swap the input elements in `sage.categories.pushout.pushout, then scalar multiplication works just fine. Thus I believe this is the underlying cause.
comment:10 Changed 3 years ago by
It tries to apply the AlgebraicExtensionFunctor
of L to itself and this crashes.
Works.