Importing a sparse matrix to Octave

John W. Eaton jwe at octave.org
Fri Jul 24 20:17:49 CDT 2009


On 24-Jul-2009, Chong Yidong wrote:

| "John W. Eaton" <jwe at octave.org> writes:
| 
| > On 24-Jul-2009, Jaroslav Hajek wrote:
| >
| > | No, not yet. A futher requirement is that the row indices should be
| > | sorted (for a certain column index).
| >
| > Is that necessary?  For example, loading
| >
| > # name: s
| > # type: sparse matrix
| > # nnz: 5
| > # rows: 10
| > # columns: 10
| > 1 1 1
| > 6 2 6
| > 4 2 4
| > 5 2 5
| > 3 6 3
| >
| > appears to work.
| 
| No, Jaroslav's right.  If the indices are out of order, some kind of
| corruption takes place that prevents some matrix operations.  With the
| above file:
| 
| octave:1> load "foo.dat"
| octave:2> [L,U] = splu(s)
| error: SparseLU::SparseLU symbolic factorization failed
| warning: Invalid matrix type
| 
| If I re-order the file as
| 
| # name: s
| # type: sparse matrix
| # nnz: 5
| # rows: 10
| # columns: 10
| 1 1 1
| 4 2 4
| 5 2 5
| 6 2 6
| 3 6 3
| 
| then the LU factorization proceeds without an error.

OK.  Then I think we should either issue a warning if the indices are
not ordered properly, or sort them so they are.

Thanks,

jwe


More information about the Help-octave mailing list