Inconsistent sparse/full behaviour (BUG?)

Inconsistent sparse/full behaviour (BUG?)

Post by Loren Shu » Sat, 15 Jun 1996 04:00:00



In article


Quote:> Consider the following short program:

> *************************

> X=reshape([1:9],3,3) % Create a 3 by 3 matrix X

> % Part 1
> A=X;                 % make a copy, A
> B=sparse(X);         % and make a sparse copy, B
> kill=([1 3]);

> A(kill,:)=[];        % Remove rows from A
> B(kill,:)=[];        % And from B
> A                    % Look at the result for A
> full(B)              % And for B
> kill                 % Look at vector `kill'. It's changed

> % Part 2
> A=X;
> B=sparse(X);         % Restore matrices
> kill=([1 3]);        % Restore `kill' vector

> B(kill,:)=[];        % Remove rows from B
> A(kill,:)=[];        % And from A
> A                    % Look at result for A
> full(B)              % And for B. It's different
> kill                 % Look at vector `kill'. It's changed

> ***********************
> This returns the following:-

> X =     1     4     7
>         2     5     8
>         3     6     9

> (Part 1 starts here)
> A =     2     5     8

> ans =   2     5     8

> kill =  1     2

> (Part 2 starts here)
> A =     3     6     9

> ans =   2     5     8

> kill =  1     2

> Note that the results in part 1 and part 2 are different. In part 2,
> different rows have been removed from A than in part 1.

> In short, the command

> X(v,:)=[];

> where v is a vector, and X is a matrix causes the rows whose
> indices correspond to the elements of v to be removed from X, as
> expected.

> However, in addition to this v will also change if X is sparse.

> I have two questions:-

> 1) Since v is not used as an output then why does it change?
> 2) Why is it changing conditional on X being sparse?

v shouldn't be changing. This will be fixed in MATLAB 5.



     24 Prime Park Way                http://www.mathworks.com
     Natick, MA 01760-1500                   ftp.mathworks.com
==== Tel: 508-647-7000 ===================== Fax: 508-647-7001 ====

 
 
 

Inconsistent sparse/full behaviour (BUG?)

Post by Steven J Baine » Sat, 15 Jun 1996 04:00:00


Consider the following short program:

*************************

X=reshape([1:9],3,3) % Create a 3 by 3 matrix X

% Part 1
A=X;                 % make a copy, A
B=sparse(X);         % and make a sparse copy, B
kill=([1 3]);

A(kill,:)=[];        % Remove rows from A
B(kill,:)=[];        % And from B
A                    % Look at the result for A
full(B)              % And for B
kill                 % Look at vector `kill'. It's changed

% Part 2
A=X;
B=sparse(X);         % Restore matrices
kill=([1 3]);        % Restore `kill' vector

B(kill,:)=[];        % Remove rows from B
A(kill,:)=[];        % And from A
A                    % Look at result for A
full(B)              % And for B. It's different
kill                 % Look at vector `kill'. It's changed

***********************
This returns the following:-

X =     1     4     7
        2     5     8
        3     6     9

(Part 1 starts here)
A =     2     5     8

ans =   2     5     8

kill =  1     2

(Part 2 starts here)
A =     3     6     9

ans =   2     5     8

kill =  1     2

Note that the results in part 1 and part 2 are different. In part 2,
different rows have been removed from A than in part 1.

In short, the command

X(v,:)=[];

where v is a vector, and X is a matrix causes the rows whose
indices correspond to the elements of v to be removed from X, as
expected.

However, in addition to this v will also change if X is sparse.

I have two questions:-

1) Since v is not used as an output then why does it change?
2) Why is it changing conditional on X being sparse?

        Cheers - Steve

------------------------------------------------------------------

Communications Research Group
Dept. of Electronics                  
University of York
Heslington
York  
YO1 5DD
ENGLAND      
------------------------------------------------------------------
The opinions given here are my personal opinions.
------------------------------------------------------------------

 
 
 

1. inconsistent behaviour of bitand

I have noticed what appears to be inconsistent behaviour with bitadd.

z=999
q=uint32(hex2dec('7f000000'))

format hex
z
q

bitand(z,q)  OK
bitand([z z],q) error, only supported for unsigned int data types
bitand([z z],[z z]) OK
bitand(z,[q q]) OK
bitand[[z z],[q q]] error, non scalar operands must have same type

The help information seems to need updating!

z is a double and the rules for scalars and matrices of other types
than unsigned integer appear to be different but undocumented.

Comments?

Brian

--

phone +47 55 99 68 74                 (((                  Postboks 7190
fax   +47 55 99 69 70                2oooS                 N-5020 Bergen
home  +47 55 13 78 49                HYDRO                        Norway

2. can't find network path

3. Inconsistent/bad behavior with mxCalloc/mxFree

4. HELP

5. inconsistent behavior with "eval"

6. FAQ (Part 2 of 2)

7. sparse vs full

8. BIND vs DNS Commander

9. Primitive operations on sparse Matrix done on full copy??

10. Quirky (buggy) behavior with sparse matrices

11. Odd behavior with sparse

12. BUG??-Odd desktop behavior

13. sparse matrix bug