-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Parsing and serialization functions for the NIST Matrix Market format
--   
--   Parsing and serialization functions for the NIST Matrix Market format.
@package matrix-market-attoparsec
@version 0.1.0.8


-- | 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 <tt>accelerate</tt>
--   developers) with some amendments.
--   
--   In this version:
--   
--   <ul>
--   <li>) Numbers are represented with Scientific notation instead of
--   floating point</li>
--   <li>) Parsing rules are a bit relaxed to accommodate various
--   whitespace corner cases</li>
--   </ul>
module Data.Matrix.MatrixMarket

-- | Load a matrix (sparse, i.e. in Coordinate format) from file
readMatrix :: FilePath -> IO (Matrix Scientific)

-- | Load a dense matrix (i.e. a matrix or vector in Array format) from
--   file
readArray :: FilePath -> IO (Array Scientific)

-- | Serialize a sparse matrix in Coordinate format
writeMatrix :: Show b => FilePath -> Matrix b -> IO ()

-- | Serialize a dense matrix in Array format
writeArray :: Show a => FilePath -> Array a -> IO ()

-- | 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
data Matrix a
RMatrix :: (Int, Int) -> Int -> Structure -> [(Int, Int, a)] -> Matrix a
CMatrix :: (Int, Int) -> Int -> Structure -> [(Int, Int, Complex a)] -> Matrix a
PatternMatrix :: (Int, Int) -> Int -> Structure -> [(Int32, Int32)] -> Matrix a
IntMatrix :: (Int, Int) -> Int -> Structure -> [(Int32, Int32, Int)] -> Matrix a

-- | Array, i.e. a DENSE matrix (also used to represent vectors as n-by-1
--   matrices)
data Array a
RArray :: (Int, Int) -> Structure -> [a] -> Array a
CArray :: (Int, Int) -> Structure -> [Complex a] -> Array a

-- | 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.
data Format
Coordinate :: Format
Array :: Format

-- | 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.
data Structure
General :: Structure
Symmetric :: Structure
Hermitian :: Structure
Skew :: Structure

-- | helpers
--   
--   Number of matrix nonzeros
nnz :: Matrix t -> Int

-- | Matrix size : number of rows, number of columns
dim :: Matrix t -> (Int, Int)

-- | Length of data vector internal to the Matrix; this is _not_
--   necessarily the actual number of matrix entries because symmetric
--   entries are not stored
numDat :: Matrix t -> Int

-- | Array size : number of rows, number of columns
dimArr :: Array t -> (Int, Int)

-- | Length of data vector internal to the Array; this is _not_ necessarily
--   the actual number of matrix entries because symmetric entries are not
--   stored
numDatArr :: Array a -> Int
data ImportError
