Copyright | (c) Marco Zocca 2017 |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | zocca marco gmail |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Attoparsec parser and serializer for the NIST MatrixMarket format. The parser logic originally appeared in `accelerate-examples` and it is reused here (courtesy of T.McDonell and the accelerate
developers) with some amendments.
In this version:
- ) Numbers are represented with Scientific notation instead of floating point
- ) Parsing rules are a bit relaxed to accommodate various whitespace corner cases
- readMatrix :: FilePath -> IO (Matrix Scientific)
- readArray :: FilePath -> IO (Array Scientific)
- writeMatrix :: Show b => FilePath -> Matrix b -> IO ()
- writeArray :: Show a => FilePath -> Array a -> IO ()
- data Matrix a
- data Array a
- data Format
- = Coordinate
- | Array
- data Structure
- nnz :: Matrix t -> Int
- dim :: Matrix t -> (Int, Int)
- numDat :: Matrix t -> Int
- dimArr :: Array t -> (Int, Int)
- numDatArr :: Array a -> Int
- data ImportError
Load
readMatrix :: FilePath -> IO (Matrix Scientific) Source #
Load a matrix (sparse, i.e. in Coordinate format) from file
readArray :: FilePath -> IO (Array Scientific) Source #
Load a dense matrix (i.e. a matrix or vector in Array format) from file
Save
writeMatrix :: Show b => FilePath -> Matrix b -> IO () Source #
Serialize a sparse matrix in Coordinate format
writeArray :: Show a => FilePath -> Array a -> IO () Source #
Serialize a dense matrix in Array format
Sparse matrix in coordinate form (row, column, entry) NB: indices are 1-based i.e. A(1,1) is the top-left entry of matrix A
Array, i.e. a DENSE matrix (also used to represent vectors as n-by-1 matrices)
Specifies either sparse or dense storage. In sparse ("coordinate") storage, elements are given in (i,j,x) triplets for matrices (or (i,x) for vectors). Indices are 1-based, so that A(1,1) is the first element of a matrix, and x(1) is the first element of a vector.
In dense ("array") storage, elements are given in column-major order.
In both cases, each element is given on a separate line.
Specifies any special structure in the matrix. For symmetric and hermitian matrices, only the lower-triangular part of the matrix is given. For skew matrices, only the entries below the diagonal are stored.
Helpers
Matrix-related
numDat :: Matrix t -> Int Source #
Length of data vector internal to the Matrix; this is _not_ necessarily the actual number of matrix entries because symmetric entries are not stored
Array-related
numDatArr :: Array a -> Int Source #
Length of data vector internal to the Array; this is _not_ necessarily the actual number of matrix entries because symmetric entries are not stored