[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Importing a sparse matrix to Octave
From: |
Jaroslav Hajek |
Subject: |
Re: Importing a sparse matrix to Octave |
Date: |
Fri, 24 Jul 2009 21:30:45 +0200 |
On Fri, Jul 24, 2009 at 9:24 PM, John W. Eaton<address@hidden> wrote:
> On 24-Jul-2009, Chong Yidong wrote:
>
> | "John W. Eaton" <address@hidden> writes:
> |
> | > # name: s
> | > # type: sparse complex matrix
> | > # nnz: 70
> | > # rows: 10
> | > # columns: 10
> | > 1 1 (0,1.145193428282681)
> | > 2 1 (0,0.5663270399606521)
> | > 3 1 (0,0.007270909230606313)
> | > 4 1 (0,0.1480797228543177)
> | > 5 1 (0,0.2478795113138578)
> | > ...
> | >
> | > The first column is the row index, the second is the column index, and
> | > the third is the corresponding value (real,complex). The number of
> | > elements must match the value of NNZ. To load this file into Octave,
> | > use the load command.
> |
> | Thanks. However, this method doesn't seem to work properly:
> |
> | # name: s
> | # type: sparse complex matrix
> | # nnz: 3
> | # rows: 10
> | # columns: 10
> | 1 1 (0,1.14)
> | 3 6 (0,0.56)
> | 6 2 (0.1,0.0)
> |
> | octave:1> load "foo.dat"
> | octave:2> s
> | s =
> |
> | Compressed Column Sparse (rows = 10, cols = 10, nnz = 3)
> |
> | (1, 1) -> 0.00000 + 1.14000i
> | (3, 2) -> 0.00000 + 0.56000i
> | (6, 2) -> 0.10000 + 0.00000i
> |
> | The second line seems to be assigned to the wrong entry. Is this a bug?
> | I'm using Octave 3.0.1, as distributed by Ubuntu.
>
> Oops, there was one detail I wasn't aware of. You must group the
> elements by column. So change your file to
>
> # name: s
> # type: sparse complex matrix
> # nnz: 3
> # rows: 10
> # columns: 10
> 1 1 (0,1.14)
> 6 2 (0.1,0.0)
> 3 6 (0,0.56)
>
> and I think it should work.
>
No, not yet. A futher requirement is that the row indices should be
sorted (for a certain column index).
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- Importing a sparse matrix to Octave, Chong Yidong, 2009/07/24
- Importing a sparse matrix to Octave, John W. Eaton, 2009/07/24
- Re: Importing a sparse matrix to Octave, Chong Yidong, 2009/07/24
- Re: Importing a sparse matrix to Octave, John W. Eaton, 2009/07/24
- Re: Importing a sparse matrix to Octave,
Jaroslav Hajek <=
- Re: Importing a sparse matrix to Octave, John W. Eaton, 2009/07/24
- Re: Importing a sparse matrix to Octave, Chong Yidong, 2009/07/24
- Re: Importing a sparse matrix to Octave, John W. Eaton, 2009/07/24
- Re: Importing a sparse matrix to Octave, John W. Eaton, 2009/07/29
- Re: Importing a sparse matrix to Octave, Carlo de Falco, 2009/07/24
- Re: Importing a sparse matrix to Octave, Chong Yidong, 2009/07/24