Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Convert array of class 'int8' to sparse
Date: Tue, 24 Mar 2009 14:46:02 +0000 (UTC)
Organization: Boeing
Lines: 32
Message-ID: <gqarna$pv1$1@fred.mathworks.com>
References: <gfhh6c$dvr$1@fred.mathworks.com> <gq9bg5$3ra$1@fred.mathworks.com> <gqa8th$7j0$1@fred.mathworks.com> <gqae67$vg$1@fred.mathworks.com> <gqaqc5$l2k$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1237905962 26593 172.30.248.38 (24 Mar 2009 14:46:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 24 Mar 2009 14:46:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:527267


"James Tursa" <aclassyguywithaknotac@hotmail.com> wrote in message <gqaqc5$l2k$1@fred.mathworks.com>...
> 
> And change your example to this:
> 
> n = 1000; 
> Sp16 = sprand(n,n,0.10);
> Sp16(Sp16>0) = 1./Sp16(Sp16>0);
> Sp16(Sp16>127) = 127;
> Sp16 = floor(Sp16);
> D16 = full(Sp16);
> D8 = int8(D16);
> Sp8 = int8tosparse(D8);
> whos
> isequal(D16,D8)
> isequal(Sp16,Sp8)
> 

Oops .. typo holdover from my small test. Try this instead:

n = 1000;
Sp16 = sprand(n,n,0.001); % <-- changed 0.10 to 0.001
Sp16(Sp16>0) = 1./Sp16(Sp16>0);
Sp16(Sp16>127) = 127;
Sp16 = floor(Sp16);
D16 = full(Sp16);
D8 = int8(D16);
Sp8 = int8tosparse(D8);
whos
isequal(D16,D8)
isequal(Sp16,Sp8)

James Tursa