From: Matt J on
"Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <heepeh$hq1$1(a)fred.mathworks.com>...
> "Matt " <xys(a)whatever.com> wrote in message <heeoar$798$1(a)fred.mathworks.com>...
>
> >
> > If you're willing, the following revised tests should give the correct results. Otherwise, it will default with a warning to the normal sparse indexing behavior
> >
>
> I sure will, but I cannot take a closer look before Wednesday for many reasons. I'm sure you will make the indexing code right Matt as you seems to be very keen on oop.
======





I carried on with it, and it seems to be doing the job.



>> A=sparse(100000,100000,1), B=RobustSparseDouble(A),

A =

(100000,100000) 1


B=

(100000,100000) 1




>> whos A B
Name Size Bytes Class Attributes

A 100000x100000 400136 double sparse
B 100000x100000 400084 RobustSparseDouble




>> A(logical(A))=2, %Wrong

A =

(65408,14101) 2
(100000,100000) 1




>> B(logical(B))=2, %RIGHT!!!

B=

(100000,100000) 2



I also took care of that pesky problem that native MATLAB sparse matrices have of not being able to interact with singles and other data types:


%ANNOYING....
>> y=A*single(rand(100000,1)); whos y
??? Error using ==> mtimes
Sparse single arrays are not supported.


%BETTER!!!!!!!
>> y=B*single(rand(100000,1)); whos y
Name Size Bytes Class Attributes

y 100000x1 800000 double



I guess I'll do seem clean-up then, and put it on the FEX.
From: Bruno Luong on
Great!!! That's will make the indexing much more intuitive. Thanks.

Bruno
From: Bruno Luong on
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hgh3t7$c3m$1(a)fred.mathworks.com>...


>
> >> A(logical(A))=2, %Wrong
>
> A =
>
> (65408,14101) 2
> (100000,100000) 1
>

This bug still holds in 2010A prerelease. ;-(

Bruno
From: Bruno Luong on
RobustSparse works well so far:

>> B(end) % RobustSparse

ans =

(1,1) 1

>> A(end) % Matlab sparse
??? Maximum variable size allowed by the program is exceeded.

>> >> B(end+1)=1 % RobustSparse

B =

(100000,100000) 1
(1,100001) 1

>> A(end+1)=1 % Matlab sparse
??? In an assignment A(I) = B, a matrix A cannot be resized.

Bruno
From: Bruno Luong on
Matt, calling setspase/getsparse on RosbustSparse does not work.

>> setsparse(B,1e5,1e5,10)
??? Error using ==> setspvalmex
First input argument must be a sparse matrix.

Error in ==> spsubsasgn at 120
S = setspvalmex(S, r(:), c(:), v(:));

Error in ==> setsparse at 45
[vout{:}] = spsubsasgn(varargin{:});

>> setsparse(A,1e5,1e5,10)

ans =

(100000,100000) 10

This is because Matlab API mxIsSparse() return 0 for RobustSparse object. We can make it works, but it requires a change either on your side or mine. Do you accommodate from your side or I do from my side?

Bruno