numeric-prelude-0.4.4: An experimental alternative hierarchy of numeric type classes
Copyright(c) Henning Thielemann 2009 Mikael Johansson 2006
Maintainernumericprelude@henning-thielemann.de
Stabilityprovisional
Portabilityrequires multi-parameter type classes
Safe HaskellNone
LanguageHaskell98

MathObj.Matrix

Description

Routines and abstractions for Matrices and basic linear algebra over fields or rings.

We stick to simple Int indices. Although advanced indices would be nice e.g. for matrices with sub-matrices, this is not easily implemented since arrays do only support a lower and an upper bound but no additional parameters.

ToDo: - Matrix inverse, determinant (see htam:Matrix)

Synopsis

Documentation

data T a Source #

A matrix is a twodimensional array, indexed by integers.

Instances

Instances details
Functor T Source # 
Instance details

Defined in MathObj.Matrix

Methods

fmap :: (a -> b) -> T a -> T b #

(<$) :: a -> T b -> T a #

C T Source # 
Instance details

Defined in MathObj.Matrix

Methods

zero :: C a => T a Source #

(<+>) :: C a => T a -> T a -> T a Source #

(*>) :: C a => a -> T a -> T a Source #

C a b => C a (T b) Source # 
Instance details

Defined in MathObj.Matrix

Methods

(*>) :: a -> T b -> T b Source #

Eq a => Eq (T a) Source # 
Instance details

Defined in MathObj.Matrix

Methods

(==) :: T a -> T a -> Bool #

(/=) :: T a -> T a -> Bool #

Ord a => Ord (T a) Source # 
Instance details

Defined in MathObj.Matrix

Methods

compare :: T a -> T a -> Ordering #

(<) :: T a -> T a -> Bool #

(<=) :: T a -> T a -> Bool #

(>) :: T a -> T a -> Bool #

(>=) :: T a -> T a -> Bool #

max :: T a -> T a -> T a #

min :: T a -> T a -> T a #

Read a => Read (T a) Source # 
Instance details

Defined in MathObj.Matrix

Methods

readsPrec :: Int -> ReadS (T a) #

readList :: ReadS [T a] #

readPrec :: ReadPrec (T a) #

readListPrec :: ReadPrec [T a] #

Show a => Show (T a) Source # 
Instance details

Defined in MathObj.Matrix

Methods

showsPrec :: Int -> T a -> ShowS #

show :: T a -> String #

showList :: [T a] -> ShowS #

C a => C (T a) Source #
genIntMatrix /\ \a -> genSameMatrix a /\ \b -> Laws.commutative (+) a b
genIntMatrix /\ \a -> genSameMatrix a /\ \b -> genSameMatrix b /\ \c -> Laws.associative (+) a b c
Instance details

Defined in MathObj.Matrix

Methods

zero :: T a Source #

(+) :: T a -> T a -> T a Source #

(-) :: T a -> T a -> T a Source #

negate :: T a -> T a Source #

C a => C (T a) Source #
genIntMatrix /\ \a -> Laws.leftIdentity  (*) (Matrix.one (Matrix.numRows a)) a
genIntMatrix /\ \a -> Laws.rightIdentity (*) (Matrix.one (Matrix.numColumns a)) a
genIntMatrix /\ \a -> genFactorMatrix a /\ \b -> Laws.homomorphism Matrix.transpose (*) (flip (*)) a b
genIntMatrix /\ \a -> genFactorMatrix a /\ \b -> genFactorMatrix b /\ \c -> Laws.associative (*) a b c
genIntMatrix /\ \b -> genSameMatrix b /\ \c -> genFactorMatrix b /\ \a -> Laws.leftDistributive (*) (+) a b c
genIntMatrix /\ \a -> genFactorMatrix a /\ \b -> genSameMatrix b /\ \c -> Laws.rightDistributive (*) (+) a b c
QC.choose (0,10) /\ \k -> genDimension /\ \n -> genMatrixFor n n /\ \a -> a^k == nest (fromInteger k) ((a::Matrix.T Integer)*) (Matrix.one n)
Instance details

Defined in MathObj.Matrix

Methods

(*) :: T a -> T a -> T a Source #

one :: T a Source #

fromInteger :: Integer -> T a Source #

(^) :: T a -> Integer -> T a Source #

format :: Show a => T a -> String Source #

transpose :: T a -> T a Source #

Transposition of matrices is just transposition in the sense of Data.List.

genIntMatrix /\ \a -> Matrix.rows a == Matrix.columns (Matrix.transpose a)
genIntMatrix /\ \a -> Matrix.columns a == Matrix.rows (Matrix.transpose a)
genIntMatrix /\ \a -> genSameMatrix a /\ \b -> Laws.homomorphism Matrix.transpose (+) (+) a b

rows :: T a -> [[a]] Source #

columns :: T a -> [[a]] Source #

index :: T a -> Dimension -> Dimension -> a Source #

fromRows :: Dimension -> Dimension -> [[a]] -> T a Source #

genIntMatrix /\ \a -> a == uncurry Matrix.fromRows (Matrix.dimension a) (Matrix.rows a)

fromColumns :: Dimension -> Dimension -> [[a]] -> T a Source #

genIntMatrix /\ \a -> a == uncurry Matrix.fromColumns (Matrix.dimension a) (Matrix.columns a)

fromList :: Dimension -> Dimension -> [a] -> T a Source #

zipWith :: (a -> b -> c) -> T a -> T b -> T c Source #

zero :: C a => Dimension -> Dimension -> T a Source #

genIntMatrix /\ \a -> Laws.identity (+) (uncurry Matrix.zero $ Matrix.dimension a) a

one :: C a => Dimension -> T a Source #

diagonal :: C a => [a] -> T a Source #

genDimension /\ \n -> Matrix.one n == Matrix.diagonal (replicate n Ring.one :: [Integer])

scale :: C a => a -> T a -> T a Source #

random :: (RandomGen g, Random a) => Dimension -> Dimension -> g -> (T a, g) Source #

randomR :: (RandomGen g, Random a) => Dimension -> Dimension -> (a, a) -> g -> (T a, g) Source #