Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Smaller matrix causes mldivide to fail (out of memory)

Subject: Smaller matrix causes mldivide to fail (out of memory)

From: Jean-Philippe

Date: 30 May, 2012 21:09:21

Message: 1 of 3

Hi,

I want to execute the following code which always worked till now. I tried 2 differents cases where one matrix is smaller than the other. The first case, with the smaller matrix, fails with an out of memory error, while the second case execute successfully!

1. m = 307785 (nnz(W) = 8290840, numel(W) = 94731606225) -> FAIL
2. m = 1064960 (nnz(W) = 28163332, numel(W) = 1134139801600) -> OK

W = sparse(Y,X,V,m,m);
D = spdiags(sum(W, 2),0,m,m);
P = D\W;

Any idea why this is happening? Thank you!

Subject: Smaller matrix causes mldivide to fail (out of memory)

From: Bruno Luong

Date: 30 May, 2012 23:17:31

Message: 2 of 3

I have no problem with matrix similar the one that causes you trouble:

>> m=307785

m =

      307785

>> nnzW=8290840;
>> W=sprand(m,m,nnzW/m^2);
>> nnz(W)

ans =

     8290486

>> D = spdiags(sum(W, 2),0,m,m);
>> P = D\W;


Note that you are better build the transpose of W ans work column-wise rather than row-wise. You could also build directly inv(D) rather than D.

 Bruno

Subject: Smaller matrix causes mldivide to fail (out of memory)

From: Roger Stafford

Date: 30 May, 2012 23:39:08

Message: 3 of 3

"Jean-Philippe" wrote in message <jq62a1$ar7$1@newscl01ah.mathworks.com>...
> Hi,
>
> I want to execute the following code which always worked till now. I tried 2 differents cases where one matrix is smaller than the other. The first case, with the smaller matrix, fails with an out of memory error, while the second case execute successfully!
>
> 1. m = 307785 (nnz(W) = 8290840, numel(W) = 94731606225) -> FAIL
> 2. m = 1064960 (nnz(W) = 28163332, numel(W) = 1134139801600) -> OK
>
> W = sparse(Y,X,V,m,m);
> D = spdiags(sum(W, 2),0,m,m);
> P = D\W;
>
> Any idea why this is happening? Thank you!
- - - - - - - - - - -
  If even one of your rows in W has all zeros, then D is singular. On my version of 'mldivide' it surrenders and puts 'inf' everywhere, filling up P completely. Could that be what has happened to you in the failed case? P would have over 94 billion nonzero elements in that case.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us