Ticket #13302 (closed defect: duplicate)

Opened 10 months ago

Last modified 7 months ago

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

trac_13302.patch Download (2.5 KB) - added by saraedum 10 months ago.

Change History

comment:1 Changed 10 months ago by saraedum

  • Status changed from new to needs_review

[not relevant anymore]

Last edited 10 months ago by saraedum (previous) (diff)

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]

Last edited 10 months ago by saraedum (previous) (diff)

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.

Changed 10 months ago by saraedum

comment:6 Changed 10 months ago by saraedum

  • Status changed from needs_work to needs_review

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

I created #13592 for the __iter__ issue. This fixes the issue described here and #13321 takes care of hom(), so I believe this ticket can be closed now.

comment:11 Changed 7 months ago by saraedum

  • Status changed from needs_review to positive_review

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
Note: See TracTickets for help on using tickets.