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 Download This Issue Editorial Policy Staff Submissions Subscriptions Advertising 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 builtin sparse linear solver in Version 5. Here is an example. Create a diagonallydominant 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 righthand 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 ).


About Mathematica  Download Mathematica Player Copyright © Wolfram Media, Inc. All rights reserved. 