Slicing in sparse
Kim Hansen
kimhanse at gmail.com
Wed Dec 5 05:07:19 CST 2007
On Dec 4, 2007 9:51 PM, John W. Eaton <jwe at bevo.che.wisc.edu> wrote:
> On 4-Dec-2007, Kim Hansen wrote:
>
> | I don't really care about what the matrices do when expanded with a
> | single index, but I think full and sparse should do the same in all
> | instances where they are expanded with two indices.
> |
> | The only case where my test fails now is:
> |
> | octave:20> x=sparse(ones(2)), x([],:)=2
> | x =
> |
> | Compressed Column Sparse (rows = 2, cols = 2, nnz = 4)
> |
> | (1, 1) -> 1
> | (2, 1) -> 1
> | (1, 2) -> 1
> | (2, 2) -> 1
> |
> | x =
> |
> | Compressed Column Sparse (rows = 2, cols = 2, nnz = 0)
> |
> |
> | octave:21>
>
> Please try the following patch. Note that while looking at this, I
> think I found another inconsistency in Matlab's behavior (see the
> comment in the patch).
If I enable the code you have commented out with #if/#endif then all
tests works, without it we still get inconsistent behaviour between
full and sparse even when we use 2 indices. I don't think we should
allow that as Octave has automatic transformation from sparse to full.
An other example of the inconsistency is:
octave:2> x=sparse(ones(2,0)), x(3,:)=2
x = Compressed Column Sparse (rows = 2, cols = 0, nnz = 0)
x = Compressed Column Sparse (rows = 2, cols = 0, nnz = 0)
octave:3> x=ones(2,0), x(3,:)=2
x = [](2x0)
x = [](3x0)
octave:4>
--
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437 -- Mobil: 3091 2437
More information about the Bug-octave
mailing list