The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: sparse matrix bug
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
John D'Errico

Posts: 5
Registered: 12/7/04
sparse matrix bug
Posted: Jun 18, 1996 11:50 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

An interesting little bug I tripped over in Matlab on the Sun
today. It is also in the mac version.

Matlab is supposed to work with sparse matrices and full matrices
together, leaving the result as a sparse matrix.

For example, when A is sparse and B is full,


C is supposed to be sparse. This is good.


C is still supposed to be sparse. Still good.

Consider the following expression though.

C = A(:,ind) - B*(R1\R2);

A and B are sparse. ind is an index vector (full). R1 and R2
are full. C should be sparse, since it is a sum of terms,
all of which should be sparse.

NOT so. At least not on a Mac running 4.2c1 or on a sparc5.

I can fix it, by forcing R1 and R2 to be sparse, but this
cost me some headaches. When I later tried to use C, which is
huge when full, it crashed the sparc20 I was running it on
remotely with memory problems. It did not return cleanly. I
tried it again on my own sparc5, and it quickly crashed that
system too. No out of memory message. Just reboot.

If you do not believe me, try out the following code.
Check out b after it is computed. Full. Not sparse.

John D'Errico,

a = sprandn(100,50,0.1);
c = sprandn(10,50,0.05);








Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.