Volume 9, Issue 2

Articles
Tricks of the Trade
In and Out
Trott's Corner
New Products
New Publications
Calendar
News Bulletins
New Resources
Classifieds

Editorial Policy
Staff
Submissions
Subscriptions
Back Issues
Contact Information

In and Out

Sparse Matrices

Q: One can use LinearSolve to solve a system of linear equations. However, I work with very large matrices having only five nonzero diagonals. Are there efficient methods for dealing with such matrices?

A: Daniel Lichtblau (danl@wolfram.com) answers: If you require only machine arithmetic, this can be done effectively using the built-in sparse linear solver in Version 5. Here is an example.

Create a diagonally-dominant random sparse -diagonal matrix using SparseArray.

With and , we obtain a sparse array with nonzero elements.

Use Normal to obtain the ordinary array corresponding to a sparse array object.

Produce a pentadiagonal sparse matrix of dimension 2000.

Solve for a random right-hand side.

Compare with the time required for an ordinary (nonsparse) matrix.

Check that the solutions agree using (for matrices, gives the maximum singular value of ).