numeric-prelude- An experimental alternative hierarchy of numeric type classes

Portabilityrequires multi-parameter type classes



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



data T a Source

A matrix is a twodimensional array, indexed by integers.


Functor T 
C T 
C a b => C a (T b) 
Eq a => Eq (T a) 
Ord a => Ord (T a) 
Read a => Read (T a) 
Show a => Show (T a) 
C a => C (T a) 
C a => C (T a) 

format :: Show a => T a -> StringSource

transpose :: T a -> T aSource

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

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

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

fromRows :: Dimension -> Dimension -> [[a]] -> T aSource

zipWith :: (a -> b -> c) -> T a -> T b -> T cSource

zero :: C a => Dimension -> Dimension -> T aSource

one :: C a => Dimension -> T aSource

diagonal :: C a => [a] -> T aSource

scale :: C a => a -> T a -> T aSource

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