Copyright | (c) Marco Zocca 2017 |
---|---|
License | GPL-style (see the file LICENSE) |
Maintainer | zocca marco gmail |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
- Matrix and vector elements (possibly Complex)
- Vector space
- Hilbert space (inner product)
- Normed vector spaces
- Matrix ring
- Linear vector space
- FiniteDim : finite-dimensional objects
- HasData : accessing inner data (do not export)
- Sparse : sparse datastructures
- Set : types that behave as sets
- SpContainer : sparse container datastructures. Insertion, lookup, toList, lookup with 0 default
- SparseVector
- SparseMatrix
- SparseMatVec
- Utilities
Typeclasses for linear algebra and related concepts
- class (Eq e, Fractional e, Floating e, Num (EltMag e), Ord (EltMag e)) => Elt e where
- (.*) :: VectorSpace v => Scalar v -> v -> v
- (./) :: (VectorSpace v, Fractional (Scalar v)) => v -> Scalar v -> v
- lerp :: (VectorSpace e, Num (Scalar e)) => Scalar e -> e -> e -> e
- dot :: InnerSpace v => v -> v -> Scalar v
- hilbertDistSq :: InnerSpace v => v -> v -> Scalar v
- class (InnerSpace v, Num (RealScalar v), Eq (RealScalar v), Epsilon (Magnitude v), Show (Magnitude v), Ord (Magnitude v)) => Normed v where
- type Magnitude v :: *
- type RealScalar v :: *
- normInftyR :: (Foldable t, Ord a) => t a -> a
- normInftyC :: (Foldable t, RealFloat a, Functor t) => t (Complex a) -> a
- dotLp :: (Set t, Foldable t, Floating a) => a -> t a -> t a -> a
- reciprocal :: (Functor f, Fractional b) => f b -> f b
- scale :: (Num b, Functor f) => b -> f b -> f b
- class (AdditiveGroup m, Epsilon (MatrixNorm m)) => MatrixRing m where
- type MatrixNorm m :: *
- class (VectorSpace v, MatrixRing (MatrixType v)) => LinearVectorSpace v where
- type MatrixType v :: *
- type V v = (LinearVectorSpace v, Normed v)
- class LinearVectorSpace v => LinearSystem v where
- class Functor f => FiniteDim f where
- class FiniteDim' f where
- class HasData f a where
- class HasData' f where
- class (FiniteDim f, HasData f a) => Sparse f a where
- class (FiniteDim' f, HasData' f) => Sparse' f where
- class Functor f => Set f where
- class Sparse c a => SpContainer c a where
- class SpContainer' c where
- class SpContainer v e => SparseVector v e where
- class SpContainer m e => SparseMatrix m e where
- toC :: Num a => a -> Complex a
Matrix and vector elements (possibly Complex)
Vector space
(.*) :: VectorSpace v => Scalar v -> v -> v Source #
Scale a vector
(./) :: (VectorSpace v, Fractional (Scalar v)) => v -> Scalar v -> v Source #
Scale a vector by the reciprocal of a number (e.g. for normalization)
lerp :: (VectorSpace e, Num (Scalar e)) => Scalar e -> e -> e -> e Source #
Convex combination of two vectors (NB: 0 <= a
<= 1).
Hilbert space (inner product)
dot :: InnerSpace v => v -> v -> Scalar v Source #
Inner product
Hilbert-space distance function
hilbertDistSq :: InnerSpace v => v -> v -> Scalar v Source #
`hilbertDistSq x y = || x - y ||^2` computes the squared L2 distance between two vectors
Normed vector spaces
class (InnerSpace v, Num (RealScalar v), Eq (RealScalar v), Epsilon (Magnitude v), Show (Magnitude v), Ord (Magnitude v)) => Normed v where Source #
norm1 :: v -> Magnitude v Source #
norm2Sq :: v -> Magnitude v Source #
normP :: RealScalar v -> v -> Magnitude v Source #
normalize :: RealScalar v -> v -> v Source #
normalize2 :: v -> v Source #
normalize2' :: Floating (Scalar v) => v -> v Source #
norm2 :: Floating (Magnitude v) => v -> Magnitude v Source #
norm2' :: Floating (Scalar v) => v -> Scalar v Source #
norm :: Floating (Magnitude v) => RealScalar v -> v -> Magnitude v Source #
normInftyR :: (Foldable t, Ord a) => t a -> a Source #
Infinity-norm (Real)
normInftyC :: (Foldable t, RealFloat a, Functor t) => t (Complex a) -> a Source #
Infinity-norm (Complex)
reciprocal :: (Functor f, Fractional b) => f b -> f b Source #
Reciprocal
Matrix ring
class (AdditiveGroup m, Epsilon (MatrixNorm m)) => MatrixRing m where Source #
A matrix ring is any collection of matrices over some ring R that form a ring under matrix addition and matrix multiplication
type MatrixNorm m :: * Source #
normFrobenius :: m -> MatrixNorm m Source #
Linear vector space
class (VectorSpace v, MatrixRing (MatrixType v)) => LinearVectorSpace v where Source #
type MatrixType v :: * Source #
(#>) :: MatrixType v -> v -> v Source #
(<#) :: v -> MatrixType v -> v Source #
LinearVectorSpace + Normed
type V v = (LinearVectorSpace v, Normed v) Source #
Linear systems
class LinearVectorSpace v => LinearSystem v where Source #
(<\>) :: (MonadIO m, MonadThrow m) => MatrixType v -> v -> m v Source #
FiniteDim : finite-dimensional objects
HasData : accessing inner data (do not export)
Sparse : sparse datastructures
class (FiniteDim f, HasData f a) => Sparse f a where Source #
spy :: Fractional b => f a -> b Source #
class (FiniteDim' f, HasData' f) => Sparse' f where Source #
spy' :: Fractional b => f -> b Source #
Set : types that behave as sets
SpContainer : sparse container datastructures. Insertion, lookup, toList, lookup with 0 default
class Sparse c a => SpContainer c a where Source #
class SpContainer' c where Source #
SparseVector
class SpContainer v e => SparseVector v e where Source #
SparseMatrix
class SpContainer m e => SparseMatrix m e where Source #