manual:wmat
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
manual:wmat [2013/11/01 15:40] – Added a headline zenke | manual:wmat [2014/12/02 10:03] (current) – Fixes bug in example zenke | ||
---|---|---|---|
Line 25: | Line 25: | ||
**Nota bene:** Cells in the wmat file are indexed starting from 1 (unlike everywhere else in Auryn, where we adapt the C convention and start numbering arrays with 0). | **Nota bene:** Cells in the wmat file are indexed starting from 1 (unlike everywhere else in Auryn, where we adapt the C convention and start numbering arrays with 0). | ||
+ | |||
+ | ===== Loading Matrix Market files in Python for analysis ===== | ||
+ | |||
+ | In Python Auryn' | ||
+ | |||
+ | <code python> | ||
+ | from scipy.sparse import * | ||
+ | from scipy.io import mmread | ||
+ | |||
+ | A = mmread(' | ||
+ | </ | ||
+ | '' | ||
+ | |||
+ | |||
+ | |||
+ | ===== Saving Matrix Market files in Python ===== | ||
+ | |||
+ | Likewise, a structured matrix can be prepared in Python and then be loaded in Auryn. To do so, use code along the lines of the following snipped: | ||
+ | <code python> | ||
+ | from scipy.sparse import * | ||
+ | from scipy.io import mmwrite | ||
+ | |||
+ | # code which generates the matrix A | ||
+ | |||
+ | sw = csr_matrix(A) # ensures row major format in COO output | ||
+ | mmwrite(' | ||
+ | </ | ||
+ | |||
+ | The additional conversion step to a csr_matrix is necessary to ensure the correct ordering of entries in the text file. If this step is omitted, Auryn might not be able to parse the sparse matrix and will throw a runtime exception. | ||
+ | |||
+ | **Note** that in many cases SciPy will append the file extension '' |
manual/wmat.1383320446.txt.gz · Last modified: 2013/11/01 15:40 by zenke