Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewing matrices of algebraic numbers can take a long time #11544

Closed
rbeezer mannequin opened this issue Jun 25, 2011 · 13 comments
Closed

Viewing matrices of algebraic numbers can take a long time #11544

rbeezer mannequin opened this issue Jun 25, 2011 · 13 comments

Comments

@rbeezer
Copy link
Mannequin

rbeezer mannequin commented Jun 25, 2011

The following code leads to about a one minute hang for me (reproducibly in a fresh session). Keshav Kini (via IRC) had the same experience.

sage: A = matrix(QQ, 4, 4, [1, 2, -2, 2, 1, 0, -1, -1, 0, -1, 1, 1, -1, 2, 1/2, 0])
sage: e = A.eigenvalues()[3]
sage: K = (A-e).kernel()
sage: P = K.basis_matrix()
sage: x = P.list()[3]
sage: remap = {}
sage: remap.has_key(x)

This behavior hangs the creation of a string version of a matrix. If you comment-out sage/matrix/matrix0.pyx at lines 1695-1696, the problem goes away. To see the effect, run the first four lines of the code above and then just print P, with and without the two lines mentioned.

I have a workaround in mind that may solve the problem in many cases. Root issue is at #11543.

Apply:

  1. attachment: trac_11544-avoid-hash-of-matrix-entries-v2.patch

Component: linear algebra

Author: Rob Beezer

Reviewer: Martin Raum

Merged: sage-4.7.2.alpha3

Issue created by migration from https://trac.sagemath.org/ticket/11544

@rbeezer rbeezer mannequin added this to the sage-4.7.2 milestone Jun 25, 2011
@rbeezer rbeezer mannequin assigned jasongrout and williamstein Jun 25, 2011
@rbeezer

This comment has been minimized.

@rbeezer

This comment has been minimized.

@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented Jun 25, 2011

comment:2

Attachment: trac_11544-avoid-hash-of-matrix-entries.patch.gz

@rbeezer rbeezer mannequin added the s: needs review label Jun 25, 2011
@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented Jun 26, 2011

comment:3

I tested this for speed, but forgot to do even minimal doctests.

It affects a lot of QQbar output in minor ways, so several doctests need fixing.

@rbeezer rbeezer mannequin added s: needs work and removed s: needs review labels Jun 26, 2011
@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented Jul 11, 2011

@rbeezer

This comment has been minimized.

@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented Jul 11, 2011

comment:4

v2 patch includes doctest fixes.

Just one line of code changes in sage/matrix/matrix0.pyx, the rest is documentation.

Previous behavior was to hash entries while printing, this caused the precision of an entry to increase, thus slightly greater precision in subsequent computed (printed) results.

@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented Jul 11, 2011

Author: Rob Beezer

@rbeezer rbeezer mannequin added s: needs review and removed s: needs work labels Jul 11, 2011
@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented Jul 12, 2011

comment:5

This probably needs a bit more explanation.

One feature of #10627 is to replace specific matrix entries by a symbol. To look up this translation in a dictionary, entries of a matrix are hashed. For QQbar, this hash is expensive (#11543).

This patch prevents a look-up if the translation dictionary is empty.

@sagetrac-mraum
Copy link
Mannequin

sagetrac-mraum mannequin commented Aug 6, 2011

Reviewer: Martin Raum

@sagetrac-mraum
Copy link
Mannequin

sagetrac-mraum mannequin commented Aug 6, 2011

comment:6

This gets a positive review as is.

@rbeezer
Copy link
Mannequin Author

rbeezer mannequin commented Aug 11, 2011

comment:7

Thanks, again!

@nexttime
Copy link
Mannequin

nexttime mannequin commented Sep 17, 2011

Merged: sage-4.7.2.alpha3

@nexttime nexttime mannequin removed the s: positive review label Sep 17, 2011
@nexttime nexttime mannequin closed this as completed Sep 17, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants