Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Return empty sparse from a mex file
Date: Fri, 30 Oct 2009 17:46:03 +0000 (UTC)
Organization: Boeing
Lines: 9
Message-ID: <hcf8or$jrc$1@fred.mathworks.com>
References: <hc3s2q$fbd$1@fred.mathworks.com> <hcf36n$83n$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256924763 20332 172.30.248.35 (30 Oct 2009 17:46:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 30 Oct 2009 17:46:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:581351


"Tim Davis" <davis@cise.ufl.edu> wrote in message <hcf36n$83n$1@fred.mathworks.com>...
> 
> You are right to be troubled; spok is correctly telling you that you have constructed an invalid matrix.  That matrix, with a NULL pointer for mxGetPr, will break MATLAB somewhere.  Not everywhere, so it may seem fine, but it is not valid.
> 
> nnzmax(A) must never be zero, even if nnz(A) is zero.  nnzmax(A)>=1 must always hold.

FYI added info just to complete this thread. There is a difference between full matrices and sparse matrices on this point. If you examine the pr of a full empty matrix, it can be NULL (0), whereas for a sparse matrix it always points to a valid memory location.

James Tursa