matrix-market-pure-0.2: Pure and composable reader and writer of the Matrix Market format.

Data.MatrixMarket

Contents

Description

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

Synopsis

Data types

data MValue a => Matrix a Source

Matrix Market format representation.

Constructors

MM 

Instances

MValue a => Eq (Matrix a) 
MValue a => Show (Matrix a) 

data MValue a => MatrixData a Source

Matrix' data block.

Constructors

CoordinateM 

Fields

coords'm :: CM a
 
ArrayM 

Fields

array'm :: AM a
 

Instances

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.

data MField Source

Field of the matrix.

Constructors

MInt 
MReal 
MComplex 
MPattern 

Instances

data Symmetry Source

Symmetry class of the matrix.

Instances

data MValue a => CM a Source

Coordinate format (sparse matrix).

Constructors

CM 

Fields

cm'rows :: Int
 
cm'cols :: Int
 
cm'size :: Int
 
cm'values :: [((Int, Int), a)]
 

Instances

MValue a => Eq (CM a) 
MValue a => Show (CM a) 

data MValue a => AM a Source

Array format (dense matrix).

Constructors

AM 

Fields

am'rows :: Int
 
am'cols :: Int
 
am'values :: [a]
 

Instances

MValue a => Eq (AM a) 
MValue a => Show (AM a) 

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.

dumpMM :: MValue a => Matrix a -> StringSource

Write Matrix Market format.

Utility functions

mm'rows :: MValue a => Matrix a -> IntSource

Number of rows in the matrix.

mm'cols :: MValue a => Matrix a -> IntSource

Number of columns in the matrix.

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

toArraySource

Arguments

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

toArrayMSource

Arguments

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

at :: MValue a => Matrix a -> (Int, Int) -> aSource

Get an element of the matrix at the specified position. Warning: This operation is slow, use toArray or toArrayM to convert to an array first.

Re-exports

data RealFloat a => Complex a

Complex numbers are an algebraic type.

For a complex number z, abs z is a number with the magnitude of z, but oriented in the positive real direction, whereas signum z has the phase of z, but unit magnitude.

Constructors

!a :+ !a

forms a complex number from its real and imaginary rectangular components.