Opened 13 years ago

Closed 13 years ago

#6554 closed defect (fixed)

[with patch, positive review] plotting sparse matrices converts the matrix to a dense matrix

Reported by: Jason Grout Owned by: William Stein
Priority: major Milestone: sage-4.1.1
Component: linear algebra Keywords:
Cc: Rob Beezer, Mike Hansen, William Stein, William Cauchois, Robert Bradshaw Merged in: Sage 4.1.1.rc0
Authors: Jason Grout Reviewers: David Joyner
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

Plotting big sparse matrices doesn't even work since it automatically converts the matrix to a dense matrix, instead of calling the spy() function.

Attachments (2)

trac-6554-sparse-matrix-plot.patch (3.8 KB) - added by Jason Grout 13 years ago.
trac-6554-matrix-plot-docs.patch (1.3 KB) - added by Jason Grout 13 years ago.
apply on top of previous patch

Download all attachments as: .zip

Change History (9)

Changed 13 years ago by Jason Grout

comment:1 Changed 13 years ago by Jason Grout

This took a very long time before, if it was even possible.

        sage: A=random_matrix(ZZ,100000,density=.00001,sparse=True)
        sage: matrix_plot(A,marker=',')

comment:2 Changed 13 years ago by Jason Grout

Cc: Mike Hansen William Stein William Cauchois added

(To those I'm adding as CC): if you have time, could you review this ticket? This is a simple change that makes plotting sparse matrices possible. Currently, it is very, very slow or is not even really possible to plot large sparse matrices because Sage immediately converts the matrix to a dense matrix.

comment:3 Changed 13 years ago by Jason Grout

Cc: Robert Bradshaw added

It would be really great if this was reviewed in time for the Monday deadline for 4.1.1. This is a simple change that makes plotting sparse matrices possible. Currently, it is very, very slow or is not even really possible to plot large sparse matrices because Sage immediately converts the matrix to a dense matrix.

comment:4 Changed 13 years ago by David Joyner

This installs fine (amd64 ubuntu 9.04, sage 4.1.1.alpha0) and I'm running tests now. However, why is it that

sage: B = random_matrix(ZZ, 10, 20, density=.4, sparse=True, x = 10)
sage: matrix_plot(B, cmap='hsv').show(axes=False)

returns a ble-and white scatterplot, but

sage: C = random_matrix(ZZ, 10, 20, x = 10)
sage: matrix_plot(C, cmap='hsv').show(axes=False)

returns a multi-colored plot? The docstring indicates that the colors plotted indicate the relative difference in sizes between the matrix entries. This seems to be incorrect, unless I am missing something, in the sparse case. Should a comment to this effect be added to the docstring?

Changed 13 years ago by Jason Grout

apply on top of previous patch

comment:5 Changed 13 years ago by Jason Grout

Good point; the docstring should be updated. I've attached a small patch that updates the docstring. Can you review this docstring change?

comment:6 Changed 13 years ago by David Joyner

Summary: [with patch, needs review] plotting sparse matrices converts the matrix to a dense matrix[with patch, positive review] plotting sparse matrices converts the matrix to a dense matrix

Yes, looks good and passes sage -testall (intel macbook, OS 10.4.11) except for

        sage -t  "devel/sage/sage/parallel/decorate.py"
        sage -t  "devel/sage/sage/symbolic/expression.pyx"

They seem unrelated. As far as I am concerned, this gets a positive review.

comment:7 Changed 13 years ago by Minh Van Nguyen

Merged in: Sage 4.1.1.rc0
Resolution: fixed
Reviewers: David Joyner
Status: newclosed

Merged both patches.

Note: See TracTickets for help on using tickets.