MyNixOS website logo
Description

Parsing and serialization functions for the NIST Matrix Market format.

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 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.

As of version 0.1.1 there are also intermediate functions readMatrix', readArray', writeMatrix' and writeArray' 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" 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

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

Metadata

Version

0.1.1.3

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows