Opened 9 years ago
Closed 8 years ago
#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: | Merged in: | ||
Authors: | Reviewers: | Julian Rueth | |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
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 (1)
Change History (13)
comment:1 Changed 9 years ago by
- Status changed from new to needs_review
comment:2 Changed 9 years ago by
- 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 9 years ago by
- Status changed from needs_review to needs_work
[moved to description]
comment:4 Changed 9 years ago by
- Component changed from linear algebra to padics
- Description modified (diff)
- Keywords padics removed
comment:5 Changed 9 years ago by
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.
Changed 9 years ago by
comment:6 Changed 9 years ago by
- Status changed from needs_work to needs_review
comment:7 Changed 9 years ago by
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 9 years ago by
- 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 9 years ago by
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 9 years ago by
- Milestone changed from sage-5.4 to sage-duplicate/invalid/wontfix
- Status changed from needs_work to needs_review
comment:11 Changed 9 years ago by
- Status changed from needs_review to positive_review
comment:12 Changed 8 years ago by
- Resolution set to duplicate
- Reviewers set to Julian Rueth
- Status changed from positive_review to closed
[not relevant anymore]