Slicing in sparse

John W. Eaton jwe at bevo.che.wisc.edu
Tue Dec 4 09:48:57 CST 2007


On  4-Dec-2007, David Bateman wrote:

| With this patch in Octave I see
| 
| octave:1>  x=sparse(ones([2 0])); x(1)=2
| x =
| 
| Compressed Column Sparse (rows = 2, cols = 1, nnz = 1)
| 
|   (1, 1) ->  2
| 
| octave:2> size(x)
| ans =
| 
|    2   1
| 
| octave:3> x=ones([2 0]); x(1)=2
| error: A(I) = X: unable to resize A
| error: assignment failed, or no method for `matrix = scalar'
| error: evaluating assignment expression near line 3, column 20
| octave:3>  x=sparse(ones([2 0])); x(3,:)=2
| x = Compressed Column Sparse (rows = 3, cols = 0, nnz = 0)
| 
| octave:4>  x=ones([2 0]); x(3,:)=2
| x = [](3x0)
| octave:5>  x=sparse([]); x(3,:)=2
| x =
| 
| Compressed Column Sparse (rows = 3, cols = 1, nnz = 1)
| 
|   (3, 1) ->  2
| 
| which duplicates the matlab behavior.

I applied the patch.

Thanks,

jwe


More information about the Bug-octave mailing list