Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Return empty sparse from a mex file
Date: Mon, 26 Oct 2009 12:18:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <hc441q$2qq$1@fred.mathworks.com>
References: <hc3s2q$fbd$1@fred.mathworks.com> <hc3uqt$dq$1@fred.mathworks.com> <hc40j6$o3d$1@fred.mathworks.com> <hc42dq$ke8$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256559482 2906 172.30.248.37 (26 Oct 2009 12:18:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 26 Oct 2009 12:18:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1935580
Xref: news.mathworks.com comp.soft-sys.matlab:580056


Ok, I added the line

    if (actual_number_of_nonzeros==0)
        actual_number_of_nonzeros = 1;

before reallocating Pr and Ir. It works fine now, although it seem a little odd to me. Thanks again for your comments!
/Arne

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <hc42dq$ke8$1@fred.mathworks.com>...
> Actually I just check, it seems nzmax is never set to 0 by Matlab
> 
> >> s=sparse([],[],[],1,1,0)
> >> nzmax(s)
> 
> ans =
> 
>      1
> 
> So I would Realloc Pr and Ir with *1* element, set nzmax to 1, and fill Jc with zeros (as you did).
> 
> Bruno