Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Sized matrixes.
Copyright: (c) 2009 University of Kansas License: BSD3
Maintainer: Andy Gill andygill@ku.edu Stability: unstable Portability: ghc
- data Matrix ix a
- = Matrix (Array ix a)
- | NullMatrix
- (!) :: Size n => Matrix n a -> n -> a
- toList :: Size i => Matrix i a -> [a]
- fromList :: forall i a. Size i => [a] -> Matrix i a
- matrix :: Size i => [a] -> Matrix i a
- indices :: Size i => Matrix i a -> [i]
- length :: Size i => Matrix i a -> Int
- assocs :: Size i => Matrix i a -> [(i, a)]
- (//) :: Size i => Matrix i e -> [(i, e)] -> Matrix i e
- accum :: Size i => (e -> a -> e) -> Matrix i e -> [(i, a)] -> Matrix i e
- zeroOf :: Size i => Matrix i a -> i
- coord :: Size i => Matrix i i
- zipWith :: Size i => (a -> b -> c) -> Matrix i a -> Matrix i b -> Matrix i c
- forEach :: Size i => Matrix i a -> (i -> a -> b) -> Matrix i b
- forAll :: Size i => (i -> a) -> Matrix i a
- mm :: (Size m, Size n, Size m', Size n', n ~ m', Num a) => Matrix (m, n) a -> Matrix (m', n') a -> Matrix (m, n') a
- transpose :: (Size x, Size y) => Matrix (x, y) a -> Matrix (y, x) a
- identity :: (Size x, Num a) => Matrix (x, x) a
- above :: (Size m, Size top, Size bottom, Size both, ADD top bottom ~ both, SUB both top ~ bottom, SUB both bottom ~ top) => Matrix (top, m) a -> Matrix (bottom, m) a -> Matrix (both, m) a
- beside :: (Size m, Size left, Size right, Size both, ADD left right ~ both, SUB both left ~ right, SUB both right ~ left) => Matrix (m, left) a -> Matrix (m, right) a -> Matrix (m, both) a
- append :: (Size left, Size right, Size both, ADD left right ~ both, SUB both left ~ right, SUB both right ~ left) => Matrix left a -> Matrix right a -> Matrix both a
- ixmap :: (Size i, Size j) => (i -> j) -> Matrix j a -> Matrix i a
- ixfmap :: (Size i, Size j, Functor f) => (i -> f j) -> Matrix j a -> Matrix i (f a)
- cropAt :: (Index i ~ Index ix, Size i, Size ix) => Matrix ix a -> ix -> Matrix i a
- rows :: (Bounded n, Size n, Bounded m, Size m) => Matrix (m, n) a -> Matrix m (Matrix n a)
- columns :: (Bounded n, Size n, Bounded m, Size m) => Matrix (m, n) a -> Matrix n (Matrix m a)
- joinRows :: (Bounded n, Size n, Bounded m, Size m) => Matrix m (Matrix n a) -> Matrix (m, n) a
- joinColumns :: (Bounded n, Size n, Bounded m, Size m) => Matrix n (Matrix m a) -> Matrix (m, n) a
- unitRow :: (Size m, Bounded m) => Matrix m a -> Matrix (X1, m) a
- unRow :: (Size m, Bounded m) => Matrix (X1, m) a -> Matrix m a
- unitColumn :: (Size m, Bounded m) => Matrix m a -> Matrix (m, X1) a
- unColumn :: (Size m, Bounded m) => Matrix (m, X1) a -> Matrix m a
- squash :: (Size n, Size m) => Matrix m a -> Matrix n a
- showMatrix :: (Size n, Size m) => Matrix (m, n) String -> String
- newtype S = S String
- showAsE :: RealFloat a => Int -> a -> S
- showAsF :: RealFloat a => Int -> a -> S
- scanM :: (Size ix, Bounded ix, Enum ix) => ((left, a, right) -> (right, b, left)) -> (left, Matrix ix a, right) -> (right, Matrix ix b, left)
- scanL :: (Size ix, Bounded ix, Enum ix) => ((a, right) -> (right, b)) -> (Matrix ix a, right) -> (right, Matrix ix b)
- scanR :: (Size ix, Bounded ix, Enum ix) => ((left, a) -> (b, left)) -> (left, Matrix ix a) -> (Matrix ix b, left)
- module Data.Sized.Ix
Documentation
A Matrix
is an array with the sized determined uniquely by the
type of the index type, ix
.
Matrix (Array ix a) | |
NullMatrix |
fromList :: forall i a. Size i => [a] -> Matrix i a Source
fromList
turns a finite list into a matrix. You often need to give the type of the result.
matrix :: Size i => [a] -> Matrix i a Source
matrix
turns a finite list into a matrix. You often need to give the type of the result.
zipWith :: Size i => (a -> b -> c) -> Matrix i a -> Matrix i b -> Matrix i c Source
Same as for lists.
forEach :: Size i => Matrix i a -> (i -> a -> b) -> Matrix i b Source
forEach
takes a matrix, and calls a function for each element, to give a new matrix of the same size.
forAll :: Size i => (i -> a) -> Matrix i a Source
forAll
creates a matrix out of a mapping from the coordinates.
mm :: (Size m, Size n, Size m', Size n', n ~ m', Num a) => Matrix (m, n) a -> Matrix (m', n') a -> Matrix (m, n') a Source
mm
is the 2D matrix multiply.
identity :: (Size x, Num a) => Matrix (x, x) a Source
return the identity for a specific matrix size.
above :: (Size m, Size top, Size bottom, Size both, ADD top bottom ~ both, SUB both top ~ bottom, SUB both bottom ~ top) => Matrix (top, m) a -> Matrix (bottom, m) a -> Matrix (both, m) a Source
stack two matrixes above
each other.
beside :: (Size m, Size left, Size right, Size both, ADD left right ~ both, SUB both left ~ right, SUB both right ~ left) => Matrix (m, left) a -> Matrix (m, right) a -> Matrix (m, both) a Source
stack two matrixes beside
each other.
append :: (Size left, Size right, Size both, ADD left right ~ both, SUB both left ~ right, SUB both right ~ left) => Matrix left a -> Matrix right a -> Matrix both a Source
append two 1-d matrixes
ixmap :: (Size i, Size j) => (i -> j) -> Matrix j a -> Matrix i a Source
look at a matrix through a lens to another matrix.
ixfmap :: (Size i, Size j, Functor f) => (i -> f j) -> Matrix j a -> Matrix i (f a) Source
look at a matrix through a functor lens, to another matrix.
cropAt :: (Index i ~ Index ix, Size i, Size ix) => Matrix ix a -> ix -> Matrix i a Source
grab part of a matrix.
rows :: (Bounded n, Size n, Bounded m, Size m) => Matrix (m, n) a -> Matrix m (Matrix n a) Source
slice a 2D matrix into rows.
columns :: (Bounded n, Size n, Bounded m, Size m) => Matrix (m, n) a -> Matrix n (Matrix m a) Source
slice a 2D matrix into columns.
joinRows :: (Bounded n, Size n, Bounded m, Size m) => Matrix m (Matrix n a) -> Matrix (m, n) a Source
join a matrix of matrixes into a single matrix.
joinColumns :: (Bounded n, Size n, Bounded m, Size m) => Matrix n (Matrix m a) -> Matrix (m, n) a Source
join a matrix of matrixes into a single matrix.
unitRow :: (Size m, Bounded m) => Matrix m a -> Matrix (X1, m) a Source
generate a 2D single row from a 1D matrix.
unRow :: (Size m, Bounded m) => Matrix (X1, m) a -> Matrix m a Source
generate a 1D matrix from a 2D matrix.
unitColumn :: (Size m, Bounded m) => Matrix m a -> Matrix (m, X1) a Source
generate a 2D single column from a 1D matrix.
unColumn :: (Size m, Bounded m) => Matrix (m, X1) a -> Matrix m a Source
generate a 1D matrix from a 2D matrix.
squash :: (Size n, Size m) => Matrix m a -> Matrix n a Source
very general; required that m and n have the same number of elements, rebundle please.
showMatrix :: (Size n, Size m) => Matrix (m, n) String -> String Source
showMatrix
displays a 2D matrix, and is the worker for show
.
GHCi> matrix [1..42] :: Matrix (X7,X6) Int [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 ]
S
is shown as the contents, without the quotes.
One use is a matrix of S, so that you can do show-style functions
using fmap.
scanM :: (Size ix, Bounded ix, Enum ix) => ((left, a, right) -> (right, b, left)) -> (left, Matrix ix a, right) -> (right, Matrix ix b, left) Source
scanL :: (Size ix, Bounded ix, Enum ix) => ((a, right) -> (right, b)) -> (Matrix ix a, right) -> (right, Matrix ix b) Source
scanR :: (Size ix, Bounded ix, Enum ix) => ((left, a) -> (b, left)) -> (left, Matrix ix a) -> (Matrix ix b, left) Source
module Data.Sized.Ix