Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Suppose i have matrix of size 1000*1000 with 70% sparsity. I am performing some multiplication, inverse operations upon it. While making calculations, does MATLAB make checks to see if matrix is sparse and perform operations accordingly(like ignoring multiplications if one of elements is zero) or do we need to explicitly mention it. What are possible ways to do so.

Suppose I have sparse matrix A. I want to get inverse of it. Usually I will use function inv(A). Since matrix is sparse, I might use following operations

sparse_A = sparse(A);
inv_sparse_A = inv(sparse_A);
inv_A = full(inv_sparse_A);
share|improve this question

1 Answer 1

The inverse of a sparse matrix is usually dense (try inverting a tridiagonal matrix sometime...), so forget about hoping that inv(sparse(something)) is sparse. If all you want is to solve a sparse linear system, it might be better to use lu() instead (or chol() if the matrix is symmetric positive definite); it's about as convenient as having an inverse without needing to worry about fill-in.

share|improve this answer
    
besides inverse, for other operations like multiplication can you answer my question, please? –  Maddy.Shik Apr 19 '11 at 12:10
    
@Maddy: Multiplication by what? –  J. M. Apr 19 '11 at 12:15
1  
@Maddy: Matrix multiplication of two sparse matrices does produce a sparse matrix. The sparsity of operations on sparse matrices is fully documented in the Matlab help: mathworks.com/help/techdoc/math/f6-8856.html –  Rahul Apr 19 '11 at 13:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.