-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Tensors whose ranks and dimensions type-inferred and type-checked. -- -- A tensor class for Haskell that can type-infer and type-check over -- tensor ranks and dimensions. @package typelevel-tensor @version 0.1 -- | A tensor algebra library. Main ingredients are : -- -- Vec and :~ are data constructors for rank-1 tensor. This -- is essentially a touple of objects of the same type. -- -- Vector is a class for rank-1 tensor. -- -- Axis is an object for accessing the tensor components. module Data.Tensor.TypeLevel -- | data constructor for constructing n+1-dimensional tensor from -- n-dimensional tensor. data (:~) n :: (* -> *) a (:~) :: (n a) -> a -> :~ a -- | data constructor for 0-dimensional tensor. data Vec a Vec :: Vec a -- | An coordinate Axis , labeled by an integer. Axis also carries -- v, the container type for its corresponding vector. Therefore, An axis -- of one type can access only vectors of a fixed dimension, but of -- arbitrary type. newtype Vector v => Axis v Axis :: Int -> Axis v axisIndex :: Axis v -> Int -- | a component operator. (!) :: Vector v => v a -> Axis v -> a -- | An object that allows component-wise access. class Traversable v => Vector v componentF :: (Vector v, Failure StringException f) => Axis v -> v a -> f a component :: Vector v => Axis v -> v a -> a dimension :: Vector v => v a -> Int compose :: Vector v => (Axis v -> a) -> v a -- | VectorRing is a Vector whose components belongs to -- C, thus providing unit vectors. class (Vector v, C a) => VectorRing v a unitVectorF :: (VectorRing v a, Failure StringException f) => Axis v -> f (v a) unitVector :: VectorRing v a => Axis v -> v a -- | Tensor contraction. Create a Vector from a function that maps -- axis to component, then sums over the axis and returns a. contract :: (Vector v, C a) => (Axis v -> a) -> a -- | Type synonyms type Vec0 = Vec type Vec1 = :~ Vec0 type Vec2 = :~ Vec1 type Vec3 = :~ Vec2 type Vec4 = :~ Vec3 instance Eq (Vec a) instance Ord (Vec a) instance Show (Vec a) instance Read (Vec a) instance (Eq a, Eq (n a)) => Eq (n :~ a) instance (Show a, Show (n a)) => Show (n :~ a) instance (Read a, Read (n a)) => Read (n :~ a) instance Eq (Axis v) instance Ord (Axis v) instance Vector v => Show (Axis v) instance Vector v => Read (Axis v) instance (C a, VectorRing v a, C (v a)) => VectorRing ((:~) v) a instance C a => VectorRing Vec a instance (Vector v, C a) => C (v :~ a) instance C a => C (Vec a) instance Vector v => Vector ((:~) v) instance Vector Vec instance (Applicative n, Traversable n) => Applicative ((:~) n) instance Traversable n => Traversable ((:~) n) instance Traversable n => Functor ((:~) n) instance Traversable n => Foldable ((:~) n) instance Applicative Vec instance Traversable Vec instance Functor Vec instance Foldable Vec instance (Ord (n a), Ord a) => Ord (n :~ a) module Data.Tensor.TypeLevel.Axis -- | The dimension of the vector space the axis belongs to. dimension :: Vector v => Axis v -> Int -- | The next axis under the Law of Cycles. next :: Vector v => Axis v -> Axis v -- | The previous axis under the Law of Cycles. prev :: Vector v => Axis v -> Axis v -- | All the axes belonging to the dimension. all :: Vector v => Axis v -> [Axis v] -- | All the axes belonging to the dimension, starting from the argument -- and followed by the Law of Cycles. allFrom :: Vector v => Axis v -> [Axis v] -- | All the axes belonging to the dimension but the argument itself, in -- the order of the Law of Cycles. others :: Vector v => Axis v -> [Axis v]