Pure and composable Matrix Market reader and writer.
Usage example:
rm <-readMM
`liftM` readFile "my-real-matrix.mtx" :: IO (ReadMatrix
Double) case rm of Right m -> -- Do something with the matrix m Left err -> -- Report error
- data MValue a => Matrix a = MM {
- mm'data :: MatrixData a
- mm'field :: MField
- mm'symmetry :: Symmetry
- mm'comments :: [String]
- data MValue a => MatrixData a
- class (Num a, Show a) => MValue a where
- data MField
- data Symmetry
- = General
- | Symmetric
- | SkewSymmetric
- | Hermitian
- data MValue a => CM a = CM {}
- data MValue a => AM a = AM {}
- data ReadError
- type ReadMatrix a = Either ReadError (Matrix a)
- readMM :: MValue a => String -> ReadMatrix a
- dumpMM :: MValue a => Matrix a -> String
- mm'rows :: MValue a => Matrix a -> Int
- mm'cols :: MValue a => Matrix a -> Int
- mm'shape :: MValue a => Matrix a -> (Int, Int)
- toList :: MValue a => Matrix a -> [((Int, Int), a)]
- toCompleteList :: MValue a => Matrix a -> [((Int, Int), a)]
- toArray :: (IArray arr a, MValue a) => Int -> Matrix a -> arr (Int, Int) a
- toArrayM :: (MArray arr a m, MValue a) => Int -> Matrix a -> m (arr (Int, Int) a)
- at :: MValue a => Matrix a -> (Int, Int) -> a
- data RealFloat a => Complex a = !a :+ !a
Data types
data MValue a => Matrix a Source
Matrix Market format representation.
MM | |
|
data MValue a => MatrixData a Source
Matrix' data block.
MValue a => Eq (MatrixData a) | |
MValue a => Show (MatrixData a) |
class (Num a, Show a) => MValue a whereSource
Values allowed in the Matrix Market files.
Symmetry class of the matrix.
Coordinate format (sparse matrix).
Array format (dense matrix).
Parsing errors.
type ReadMatrix a = Either ReadError (Matrix a)Source
Use this type synonym to specify the type of readMM
when calling.
Read and write Matrix Market
readMM :: MValue a => String -> ReadMatrix aSource
Parse Matrix Market format.
Utility functions
mm'shape :: MValue a => Matrix a -> (Int, Int)Source
Dimensions of the matrix: (number of rows, number of columns).
toList :: MValue a => Matrix a -> [((Int, Int), a)]Source
Construct a list of non-zero entries (without symmetric entries).
toCompleteList :: MValue a => Matrix a -> [((Int, Int), a)]Source
Construct a list of all non-zero entries (including symmetric entries).
:: (IArray arr a, MValue a) | |
=> Int | array starting index, usually 0 or 1 |
-> Matrix a | matrix to convert |
-> arr (Int, Int) a |
Convert to an immutable dense array.
:: (MArray arr a m, MValue a) | |
=> Int | array starting index, usually 0 or 1 |
-> Matrix a | matrix to convert |
-> m (arr (Int, Int) a) |
Convert to a mutable dense array.