matrix-market-attoparsec

Parsing and serialization functions for the NIST Matrix Market format

https://github.com/ocramz/matrix-market-attoparsec

Version on this page:0.1.0.5
LTS Haskell 22.13:0.1.1.3
Stackage Nightly 2024-03-14:0.1.1.3
Latest on Hackage:0.1.1.3

See all snapshots matrix-market-attoparsec appears in

BSD-2-Clause licensed by Marco Zocca
Maintained by zocca marco gmail
This version can be pinned in stack with:matrix-market-attoparsec-0.1.0.5@sha256:9b637f3d796751e123f27377021f2db5d6f3b9ef614d830ab5366cf82f3fd2e9,2090

Module documentation for 0.1.0.5

matrix-market-attoparsec

Build Status

Attoparsec parser for the NIST Matrix Market format [1].

The library also contains functions for serializing to text file, and the read/write/read roundtrip works as expected.

User guide

The module Data.Matrix.MatrixMarket exports the user interface:

readMatrix :: FilePath -> IO (Matrix S.Scientific)

readArray :: FilePath -> IO (Array S.Scientific)

writeMatrix :: Show a => FilePath -> Matrix a -> IO ()

writeArray :: Show a => FilePath -> Array a -> IO ()  

The first two functions contain the parsing logic, and make use of scientific for parsing numerical data in scientific notation.

Naming convention

We follow the MatrixMarket format definitions, by which a “Matrix” is sparse and stored in coordinate format (row, column, entry), whereas an “Array” is a dense grid of numbers, stored in column-oriented form. Algebraic vectors, such as the right-hand sides of equation systems, are stored as n-by-1 Arrays.

Testing

test/LibSpec.hs contains a simple read/write/read sanity test for the included Matrix Marked data files (fidapm05.mtx and fidapm05_rhs1.mtx):

m0 <- readMatrix fname   -- load original
writeMatrix ftemp m0     -- save as temp
m1 <- readMatrix ftemp   -- load temp
m0 `shouldBe` m1         -- compare temp with original

References

[1] http://math.nist.gov/MatrixMarket/

Changes

0.2.0.1

Added MatrixMarket module from accelerate-examples SMVM