octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sparse indexed assignment broken?


From: Jarno Rajahalme
Subject: sparse indexed assignment broken?
Date: Fri, 23 Apr 2010 00:33:23 -0700

Hi,

Trying out my earlier Octave code with the development branch I ran into messed 
up sparse matrices. I have isolated the problem to the following code:

clear spmx
spmx = sparse(4,1);
spmx(4,1) = 1
spmx(3,1) = 2
spmx(2,1) = 3

save test_spmx.oct spmx
load test_spmx.oct


When executed line by line, I get:

octave:1> clear spmx
octave:2> spmx = sparse(4,1);
octave:3> spmx(4,1) = 1
spmx =

Compressed Column Sparse (rows = 4, cols = 1, nnz = 1 [25%])

  (4, 1) ->  1

octave:4> spmx(3,1) = 2
spmx =

Compressed Column Sparse (rows = 4, cols = 1, nnz = 2 [50%])

  (3, 1) ->  2
  (3, 1) ->  2

octave:5> spmx(2,1) = 3
spmx =

Compressed Column Sparse (rows = 4, cols = 1, nnz = 3 [75%])

  (2, 1) ->  3
  (2, 1) ->  3
  (1, 1) ->  2.1539e-314

octave:6> save test_spmx.oct spmx
octave:7> load test_spmx.oct
error: load: invalid sparse matrix: row indices must appear in ascending order 
in each column
octave:7> 

At this point, the saved file looks like this:

# Created by Octave 3.3.51+, Fri Apr 23 00:21:36 2010 PDT <address@hidden>
# name: spmx
# type: sparse matrix
# nnz: 3
# rows: 4
# columns: 1
2 1 3
2 1 3
1 1 2.154517066753669e-314


This is the same as printed after the last assignment above. But the contents 
has only the last assignment correctly, others have been replaced with 
incorrect indices and values.

I did hg pull; hg update to make sure I have the latest code. Running on OSX, 
64-bit (but without --enable-64). I'll provide more details if need be.

Regards,

  Jarno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]