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

Safe HaskellNone
LanguageHaskell2010

TensorOps.Types

Contents

Synopsis

Documentation

class NatKind k => Tensor t where Source #

Minimal complete definition

liftT, gmul, sumT, scaleT, transp, mapRows, sumRows, diag, getDiag, genRand, generateA, ixRows, (!)

Associated Types

type ElemT t :: Type Source #

Methods

liftT :: SingI o => (Vec n (ElemT t) -> ElemT t) -> Vec n (t o) -> t o Source #

gmul :: (SingI (Reverse os ++ ns), SingI (ms ++ ns)) => Length ms -> Length os -> Length ns -> t (ms ++ os) -> t (Reverse os ++ ns) -> t (ms ++ ns) Source #

sumT :: SingI o => [t o] -> t o Source #

scaleT :: SingI o => ElemT t -> t o -> t o Source #

transp :: (SingI ns, SingI (Reverse ns)) => t ns -> t (Reverse ns) Source #

mapRows :: SingI (ns ++ ms) => Length ns -> (t ms -> t ms) -> t (ns ++ ms) -> t (ns ++ ms) Source #

sumRows :: (SingI (n ': ns), SingI ns) => t (n ': ns) -> t ns Source #

diag :: SingI (n ': ns) => Uniform n ns -> t '[n] -> t (n ': ns) Source #

getDiag :: SingI n => Uniform n ns -> t (n ': (n ': ns)) -> t '[n] Source #

genRand :: (ContGen d, PrimMonad m, SingI ns) => d -> Gen (PrimState m) -> m (t ns) Source #

generateA :: (Applicative f, SingI ns) => (Prod (IndexN k) ns -> f (ElemT t)) -> f (t ns) Source #

ixRows :: (Applicative f, SingI (ms ++ os)) => Length ms -> Length os -> (Prod (IndexN k) ms -> t ns -> f (t os)) -> t (ms ++ ns) -> f (t (ms ++ os)) Source #

(!) :: t ns -> Prod (IndexN k) ns -> ElemT t Source #

Instances

(Vec k2 v, BLAS k2 b, RealFloat (ElemB k2 b), Nesting1 (* -> *) k2 (Proxy k2) Functor v, Nesting1 (* -> *) k2 (Proxy k2) Foldable v, Nesting1 (* -> *) k2 (Sing k2) Applicative v, Nesting1 (* -> *) k2 (Sing k2) Distributive v, Eq1 k2 (IndexN k2)) => Tensor k2 (BTensor k2 v b) Source # 

Associated Types

type ElemT (BTensor k2 v b) (t :: [BTensor k2 v b] -> Type) :: Type Source #

Methods

liftT :: SingI [BTensor k2 v b] o => (Vec n (ElemT (BTensor k2 v b) t) -> ElemT (BTensor k2 v b) t) -> Vec n (t o) -> t o Source #

gmul :: (SingI [BTensor k2 v b] ((BTensor k2 v b ++ Reverse (BTensor k2 v b) os) ns), SingI [BTensor k2 v b] ((BTensor k2 v b ++ ms) ns)) => Length (BTensor k2 v b) ms -> Length (BTensor k2 v b) os -> Length (BTensor k2 v b) ns -> t ((BTensor k2 v b ++ ms) os) -> t ((BTensor k2 v b ++ Reverse (BTensor k2 v b) os) ns) -> t ((BTensor k2 v b ++ ms) ns) Source #

sumT :: SingI [BTensor k2 v b] o => [t o] -> t o Source #

scaleT :: SingI [BTensor k2 v b] o => ElemT (BTensor k2 v b) t -> t o -> t o Source #

transp :: (SingI [BTensor k2 v b] ns, SingI [BTensor k2 v b] (Reverse (BTensor k2 v b) ns)) => t ns -> t (Reverse (BTensor k2 v b) ns) Source #

mapRows :: SingI [BTensor k2 v b] ((BTensor k2 v b ++ ns) ms) => Length (BTensor k2 v b) ns -> (t ms -> t ms) -> t ((BTensor k2 v b ++ ns) ms) -> t ((BTensor k2 v b ++ ns) ms) Source #

sumRows :: (SingI [BTensor k2 v b] ((BTensor k2 v b ': n) ns), SingI [BTensor k2 v b] ns) => t ((BTensor k2 v b ': n) ns) -> t ns Source #

diag :: SingI [BTensor k2 v b] ((BTensor k2 v b ': n) ns) => Uniform (BTensor k2 v b) n ns -> t ((BTensor k2 v b ': n) [BTensor k2 v b]) -> t ((BTensor k2 v b ': n) ns) Source #

getDiag :: SingI (BTensor k2 v b) n => Uniform (BTensor k2 v b) n ns -> t ((BTensor k2 v b ': n) ((BTensor k2 v b ': n) ns)) -> t ((BTensor k2 v b ': n) [BTensor k2 v b]) Source #

genRand :: (ContGen d, PrimMonad m, SingI [BTensor k2 v b] ns) => d -> Gen (PrimState m) -> m (t ns) Source #

generateA :: (Applicative f, SingI [BTensor k2 v b] ns) => (Prod (BTensor k2 v b) (IndexN (BTensor k2 v b)) ns -> f (ElemT (BTensor k2 v b) t)) -> f (t ns) Source #

ixRows :: (Applicative f, SingI [BTensor k2 v b] ((BTensor k2 v b ++ ms) os)) => Length (BTensor k2 v b) ms -> Length (BTensor k2 v b) os -> (Prod (BTensor k2 v b) (IndexN (BTensor k2 v b)) ms -> t ns -> f (t os)) -> t ((BTensor k2 v b ++ ms) ns) -> f (t ((BTensor k2 v b ++ ms) os)) Source #

(!) :: t ns -> Prod (BTensor k2 v b) (IndexN (BTensor k2 v b)) ns -> ElemT (BTensor k2 v b) t Source #

(Vec k2 v, RealFloat a, Nesting1 (* -> *) k2 (Proxy k2) Functor v, Nesting1 (* -> *) k2 (Sing k2) Applicative v, Nesting1 (* -> *) k2 (Proxy k2) Foldable v, Nesting1 (* -> *) k2 (Proxy k2) Traversable v, Nesting1 (* -> *) k2 (Sing k2) Distributive v, Eq1 k2 (IndexN k2)) => Tensor k2 (NTensor k2 v a) Source # 

Associated Types

type ElemT (NTensor k2 v a) (t :: [NTensor k2 v a] -> Type) :: Type Source #

Methods

liftT :: SingI [NTensor k2 v a] o => (Vec n (ElemT (NTensor k2 v a) t) -> ElemT (NTensor k2 v a) t) -> Vec n (t o) -> t o Source #

gmul :: (SingI [NTensor k2 v a] ((NTensor k2 v a ++ Reverse (NTensor k2 v a) os) ns), SingI [NTensor k2 v a] ((NTensor k2 v a ++ ms) ns)) => Length (NTensor k2 v a) ms -> Length (NTensor k2 v a) os -> Length (NTensor k2 v a) ns -> t ((NTensor k2 v a ++ ms) os) -> t ((NTensor k2 v a ++ Reverse (NTensor k2 v a) os) ns) -> t ((NTensor k2 v a ++ ms) ns) Source #

sumT :: SingI [NTensor k2 v a] o => [t o] -> t o Source #

scaleT :: SingI [NTensor k2 v a] o => ElemT (NTensor k2 v a) t -> t o -> t o Source #

transp :: (SingI [NTensor k2 v a] ns, SingI [NTensor k2 v a] (Reverse (NTensor k2 v a) ns)) => t ns -> t (Reverse (NTensor k2 v a) ns) Source #

mapRows :: SingI [NTensor k2 v a] ((NTensor k2 v a ++ ns) ms) => Length (NTensor k2 v a) ns -> (t ms -> t ms) -> t ((NTensor k2 v a ++ ns) ms) -> t ((NTensor k2 v a ++ ns) ms) Source #

sumRows :: (SingI [NTensor k2 v a] ((NTensor k2 v a ': n) ns), SingI [NTensor k2 v a] ns) => t ((NTensor k2 v a ': n) ns) -> t ns Source #

diag :: SingI [NTensor k2 v a] ((NTensor k2 v a ': n) ns) => Uniform (NTensor k2 v a) n ns -> t ((NTensor k2 v a ': n) [NTensor k2 v a]) -> t ((NTensor k2 v a ': n) ns) Source #

getDiag :: SingI (NTensor k2 v a) n => Uniform (NTensor k2 v a) n ns -> t ((NTensor k2 v a ': n) ((NTensor k2 v a ': n) ns)) -> t ((NTensor k2 v a ': n) [NTensor k2 v a]) Source #

genRand :: (ContGen d, PrimMonad m, SingI [NTensor k2 v a] ns) => d -> Gen (PrimState m) -> m (t ns) Source #

generateA :: (Applicative f, SingI [NTensor k2 v a] ns) => (Prod (NTensor k2 v a) (IndexN (NTensor k2 v a)) ns -> f (ElemT (NTensor k2 v a) t)) -> f (t ns) Source #

ixRows :: (Applicative f, SingI [NTensor k2 v a] ((NTensor k2 v a ++ ms) os)) => Length (NTensor k2 v a) ms -> Length (NTensor k2 v a) os -> (Prod (NTensor k2 v a) (IndexN (NTensor k2 v a)) ms -> t ns -> f (t os)) -> t ((NTensor k2 v a ++ ms) ns) -> f (t ((NTensor k2 v a ++ ms) os)) Source #

(!) :: t ns -> Prod (NTensor k2 v a) (IndexN (NTensor k2 v a)) ns -> ElemT (NTensor k2 v a) t Source #

data VFunc n Source #

Function and gradient

Constructors

VF 

Fields

data TOp :: [[k]] -> [[k]] -> Type where Source #

Constructors

TOp :: {..} -> TOp ns ms 

Fields

Instances

Category [[k]] (TOp k) Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

gradTOp :: (Tensor t, RealFloat (ElemT t)) => TOp ns '['[]] -> Prod t ns -> Prod t ns Source #

idOp :: forall ns. TOp ns ns Source #

firstOp :: forall os ns ms. (Known Length ns, Known Length ms) => TOp ns ms -> TOp (ns ++ os) (ms ++ os) Source #

secondOp :: forall os ns ms. Known Length os => TOp ns ms -> TOp (os ++ ns) (os ++ ms) Source #

(*>>) :: forall as bs cs ds. (Known Length as, Known Length bs) => TOp as bs -> TOp (bs ++ cs) ds -> TOp (as ++ cs) ds infixr 0 Source #

(<<*) :: forall as bs cs ds. (Known Length as, Known Length bs) => TOp (bs ++ cs) ds -> TOp as bs -> TOp (as ++ cs) ds infixr 2 Source #

(***) :: forall as bs cs ds. (Known Length as, Known Length cs) => TOp as cs -> TOp bs ds -> TOp (as ++ bs) (cs ++ ds) Source #

(&&&) :: forall as bs cs. (Known Length bs, SingI as) => TOp as bs -> TOp as cs -> TOp as (bs ++ cs) Source #

Orphan instances

Eq1 Nat Finite Source # 

Methods

eq1 :: f a -> f a -> Bool #

neq1 :: f a -> f a -> Bool #