Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Return empty sparse from a mex file
Date: Mon, 26 Oct 2009 10:49:01 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 17
Message-ID: <hc3uqt$dq$1@fred.mathworks.com>
References: <hc3s2q$fbd$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256554141 442 172.30.248.38 (26 Oct 2009 10:49:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 26 Oct 2009 10:49:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:580033


"Arne Vagren" <arne.vagren@gmail.com> wrote in message <hc3s2q$fbd$1@fred.mathworks.com>...
> Hello!
> 
> I'm trying to assemble and return a sparse matrix in a mex-function. At the end of the function, I try to correct for the actual number of non-zero entries in the following way (where Btu = mxGetPr(plhs[0]);):
> 
> "nbytes = actual_number_of_nonzeros*sizeof(*Btu);
>  newptr = mxRealloc(Btu,nbytes);     
>  mxSetPr(plhs[0], newptr); 
>         
>  nbytes = actual_number_of_nonzeros*sizeof(*ir);
>  newptr = mxRealloc(ir, nbytes);
>  mxSetIr(plhs[0], newptr);"
> 

There is a possibly problem in Jc array, which you didn't provide information.

Bruno