numeric-prelude-0.0.5: An experimental alternative hierarchy of numeric type classesSource codeContentsIndex
Portabilityrequires multi-parameter type classes
Routines and abstractions for Matrices and basic linear algebra over fields or rings.
data T a = Cons (Array (Integer, Integer) a)
twist :: (Integer, Integer) -> (Integer, Integer)
transpose :: T a -> T a
rows :: T a -> [[a]]
columns :: T a -> [[a]]
fromList :: Integer -> Integer -> [a] -> T a
dimension :: T a -> (Integer, Integer)
numRows :: T a -> Integer
numColumns :: T a -> Integer
zipWith :: (a -> b -> c) -> T a -> T b -> T c
zeroMatrix :: C a => Integer -> Integer -> T a
preimage :: C a => T a -> T a -> Maybe (T a)
data T a Source
A matrix is a twodimensional array of ring elements, indexed by integers.
Cons (Array (Integer, Integer) a)
show/hide Instances
Functor T
C a b => C a (T b)
Eq a => Eq (T a)
Ord a => Ord (T a)
Read a => Read (T a)
(C a, Show a) => Show (T a)
C a => C (T a)
C a => C (T a)
twist :: (Integer, Integer) -> (Integer, Integer)Source
Transposition of matrices is just transposition in the sense of Data.List.
transpose :: T a -> T aSource
rows :: T a -> [[a]]Source
columns :: T a -> [[a]]Source
fromList :: Integer -> Integer -> [a] -> T aSource
dimension :: T a -> (Integer, Integer)Source
numRows :: T a -> IntegerSource
numColumns :: T a -> IntegerSource
zipWith :: (a -> b -> c) -> T a -> T b -> T cSource
zeroMatrix :: C a => Integer -> Integer -> T aSource
preimage :: C a => T a -> T a -> Maybe (T a)Source

What more do we need from our matrix class? We have addition, subtraction and multiplication, and thus composition of generic free-module-maps. We're going to want to solve linear equations with or without fields underneath, so we're going to want an implementation of the Gaussian algorithm as well as most probably Smith normal form. Determinants are cool, and these are to be calculated either with the Gaussian algorithm or some other goodish method.

We'll want generic linear equation solving, returning one solution, any solution really, or nothing. Basically, this is asking for the preimage of a given vector over the given map, so

a_11 x_1 + .. + a_1n x_n = y_1 ... a_m1 x_1 + .. + a_mn a_n = y_m

has really x_1,...,x_n as a preimage of the vector y_1,..,y_m under the map (a_ij), since obviously y_1,..,y_m = (a_ij) x_1,..,x_n

So, generic linear equation solving boils down to the function

Produced by Haddock version 2.6.0