tensor-ops-0.1.0.0: Tensor manipulation operations with tensorflow-style automatic differentiation

Safe HaskellNone
LanguageHaskell2010

Data.Nested

Synopsis

Documentation

class NatKind k => Vec v where Source #

Minimal complete definition

vHead, vTail, vGenA, vIndex, vUncons, vEmpty, vCons, vITraverse

Methods

vHead :: p j -> v (Succ j) a -> a Source #

vTail :: v (Succ j) a -> v j a Source #

vGenA :: Applicative f => Sing j -> (IndexN k j -> f a) -> f (v j a) Source #

vIndex :: IndexN k j -> v j a -> a Source #

vUncons :: Sing j -> v j a -> Uncons v j a Source #

vEmpty :: v (FromNat 0) a Source #

vCons :: a -> v j a -> v (Succ j) a Source #

vITraverse :: Applicative f => (IndexN k j -> a -> f b) -> v j a -> f (v j b) Source #

class Nesting w c v where Source #

Minimal complete definition

nesting

Methods

nesting :: w i -> c a :- c (v i a) Source #

class Nesting1 w c v where Source #

Minimal complete definition

nesting1

Methods

nesting1 :: w a -> Wit (c (v a)) Source #

Instances

(NFData a, Nesting * k (Proxy k) NFData v) => Nesting1 * [k] w NFData (NTensor k v a) Source # 

Methods

nesting1 :: NTensor k v a a -> Wit (c (v a)) Source #

(NFData (ElemB k b), NFData1 (BShape k) b, Nesting * k (Proxy k) NFData v) => Nesting1 * [k] (Proxy [k]) NFData (BTensor k v b) Source # 

Methods

nesting1 :: BTensor k v b a -> Wit (c (v a)) Source #

nesting1Every :: forall p w c v as. Nesting1 w c v => p v -> Prod w as -> Wit (Every c (v <$> as)) Source #

data Nested :: (k -> Type -> Type) -> [k] -> Type -> Type Source #

Instances

Nesting1 (* -> *) k (Proxy k) Functor v => Functor (Nested k v js) Source # 

Methods

fmap :: (a -> b) -> Nested k v js a -> Nested k v js b #

(<$) :: a -> Nested k v js b -> Nested k v js a #

(SingI [k] js, Nesting1 (* -> *) k (Sing k) Applicative v, Nesting1 (* -> *) k (Proxy k) Functor v) => Applicative (Nested k v js) Source # 

Methods

pure :: a -> Nested k v js a #

(<*>) :: Nested k v js (a -> b) -> Nested k v js a -> Nested k v js b #

(*>) :: Nested k v js a -> Nested k v js b -> Nested k v js b #

(<*) :: Nested k v js a -> Nested k v js b -> Nested k v js a #

Nesting1 (* -> *) k (Proxy k) Foldable v => Foldable (Nested k v js) Source # 

Methods

fold :: Monoid m => Nested k v js m -> m #

foldMap :: Monoid m => (a -> m) -> Nested k v js a -> m #

foldr :: (a -> b -> b) -> b -> Nested k v js a -> b #

foldr' :: (a -> b -> b) -> b -> Nested k v js a -> b #

foldl :: (b -> a -> b) -> b -> Nested k v js a -> b #

foldl' :: (b -> a -> b) -> b -> Nested k v js a -> b #

foldr1 :: (a -> a -> a) -> Nested k v js a -> a #

foldl1 :: (a -> a -> a) -> Nested k v js a -> a #

toList :: Nested k v js a -> [a] #

null :: Nested k v js a -> Bool #

length :: Nested k v js a -> Int #

elem :: Eq a => a -> Nested k v js a -> Bool #

maximum :: Ord a => Nested k v js a -> a #

minimum :: Ord a => Nested k v js a -> a #

sum :: Num a => Nested k v js a -> a #

product :: Num a => Nested k v js a -> a #

(Nesting1 (* -> *) k (Proxy k) Functor v, Nesting1 (* -> *) k (Proxy k) Foldable v, Nesting1 (* -> *) k (Proxy k) Traversable v) => Traversable (Nested k v js) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Nested k v js a -> f (Nested k v js b) #

sequenceA :: Applicative f => Nested k v js (f a) -> f (Nested k v js a) #

mapM :: Monad m => (a -> m b) -> Nested k v js a -> m (Nested k v js b) #

sequence :: Monad m => Nested k v js (m a) -> m (Nested k v js a) #

(Vec k v, SingI [k] js, Nesting1 (* -> *) k (Proxy k) Functor v) => Distributive (Nested k v js) Source # 

Methods

distribute :: Functor f => f (Nested k v js a) -> Nested k v js (f a) #

collect :: Functor f => (a -> Nested k v js b) -> f a -> Nested k v js (f b) #

distributeM :: Monad m => m (Nested k v js a) -> Nested k v js (m a) #

collectM :: Monad m => (a -> Nested k v js b) -> m a -> Nested k v js (m b) #

(Num a, Applicative (Nested k v js)) => Num (Nested k v js a) Source # 

Methods

(+) :: Nested k v js a -> Nested k v js a -> Nested k v js a #

(-) :: Nested k v js a -> Nested k v js a -> Nested k v js a #

(*) :: Nested k v js a -> Nested k v js a -> Nested k v js a #

negate :: Nested k v js a -> Nested k v js a #

abs :: Nested k v js a -> Nested k v js a #

signum :: Nested k v js a -> Nested k v js a #

fromInteger :: Integer -> Nested k v js a #

(NFData a, Nesting * k (Proxy k) NFData v) => NFData (Nested k v js a) Source # 

Methods

rnf :: Nested k v js a -> () #

genNested :: Vec (v :: k -> Type -> Type) => Sing ns -> (Prod (IndexN k) ns -> a) -> Nested v ns a Source #

genNestedA :: (Vec (v :: k -> Type -> Type), Applicative f) => Sing ns -> (Prod (IndexN k) ns -> f a) -> f (Nested v ns a) Source #

indexNested :: Vec (v :: k -> Type -> Type) => Prod (IndexN k) ns -> Nested v ns a -> a Source #

indexNested' :: Vec (v :: k -> Type -> Type) => Prod (IndexN k) ms -> Nested v (ms ++ ns) a -> Nested v ns a Source #

transpose :: forall v os a. (Nesting1 Proxy Functor v, Nesting1 Proxy Foldable v, Nesting1 Proxy Traversable v, Nesting1 Sing Distributive v) => Sing os -> Nested v os a -> Nested v (Reverse os) a Source #

Transpose by iteratively sequencing/distributing layers

transpose' :: Vec v => Length os -> Sing (Reverse os) -> Nested v os a -> Nested v (Reverse os) a Source #

Transpose by populating a new Nested from scratch

gmul' :: forall ms os ns v a. (Nesting1 Proxy Functor v, Nesting1 Sing Applicative v, SingI ns, Num a, Vec v) => Length ms -> Length os -> Length ns -> Nested v (ms ++ os) a -> Nested v (Reverse os ++ ns) a -> Nested v (ms ++ ns) a Source #

diagNV :: (Vec v, Nesting1 Proxy Functor v) => Sing n -> Uniform n ms -> Nested v (n ': (n ': ms)) a -> Nested v '[n] a Source #

joinNested :: forall v ns ms a. Nesting1 Proxy Functor v => Nested v ns (Nested v ms a) -> Nested v (ns ++ ms) a Source #

mapNVecSlices :: forall v ns ms a b. Nesting1 Proxy Functor v => (Nested v ms a -> b) -> Length ns -> Nested v (ns ++ ms) a -> Nested v ns b Source #

nIxRows :: forall k v ns ms a b f. (Nesting1 Proxy Functor v, Applicative f, Vec v) => Length ns -> (Prod (IndexN k) ns -> Nested v ms a -> f b) -> Nested v (ns ++ ms) a -> f (Nested v ns b) Source #

vGen :: Vec (v :: k -> Type -> Type) => Sing j -> (IndexN k j -> a) -> v j a Source #

vIFoldMap :: (Monoid m, Vec v) => (IndexN k j -> a -> m) -> v j a -> m Source #

itraverseNested :: forall k v ns a b f. (Applicative f, Vec v) => (Prod (IndexN k) ns -> a -> f b) -> Nested v ns a -> f (Nested v ns b) Source #

liftNested :: Distributive (Nested v ns) => (Vec n a -> a) -> Vec n (Nested v ns a) -> Nested v ns a Source #

unScalar :: Nested v '[] a -> a Source #

unNest :: Nested v (j ': js) a -> v j (Nested v js a) Source #

unVector :: Functor (v j) => Nested v '[j] a -> v j a Source #

sumRowsNested :: forall v n ns a. (Foldable (v n), Num a, SingI ns, Nesting1 Proxy Functor v, Nesting1 Sing Applicative v) => Nested v (n ': ns) a -> Nested v ns a Source #