matrix-market-attoparsec

Parsing and serialization functions for the NIST Matrix Market format

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

LTS Haskell 23.27:0.1.1.3
Stackage Nightly 2025-07-13:0.1.1.3
Latest on Hackage:0.1.1.3

See all snapshotsmatrix-market-attoparsec appears in

BSD-2-Clause licensedbyMarco Zocca
Maintained byzocca marco gmail
This version can be pinned in stack with:matrix-market-attoparsec-0.1.1.3@sha256:495f7de76088388b7eeeeddf189873c5b8401e859cf22bd7a0aa441f50aabd98,1878

Module documentation for 0.1.1.3

matrix-market-attoparsec

Build Status

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

The library also contains functions for serializing matrix data to text file.

User guide

The moduleData.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 ofscientific for parsing numerical data in scientific notation.

As of version 0.1.1 there are also intermediate functionsreadMatrix',readArray',writeMatrix' andwriteArray' that do not touch the filesystem but (de-)serialize from/to lazy ByteString.

Naming convention

We follow the MatrixMarket format definitions, by which a “Matrix” issparse and stored in coordinate format (row, column, entry), whereas an “Array” is adense 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 andfidapm05_rhs1.mtx):

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

References

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

Changes

0.1.1.2

Expose writeArray’ and readArray’ as well

0.1.1.0

Add ExportError exception

0.1.0.1

Add MatrixMarket module fromaccelerate-examples SMVM