Ticket #13302 (closed defect: duplicate)
Matrix constructor does not return over padic field
| Reported by: | saraedum | Owned by: | jason, was |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-duplicate/invalid/wontfix |
| Component: | padics | Keywords: | matrix space |
| Cc: | Work issues: | ||
| Report Upstream: | N/A | Reviewers: | Julian Rueth |
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description (last modified by saraedum) (diff)
The following code does not return in sage 5.1.rc1.
sage: MatrixSpace(Qp(3),1,1)([Qp(3).zero()])
The problem is that the matrix constructor tries to unpack a padic zero which is an infinite list of zeros.
Another example where the unpacking does not work is the following:
sage: MatrixSpace(Qp(3),1,1)([Qp(3)(4/3)]) [1 + O(3^20)]
The problem here is that the iterator returned for a padic (implicitly defined through __getitem__) starts at the term with valuation 0.
Attachments
Change History
comment:2 Changed 10 months ago by saraedum
- Description modified (diff)
- Summary changed from Vector space homomorphism does not return over padic field to Matrix constructor does not return over padic field
comment:3 Changed 10 months ago by saraedum
- Status changed from needs_review to needs_work
[moved to description]
comment:4 Changed 10 months ago by saraedum
- Keywords space added; space, padics removed
- Component changed from linear algebra to padics
- Description modified (diff)
comment:5 Changed 10 months ago by saraedum
I think that padics should probably not return iterators at all.
What should the iterator for Qp(3).zero() be — should it be infinite or empty? Should the iterator for Zp(3)(3) and Qp(3)(3) iterate over [0,1] or over [1]?
I believe that if one wants to iterate over the terms, then one should have to call .list() or similar explicitly.
comment:7 Changed 10 months ago by mderickx
I think the real problem is that your example is missing some parentheses
sage: MatrixSpace(Qp(3),1)([[Qp(3).zero()]]) [0] sage: MatrixSpace(Qp(3),1,1)([[Qp(3)(4/3)]]) [3^-1 + 1 + O(3^19)]
This causes the matrix constructor to look if it can unpack the element Qp(3).zero()] in the list [Qp(3).zero()] .
If you want it also to work with fewer parentheses I'd say that it's the fault of MatrixSpace?.call not checking if Qp(3).zero() is a ring element before just trying to unpack it.
Note that it's not only the p-adics that give rise to strange behaviour. You can also use polynomials:
sage: K.<x>=QQ[] sage: MatrixSpace(K,2)([x+2,3*x+4]) [2 1] [4 3]
comment:8 Changed 10 months ago by saraedum
- Status changed from needs_review to needs_work
Thanks for pointing this out Maarten.
I'll have a look if the check you propose can be done easily. Btw, the original problem I had was the following:
sage: K=Qp(3) sage: V=K^1 sage: V.hom([V.zero()])
This hangs and there don't seem to be any parentheses missing, right?
So apparently the hom does too much unpacking along the way.
Anyway, I'll look into this and most probably split this ticket into two tickets, since I still think that padics should not be iterable.
comment:9 Changed 10 months ago by mderickx
hom is broken in even more ways. see the discussion (maybe monologue is more adequate) https://groups.google.com/forum/?fromgroups#!topic/sage-devel/UdHakJf5A5Q
I created #13321 for this.
comment:10 Changed 7 months ago by saraedum
- Status changed from needs_work to needs_review
- Milestone changed from sage-5.4 to sage-duplicate/invalid/wontfix
comment:12 Changed 7 months ago by jdemeyer
- Status changed from positive_review to closed
- Reviewers set to Julian Rueth
- Resolution set to duplicate
- Authors Julian Rueth deleted


[not relevant anymore]