[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ASCII file format for sparse matrices?
From: |
Rui Maciel |
Subject: |
Re: ASCII file format for sparse matrices? |
Date: |
Fri, 13 May 2011 02:13:26 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 |
On 05/12/2011 09:50 PM, Jordi Gutiérrez Hermoso wrote:
On 12 May 2011 15:33, Rui Maciel<address@hidden> wrote:
Does Octave support any ASCII file format to import/export sparse matrices?
Yes, it's the default format. Try
x = sprand(5,5,0.2)
save x x
and you can now inspect in an editor file named "x" to see how Octave saved it
Thanks for the help, Jordi. I've ran your example and a file was saved
in a "dictionary of keys" sort of format. Nice.
Yet, I've stumbled on what appears to be a problem. Although the file
format appears to follow the "dictionary of keys" format, the input
routine fails to successfully import any matrix whose coefficients
aren't ordered according to the compressed column format. So, for
example, considering the following random matrix generated by octave:
# Created by Octave 3.2.4, Fri May 13 02:09:48 2011 WEST <address@hidden>
# name: K
# type: sparse matrix
# nnz: 6
# rows: 5
# columns: 5
2 1 0.6120845834944717
2 2 0.5161747681939882
4 2 0.9411864619881111
2 3 0.5464955826864553
2 5 0.6005530554138011
4 5 0.8149565265346684
And now, if the fields are reordered in the compressed row order:
# Created by Octave 3.2.4, Fri May 13 02:09:48 2011 WEST <address@hidden>
# name: K
# type: sparse matrix
# nnz: 6
# rows: 5
# columns: 5
2 1 0.6120845834944717
2 2 0.5161747681939882
2 3 0.5464955826864553
2 5 0.6005530554138011
4 2 0.9411864619881111
4 5 0.8149565265346684
If that file is loaded into octave, octave only manages to generate the
following matrix.
# Created by Octave 3.2.4, Fri May 13 02:12:02 2011 WEST <address@hidden>
# name: K
# type: sparse matrix
# nnz: 6
# rows: 5
# columns: 5
2 1 0.6120845834944717
2 2 0.5161747681939882
2 2 0.5464955826864553
2 2 0.6005530554138011
4 2 0.9411864619881111
4 5 0.8149565265346684
So, does this file format only support compressed-column format ordering
or is there a bug with the file importing routine?
Thanks in advance,
Rui Maciel
- ASCII file format for sparse matrices?, Rui Maciel, 2011/05/12
- Re: ASCII file format for sparse matrices?, Jordi Gutiérrez Hermoso, 2011/05/12
- Re: ASCII file format for sparse matrices?, David Bateman, 2011/05/12
- Re: ASCII file format for sparse matrices?,
Rui Maciel <=
- Re: ASCII file format for sparse matrices?, David Bateman, 2011/05/13
- Re: ASCII file format for sparse matrices?, Rui Maciel, 2011/05/13
- Re: ASCII file format for sparse matrices?, david moloney, 2011/05/13
- Re: ASCII file format for sparse matrices?, Jordi Gutiérrez Hermoso, 2011/05/13
- Re: ASCII file format for sparse matrices?, Rui Maciel, 2011/05/13
Re: ASCII file format for sparse matrices?, Rui Maciel, 2011/05/12
Re: ASCII file format for sparse matrices?, Rik, 2011/05/24