{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE NoStarIsType #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE UnicodeSyntax #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE CPP #-}
module Math.LinearMap.Category.Class where
import Data.VectorSpace
import Math.VectorSpace.DimensionAware
import Data.AffineSpace
import Prelude ()
import qualified Prelude as Hask
import Control.Category.Constrained.Prelude hiding (type (+))
import Control.Arrow.Constrained
import Data.Coerce
import Data.Type.Coercion
import Data.Tagged
import Data.Proxy(Proxy(..))
import qualified Data.Vector.Generic as GArr
import Math.Manifold.Core.PseudoAffine
import Math.LinearMap.Asserted
import Math.VectorSpace.ZeroDimensional
import Data.VectorSpace.Free
import Control.Monad.ST (ST)
import Data.Singletons (sing, withSingI)
#if MIN_VERSION_singletons(3,0,0)
import Prelude.Singletons (SNum(..))
import Data.Maybe.Singletons (SMaybe(..))
import GHC.TypeLits.Singletons (withKnownNat, SNat(..))
#else
import Data.Singletons.Prelude.Num (SNum(..))
import Data.Singletons.Prelude.Maybe (SMaybe(..))
import Data.Singletons.TypeLits (withKnownNat, SNat(..))
#endif
import Data.Kind (Type)
import GHC.TypeLits (Nat, type (+), type (*), KnownNat, natVal)
import qualified GHC.Generics as Gnrx
import GHC.Generics (Generic, (:*:)((:*:)))
import qualified Math.VectorSpace.DimensionAware.Theorems.MaybeNat as Maybe
data ClosedScalarWitness s where
ClosedScalarWitness :: (Scalar s ~ s, DualVector s ~ s) => ClosedScalarWitness s
data TrivialTensorWitness s w where
TrivialTensorWitness :: w ~ TensorProduct s w => TrivialTensorWitness s w
class (Num s, LinearSpace s, FreeVectorSpace s, 1`Dimensional`s)
=> Num' s where
closedScalarWitness :: ClosedScalarWitness s
default closedScalarWitness :: (Scalar s ~ s, DualVector s ~ s) => ClosedScalarWitness s
closedScalarWitness = ClosedScalarWitness s
forall s. (Scalar s ~ s, DualVector s ~ s) => ClosedScalarWitness s
ClosedScalarWitness
trivialTensorWitness :: TrivialTensorWitness s w
default trivialTensorWitness :: (w ~ TensorProduct s w) => TrivialTensorWitness s w
trivialTensorWitness = TrivialTensorWitness s w
forall w s. (w ~ TensorProduct s w) => TrivialTensorWitness s w
TrivialTensorWitness
data ScalarSpaceWitness v where
ScalarSpaceWitness :: (Num' (Scalar v), Scalar (Scalar v) ~ Scalar v)
=> ScalarSpaceWitness v
data LinearManifoldWitness v where
LinearManifoldWitness :: (Needle v ~ v, AffineSpace v, Diff v ~ v)
=>
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness v ->
#endif
LinearManifoldWitness v
data VSCCoercion s a b where
VSCCoercion :: (Coercible a b, StaticDimension a ~ StaticDimension b)
=> VSCCoercion s a b
getVSCCoercion :: VSCCoercion s a b -> Coercion a b
getVSCCoercion :: forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion VSCCoercion s a b
VSCCoercion = Coercion a b
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion
symVSC :: VSCCoercion s a b -> VSCCoercion s b a
symVSC :: forall s a b. VSCCoercion s a b -> VSCCoercion s b a
symVSC VSCCoercion s a b
VSCCoercion = VSCCoercion s b a
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
firstVSC :: VSCCoercion s a b -> VSCCoercion s (a,c) (b,c)
firstVSC :: forall s a b c. VSCCoercion s a b -> VSCCoercion s (a, c) (b, c)
firstVSC VSCCoercion s a b
VSCCoercion = VSCCoercion s (a, c) (b, c)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
secondVSC :: VSCCoercion s a b -> VSCCoercion s (c,a) (c,b)
secondVSC :: forall s a b c. VSCCoercion s a b -> VSCCoercion s (c, a) (c, b)
secondVSC VSCCoercion s a b
VSCCoercion = VSCCoercion s (c, a) (c, b)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
unsafeFollowVSC :: (Coercible a b, StaticDimension a ~ StaticDimension b)
=> c a b -> VSCCoercion s a b
unsafeFollowVSC :: forall a b (c :: Type -> Type -> Type) s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
c a b -> VSCCoercion s a b
unsafeFollowVSC c a b
_ = VSCCoercion s a b
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
unsafeFloutVSC :: (Coercible a b, StaticDimension a ~ StaticDimension b)
=> c b a -> VSCCoercion s a b
unsafeFloutVSC :: forall a b (c :: Type -> Type -> Type) s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
c b a -> VSCCoercion s a b
unsafeFloutVSC c b a
_ = VSCCoercion s a b
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
instance Category (VSCCoercion s) where
type Object (VSCCoercion s) v = (TensorSpace v, Scalar v ~ s)
id :: forall a. Object (VSCCoercion s) a => VSCCoercion s a a
id = VSCCoercion s a a
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
VSCCoercion s b c
VSCCoercion . :: forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
. VSCCoercion s a b
VSCCoercion = VSCCoercion s a c
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
instance EnhancedCat Coercion (VSCCoercion s) where
arr :: forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object Coercion b, Object Coercion c) =>
VSCCoercion s b c -> Coercion b c
arr = VSCCoercion s b c -> Coercion b c
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion
instance EnhancedCat (->) (VSCCoercion s) where
arr :: forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c, Object (->) b,
Object (->) c) =>
VSCCoercion s b c -> b -> c
arr VSCCoercion s b c
VSCCoercion b
x = b -> c
forall a b. Coercible a b => a -> b
coerce b
x
infixr 0 -+$=>
(-+$=>) :: VSCCoercion s a b -> a -> b
VSCCoercion s a b
VSCCoercion -+$=> :: forall s a b. VSCCoercion s a b -> a -> b
-+$=> a
x = a -> b
forall a b. Coercible a b => a -> b
coerce a
x
class (DimensionAware v, PseudoAffine v) => TensorSpace v where
type TensorProduct v w :: Type
scalarSpaceWitness :: ScalarSpaceWitness v
linearManifoldWitness :: LinearManifoldWitness v
zeroTensor :: (TensorSpace w, Scalar w ~ Scalar v)
=> v ⊗ w
toFlatTensor :: v -+> (v ⊗ Scalar v)
fromFlatTensor :: (v ⊗ Scalar v) -+> v
addTensors :: (TensorSpace w, Scalar w ~ Scalar v)
=> (v ⊗ w) -> (v ⊗ w) -> v ⊗ w
default addTensors :: AdditiveGroup (TensorProduct v w) => (v ⊗ w) -> (v ⊗ w) -> v ⊗ w
addTensors (Tensor TensorProduct v w
vw₀) (Tensor TensorProduct v w
vw₁) = TensorProduct v w -> Tensor (Scalar v) v w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (TensorProduct v w -> Tensor (Scalar v) v w)
-> TensorProduct v w -> Tensor (Scalar v) v w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ TensorProduct v w
vw₀ TensorProduct v w -> TensorProduct v w -> TensorProduct v w
forall v. AdditiveGroup v => v -> v -> v
^+^ TensorProduct v w
vw₁
subtractTensors :: (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v)
=> (v ⊗ w) -> (v ⊗ w) -> v ⊗ w
default subtractTensors :: AdditiveGroup (TensorProduct v w) => (v ⊗ w) -> (v ⊗ w) -> v ⊗ w
subtractTensors (Tensor TensorProduct v w
vw₀) (Tensor TensorProduct v w
vw₁) = TensorProduct v w -> Tensor (Scalar v) v w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (TensorProduct v w -> Tensor (Scalar v) v w)
-> TensorProduct v w -> Tensor (Scalar v) v w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ TensorProduct v w
vw₀ TensorProduct v w -> TensorProduct v w -> TensorProduct v w
forall v. AdditiveGroup v => v -> v -> v
^-^ TensorProduct v w
vw₁
scaleTensor :: (TensorSpace w, Scalar w ~ Scalar v)
=> Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
default scaleTensor
:: (VectorSpace (TensorProduct v w), Scalar (TensorProduct v w) ~ Scalar v)
=> Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
scaleTensor = (Scalar v -> Tensor (Scalar v) v w -> Tensor (Scalar v) v w)
-> LinearFunction
(Scalar (Scalar v))
(Scalar v)
(LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) v w)
(Tensor (Scalar v) v w))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((Scalar v -> Tensor (Scalar v) v w -> Tensor (Scalar v) v w)
-> LinearFunction
(Scalar (Scalar v))
(Scalar v)
(LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) v w)
(Tensor (Scalar v) v w)))
-> (Scalar v -> Tensor (Scalar v) v w -> Tensor (Scalar v) v w)
-> LinearFunction
(Scalar (Scalar v))
(Scalar v)
(LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) v w)
(Tensor (Scalar v) v w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \Scalar v
μ (Tensor TensorProduct v w
vw) -> TensorProduct v w -> Tensor (Scalar v) v w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (TensorProduct v w -> Tensor (Scalar v) v w)
-> TensorProduct v w -> Tensor (Scalar v) v w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Scalar v
Scalar (TensorProduct v w)
μScalar (TensorProduct v w)
-> TensorProduct v w -> TensorProduct v w
forall v. VectorSpace v => Scalar v -> v -> v
*^TensorProduct v w
vw
negateTensor :: (TensorSpace w, Scalar w ~ Scalar v)
=> (v ⊗ w) -+> (v ⊗ w)
default negateTensor :: AdditiveGroup (TensorProduct v w) => (v ⊗ w) -+> (v ⊗ w)
negateTensor = (Tensor (Scalar v) v w -> Tensor (Scalar v) v w)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor (Scalar v) v w -> Tensor (Scalar v) v w)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w))
-> (Tensor (Scalar v) v w -> Tensor (Scalar v) v w)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Tensor TensorProduct v w
vw) -> TensorProduct v w -> Tensor (Scalar v) v w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (TensorProduct v w -> Tensor (Scalar v) v w)
-> TensorProduct v w -> Tensor (Scalar v) v w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ TensorProduct v w -> TensorProduct v w
forall v. AdditiveGroup v => v -> v
negateV TensorProduct v w
vw
tensorProduct :: (TensorSpace w, Scalar w ~ Scalar v)
=> Bilinear v w (v ⊗ w)
tensorProducts :: (TensorSpace w, Scalar w ~ Scalar v)
=> [(v,w)] -> (v ⊗ w)
tensorProducts [(v, w)]
vws = [Tensor (Scalar v) v w] -> Tensor (Scalar v) v w
forall (f :: Type -> Type) v.
(Foldable f, AdditiveGroup v) =>
f v -> v
sumV [ LinearFunction (Scalar v) w (Tensor (Scalar v) v w)
-> w -> Tensor (Scalar v) v w
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction (
LinearFunction
(Scalar v) v (LinearFunction (Scalar v) w (Tensor (Scalar v) v w))
-> v -> LinearFunction (Scalar v) w (Tensor (Scalar v) v w)
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar v) v (LinearFunction (Scalar v) w (Tensor (Scalar v) v w))
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProduct v
v) w
w
| (v
v,w
w) <- [(v, w)]
vws ]
transposeTensor :: (TensorSpace w, Scalar w ~ Scalar v)
=> (v ⊗ w) -+> (w ⊗ v)
fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar v, Scalar x ~ Scalar v)
=> Bilinear (w -+> x) (v⊗w) (v⊗x)
fzipTensorWith :: ( TensorSpace u, TensorSpace w, TensorSpace x
, Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v )
=> Bilinear ((w,x) -+> u) (v⊗w, v⊗x) (v⊗u)
tensorUnsafeFromArrayWithOffset :: ∀ w α n m
. ( n`Dimensional`v
, TensorSpace w, m`Dimensional`w, Scalar w ~ Scalar v
, GArr.Vector α (Scalar v) )
=> Int -> α (Scalar v) -> (v⊗w)
tensorUnsafeWriteArrayWithOffset :: ∀ w α σ n m
. ( n`Dimensional`v
, TensorSpace w, m`Dimensional`w, Scalar w ~ Scalar v
, GArr.Vector α (Scalar v) )
=> GArr.Mutable α σ (Scalar v) -> Int -> (v⊗w) -> ST σ ()
coerceFmapTensorProduct :: ( Hask.Functor p
, TensorSpace a, Scalar a ~ Scalar v
, TensorSpace b, Scalar b ~ Scalar v )
=> p v -> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
wellDefinedVector :: v -> Maybe v
default wellDefinedVector :: Eq v => v -> Maybe v
wellDefinedVector v
v = if v
vv -> v -> Bool
forall a. Eq a => a -> a -> Bool
==v
v then v -> Maybe v
forall a. a -> Maybe a
Just v
v else Maybe v
forall a. Maybe a
Nothing
wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar v) => v⊗w -> Maybe (v⊗w)
infixl 7 ⊗
(⊗) :: ∀ v w . (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v, Num' (Scalar v))
=> v -> w -> v ⊗ w
v
v⊗ :: forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v,
Num' (Scalar v)) =>
v -> w -> v ⊗ w
⊗w
w = (Bilinear v w (Tensor (Scalar v) v w)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductBilinear v w (Tensor (Scalar v) v w)
-> v -> LinearFunction (Scalar v) w (Tensor (Scalar v) v w)
forall s v w. LinearFunction s v w -> v -> w
-+$>v
v)LinearFunction (Scalar v) w (Tensor (Scalar v) v w)
-> w -> Tensor (Scalar v) v w
forall s v w. LinearFunction s v w -> v -> w
-+$>w
w
data DualSpaceWitness v where
DualSpaceWitness :: ( LinearSpace (Scalar v), DualVector (Scalar v) ~ Scalar v
, LinearSpace (DualVector v), Scalar (DualVector v) ~ Scalar v
, DualVector (DualVector v) ~ v
, StaticDimension (DualVector v) ~ StaticDimension v )
=> DualSpaceWitness v
class (TensorSpace v, Num (Scalar v)) => LinearSpace v where
type DualVector v :: Type
dualSpaceWitness :: DualSpaceWitness v
linearId :: v +> v
idTensor :: v ⊗ DualVector v
idTensor = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> Tensor (Scalar (DualVector v)) (DualVector v) v
-+> (v ⊗ DualVector v)
LinearFunction
(Scalar (DualVector v))
(Tensor (Scalar (DualVector v)) (DualVector v) v)
(v ⊗ DualVector v)
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector v)) =>
(DualVector v ⊗ w) -+> (w ⊗ DualVector v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensorLinearFunction
(Scalar (DualVector v))
(Tensor (Scalar (DualVector v)) (DualVector v) v)
(v ⊗ DualVector v)
-> Tensor (Scalar (DualVector v)) (DualVector v) v
-> v ⊗ DualVector v
forall s v w. LinearFunction s v w -> v -> w
-+$>VSCCoercion
(Scalar v)
(LinearMap (Scalar v) v v)
(Tensor (Scalar v) (DualVector v) v)
VSCCoercion
(Scalar v)
(LinearMap (Scalar v) v v)
(Tensor (Scalar (DualVector v)) (DualVector v) v)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
(Scalar v)
(LinearMap (Scalar v) v v)
(Tensor (Scalar (DualVector v)) (DualVector v) v)
-> LinearMap (Scalar v) v v
-> Tensor (Scalar (DualVector v)) (DualVector v) v
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar v) v v
forall v. LinearSpace v => LinearMap (Scalar v) v v
linearId
sampleLinearFunction :: (TensorSpace w, Scalar v ~ Scalar w)
=> (v-+>w) -+> (v+>w)
sampleLinearFunction = case ( ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(ScalarSpaceWitness v
ScalarSpaceWitness, DualSpaceWitness v
DualSpaceWitness) -> ((v -+> w) -> LinearMap (Scalar w) v w)
-> LinearFunction (Scalar w) (v -+> w) (LinearMap (Scalar w) v w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction
(((v -+> w) -> LinearMap (Scalar w) v w)
-> LinearFunction (Scalar w) (v -+> w) (LinearMap (Scalar w) v w))
-> ((v -+> w) -> LinearMap (Scalar w) v w)
-> LinearFunction (Scalar w) (v -+> w) (LinearMap (Scalar w) v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \v -+> w
f -> LinearFunction
(Scalar w) (LinearMap (Scalar w) v v) (LinearMap (Scalar w) v w)
-> LinearMap (Scalar w) v v -> LinearMap (Scalar w) v w
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction ((v -+> w)
-> LinearFunction
(Scalar w) (LinearMap (Scalar w) v v) (LinearMap (Scalar w) v w)
forall a b.
(Object (LinearFunction (Scalar w)) a,
Object (LinearFunction (Scalar w)) (LinearMap (Scalar w) v a),
Object (LinearFunction (Scalar w)) b,
Object (LinearFunction (Scalar w)) (LinearMap (Scalar w) v b)) =>
LinearFunction (Scalar w) a b
-> LinearFunction
(Scalar w) (LinearMap (Scalar w) v a) (LinearMap (Scalar w) v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap v -+> w
f) LinearMap (Scalar w) v v
forall a.
Object (LinearMap (Scalar w)) a =>
LinearMap (Scalar w) a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id
toLinearForm :: DualVector v -+> (v+>Scalar v)
toLinearForm = case ( ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(ScalarSpaceWitness v
ScalarSpaceWitness,DualSpaceWitness v
DualSpaceWitness) -> LinearFunction
(Scalar v)
(DualVector v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
DualVector v -+> (DualVector v ⊗ Scalar (DualVector v))
forall v. TensorSpace v => v -+> (v ⊗ Scalar v)
toFlatTensor LinearFunction
(Scalar v)
(DualVector v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
(v +> Scalar v)
-> LinearFunction (Scalar v) (DualVector v) (v +> Scalar v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
(v +> Scalar v)
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
(v +> Scalar v)
forall b c.
(Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c,
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction (Scalar v)) c) =>
VSCCoercion (Scalar v) b c -> LinearFunction (Scalar v) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
(v +> Scalar v)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor
fromLinearForm :: (v+>Scalar v) -+> DualVector v
fromLinearForm = case ( ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(ScalarSpaceWitness v
ScalarSpaceWitness,DualSpaceWitness v
DualSpaceWitness) -> VSCCoercion
(Scalar v)
(v +> Scalar v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
-> LinearFunction
(Scalar v)
(v +> Scalar v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
forall b c.
(Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c,
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction (Scalar v)) c) =>
VSCCoercion (Scalar v) b c -> LinearFunction (Scalar v) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
(Scalar v)
(v +> Scalar v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor LinearFunction
(Scalar v)
(v +> Scalar v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
(DualVector v)
-> LinearFunction (Scalar v) (v +> Scalar v) (DualVector v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar v)
(Tensor (Scalar v) (DualVector v) (Scalar v))
(DualVector v)
(DualVector v ⊗ Scalar (DualVector v)) -+> DualVector v
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor
coerceDoubleDual :: VSCCoercion (Scalar v) v (DualVector (DualVector v))
coerceDoubleDual = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> VSCCoercion (Scalar v) v v
VSCCoercion (Scalar v) v (DualVector (DualVector v))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
trace :: (v+>v) -+> Scalar v
trace = case ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v of
ScalarSpaceWitness v
ScalarSpaceWitness -> Bilinear
(LinearMap (Scalar v) v v)
(LinearFunction (Scalar v) v v)
(Scalar v)
-> Bilinear
(LinearFunction (Scalar v) v v)
(LinearMap (Scalar v) v v)
(Scalar v)
forall v w y. Bilinear v w y -> Bilinear w v y
flipBilin Bilinear
(LinearMap (Scalar v) v v)
(LinearFunction (Scalar v) v v)
(Scalar v)
forall w.
(LinearSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) (w -+> v) (Scalar v)
forall v w.
(LinearSpace v, LinearSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) (w -+> v) (Scalar v)
contractLinearMapAgainstLinearFunction
(Scalar (LinearFunction (Scalar v) v v))
(LinearFunction (Scalar v) v v)
(LinearFunction (Scalar v) (LinearMap (Scalar v) v v) (Scalar v))
-> LinearFunction (Scalar v) v v
-> LinearFunction (Scalar v) (LinearMap (Scalar v) v v) (Scalar v)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar v) v v
forall a.
Object (LinearFunction (Scalar v)) a =>
LinearFunction (Scalar v) a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id
contractTensorMap :: (TensorSpace w, Scalar w ~ Scalar v)
=> (v+>(v⊗w)) -+> w
contractTensorMap = case ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v of
ScalarSpaceWitness v
ScalarSpaceWitness -> VSCCoercion
(Scalar v)
(v +> (v ⊗ w))
(Tensor (Scalar v) (LinearMap (Scalar v) v v) w)
-> LinearFunction
(Scalar v)
(v +> (v ⊗ w))
(Tensor (Scalar v) (LinearMap (Scalar v) v v) w)
forall b c.
(Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c,
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction (Scalar v)) c) =>
VSCCoercion (Scalar v) b c -> LinearFunction (Scalar v) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
(Scalar v)
(v +> (v ⊗ w))
(Tensor (Scalar v) (LinearMap (Scalar v) v v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap LinearFunction
(Scalar v)
(v +> (v ⊗ w))
(Tensor (Scalar v) (LinearMap (Scalar v) v v) w)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) (LinearMap (Scalar v) v v) w) w
-> LinearFunction (Scalar v) (v +> (v ⊗ w)) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar v)
(Tensor (Scalar v) (LinearMap (Scalar v) v v) w)
(Tensor (Scalar v) w (LinearMap (Scalar v) v v))
(LinearMap (Scalar v) v v ⊗ w) -+> (w ⊗ LinearMap (Scalar v) v v)
forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap (Scalar v) v v)) =>
(LinearMap (Scalar v) v v ⊗ w) -+> (w ⊗ LinearMap (Scalar v) v v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
(Scalar v)
(Tensor (Scalar v) (LinearMap (Scalar v) v v) w)
(Tensor (Scalar v) w (LinearMap (Scalar v) v v))
-> LinearFunction
(Scalar v) (Tensor (Scalar v) w (LinearMap (Scalar v) v v)) w
-> LinearFunction
(Scalar v) (Tensor (Scalar v) (LinearMap (Scalar v) v v) w) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> (LinearMap (Scalar v) v v -+> Scalar v)
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) w (LinearMap (Scalar v) v v))
(Tensor (Scalar v) w (Scalar v))
forall a b.
(Object (LinearFunction (Scalar (Scalar v))) a,
Object (LinearFunction (Scalar v)) (Tensor (Scalar v) w a),
Object (LinearFunction (Scalar (Scalar v))) b,
Object (LinearFunction (Scalar v)) (Tensor (Scalar v) w b)) =>
LinearFunction (Scalar (Scalar v)) a b
-> LinearFunction
(Scalar v) (Tensor (Scalar v) w a) (Tensor (Scalar v) w b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearMap (Scalar v) v v -+> Scalar v
forall v. LinearSpace v => LinearMap (Scalar v) v v -+> Scalar v
trace LinearFunction
(Scalar v)
(Tensor (Scalar v) w (LinearMap (Scalar v) v v))
(Tensor (Scalar v) w (Scalar v))
-> LinearFunction (Scalar v) (Tensor (Scalar v) w (Scalar v)) w
-> LinearFunction
(Scalar v) (Tensor (Scalar v) w (LinearMap (Scalar v) v v)) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction (Scalar v) (Tensor (Scalar v) w (Scalar v)) w
(w ⊗ Scalar w) -+> w
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor
contractMapTensor :: (TensorSpace w, Scalar w ~ Scalar v)
=> (v⊗(v+>w)) -+> w
contractMapTensor = case ( ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(ScalarSpaceWitness v
ScalarSpaceWitness,DualSpaceWitness v
DualSpaceWitness)
-> VSCCoercion
(Scalar v) (v ⊗ (v +> w)) (Tensor (Scalar v) (v ⊗ DualVector v) w)
-> LinearFunction
(Scalar v) (v ⊗ (v +> w)) (Tensor (Scalar v) (v ⊗ DualVector v) w)
forall b c.
(Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c,
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction (Scalar v)) c) =>
VSCCoercion (Scalar v) b c -> LinearFunction (Scalar v) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (VSCCoercion
(Scalar v)
(v ⊗ (v +> w))
(LinearMap (Scalar v) (LinearMap (Scalar v) v v) w)
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (Tensor s u (LinearMap s v w)) (LinearMap s (LinearMap s u v) w)
coUncurryLinearMapVSCCoercion
(Scalar v)
(v ⊗ (v +> w))
(LinearMap (Scalar v) (LinearMap (Scalar v) v v) w)
-> VSCCoercion
(Scalar v)
(LinearMap (Scalar v) (LinearMap (Scalar v) v v) w)
(Tensor (Scalar v) (v ⊗ DualVector v) w)
-> VSCCoercion
(Scalar v) (v ⊗ (v +> w)) (Tensor (Scalar v) (v ⊗ DualVector v) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>>VSCCoercion
(Scalar v)
(LinearMap (Scalar v) (LinearMap (Scalar v) v v) w)
(Tensor (Scalar v) (v ⊗ DualVector v) w)
VSCCoercion
(Scalar v)
(LinearMap (Scalar v) (LinearMap (Scalar v) v v) w)
(Tensor (Scalar v) (DualVector (LinearMap (Scalar v) v v)) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor)
LinearFunction
(Scalar v) (v ⊗ (v +> w)) (Tensor (Scalar v) (v ⊗ DualVector v) w)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) (v ⊗ DualVector v) w) w
-> LinearFunction (Scalar v) (v ⊗ (v +> w)) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar v)
(Tensor (Scalar v) (v ⊗ DualVector v) w)
(Tensor (Scalar v) w (v ⊗ DualVector v))
((v ⊗ DualVector v) ⊗ w) -+> (w ⊗ (v ⊗ DualVector v))
forall w.
(TensorSpace w, Scalar w ~ Scalar (v ⊗ DualVector v)) =>
((v ⊗ DualVector v) ⊗ w) -+> (w ⊗ (v ⊗ DualVector v))
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor LinearFunction
(Scalar v)
(Tensor (Scalar v) (v ⊗ DualVector v) w)
(Tensor (Scalar v) w (v ⊗ DualVector v))
-> LinearFunction
(Scalar v) (Tensor (Scalar v) w (v ⊗ DualVector v)) w
-> LinearFunction
(Scalar v) (Tensor (Scalar v) (v ⊗ DualVector v) w) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar (Scalar (DualVector v))) (v ⊗ DualVector v) (Scalar v)
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) w (v ⊗ DualVector v))
(Tensor (Scalar v) w (Scalar v))
forall a b.
(Object (LinearFunction (Scalar (Scalar (DualVector v)))) a,
Object (LinearFunction (Scalar v)) (Tensor (Scalar v) w a),
Object (LinearFunction (Scalar (Scalar (DualVector v)))) b,
Object (LinearFunction (Scalar v)) (Tensor (Scalar v) w b)) =>
LinearFunction (Scalar (Scalar (DualVector v))) a b
-> LinearFunction
(Scalar v) (Tensor (Scalar v) w a) (Tensor (Scalar v) w b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (VSCCoercion
(Scalar v)
(v ⊗ DualVector v)
(LinearMap (Scalar v) (DualVector v) (DualVector v))
-> LinearFunction
(Scalar (Scalar (DualVector v)))
(v ⊗ DualVector v)
(LinearMap (Scalar v) (DualVector v) (DualVector v))
forall b c.
(Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c,
Object (LinearFunction (Scalar (Scalar (DualVector v)))) b,
Object (LinearFunction (Scalar (Scalar (DualVector v)))) c) =>
VSCCoercion (Scalar v) b c
-> LinearFunction (Scalar (Scalar (DualVector v))) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
(Scalar v)
(v ⊗ DualVector v)
(LinearMap (Scalar v) (DualVector v) (DualVector v))
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap LinearFunction
(Scalar (Scalar (DualVector v)))
(v ⊗ DualVector v)
(LinearMap (Scalar v) (DualVector v) (DualVector v))
-> LinearFunction
(Scalar (Scalar (DualVector v)))
(LinearMap (Scalar v) (DualVector v) (DualVector v))
(Scalar v)
-> LinearFunction
(Scalar (Scalar (DualVector v))) (v ⊗ DualVector v) (Scalar v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar (Scalar (DualVector v)))
(LinearMap (Scalar v) (DualVector v) (DualVector v))
(Scalar v)
(DualVector v +> DualVector v) -+> Scalar (DualVector v)
forall v. LinearSpace v => LinearMap (Scalar v) v v -+> Scalar v
trace)
LinearFunction
(Scalar v)
(Tensor (Scalar v) w (v ⊗ DualVector v))
(Tensor (Scalar v) w (Scalar v))
-> LinearFunction (Scalar v) (Tensor (Scalar v) w (Scalar v)) w
-> LinearFunction
(Scalar v) (Tensor (Scalar v) w (v ⊗ DualVector v)) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction (Scalar v) (Tensor (Scalar v) w (Scalar v)) w
(w ⊗ Scalar w) -+> w
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor
contractTensorFn :: ∀ w . (TensorSpace w, Scalar w ~ Scalar v)
=> (v-+>(v⊗w)) -+> w
contractTensorFn = (LinearFunction (Scalar v) v (Tensor (Scalar v) v w) -> w)
-> LinearFunction
(Scalar v) (LinearFunction (Scalar v) v (Tensor (Scalar v) v w)) w
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction (Scalar v) v (Tensor (Scalar v) v w) -> w)
-> LinearFunction
(Scalar v) (LinearFunction (Scalar v) v (Tensor (Scalar v) v w)) w)
-> (LinearFunction (Scalar v) v (Tensor (Scalar v) v w) -> w)
-> LinearFunction
(Scalar v) (LinearFunction (Scalar v) v (Tensor (Scalar v) v w)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction
(Scalar (Tensor (Scalar v) v w))
(LinearFunction (Scalar v) v (Tensor (Scalar v) v w))
(LinearMap (Scalar v) v (Tensor (Scalar v) v w))
-> LinearFunction (Scalar v) v (Tensor (Scalar v) v w)
-> LinearMap (Scalar v) v (Tensor (Scalar v) v w)
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar (Tensor (Scalar v) v w))
(LinearFunction (Scalar v) v (Tensor (Scalar v) v w))
(LinearMap (Scalar v) v (Tensor (Scalar v) v w))
LinearFunction
(Scalar (Tensor (Scalar v) v w)) v (Tensor (Scalar v) v w)
-+> LinearMap (Scalar v) v (Tensor (Scalar v) v w)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
sampleLinearFunction
(LinearFunction (Scalar v) v (Tensor (Scalar v) v w)
-> LinearMap (Scalar v) v (Tensor (Scalar v) v w))
-> (LinearMap (Scalar v) v (Tensor (Scalar v) v w) -> w)
-> LinearFunction (Scalar v) v (Tensor (Scalar v) v w)
-> w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar v) (LinearMap (Scalar v) v (Tensor (Scalar v) v w)) w
-> LinearMap (Scalar v) v (Tensor (Scalar v) v w) -> w
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar v) (LinearMap (Scalar v) v (Tensor (Scalar v) v w)) w
LinearMap (Scalar v) v (Tensor (Scalar v) v w) -+> w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v +> (v ⊗ w)) -+> w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v +> (v ⊗ w)) -+> w
contractTensorMap
contractLinearMapAgainst :: (LinearSpace w, Scalar w ~ Scalar v)
=> Bilinear (v+>w) (w-+>v) (Scalar v)
contractLinearMapAgainst = case ( ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(ScalarSpaceWitness v
ScalarSpaceWitness,DualSpaceWitness v
DualSpaceWitness) -> VSCCoercion
(Scalar v) (v +> w) (Tensor (Scalar v) (DualVector v) w)
-> LinearFunction
(Scalar v) (v +> w) (Tensor (Scalar v) (DualVector v) w)
forall b c.
(Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c,
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction (Scalar v)) c) =>
VSCCoercion (Scalar v) b c -> LinearFunction (Scalar v) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
(Scalar v) (v +> w) (Tensor (Scalar v) (DualVector v) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor LinearFunction
(Scalar v) (v +> w) (Tensor (Scalar v) (DualVector v) w)
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (DualVector v) w)
(LinearFunction (Scalar v) (w -+> v) (Scalar v))
-> LinearFunction
(Scalar v)
(v +> w)
(LinearFunction (Scalar v) (w -+> v) (Scalar v))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar v)
(Tensor (Scalar v) (DualVector v) w)
(Tensor (Scalar v) w (DualVector v))
(DualVector v ⊗ w) -+> (w ⊗ DualVector v)
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector v)) =>
(DualVector v ⊗ w) -+> (w ⊗ DualVector v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
(Scalar v)
(Tensor (Scalar v) (DualVector v) w)
(Tensor (Scalar v) w (DualVector v))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) w (DualVector v))
(LinearFunction (Scalar v) (w -+> v) (Scalar v))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (DualVector v) w)
(LinearFunction (Scalar v) (w -+> v) (Scalar v))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar v)
(Tensor (Scalar v) w (DualVector v))
(LinearFunction (Scalar v) (LinearMap (Scalar v) w v) (Scalar v))
Bilinear
(DualVector (LinearMap (Scalar v) w v))
(LinearMap (Scalar v) w v)
(Scalar (LinearMap (Scalar v) w v))
forall v.
(LinearSpace v, LinearSpace v) =>
Bilinear (DualVector v) v (Scalar v)
applyDualVector LinearFunction
(Scalar v)
(Tensor (Scalar v) w (DualVector v))
(LinearFunction (Scalar v) (LinearMap (Scalar v) w v) (Scalar v))
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) (LinearMap (Scalar v) w v) (Scalar v))
(LinearFunction (Scalar v) (w -+> v) (Scalar v))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) w (DualVector v))
(LinearFunction (Scalar v) (w -+> v) (Scalar v))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> (LinearFunction (Scalar v) (LinearMap (Scalar v) w v) (Scalar v)
-> LinearFunction (Scalar v) (w -+> v) (Scalar v))
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) (LinearMap (Scalar v) w v) (Scalar v))
(LinearFunction (Scalar v) (w -+> v) (Scalar v))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (LinearFunction (Scalar v) (LinearMap (Scalar v) w v) (Scalar v)
-> LinearFunction (Scalar v) (w -+> v) (LinearMap (Scalar v) w v)
-> LinearFunction (Scalar v) (w -+> v) (Scalar v)
forall a b c.
(Object (LinearFunction (Scalar v)) a,
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction (Scalar v)) c) =>
LinearFunction (Scalar v) b c
-> LinearFunction (Scalar v) a b -> LinearFunction (Scalar v) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction (Scalar v) (w -+> v) (LinearMap (Scalar v) w v)
(w -+> v) -+> (w +> v)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar w ~ Scalar w) =>
(w -+> w) -+> (w +> w)
sampleLinearFunction)
applyDualVector :: LinearSpace v
=> Bilinear (DualVector v) v (Scalar v)
applyLinear :: (TensorSpace w, Scalar w ~ Scalar v)
=> Bilinear (v+>w) v w
composeLinear :: ( LinearSpace w, TensorSpace x
, Scalar w ~ Scalar v, Scalar x ~ Scalar v )
=> Bilinear (w+>x) (v+>w) (v+>x)
composeLinear = case ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v of
ScalarSpaceWitness v
ScalarSpaceWitness -> (LinearMap (Scalar v) w x
-> LinearFunction (Scalar v) (v +> w) (v +> x))
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) w x)
(LinearFunction (Scalar v) (v +> w) (v +> x))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearMap (Scalar v) w x
-> LinearFunction (Scalar v) (v +> w) (v +> x))
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) w x)
(LinearFunction (Scalar v) (v +> w) (v +> x)))
-> (LinearMap (Scalar v) w x
-> LinearFunction (Scalar v) (v +> w) (v +> x))
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) w x)
(LinearFunction (Scalar v) (v +> w) (v +> x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearMap (Scalar v) w x
f -> LinearFunction (Scalar v) w x
-> LinearFunction (Scalar v) (v +> w) (v +> x)
forall a b.
(Object (LinearFunction (Scalar v)) a,
Object (LinearFunction (Scalar v)) (LinearMap (Scalar v) v a),
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction (Scalar v)) (LinearMap (Scalar v) v b)) =>
LinearFunction (Scalar v) a b
-> LinearFunction
(Scalar v) (LinearMap (Scalar v) v a) (LinearMap (Scalar v) v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction
(Scalar v)
(LinearMap (Scalar v) w x)
(LinearFunction (Scalar v) w x)
Bilinear (w +> x) w x
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar w) =>
Bilinear (w +> w) w w
applyLinearLinearFunction
(Scalar v)
(LinearMap (Scalar v) w x)
(LinearFunction (Scalar v) w x)
-> LinearMap (Scalar v) w x -> LinearFunction (Scalar v) w x
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar v) w x
f)
tensorId :: (LinearSpace w, Scalar w ~ Scalar v)
=> (v⊗w)+>(v⊗w)
applyTensorFunctional :: ( LinearSpace u, Scalar u ~ Scalar v )
=> Bilinear (DualVector (v⊗u)) (v⊗u) (Scalar v)
applyTensorLinMap :: ( LinearSpace u, TensorSpace w
, Scalar u ~ Scalar v, Scalar w ~ Scalar v )
=> Bilinear ((v⊗u)+>w) (v⊗u) w
useTupleLinearSpaceComponents :: (v ~ (x,y))
=> ((LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ) -> φ
fmapLinearMap :: ∀ s v w x . ( LinearSpace v, TensorSpace w, TensorSpace x
, Scalar v ~ s, Scalar w ~ s, Scalar x ~ s )
=> Bilinear (LinearFunction s w x) (v+>w) (v+>x)
fmapLinearMap :: forall s v w x.
(LinearSpace v, TensorSpace w, TensorSpace x, Scalar v ~ s,
Scalar w ~ s, Scalar x ~ s) =>
Bilinear (LinearFunction s w x) (v +> w) (v +> x)
fmapLinearMap = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> (LinearFunction s w x -> LinearMap s v w -> LinearMap s v x)
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction s (LinearMap s v w) (LinearMap s v x))
(LinearFunction s w x -> LinearMap s v w -> LinearMap s v x)
-> Bilinear
(LinearFunction s w x) (LinearMap s v w) (LinearMap s v x)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction
((LinearFunction s w x -> LinearMap s v w -> LinearMap s v x)
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction s (LinearMap s v w) (LinearMap s v x)))
-> (LinearFunction s w x -> LinearMap s v w -> LinearMap s v x)
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction s (LinearMap s v w) (LinearMap s v x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction s w x
f -> VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
-> LinearMap s v w -> Tensor s (DualVector v) w
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c, Object (->) b,
Object (->) c) =>
VSCCoercion s b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor (LinearMap s v w -> Tensor s (DualVector v) w)
-> (Tensor s (DualVector v) w -> LinearMap s v x)
-> LinearMap s v w
-> LinearMap s v x
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
s (Tensor s (DualVector v) w) (Tensor s (DualVector v) x)
-> Tensor s (DualVector v) w -> Tensor s (DualVector v) x
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction (Bilinear (w -+> x) (DualVector v ⊗ w) (DualVector v ⊗ x)
LinearFunction
(Scalar (DualVector v))
(LinearFunction s w x)
(LinearFunction
s (Tensor s (DualVector v) w) (Tensor s (DualVector v) x))
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (DualVector v),
Scalar x ~ Scalar (DualVector v)) =>
Bilinear (w -+> x) (DualVector v ⊗ w) (DualVector v ⊗ x)
fmapTensorLinearFunction
(Scalar (DualVector v))
(LinearFunction s w x)
(LinearFunction
s (Tensor s (DualVector v) w) (Tensor s (DualVector v) x))
-> LinearFunction s w x
-> LinearFunction
s (Tensor s (DualVector v) w) (Tensor s (DualVector v) x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction s w x
f) (Tensor s (DualVector v) w -> Tensor s (DualVector v) x)
-> (Tensor s (DualVector v) x -> LinearMap s v x)
-> Tensor s (DualVector v) w
-> LinearMap s v x
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion s (Tensor s (DualVector v) x) (LinearMap s v x)
-> Tensor s (DualVector v) x -> LinearMap s v x
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c, Object (->) b,
Object (->) c) =>
VSCCoercion s b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion s (Tensor s (DualVector v) x) (LinearMap s v x)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor
instance DimensionAware (ZeroDim s) where
type StaticDimension (ZeroDim s) = 'Just 0
dimensionalityWitness :: DimensionalityWitness (ZeroDim s)
dimensionalityWitness = DimensionalityWitness (ZeroDim s)
forall (n :: Nat) v. Dimensional n v => DimensionalityWitness v
IsStaticDimensional
instance 0`Dimensional`ZeroDim s where
unsafeFromArrayWithOffset :: forall (α :: Type -> Type).
Vector α (Scalar (ZeroDim s)) =>
Int -> α (Scalar (ZeroDim s)) -> ZeroDim s
unsafeFromArrayWithOffset Int
_ α (Scalar (ZeroDim s))
_ = ZeroDim s
forall s. ZeroDim s
Origin
unsafeWriteArrayWithOffset :: forall (α :: Type -> Type) σ.
Vector α (Scalar (ZeroDim s)) =>
Mutable α σ (Scalar (ZeroDim s)) -> Int -> ZeroDim s -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (ZeroDim s))
_ Int
_ ZeroDim s
_ = () -> ST σ ()
forall (m :: Type -> Type) a. Monad m (->) => a -> m a
return ()
instance Num' s => TensorSpace (ZeroDim s) where
type TensorProduct (ZeroDim s) v = ZeroDim s
scalarSpaceWitness :: ScalarSpaceWitness (ZeroDim s)
scalarSpaceWitness = case ClosedScalarWitness s
forall s. Num' s => ClosedScalarWitness s
closedScalarWitness :: ClosedScalarWitness s of
ClosedScalarWitness s
ClosedScalarWitness -> ScalarSpaceWitness (ZeroDim s)
forall v.
(Num' (Scalar v), Scalar (Scalar v) ~ Scalar v) =>
ScalarSpaceWitness v
ScalarSpaceWitness
linearManifoldWitness :: LinearManifoldWitness (ZeroDim s)
linearManifoldWitness = LinearManifoldWitness (ZeroDim s)
forall v.
(Needle v ~ v, AffineSpace v, Diff v ~ v) =>
LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
zeroTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
ZeroDim s ⊗ w
zeroTensor = TensorProduct (ZeroDim s) w -> Tensor s (ZeroDim s) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ZeroDim s
TensorProduct (ZeroDim s) w
forall s. ZeroDim s
Origin
toFlatTensor :: ZeroDim s -+> (ZeroDim s ⊗ Scalar (ZeroDim s))
toFlatTensor = (ZeroDim s -> Tensor s (ZeroDim s) s)
-> LinearFunction s (ZeroDim s) (Tensor s (ZeroDim s) s)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((ZeroDim s -> Tensor s (ZeroDim s) s)
-> LinearFunction s (ZeroDim s) (Tensor s (ZeroDim s) s))
-> (ZeroDim s -> Tensor s (ZeroDim s) s)
-> LinearFunction s (ZeroDim s) (Tensor s (ZeroDim s) s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \ZeroDim s
Origin -> TensorProduct (ZeroDim s) s -> Tensor s (ZeroDim s) s
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ZeroDim s
TensorProduct (ZeroDim s) s
forall s. ZeroDim s
Origin
fromFlatTensor :: (ZeroDim s ⊗ Scalar (ZeroDim s)) -+> ZeroDim s
fromFlatTensor = (Tensor s (ZeroDim s) s -> ZeroDim s)
-> LinearFunction s (Tensor s (ZeroDim s) s) (ZeroDim s)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor s (ZeroDim s) s -> ZeroDim s)
-> LinearFunction s (Tensor s (ZeroDim s) s) (ZeroDim s))
-> (Tensor s (ZeroDim s) s -> ZeroDim s)
-> LinearFunction s (Tensor s (ZeroDim s) s) (ZeroDim s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Tensor ZeroDim s
TensorProduct (ZeroDim s) s
Origin) -> ZeroDim s
forall s. ZeroDim s
Origin
negateTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
(ZeroDim s ⊗ w) -+> (ZeroDim s ⊗ w)
negateTensor = (Tensor s (ZeroDim s) w -> Tensor s (ZeroDim s) w)
-> LinearFunction
s (Tensor s (ZeroDim s) w) (Tensor s (ZeroDim s) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction Tensor s (ZeroDim s) w -> Tensor s (ZeroDim s) w
forall a. Object (->) a => a -> a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id
scaleTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
Bilinear (Scalar (ZeroDim s)) (ZeroDim s ⊗ w) (ZeroDim s ⊗ w)
scaleTensor = Bilinear s (Tensor s (ZeroDim s) w) (Tensor s (ZeroDim s) w)
LinearFunction
(Scalar (Scalar (ZeroDim s)))
(Scalar (ZeroDim s))
(LinearFunction
(Scalar (Scalar (ZeroDim s)))
(Tensor (Scalar (ZeroDim s)) (ZeroDim s) w)
(Tensor (Scalar (ZeroDim s)) (ZeroDim s) w))
forall v a b. AdditiveGroup v => Bilinear a b v
biConst0
addTensors :: forall w.
(TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
(ZeroDim s ⊗ w) -> (ZeroDim s ⊗ w) -> ZeroDim s ⊗ w
addTensors (Tensor ZeroDim s
TensorProduct (ZeroDim s) w
Origin) (Tensor ZeroDim s
TensorProduct (ZeroDim s) w
Origin) = TensorProduct (ZeroDim s) w -> Tensor s (ZeroDim s) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ZeroDim s
TensorProduct (ZeroDim s) w
forall s. ZeroDim s
Origin
subtractTensors :: forall w.
(TensorSpace (ZeroDim s), TensorSpace w,
Scalar w ~ Scalar (ZeroDim s)) =>
(ZeroDim s ⊗ w) -> (ZeroDim s ⊗ w) -> ZeroDim s ⊗ w
subtractTensors (Tensor ZeroDim s
TensorProduct (ZeroDim s) w
Origin) (Tensor ZeroDim s
TensorProduct (ZeroDim s) w
Origin) = TensorProduct (ZeroDim s) w -> Tensor s (ZeroDim s) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ZeroDim s
TensorProduct (ZeroDim s) w
forall s. ZeroDim s
Origin
tensorProduct :: forall w.
(TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
Bilinear (ZeroDim s) w (ZeroDim s ⊗ w)
tensorProduct = Bilinear (ZeroDim s) w (Tensor s (ZeroDim s) w)
LinearFunction
(Scalar (ZeroDim s))
(ZeroDim s)
(LinearFunction
(Scalar (ZeroDim s)) w (Tensor (Scalar (ZeroDim s)) (ZeroDim s) w))
forall v a b. AdditiveGroup v => Bilinear a b v
biConst0
transposeTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
(ZeroDim s ⊗ w) -+> (w ⊗ ZeroDim s)
transposeTensor = LinearFunction s (Tensor s (ZeroDim s) w) (Tensor s w (ZeroDim s))
LinearFunction
(Scalar (w ⊗ ZeroDim s))
(Tensor (Scalar (ZeroDim s)) (ZeroDim s) w)
(w ⊗ ZeroDim s)
forall w s v. AdditiveGroup w => LinearFunction s v w
const0
fmapTensor :: forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (ZeroDim s),
Scalar x ~ Scalar (ZeroDim s)) =>
Bilinear (w -+> x) (ZeroDim s ⊗ w) (ZeroDim s ⊗ x)
fmapTensor = Bilinear
(LinearFunction s w x)
(Tensor s (ZeroDim s) w)
(Tensor s (ZeroDim s) x)
LinearFunction
(Scalar (w -+> x))
(w -+> x)
(LinearFunction
(Scalar (w -+> x))
(Tensor (Scalar (ZeroDim s)) (ZeroDim s) w)
(Tensor (Scalar (ZeroDim s)) (ZeroDim s) x))
forall v a b. AdditiveGroup v => Bilinear a b v
biConst0
fzipTensorWith :: forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (ZeroDim s), Scalar w ~ Scalar (ZeroDim s),
Scalar x ~ Scalar (ZeroDim s)) =>
Bilinear
((w, x) -+> u) (ZeroDim s ⊗ w, ZeroDim s ⊗ x) (ZeroDim s ⊗ u)
fzipTensorWith = Bilinear
(LinearFunction s (w, x) u)
(Tensor s (ZeroDim s) w, Tensor s (ZeroDim s) x)
(Tensor s (ZeroDim s) u)
LinearFunction
(Scalar ((w, x) -+> u))
((w, x) -+> u)
(LinearFunction
(Scalar ((w, x) -+> u))
(Tensor (Scalar (ZeroDim s)) (ZeroDim s) w,
Tensor (Scalar (ZeroDim s)) (ZeroDim s) x)
(Tensor (Scalar (ZeroDim s)) (ZeroDim s) u))
forall v a b. AdditiveGroup v => Bilinear a b v
biConst0
tensorUnsafeFromArrayWithOffset :: forall w (α :: Type -> Type) (n :: Nat) (m :: Nat).
(Dimensional n (ZeroDim s), TensorSpace w, Dimensional m w,
Scalar w ~ Scalar (ZeroDim s), Vector α (Scalar (ZeroDim s))) =>
Int -> α (Scalar (ZeroDim s)) -> ZeroDim s ⊗ w
tensorUnsafeFromArrayWithOffset Int
_ α (Scalar (ZeroDim s))
_ = TensorProduct (ZeroDim s) w -> Tensor s (ZeroDim s) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ZeroDim s
TensorProduct (ZeroDim s) w
forall s. ZeroDim s
Origin
tensorUnsafeWriteArrayWithOffset :: forall w (α :: Type -> Type) σ (n :: Nat) (m :: Nat).
(Dimensional n (ZeroDim s), TensorSpace w, Dimensional m w,
Scalar w ~ Scalar (ZeroDim s), Vector α (Scalar (ZeroDim s))) =>
Mutable α σ (Scalar (ZeroDim s))
-> Int -> (ZeroDim s ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset Mutable α σ (Scalar (ZeroDim s))
_ Int
_ (Tensor ZeroDim s
TensorProduct (ZeroDim s) w
Origin) = () -> ST σ ()
forall (m :: Type -> Type) a. Monad m (->) => a -> m a
return ()
coerceFmapTensorProduct :: forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (ZeroDim s),
TensorSpace b, Scalar b ~ Scalar (ZeroDim s)) =>
p (ZeroDim s)
-> VSCCoercion (Scalar (ZeroDim s)) a b
-> Coercion
(TensorProduct (ZeroDim s) a) (TensorProduct (ZeroDim s) b)
coerceFmapTensorProduct p (ZeroDim s)
_ VSCCoercion (Scalar (ZeroDim s)) a b
VSCCoercion = Coercion (ZeroDim s) (ZeroDim s)
Coercion
(TensorProduct (ZeroDim s) a) (TensorProduct (ZeroDim s) b)
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion
wellDefinedVector :: ZeroDim s -> Maybe (ZeroDim s)
wellDefinedVector ZeroDim s
Origin = ZeroDim s -> Maybe (ZeroDim s)
forall a. a -> Maybe a
Just ZeroDim s
forall s. ZeroDim s
Origin
wellDefinedTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
(ZeroDim s ⊗ w) -> Maybe (ZeroDim s ⊗ w)
wellDefinedTensor (Tensor ZeroDim s
TensorProduct (ZeroDim s) w
Origin) = Tensor s (ZeroDim s) w -> Maybe (Tensor s (ZeroDim s) w)
forall a. a -> Maybe a
Just (TensorProduct (ZeroDim s) w -> Tensor s (ZeroDim s) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ZeroDim s
TensorProduct (ZeroDim s) w
forall s. ZeroDim s
Origin)
instance Num' s => LinearSpace (ZeroDim s) where
type DualVector (ZeroDim s) = ZeroDim s
dualSpaceWitness :: DualSpaceWitness (ZeroDim s)
dualSpaceWitness = case ClosedScalarWitness s
forall s. Num' s => ClosedScalarWitness s
closedScalarWitness :: ClosedScalarWitness s of
ClosedScalarWitness s
ClosedScalarWitness -> DualSpaceWitness (ZeroDim s)
forall v.
(LinearSpace (Scalar v), DualVector (Scalar v) ~ Scalar v,
LinearSpace (DualVector v), Scalar (DualVector v) ~ Scalar v,
DualVector (DualVector v) ~ v,
StaticDimension (DualVector v) ~ StaticDimension v) =>
DualSpaceWitness v
DualSpaceWitness
linearId :: ZeroDim s +> ZeroDim s
linearId = TensorProduct (DualVector (ZeroDim s)) (ZeroDim s)
-> LinearMap s (ZeroDim s) (ZeroDim s)
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap ZeroDim s
TensorProduct (DualVector (ZeroDim s)) (ZeroDim s)
forall s. ZeroDim s
Origin
idTensor :: ZeroDim s ⊗ DualVector (ZeroDim s)
idTensor = TensorProduct (ZeroDim s) (ZeroDim s)
-> Tensor s (ZeroDim s) (ZeroDim s)
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ZeroDim s
TensorProduct (ZeroDim s) (ZeroDim s)
forall s. ZeroDim s
Origin
tensorId :: forall w.
(LinearSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
(ZeroDim s ⊗ w) +> (ZeroDim s ⊗ w)
tensorId = TensorProduct
(DualVector (Tensor s (ZeroDim s) w)) (Tensor s (ZeroDim s) w)
-> LinearMap s (Tensor s (ZeroDim s) w) (Tensor s (ZeroDim s) w)
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap ZeroDim s
TensorProduct
(DualVector (Tensor s (ZeroDim s) w)) (Tensor s (ZeroDim s) w)
forall s. ZeroDim s
Origin
toLinearForm :: DualVector (ZeroDim s) -+> (ZeroDim s +> Scalar (ZeroDim s))
toLinearForm = (ZeroDim s -> LinearMap s (ZeroDim s) s)
-> LinearFunction s (ZeroDim s) (LinearMap s (ZeroDim s) s)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((ZeroDim s -> LinearMap s (ZeroDim s) s)
-> LinearFunction s (ZeroDim s) (LinearMap s (ZeroDim s) s))
-> (LinearMap s (ZeroDim s) s
-> ZeroDim s -> LinearMap s (ZeroDim s) s)
-> LinearMap s (ZeroDim s) s
-> LinearFunction s (ZeroDim s) (LinearMap s (ZeroDim s) s)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearMap s (ZeroDim s) s -> ZeroDim s -> LinearMap s (ZeroDim s) s
forall b x. (Object (->) b, ObjectPoint (->) x) => x -> b -> x
forall (a :: Type -> Type -> Type) b x.
(WellPointed a, Object a b, ObjectPoint a x) =>
x -> a b x
const (LinearMap s (ZeroDim s) s
-> LinearFunction s (ZeroDim s) (LinearMap s (ZeroDim s) s))
-> LinearMap s (ZeroDim s) s
-> LinearFunction s (ZeroDim s) (LinearMap s (ZeroDim s) s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ TensorProduct (DualVector (ZeroDim s)) s
-> LinearMap s (ZeroDim s) s
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap ZeroDim s
TensorProduct (DualVector (ZeroDim s)) s
forall s. ZeroDim s
Origin
fromLinearForm :: (ZeroDim s +> Scalar (ZeroDim s)) -+> DualVector (ZeroDim s)
fromLinearForm = LinearFunction s (LinearMap s (ZeroDim s) s) (ZeroDim s)
(ZeroDim s +> Scalar (ZeroDim s)) -+> DualVector (ZeroDim s)
forall w s v. AdditiveGroup w => LinearFunction s v w
const0
coerceDoubleDual :: VSCCoercion
(Scalar (ZeroDim s))
(ZeroDim s)
(DualVector (DualVector (ZeroDim s)))
coerceDoubleDual = VSCCoercion s (ZeroDim s) (ZeroDim s)
VSCCoercion
(Scalar (ZeroDim s))
(ZeroDim s)
(DualVector (DualVector (ZeroDim s)))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
contractTensorMap :: forall w.
(TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
(ZeroDim s +> (ZeroDim s ⊗ w)) -+> w
contractTensorMap = LinearFunction
s (LinearMap s (ZeroDim s) (Tensor s (ZeroDim s) w)) w
LinearFunction
(Scalar w)
(LinearMap
(Scalar (ZeroDim s))
(ZeroDim s)
(Tensor (Scalar (ZeroDim s)) (ZeroDim s) w))
w
forall w s v. AdditiveGroup w => LinearFunction s v w
const0
contractMapTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
(ZeroDim s ⊗ (ZeroDim s +> w)) -+> w
contractMapTensor = LinearFunction
s (Tensor s (ZeroDim s) (LinearMap s (ZeroDim s) w)) w
LinearFunction
(Scalar w)
(Tensor
(Scalar (ZeroDim s))
(ZeroDim s)
(LinearMap (Scalar (ZeroDim s)) (ZeroDim s) w))
w
forall w s v. AdditiveGroup w => LinearFunction s v w
const0
contractLinearMapAgainst :: forall w.
(LinearSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
Bilinear (ZeroDim s +> w) (w -+> ZeroDim s) (Scalar (ZeroDim s))
contractLinearMapAgainst = Bilinear
(LinearMap s (ZeroDim s) w) (LinearFunction s w (ZeroDim s)) s
LinearFunction
(Scalar (ZeroDim s +> w))
(ZeroDim s +> w)
(LinearFunction
(Scalar (ZeroDim s +> w))
(LinearFunction (Scalar (ZeroDim s)) w (ZeroDim s))
(Scalar (ZeroDim s)))
forall v a b. AdditiveGroup v => Bilinear a b v
biConst0
applyDualVector :: LinearSpace (ZeroDim s) =>
Bilinear (DualVector (ZeroDim s)) (ZeroDim s) (Scalar (ZeroDim s))
applyDualVector = Bilinear (ZeroDim s) (ZeroDim s) s
Bilinear (DualVector (ZeroDim s)) (ZeroDim s) (Scalar (ZeroDim s))
forall v a b. AdditiveGroup v => Bilinear a b v
biConst0
applyLinear :: forall w.
(TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) =>
Bilinear (ZeroDim s +> w) (ZeroDim s) w
applyLinear = Bilinear (LinearMap s (ZeroDim s) w) (ZeroDim s) w
LinearFunction
(Scalar (ZeroDim s +> w))
(ZeroDim s +> w)
(LinearFunction (Scalar (ZeroDim s +> w)) (ZeroDim s) w)
forall v a b. AdditiveGroup v => Bilinear a b v
biConst0
applyTensorFunctional :: forall u.
(LinearSpace u, Scalar u ~ Scalar (ZeroDim s)) =>
Bilinear
(DualVector (ZeroDim s ⊗ u)) (ZeroDim s ⊗ u) (Scalar (ZeroDim s))
applyTensorFunctional = Bilinear
(LinearMap s (ZeroDim s) (DualVector u)) (Tensor s (ZeroDim s) u) s
LinearFunction
(Scalar (DualVector (ZeroDim s ⊗ u)))
(DualVector (ZeroDim s ⊗ u))
(LinearFunction
(Scalar (DualVector (ZeroDim s ⊗ u)))
(ZeroDim s ⊗ u)
(Scalar (ZeroDim s)))
forall v a b. AdditiveGroup v => Bilinear a b v
biConst0
applyTensorLinMap :: forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (ZeroDim s),
Scalar w ~ Scalar (ZeroDim s)) =>
Bilinear ((ZeroDim s ⊗ u) +> w) (ZeroDim s ⊗ u) w
applyTensorLinMap = Bilinear
(LinearMap s (Tensor s (ZeroDim s) u) w) (Tensor s (ZeroDim s) u) w
LinearFunction
(Scalar ((ZeroDim s ⊗ u) +> w))
((ZeroDim s ⊗ u) +> w)
(LinearFunction (Scalar ((ZeroDim s ⊗ u) +> w)) (ZeroDim s ⊗ u) w)
forall v a b. AdditiveGroup v => Bilinear a b v
biConst0
composeLinear :: forall w x.
(LinearSpace w, TensorSpace x, Scalar w ~ Scalar (ZeroDim s),
Scalar x ~ Scalar (ZeroDim s)) =>
Bilinear (w +> x) (ZeroDim s +> w) (ZeroDim s +> x)
composeLinear = Bilinear
(LinearMap s w x)
(LinearMap s (ZeroDim s) w)
(LinearMap s (ZeroDim s) x)
LinearFunction
(Scalar (w +> x))
(w +> x)
(LinearFunction
(Scalar (w +> x))
(LinearMap (Scalar (ZeroDim s)) (ZeroDim s) w)
(LinearMap (Scalar (ZeroDim s)) (ZeroDim s) x))
forall v a b. AdditiveGroup v => Bilinear a b v
biConst0
useTupleLinearSpaceComponents :: forall x y φ.
(ZeroDim s ~ (x, y)) =>
((LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ) -> φ
useTupleLinearSpaceComponents (LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ
_ = φ
forall a. a
usingNonTupleTypeAsTupleError
newtype LinearMap s v w = LinearMap {forall s v w. LinearMap s v w -> TensorProduct (DualVector v) w
getLinearMap :: TensorProduct (DualVector v) w}
newtype Tensor s v w = Tensor {forall s v w. Tensor s v w -> TensorProduct v w
getTensorProduct :: TensorProduct v w}
asTensor :: ∀ s v w . LinearSpace v
=> VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor :: forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor = case forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @v of
DualSpaceWitness v
DualSpaceWitness -> VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
fromTensor :: ∀ s v w . LinearSpace v
=> VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor :: forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor = case forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @v of
DualSpaceWitness v
DualSpaceWitness -> VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
asLinearMap :: ∀ s v w . (LinearSpace v, Scalar v ~ s)
=> VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap :: forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
fromLinearMap :: ∀ s v w . (LinearSpace v, Scalar v ~ s)
=> VSCCoercion s (LinearMap s (DualVector v) w) (Tensor s v w)
fromLinearMap :: forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (LinearMap s (DualVector v) w) (Tensor s v w)
fromLinearMap = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> VSCCoercion s (LinearMap s (DualVector v) w) (Tensor s v w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
pseudoFmapTensorLHS :: ( TensorProduct v w ~ TensorProduct v' w
, StaticDimension v ~ StaticDimension v' )
=> c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS :: forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS c v v'
_ = VSCCoercion s (Tensor s v w) (Tensor s v' w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
pseudoPrecomposeLinmap
:: ( TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w
, StaticDimension v ~ StaticDimension v' )
=> c v' v -> VSCCoercion s (LinearMap s v w) (LinearMap s v' w)
pseudoPrecomposeLinmap :: forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w,
StaticDimension v ~ StaticDimension v') =>
c v' v -> VSCCoercion s (LinearMap s v w) (LinearMap s v' w)
pseudoPrecomposeLinmap c v' v
_ = VSCCoercion s (LinearMap s v w) (LinearMap s v' w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
envTensorLHSCoercion :: ( TensorProduct v w ~ TensorProduct v' w
, TensorProduct v w' ~ TensorProduct v' w' )
=> c v v' -> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion :: forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion c v v'
i (LinearFunction Tensor s v w -> Tensor s v w'
f) = (Tensor s v' w -> Tensor s v' w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor s v' w -> Tensor s v' w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w'))
-> (Tensor s v' w -> Tensor s v' w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Tensor s v w -> Tensor s v w') -> Tensor s v' w -> Tensor s v' w'
forall a b. Coercible a b => a -> b
coerce Tensor s v w -> Tensor s v w'
f
envLinmapPrecomposeCoercion
:: ( TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w
, TensorProduct (DualVector v) w' ~ TensorProduct (DualVector v') w' )
=> c v' v -> LinearFunction s' (LinearMap s v w) (LinearMap s v w')
-> LinearFunction s' (LinearMap s v' w) (LinearMap s v' w')
envLinmapPrecomposeCoercion :: forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w,
TensorProduct (DualVector v) w'
~ TensorProduct (DualVector v') w') =>
c v' v
-> LinearFunction s' (LinearMap s v w) (LinearMap s v w')
-> LinearFunction s' (LinearMap s v' w) (LinearMap s v' w')
envLinmapPrecomposeCoercion c v' v
i (LinearFunction LinearMap s v w -> LinearMap s v w'
f) = (LinearMap s v' w -> LinearMap s v' w')
-> LinearFunction s' (LinearMap s v' w) (LinearMap s v' w')
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearMap s v' w -> LinearMap s v' w')
-> LinearFunction s' (LinearMap s v' w) (LinearMap s v' w'))
-> (LinearMap s v' w -> LinearMap s v' w')
-> LinearFunction s' (LinearMap s v' w) (LinearMap s v' w')
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (LinearMap s v w -> LinearMap s v w')
-> LinearMap s v' w -> LinearMap s v' w'
forall a b. Coercible a b => a -> b
coerce LinearMap s v w -> LinearMap s v w'
f
type v +> w = LinearMap (Scalar v) v w
type v ⊗ w = Tensor (Scalar v) v w
type LSpace v = ( LinearSpace v, Num' (Scalar v) )
instance (LinearSpace v, TensorSpace w, Scalar v~s, Scalar w~s)
=> AdditiveGroup (LinearMap s v w) where
zeroV :: LinearMap s v w
zeroV = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
-> Tensor s (DualVector v) w -> LinearMap s v w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor s (DualVector v) w
DualVector v ⊗ w
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector v)) =>
DualVector v ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor
LinearMap s v w
m^+^ :: LinearMap s v w -> LinearMap s v w -> LinearMap s v w
^+^LinearMap s v w
n = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
-> Tensor s (DualVector v) w -> LinearMap s v w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensorVSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
-> LinearMap s v w -> Tensor s (DualVector v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$LinearMap s v w
m) Tensor s (DualVector v) w
-> Tensor s (DualVector v) w -> Tensor s (DualVector v) w
forall v. AdditiveGroup v => v -> v -> v
^+^ (VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensorVSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
-> LinearMap s v w -> Tensor s (DualVector v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$LinearMap s v w
n)
LinearMap s v w
m^-^ :: LinearMap s v w -> LinearMap s v w -> LinearMap s v w
^-^LinearMap s v w
n = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
-> Tensor s (DualVector v) w -> LinearMap s v w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensorVSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
-> LinearMap s v w -> Tensor s (DualVector v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$LinearMap s v w
m) Tensor s (DualVector v) w
-> Tensor s (DualVector v) w -> Tensor s (DualVector v) w
forall v. AdditiveGroup v => v -> v -> v
^-^ (VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensorVSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
-> LinearMap s v w -> Tensor s (DualVector v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$LinearMap s v w
n)
negateV :: LinearMap s v w -> LinearMap s v w
negateV = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> (VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensorVSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
-> Tensor s (DualVector v) w -> LinearMap s v w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$) (Tensor s (DualVector v) w -> LinearMap s v w)
-> (LinearMap s v w -> Tensor s (DualVector v) w)
-> LinearMap s v w
-> LinearMap s v w
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Tensor s (DualVector v) w -> Tensor s (DualVector v) w
forall v. AdditiveGroup v => v -> v
negateV (Tensor s (DualVector v) w -> Tensor s (DualVector v) w)
-> (LinearMap s v w -> Tensor s (DualVector v) w)
-> LinearMap s v w
-> Tensor s (DualVector v) w
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. (VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensorVSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
-> LinearMap s v w -> Tensor s (DualVector v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$)
instance ∀ v w s . (LinearSpace v, TensorSpace w, Scalar v~s, Scalar w~s)
=> VectorSpace (LinearMap s v w) where
type Scalar (LinearMap s v w) = s
Scalar (LinearMap s v w)
μ*^ :: Scalar (LinearMap s v w) -> LinearMap s v w -> LinearMap s v w
*^LinearMap s v w
v = case ( DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v
, ScalarSpaceWitness w
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness w ) of
(DualSpaceWitness v
DualSpaceWitness, ScalarSpaceWitness w
ScalarSpaceWitness)
-> VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
-> Tensor s (DualVector v) w -> LinearMap s v w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (LinearFunction
(Scalar (Scalar (DualVector v)))
(Scalar (DualVector v))
(LinearFunction
(Scalar (Scalar (DualVector v)))
(Tensor (Scalar (DualVector v)) (DualVector v) w)
(Tensor s (DualVector v) w))
Bilinear
(Scalar (DualVector v))
(Tensor (Scalar (DualVector v)) (DualVector v) w)
(Tensor (Scalar (DualVector v)) (DualVector v) w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector v)) =>
Bilinear
(Scalar (DualVector v)) (DualVector v ⊗ w) (DualVector v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
scaleTensorLinearFunction
(Scalar (Scalar (DualVector v)))
(Scalar (DualVector v))
(LinearFunction
(Scalar (Scalar (DualVector v)))
(Tensor (Scalar (DualVector v)) (DualVector v) w)
(Tensor s (DualVector v) w))
-> Scalar (DualVector v)
-> LinearFunction
(Scalar (Scalar (DualVector v)))
(Tensor (Scalar (DualVector v)) (DualVector v) w)
(Tensor s (DualVector v) w)
forall s v w. LinearFunction s v w -> v -> w
-+$>Scalar (LinearMap s v w)
Scalar (DualVector v)
μ) LinearFunction
(Scalar (Scalar (DualVector v)))
(Tensor (Scalar (DualVector v)) (DualVector v) w)
(Tensor s (DualVector v) w)
-> Tensor (Scalar (DualVector v)) (DualVector v) w
-> Tensor s (DualVector v) w
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
VSCCoercion
s
(LinearMap s v w)
(Tensor (Scalar (DualVector v)) (DualVector v) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
s
(LinearMap s v w)
(Tensor (Scalar (DualVector v)) (DualVector v) w)
-> LinearMap s v w
-> Tensor (Scalar (DualVector v)) (DualVector v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s v w
v
instance ∀ v w s . (LinearSpace v, TensorSpace w, Scalar v~s, Scalar w~s)
=> Semimanifold (LinearMap s v w) where
type Needle (LinearMap s v w) = LinearMap s v w
#if !MIN_VERSION_manifolds_core(0,6,0)
toInterior = pure
fromInterior = id
translateP = Tagged (^+^)
#endif
.+~^ :: LinearMap s v w -> Needle (LinearMap s v w) -> LinearMap s v w
(.+~^) = LinearMap s v w -> Needle (LinearMap s v w) -> LinearMap s v w
LinearMap s v w -> LinearMap s v w -> LinearMap s v w
forall v. AdditiveGroup v => v -> v -> v
(^+^)
instance ∀ v w s . (LinearSpace v, TensorSpace w, Scalar v~s, Scalar w~s)
=> PseudoAffine (LinearMap s v w) where
LinearMap s v w
f.-~. :: LinearMap s v w
-> LinearMap s v w -> Maybe (Needle (LinearMap s v w))
.-~.LinearMap s v w
g = LinearMap s v w -> Maybe (LinearMap s v w)
forall (m :: Type -> Type) a. Monad m (->) => a -> m a
return (LinearMap s v w -> Maybe (LinearMap s v w))
-> LinearMap s v w -> Maybe (LinearMap s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s v w
fLinearMap s v w -> LinearMap s v w -> LinearMap s v w
forall v. AdditiveGroup v => v -> v -> v
^-^LinearMap s v w
g
.-~! :: HasCallStack =>
LinearMap s v w -> LinearMap s v w -> Needle (LinearMap s v w)
(.-~!) = LinearMap s v w -> LinearMap s v w -> Needle (LinearMap s v w)
LinearMap s v w -> LinearMap s v w -> LinearMap s v w
forall v. AdditiveGroup v => v -> v -> v
(^-^)
instance (TensorSpace v, TensorSpace w, Scalar v~s, Scalar w~s)
=> AdditiveGroup (Tensor s v w) where
zeroV :: Tensor s v w
zeroV = Tensor s v w
v ⊗ w
forall w. (TensorSpace w, Scalar w ~ Scalar v) => v ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor
^+^ :: Tensor s v w -> Tensor s v w -> Tensor s v w
(^+^) = Tensor s v w -> Tensor s v w -> Tensor s v w
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
addTensors
^-^ :: Tensor s v w -> Tensor s v w -> Tensor s v w
(^-^) = Tensor s v w -> Tensor s v w -> Tensor s v w
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
forall v w.
(TensorSpace v, TensorSpace v, TensorSpace w,
Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
forall w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
subtractTensors
negateV :: Tensor s v w -> Tensor s v w
negateV = LinearFunction s (Tensor s v w) (Tensor s v w)
-> Tensor s v w -> Tensor s v w
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction s (Tensor s v w) (Tensor s v w)
(v ⊗ w) -+> (v ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
negateTensor
instance (TensorSpace v, TensorSpace w, Scalar v~s, Scalar w~s)
=> VectorSpace (Tensor s v w) where
type Scalar (Tensor s v w) = s
Scalar (Tensor s v w)
μ*^ :: Scalar (Tensor s v w) -> Tensor s v w -> Tensor s v w
*^Tensor s v w
t = (LinearFunction
(Scalar s)
s
(LinearFunction (Scalar s) (Tensor s v w) (Tensor s v w))
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
scaleTensorLinearFunction
(Scalar s)
s
(LinearFunction (Scalar s) (Tensor s v w) (Tensor s v w))
-> s -> LinearFunction (Scalar s) (Tensor s v w) (Tensor s v w)
forall s v w. LinearFunction s v w -> v -> w
-+$>s
Scalar (Tensor s v w)
μ)LinearFunction (Scalar s) (Tensor s v w) (Tensor s v w)
-> Tensor s v w -> Tensor s v w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor s v w
t
instance (TensorSpace v, TensorSpace w, Scalar v~s, Scalar w~s)
=> Semimanifold (Tensor s v w) where
type Needle (Tensor s v w) = Tensor s v w
#if !MIN_VERSION_manifolds_core(0,6,0)
toInterior = pure
fromInterior = id
translateP = Tagged (^+^)
#endif
.+~^ :: Tensor s v w -> Needle (Tensor s v w) -> Tensor s v w
(.+~^) = Tensor s v w -> Needle (Tensor s v w) -> Tensor s v w
Tensor s v w -> Tensor s v w -> Tensor s v w
forall v. AdditiveGroup v => v -> v -> v
(^+^)
instance (TensorSpace v, TensorSpace w, Scalar v~s, Scalar w~s)
=> PseudoAffine (Tensor s v w) where
Tensor s v w
f.-~. :: Tensor s v w -> Tensor s v w -> Maybe (Needle (Tensor s v w))
.-~.Tensor s v w
g = Tensor s v w -> Maybe (Tensor s v w)
forall (m :: Type -> Type) a. Monad m (->) => a -> m a
return (Tensor s v w -> Maybe (Tensor s v w))
-> Tensor s v w -> Maybe (Tensor s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor s v w
fTensor s v w -> Tensor s v w -> Tensor s v w
forall v. AdditiveGroup v => v -> v -> v
^-^Tensor s v w
g
.-~! :: HasCallStack =>
Tensor s v w -> Tensor s v w -> Needle (Tensor s v w)
(.-~!) = Tensor s v w -> Tensor s v w -> Needle (Tensor s v w)
Tensor s v w -> Tensor s v w -> Tensor s v w
forall v. AdditiveGroup v => v -> v -> v
(^-^)
infixr 6 ⊕, >+<, <⊕
(<⊕) :: (u⊗w) -> (v⊗w) -> (u,v)⊗w
Tensor (Scalar u) u w
m <⊕ :: forall u w v. (u ⊗ w) -> (v ⊗ w) -> (u, v) ⊗ w
<⊕ Tensor (Scalar v) v w
n = (Tensor (Scalar u) u w, Tensor (Scalar v) v w)
-> Tensor (Scalar u) (u, v) w
TensorProduct (u, v) w -> Tensor (Scalar u) (u, v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ((Tensor (Scalar u) u w, Tensor (Scalar v) v w)
-> Tensor (Scalar u) (u, v) w)
-> (Tensor (Scalar u) u w, Tensor (Scalar v) v w)
-> Tensor (Scalar u) (u, v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Tensor (Scalar u) u w
m, Tensor (Scalar v) v w
n)
(⊕) :: (u+>w) -> (v+>w) -> (u,v)+>w
LinearMap TensorProduct (DualVector u) w
m ⊕ :: forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
⊕ LinearMap TensorProduct (DualVector v) w
n = (Tensor (Scalar (DualVector u)) (DualVector u) w,
Tensor (Scalar (DualVector v)) (DualVector v) w)
-> LinearMap (Scalar u) (u, v) w
TensorProduct (DualVector (u, v)) w
-> LinearMap (Scalar u) (u, v) w
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap ((Tensor (Scalar (DualVector u)) (DualVector u) w,
Tensor (Scalar (DualVector v)) (DualVector v) w)
-> LinearMap (Scalar u) (u, v) w)
-> (Tensor (Scalar (DualVector u)) (DualVector u) w,
Tensor (Scalar (DualVector v)) (DualVector v) w)
-> LinearMap (Scalar u) (u, v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (TensorProduct (DualVector u) w
-> Tensor (Scalar (DualVector u)) (DualVector u) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (DualVector u) w
m, TensorProduct (DualVector v) w
-> Tensor (Scalar (DualVector v)) (DualVector v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (DualVector v) w
n)
(>+<) :: (u+>w) -> (v+>w) -> (u,v)+>w
>+< :: forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
(>+<) = (u +> w) -> (v +> w) -> (u, v) +> w
forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
(⊕)
instance Category (LinearMap s) where
type Object (LinearMap s) v = (LinearSpace v, Scalar v ~ s)
id :: forall a. Object (LinearMap s) a => LinearMap s a a
id = LinearMap s a a
a +> a
forall v. LinearSpace v => LinearMap (Scalar v) v v
linearId
. :: forall a b c.
(Object (LinearMap s) a, Object (LinearMap s) b,
Object (LinearMap s) c) =>
LinearMap s b c -> LinearMap s a b -> LinearMap s a c
(.) = DualSpaceWitness a
-> LinearMap s b c -> LinearMap s a b -> LinearMap s a c
forall v w x.
(LinearSpace v, Scalar v ~ s, LinearSpace w, Scalar w ~ s,
TensorSpace x, Scalar x ~ s) =>
DualSpaceWitness v
-> LinearMap s w x -> LinearMap s v w -> LinearMap s v x
lmc DualSpaceWitness a
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness
where lmc :: ∀ v w x . ( LinearSpace v, Scalar v ~ s
, LinearSpace w, Scalar w ~ s
, TensorSpace x, Scalar x ~ s )
=> DualSpaceWitness v
-> LinearMap s w x -> LinearMap s v w -> LinearMap s v x
lmc :: forall v w x.
(LinearSpace v, Scalar v ~ s, LinearSpace w, Scalar w ~ s,
TensorSpace x, Scalar x ~ s) =>
DualSpaceWitness v
-> LinearMap s w x -> LinearMap s v w -> LinearMap s v x
lmc DualSpaceWitness v
DualSpaceWitness = LinearFunction s (LinearMap s v w) (LinearMap s v x)
-> LinearMap s v w -> LinearMap s v x
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction (LinearFunction s (LinearMap s v w) (LinearMap s v x)
-> LinearMap s v w -> LinearMap s v x)
-> (LinearMap s w x
-> LinearFunction s (LinearMap s v w) (LinearMap s v x))
-> LinearMap s w x
-> LinearMap s v w
-> LinearMap s v x
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar v)
(LinearMap s w x)
(LinearFunction s (LinearMap s v w) (LinearMap s v x))
-> LinearMap s w x
-> LinearFunction s (LinearMap s v w) (LinearMap s v x)
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar v)
(LinearMap s w x)
(LinearFunction s (LinearMap s v w) (LinearMap s v x))
Bilinear (w +> x) (v +> w) (v +> x)
forall v w x.
(LinearSpace v, LinearSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w +> x) (v +> w) (v +> x)
forall w x.
(LinearSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w +> x) (v +> w) (v +> x)
composeLinear
instance Num' s => Cartesian (LinearMap s) where
type UnitObject (LinearMap s) = ZeroDim s
swap :: forall a b.
(ObjectPair (LinearMap s) a b, ObjectPair (LinearMap s) b a) =>
LinearMap s (a, b) (b, a)
swap = (LinearFunction s a (b, a)
-> LinearFunction s (LinearMap s a a) (LinearMap s a (b, a))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s a a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s a b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s a a) (LinearMap s a b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction s a b
forall w s v. AdditiveGroup w => LinearFunction s v w
const0LinearFunction s a b
-> LinearFunction s a a -> LinearFunction s a (b, a)
forall b c c'.
(Object (LinearFunction s) b,
ObjectPair (LinearFunction s) c c') =>
LinearFunction s b c
-> LinearFunction s b c' -> LinearFunction s b (c, c')
forall (a :: Type -> Type -> Type) b c c'.
(PreArrow a, Object a b, ObjectPair a c c') =>
a b c -> a b c' -> a b (c, c')
&&&LinearFunction s a a
forall a. Object (LinearFunction s) a => LinearFunction s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id) LinearFunction s (LinearMap s a a) (LinearMap s a (b, a))
-> LinearMap s a a -> LinearMap s a (b, a)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s a a
forall a. Object (LinearMap s) a => LinearMap s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id) LinearMap (Scalar a) a (b, a) -> (b +> (b, a)) -> (a, b) +> (b, a)
forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
⊕ (LinearFunction s b (b, a)
-> LinearFunction s (LinearMap s b b) (LinearMap s b (b, a))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s b a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s b b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s b a) (LinearMap s b b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction s b b
forall a. Object (LinearFunction s) a => LinearFunction s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
idLinearFunction s b b
-> LinearFunction s b a -> LinearFunction s b (b, a)
forall b c c'.
(Object (LinearFunction s) b,
ObjectPair (LinearFunction s) c c') =>
LinearFunction s b c
-> LinearFunction s b c' -> LinearFunction s b (c, c')
forall (a :: Type -> Type -> Type) b c c'.
(PreArrow a, Object a b, ObjectPair a c c') =>
a b c -> a b c' -> a b (c, c')
&&&LinearFunction s b a
forall w s v. AdditiveGroup w => LinearFunction s v w
const0) LinearFunction s (LinearMap s b b) (LinearMap s b (b, a))
-> LinearMap s b b -> LinearMap s b (b, a)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s b b
forall a. Object (LinearMap s) a => LinearMap s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id)
attachUnit :: forall unit a.
(unit ~ UnitObject (LinearMap s),
ObjectPair (LinearMap s) a unit) =>
LinearMap s a (a, unit)
attachUnit = LinearFunction s a (a, unit)
-> LinearFunction s (LinearMap s a a) (LinearMap s a (a, unit))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s a a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s a b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s a a) (LinearMap s a b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction s a a
forall a. Object (LinearFunction s) a => LinearFunction s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
idLinearFunction s a a
-> LinearFunction s a unit -> LinearFunction s a (a, unit)
forall b c c'.
(Object (LinearFunction s) b,
ObjectPair (LinearFunction s) c c') =>
LinearFunction s b c
-> LinearFunction s b c' -> LinearFunction s b (c, c')
forall (a :: Type -> Type -> Type) b c c'.
(PreArrow a, Object a b, ObjectPair a c c') =>
a b c -> a b c' -> a b (c, c')
&&&LinearFunction s a unit
forall w s v. AdditiveGroup w => LinearFunction s v w
const0) LinearFunction s (LinearMap s a a) (LinearMap s a (a, unit))
-> LinearMap s a a -> LinearMap s a (a, unit)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s a a
forall a. Object (LinearMap s) a => LinearMap s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id
detachUnit :: forall unit a.
(unit ~ UnitObject (LinearMap s),
ObjectPair (LinearMap s) a unit) =>
LinearMap s (a, unit) a
detachUnit = LinearMap s (a, unit) a
forall x y. ObjectPair (LinearMap s) x y => LinearMap s (x, y) x
forall (a :: Type -> Type -> Type) x y.
(PreArrow a, ObjectPair a x y) =>
a (x, y) x
fst
regroup :: forall a b c.
(ObjectPair (LinearMap s) a b, ObjectPair (LinearMap s) b c,
ObjectPair (LinearMap s) a (b, c),
ObjectPair (LinearMap s) (a, b) c) =>
LinearMap s (a, (b, c)) ((a, b), c)
regroup = LinearFunction
s
(LinearFunction s (a, (b, c)) ((a, b), c))
(LinearMap s (a, (b, c)) ((a, b), c))
((a, (b, c)) -+> ((a, b), c)) -+> ((a, (b, c)) +> ((a, b), c))
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar (a, (b, c)) ~ Scalar w) =>
((a, (b, c)) -+> w) -+> ((a, (b, c)) +> w)
sampleLinearFunction LinearFunction
s
(LinearFunction s (a, (b, c)) ((a, b), c))
(LinearMap s (a, (b, c)) ((a, b), c))
-> LinearFunction s (a, (b, c)) ((a, b), c)
-> LinearMap s (a, (b, c)) ((a, b), c)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ ((a, (b, c)) -> ((a, b), c))
-> LinearFunction s (a, (b, c)) ((a, b), c)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (a, (b, c)) -> ((a, b), c)
forall a b c.
(ObjectPair (->) a b, ObjectPair (->) b c,
ObjectPair (->) a (b, c), ObjectPair (->) (a, b) c) =>
(a, (b, c)) -> ((a, b), c)
forall (k :: Type -> Type -> Type) a b c.
(Cartesian k, ObjectPair k a b, ObjectPair k b c,
ObjectPair k a (b, c), ObjectPair k (a, b) c) =>
k (a, (b, c)) ((a, b), c)
regroup
regroup' :: forall a b c.
(ObjectPair (LinearMap s) a b, ObjectPair (LinearMap s) b c,
ObjectPair (LinearMap s) a (b, c),
ObjectPair (LinearMap s) (a, b) c) =>
LinearMap s ((a, b), c) (a, (b, c))
regroup' = LinearFunction
s
(LinearFunction s ((a, b), c) (a, (b, c)))
(LinearMap s ((a, b), c) (a, (b, c)))
(((a, b), c) -+> (a, (b, c))) -+> (((a, b), c) +> (a, (b, c)))
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar ((a, b), c) ~ Scalar w) =>
(((a, b), c) -+> w) -+> (((a, b), c) +> w)
sampleLinearFunction LinearFunction
s
(LinearFunction s ((a, b), c) (a, (b, c)))
(LinearMap s ((a, b), c) (a, (b, c)))
-> LinearFunction s ((a, b), c) (a, (b, c))
-> LinearMap s ((a, b), c) (a, (b, c))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (((a, b), c) -> (a, (b, c)))
-> LinearFunction s ((a, b), c) (a, (b, c))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((a, b), c) -> (a, (b, c))
forall a b c.
(ObjectPair (->) a b, ObjectPair (->) b c,
ObjectPair (->) a (b, c), ObjectPair (->) (a, b) c) =>
((a, b), c) -> (a, (b, c))
forall (k :: Type -> Type -> Type) a b c.
(Cartesian k, ObjectPair k a b, ObjectPair k b c,
ObjectPair k a (b, c), ObjectPair k (a, b) c) =>
k ((a, b), c) (a, (b, c))
regroup'
instance Num' s => Morphism (LinearMap s) where
LinearMap s b c
f *** :: forall b b' c c'.
(ObjectPair (LinearMap s) b b', ObjectPair (LinearMap s) c c') =>
LinearMap s b c -> LinearMap s b' c' -> LinearMap s (b, b') (c, c')
*** LinearMap s b' c'
g = (LinearFunction s c (c, c')
-> LinearFunction s (LinearMap s b c) (LinearMap s b (c, c'))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s b a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s b b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s b a) (LinearMap s b b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction s c c
forall a. Object (LinearFunction s) a => LinearFunction s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
idLinearFunction s c c
-> LinearFunction s c c' -> LinearFunction s c (c, c')
forall b c c'.
(Object (LinearFunction s) b,
ObjectPair (LinearFunction s) c c') =>
LinearFunction s b c
-> LinearFunction s b c' -> LinearFunction s b (c, c')
forall (a :: Type -> Type -> Type) b c c'.
(PreArrow a, Object a b, ObjectPair a c c') =>
a b c -> a b c' -> a b (c, c')
&&&LinearFunction s c c'
forall w s v. AdditiveGroup w => LinearFunction s v w
const0) LinearFunction s (LinearMap s b c) (LinearMap s b (c, c'))
-> LinearMap s b c -> LinearMap s b (c, c')
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s b c
f) LinearMap (Scalar b) b (c, c')
-> (b' +> (c, c')) -> (b, b') +> (c, c')
forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
⊕ (LinearFunction s c' (c, c')
-> LinearFunction s (LinearMap s b' c') (LinearMap s b' (c, c'))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s b' a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s b' b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s b' a) (LinearMap s b' b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction s c' c
forall w s v. AdditiveGroup w => LinearFunction s v w
const0LinearFunction s c' c
-> LinearFunction s c' c' -> LinearFunction s c' (c, c')
forall b c c'.
(Object (LinearFunction s) b,
ObjectPair (LinearFunction s) c c') =>
LinearFunction s b c
-> LinearFunction s b c' -> LinearFunction s b (c, c')
forall (a :: Type -> Type -> Type) b c c'.
(PreArrow a, Object a b, ObjectPair a c c') =>
a b c -> a b c' -> a b (c, c')
&&&LinearFunction s c' c'
forall a. Object (LinearFunction s) a => LinearFunction s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id) LinearFunction s (LinearMap s b' c') (LinearMap s b' (c, c'))
-> LinearMap s b' c' -> LinearMap s b' (c, c')
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s b' c'
g)
instance ∀ s . Num' s => PreArrow (LinearMap s) where
&&& :: forall b c c'.
(Object (LinearMap s) b, ObjectPair (LinearMap s) c c') =>
LinearMap s b c -> LinearMap s b c' -> LinearMap s b (c, c')
(&&&) = LinearMap s b c -> LinearMap s b c' -> LinearMap s b (c, c')
forall u v w.
(LinearSpace u, LinearSpace v, LinearSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
LinearMap s u v -> LinearMap s u w -> LinearMap s u (v, w)
lmFanout
where lmFanout :: ∀ u v w . ( LinearSpace u, LinearSpace v, LinearSpace w
, Scalar u~s, Scalar v~s, Scalar w~s )
=> LinearMap s u v -> LinearMap s u w -> LinearMap s u (v,w)
lmFanout :: forall u v w.
(LinearSpace u, LinearSpace v, LinearSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
LinearMap s u v -> LinearMap s u w -> LinearMap s u (v, w)
lmFanout LinearMap s u v
f LinearMap s u w
g = case ( DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v
, DualSpaceWitness w
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness w ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness, DualSpaceWitness w
DualSpaceWitness)
-> VSCCoercion
s (Tensor s (DualVector u) (v, w)) (LinearMap s u (v, w))
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
s (Tensor s (DualVector u) (v, w)) (LinearMap s u (v, w))
-> Tensor s (DualVector u) (v, w) -> LinearMap s u (v, w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Bilinear
((v, w) -+> (v, w))
(Tensor (Scalar (DualVector u)) (DualVector u) v,
Tensor (Scalar (DualVector u)) (DualVector u) w)
(DualVector u ⊗ (v, w))
LinearFunction
(Scalar (DualVector u))
(LinearFunction (Scalar (DualVector u)) (v, w) (v, w))
(LinearFunction
(Scalar (DualVector u))
(Tensor (Scalar (DualVector u)) (DualVector u) v,
Tensor (Scalar (DualVector u)) (DualVector u) w)
(Tensor s (DualVector u) (v, w)))
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (DualVector u), Scalar w ~ Scalar (DualVector u),
Scalar x ~ Scalar (DualVector u)) =>
Bilinear
((w, x) -+> u)
(DualVector u ⊗ w, DualVector u ⊗ x)
(DualVector u ⊗ u)
fzipTensorWithLinearFunction
(Scalar (DualVector u))
(LinearFunction (Scalar (DualVector u)) (v, w) (v, w))
(LinearFunction
(Scalar (DualVector u))
(Tensor (Scalar (DualVector u)) (DualVector u) v,
Tensor (Scalar (DualVector u)) (DualVector u) w)
(Tensor s (DualVector u) (v, w)))
-> LinearFunction (Scalar (DualVector u)) (v, w) (v, w)
-> LinearFunction
(Scalar (DualVector u))
(Tensor (Scalar (DualVector u)) (DualVector u) v,
Tensor (Scalar (DualVector u)) (DualVector u) w)
(Tensor s (DualVector u) (v, w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$LinearFunction (Scalar (DualVector u)) (v, w) (v, w)
forall a.
Object (LinearFunction (Scalar (DualVector u))) a =>
LinearFunction (Scalar (DualVector u)) a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id) LinearFunction
(Scalar (DualVector u))
(Tensor (Scalar (DualVector u)) (DualVector u) v,
Tensor (Scalar (DualVector u)) (DualVector u) w)
(Tensor s (DualVector u) (v, w))
-> (Tensor (Scalar (DualVector u)) (DualVector u) v,
Tensor (Scalar (DualVector u)) (DualVector u) w)
-> Tensor s (DualVector u) (v, w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (VSCCoercion s (LinearMap s u v) (Tensor s (DualVector u) v)
VSCCoercion
s
(LinearMap s u v)
(Tensor (Scalar (DualVector u)) (DualVector u) v)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
s
(LinearMap s u v)
(Tensor (Scalar (DualVector u)) (DualVector u) v)
-> LinearMap s u v
-> Tensor (Scalar (DualVector u)) (DualVector u) v
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s u v
f, VSCCoercion s (LinearMap s u w) (Tensor s (DualVector u) w)
VSCCoercion
s
(LinearMap s u w)
(Tensor (Scalar (DualVector u)) (DualVector u) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
s
(LinearMap s u w)
(Tensor (Scalar (DualVector u)) (DualVector u) w)
-> LinearMap s u w
-> Tensor (Scalar (DualVector u)) (DualVector u) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s u w
g)
terminal :: forall b.
Object (LinearMap s) b =>
LinearMap s b (UnitObject (LinearMap s))
terminal = LinearMap s b (UnitObject (LinearMap s))
LinearMap s b (ZeroDim s)
forall v. AdditiveGroup v => v
zeroV
fst :: forall x y. ObjectPair (LinearMap s) x y => LinearMap s (x, y) x
fst = LinearMap s x x
LinearMap (Scalar x) x x
forall a. Object (LinearMap s) a => LinearMap s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id LinearMap (Scalar x) x x -> (y +> x) -> (x, y) +> x
forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
⊕ LinearMap s y x
y +> x
forall v. AdditiveGroup v => v
zeroV
snd :: forall x y. ObjectPair (LinearMap s) x y => LinearMap s (x, y) y
snd = LinearMap s x y
LinearMap (Scalar x) x y
forall v. AdditiveGroup v => v
zeroV LinearMap (Scalar x) x y -> (y +> y) -> (x, y) +> y
forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
⊕ LinearMap s y y
y +> y
forall a. Object (LinearMap s) a => LinearMap s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id
instance Num' s => EnhancedCat (->) (LinearMap s) where
arr :: forall b c.
(Object (LinearMap s) b, Object (LinearMap s) c, Object (->) b,
Object (->) c) =>
LinearMap s b c -> b -> c
arr LinearMap s b c
m = LinearFunction s b c -> b -> c
forall b c.
(Object (LinearFunction s) b, Object (LinearFunction s) c,
Object (->) b, Object (->) c) =>
LinearFunction s b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (LinearFunction s b c -> b -> c) -> LinearFunction s b c -> b -> c
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction (Scalar b) (LinearMap s b c) (LinearFunction s b c)
Bilinear (b +> c) b c
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar b) =>
Bilinear (b +> w) b w
applyLinear LinearFunction (Scalar b) (LinearMap s b c) (LinearFunction s b c)
-> LinearMap s b c -> LinearFunction s b c
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s b c
m
instance Num' s => EnhancedCat (LinearFunction s) (LinearMap s) where
arr :: forall b c.
(Object (LinearMap s) b, Object (LinearMap s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
LinearMap s b c -> LinearFunction s b c
arr LinearMap s b c
m = LinearFunction s (LinearMap s b c) (LinearFunction s b c)
Bilinear (b +> c) b c
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar b) =>
Bilinear (b +> w) b w
applyLinear LinearFunction s (LinearMap s b c) (LinearFunction s b c)
-> LinearMap s b c -> LinearFunction s b c
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s b c
m
instance Num' s => EnhancedCat (LinearMap s) (LinearFunction s) where
arr :: forall b c.
(Object (LinearFunction s) b, Object (LinearFunction s) c,
Object (LinearMap s) b, Object (LinearMap s) c) =>
LinearFunction s b c -> LinearMap s b c
arr LinearFunction s b c
m = LinearFunction s (LinearFunction s b c) (LinearMap s b c)
(b -+> c) -+> (b +> c)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar b ~ Scalar w) =>
(b -+> w) -+> (b +> w)
sampleLinearFunction LinearFunction s (LinearFunction s b c) (LinearMap s b c)
-> LinearFunction s b c -> LinearMap s b c
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction s b c
m
instance ∀ u v . ( TensorSpace u, TensorSpace v, Scalar u ~ Scalar v )
=> TensorSpace (u,v) where
type TensorProduct (u,v) w = (u⊗w, v⊗w)
scalarSpaceWitness :: ScalarSpaceWitness (u, v)
scalarSpaceWitness = case ( ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u
, ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v ) of
(ScalarSpaceWitness u
ScalarSpaceWitness, ScalarSpaceWitness v
ScalarSpaceWitness) -> ScalarSpaceWitness (u, v)
forall v.
(Num' (Scalar v), Scalar (Scalar v) ~ Scalar v) =>
ScalarSpaceWitness v
ScalarSpaceWitness
linearManifoldWitness :: LinearManifoldWitness (u, v)
linearManifoldWitness = case ( LinearManifoldWitness u
forall v. TensorSpace v => LinearManifoldWitness v
linearManifoldWitness :: LinearManifoldWitness u
, LinearManifoldWitness v
forall v. TensorSpace v => LinearManifoldWitness v
linearManifoldWitness :: LinearManifoldWitness v ) of
( LinearManifoldWitness u
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
,LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
)
-> LinearManifoldWitness (u, v)
forall v.
(Needle v ~ v, AffineSpace v, Diff v ~ v) =>
LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
zeroTensor :: forall w. (TensorSpace w, Scalar w ~ Scalar (u, v)) => (u, v) ⊗ w
zeroTensor = u ⊗ w
forall w. (TensorSpace w, Scalar w ~ Scalar u) => u ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor (u ⊗ w) -> (v ⊗ w) -> Tensor (Scalar (u, v)) (u, v) w
forall u w v. (u ⊗ w) -> (v ⊗ w) -> (u, v) ⊗ w
<⊕ v ⊗ w
forall w. (TensorSpace w, Scalar w ~ Scalar v) => v ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor
scaleTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (u, v)) =>
Bilinear (Scalar (u, v)) ((u, v) ⊗ w) ((u, v) ⊗ w)
scaleTensor = (Scalar v
-> Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar (Scalar v))
(Scalar v)
(LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) (u, v) w))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((Scalar v
-> Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar (Scalar v))
(Scalar v)
(LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) (u, v) w)))
-> (Scalar v
-> Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar (Scalar v))
(Scalar v)
(LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) (u, v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \Scalar v
μ (Tensor (Tensor (Scalar v) u w
v,Tensor (Scalar v) v w
w)) ->
TensorProduct (u, v) w -> Tensor (Scalar v) (u, v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ( (Bilinear (Scalar u) (u ⊗ w) (u ⊗ w)
LinearFunction
(Scalar (Scalar u))
(Scalar v)
(LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) u w)
(Tensor (Scalar v) u w))
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
Bilinear (Scalar u) (u ⊗ w) (u ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
scaleTensorLinearFunction
(Scalar (Scalar u))
(Scalar v)
(LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) u w)
(Tensor (Scalar v) u w))
-> Scalar v
-> LinearFunction
(Scalar (Scalar v)) (Tensor (Scalar v) u w) (Tensor (Scalar v) u w)
forall s v w. LinearFunction s v w -> v -> w
-+$>Scalar v
μ)LinearFunction
(Scalar (Scalar v)) (Tensor (Scalar v) u w) (Tensor (Scalar v) u w)
-> Tensor (Scalar v) u w -> Tensor (Scalar v) u w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) u w
v, (Bilinear (Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
scaleTensorBilinear (Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
-> Scalar v
-> LinearFunction
(Scalar (Scalar v)) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
forall s v w. LinearFunction s v w -> v -> w
-+$>Scalar v
μ)LinearFunction
(Scalar (Scalar v)) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
-> Tensor (Scalar v) v w -> Tensor (Scalar v) v w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) v w
w )
negateTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (u, v)) =>
((u, v) ⊗ w) -+> ((u, v) ⊗ w)
negateTensor = (Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) (u, v) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) (u, v) w))
-> (Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) (u, v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Tensor (Tensor (Scalar v) u w
v,Tensor (Scalar v) v w
w))
-> TensorProduct (u, v) w -> Tensor (Scalar v) (u, v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (LinearFunction
(Scalar u) (Tensor (Scalar v) u w) (Tensor (Scalar v) u w)
(u ⊗ w) -+> (u ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) -+> (u ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
negateTensorLinearFunction
(Scalar u) (Tensor (Scalar v) u w) (Tensor (Scalar v) u w)
-> Tensor (Scalar v) u w -> Tensor (Scalar v) u w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) u w
v, LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
Tensor (Scalar v) v w -+> Tensor (Scalar v) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
negateTensorLinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
-> Tensor (Scalar v) v w -> Tensor (Scalar v) v w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) v w
w)
addTensors :: forall w.
(TensorSpace w, Scalar w ~ Scalar (u, v)) =>
((u, v) ⊗ w) -> ((u, v) ⊗ w) -> (u, v) ⊗ w
addTensors (Tensor (Tensor (Scalar v) u w
fu, Tensor (Scalar v) v w
fv)) (Tensor (Tensor (Scalar v) u w
fu', Tensor (Scalar v) v w
fv')) = (Tensor (Scalar v) u w
fu Tensor (Scalar v) u w
-> Tensor (Scalar v) u w -> Tensor (Scalar v) u w
forall v. AdditiveGroup v => v -> v -> v
^+^ Tensor (Scalar v) u w
fu') Tensor (Scalar u) u w
-> Tensor (Scalar v) v w -> Tensor (Scalar (u, v)) (u, v) w
forall u w v. (u ⊗ w) -> (v ⊗ w) -> (u, v) ⊗ w
<⊕ (Tensor (Scalar v) v w
fv Tensor (Scalar v) v w
-> Tensor (Scalar v) v w -> Tensor (Scalar v) v w
forall v. AdditiveGroup v => v -> v -> v
^+^ Tensor (Scalar v) v w
fv')
subtractTensors :: forall w.
(TensorSpace (u, v), TensorSpace w, Scalar w ~ Scalar (u, v)) =>
((u, v) ⊗ w) -> ((u, v) ⊗ w) -> (u, v) ⊗ w
subtractTensors (Tensor (Tensor (Scalar v) u w
fu, Tensor (Scalar v) v w
fv)) (Tensor (Tensor (Scalar v) u w
fu', Tensor (Scalar v) v w
fv'))
= (Tensor (Scalar v) u w
fu Tensor (Scalar v) u w
-> Tensor (Scalar v) u w -> Tensor (Scalar v) u w
forall v. AdditiveGroup v => v -> v -> v
^-^ Tensor (Scalar v) u w
fu') Tensor (Scalar u) u w
-> Tensor (Scalar v) v w -> Tensor (Scalar (u, v)) (u, v) w
forall u w v. (u ⊗ w) -> (v ⊗ w) -> (u, v) ⊗ w
<⊕ (Tensor (Scalar v) v w
fv Tensor (Scalar v) v w
-> Tensor (Scalar v) v w -> Tensor (Scalar v) v w
forall v. AdditiveGroup v => v -> v -> v
^-^ Tensor (Scalar v) v w
fv')
toFlatTensor :: (u, v) -+> ((u, v) ⊗ Scalar (u, v))
toFlatTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> ((Tensor (Scalar v) u (Scalar v), Tensor (Scalar v) v (Scalar v))
-> Tensor (Scalar v) (u, v) (Scalar v))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) u (Scalar v), Tensor (Scalar v) v (Scalar v))
(Tensor (Scalar v) (u, v) (Scalar v))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (Tensor (Scalar v) u (Scalar v), Tensor (Scalar v) v (Scalar v))
-> Tensor (Scalar v) (u, v) (Scalar v)
forall a b. Coercible a b => a -> b
coerce
LinearFunction
(Scalar v)
(Tensor (Scalar v) u (Scalar v), Tensor (Scalar v) v (Scalar v))
(Tensor (Scalar v) (u, v) (Scalar v))
-> LinearFunction
(Scalar v)
(u, v)
(Tensor (Scalar v) u (Scalar v), Tensor (Scalar v) v (Scalar v))
-> LinearFunction
(Scalar v) (u, v) (Tensor (Scalar v) (u, v) (Scalar v))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< LinearFunction (Scalar v) u (Tensor (Scalar v) u (Scalar v))
u -+> (u ⊗ Scalar u)
forall v. TensorSpace v => v -+> (v ⊗ Scalar v)
toFlatTensor LinearFunction (Scalar v) u (Tensor (Scalar v) u (Scalar v))
-> LinearFunction (Scalar v) v (Tensor (Scalar v) v (Scalar v))
-> LinearFunction
(Scalar v)
(u, v)
(Tensor (Scalar v) u (Scalar v), Tensor (Scalar v) v (Scalar v))
forall b b' c c'.
(ObjectPair (LinearFunction (Scalar v)) b b',
ObjectPair (LinearFunction (Scalar v)) c c') =>
LinearFunction (Scalar v) b c
-> LinearFunction (Scalar v) b' c'
-> LinearFunction (Scalar v) (b, b') (c, c')
forall (a :: Type -> Type -> Type) b b' c c'.
(Morphism a, ObjectPair a b b', ObjectPair a c c') =>
a b c -> a b' c' -> a (b, b') (c, c')
*** LinearFunction (Scalar v) v (Tensor (Scalar v) v (Scalar v))
v -+> Tensor (Scalar v) v (Scalar v)
forall v. TensorSpace v => v -+> (v ⊗ Scalar v)
toFlatTensor
fromFlatTensor :: ((u, v) ⊗ Scalar (u, v)) -+> (u, v)
fromFlatTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> (Tensor (Scalar v) (u, v) (Scalar v)
-> (Tensor (Scalar v) u (Scalar v),
Tensor (Scalar v) v (Scalar v)))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) (Scalar v))
(Tensor (Scalar v) u (Scalar v), Tensor (Scalar v) v (Scalar v))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction Tensor (Scalar v) (u, v) (Scalar v)
-> (Tensor (Scalar v) u (Scalar v), Tensor (Scalar v) v (Scalar v))
forall a b. Coercible a b => a -> b
coerce
LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) (Scalar v))
(Tensor (Scalar v) u (Scalar v), Tensor (Scalar v) v (Scalar v))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) u (Scalar v), Tensor (Scalar v) v (Scalar v))
(u, v)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) (u, v) (Scalar v)) (u, v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> (u ⊗ Scalar u) -+> u
LinearFunction (Scalar v) (Tensor (Scalar v) u (Scalar v)) u
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor LinearFunction (Scalar v) (Tensor (Scalar v) u (Scalar v)) u
-> LinearFunction (Scalar v) (Tensor (Scalar v) v (Scalar v)) v
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) u (Scalar v), Tensor (Scalar v) v (Scalar v))
(u, v)
forall b b' c c'.
(ObjectPair (LinearFunction (Scalar v)) b b',
ObjectPair (LinearFunction (Scalar v)) c c') =>
LinearFunction (Scalar v) b c
-> LinearFunction (Scalar v) b' c'
-> LinearFunction (Scalar v) (b, b') (c, c')
forall (a :: Type -> Type -> Type) b b' c c'.
(Morphism a, ObjectPair a b b', ObjectPair a c c') =>
a b c -> a b' c' -> a (b, b') (c, c')
*** LinearFunction (Scalar v) (Tensor (Scalar v) v (Scalar v)) v
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor
tensorProduct :: forall w.
(TensorSpace w, Scalar w ~ Scalar (u, v)) =>
Bilinear (u, v) w ((u, v) ⊗ w)
tensorProduct = ((u, v) -> w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v)
(u, v)
(LinearFunction (Scalar v) w (Tensor (Scalar v) (u, v) w))
((u, v) -> w -> Tensor (Scalar v) (u, v) w)
-> Bilinear (u, v) w (Tensor (Scalar v) (u, v) w)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction (((u, v) -> w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v)
(u, v)
(LinearFunction (Scalar v) w (Tensor (Scalar v) (u, v) w)))
-> ((u, v) -> w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v)
(u, v)
(LinearFunction (Scalar v) w (Tensor (Scalar v) (u, v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(u
u,v
v) w
w ->
TensorProduct (u, v) w -> Tensor (Scalar v) (u, v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ((Bilinear u w (u ⊗ w)
LinearFunction
(Scalar v) u (LinearFunction (Scalar v) w (Tensor (Scalar v) u w))
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
Bilinear u w (u ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductLinearFunction
(Scalar v) u (LinearFunction (Scalar v) w (Tensor (Scalar v) u w))
-> u -> LinearFunction (Scalar v) w (Tensor (Scalar v) u w)
forall s v w. LinearFunction s v w -> v -> w
-+$>u
u)LinearFunction (Scalar v) w (Tensor (Scalar v) u w)
-> w -> Tensor (Scalar v) u w
forall s v w. LinearFunction s v w -> v -> w
-+$>w
w, (Bilinear v w (v ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductBilinear v w (v ⊗ w) -> v -> LinearFunction (Scalar v) w (v ⊗ w)
forall s v w. LinearFunction s v w -> v -> w
-+$>v
v)LinearFunction (Scalar v) w (v ⊗ w) -> w -> v ⊗ w
forall s v w. LinearFunction s v w -> v -> w
-+$>w
w)
transposeTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (u, v)) =>
((u, v) ⊗ w) -+> (w ⊗ (u, v))
transposeTensor = (Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) w (u, v))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) w (u, v))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) w (u, v))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) w (u, v)))
-> (Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) w (u, v))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) w (u, v))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Tensor (Tensor (Scalar v) u w
uw,Tensor (Scalar v) v w
vw))
-> (LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (u, v) (u, v))
(LinearFunction
(Scalar w)
(Tensor (Scalar w) w u, Tensor (Scalar w) w v)
(Tensor (Scalar v) w (u, v)))
Bilinear
((u, v) -+> (u, v))
(Tensor (Scalar w) w u, Tensor (Scalar w) w v)
(Tensor (Scalar w) w (u, v))
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar w,
Scalar w ~ Scalar w, Scalar x ~ Scalar w) =>
Bilinear ((w, x) -+> u) (w ⊗ w, w ⊗ x) (w ⊗ u)
fzipTensorWithLinearFunction
(Scalar w)
(LinearFunction (Scalar w) (u, v) (u, v))
(LinearFunction
(Scalar w)
(Tensor (Scalar w) w u, Tensor (Scalar w) w v)
(Tensor (Scalar v) w (u, v)))
-> LinearFunction (Scalar w) (u, v) (u, v)
-> LinearFunction
(Scalar w)
(Tensor (Scalar w) w u, Tensor (Scalar w) w v)
(Tensor (Scalar v) w (u, v))
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar w) (u, v) (u, v)
forall a.
Object (LinearFunction (Scalar w)) a =>
LinearFunction (Scalar w) a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id)LinearFunction
(Scalar w)
(Tensor (Scalar w) w u, Tensor (Scalar w) w v)
(Tensor (Scalar v) w (u, v))
-> (Tensor (Scalar w) w u, Tensor (Scalar w) w v)
-> Tensor (Scalar v) w (u, v)
forall s v w. LinearFunction s v w -> v -> w
-+$>(LinearFunction
(Scalar u) (Tensor (Scalar v) u w) (Tensor (Scalar w) w u)
(u ⊗ w) -+> Tensor (Scalar w) w u
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) -+> (w ⊗ u)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensorLinearFunction
(Scalar u) (Tensor (Scalar v) u w) (Tensor (Scalar w) w u)
-> Tensor (Scalar v) u w -> Tensor (Scalar w) w u
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) u w
uw,LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar w) w v)
Tensor (Scalar v) v w -+> Tensor (Scalar w) w v
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensorLinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar w) w v)
-> Tensor (Scalar v) v w -> Tensor (Scalar w) w v
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) v w
vw)
fmapTensor :: forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (u, v),
Scalar x ~ Scalar (u, v)) =>
Bilinear (w -+> x) ((u, v) ⊗ w) ((u, v) ⊗ x)
fmapTensor = (LinearFunction (Scalar v) w x
-> Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) (u, v) x)
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) (u, v) x))
(LinearFunction (Scalar v) w x
-> Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) (u, v) x)
-> Bilinear
(LinearFunction (Scalar v) w x)
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) (u, v) x)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction (Scalar v) w x
-> Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) (u, v) x)
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) (u, v) x)))
-> (LinearFunction (Scalar v) w x
-> Tensor (Scalar v) (u, v) w -> Tensor (Scalar v) (u, v) x)
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) (u, v) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction (Scalar v) w x
f (Tensor (Tensor (Scalar v) u w
uw,Tensor (Scalar v) v w
vw)) -> TensorProduct (u, v) x -> Tensor (Scalar v) (u, v) x
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ((LinearFunction
(Scalar u)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) u x))
Bilinear (LinearFunction (Scalar x) w x) (u ⊗ w) (u ⊗ x)
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar u,
Scalar x ~ Scalar u) =>
Bilinear (w -+> x) (u ⊗ w) (u ⊗ x)
fmapTensorLinearFunction
(Scalar u)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) u x))
-> LinearFunction (Scalar v) w x
-> LinearFunction
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) u x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar v) w x
f)LinearFunction
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) u x)
-> Tensor (Scalar v) u w -> Tensor (Scalar v) u x
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) u w
uw, (LinearFunction
(Scalar v)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v x))
Bilinear
(LinearFunction (Scalar x) w x)
(Tensor (Scalar v) v w)
(Tensor (Scalar v) v x)
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
fmapTensorLinearFunction
(Scalar v)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v x))
-> LinearFunction (Scalar v) w x
-> LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar v) w x
f)LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v x)
-> Tensor (Scalar v) v w -> Tensor (Scalar v) v x
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) v w
vw)
fzipTensorWith :: forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (u, v), Scalar w ~ Scalar (u, v),
Scalar x ~ Scalar (u, v)) =>
Bilinear ((w, x) -+> u) ((u, v) ⊗ w, (u, v) ⊗ x) ((u, v) ⊗ u)
fzipTensorWith = (LinearFunction (Scalar v) (w, x) u
-> (Tensor (Scalar v) (u, v) w, Tensor (Scalar v) (u, v) x)
-> Tensor (Scalar v) (u, v) u)
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w, Tensor (Scalar v) (u, v) x)
(Tensor (Scalar v) (u, v) u))
(LinearFunction (Scalar v) (w, x) u
-> (Tensor (Scalar v) (u, v) w, Tensor (Scalar v) (u, v) x)
-> Tensor (Scalar v) (u, v) u)
-> Bilinear
(LinearFunction (Scalar v) (w, x) u)
(Tensor (Scalar v) (u, v) w, Tensor (Scalar v) (u, v) x)
(Tensor (Scalar v) (u, v) u)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction
((LinearFunction (Scalar v) (w, x) u
-> (Tensor (Scalar v) (u, v) w, Tensor (Scalar v) (u, v) x)
-> Tensor (Scalar v) (u, v) u)
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w, Tensor (Scalar v) (u, v) x)
(Tensor (Scalar v) (u, v) u)))
-> (LinearFunction (Scalar v) (w, x) u
-> (Tensor (Scalar v) (u, v) w, Tensor (Scalar v) (u, v) x)
-> Tensor (Scalar v) (u, v) u)
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (u, v) w, Tensor (Scalar v) (u, v) x)
(Tensor (Scalar v) (u, v) u))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction (Scalar v) (w, x) u
f (Tensor (Tensor (Scalar v) u w
uw, Tensor (Scalar v) v w
vw), Tensor (Tensor (Scalar v) u x
ux, Tensor (Scalar v) v x
vx))
-> TensorProduct (u, v) u -> Tensor (Scalar v) (u, v) u
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ( (LinearFunction
(Scalar u)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) u w, Tensor (Scalar v) u x)
(Tensor (Scalar v) u u))
Bilinear
(LinearFunction (Scalar u) (w, x) u) (u ⊗ w, u ⊗ x) (u ⊗ u)
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar u,
Scalar w ~ Scalar u, Scalar x ~ Scalar u) =>
Bilinear ((w, x) -+> u) (u ⊗ w, u ⊗ x) (u ⊗ u)
fzipTensorWithLinearFunction
(Scalar u)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) u w, Tensor (Scalar v) u x)
(Tensor (Scalar v) u u))
-> LinearFunction (Scalar v) (w, x) u
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) u w, Tensor (Scalar v) u x)
(Tensor (Scalar v) u u)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar v) (w, x) u
f)LinearFunction
(Scalar v)
(Tensor (Scalar v) u w, Tensor (Scalar v) u x)
(Tensor (Scalar v) u u)
-> (Tensor (Scalar v) u w, Tensor (Scalar v) u x)
-> Tensor (Scalar v) u u
forall s v w. LinearFunction s v w -> v -> w
-+$>(Tensor (Scalar v) u w
uw,Tensor (Scalar v) u x
ux)
, (LinearFunction
(Scalar v)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) v w, Tensor (Scalar v) v x)
(Tensor (Scalar v) v u))
Bilinear
(LinearFunction (Scalar u) (w, x) u)
(Tensor (Scalar v) v w, Tensor (Scalar v) v x)
(Tensor (Scalar v) v u)
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar v,
Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
fzipTensorWithLinearFunction
(Scalar v)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) v w, Tensor (Scalar v) v x)
(Tensor (Scalar v) v u))
-> LinearFunction (Scalar v) (w, x) u
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) v w, Tensor (Scalar v) v x)
(Tensor (Scalar v) v u)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar v) (w, x) u
f)LinearFunction
(Scalar v)
(Tensor (Scalar v) v w, Tensor (Scalar v) v x)
(Tensor (Scalar v) v u)
-> (Tensor (Scalar v) v w, Tensor (Scalar v) v x)
-> Tensor (Scalar v) v u
forall s v w. LinearFunction s v w -> v -> w
-+$>(Tensor (Scalar v) v w
vw,Tensor (Scalar v) v x
vx) )
tensorUnsafeFromArrayWithOffset :: ∀ nm w o α
. ( nm`Dimensional`(u,v)
, TensorSpace w, o`Dimensional`w, Scalar w ~ Scalar v
, GArr.Vector α (Scalar u) )
=> Int -> α (Scalar u) -> ((u,v)⊗w)
tensorUnsafeFromArrayWithOffset :: forall (nm :: Nat) w (o :: Nat) (α :: Type -> Type).
(Dimensional nm (u, v), TensorSpace w, Dimensional o w,
Scalar w ~ Scalar v, Vector α (Scalar u)) =>
Int -> α (Scalar u) -> (u, v) ⊗ w
tensorUnsafeFromArrayWithOffset
= case ( forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @u
, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v ) of
( SJust Sing n
sn, DimensionalityWitness u
IsStaticDimensional
,SJust Sing n
sm, DimensionalityWitness v
IsStaticDimensional )
-> let sno :: Sing (Apply (Apply (*@#@$) n) o)
sno = Sing n
sn Sing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%* forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w
smo :: Sing (Apply (Apply (*@#@$) n) o)
smo = Sing n
sm Sing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%* forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w
in SNat (n * o)
-> (KnownNat (n * o) =>
Int -> α (Scalar v) -> Tensor (Scalar v) (u, v) w)
-> Int
-> α (Scalar v)
-> Tensor (Scalar v) (u, v) w
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat SNat (n * o)
Sing (Apply (Apply (*@#@$) n) o)
sno (SNat (n * o)
-> (KnownNat (n * o) =>
Int -> α (Scalar v) -> Tensor (Scalar v) (u, v) w)
-> Int
-> α (Scalar v)
-> Tensor (Scalar v) (u, v) w
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat SNat (n * o)
Sing (Apply (Apply (*@#@$) n) o)
smo (
\Int
i α (Scalar (Tensor (Scalar v) u w))
arr -> TensorProduct (u, v) w -> Tensor (Scalar v) (u, v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ( Int -> α (Scalar (Tensor (Scalar v) u w)) -> Tensor (Scalar v) u w
forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
forall (α :: Type -> Type).
Vector α (Scalar (Tensor (Scalar v) u w)) =>
Int -> α (Scalar (Tensor (Scalar v) u w)) -> Tensor (Scalar v) u w
unsafeFromArrayWithOffset Int
i α (Scalar (Tensor (Scalar v) u w))
arr
, Int -> α (Scalar (Tensor (Scalar v) v w)) -> Tensor (Scalar v) v w
forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
forall (α :: Type -> Type).
Vector α (Scalar (Tensor (Scalar v) v w)) =>
Int -> α (Scalar (Tensor (Scalar v) v w)) -> Tensor (Scalar v) v w
unsafeFromArrayWithOffset
(Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (SNat (n * o) -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal SNat (n * o)
Sing (Apply (Apply (*@#@$) n) o)
sno)) α (Scalar (Tensor (Scalar v) u w))
α (Scalar (Tensor (Scalar v) v w))
arr )))
tensorUnsafeWriteArrayWithOffset :: ∀ nm w o α σ
. ( nm`Dimensional`(u,v)
, TensorSpace w, o`Dimensional`w, Scalar w ~ Scalar v
, GArr.Vector α (Scalar u) )
=> GArr.Mutable α σ (Scalar u) -> Int -> ((u,v)⊗w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset :: forall (nm :: Nat) w (o :: Nat) (α :: Type -> Type) σ.
(Dimensional nm (u, v), TensorSpace w, Dimensional o w,
Scalar w ~ Scalar v, Vector α (Scalar u)) =>
Mutable α σ (Scalar u) -> Int -> ((u, v) ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset
= case ( forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @u
, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v ) of
( SJust Sing n
sn, DimensionalityWitness u
IsStaticDimensional
,SJust Sing n
sm, DimensionalityWitness v
IsStaticDimensional )
-> let sno :: Sing (Apply (Apply (*@#@$) n) o)
sno = Sing n
sn Sing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%* forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w
smo :: Sing (Apply (Apply (*@#@$) n) o)
smo = Sing n
sm Sing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%* forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w
in SNat (n * o)
-> (KnownNat (n * o) =>
Mutable α σ (Scalar v)
-> Int -> Tensor (Scalar v) (u, v) w -> ST σ ())
-> Mutable α σ (Scalar v)
-> Int
-> Tensor (Scalar v) (u, v) w
-> ST σ ()
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat SNat (n * o)
Sing (Apply (Apply (*@#@$) n) o)
sno (SNat (n * o)
-> (KnownNat (n * o) =>
Mutable α σ (Scalar v)
-> Int -> Tensor (Scalar v) (u, v) w -> ST σ ())
-> Mutable α σ (Scalar v)
-> Int
-> Tensor (Scalar v) (u, v) w
-> ST σ ()
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat SNat (n * o)
Sing (Apply (Apply (*@#@$) n) o)
smo (
\Mutable α σ (Scalar (Tensor (Scalar v) u w))
arr Int
i (Tensor (Tensor (Scalar v) u w
x,Tensor (Scalar v) v w
y)) -> do
Mutable α σ (Scalar (Tensor (Scalar v) u w))
-> Int -> Tensor (Scalar v) u w -> ST σ ()
forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
forall (α :: Type -> Type) σ.
Vector α (Scalar (Tensor (Scalar v) u w)) =>
Mutable α σ (Scalar (Tensor (Scalar v) u w))
-> Int -> Tensor (Scalar v) u w -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (Tensor (Scalar v) u w))
arr Int
i Tensor (Scalar v) u w
x
Mutable α σ (Scalar (Tensor (Scalar v) v w))
-> Int -> Tensor (Scalar v) v w -> ST σ ()
forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
forall (α :: Type -> Type) σ.
Vector α (Scalar (Tensor (Scalar v) v w)) =>
Mutable α σ (Scalar (Tensor (Scalar v) v w))
-> Int -> Tensor (Scalar v) v w -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (Tensor (Scalar v) u w))
Mutable α σ (Scalar (Tensor (Scalar v) v w))
arr (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Integer -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (SNat (n * o) -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal SNat (n * o)
Sing (Apply (Apply (*@#@$) n) o)
sno)) Tensor (Scalar v) v w
y ))
coerceFmapTensorProduct :: forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (u, v), TensorSpace b,
Scalar b ~ Scalar (u, v)) =>
p (u, v)
-> VSCCoercion (Scalar (u, v)) a b
-> Coercion (TensorProduct (u, v) a) (TensorProduct (u, v) b)
coerceFmapTensorProduct p (u, v)
p VSCCoercion (Scalar (u, v)) a b
cab = case
( p u
-> VSCCoercion (Scalar u) a b
-> Coercion (TensorProduct u a) (TensorProduct u b)
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar u, TensorSpace b,
Scalar b ~ Scalar u) =>
p u
-> VSCCoercion (Scalar u) a b
-> Coercion (TensorProduct u a) (TensorProduct u b)
coerceFmapTensorProduct ((u, v) -> u
forall x y. ObjectPair (->) x y => (x, y) -> x
forall (a :: Type -> Type -> Type) x y.
(PreArrow a, ObjectPair a x y) =>
a (x, y) x
fst((u, v) -> u) -> p (u, v) -> p u
forall (f :: Type -> Type) (r :: Type -> Type -> Type) a b.
(Functor f r (->), Object r a, Object r b) =>
r a b -> f a -> f b
<$>p (u, v)
p) VSCCoercion (Scalar u) a b
VSCCoercion (Scalar (u, v)) a b
cab
, p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar v, TensorSpace b,
Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
coerceFmapTensorProduct ((u, v) -> v
forall x y. ObjectPair (->) x y => (x, y) -> y
forall (a :: Type -> Type -> Type) x y.
(PreArrow a, ObjectPair a x y) =>
a (x, y) y
snd((u, v) -> v) -> p (u, v) -> p v
forall (f :: Type -> Type) (r :: Type -> Type -> Type) a b.
(Functor f r (->), Object r a, Object r b) =>
r a b -> f a -> f b
<$>p (u, v)
p) VSCCoercion (Scalar v) a b
VSCCoercion (Scalar (u, v)) a b
cab ) of
(Coercion (TensorProduct u a) (TensorProduct u b)
Coercion, Coercion (TensorProduct v a) (TensorProduct v b)
Coercion) -> Coercion
(Tensor (Scalar v) u a, Tensor (Scalar v) v a)
(Tensor (Scalar v) u b, Tensor (Scalar v) v b)
Coercion (TensorProduct (u, v) a) (TensorProduct (u, v) b)
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion
wellDefinedVector :: (u, v) -> Maybe (u, v)
wellDefinedVector (u
u,v
v) = (u -> v -> (u, v)) -> Maybe u -> Maybe v -> Maybe (u, v)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) c b a.
(Applicative f r t, Object r c, ObjectMorphism r b c,
Object t (f c), ObjectMorphism t (f b) (f c), ObjectPair r a b,
ObjectPair t (f a) (f b)) =>
r a (r b c) -> t (f a) (t (f b) (f c))
liftA2 (,) (u -> Maybe u
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector u
u) (v -> Maybe v
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector v
v)
wellDefinedTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (u, v)) =>
((u, v) ⊗ w) -> Maybe ((u, v) ⊗ w)
wellDefinedTensor (Tensor (Tensor (Scalar v) u w
u,Tensor (Scalar v) v w
v))
= (Tensor (Scalar v) u w
-> Tensor (Scalar v) v w -> Tensor (Scalar v) (u, v) w)
-> Maybe (Tensor (Scalar v) u w)
-> Maybe (Tensor (Scalar v) v w)
-> Maybe (Tensor (Scalar v) (u, v) w)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) c b a.
(Applicative f r t, Object r c, ObjectMorphism r b c,
Object t (f c), ObjectMorphism t (f b) (f c), ObjectPair r a b,
ObjectPair t (f a) (f b)) =>
r a (r b c) -> t (f a) (t (f b) (f c))
liftA2 (((Tensor (Scalar v) u w, Tensor (Scalar v) v w)
-> Tensor (Scalar v) (u, v) w
TensorProduct (u, v) w -> Tensor (Scalar v) (u, v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor((Tensor (Scalar v) u w, Tensor (Scalar v) v w)
-> Tensor (Scalar v) (u, v) w)
-> (Tensor (Scalar v) v w
-> (Tensor (Scalar v) u w, Tensor (Scalar v) v w))
-> Tensor (Scalar v) v w
-> Tensor (Scalar v) (u, v) w
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
.) ((Tensor (Scalar v) v w
-> (Tensor (Scalar v) u w, Tensor (Scalar v) v w))
-> Tensor (Scalar v) v w -> Tensor (Scalar v) (u, v) w)
-> (Tensor (Scalar v) u w
-> Tensor (Scalar v) v w
-> (Tensor (Scalar v) u w, Tensor (Scalar v) v w))
-> Tensor (Scalar v) u w
-> Tensor (Scalar v) v w
-> Tensor (Scalar v) (u, v) w
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. (,)) ((u ⊗ w) -> Maybe (u ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) -> Maybe (u ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor u ⊗ w
Tensor (Scalar v) u w
u) (Tensor (Scalar v) v w -> Maybe (Tensor (Scalar v) v w)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor Tensor (Scalar v) v w
v)
instance ∀ u v . ( LinearSpace u, LinearSpace v, Scalar u ~ Scalar v )
=> LinearSpace (u,v) where
type DualVector (u,v) = (DualVector u, DualVector v)
dualSpaceWitness :: DualSpaceWitness (u, v)
dualSpaceWitness = case ( DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness) -> DualSpaceWitness (u, v)
forall v.
(LinearSpace (Scalar v), DualVector (Scalar v) ~ Scalar v,
LinearSpace (DualVector v), Scalar (DualVector v) ~ Scalar v,
DualVector (DualVector v) ~ v,
StaticDimension (DualVector v) ~ StaticDimension v) =>
DualSpaceWitness v
DualSpaceWitness
linearId :: (u, v) +> (u, v)
linearId = case ( ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u
, DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(ScalarSpaceWitness u
ScalarSpaceWitness, DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness)
-> (LinearFunction (Scalar v) u (u, v)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) u u)
(LinearMap (Scalar v) u (u, v))
forall a b.
(Object (LinearFunction (Scalar v)) a,
Object (LinearFunction (Scalar v)) (LinearMap (Scalar v) u a),
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction (Scalar v)) (LinearMap (Scalar v) u b)) =>
LinearFunction (Scalar v) a b
-> LinearFunction
(Scalar v) (LinearMap (Scalar v) u a) (LinearMap (Scalar v) u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction (Scalar v) u u
forall a.
Object (LinearFunction (Scalar v)) a =>
LinearFunction (Scalar v) a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
idLinearFunction (Scalar v) u u
-> LinearFunction (Scalar v) u v
-> LinearFunction (Scalar v) u (u, v)
forall b c c'.
(Object (LinearFunction (Scalar v)) b,
ObjectPair (LinearFunction (Scalar v)) c c') =>
LinearFunction (Scalar v) b c
-> LinearFunction (Scalar v) b c'
-> LinearFunction (Scalar v) b (c, c')
forall (a :: Type -> Type -> Type) b c c'.
(PreArrow a, Object a b, ObjectPair a c c') =>
a b c -> a b c' -> a b (c, c')
&&&LinearFunction (Scalar v) u v
forall w s v. AdditiveGroup w => LinearFunction s v w
const0)LinearFunction
(Scalar v)
(LinearMap (Scalar v) u u)
(LinearMap (Scalar v) u (u, v))
-> LinearMap (Scalar v) u u -> LinearMap (Scalar v) u (u, v)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar v) u u
forall a.
Object (LinearMap (Scalar v)) a =>
LinearMap (Scalar v) a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id) LinearMap (Scalar u) u (u, v)
-> LinearMap (Scalar v) v (u, v) -> (u, v) +> (u, v)
forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
⊕ (LinearFunction (Scalar v) v (u, v)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) v v)
(LinearMap (Scalar v) v (u, v))
forall a b.
(Object (LinearFunction (Scalar v)) a,
Object (LinearFunction (Scalar v)) (LinearMap (Scalar v) v a),
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction (Scalar v)) (LinearMap (Scalar v) v b)) =>
LinearFunction (Scalar v) a b
-> LinearFunction
(Scalar v) (LinearMap (Scalar v) v a) (LinearMap (Scalar v) v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction (Scalar v) v u
forall w s v. AdditiveGroup w => LinearFunction s v w
const0LinearFunction (Scalar v) v u
-> LinearFunction (Scalar v) v v
-> LinearFunction (Scalar v) v (u, v)
forall b c c'.
(Object (LinearFunction (Scalar v)) b,
ObjectPair (LinearFunction (Scalar v)) c c') =>
LinearFunction (Scalar v) b c
-> LinearFunction (Scalar v) b c'
-> LinearFunction (Scalar v) b (c, c')
forall (a :: Type -> Type -> Type) b c c'.
(PreArrow a, Object a b, ObjectPair a c c') =>
a b c -> a b c' -> a b (c, c')
&&&LinearFunction (Scalar v) v v
forall a.
Object (LinearFunction (Scalar v)) a =>
LinearFunction (Scalar v) a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id)LinearFunction
(Scalar v)
(LinearMap (Scalar v) v v)
(LinearMap (Scalar v) v (u, v))
-> LinearMap (Scalar v) v v -> LinearMap (Scalar v) v (u, v)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar v) v v
forall a.
Object (LinearMap (Scalar v)) a =>
LinearMap (Scalar v) a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id)
tensorId :: forall w.
(LinearSpace w, Scalar w ~ Scalar (u, v)) =>
((u, v) ⊗ w) +> ((u, v) ⊗ w)
tensorId = ScalarSpaceWitness u
-> DualSpaceWitness u
-> DualSpaceWitness v
-> DualSpaceWitness w
-> LinearMap (Scalar ((u, v) ⊗ w)) ((u, v) ⊗ w) ((u, v) ⊗ w)
forall w.
(LinearSpace w, Scalar w ~ Scalar v) =>
ScalarSpaceWitness u
-> DualSpaceWitness u
-> DualSpaceWitness v
-> DualSpaceWitness w
-> ((u, v) ⊗ w) +> ((u, v) ⊗ w)
tI ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness DualSpaceWitness w
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness
where tI :: ∀ w . (LinearSpace w, Scalar w ~ Scalar v)
=> ScalarSpaceWitness u -> DualSpaceWitness u
-> DualSpaceWitness v -> DualSpaceWitness w
-> ((u,v)⊗w)+>((u,v)⊗w)
tI :: forall w.
(LinearSpace w, Scalar w ~ Scalar v) =>
ScalarSpaceWitness u
-> DualSpaceWitness u
-> DualSpaceWitness v
-> DualSpaceWitness w
-> ((u, v) ⊗ w) +> ((u, v) ⊗ w)
tI ScalarSpaceWitness u
ScalarSpaceWitness DualSpaceWitness u
DualSpaceWitness DualSpaceWitness v
DualSpaceWitness DualSpaceWitness w
DualSpaceWitness
= TensorProduct
(DualVector (Tensor (Scalar v) (u, v) w))
(Tensor (Scalar v) (u, v) w)
-> LinearMap
(Scalar v)
(Tensor (Scalar v) (u, v) w)
(Tensor (Scalar v) (u, v) w)
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap
( VSCCoercion
(Scalar v)
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector u) (DualVector w))
(Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(DualVector u)
(Tensor (Scalar v) (DualVector w) (Tensor (Scalar v) (u, v) w)))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor VSCCoercion
(Scalar v)
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector u) (DualVector w))
(Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(DualVector u)
(Tensor (Scalar v) (DualVector w) (Tensor (Scalar v) (u, v) w)))
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector u) (DualVector w))
(Tensor (Scalar v) (u, v) w))
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(DualVector u)
(Tensor (Scalar v) (DualVector w) (Tensor (Scalar v) (u, v) w)))
forall a b c.
(Object (VSCCoercion (Scalar v)) a,
Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c) =>
VSCCoercion (Scalar v) b c
-> VSCCoercion (Scalar v) a b -> VSCCoercion (Scalar v) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar v)
(LinearMap
(Scalar v)
(LinearMap (Scalar v) (DualVector u) w)
(Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector u) (DualVector w))
(Tensor (Scalar v) (u, v) w))
VSCCoercion
(Scalar v)
(LinearMap
(Scalar v)
(DualVector (Tensor (Scalar v) (DualVector u) (DualVector w)))
(Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector u) (DualVector w))
(Tensor (Scalar v) (u, v) w))
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (LinearMap s (DualVector v) w) (Tensor s v w)
fromLinearMap VSCCoercion
(Scalar v)
(LinearMap
(Scalar v)
(LinearMap (Scalar v) (DualVector u) w)
(Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector u) (DualVector w))
(Tensor (Scalar v) (u, v) w))
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w))
(LinearMap
(Scalar v)
(LinearMap (Scalar v) (DualVector u) w)
(Tensor (Scalar v) (u, v) w))
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector u) (DualVector w))
(Tensor (Scalar v) (u, v) w))
forall a b c.
(Object (VSCCoercion (Scalar v)) a,
Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c) =>
VSCCoercion (Scalar v) b c
-> VSCCoercion (Scalar v) a b -> VSCCoercion (Scalar v) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w))
(LinearMap
(Scalar v)
(LinearMap (Scalar v) (DualVector u) w)
(Tensor (Scalar v) (u, v) w))
VSCCoercion
(Scalar v)
(LinearMap
(Scalar v)
(Tensor (Scalar v) (DualVector (DualVector u)) w)
(Tensor (Scalar v) (u, v) w))
(LinearMap
(Scalar v)
(LinearMap (Scalar v) (DualVector u) w)
(Tensor (Scalar v) (u, v) w))
forall s v w x.
(LinearSpace v, LinearSpace w, Scalar v ~ s, Scalar w ~ s,
TensorSpace x, Scalar x ~ s) =>
VSCCoercion
s
(LinearMap s (Tensor s (DualVector v) w) x)
(LinearMap s (LinearMap s v w) x)
argFromTensor
VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(DualVector u)
(Tensor (Scalar v) (DualVector w) (Tensor (Scalar v) (u, v) w)))
-> LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w)
-> Tensor
(Scalar v)
(DualVector u)
(Tensor (Scalar v) (DualVector w) (Tensor (Scalar v) (u, v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) u w))
(LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w))
forall a b.
(Object (LinearFunction (Scalar v)) a,
Object
(LinearFunction (Scalar v))
(LinearMap (Scalar v) (Tensor (Scalar v) u w) a),
Object (LinearFunction (Scalar v)) b,
Object
(LinearFunction (Scalar v))
(LinearMap (Scalar v) (Tensor (Scalar v) u w) b)) =>
LinearFunction (Scalar v) a b
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) u w) a)
(LinearMap (Scalar v) (Tensor (Scalar v) u w) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap ((Tensor (Scalar v) u w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor (Scalar v) u w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w))
-> (Tensor (Scalar v) u w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \Tensor (Scalar v) u w
t -> TensorProduct (u, v) w -> Tensor (Scalar v) (u, v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (Tensor (Scalar v) u w
t,Tensor (Scalar v) v w
forall v. AdditiveGroup v => v
zeroV)) LinearFunction
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) u w))
(LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w))
-> LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) u w)
-> LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) (u, v) w)
forall s v w. LinearFunction s v w -> v -> w
-+$> LinearMap
(Scalar v) (Tensor (Scalar v) u w) (Tensor (Scalar v) u w)
(u ⊗ w) +> (u ⊗ w)
forall w.
(LinearSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) +> (u ⊗ w)
forall v w.
(LinearSpace v, LinearSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) +> (v ⊗ w)
tensorId
, VSCCoercion
(Scalar v)
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector v) (DualVector w))
(Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(DualVector v)
(Tensor (Scalar v) (DualVector w) (Tensor (Scalar v) (u, v) w)))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor VSCCoercion
(Scalar v)
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector v) (DualVector w))
(Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(DualVector v)
(Tensor (Scalar v) (DualVector w) (Tensor (Scalar v) (u, v) w)))
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector v) (DualVector w))
(Tensor (Scalar v) (u, v) w))
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(DualVector v)
(Tensor (Scalar v) (DualVector w) (Tensor (Scalar v) (u, v) w)))
forall a b c.
(Object (VSCCoercion (Scalar v)) a,
Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c) =>
VSCCoercion (Scalar v) b c
-> VSCCoercion (Scalar v) a b -> VSCCoercion (Scalar v) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar v)
(LinearMap
(Scalar v)
(LinearMap (Scalar v) (DualVector v) w)
(Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector v) (DualVector w))
(Tensor (Scalar v) (u, v) w))
VSCCoercion
(Scalar v)
(LinearMap
(Scalar v)
(DualVector (Tensor (Scalar v) (DualVector v) (DualVector w)))
(Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector v) (DualVector w))
(Tensor (Scalar v) (u, v) w))
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (LinearMap s (DualVector v) w) (Tensor s v w)
fromLinearMap VSCCoercion
(Scalar v)
(LinearMap
(Scalar v)
(LinearMap (Scalar v) (DualVector v) w)
(Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector v) (DualVector w))
(Tensor (Scalar v) (u, v) w))
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w))
(LinearMap
(Scalar v)
(LinearMap (Scalar v) (DualVector v) w)
(Tensor (Scalar v) (u, v) w))
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(Tensor (Scalar v) (DualVector v) (DualVector w))
(Tensor (Scalar v) (u, v) w))
forall a b c.
(Object (VSCCoercion (Scalar v)) a,
Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c) =>
VSCCoercion (Scalar v) b c
-> VSCCoercion (Scalar v) a b -> VSCCoercion (Scalar v) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w))
(LinearMap
(Scalar v)
(LinearMap (Scalar v) (DualVector v) w)
(Tensor (Scalar v) (u, v) w))
VSCCoercion
(Scalar v)
(LinearMap
(Scalar v)
(Tensor (Scalar v) (DualVector (DualVector v)) w)
(Tensor (Scalar v) (u, v) w))
(LinearMap
(Scalar v)
(LinearMap (Scalar v) (DualVector v) w)
(Tensor (Scalar v) (u, v) w))
forall s v w x.
(LinearSpace v, LinearSpace w, Scalar v ~ s, Scalar w ~ s,
TensorSpace x, Scalar x ~ s) =>
VSCCoercion
s
(LinearMap s (Tensor s (DualVector v) w) x)
(LinearMap s (LinearMap s v w) x)
argFromTensor
VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w))
(Tensor
(Scalar v)
(DualVector v)
(Tensor (Scalar v) (DualVector w) (Tensor (Scalar v) (u, v) w)))
-> LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w)
-> Tensor
(Scalar v)
(DualVector v)
(Tensor (Scalar v) (DualVector w) (Tensor (Scalar v) (u, v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w))
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w))
forall a b.
(Object (LinearFunction (Scalar v)) a,
Object
(LinearFunction (Scalar v))
(LinearMap (Scalar v) (Tensor (Scalar v) v w) a),
Object (LinearFunction (Scalar v)) b,
Object
(LinearFunction (Scalar v))
(LinearMap (Scalar v) (Tensor (Scalar v) v w) b)) =>
LinearFunction (Scalar v) a b
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) v w) a)
(LinearMap (Scalar v) (Tensor (Scalar v) v w) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap ((Tensor (Scalar v) v w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor (Scalar v) v w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w))
-> (Tensor (Scalar v) v w -> Tensor (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \Tensor (Scalar v) v w
t -> TensorProduct (u, v) w -> Tensor (Scalar v) (u, v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (Tensor (Scalar v) u w
forall v. AdditiveGroup v => v
zeroV,Tensor (Scalar v) v w
t)) LinearFunction
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w))
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w))
-> LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
-> LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (u, v) w)
forall s v w. LinearFunction s v w -> v -> w
-+$> LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
Tensor (Scalar v) v w +> Tensor (Scalar v) v w
forall w.
(LinearSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) +> (v ⊗ w)
forall v w.
(LinearSpace v, LinearSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) +> (v ⊗ w)
tensorId )
sampleLinearFunction :: forall w.
(TensorSpace w, Scalar (u, v) ~ Scalar w) =>
((u, v) -+> w) -+> ((u, v) +> w)
sampleLinearFunction = case ( ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u
, DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(ScalarSpaceWitness u
ScalarSpaceWitness, DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness)
-> (((u, v) -+> w) -> LinearMap (Scalar w) (u, v) w)
-> LinearFunction
(Scalar w) ((u, v) -+> w) (LinearMap (Scalar w) (u, v) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((((u, v) -+> w) -> LinearMap (Scalar w) (u, v) w)
-> LinearFunction
(Scalar w) ((u, v) -+> w) (LinearMap (Scalar w) (u, v) w))
-> (((u, v) -+> w) -> LinearMap (Scalar w) (u, v) w)
-> LinearFunction
(Scalar w) ((u, v) -+> w) (LinearMap (Scalar w) (u, v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(u, v) -+> w
f -> (LinearFunction
(Scalar w)
(LinearFunction (Scalar w) u w)
(LinearMap (Scalar u) u w)
LinearFunction (Scalar w) u w -+> LinearMap (Scalar u) u w
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar u ~ Scalar w) =>
(u -+> w) -+> (u +> w)
sampleLinearFunction LinearFunction
(Scalar w)
(LinearFunction (Scalar w) u w)
(LinearMap (Scalar u) u w)
-> LinearFunction (Scalar w) u w -> LinearMap (Scalar u) u w
forall s v w. LinearFunction s v w -> v -> w
-+$> (u, v) -+> w
f ((u, v) -+> w)
-> LinearFunction (Scalar w) u (u, v)
-> LinearFunction (Scalar w) u w
forall a b c.
(Object (LinearFunction (Scalar w)) a,
Object (LinearFunction (Scalar w)) b,
Object (LinearFunction (Scalar w)) c) =>
LinearFunction (Scalar w) b c
-> LinearFunction (Scalar w) a b -> LinearFunction (Scalar w) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction (Scalar w) u (u, v)
forall w s v. AdditiveGroup w => LinearFunction s v (v, w)
lCoFst)
LinearMap (Scalar u) u w -> (v +> w) -> (u, v) +> w
forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
⊕ (LinearFunction (Scalar w) (LinearFunction (Scalar w) v w) (v +> w)
LinearFunction (Scalar w) v w -+> (v +> w)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
sampleLinearFunction LinearFunction (Scalar w) (LinearFunction (Scalar w) v w) (v +> w)
-> LinearFunction (Scalar w) v w -> v +> w
forall s v w. LinearFunction s v w -> v -> w
-+$> (u, v) -+> w
f ((u, v) -+> w)
-> LinearFunction (Scalar w) v (u, v)
-> LinearFunction (Scalar w) v w
forall a b c.
(Object (LinearFunction (Scalar w)) a,
Object (LinearFunction (Scalar w)) b,
Object (LinearFunction (Scalar w)) c) =>
LinearFunction (Scalar w) b c
-> LinearFunction (Scalar w) a b -> LinearFunction (Scalar w) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction (Scalar w) v (u, v)
forall v s w. AdditiveGroup v => LinearFunction s w (v, w)
lCoSnd)
applyDualVector :: LinearSpace (u, v) =>
Bilinear (DualVector (u, v)) (u, v) (Scalar (u, v))
applyDualVector = case ( ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u
, DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(ScalarSpaceWitness u
ScalarSpaceWitness, DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness)
-> ((DualVector u, DualVector v)
-> LinearFunction (Scalar v) (u, v) (Scalar v))
-> LinearFunction
(Scalar v)
(DualVector u, DualVector v)
(LinearFunction (Scalar v) (u, v) (Scalar v))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (((DualVector u, DualVector v)
-> LinearFunction (Scalar v) (u, v) (Scalar v))
-> LinearFunction
(Scalar v)
(DualVector u, DualVector v)
(LinearFunction (Scalar v) (u, v) (Scalar v)))
-> ((DualVector u, DualVector v)
-> LinearFunction (Scalar v) (u, v) (Scalar v))
-> LinearFunction
(Scalar v)
(DualVector u, DualVector v)
(LinearFunction (Scalar v) (u, v) (Scalar v))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(DualVector u
du,DualVector v
dv)
-> (LinearFunction
(Scalar v) (DualVector u) (LinearFunction (Scalar v) u (Scalar v))
Bilinear (DualVector u) u (Scalar u)
forall v.
(LinearSpace v, LinearSpace v) =>
Bilinear (DualVector v) v (Scalar v)
applyDualVectorLinearFunction
(Scalar v) (DualVector u) (LinearFunction (Scalar v) u (Scalar v))
-> DualVector u -> LinearFunction (Scalar v) u (Scalar v)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$DualVector u
du) LinearFunction (Scalar v) u (Scalar v)
-> LinearFunction (Scalar v) v (Scalar v)
-> LinearFunction (Scalar v) (u, v) (Scalar v, Scalar v)
forall b b' c c'.
(ObjectPair (LinearFunction (Scalar v)) b b',
ObjectPair (LinearFunction (Scalar v)) c c') =>
LinearFunction (Scalar v) b c
-> LinearFunction (Scalar v) b' c'
-> LinearFunction (Scalar v) (b, b') (c, c')
forall (a :: Type -> Type -> Type) b b' c c'.
(Morphism a, ObjectPair a b b', ObjectPair a c c') =>
a b c -> a b' c' -> a (b, b') (c, c')
*** (LinearFunction
(Scalar v) (DualVector v) (LinearFunction (Scalar v) v (Scalar v))
Bilinear (DualVector v) v (Scalar v)
forall v.
(LinearSpace v, LinearSpace v) =>
Bilinear (DualVector v) v (Scalar v)
applyDualVectorLinearFunction
(Scalar v) (DualVector v) (LinearFunction (Scalar v) v (Scalar v))
-> DualVector v -> LinearFunction (Scalar v) v (Scalar v)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$DualVector v
dv) LinearFunction (Scalar v) (u, v) (Scalar v, Scalar v)
-> LinearFunction (Scalar v) (Scalar v, Scalar v) (Scalar v)
-> LinearFunction (Scalar v) (u, v) (Scalar v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction (Scalar v) (Scalar v, Scalar v) (Scalar v)
forall w s. AdditiveGroup w => LinearFunction s (w, w) w
addV
applyLinear :: forall w.
(TensorSpace w, Scalar w ~ Scalar (u, v)) =>
Bilinear ((u, v) +> w) (u, v) w
applyLinear = case ( ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u
, DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(ScalarSpaceWitness u
ScalarSpaceWitness, DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness)
-> (LinearMap (Scalar v) (u, v) w
-> LinearFunction (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (u, v) w)
(LinearFunction (Scalar v) (u, v) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearMap (Scalar v) (u, v) w
-> LinearFunction (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (u, v) w)
(LinearFunction (Scalar v) (u, v) w))
-> (LinearMap (Scalar v) (u, v) w
-> LinearFunction (Scalar v) (u, v) w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (u, v) w)
(LinearFunction (Scalar v) (u, v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap (Tensor (Scalar v) (DualVector u) w
fu, Tensor (Scalar v) (DualVector v) w
fv)) ->
(LinearFunction
(Scalar v)
(LinearMap (Scalar v) u w)
(LinearFunction (Scalar v) u w)
Bilinear (u +> w) u w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
Bilinear (u +> w) u w
applyLinear LinearFunction
(Scalar v)
(LinearMap (Scalar v) u w)
(LinearFunction (Scalar v) u w)
-> LinearMap (Scalar v) u w -> LinearFunction (Scalar v) u w
forall s v w. LinearFunction s v w -> v -> w
-+$> (VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector u) w)
(LinearMap (Scalar v) u w)
VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector u) w)
(LinearMap (Scalar v) (DualVector (DualVector u)) w)
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector u) w)
(LinearMap (Scalar v) u w)
-> Tensor (Scalar v) (DualVector u) w -> LinearMap (Scalar v) u w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) (DualVector u) w
fu)) LinearFunction (Scalar v) u w
-> LinearFunction (Scalar v) v w
-> LinearFunction (Scalar v) (u, v) (w, w)
forall b b' c c'.
(ObjectPair (LinearFunction (Scalar v)) b b',
ObjectPair (LinearFunction (Scalar v)) c c') =>
LinearFunction (Scalar v) b c
-> LinearFunction (Scalar v) b' c'
-> LinearFunction (Scalar v) (b, b') (c, c')
forall (a :: Type -> Type -> Type) b b' c c'.
(Morphism a, ObjectPair a b b', ObjectPair a c c') =>
a b c -> a b' c' -> a (b, b') (c, c')
*** (LinearFunction
(Scalar v)
(LinearMap (Scalar v) v w)
(LinearFunction (Scalar v) v w)
Bilinear (LinearMap (Scalar v) v w) v w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
applyLinear LinearFunction
(Scalar v)
(LinearMap (Scalar v) v w)
(LinearFunction (Scalar v) v w)
-> LinearMap (Scalar v) v w -> LinearFunction (Scalar v) v w
forall s v w. LinearFunction s v w -> v -> w
-+$> (VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) w)
(LinearMap (Scalar v) v w)
VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) w)
(LinearMap (Scalar v) (DualVector (DualVector v)) w)
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) w)
(LinearMap (Scalar v) v w)
-> Tensor (Scalar v) (DualVector v) w -> LinearMap (Scalar v) v w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) (DualVector v) w
fv))
LinearFunction (Scalar v) (u, v) (w, w)
-> LinearFunction (Scalar v) (w, w) w
-> LinearFunction (Scalar v) (u, v) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction (Scalar v) (w, w) w
forall w s. AdditiveGroup w => LinearFunction s (w, w) w
addV
composeLinear :: forall w x.
(LinearSpace w, TensorSpace x, Scalar w ~ Scalar (u, v),
Scalar x ~ Scalar (u, v)) =>
Bilinear (w +> x) ((u, v) +> w) ((u, v) +> x)
composeLinear = case ( DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness)
-> (LinearMap (Scalar v) w x
-> LinearMap (Scalar v) (u, v) w -> LinearMap (Scalar v) (u, v) x)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) w x)
(LinearFunction
(Scalar v)
(LinearMap (Scalar v) (u, v) w)
(LinearMap (Scalar v) (u, v) x))
(LinearMap (Scalar v) w x
-> LinearMap (Scalar v) (u, v) w -> LinearMap (Scalar v) (u, v) x)
-> Bilinear
(LinearMap (Scalar v) w x)
(LinearMap (Scalar v) (u, v) w)
(LinearMap (Scalar v) (u, v) x)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap (Scalar v) w x
-> LinearMap (Scalar v) (u, v) w -> LinearMap (Scalar v) (u, v) x)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) w x)
(LinearFunction
(Scalar v)
(LinearMap (Scalar v) (u, v) w)
(LinearMap (Scalar v) (u, v) x)))
-> (LinearMap (Scalar v) w x
-> LinearMap (Scalar v) (u, v) w -> LinearMap (Scalar v) (u, v) x)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) w x)
(LinearFunction
(Scalar v)
(LinearMap (Scalar v) (u, v) w)
(LinearMap (Scalar v) (u, v) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearMap (Scalar (DualVector (DualVector u))) w x
f (LinearMap (Tensor (Scalar (DualVector u)) (DualVector u) w
fu, Tensor (Scalar (DualVector v)) (DualVector v) w
fv))
-> ((Bilinear
(w +> x)
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) w)
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) x)
LinearFunction
(Scalar (DualVector (DualVector u)))
(LinearMap (Scalar (DualVector (DualVector u))) w x)
(LinearFunction
(Scalar (DualVector (DualVector u)))
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) w)
(LinearMap
(Scalar (DualVector (DualVector u)))
(DualVector (DualVector u))
x))
forall v w x.
(LinearSpace v, LinearSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w +> x) (v +> w) (v +> x)
forall w x.
(LinearSpace w, TensorSpace x,
Scalar w ~ Scalar (DualVector (DualVector u)),
Scalar x ~ Scalar (DualVector (DualVector u))) =>
Bilinear
(w +> x)
(DualVector (DualVector u) +> w)
(DualVector (DualVector u) +> x)
composeLinearLinearFunction
(Scalar (DualVector (DualVector u)))
(LinearMap (Scalar (DualVector (DualVector u))) w x)
(LinearFunction
(Scalar (DualVector (DualVector u)))
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) w)
(LinearMap
(Scalar (DualVector (DualVector u)))
(DualVector (DualVector u))
x))
-> LinearMap (Scalar (DualVector (DualVector u))) w x
-> LinearFunction
(Scalar (DualVector (DualVector u)))
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) w)
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar (DualVector (DualVector u))) w x
f)LinearFunction
(Scalar (DualVector (DualVector u)))
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) w)
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) x)
-> LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) w
-> LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) x
forall s v w. LinearFunction s v w -> v -> w
-+$>VSCCoercion
(Scalar (DualVector u))
(Tensor (Scalar (DualVector u)) (DualVector u) w)
(LinearMap (Scalar (DualVector u)) (DualVector (DualVector u)) w)
VSCCoercion
(Scalar (DualVector u))
(Tensor (Scalar (DualVector u)) (DualVector u) w)
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) w)
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap VSCCoercion
(Scalar (DualVector u))
(Tensor (Scalar (DualVector u)) (DualVector u) w)
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) w)
-> Tensor (Scalar (DualVector u)) (DualVector u) w
-> LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (DualVector u)) (DualVector u) w
fu)
LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector u)) x
-> (DualVector (DualVector v) +> x)
-> (DualVector (DualVector u), DualVector (DualVector v)) +> x
forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
⊕ ((Bilinear
(w +> x)
(DualVector (DualVector v) +> w)
(DualVector (DualVector v) +> x)
LinearFunction
(Scalar (DualVector (DualVector v)))
(LinearMap (Scalar (DualVector (DualVector u))) w x)
(LinearFunction
(Scalar (DualVector (DualVector u)))
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector v)) w)
(DualVector (DualVector v) +> x))
forall v w x.
(LinearSpace v, LinearSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w +> x) (v +> w) (v +> x)
forall w x.
(LinearSpace w, TensorSpace x,
Scalar w ~ Scalar (DualVector (DualVector v)),
Scalar x ~ Scalar (DualVector (DualVector v))) =>
Bilinear
(w +> x)
(DualVector (DualVector v) +> w)
(DualVector (DualVector v) +> x)
composeLinearLinearFunction
(Scalar (DualVector (DualVector v)))
(LinearMap (Scalar (DualVector (DualVector u))) w x)
(LinearFunction
(Scalar (DualVector (DualVector u)))
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector v)) w)
(DualVector (DualVector v) +> x))
-> LinearMap (Scalar (DualVector (DualVector u))) w x
-> LinearFunction
(Scalar (DualVector (DualVector u)))
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector v)) w)
(DualVector (DualVector v) +> x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar (DualVector (DualVector u))) w x
f)LinearFunction
(Scalar (DualVector (DualVector u)))
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector v)) w)
(DualVector (DualVector v) +> x)
-> LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector v)) w
-> DualVector (DualVector v) +> x
forall s v w. LinearFunction s v w -> v -> w
-+$>VSCCoercion
(Scalar (DualVector v))
(Tensor (Scalar (DualVector v)) (DualVector v) w)
(LinearMap (Scalar (DualVector v)) (DualVector (DualVector v)) w)
VSCCoercion
(Scalar (DualVector v))
(Tensor (Scalar (DualVector v)) (DualVector v) w)
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector v)) w)
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap VSCCoercion
(Scalar (DualVector v))
(Tensor (Scalar (DualVector v)) (DualVector v) w)
(LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector v)) w)
-> Tensor (Scalar (DualVector v)) (DualVector v) w
-> LinearMap
(Scalar (DualVector (DualVector u))) (DualVector (DualVector v)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (DualVector v)) (DualVector v) w
fv)
applyTensorFunctional :: forall u.
(LinearSpace u, Scalar u ~ Scalar (u, v)) =>
Bilinear (DualVector ((u, v) ⊗ u)) ((u, v) ⊗ u) (Scalar (u, v))
applyTensorFunctional = case ( forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @u, forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @v ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness) -> (LinearMap (Scalar v) (u, v) (DualVector u)
-> Tensor (Scalar v) (u, v) u -> Scalar v)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (u, v) (DualVector u))
(LinearFunction (Scalar v) (Tensor (Scalar v) (u, v) u) (Scalar v))
(LinearMap (Scalar v) (u, v) (DualVector u)
-> Tensor (Scalar v) (u, v) u -> Scalar v)
-> Bilinear
(LinearMap (Scalar v) (u, v) (DualVector u))
(Tensor (Scalar v) (u, v) u)
(Scalar v)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap (Scalar v) (u, v) (DualVector u)
-> Tensor (Scalar v) (u, v) u -> Scalar v)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (u, v) (DualVector u))
(LinearFunction
(Scalar v) (Tensor (Scalar v) (u, v) u) (Scalar v)))
-> (LinearMap (Scalar v) (u, v) (DualVector u)
-> Tensor (Scalar v) (u, v) u -> Scalar v)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (u, v) (DualVector u))
(LinearFunction (Scalar v) (Tensor (Scalar v) (u, v) u) (Scalar v))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\(LinearMap (Tensor (Scalar v) (DualVector u) (DualVector u)
fu,Tensor (Scalar v) (DualVector v) (DualVector u)
fv)) (Tensor (Tensor (Scalar v) u u
tu,Tensor (Scalar v) v u
tv))
-> ((LinearFunction
(Scalar u)
(LinearMap (Scalar u) u (DualVector u))
(LinearFunction (Scalar u) (Tensor (Scalar v) u u) (Scalar v))
Bilinear (DualVector (u ⊗ u)) (u ⊗ u) (Scalar u)
forall u.
(LinearSpace u, Scalar u ~ Scalar u) =>
Bilinear (DualVector (u ⊗ u)) (u ⊗ u) (Scalar u)
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctional
LinearFunction
(Scalar u)
(LinearMap (Scalar u) u (DualVector u))
(LinearFunction (Scalar u) (Tensor (Scalar v) u u) (Scalar v))
-> LinearMap (Scalar u) u (DualVector u)
-> LinearFunction (Scalar u) (Tensor (Scalar v) u u) (Scalar v)
forall s v w. LinearFunction s v w -> v -> w
-+$>VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector u) (DualVector u))
(LinearMap (Scalar u) u (DualVector u))
-> Coercion
(Tensor (Scalar v) (DualVector u) (DualVector u))
(LinearMap (Scalar u) u (DualVector u))
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector u) (DualVector u))
(LinearMap (Scalar u) u (DualVector u))
VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector u) (DualVector u))
(LinearMap (Scalar v) (DualVector (DualVector u)) (DualVector u))
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMapCoercion
(Tensor (Scalar v) (DualVector u) (DualVector u))
(LinearMap (Scalar u) u (DualVector u))
-> Tensor (Scalar v) (DualVector u) (DualVector u)
-> LinearMap (Scalar u) u (DualVector u)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$Tensor (Scalar v) (DualVector u) (DualVector u)
fu)LinearFunction (Scalar u) (Tensor (Scalar v) u u) (Scalar v)
-> Tensor (Scalar v) u u -> Scalar v
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) u u
tu)
Scalar v -> Scalar v -> Scalar v
forall a. Num a => a -> a -> a
+ ((LinearFunction
(Scalar v)
(LinearMap (Scalar v) v (DualVector u))
(LinearFunction (Scalar v) (Tensor (Scalar v) v u) (Scalar v))
Bilinear
(DualVector (Tensor (Scalar v) v u))
(Tensor (Scalar v) v u)
(Scalar v)
forall u.
(LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctional
LinearFunction
(Scalar v)
(LinearMap (Scalar v) v (DualVector u))
(LinearFunction (Scalar v) (Tensor (Scalar v) v u) (Scalar v))
-> LinearMap (Scalar v) v (DualVector u)
-> LinearFunction (Scalar v) (Tensor (Scalar v) v u) (Scalar v)
forall s v w. LinearFunction s v w -> v -> w
-+$>VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) (DualVector u))
(LinearMap (Scalar v) v (DualVector u))
-> Coercion
(Tensor (Scalar v) (DualVector v) (DualVector u))
(LinearMap (Scalar v) v (DualVector u))
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) (DualVector u))
(LinearMap (Scalar v) v (DualVector u))
VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) (DualVector u))
(LinearMap (Scalar v) (DualVector (DualVector v)) (DualVector u))
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMapCoercion
(Tensor (Scalar v) (DualVector v) (DualVector u))
(LinearMap (Scalar v) v (DualVector u))
-> Tensor (Scalar v) (DualVector v) (DualVector u)
-> LinearMap (Scalar v) v (DualVector u)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$Tensor (Scalar v) (DualVector v) (DualVector u)
fv)LinearFunction (Scalar v) (Tensor (Scalar v) v u) (Scalar v)
-> Tensor (Scalar v) v u -> Scalar v
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) v u
tv)
applyTensorLinMap :: forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (u, v),
Scalar w ~ Scalar (u, v)) =>
Bilinear (((u, v) ⊗ u) +> w) ((u, v) ⊗ u) w
applyTensorLinMap = case ( DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness) -> (LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w
-> Tensor (Scalar v) (u, v) u -> w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) (u, v) u) w)
(LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w
-> Tensor (Scalar v) (u, v) u -> w)
-> Bilinear
(LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w)
(Tensor (Scalar v) (u, v) u)
w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction((LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w
-> Tensor (Scalar v) (u, v) u -> w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) (u, v) u) w))
-> (LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w
-> Tensor (Scalar v) (u, v) u -> w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) (u, v) u) w)
forall a. Object (->) a => a -> a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
`id`
\LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w
f (Tensor (Tensor (Scalar v) u u
tu,Tensor (Scalar v) v u
tv)) -> let LinearMap (Tensor (Scalar v) (DualVector u) (LinearMap (Scalar v) u w)
fu,Tensor (Scalar v) (DualVector v) (LinearMap (Scalar v) u w)
fv) = VSCCoercion
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w)
(LinearMap (Scalar v) (u, v) (LinearMap (Scalar v) u w))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap VSCCoercion
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w)
(LinearMap (Scalar v) (u, v) (LinearMap (Scalar v) u w))
-> LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w
-> LinearMap (Scalar v) (u, v) (LinearMap (Scalar v) u w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar v) (Tensor (Scalar v) (u, v) u) w
f
in ( (LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) u u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) u u) w)
Bilinear ((u ⊗ u) +> w) (u ⊗ u) w
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar u,
Scalar w ~ Scalar u) =>
Bilinear ((u ⊗ u) +> w) (u ⊗ u) w
applyTensorLinMapLinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) u u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) u u) w)
-> LinearMap (Scalar v) (Tensor (Scalar v) u u) w
-> LinearFunction (Scalar v) (Tensor (Scalar v) u u) w
forall s v w. LinearFunction s v w -> v -> w
-+$>VSCCoercion
(Scalar v)
(LinearMap (Scalar v) u (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) (Tensor (Scalar v) u u) w)
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMapVSCCoercion
(Scalar v)
(LinearMap (Scalar v) u (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) (Tensor (Scalar v) u u) w)
-> VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector u) (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) u (LinearMap (Scalar v) u w))
-> VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector u) (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) (Tensor (Scalar v) u u) w)
forall a b c.
(Object (VSCCoercion (Scalar v)) a,
Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c) =>
VSCCoercion (Scalar v) b c
-> VSCCoercion (Scalar v) a b -> VSCCoercion (Scalar v) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
.VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector u) (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) u (LinearMap (Scalar v) u w))
VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector u) (LinearMap (Scalar v) u w))
(LinearMap
(Scalar v) (DualVector (DualVector u)) (LinearMap (Scalar v) u w))
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector u) (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) (Tensor (Scalar v) u u) w)
-> Tensor (Scalar v) (DualVector u) (LinearMap (Scalar v) u w)
-> LinearMap (Scalar v) (Tensor (Scalar v) u u) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) (DualVector u) (LinearMap (Scalar v) u w)
fu)LinearFunction (Scalar v) (Tensor (Scalar v) u u) w
-> Tensor (Scalar v) u u -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) u u
tu )
w -> w -> w
forall v. AdditiveGroup v => v -> v -> v
^+^ ( (LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) v u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) v u) w)
Bilinear (Tensor (Scalar v) v u +> w) (Tensor (Scalar v) v u) w
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
applyTensorLinMapLinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) v u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) v u) w)
-> LinearMap (Scalar v) (Tensor (Scalar v) v u) w
-> LinearFunction (Scalar v) (Tensor (Scalar v) v u) w
forall s v w. LinearFunction s v w -> v -> w
-+$>VSCCoercion
(Scalar v)
(LinearMap (Scalar v) v (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) (Tensor (Scalar v) v u) w)
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMapVSCCoercion
(Scalar v)
(LinearMap (Scalar v) v (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) (Tensor (Scalar v) v u) w)
-> VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) v (LinearMap (Scalar v) u w))
-> VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) (Tensor (Scalar v) v u) w)
forall a b c.
(Object (VSCCoercion (Scalar v)) a,
Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c) =>
VSCCoercion (Scalar v) b c
-> VSCCoercion (Scalar v) a b -> VSCCoercion (Scalar v) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
.VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) v (LinearMap (Scalar v) u w))
VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) (LinearMap (Scalar v) u w))
(LinearMap
(Scalar v) (DualVector (DualVector v)) (LinearMap (Scalar v) u w))
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap VSCCoercion
(Scalar v)
(Tensor (Scalar v) (DualVector v) (LinearMap (Scalar v) u w))
(LinearMap (Scalar v) (Tensor (Scalar v) v u) w)
-> Tensor (Scalar v) (DualVector v) (LinearMap (Scalar v) u w)
-> LinearMap (Scalar v) (Tensor (Scalar v) v u) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) (DualVector v) (LinearMap (Scalar v) u w)
fv)LinearFunction (Scalar v) (Tensor (Scalar v) v u) w
-> Tensor (Scalar v) v u -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar v) v u
tv )
useTupleLinearSpaceComponents :: forall x y φ.
((u, v) ~ (x, y)) =>
((LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ) -> φ
useTupleLinearSpaceComponents (LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ
r = φ
(LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ
r
coerceDoubleDual :: VSCCoercion (Scalar (u, v)) (u, v) (DualVector (DualVector (u, v)))
coerceDoubleDual = case ( forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @u, forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @v ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness) -> VSCCoercion (Scalar v) (u, v) (u, v)
VSCCoercion (Scalar (u, v)) (u, v) (DualVector (DualVector (u, v)))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
lfstBlock :: ( LSpace u, LSpace v, LSpace w
, Scalar u ~ Scalar v, Scalar v ~ Scalar w )
=> (u+>w) -+> ((u,v)+>w)
lfstBlock :: forall u v w.
(LSpace u, LSpace v, LSpace w, Scalar u ~ Scalar v,
Scalar v ~ Scalar w) =>
(u +> w) -+> ((u, v) +> w)
lfstBlock = (LinearMap (Scalar w) u w -> LinearMap (Scalar w) (u, v) w)
-> LinearFunction
(Scalar w)
(LinearMap (Scalar w) u w)
(LinearMap (Scalar w) (u, v) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (LinearMap (Scalar u) u w -> (v +> w) -> (u, v) +> w
forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
⊕v +> w
LinearMap (Scalar w) v w
forall v. AdditiveGroup v => v
zeroV)
lsndBlock :: ( LSpace u, LSpace v, LSpace w
, Scalar u ~ Scalar v, Scalar v ~ Scalar w )
=> (v+>w) -+> ((u,v)+>w)
lsndBlock :: forall u v w.
(LSpace u, LSpace v, LSpace w, Scalar u ~ Scalar v,
Scalar v ~ Scalar w) =>
(v +> w) -+> ((u, v) +> w)
lsndBlock = (LinearMap (Scalar w) v w -> LinearMap (Scalar w) (u, v) w)
-> LinearFunction
(Scalar w)
(LinearMap (Scalar w) v w)
(LinearMap (Scalar w) (u, v) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (LinearMap (Scalar u) u w
LinearMap (Scalar w) u w
forall v. AdditiveGroup v => v
zeroVLinearMap (Scalar u) u w -> LinearMap (Scalar v) v w -> (u, v) +> w
forall u w v. (u +> w) -> (v +> w) -> (u, v) +> w
⊕)
argFromTensor :: ∀ s v w x . ( LinearSpace v, LinearSpace w
, Scalar v ~ s, Scalar w ~ s
, TensorSpace x, Scalar x ~ s
)
=> VSCCoercion s (LinearMap s (Tensor s (DualVector v) w) x)
(LinearMap s (LinearMap s v w) x)
argFromTensor :: forall s v w x.
(LinearSpace v, LinearSpace w, Scalar v ~ s, Scalar w ~ s,
TensorSpace x, Scalar x ~ s) =>
VSCCoercion
s
(LinearMap s (Tensor s (DualVector v) w) x)
(LinearMap s (LinearMap s v w) x)
argFromTensor = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> VSCCoercion
s
(LinearMap s (Tensor s (DualVector v) w) x)
(LinearMap s (DualVector v) (LinearMap s w x))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap VSCCoercion
s
(LinearMap s (Tensor s (DualVector v) w) x)
(LinearMap s (DualVector v) (LinearMap s w x))
-> VSCCoercion
s
(LinearMap s (DualVector v) (LinearMap s w x))
(LinearMap s (LinearMap s v w) x)
-> VSCCoercion
s
(LinearMap s (Tensor s (DualVector v) w) x)
(LinearMap s (LinearMap s v w) x)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion
s
(LinearMap s (DualVector v) (LinearMap s w x))
(Tensor s v (LinearMap s w x))
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (LinearMap s (DualVector v) w) (Tensor s v w)
fromLinearMap VSCCoercion
s
(LinearMap s (DualVector v) (LinearMap s w x))
(Tensor s v (LinearMap s w x))
-> VSCCoercion
s (Tensor s v (LinearMap s w x)) (LinearMap s (LinearMap s v w) x)
-> VSCCoercion
s
(LinearMap s (DualVector v) (LinearMap s w x))
(LinearMap s (LinearMap s v w) x)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion
s (Tensor s v (LinearMap s w x)) (LinearMap s (LinearMap s v w) x)
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (Tensor s u (LinearMap s v w)) (LinearMap s (LinearMap s u v) w)
coUncurryLinearMap
argAsTensor :: ∀ s v w x . ( LinearSpace v, LinearSpace w
, Scalar v ~ s, Scalar w ~ s
, TensorSpace x, Scalar x ~ s
)
=> VSCCoercion s (LinearMap s (LinearMap s v w) x)
(LinearMap s (Tensor s (DualVector v) w) x)
argAsTensor :: forall s v w x.
(LinearSpace v, LinearSpace w, Scalar v ~ s, Scalar w ~ s,
TensorSpace x, Scalar x ~ s) =>
VSCCoercion
s
(LinearMap s (LinearMap s v w) x)
(LinearMap s (Tensor s (DualVector v) w) x)
argAsTensor = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> VSCCoercion
s
(LinearMap s (DualVector v) (LinearMap s w x))
(LinearMap s (Tensor s (DualVector v) w) x)
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMap VSCCoercion
s
(LinearMap s (DualVector v) (LinearMap s w x))
(LinearMap s (Tensor s (DualVector v) w) x)
-> VSCCoercion
s
(LinearMap s (LinearMap s v w) x)
(LinearMap s (DualVector v) (LinearMap s w x))
-> VSCCoercion
s
(LinearMap s (LinearMap s v w) x)
(LinearMap s (Tensor s (DualVector v) w) x)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< VSCCoercion
s
(Tensor s v (LinearMap s w x))
(LinearMap s (DualVector v) (LinearMap s w x))
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap VSCCoercion
s
(Tensor s v (LinearMap s w x))
(LinearMap s (DualVector v) (LinearMap s w x))
-> VSCCoercion
s (LinearMap s (LinearMap s v w) x) (Tensor s v (LinearMap s w x))
-> VSCCoercion
s
(LinearMap s (LinearMap s v w) x)
(LinearMap s (DualVector v) (LinearMap s w x))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< VSCCoercion
s (LinearMap s (LinearMap s v w) x) (Tensor s v (LinearMap s w x))
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (LinearMap s u v) w) (Tensor s u (LinearMap s v w))
coCurryLinearMap
tensorDimensionAssoc :: ∀ u v w s r . (TensorSpace u, TensorSpace v, TensorSpace w)
=> (( Maybe.ZipWithTimes (Maybe.ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ Maybe.ZipWithTimes (StaticDimension u)
(Maybe.ZipWithTimes (StaticDimension v) (StaticDimension w))
) => r) -> r
tensorDimensionAssoc :: forall u v w s r.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
((ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
r)
-> r
tensorDimensionAssoc (ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
r
φ
= Sing (StaticDimension u)
-> Sing (StaticDimension v)
-> Sing (StaticDimension w)
-> ((ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))
~ ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)) =>
r)
-> r
forall (a :: Maybe Nat) (b :: Maybe Nat) (c :: Maybe Nat) r.
Sing a
-> Sing b
-> Sing c
-> ((ZipWithTimes a (ZipWithTimes b c)
~ ZipWithTimes (ZipWithTimes a b) c) =>
r)
-> r
Maybe.zipWithTimesAssoc (forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u)
(forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v)
(forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @w) r
(ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
r
(ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))
~ ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)) =>
r
φ
deferLinearMap :: ∀ s u v w . (TensorSpace u, TensorSpace v, TensorSpace w)
=> VSCCoercion s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap :: forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap
= forall u v w s r.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
((ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
r)
-> r
tensorDimensionAssoc @u @v @w VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
(ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
hasteLinearMap :: ∀ s u v w . (TensorSpace u, TensorSpace v, TensorSpace w)
=> VSCCoercion s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap :: forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap = forall u v w s r.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
((ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
r)
-> r
tensorDimensionAssoc @u @v @w VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
(ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
lassocTensor :: ∀ s u v w . (TensorSpace u, TensorSpace v, TensorSpace w)
=> VSCCoercion s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor :: forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor = forall u v w s r.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
((ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
r)
-> r
tensorDimensionAssoc @u @v @w VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
(ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
rassocTensor :: ∀ s u v w . (TensorSpace u, TensorSpace v, TensorSpace w)
=> VSCCoercion s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor :: forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor = forall u v w s r.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
((ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
r)
-> r
tensorDimensionAssoc @u @v @w VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
(ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
instance ∀ s u v . ( LinearSpace u, TensorSpace v, Scalar u ~ s, Scalar v ~ s )
=> DimensionAware (LinearMap s u v) where
type StaticDimension (LinearMap s u v)
= Maybe.ZipWithTimes (StaticDimension u) (StaticDimension v)
dimensionalityWitness :: DimensionalityWitness (LinearMap s u v)
dimensionalityWitness = case (forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @u, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v) of
(DimensionalityWitness u
IsStaticDimensional, DimensionalityWitness v
IsStaticDimensional)
-> SNat (n * n)
-> (KnownNat (n * n) => DimensionalityWitness (LinearMap s u v))
-> DimensionalityWitness (LinearMap s u v)
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @u Sing n -> Sing n -> Sing (Apply (Apply (*@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%* forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @v)
DimensionalityWitness (LinearMap s u v)
KnownNat (n * n) => DimensionalityWitness (LinearMap s u v)
forall (n :: Nat) v. Dimensional n v => DimensionalityWitness v
IsStaticDimensional
(DimensionalityWitness u
IsFlexibleDimensional, DimensionalityWitness v
_) -> DimensionalityWitness (LinearMap s u v)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
(DimensionalityWitness u
_, DimensionalityWitness v
IsFlexibleDimensional) -> DimensionalityWitness (LinearMap s u v)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
instance ∀ s n u m v nm . ( n`Dimensional`u, m`Dimensional`v
, LinearSpace u, TensorSpace v, Scalar u ~ s, Scalar v ~ s
, nm ~ (n*m) )
=> nm`Dimensional`(LinearMap s u v) where
knownDimensionalitySing :: Sing nm
knownDimensionalitySing = forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @u Sing n -> Sing m -> Sing (Apply (Apply (*@#@$) n) m)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%* forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @v
unsafeFromArrayWithOffset :: forall (α :: Type -> Type).
Vector α (Scalar (LinearMap s u v)) =>
Int -> α (Scalar (LinearMap s u v)) -> LinearMap s u v
unsafeFromArrayWithOffset Int
i α (Scalar (LinearMap s u v))
arr = case forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @u of
DualSpaceWitness u
DualSpaceWitness -> case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(DualVector u) of
DimensionalityWitness (DualVector u)
IsStaticDimensional
-> VSCCoercion s (Tensor s (DualVector u) v) (LinearMap s u v)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion s (Tensor s (DualVector u) v) (LinearMap s u v)
-> Tensor s (DualVector u) v -> LinearMap s u v
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Int
-> α (Scalar (Tensor s (DualVector u) v))
-> Tensor s (DualVector u) v
forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
forall (α :: Type -> Type).
Vector α (Scalar (Tensor s (DualVector u) v)) =>
Int
-> α (Scalar (Tensor s (DualVector u) v))
-> Tensor s (DualVector u) v
unsafeFromArrayWithOffset Int
i α (Scalar (Tensor s (DualVector u) v))
α (Scalar (LinearMap s u v))
arr
unsafeWriteArrayWithOffset :: forall (α :: Type -> Type) σ.
Vector α (Scalar (LinearMap s u v)) =>
Mutable α σ (Scalar (LinearMap s u v))
-> Int -> LinearMap s u v -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (LinearMap s u v))
arr Int
i LinearMap s u v
lm = case forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @u of
DualSpaceWitness u
DualSpaceWitness -> case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(DualVector u) of
DimensionalityWitness (DualVector u)
IsStaticDimensional
-> Mutable α σ (Scalar (Tensor s (DualVector u) v))
-> Int -> Tensor s (DualVector u) v -> ST σ ()
forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
forall (α :: Type -> Type) σ.
Vector α (Scalar (Tensor s (DualVector u) v)) =>
Mutable α σ (Scalar (Tensor s (DualVector u) v))
-> Int -> Tensor s (DualVector u) v -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (Tensor s (DualVector u) v))
Mutable α σ (Scalar (LinearMap s u v))
arr Int
i (VSCCoercion s (LinearMap s u v) (Tensor s (DualVector u) v)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion s (LinearMap s u v) (Tensor s (DualVector u) v)
-> LinearMap s u v -> Tensor s (DualVector u) v
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s u v
lm)
instance ∀ s u v . ( LinearSpace u, TensorSpace v, Scalar u ~ s, Scalar v ~ s )
=> TensorSpace (LinearMap s u v) where
type TensorProduct (LinearMap s u v) w = TensorProduct (DualVector u) (Tensor s v w)
scalarSpaceWitness :: ScalarSpaceWitness (LinearMap s u v)
scalarSpaceWitness = case ( ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u
, ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v ) of
(ScalarSpaceWitness u
ScalarSpaceWitness, ScalarSpaceWitness v
_ScalarSpaceWitness) -> ScalarSpaceWitness (LinearMap s u v)
forall v.
(Num' (Scalar v), Scalar (Scalar v) ~ Scalar v) =>
ScalarSpaceWitness v
ScalarSpaceWitness
linearManifoldWitness :: LinearManifoldWitness (LinearMap s u v)
linearManifoldWitness = case ( ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u
, LinearManifoldWitness u
forall v. TensorSpace v => LinearManifoldWitness v
linearManifoldWitness :: LinearManifoldWitness u
, LinearManifoldWitness v
forall v. TensorSpace v => LinearManifoldWitness v
linearManifoldWitness :: LinearManifoldWitness v ) of
( ScalarSpaceWitness u
ScalarSpaceWitness
,LinearManifoldWitness u
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
,LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
)
-> LinearManifoldWitness (LinearMap s u v)
forall v.
(Needle v ~ v, AffineSpace v, Diff v ~ v) =>
LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
zeroTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) =>
LinearMap s u v ⊗ w
zeroTensor = VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> LinearMap s u (Tensor s v w) -> Tensor s (LinearMap s u v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s u (Tensor s v w)
forall v. AdditiveGroup v => v
zeroV
toFlatTensor :: LinearMap s u v -+> (LinearMap s u v ⊗ Scalar (LinearMap s u v))
toFlatTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> VSCCoercion
s (LinearMap s u (Tensor s v s)) (Tensor s (LinearMap s u v) s)
-> LinearFunction
s (LinearMap s u (Tensor s v s)) (Tensor s (LinearMap s u v) s)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (LinearMap s u (Tensor s v s)) (Tensor s (LinearMap s u v) s)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap LinearFunction
s (LinearMap s u (Tensor s v s)) (Tensor s (LinearMap s u v) s)
-> LinearFunction
s (LinearMap s u v) (LinearMap s u (Tensor s v s))
-> LinearFunction
s (LinearMap s u v) (Tensor s (LinearMap s u v) s)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s v (Tensor s v s)
-> LinearFunction
s (LinearMap s u v) (LinearMap s u (Tensor s v s))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s u b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s u a) (LinearMap s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction s v (Tensor s v s)
v -+> (v ⊗ Scalar v)
forall v. TensorSpace v => v -+> (v ⊗ Scalar v)
toFlatTensor
fromFlatTensor :: (LinearMap s u v ⊗ Scalar (LinearMap s u v)) -+> LinearMap s u v
fromFlatTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> LinearFunction s (Tensor s v s) v
-> LinearFunction
s (LinearMap s u (Tensor s v s)) (LinearMap s u v)
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s u b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s u a) (LinearMap s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction s (Tensor s v s) v
(v ⊗ Scalar v) -+> v
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor LinearFunction s (LinearMap s u (Tensor s v s)) (LinearMap s u v)
-> LinearFunction
s (Tensor s (LinearMap s u v) s) (LinearMap s u (Tensor s v s))
-> LinearFunction
s (Tensor s (LinearMap s u v) s) (LinearMap s u v)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (LinearMap s u v) s) (LinearMap s u (Tensor s v s))
-> LinearFunction
s (Tensor s (LinearMap s u v) s) (LinearMap s u (Tensor s v s))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (LinearMap s u v) s) (LinearMap s u (Tensor s v s))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap
addTensors :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) =>
(LinearMap s u v ⊗ w)
-> (LinearMap s u v ⊗ w) -> LinearMap s u v ⊗ w
addTensors LinearMap s u v ⊗ w
t₁ LinearMap s u v ⊗ w
t₂ = VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> LinearMap s u (Tensor s v w) -> Tensor s (LinearMap s u v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMapVSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> Tensor s (LinearMap s u v) w -> LinearMap s u (Tensor s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$Tensor s (LinearMap s u v) w
LinearMap s u v ⊗ w
t₁) LinearMap s u (Tensor s v w)
-> LinearMap s u (Tensor s v w) -> LinearMap s u (Tensor s v w)
forall v. AdditiveGroup v => v -> v -> v
^+^ (VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMapVSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> Tensor s (LinearMap s u v) w -> LinearMap s u (Tensor s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$Tensor s (LinearMap s u v) w
LinearMap s u v ⊗ w
t₂)
subtractTensors :: forall w.
(TensorSpace (LinearMap s u v), TensorSpace w,
Scalar w ~ Scalar (LinearMap s u v)) =>
(LinearMap s u v ⊗ w)
-> (LinearMap s u v ⊗ w) -> LinearMap s u v ⊗ w
subtractTensors LinearMap s u v ⊗ w
t₁ LinearMap s u v ⊗ w
t₂ = VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> LinearMap s u (Tensor s v w) -> Tensor s (LinearMap s u v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMapVSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> Tensor s (LinearMap s u v) w -> LinearMap s u (Tensor s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$Tensor s (LinearMap s u v) w
LinearMap s u v ⊗ w
t₁) LinearMap s u (Tensor s v w)
-> LinearMap s u (Tensor s v w) -> LinearMap s u (Tensor s v w)
forall v. AdditiveGroup v => v -> v -> v
^-^ (VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMapVSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> Tensor s (LinearMap s u v) w -> LinearMap s u (Tensor s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$Tensor s (LinearMap s u v) w
LinearMap s u v ⊗ w
t₂)
scaleTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) =>
Bilinear
(Scalar (LinearMap s u v))
(LinearMap s u v ⊗ w)
(LinearMap s u v ⊗ w)
scaleTensor = (s -> Tensor s (LinearMap s u v) w -> Tensor s (LinearMap s u v) w)
-> LinearFunction
(Scalar s)
s
(LinearFunction
(Scalar s)
(Tensor s (LinearMap s u v) w)
(Tensor s (LinearMap s u v) w))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((s
-> Tensor s (LinearMap s u v) w -> Tensor s (LinearMap s u v) w)
-> LinearFunction
(Scalar s)
s
(LinearFunction
(Scalar s)
(Tensor s (LinearMap s u v) w)
(Tensor s (LinearMap s u v) w)))
-> (s
-> Tensor s (LinearMap s u v) w -> Tensor s (LinearMap s u v) w)
-> LinearFunction
(Scalar s)
s
(LinearFunction
(Scalar s)
(Tensor s (LinearMap s u v) w)
(Tensor s (LinearMap s u v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \s
μ Tensor s (LinearMap s u v) w
t
-> VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> LinearMap s u (Tensor s v w) -> Tensor s (LinearMap s u v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ s
-> LinearFunction
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w))
forall v s.
(VectorSpace v, Scalar v ~ s) =>
s -> LinearFunction s v v
scaleWith s
μ LinearFunction
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w))
-> LinearMap s u (Tensor s v w) -> LinearMap s u (Tensor s v w)
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> Tensor s (LinearMap s u v) w -> LinearMap s u (Tensor s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor s (LinearMap s u v) w
t
negateTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) =>
(LinearMap s u v ⊗ w) -+> (LinearMap s u v ⊗ w)
negateTensor = VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> LinearFunction
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap LinearFunction
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) w)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w))
forall w s. AdditiveGroup w => LinearFunction s w w
lNegateV LinearFunction
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w))
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap
transposeTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) =>
(LinearMap s u v ⊗ w) -+> (w ⊗ LinearMap s u v)
transposeTensor = case ( ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u
, DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u ) of
(ScalarSpaceWitness u
ScalarSpaceWitness,DualSpaceWitness u
DualSpaceWitness)->
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap
LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> LinearFunction
s (LinearMap s u (Tensor s v w)) (Tensor s w (LinearMap s u v))
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (Tensor s w (LinearMap s u v))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction s (Tensor s v w) (Tensor s w v)
-> LinearFunction
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s w v))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s u b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s u a) (LinearMap s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction s (Tensor s v w) (Tensor s w v)
(v ⊗ w) -+> (w ⊗ v)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s w v))
-> LinearFunction
s (LinearMap s u (Tensor s w v)) (Tensor s w (LinearMap s u v))
-> LinearFunction
s (LinearMap s u (Tensor s v w)) (Tensor s w (LinearMap s u v))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion
s
(LinearMap s u (Tensor s w v))
(Tensor s (DualVector u) (Tensor s w v))
-> LinearFunction
s
(LinearMap s u (Tensor s w v))
(Tensor s (DualVector u) (Tensor s w v))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s
(LinearMap s u (Tensor s w v))
(Tensor s (DualVector u) (Tensor s w v))
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor
LinearFunction
s
(LinearMap s u (Tensor s w v))
(Tensor s (DualVector u) (Tensor s w v))
-> LinearFunction
s
(Tensor s (DualVector u) (Tensor s w v))
(Tensor s w (LinearMap s u v))
-> LinearFunction
s (LinearMap s u (Tensor s w v)) (Tensor s w (LinearMap s u v))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
s
(Tensor s (DualVector u) (Tensor s w v))
(Tensor s (Tensor s w v) (DualVector u))
(DualVector u ⊗ Tensor s w v) -+> (Tensor s w v ⊗ DualVector u)
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector u)) =>
(DualVector u ⊗ w) -+> (w ⊗ DualVector u)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
s
(Tensor s (DualVector u) (Tensor s w v))
(Tensor s (Tensor s w v) (DualVector u))
-> LinearFunction
s
(Tensor s (Tensor s w v) (DualVector u))
(Tensor s w (LinearMap s u v))
-> LinearFunction
s
(Tensor s (DualVector u) (Tensor s w v))
(Tensor s w (LinearMap s u v))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion
s
(Tensor s (Tensor s w v) (DualVector u))
(Tensor s w (Tensor s v (DualVector u)))
-> LinearFunction
s
(Tensor s (Tensor s w v) (DualVector u))
(Tensor s w (Tensor s v (DualVector u)))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s
(Tensor s (Tensor s w v) (DualVector u))
(Tensor s w (Tensor s v (DualVector u)))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
LinearFunction
s
(Tensor s (Tensor s w v) (DualVector u))
(Tensor s w (Tensor s v (DualVector u)))
-> LinearFunction
s
(Tensor s w (Tensor s v (DualVector u)))
(Tensor s w (LinearMap s u v))
-> LinearFunction
s
(Tensor s (Tensor s w v) (DualVector u))
(Tensor s w (LinearMap s u v))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
s (Tensor s v (DualVector u)) (Tensor s (DualVector u) v)
-> LinearFunction
s
(Tensor s w (Tensor s v (DualVector u)))
(Tensor s w (Tensor s (DualVector u) v))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s w a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s w b)) =>
LinearFunction s a b
-> LinearFunction s (Tensor s w a) (Tensor s w b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction
s (Tensor s v (DualVector u)) (Tensor s (DualVector u) v)
(v ⊗ DualVector u) -+> (DualVector u ⊗ v)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
s
(Tensor s w (Tensor s v (DualVector u)))
(Tensor s w (Tensor s (DualVector u) v))
-> LinearFunction
s
(Tensor s w (Tensor s (DualVector u) v))
(Tensor s w (LinearMap s u v))
-> LinearFunction
s
(Tensor s w (Tensor s v (DualVector u)))
(Tensor s w (LinearMap s u v))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion
s
(Tensor s w (Tensor s (DualVector u) v))
(Tensor s w (LinearMap s u v))
-> LinearFunction
s
(Tensor s w (Tensor s (DualVector u) v))
(Tensor s w (LinearMap s u v))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (VSCCoercion s (Tensor s (DualVector u) v) (LinearMap s u v)
-> VSCCoercion
s
(Tensor s w (Tensor s (DualVector u) v))
(Tensor s w (LinearMap s u v))
forall a b.
(Object (VSCCoercion s) a, Object (VSCCoercion s) (Tensor s w a),
Object (VSCCoercion s) b, Object (VSCCoercion s) (Tensor s w b)) =>
VSCCoercion s a b -> VSCCoercion s (Tensor s w a) (Tensor s w b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion s (Tensor s (DualVector u) v) (LinearMap s u v)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor)
tensorProduct :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) =>
Bilinear (LinearMap s u v) w (LinearMap s u v ⊗ w)
tensorProduct = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> (LinearMap s u v -> w -> Tensor s (LinearMap s u v) w)
-> LinearFunction
s
(LinearMap s u v)
(LinearFunction s w (Tensor s (LinearMap s u v) w))
(LinearMap s u v -> w -> Tensor s (LinearMap s u v) w)
-> Bilinear (LinearMap s u v) w (Tensor s (LinearMap s u v) w)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s u v -> w -> Tensor s (LinearMap s u v) w)
-> LinearFunction
s
(LinearMap s u v)
(LinearFunction s w (Tensor s (LinearMap s u v) w)))
-> (LinearMap s u v -> w -> Tensor s (LinearMap s u v) w)
-> LinearFunction
s
(LinearMap s u v)
(LinearFunction s w (Tensor s (LinearMap s u v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearMap s u v
f w
s
-> VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> LinearMap s u (Tensor s v w) -> Tensor s (LinearMap s u v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction s v (Tensor s v w)
-> LinearFunction
s (LinearMap s u v) (LinearMap s u (Tensor s v w))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s u b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s u a) (LinearMap s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (Bilinear v w (Tensor s v w) -> Bilinear w v (Tensor s v w)
forall v w y. Bilinear v w y -> Bilinear w v y
flipBilin Bilinear v w (Tensor s v w)
Bilinear v w (v ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductLinearFunction s w (LinearFunction s v (Tensor s v w))
-> w -> LinearFunction s v (Tensor s v w)
forall s v w. LinearFunction s v w -> v -> w
-+$>w
s)LinearFunction s (LinearMap s u v) (LinearMap s u (Tensor s v w))
-> LinearMap s u v -> LinearMap s u (Tensor s v w)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap s u v
f
fmapTensor :: forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (LinearMap s u v),
Scalar x ~ Scalar (LinearMap s u v)) =>
Bilinear (w -+> x) (LinearMap s u v ⊗ w) (LinearMap s u v ⊗ x)
fmapTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> (LinearFunction s w x
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) x))
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) x))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction s w x
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) x))
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) x)))
-> (LinearFunction s w x
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) x))
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction s w x
f
-> VSCCoercion
s (LinearMap s u (Tensor s v x)) (Tensor s (LinearMap s u v) x)
-> LinearFunction
s (LinearMap s u (Tensor s v x)) (Tensor s (LinearMap s u v) x)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (LinearMap s u (Tensor s v x)) (Tensor s (LinearMap s u v) x)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap LinearFunction
s (LinearMap s u (Tensor s v x)) (Tensor s (LinearMap s u v) x)
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v x))
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) x)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< LinearFunction s (Tensor s v w) (Tensor s v x)
-> LinearFunction
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v x))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s u b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s u a) (LinearMap s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction s w x
-> LinearFunction s (Tensor s v w) (Tensor s v x)
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s v a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s v b)) =>
LinearFunction s a b
-> LinearFunction s (Tensor s v a) (Tensor s v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction s w x
f) LinearFunction
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v x))
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v x))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap
fzipTensorWith :: forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (LinearMap s u v),
Scalar w ~ Scalar (LinearMap s u v),
Scalar x ~ Scalar (LinearMap s u v)) =>
Bilinear
((w, x) -+> u)
(LinearMap s u v ⊗ w, LinearMap s u v ⊗ x)
(LinearMap s u v ⊗ u)
fzipTensorWith = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> (LinearFunction s (w, x) u
-> LinearFunction
s
(Tensor s (LinearMap s u v) w, Tensor s (LinearMap s u v) x)
(Tensor s (LinearMap s u v) u))
-> LinearFunction
s
(LinearFunction s (w, x) u)
(LinearFunction
s
(Tensor s (LinearMap s u v) w, Tensor s (LinearMap s u v) x)
(Tensor s (LinearMap s u v) u))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction s (w, x) u
-> LinearFunction
s
(Tensor s (LinearMap s u v) w, Tensor s (LinearMap s u v) x)
(Tensor s (LinearMap s u v) u))
-> LinearFunction
s
(LinearFunction s (w, x) u)
(LinearFunction
s
(Tensor s (LinearMap s u v) w, Tensor s (LinearMap s u v) x)
(Tensor s (LinearMap s u v) u)))
-> (LinearFunction s (w, x) u
-> LinearFunction
s
(Tensor s (LinearMap s u v) w, Tensor s (LinearMap s u v) x)
(Tensor s (LinearMap s u v) u))
-> LinearFunction
s
(LinearFunction s (w, x) u)
(LinearFunction
s
(Tensor s (LinearMap s u v) w, Tensor s (LinearMap s u v) x)
(Tensor s (LinearMap s u v) u))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction s (w, x) u
f
-> VSCCoercion
s (LinearMap s u (Tensor s v u)) (Tensor s (LinearMap s u v) u)
-> LinearFunction
s (LinearMap s u (Tensor s v u)) (Tensor s (LinearMap s u v) u)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (LinearMap s u (Tensor s v u)) (Tensor s (LinearMap s u v) u)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap LinearFunction
s (LinearMap s u (Tensor s v u)) (Tensor s (LinearMap s u v) u)
-> LinearFunction
s
(Tensor s (LinearMap s u v) w, Tensor s (LinearMap s u v) x)
(LinearMap s u (Tensor s v u))
-> LinearFunction
s
(Tensor s (LinearMap s u v) w, Tensor s (LinearMap s u v) x)
(Tensor s (LinearMap s u v) u)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< LinearFunction s (Tensor s v w, Tensor s v x) (Tensor s v u)
-> LinearFunction
s
(LinearMap s u (Tensor s v w), LinearMap s u (Tensor s v x))
(LinearMap s u (Tensor s v u))
forall a b c.
(ObjectPair (LinearFunction s) a b, Object (LinearFunction s) c,
ObjectPair (LinearFunction s) (LinearMap s u a) (LinearMap s u b),
Object (LinearFunction s) (LinearMap s u c)) =>
LinearFunction s (a, b) c
-> LinearFunction
s (LinearMap s u a, LinearMap s u b) (LinearMap s u c)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b c.
(Monoidal f r t, ObjectPair r a b, Object r c,
ObjectPair t (f a) (f b), Object t (f c)) =>
r (a, b) c -> t (f a, f b) (f c)
fzipWith (LinearFunction s (w, x) u
-> LinearFunction s (Tensor s v w, Tensor s v x) (Tensor s v u)
forall a b c.
(ObjectPair (LinearFunction s) a b, Object (LinearFunction s) c,
ObjectPair (LinearFunction s) (Tensor s v a) (Tensor s v b),
Object (LinearFunction s) (Tensor s v c)) =>
LinearFunction s (a, b) c
-> LinearFunction s (Tensor s v a, Tensor s v b) (Tensor s v c)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b c.
(Monoidal f r t, ObjectPair r a b, Object r c,
ObjectPair t (f a) (f b), Object t (f c)) =>
r (a, b) c -> t (f a, f b) (f c)
fzipWith LinearFunction s (w, x) u
f)
LinearFunction
s
(LinearMap s u (Tensor s v w), LinearMap s u (Tensor s v x))
(LinearMap s u (Tensor s v u))
-> LinearFunction
s
(Tensor s (LinearMap s u v) w, Tensor s (LinearMap s u v) x)
(LinearMap s u (Tensor s v w), LinearMap s u (Tensor s v x))
-> LinearFunction
s
(Tensor s (LinearMap s u v) w, Tensor s (LinearMap s u v) x)
(LinearMap s u (Tensor s v u))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap LinearFunction
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> LinearFunction
s (Tensor s (LinearMap s u v) x) (LinearMap s u (Tensor s v x))
-> LinearFunction
s
(Tensor s (LinearMap s u v) w, Tensor s (LinearMap s u v) x)
(LinearMap s u (Tensor s v w), LinearMap s u (Tensor s v x))
forall b b' c c'.
(ObjectPair (LinearFunction s) b b',
ObjectPair (LinearFunction s) c c') =>
LinearFunction s b c
-> LinearFunction s b' c' -> LinearFunction s (b, b') (c, c')
forall (a :: Type -> Type -> Type) b b' c c'.
(Morphism a, ObjectPair a b b', ObjectPair a c c') =>
a b c -> a b' c' -> a (b, b') (c, c')
*** VSCCoercion
s (Tensor s (LinearMap s u v) x) (LinearMap s u (Tensor s v x))
-> LinearFunction
s (Tensor s (LinearMap s u v) x) (LinearMap s u (Tensor s v x))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (LinearMap s u v) x) (LinearMap s u (Tensor s v x))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap
tensorUnsafeFromArrayWithOffset :: ∀ nm w o α
. ( nm`Dimensional`LinearMap s u v
, TensorSpace w, o`Dimensional`w, Scalar w ~ s
, GArr.Vector α s )
=> Int -> α s -> (LinearMap s u v⊗w)
tensorUnsafeFromArrayWithOffset :: forall (nm :: Nat) w (o :: Nat) (α :: Type -> Type).
(Dimensional nm (LinearMap s u v), TensorSpace w, Dimensional o w,
Scalar w ~ s, Vector α s) =>
Int -> α s -> LinearMap s u v ⊗ w
tensorUnsafeFromArrayWithOffset
= case ( forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @u, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u
, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v ) of
( DimensionalityWitness u
IsStaticDimensional, SJust Sing n
sn
,DimensionalityWitness v
IsStaticDimensional, SJust Sing n
sm )
-> SNat (n * o)
-> (KnownNat (n * o) => Int -> α s -> Tensor s (LinearMap s u v) w)
-> Int
-> α s
-> Tensor s (LinearMap s u v) w
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (Sing n
Sing n
smSing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w) (
SNat (n * (n * o))
-> (KnownNat (n * (n * o)) =>
Int -> α s -> Tensor s (LinearMap s u v) w)
-> Int
-> α s
-> Tensor s (LinearMap s u v) w
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (Sing n
Sing n
snSing n -> Sing (n * o) -> Sing (Apply (Apply (*@#@$) n) (n * o))
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*(Sing n
Sing n
smSing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w)) (
\Int
i -> VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> LinearMap s u (Tensor s v w) -> Tensor s (LinearMap s u v) w
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c, Object (->) b,
Object (->) c) =>
VSCCoercion s b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap @s @u @v @w)
(LinearMap s u (Tensor s v w) -> Tensor s (LinearMap s u v) w)
-> (α s -> LinearMap s u (Tensor s v w))
-> α s
-> Tensor s (LinearMap s u v) w
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Int
-> α (Scalar (LinearMap s u (Tensor s v w)))
-> LinearMap s u (Tensor s v w)
forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
forall (α :: Type -> Type).
Vector α (Scalar (LinearMap s u (Tensor s v w))) =>
Int
-> α (Scalar (LinearMap s u (Tensor s v w)))
-> LinearMap s u (Tensor s v w)
unsafeFromArrayWithOffset Int
i))
tensorUnsafeWriteArrayWithOffset :: ∀ nm w o α σ
. ( nm`Dimensional`LinearMap s u v
, TensorSpace w, o`Dimensional`w, Scalar w ~ s
, GArr.Vector α s )
=> GArr.Mutable α σ s -> Int -> (LinearMap s u v⊗w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset :: forall (nm :: Nat) w (o :: Nat) (α :: Type -> Type) σ.
(Dimensional nm (LinearMap s u v), TensorSpace w, Dimensional o w,
Scalar w ~ s, Vector α s) =>
Mutable α σ s -> Int -> (LinearMap s u v ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset
= case ( forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @u, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u
, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v ) of
( DimensionalityWitness u
IsStaticDimensional, SJust Sing n
sn
,DimensionalityWitness v
IsStaticDimensional, SJust Sing n
sm )
-> SNat (n * o)
-> (KnownNat (n * o) =>
Mutable α σ s -> Int -> Tensor s (LinearMap s u v) w -> ST σ ())
-> Mutable α σ s
-> Int
-> Tensor s (LinearMap s u v) w
-> ST σ ()
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (Sing n
Sing n
smSing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w) (
SNat (n * (n * o))
-> (KnownNat (n * (n * o)) =>
Mutable α σ s -> Int -> Tensor s (LinearMap s u v) w -> ST σ ())
-> Mutable α σ s
-> Int
-> Tensor s (LinearMap s u v) w
-> ST σ ()
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (Sing n
Sing n
snSing n -> Sing (n * o) -> Sing (Apply (Apply (*@#@$) n) (n * o))
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*(Sing n
Sing n
smSing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w)) (
\Mutable α σ s
ar Int
i -> Mutable α σ (Scalar (LinearMap s u (Tensor s v w)))
-> Int -> LinearMap s u (Tensor s v w) -> ST σ ()
forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
forall (α :: Type -> Type) σ.
Vector α (Scalar (LinearMap s u (Tensor s v w))) =>
Mutable α σ (Scalar (LinearMap s u (Tensor s v w)))
-> Int -> LinearMap s u (Tensor s v w) -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ s
Mutable α σ (Scalar (LinearMap s u (Tensor s v w)))
ar Int
i
(LinearMap s u (Tensor s v w) -> ST σ ())
-> (Tensor s (LinearMap s u v) w -> LinearMap s u (Tensor s v w))
-> Tensor s (LinearMap s u v) w
-> ST σ ()
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> Tensor s (LinearMap s u v) w -> LinearMap s u (Tensor s v w)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c, Object (->) b,
Object (->) c) =>
VSCCoercion s b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap @s @u @v @w) ))
coerceFmapTensorProduct :: forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (LinearMap s u v),
TensorSpace b, Scalar b ~ Scalar (LinearMap s u v)) =>
p (LinearMap s u v)
-> VSCCoercion (Scalar (LinearMap s u v)) a b
-> Coercion
(TensorProduct (LinearMap s u v) a)
(TensorProduct (LinearMap s u v) b)
coerceFmapTensorProduct = DualSpaceWitness u
-> p (LinearMap s u v)
-> VSCCoercion s a b
-> Coercion
(TensorProduct (DualVector u) (Tensor s v a))
(TensorProduct (DualVector u) (Tensor s v b))
forall a b (p :: Type -> Type).
(TensorSpace a, Scalar a ~ s, TensorSpace b, Scalar b ~ s) =>
DualSpaceWitness u
-> p (LinearMap s u v)
-> VSCCoercion s a b
-> Coercion
(TensorProduct (DualVector u) (Tensor s v a))
(TensorProduct (DualVector u) (Tensor s v b))
cftlp DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness
where cftlp :: ∀ a b p . ( TensorSpace a, Scalar a ~ s
, TensorSpace b, Scalar b ~ s )
=> DualSpaceWitness u -> p (LinearMap s u v) -> VSCCoercion s a b
-> Coercion (TensorProduct (DualVector u) (Tensor s v a))
(TensorProduct (DualVector u) (Tensor s v b))
cftlp :: forall a b (p :: Type -> Type).
(TensorSpace a, Scalar a ~ s, TensorSpace b, Scalar b ~ s) =>
DualSpaceWitness u
-> p (LinearMap s u v)
-> VSCCoercion s a b
-> Coercion
(TensorProduct (DualVector u) (Tensor s v a))
(TensorProduct (DualVector u) (Tensor s v b))
cftlp DualSpaceWitness u
DualSpaceWitness p (LinearMap s u v)
_ VSCCoercion s a b
c
= [DualVector u]
-> VSCCoercion
(Scalar (DualVector u)) (Tensor s v a) (Tensor s v b)
-> Coercion
(TensorProduct (DualVector u) (Tensor s v a))
(TensorProduct (DualVector u) (Tensor s v b))
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (DualVector u),
TensorSpace b, Scalar b ~ Scalar (DualVector u)) =>
p (DualVector u)
-> VSCCoercion (Scalar (DualVector u)) a b
-> Coercion
(TensorProduct (DualVector u) a) (TensorProduct (DualVector u) b)
coerceFmapTensorProduct ([]::[DualVector u])
(VSCCoercion s a b -> VSCCoercion s (Tensor s v a) (Tensor s v b)
forall a b.
(Object (VSCCoercion s) a, Object (VSCCoercion s) (Tensor s v a),
Object (VSCCoercion s) b, Object (VSCCoercion s) (Tensor s v b)) =>
VSCCoercion s a b -> VSCCoercion s (Tensor s v a) (Tensor s v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion s a b
c :: VSCCoercion s (v⊗a) (v⊗b))
wellDefinedVector :: LinearMap s u v -> Maybe (LinearMap s u v)
wellDefinedVector = case DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u of
DualSpaceWitness u
DualSpaceWitness -> VSCCoercion s (LinearMap s u v) (Tensor s (DualVector u) v)
-> LinearMap s u v -> Tensor s (DualVector u) v
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c, Object (->) b,
Object (->) c) =>
VSCCoercion s b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion s (LinearMap s u v) (Tensor s (DualVector u) v)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor (LinearMap s u v -> Tensor s (DualVector u) v)
-> (Tensor s (DualVector u) v -> Maybe (LinearMap s u v))
-> LinearMap s u v
-> Maybe (LinearMap s u v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> Tensor s (DualVector u) v -> Maybe (DualVector u ⊗ v)
(DualVector u ⊗ v) -> Maybe (DualVector u ⊗ v)
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector u)) =>
(DualVector u ⊗ w) -> Maybe (DualVector u ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor (Tensor s (DualVector u) v -> Maybe (DualVector u ⊗ v))
-> (Maybe (DualVector u ⊗ v) -> Maybe (LinearMap s u v))
-> Tensor s (DualVector u) v
-> Maybe (LinearMap s u v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> Coercion (Maybe (DualVector u ⊗ v)) (Maybe (LinearMap s u v))
-> Maybe (DualVector u ⊗ v) -> Maybe (LinearMap s u v)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (Coercion (DualVector u ⊗ v) (LinearMap s u v)
-> Coercion (Maybe (DualVector u ⊗ v)) (Maybe (LinearMap s u v))
forall a b.
(Object Coercion a, Object Coercion (Maybe a), Object Coercion b,
Object Coercion (Maybe b)) =>
Coercion a b -> Coercion (Maybe a) (Maybe b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (VSCCoercion s (DualVector u ⊗ v) (LinearMap s u v)
-> Coercion (DualVector u ⊗ v) (LinearMap s u v)
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion VSCCoercion s (Tensor s (DualVector u) v) (LinearMap s u v)
VSCCoercion s (DualVector u ⊗ v) (LinearMap s u v)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor))
wellDefinedTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) =>
(LinearMap s u v ⊗ w) -> Maybe (LinearMap s u v ⊗ w)
wellDefinedTensor
= VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> Tensor s (LinearMap s u v) w -> LinearMap s u (Tensor s v w)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c, Object (->) b,
Object (->) c) =>
VSCCoercion s b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap (Tensor s (LinearMap s u v) w -> LinearMap s u (Tensor s v w))
-> (LinearMap s u (Tensor s v w)
-> Maybe (Tensor s (LinearMap s u v) w))
-> Tensor s (LinearMap s u v) w
-> Maybe (Tensor s (LinearMap s u v) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearMap s u (Tensor s v w)
-> Maybe (LinearMap s u (Tensor s v w))
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector (LinearMap s u (Tensor s v w)
-> Maybe (LinearMap s u (Tensor s v w)))
-> (Maybe (LinearMap s u (Tensor s v w))
-> Maybe (Tensor s (LinearMap s u v) w))
-> LinearMap s u (Tensor s v w)
-> Maybe (Tensor s (LinearMap s u v) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> Coercion
(Maybe (LinearMap s u (Tensor s v w)))
(Maybe (Tensor s (LinearMap s u v) w))
-> Maybe (LinearMap s u (Tensor s v w))
-> Maybe (Tensor s (LinearMap s u v) w)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (Coercion
(LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> Coercion
(Maybe (LinearMap s u (Tensor s v w)))
(Maybe (Tensor s (LinearMap s u v) w))
forall a b.
(Object Coercion a, Object Coercion (Maybe a), Object Coercion b,
Object Coercion (Maybe b)) =>
Coercion a b -> Coercion (Maybe a) (Maybe b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> Coercion
(LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap))
coCurryLinearMap :: ∀ s u v w . ( LinearSpace u, Scalar u ~ s
, LinearSpace v, Scalar v ~ s
, TensorSpace w, Scalar w ~ s ) =>
VSCCoercion s (LinearMap s (LinearMap s u v) w) (Tensor s u (LinearMap s v w))
coCurryLinearMap :: forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (LinearMap s u v) w) (Tensor s u (LinearMap s v w))
coCurryLinearMap = case ( DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness)
-> VSCCoercion
s
(LinearMap s (LinearMap s u v) w)
(Tensor s (Tensor s u (DualVector v)) w)
VSCCoercion
s
(LinearMap s (LinearMap s u v) w)
(Tensor s (DualVector (LinearMap s u v)) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
s
(LinearMap s (LinearMap s u v) w)
(Tensor s (Tensor s u (DualVector v)) w)
-> VSCCoercion
s
(Tensor s (Tensor s u (DualVector v)) w)
(Tensor s u (LinearMap s v w))
-> VSCCoercion
s (LinearMap s (LinearMap s u v) w) (Tensor s u (LinearMap s v w))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion
s
(Tensor s (Tensor s u (DualVector v)) w)
(Tensor s u (Tensor s (DualVector v) w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor VSCCoercion
s
(Tensor s (Tensor s u (DualVector v)) w)
(Tensor s u (Tensor s (DualVector v) w))
-> VSCCoercion
s
(Tensor s u (Tensor s (DualVector v) w))
(Tensor s u (LinearMap s v w))
-> VSCCoercion
s
(Tensor s (Tensor s u (DualVector v)) w)
(Tensor s u (LinearMap s v w))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
-> VSCCoercion
s
(Tensor s u (Tensor s (DualVector v) w))
(Tensor s u (LinearMap s v w))
forall a b.
(Object (VSCCoercion s) a, Object (VSCCoercion s) (Tensor s u a),
Object (VSCCoercion s) b, Object (VSCCoercion s) (Tensor s u b)) =>
VSCCoercion s a b -> VSCCoercion s (Tensor s u a) (Tensor s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
VSCCoercion
s
(Tensor s (DualVector v) w)
(LinearMap s (DualVector (DualVector v)) w)
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap
coUncurryLinearMap :: ∀ s u v w . ( LinearSpace u, Scalar u ~ s
, LinearSpace v, Scalar v ~ s
, TensorSpace w, Scalar w ~ s ) =>
VSCCoercion s (Tensor s u (LinearMap s v w)) (LinearMap s (LinearMap s u v) w)
coUncurryLinearMap :: forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (Tensor s u (LinearMap s v w)) (LinearMap s (LinearMap s u v) w)
coUncurryLinearMap = case ( DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness)
-> VSCCoercion
s
(Tensor s (Tensor s u (DualVector v)) w)
(LinearMap s (LinearMap s u v) w)
VSCCoercion
s
(Tensor s (DualVector (LinearMap s u v)) w)
(LinearMap s (LinearMap s u v) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
s
(Tensor s (Tensor s u (DualVector v)) w)
(LinearMap s (LinearMap s u v) w)
-> VSCCoercion
s
(Tensor s u (LinearMap s v w))
(Tensor s (Tensor s u (DualVector v)) w)
-> VSCCoercion
s (Tensor s u (LinearMap s v w)) (LinearMap s (LinearMap s u v) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< VSCCoercion
s
(Tensor s u (Tensor s (DualVector v) w))
(Tensor s (Tensor s u (DualVector v)) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor VSCCoercion
s
(Tensor s u (Tensor s (DualVector v) w))
(Tensor s (Tensor s u (DualVector v)) w)
-> VSCCoercion
s
(Tensor s u (LinearMap s v w))
(Tensor s u (Tensor s (DualVector v) w))
-> VSCCoercion
s
(Tensor s u (LinearMap s v w))
(Tensor s (Tensor s u (DualVector v)) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
-> VSCCoercion
s
(Tensor s u (LinearMap s v w))
(Tensor s u (Tensor s (DualVector v) w))
forall a b.
(Object (VSCCoercion s) a, Object (VSCCoercion s) (Tensor s u a),
Object (VSCCoercion s) b, Object (VSCCoercion s) (Tensor s u b)) =>
VSCCoercion s a b -> VSCCoercion s (Tensor s u a) (Tensor s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
VSCCoercion
s
(LinearMap s (DualVector (DualVector v)) w)
(Tensor s (DualVector v) w)
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (LinearMap s (DualVector v) w) (Tensor s v w)
fromLinearMap
curryLinearMap :: ∀ u v w s . ( LinearSpace u, LinearSpace v, TensorSpace w
, Scalar u ~ s , Scalar v ~ s , Scalar w ~ s )
=> VSCCoercion s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap :: forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap = case (forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @u, forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @v) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness)
-> forall u v w s r.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
((ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
r)
-> r
tensorDimensionAssoc @u @(DualVector v) @w
(VSCCoercion
s
(LinearMap s (Tensor s u v) w)
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
VSCCoercion
s
(LinearMap
(Scalar (Tensor (Scalar u) u v)) (Tensor (Scalar u) u v) w)
(Tensor
(Scalar (DualVector u)) (DualVector u) (Tensor s (DualVector v) w))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion :: VSCCoercion s ((u⊗v)+>w)
((DualVector u)⊗(Tensor s (DualVector v) w)) )
VSCCoercion
s
(LinearMap s (Tensor s u v) w)
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
-> VSCCoercion
s
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
(LinearMap s u (LinearMap s v w))
-> VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
-> VSCCoercion
s
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
(Tensor s (DualVector u) (LinearMap s v w))
forall a b.
(Object (VSCCoercion s) a,
Object (VSCCoercion s) (Tensor s (DualVector u) a),
Object (VSCCoercion s) b,
Object (VSCCoercion s) (Tensor s (DualVector u) b)) =>
VSCCoercion s a b
-> VSCCoercion
s (Tensor s (DualVector u) a) (Tensor s (DualVector u) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
s
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
(Tensor s (DualVector u) (LinearMap s v w))
-> VSCCoercion
s
(Tensor s (DualVector u) (LinearMap s v w))
(LinearMap s u (LinearMap s v w))
-> VSCCoercion
s
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
(LinearMap s u (LinearMap s v w))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion
s
(Tensor s (DualVector u) (LinearMap s v w))
(LinearMap s u (LinearMap s v w))
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor
uncurryLinearMap :: ∀ u v w s . ( LinearSpace u, LinearSpace v, TensorSpace w
, Scalar u ~ s , Scalar v ~ s , Scalar w ~ s )
=> VSCCoercion s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMap :: forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMap = case (forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @u, forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @v) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness)
-> forall u v w s r.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
((ZipWithTimes
(ZipWithTimes (StaticDimension u) (StaticDimension v))
(StaticDimension w)
~ ZipWithTimes
(StaticDimension u)
(ZipWithTimes (StaticDimension v) (StaticDimension w))) =>
r)
-> r
tensorDimensionAssoc @u @(DualVector v) @w
(VSCCoercion
s
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
(LinearMap s (Tensor s u v) w)
VSCCoercion
s
(Tensor
(Scalar (DualVector u)) (DualVector u) (Tensor s (DualVector v) w))
(LinearMap
(Scalar (Tensor (Scalar u) u v)) (Tensor (Scalar u) u v) w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion :: VSCCoercion s
((DualVector u)⊗(Tensor s (DualVector v) w))
((u⊗v)+>w) )
VSCCoercion
s
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
(LinearMap s (Tensor s u v) w)
-> VSCCoercion
s
(LinearMap s u (LinearMap s v w))
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
-> VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
-> VSCCoercion
s
(Tensor s (DualVector u) (LinearMap s v w))
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
forall a b.
(Object (VSCCoercion s) a,
Object (VSCCoercion s) (Tensor s (DualVector u) a),
Object (VSCCoercion s) b,
Object (VSCCoercion s) (Tensor s (DualVector u) b)) =>
VSCCoercion s a b
-> VSCCoercion
s (Tensor s (DualVector u) a) (Tensor s (DualVector u) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
s
(Tensor s (DualVector u) (LinearMap s v w))
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
-> VSCCoercion
s
(LinearMap s u (LinearMap s v w))
(Tensor s (DualVector u) (LinearMap s v w))
-> VSCCoercion
s
(LinearMap s u (LinearMap s v w))
(Tensor s (DualVector u) (Tensor s (DualVector v) w))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< VSCCoercion
s
(LinearMap s u (LinearMap s v w))
(Tensor s (DualVector u) (LinearMap s v w))
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor
uncurryLinearFn :: ( Num' s, LSpace u, LSpace v, LSpace w
, Scalar u ~ s, Scalar v ~ s, Scalar w ~ s )
=> LinearFunction s u (LinearMap s v w) -+> LinearFunction s (Tensor s u v) w
uncurryLinearFn :: forall s u v w.
(Num' s, LSpace u, LSpace v, LSpace w, Scalar u ~ s, Scalar v ~ s,
Scalar w ~ s) =>
LinearFunction s u (LinearMap s v w)
-+> LinearFunction s (Tensor s u v) w
uncurryLinearFn = (LinearFunction s u (LinearMap s v w) -> Tensor s u v -> w)
-> LinearFunction
s
(LinearFunction s u (LinearMap s v w))
(LinearFunction s (Tensor s u v) w)
(LinearFunction s u (LinearMap s v w) -> Tensor s u v -> w)
-> Bilinear (LinearFunction s u (LinearMap s v w)) (Tensor s u v) w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction
((LinearFunction s u (LinearMap s v w) -> Tensor s u v -> w)
-> LinearFunction
s
(LinearFunction s u (LinearMap s v w))
(LinearFunction s (Tensor s u v) w))
-> (LinearFunction s u (LinearMap s v w) -> Tensor s u v -> w)
-> LinearFunction
s
(LinearFunction s u (LinearMap s v w))
(LinearFunction s (Tensor s u v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction s u (LinearMap s v w)
f Tensor s u v
t -> LinearFunction s (Tensor s v (LinearMap s v w)) w
(v ⊗ (v +> w)) -+> w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ (v +> w)) -+> w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ (v +> w)) -+> w
contractMapTensor LinearFunction s (Tensor s v (LinearMap s v w)) w
-> LinearFunction s (Tensor s u v) (Tensor s v (LinearMap s v w))
-> LinearFunction s (Tensor s u v) w
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s u (LinearMap s v w)
-> LinearFunction s (Tensor s v u) (Tensor s v (LinearMap s v w))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s v a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s v b)) =>
LinearFunction s a b
-> LinearFunction s (Tensor s v a) (Tensor s v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction s u (LinearMap s v w)
f LinearFunction s (Tensor s v u) (Tensor s v (LinearMap s v w))
-> LinearFunction s (Tensor s u v) (Tensor s v u)
-> LinearFunction s (Tensor s u v) (Tensor s v (LinearMap s v w))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s (Tensor s u v) (Tensor s v u)
(u ⊗ v) -+> (v ⊗ u)
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) -+> (w ⊗ u)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor LinearFunction s (Tensor s u v) w -> Tensor s u v -> w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor s u v
t
instance ∀ s u v . (LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s)
=> LinearSpace (LinearMap s u v) where
type DualVector (LinearMap s u v) = Tensor s u (DualVector v)
dualSpaceWitness :: DualSpaceWitness (LinearMap s u v)
dualSpaceWitness = case ( DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness) -> DualSpaceWitness (LinearMap s u v)
forall v.
(LinearSpace (Scalar v), DualVector (Scalar v) ~ Scalar v,
LinearSpace (DualVector v), Scalar (DualVector v) ~ Scalar v,
DualVector (DualVector v) ~ v,
StaticDimension (DualVector v) ~ StaticDimension v) =>
DualSpaceWitness v
DualSpaceWitness
linearId :: LinearMap s u v +> LinearMap s u v
linearId = case (forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @u, forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @v) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness)
-> VSCCoercion
s
(Tensor s (Tensor s u (DualVector v)) (LinearMap s u v))
(LinearMap s (LinearMap s u v) (LinearMap s u v))
VSCCoercion
s
(Tensor s (DualVector (LinearMap s u v)) (LinearMap s u v))
(LinearMap s (LinearMap s u v) (LinearMap s u v))
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
s
(Tensor s (Tensor s u (DualVector v)) (LinearMap s u v))
(LinearMap s (LinearMap s u v) (LinearMap s u v))
-> VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(Tensor s (Tensor s u (DualVector v)) (LinearMap s u v))
-> VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(LinearMap s (LinearMap s u v) (LinearMap s u v))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(Tensor s u (Tensor s (DualVector v) (LinearMap s u v)))
(Tensor s (Tensor s u (DualVector v)) (LinearMap s u v))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor VSCCoercion
s
(Tensor s u (Tensor s (DualVector v) (LinearMap s u v)))
(Tensor s (Tensor s u (DualVector v)) (LinearMap s u v))
-> VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(Tensor s u (Tensor s (DualVector v) (LinearMap s u v)))
-> VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(Tensor s (Tensor s u (DualVector v)) (LinearMap s u v))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearMap
s (DualVector u) (Tensor s (DualVector v) (LinearMap s u v)))
(Tensor s u (Tensor s (DualVector v) (LinearMap s u v)))
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (LinearMap s (DualVector v) w) (Tensor s v w)
fromLinearMap VSCCoercion
s
(LinearMap
s (DualVector u) (Tensor s (DualVector v) (LinearMap s u v)))
(Tensor s u (Tensor s (DualVector v) (LinearMap s u v)))
-> VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(LinearMap
s (DualVector u) (Tensor s (DualVector v) (LinearMap s u v)))
-> VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(Tensor s u (Tensor s (DualVector v) (LinearMap s u v)))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearMap s v (LinearMap s u v))
(Tensor s (DualVector v) (LinearMap s u v))
-> VSCCoercion
s
(LinearMap s (DualVector u) (LinearMap s v (LinearMap s u v)))
(LinearMap
s (DualVector u) (Tensor s (DualVector v) (LinearMap s u v)))
forall a b.
(Object (VSCCoercion s) a,
Object (VSCCoercion s) (LinearMap s (DualVector u) a),
Object (VSCCoercion s) b,
Object (VSCCoercion s) (LinearMap s (DualVector u) b)) =>
VSCCoercion s a b
-> VSCCoercion
s (LinearMap s (DualVector u) a) (LinearMap s (DualVector u) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion
s
(LinearMap s v (LinearMap s u v))
(Tensor s (DualVector v) (LinearMap s u v))
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor
VSCCoercion
s
(LinearMap s (DualVector u) (LinearMap s v (LinearMap s u v)))
(LinearMap
s (DualVector u) (Tensor s (DualVector v) (LinearMap s u v)))
-> VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(LinearMap s (DualVector u) (LinearMap s v (LinearMap s u v)))
-> VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(LinearMap
s (DualVector u) (Tensor s (DualVector v) (LinearMap s u v)))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearMap s (Tensor s (DualVector u) v) (LinearMap s u v))
(LinearMap s (DualVector u) (LinearMap s v (LinearMap s u v)))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap VSCCoercion
s
(LinearMap s (Tensor s (DualVector u) v) (LinearMap s u v))
(LinearMap s (DualVector u) (LinearMap s v (LinearMap s u v)))
-> VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(LinearMap s (Tensor s (DualVector u) v) (LinearMap s u v))
-> VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(LinearMap s (DualVector u) (LinearMap s v (LinearMap s u v)))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion s (Tensor s (DualVector u) v) (LinearMap s u v)
-> VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(LinearMap s (Tensor s (DualVector u) v) (LinearMap s u v))
forall a b.
(Object (VSCCoercion s) a,
Object (VSCCoercion s) (LinearMap s (Tensor s (DualVector u) v) a),
Object (VSCCoercion s) b,
Object
(VSCCoercion s) (LinearMap s (Tensor s (DualVector u) v) b)) =>
VSCCoercion s a b
-> VSCCoercion
s
(LinearMap s (Tensor s (DualVector u) v) a)
(LinearMap s (Tensor s (DualVector u) v) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion s (Tensor s (DualVector u) v) (LinearMap s u v)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
s
(LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v))
(LinearMap s (LinearMap s u v) (LinearMap s u v))
-> LinearMap
s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v)
-> LinearMap s (LinearMap s u v) (LinearMap s u v)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s (Tensor s (DualVector u) v) (Tensor s (DualVector u) v)
(DualVector u ⊗ v) +> (DualVector u ⊗ v)
forall w.
(LinearSpace w, Scalar w ~ Scalar (DualVector u)) =>
(DualVector u ⊗ w) +> (DualVector u ⊗ w)
forall v w.
(LinearSpace v, LinearSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) +> (v ⊗ w)
tensorId
tensorId :: forall w.
(LinearSpace w, Scalar w ~ Scalar (LinearMap s u v)) =>
(LinearMap s u v ⊗ w) +> (LinearMap s u v ⊗ w)
tensorId = VSCCoercion
s
(LinearMap
s (LinearMap s u v) (LinearMap s w (Tensor s (LinearMap s u v) w)))
(LinearMap
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) w))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMap VSCCoercion
s
(LinearMap
s (LinearMap s u v) (LinearMap s w (Tensor s (LinearMap s u v) w)))
(LinearMap
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) w))
-> VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w)))
(LinearMap
s (LinearMap s u v) (LinearMap s w (Tensor s (LinearMap s u v) w)))
-> VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w)))
(LinearMap
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) w))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(Tensor
s u (LinearMap s v (LinearMap s w (Tensor s (LinearMap s u v) w))))
(LinearMap
s (LinearMap s u v) (LinearMap s w (Tensor s (LinearMap s u v) w)))
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (Tensor s u (LinearMap s v w)) (LinearMap s (LinearMap s u v) w)
coUncurryLinearMap VSCCoercion
s
(Tensor
s u (LinearMap s v (LinearMap s w (Tensor s (LinearMap s u v) w))))
(LinearMap
s (LinearMap s u v) (LinearMap s w (Tensor s (LinearMap s u v) w)))
-> VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w)))
(Tensor
s u (LinearMap s v (LinearMap s w (Tensor s (LinearMap s u v) w))))
-> VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w)))
(LinearMap
s (LinearMap s u v) (LinearMap s w (Tensor s (LinearMap s u v) w)))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearMap s (Tensor s v w) (Tensor s (LinearMap s u v) w))
(LinearMap s v (LinearMap s w (Tensor s (LinearMap s u v) w)))
-> VSCCoercion
s
(Tensor
s u (LinearMap s (Tensor s v w) (Tensor s (LinearMap s u v) w)))
(Tensor
s u (LinearMap s v (LinearMap s w (Tensor s (LinearMap s u v) w))))
forall a b.
(Object (VSCCoercion s) a, Object (VSCCoercion s) (Tensor s u a),
Object (VSCCoercion s) b, Object (VSCCoercion s) (Tensor s u b)) =>
VSCCoercion s a b -> VSCCoercion s (Tensor s u a) (Tensor s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion
s
(LinearMap s (Tensor s v w) (Tensor s (LinearMap s u v) w))
(LinearMap s v (LinearMap s w (Tensor s (LinearMap s u v) w)))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap
VSCCoercion
s
(Tensor
s u (LinearMap s (Tensor s v w) (Tensor s (LinearMap s u v) w)))
(Tensor
s u (LinearMap s v (LinearMap s w (Tensor s (LinearMap s u v) w))))
-> VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w)))
(Tensor
s u (LinearMap s (Tensor s v w) (Tensor s (LinearMap s u v) w)))
-> VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w)))
(Tensor
s u (LinearMap s v (LinearMap s w (Tensor s (LinearMap s u v) w))))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w))
(Tensor
s u (LinearMap s (Tensor s v w) (Tensor s (LinearMap s u v) w)))
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (LinearMap s u v) w) (Tensor s u (LinearMap s v w))
coCurryLinearMap VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w))
(Tensor
s u (LinearMap s (Tensor s v w) (Tensor s (LinearMap s u v) w)))
-> VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w)))
(LinearMap
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w))
-> VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w)))
(Tensor
s u (LinearMap s (Tensor s v w) (Tensor s (LinearMap s u v) w)))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w)))
(LinearMap
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w))
forall a b.
(Object (VSCCoercion s) a,
Object
(VSCCoercion s) (LinearMap s (LinearMap s u (Tensor s v w)) a),
Object (VSCCoercion s) b,
Object
(VSCCoercion s) (LinearMap s (LinearMap s u (Tensor s v w)) b)) =>
VSCCoercion s a b
-> VSCCoercion
s
(LinearMap s (LinearMap s u (Tensor s v w)) a)
(LinearMap s (LinearMap s u (Tensor s v w)) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap VSCCoercion
s
(LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w)))
(LinearMap
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) w))
-> LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w))
-> LinearMap
s (Tensor s (LinearMap s u v) w) (Tensor s (LinearMap s u v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap
s (LinearMap s u (Tensor s v w)) (LinearMap s u (Tensor s v w))
forall a. Object (LinearMap s) a => LinearMap s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id
coerceDoubleDual :: VSCCoercion
(Scalar (LinearMap s u v))
(LinearMap s u v)
(DualVector (DualVector (LinearMap s u v)))
coerceDoubleDual = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> VSCCoercion s (LinearMap s u v) (LinearMap s u v)
VSCCoercion
(Scalar (LinearMap s u v))
(LinearMap s u v)
(DualVector (DualVector (LinearMap s u v)))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
applyLinear :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) =>
Bilinear (LinearMap s u v +> w) (LinearMap s u v) w
applyLinear = case DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u of
DualSpaceWitness u
DualSpaceWitness -> (LinearMap s (LinearMap s u v) w -> LinearMap s u v -> w)
-> LinearFunction
s
(LinearMap s (LinearMap s u v) w)
(LinearFunction s (LinearMap s u v) w)
(LinearMap s (LinearMap s u v) w -> LinearMap s u v -> w)
-> Bilinear (LinearMap s (LinearMap s u v) w) (LinearMap s u v) w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s (LinearMap s u v) w -> LinearMap s u v -> w)
-> LinearFunction
s
(LinearMap s (LinearMap s u v) w)
(LinearFunction s (LinearMap s u v) w))
-> (LinearMap s (LinearMap s u v) w -> LinearMap s u v -> w)
-> LinearFunction
s
(LinearMap s (LinearMap s u v) w)
(LinearFunction s (LinearMap s u v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearMap s (LinearMap s u v) w
f LinearMap s u v
g
-> let tf :: LinearMap s (Tensor s (DualVector u) v) w
tf = VSCCoercion
s
(LinearMap s (LinearMap s u v) w)
(LinearMap s (Tensor s (DualVector u) v) w)
forall s v w x.
(LinearSpace v, LinearSpace w, Scalar v ~ s, Scalar w ~ s,
TensorSpace x, Scalar x ~ s) =>
VSCCoercion
s
(LinearMap s (LinearMap s v w) x)
(LinearMap s (Tensor s (DualVector v) w) x)
argAsTensor VSCCoercion
s
(LinearMap s (LinearMap s u v) w)
(LinearMap s (Tensor s (DualVector u) v) w)
-> LinearMap s (LinearMap s u v) w
-> LinearMap s (Tensor s (DualVector u) v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s (LinearMap s u v) w
f
in (LinearFunction
s
(LinearMap s (Tensor s (DualVector u) v) w)
(LinearFunction s (Tensor s (DualVector u) v) w)
Bilinear ((DualVector u ⊗ v) +> w) (DualVector u ⊗ v) w
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (DualVector u),
Scalar w ~ Scalar (DualVector u)) =>
Bilinear ((DualVector u ⊗ u) +> w) (DualVector u ⊗ u) w
applyTensorLinMapLinearFunction
s
(LinearMap s (Tensor s (DualVector u) v) w)
(LinearFunction s (Tensor s (DualVector u) v) w)
-> LinearMap s (Tensor s (DualVector u) v) w
-> LinearFunction s (Tensor s (DualVector u) v) w
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap s (Tensor s (DualVector u) v) w
tf)LinearFunction s (Tensor s (DualVector u) v) w
-> Tensor s (DualVector u) v -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>VSCCoercion s (LinearMap s u v) (Tensor s (DualVector u) v)
VSCCoercion
s
(LinearMap s (DualVector (DualVector u)) v)
(Tensor s (DualVector u) v)
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (LinearMap s (DualVector v) w) (Tensor s v w)
fromLinearMap VSCCoercion s (LinearMap s u v) (Tensor s (DualVector u) v)
-> LinearMap s u v -> Tensor s (DualVector u) v
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s u v
g
applyDualVector :: LinearSpace (LinearMap s u v) =>
Bilinear
(DualVector (LinearMap s u v))
(LinearMap s u v)
(Scalar (LinearMap s u v))
applyDualVector = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> Bilinear (LinearMap s u v) (Tensor s u (DualVector v)) s
-> Bilinear (Tensor s u (DualVector v)) (LinearMap s u v) s
forall v w y. Bilinear v w y -> Bilinear w v y
flipBilin Bilinear (LinearMap s u v) (Tensor s u (DualVector v)) s
Bilinear
(DualVector (u ⊗ DualVector v)) (u ⊗ DualVector v) (Scalar u)
forall u.
(LinearSpace u, Scalar u ~ Scalar u) =>
Bilinear (DualVector (u ⊗ u)) (u ⊗ u) (Scalar u)
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctional
applyTensorFunctional :: forall u.
(LinearSpace u, Scalar u ~ Scalar (LinearMap s u v)) =>
Bilinear
(DualVector (LinearMap s u v ⊗ u))
(LinearMap s u v ⊗ u)
(Scalar (LinearMap s u v))
applyTensorFunctional = ScalarSpaceWitness u
-> DualSpaceWitness u
-> DualSpaceWitness u
-> Bilinear ((u +> v) +> DualVector u) ((u +> v) ⊗ u) s
forall w.
(LinearSpace w, Scalar w ~ s) =>
ScalarSpaceWitness u
-> DualSpaceWitness u
-> DualSpaceWitness w
-> Bilinear ((u +> v) +> DualVector w) ((u +> v) ⊗ w) s
atf ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness
where atf :: ∀ w . (LinearSpace w, Scalar w ~ s)
=> ScalarSpaceWitness u -> DualSpaceWitness u -> DualSpaceWitness w
-> Bilinear ((u+>v)+>DualVector w) ((u+>v)⊗w) s
atf :: forall w.
(LinearSpace w, Scalar w ~ s) =>
ScalarSpaceWitness u
-> DualSpaceWitness u
-> DualSpaceWitness w
-> Bilinear ((u +> v) +> DualVector w) ((u +> v) ⊗ w) s
atf ScalarSpaceWitness u
ScalarSpaceWitness DualSpaceWitness u
DualSpaceWitness DualSpaceWitness w
DualSpaceWitness
= VSCCoercion
s
(LinearMap s (LinearMap s u v) (DualVector w))
(LinearMap s (DualVector u) (LinearMap s v (DualVector w)))
-> LinearFunction
s
(LinearMap s (LinearMap s u v) (DualVector w))
(LinearMap s (DualVector u) (LinearMap s v (DualVector w)))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (VSCCoercion
s
(LinearMap s (LinearMap s u v) (DualVector w))
(Tensor s u (LinearMap s v (DualVector w)))
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (LinearMap s u v) w) (Tensor s u (LinearMap s v w))
coCurryLinearMap VSCCoercion
s
(LinearMap s (LinearMap s u v) (DualVector w))
(Tensor s u (LinearMap s v (DualVector w)))
-> VSCCoercion
s
(Tensor s u (LinearMap s v (DualVector w)))
(LinearMap s (DualVector u) (LinearMap s v (DualVector w)))
-> VSCCoercion
s
(LinearMap s (LinearMap s u v) (DualVector w))
(LinearMap s (DualVector u) (LinearMap s v (DualVector w)))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion
s
(Tensor s u (LinearMap s v (DualVector w)))
(LinearMap s (DualVector u) (LinearMap s v (DualVector w)))
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (Tensor s v w) (LinearMap s (DualVector v) w)
asLinearMap)
LinearFunction
s
(LinearMap s (LinearMap s u v) (DualVector w))
(LinearMap s (DualVector u) (LinearMap s v (DualVector w)))
-> LinearFunction
s
(LinearMap s (DualVector u) (LinearMap s v (DualVector w)))
(LinearFunction s (Tensor s (LinearMap s u v) w) s)
-> LinearFunction
s
(LinearMap s (LinearMap s u v) (DualVector w))
(LinearFunction s (Tensor s (LinearMap s u v) w) s)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
s
(LinearMap s (DualVector u) (LinearMap s v (DualVector w)))
(LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s)
Bilinear
(DualVector (DualVector u ⊗ Tensor s v w))
(DualVector u ⊗ Tensor s v w)
(Scalar (DualVector u))
forall u.
(LinearSpace u, Scalar u ~ Scalar (DualVector u)) =>
Bilinear
(DualVector (DualVector u ⊗ u))
(DualVector u ⊗ u)
(Scalar (DualVector u))
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctional LinearFunction
s
(LinearMap s (DualVector u) (LinearMap s v (DualVector w)))
(LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s)
-> LinearFunction
s
(LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s)
(LinearFunction s (Tensor s (LinearMap s u v) w) s)
-> LinearFunction
s
(LinearMap s (DualVector u) (LinearMap s v (DualVector w)))
(LinearFunction s (Tensor s (LinearMap s u v) w) s)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> (LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s
-> Tensor s (LinearMap s u v) w -> s)
-> LinearFunction
s
(LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s)
(LinearFunction s (Tensor s (LinearMap s u v) w) s)
(LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s
-> Tensor s (LinearMap s u v) w -> s)
-> Bilinear
(LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s)
(Tensor s (LinearMap s u v) w)
s
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction((LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s
-> Tensor s (LinearMap s u v) w -> s)
-> LinearFunction
s
(LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s)
(LinearFunction s (Tensor s (LinearMap s u v) w) s))
-> (LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s
-> Tensor s (LinearMap s u v) w -> s)
-> LinearFunction
s
(LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s)
(LinearFunction s (Tensor s (LinearMap s u v) w) s)
forall a. Object (->) a => a -> a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
`id`\LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s
f Tensor s (LinearMap s u v) w
t
-> LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s
f LinearFunction s (Tensor s (DualVector u) (Tensor s v w)) s
-> LinearFunction
s
(Tensor s (LinearMap s u v) w)
(Tensor s (DualVector u) (Tensor s v w))
-> LinearFunction s (Tensor s (LinearMap s u v) w) s
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(Tensor s (LinearMap s u v) w)
(Tensor s (DualVector u) (Tensor s v w))
-> LinearFunction
s
(Tensor s (LinearMap s u v) w)
(Tensor s (DualVector u) (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (VSCCoercion
s
(LinearMap s u (Tensor s v w))
(Tensor s (DualVector u) (Tensor s v w))
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
s
(LinearMap s u (Tensor s v w))
(Tensor s (DualVector u) (Tensor s v w))
-> VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
-> VSCCoercion
s
(Tensor s (LinearMap s u v) w)
(Tensor s (DualVector u) (Tensor s v w))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap) LinearFunction s (Tensor s (LinearMap s u v) w) s
-> Tensor s (LinearMap s u v) w -> s
forall s v w. LinearFunction s v w -> v -> w
-+$> Tensor s (LinearMap s u v) w
t
applyTensorLinMap :: forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (LinearMap s u v),
Scalar w ~ Scalar (LinearMap s u v)) =>
Bilinear ((LinearMap s u v ⊗ u) +> w) (LinearMap s u v ⊗ u) w
applyTensorLinMap = case DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u of
DualSpaceWitness u
DualSpaceWitness -> (LinearMap s (Tensor s (LinearMap s u v) u) w
-> LinearFunction s (Tensor s (LinearMap s u v) u) w)
-> LinearFunction
s
(LinearMap s (Tensor s (LinearMap s u v) u) w)
(LinearFunction s (Tensor s (LinearMap s u v) u) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearMap s (Tensor s (LinearMap s u v) u) w
-> LinearFunction s (Tensor s (LinearMap s u v) u) w)
-> LinearFunction
s
(LinearMap s (Tensor s (LinearMap s u v) u) w)
(LinearFunction s (Tensor s (LinearMap s u v) u) w))
-> (LinearMap s (Tensor s (LinearMap s u v) u) w
-> LinearFunction s (Tensor s (LinearMap s u v) u) w)
-> LinearFunction
s
(LinearMap s (Tensor s (LinearMap s u v) u) w)
(LinearFunction s (Tensor s (LinearMap s u v) u) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
VSCCoercion
s
(LinearMap s (Tensor s (LinearMap s u v) u) w)
(LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w)
-> LinearMap s (Tensor s (LinearMap s u v) u) w
-> LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c, Object (->) b,
Object (->) c) =>
VSCCoercion s b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (VSCCoercion
s
(LinearMap s (Tensor s (LinearMap s u v) u) w)
(LinearMap s (LinearMap s u v) (LinearMap s u w))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMapVSCCoercion
s
(LinearMap s (Tensor s (LinearMap s u v) u) w)
(LinearMap s (LinearMap s u v) (LinearMap s u w))
-> VSCCoercion
s
(LinearMap s (LinearMap s u v) (LinearMap s u w))
(LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w)
-> VSCCoercion
s
(LinearMap s (Tensor s (LinearMap s u v) u) w)
(LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>>VSCCoercion
s
(LinearMap s (LinearMap s u v) (LinearMap s u w))
(Tensor s u (LinearMap s v (LinearMap s u w)))
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (LinearMap s u v) w) (Tensor s u (LinearMap s v w))
coCurryLinearMap
VSCCoercion
s
(LinearMap s (LinearMap s u v) (LinearMap s u w))
(Tensor s u (LinearMap s v (LinearMap s u w)))
-> VSCCoercion
s
(Tensor s u (LinearMap s v (LinearMap s u w)))
(LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w)
-> VSCCoercion
s
(LinearMap s (LinearMap s u v) (LinearMap s u w))
(LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>>VSCCoercion
s (LinearMap s v (LinearMap s u w)) (LinearMap s (Tensor s v u) w)
-> VSCCoercion
s
(Tensor s u (LinearMap s v (LinearMap s u w)))
(Tensor s u (LinearMap s (Tensor s v u) w))
forall a b.
(Object (VSCCoercion s) a, Object (VSCCoercion s) (Tensor s u a),
Object (VSCCoercion s) b, Object (VSCCoercion s) (Tensor s u b)) =>
VSCCoercion s a b -> VSCCoercion s (Tensor s u a) (Tensor s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion
s (LinearMap s v (LinearMap s u w)) (LinearMap s (Tensor s v u) w)
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMapVSCCoercion
s
(Tensor s u (LinearMap s v (LinearMap s u w)))
(Tensor s u (LinearMap s (Tensor s v u) w))
-> VSCCoercion
s
(Tensor s u (LinearMap s (Tensor s v u) w))
(LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w)
-> VSCCoercion
s
(Tensor s u (LinearMap s v (LinearMap s u w)))
(LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>>VSCCoercion
s
(Tensor s u (LinearMap s (Tensor s v u) w))
(LinearMap s (LinearMap s u (Tensor s v u)) w)
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (Tensor s u (LinearMap s v w)) (LinearMap s (LinearMap s u v) w)
coUncurryLinearMapVSCCoercion
s
(Tensor s u (LinearMap s (Tensor s v u) w))
(LinearMap s (LinearMap s u (Tensor s v u)) w)
-> VSCCoercion
s
(LinearMap s (LinearMap s u (Tensor s v u)) w)
(LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w)
-> VSCCoercion
s
(Tensor s u (LinearMap s (Tensor s v u) w))
(LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>>VSCCoercion
s
(LinearMap s (LinearMap s u (Tensor s v u)) w)
(LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w)
forall s v w x.
(LinearSpace v, LinearSpace w, Scalar v ~ s, Scalar w ~ s,
TensorSpace x, Scalar x ~ s) =>
VSCCoercion
s
(LinearMap s (LinearMap s v w) x)
(LinearMap s (Tensor s (DualVector v) w) x)
argAsTensor)
(LinearMap s (Tensor s (LinearMap s u v) u) w
-> LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w)
-> (LinearMap s (Tensor s (DualVector u) (Tensor s v u)) w
-> LinearFunction s (Tensor s (LinearMap s u v) u) w)
-> LinearMap s (Tensor s (LinearMap s u v) u) w
-> LinearFunction s (Tensor s (LinearMap s u v) u) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> \LinearMap
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
w
f -> (Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u
-> w)
-> LinearFunction
s
(Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u)
w
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u
-> w)
-> LinearFunction
s
(Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u)
w)
-> (Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u
-> w)
-> LinearFunction
s
(Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u)
w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u
g
-> (Bilinear
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u)
+> w)
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
w
LinearFunction
(Scalar (DualVector u))
(LinearMap
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
w)
(LinearFunction
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
w)
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (DualVector u),
Scalar w ~ Scalar (DualVector u)) =>
Bilinear ((DualVector u ⊗ u) +> w) (DualVector u ⊗ u) w
applyTensorLinMapLinearFunction
(Scalar (DualVector u))
(LinearMap
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
w)
(LinearFunction
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
w)
-> LinearMap
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
w
-> LinearFunction
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
w
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
w
f)
LinearFunction
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
w
-> LinearFunction
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u)
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
-> LinearFunction
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u)
w
forall a b c.
(Object (LinearFunction (Scalar (DualVector u))) a,
Object (LinearFunction (Scalar (DualVector u))) b,
Object (LinearFunction (Scalar (DualVector u))) c) =>
LinearFunction (Scalar (DualVector u)) b c
-> LinearFunction (Scalar (DualVector u)) a b
-> LinearFunction (Scalar (DualVector u)) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u)
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
-> LinearFunction
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u)
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
forall b c.
(Object (VSCCoercion (Scalar (DualVector u))) b,
Object (VSCCoercion (Scalar (DualVector u))) c,
Object (LinearFunction (Scalar (DualVector u))) b,
Object (LinearFunction (Scalar (DualVector u))) c) =>
VSCCoercion (Scalar (DualVector u)) b c
-> LinearFunction (Scalar (DualVector u)) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (VSCCoercion
(Scalar (DualVector u))
(LinearMap
(Scalar (DualVector u)) u (Tensor (Scalar (DualVector u)) v u))
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
(Scalar (DualVector u))
(LinearMap
(Scalar (DualVector u)) u (Tensor (Scalar (DualVector u)) v u))
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
-> VSCCoercion
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u)
(LinearMap
(Scalar (DualVector u)) u (Tensor (Scalar (DualVector u)) v u))
-> VSCCoercion
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u)
(Tensor
(Scalar (DualVector u))
(DualVector u)
(Tensor (Scalar (DualVector u)) v u))
forall a b c.
(Object (VSCCoercion (Scalar (DualVector u))) a,
Object (VSCCoercion (Scalar (DualVector u))) b,
Object (VSCCoercion (Scalar (DualVector u))) c) =>
VSCCoercion (Scalar (DualVector u)) b c
-> VSCCoercion (Scalar (DualVector u)) a b
-> VSCCoercion (Scalar (DualVector u)) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u)
(LinearMap
(Scalar (DualVector u)) u (Tensor (Scalar (DualVector u)) v u))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap) LinearFunction
(Scalar (DualVector u))
(Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u)
w
-> Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u
-> w
forall s v w. LinearFunction s v w -> v -> w
-+$> Tensor
(Scalar (DualVector u)) (LinearMap (Scalar (DualVector u)) u v) u
g
useTupleLinearSpaceComponents :: forall x y φ.
(LinearMap s u v ~ (x, y)) =>
((LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ) -> φ
useTupleLinearSpaceComponents (LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ
_ = φ
forall a. a
usingNonTupleTypeAsTupleError
instance ∀ s u v . (TensorSpace u, TensorSpace v, Scalar u ~ s, Scalar v ~ s)
=> DimensionAware (Tensor s u v) where
type StaticDimension (Tensor s u v)
= Maybe.ZipWithTimes (StaticDimension u) (StaticDimension v)
dimensionalityWitness :: DimensionalityWitness (Tensor s u v)
dimensionalityWitness = case (forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @u, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v) of
(DimensionalityWitness u
IsStaticDimensional, DimensionalityWitness v
IsStaticDimensional)
-> SNat (n * n)
-> (KnownNat (n * n) => DimensionalityWitness (Tensor s u v))
-> DimensionalityWitness (Tensor s u v)
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @u Sing n -> Sing n -> Sing (Apply (Apply (*@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%* forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @v)
DimensionalityWitness (Tensor s u v)
KnownNat (n * n) => DimensionalityWitness (Tensor s u v)
forall (n :: Nat) v. Dimensional n v => DimensionalityWitness v
IsStaticDimensional
(DimensionalityWitness u
IsFlexibleDimensional, DimensionalityWitness v
_) -> DimensionalityWitness (Tensor s u v)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
(DimensionalityWitness u
_, DimensionalityWitness v
IsFlexibleDimensional) -> DimensionalityWitness (Tensor s u v)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
instance ∀ s n u m v nm . ( n`Dimensional`u, m`Dimensional`v
, TensorSpace u, TensorSpace v, Scalar u ~ s, Scalar v ~ s
, nm ~ (n*m) )
=> nm`Dimensional`(Tensor s u v) where
knownDimensionalitySing :: Sing nm
knownDimensionalitySing = forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @u Sing n -> Sing m -> Sing (Apply (Apply (*@#@$) n) m)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%* forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @v
unsafeFromArrayWithOffset :: forall (α :: Type -> Type).
Vector α (Scalar (Tensor s u v)) =>
Int -> α (Scalar (Tensor s u v)) -> Tensor s u v
unsafeFromArrayWithOffset = Int -> α (Scalar u) -> u ⊗ v
Int -> α (Scalar (Tensor s u v)) -> Tensor s u v
forall v w (α :: Type -> Type) (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v ⊗ w
forall w (α :: Type -> Type) (n :: Nat) (m :: Nat).
(Dimensional n u, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar u, Vector α (Scalar u)) =>
Int -> α (Scalar u) -> u ⊗ w
tensorUnsafeFromArrayWithOffset
unsafeWriteArrayWithOffset :: forall (α :: Type -> Type) σ.
Vector α (Scalar (Tensor s u v)) =>
Mutable α σ (Scalar (Tensor s u v))
-> Int -> Tensor s u v -> ST σ ()
unsafeWriteArrayWithOffset = Mutable α σ (Scalar u) -> Int -> (u ⊗ v) -> ST σ ()
Mutable α σ (Scalar (Tensor s u v))
-> Int -> Tensor s u v -> ST σ ()
forall v w (α :: Type -> Type) σ (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> (v ⊗ w) -> ST σ ()
forall w (α :: Type -> Type) σ (n :: Nat) (m :: Nat).
(Dimensional n u, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar u, Vector α (Scalar u)) =>
Mutable α σ (Scalar u) -> Int -> (u ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset
instance ∀ s u v . (TensorSpace u, TensorSpace v, Scalar u ~ s, Scalar v ~ s)
=> TensorSpace (Tensor s u v) where
type TensorProduct (Tensor s u v) w = TensorProduct u (Tensor s v w)
scalarSpaceWitness :: ScalarSpaceWitness (Tensor s u v)
scalarSpaceWitness = case ( ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u
, ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v ) of
(ScalarSpaceWitness u
ScalarSpaceWitness, ScalarSpaceWitness v
ScalarSpaceWitness) -> ScalarSpaceWitness (Tensor s u v)
forall v.
(Num' (Scalar v), Scalar (Scalar v) ~ Scalar v) =>
ScalarSpaceWitness v
ScalarSpaceWitness
linearManifoldWitness :: LinearManifoldWitness (Tensor s u v)
linearManifoldWitness = case ( LinearManifoldWitness u
forall v. TensorSpace v => LinearManifoldWitness v
linearManifoldWitness :: LinearManifoldWitness u
, LinearManifoldWitness v
forall v. TensorSpace v => LinearManifoldWitness v
linearManifoldWitness :: LinearManifoldWitness v ) of
( LinearManifoldWitness u
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
,LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
)
-> LinearManifoldWitness (Tensor s u v)
forall v.
(Needle v ~ v, AffineSpace v, Diff v ~ v) =>
LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
zeroTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) =>
Tensor s u v ⊗ w
zeroTensor = VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> Tensor s u (Tensor s v w) -> Tensor s (Tensor s u v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor s u (Tensor s v w)
u ⊗ Tensor s v w
forall w. (TensorSpace w, Scalar w ~ Scalar u) => u ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor
toFlatTensor :: Tensor s u v -+> (Tensor s u v ⊗ Scalar (Tensor s u v))
toFlatTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> VSCCoercion
s (Tensor s u (Tensor s v s)) (Tensor s (Tensor s u v) s)
-> LinearFunction
s (Tensor s u (Tensor s v s)) (Tensor s (Tensor s u v) s)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s u (Tensor s v s)) (Tensor s (Tensor s u v) s)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor LinearFunction
s (Tensor s u (Tensor s v s)) (Tensor s (Tensor s u v) s)
-> LinearFunction s (Tensor s u v) (Tensor s u (Tensor s v s))
-> LinearFunction s (Tensor s u v) (Tensor s (Tensor s u v) s)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s v (Tensor s v s)
-> LinearFunction s (Tensor s u v) (Tensor s u (Tensor s v s))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s u b)) =>
LinearFunction s a b
-> LinearFunction s (Tensor s u a) (Tensor s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction s v (Tensor s v s)
v -+> (v ⊗ Scalar v)
forall v. TensorSpace v => v -+> (v ⊗ Scalar v)
toFlatTensor
fromFlatTensor :: (Tensor s u v ⊗ Scalar (Tensor s u v)) -+> Tensor s u v
fromFlatTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> LinearFunction s (Tensor s v s) v
-> LinearFunction s (Tensor s u (Tensor s v s)) (Tensor s u v)
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s u b)) =>
LinearFunction s a b
-> LinearFunction s (Tensor s u a) (Tensor s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction s (Tensor s v s) v
(v ⊗ Scalar v) -+> v
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor LinearFunction s (Tensor s u (Tensor s v s)) (Tensor s u v)
-> LinearFunction
s (Tensor s (Tensor s u v) s) (Tensor s u (Tensor s v s))
-> LinearFunction s (Tensor s (Tensor s u v) s) (Tensor s u v)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (Tensor s u v) s) (Tensor s u (Tensor s v s))
-> LinearFunction
s (Tensor s (Tensor s u v) s) (Tensor s u (Tensor s v s))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (Tensor s u v) s) (Tensor s u (Tensor s v s))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
addTensors :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) =>
(Tensor s u v ⊗ w) -> (Tensor s u v ⊗ w) -> Tensor s u v ⊗ w
addTensors Tensor s u v ⊗ w
t₁ Tensor s u v ⊗ w
t₂ = VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> Tensor s u (Tensor s v w) -> Tensor s (Tensor s u v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensorVSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> Tensor s (Tensor s u v) w -> Tensor s u (Tensor s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$Tensor s (Tensor s u v) w
Tensor s u v ⊗ w
t₁) Tensor s u (Tensor s v w)
-> Tensor s u (Tensor s v w) -> Tensor s u (Tensor s v w)
forall v. AdditiveGroup v => v -> v -> v
^+^ (VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensorVSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> Tensor s (Tensor s u v) w -> Tensor s u (Tensor s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$Tensor s (Tensor s u v) w
Tensor s u v ⊗ w
t₂)
subtractTensors :: forall w.
(TensorSpace (Tensor s u v), TensorSpace w,
Scalar w ~ Scalar (Tensor s u v)) =>
(Tensor s u v ⊗ w) -> (Tensor s u v ⊗ w) -> Tensor s u v ⊗ w
subtractTensors Tensor s u v ⊗ w
t₁ Tensor s u v ⊗ w
t₂ = VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> Tensor s u (Tensor s v w) -> Tensor s (Tensor s u v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensorVSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> Tensor s (Tensor s u v) w -> Tensor s u (Tensor s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$Tensor s (Tensor s u v) w
Tensor s u v ⊗ w
t₁) Tensor s u (Tensor s v w)
-> Tensor s u (Tensor s v w) -> Tensor s u (Tensor s v w)
forall v. AdditiveGroup v => v -> v -> v
^-^ (VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensorVSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> Tensor s (Tensor s u v) w -> Tensor s u (Tensor s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$Tensor s (Tensor s u v) w
Tensor s u v ⊗ w
t₂)
scaleTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) =>
Bilinear
(Scalar (Tensor s u v)) (Tensor s u v ⊗ w) (Tensor s u v ⊗ w)
scaleTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness ->
(s
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w))
-> LinearFunction
s
s
(LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((s
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w))
-> LinearFunction
s
s
(LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w)))
-> (s
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w))
-> LinearFunction
s
s
(LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \s
μ -> VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. s
-> LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w))
forall v s.
(VectorSpace v, Scalar v ~ s) =>
s -> LinearFunction s v v
scaleWith s
μ LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
negateTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) =>
(Tensor s u v ⊗ w) -+> (Tensor s u v ⊗ w)
negateTensor = VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w))
forall w s. AdditiveGroup w => LinearFunction s w w
lNegateV LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
tensorProduct :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) =>
Bilinear (Tensor s u v) w (Tensor s u v ⊗ w)
tensorProduct = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> LinearFunction
s w (LinearFunction s (Tensor s u v) (Tensor s (Tensor s u v) w))
-> LinearFunction
s (Tensor s u v) (LinearFunction s w (Tensor s (Tensor s u v) w))
Bilinear w (Tensor s u v) (Tensor s (Tensor s u v) w)
-> Bilinear (Tensor s u v) w (Tensor s (Tensor s u v) w)
forall v w y. Bilinear v w y -> Bilinear w v y
flipBilin (LinearFunction
s w (LinearFunction s (Tensor s u v) (Tensor s (Tensor s u v) w))
-> LinearFunction
s (Tensor s u v) (LinearFunction s w (Tensor s (Tensor s u v) w)))
-> LinearFunction
s w (LinearFunction s (Tensor s u v) (Tensor s (Tensor s u v) w))
-> LinearFunction
s (Tensor s u v) (LinearFunction s w (Tensor s (Tensor s u v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (w -> LinearFunction s (Tensor s u v) (Tensor s (Tensor s u v) w))
-> LinearFunction
s w (LinearFunction s (Tensor s u v) (Tensor s (Tensor s u v) w))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((w -> LinearFunction s (Tensor s u v) (Tensor s (Tensor s u v) w))
-> LinearFunction
s w (LinearFunction s (Tensor s u v) (Tensor s (Tensor s u v) w)))
-> (w
-> LinearFunction s (Tensor s u v) (Tensor s (Tensor s u v) w))
-> LinearFunction
s w (LinearFunction s (Tensor s u v) (Tensor s (Tensor s u v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \w
w
-> VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> LinearFunction s (Tensor s u v) (Tensor s u (Tensor s v w))
-> LinearFunction s (Tensor s u v) (Tensor s (Tensor s u v) w)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s v (Tensor s v w)
-> LinearFunction s (Tensor s u v) (Tensor s u (Tensor s v w))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s u b)) =>
LinearFunction s a b
-> LinearFunction s (Tensor s u a) (Tensor s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (Bilinear v w (Tensor s v w) -> Bilinear w v (Tensor s v w)
forall v w y. Bilinear v w y -> Bilinear w v y
flipBilin Bilinear v w (Tensor s v w)
Bilinear v w (v ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductLinearFunction s w (LinearFunction s v (Tensor s v w))
-> w -> LinearFunction s v (Tensor s v w)
forall s v w. LinearFunction s v w -> v -> w
-+$>w
w)
transposeTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) =>
(Tensor s u v ⊗ w) -+> (w ⊗ Tensor s u v)
transposeTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> LinearFunction (Scalar v) (Tensor s v u) (Tensor s u v)
-> LinearFunction
s (Tensor s w (Tensor s v u)) (Tensor s w (Tensor s u v))
forall a b.
(Object (LinearFunction (Scalar v)) a,
Object (LinearFunction s) (Tensor s w a),
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction s) (Tensor s w b)) =>
LinearFunction (Scalar v) a b
-> LinearFunction s (Tensor s w a) (Tensor s w b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction (Scalar v) (Tensor s v u) (Tensor s u v)
(v ⊗ u) -+> (u ⊗ v)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor LinearFunction
s (Tensor s w (Tensor s v u)) (Tensor s w (Tensor s u v))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s w (Tensor s v u))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s w (Tensor s u v))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (Tensor s w v) u) (Tensor s w (Tensor s v u))
-> LinearFunction
s (Tensor s (Tensor s w v) u) (Tensor s w (Tensor s v u))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (Tensor s w v) u) (Tensor s w (Tensor s v u))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
LinearFunction
s (Tensor s (Tensor s w v) u) (Tensor s w (Tensor s v u))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s w v) u)
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s w (Tensor s v u))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
s (Tensor s u (Tensor s w v)) (Tensor s (Tensor s w v) u)
(u ⊗ Tensor s w v) -+> (Tensor s w v ⊗ u)
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) -+> (w ⊗ u)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor LinearFunction
s (Tensor s u (Tensor s w v)) (Tensor s (Tensor s w v) u)
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s w v))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s w v) u)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction (Scalar v) (Tensor s v w) (Tensor s w v)
-> LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s w v))
forall a b.
(Object (LinearFunction (Scalar v)) a,
Object (LinearFunction s) (Tensor s u a),
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction s) (Tensor s u b)) =>
LinearFunction (Scalar v) a b
-> LinearFunction s (Tensor s u a) (Tensor s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction (Scalar v) (Tensor s v w) (Tensor s w v)
(v ⊗ w) -+> (w ⊗ v)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s w v))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s w v))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
fmapTensor :: forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (Tensor s u v),
Scalar x ~ Scalar (Tensor s u v)) =>
Bilinear (w -+> x) (Tensor s u v ⊗ w) (Tensor s u v ⊗ x)
fmapTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> (LinearFunction s w x
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) x))
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) x))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction s w x
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) x))
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) x)))
-> (LinearFunction s w x
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) x))
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction s w x
f
-> VSCCoercion
s (Tensor s u (Tensor s v x)) (Tensor s (Tensor s u v) x)
-> LinearFunction
s (Tensor s u (Tensor s v x)) (Tensor s (Tensor s u v) x)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s u (Tensor s v x)) (Tensor s (Tensor s u v) x)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor LinearFunction
s (Tensor s u (Tensor s v x)) (Tensor s (Tensor s u v) x)
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v x))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) x)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< LinearFunction s (Tensor s v w) (Tensor s v x)
-> LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v x))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s u b)) =>
LinearFunction s a b
-> LinearFunction s (Tensor s u a) (Tensor s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction s w x
-> LinearFunction s (Tensor s v w) (Tensor s v x)
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s v a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s v b)) =>
LinearFunction s a b
-> LinearFunction s (Tensor s v a) (Tensor s v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction s w x
f) LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v x))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v x))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
fzipTensorWith :: forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (Tensor s u v), Scalar w ~ Scalar (Tensor s u v),
Scalar x ~ Scalar (Tensor s u v)) =>
Bilinear
((w, x) -+> u)
(Tensor s u v ⊗ w, Tensor s u v ⊗ x)
(Tensor s u v ⊗ u)
fzipTensorWith = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> (LinearFunction s (w, x) u
-> LinearFunction
s
(Tensor s (Tensor s u v) w, Tensor s (Tensor s u v) x)
(Tensor s (Tensor s u v) u))
-> LinearFunction
s
(LinearFunction s (w, x) u)
(LinearFunction
s
(Tensor s (Tensor s u v) w, Tensor s (Tensor s u v) x)
(Tensor s (Tensor s u v) u))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction s (w, x) u
-> LinearFunction
s
(Tensor s (Tensor s u v) w, Tensor s (Tensor s u v) x)
(Tensor s (Tensor s u v) u))
-> LinearFunction
s
(LinearFunction s (w, x) u)
(LinearFunction
s
(Tensor s (Tensor s u v) w, Tensor s (Tensor s u v) x)
(Tensor s (Tensor s u v) u)))
-> (LinearFunction s (w, x) u
-> LinearFunction
s
(Tensor s (Tensor s u v) w, Tensor s (Tensor s u v) x)
(Tensor s (Tensor s u v) u))
-> LinearFunction
s
(LinearFunction s (w, x) u)
(LinearFunction
s
(Tensor s (Tensor s u v) w, Tensor s (Tensor s u v) x)
(Tensor s (Tensor s u v) u))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction s (w, x) u
f
-> VSCCoercion
s (Tensor s u (Tensor s v u)) (Tensor s (Tensor s u v) u)
-> LinearFunction
s (Tensor s u (Tensor s v u)) (Tensor s (Tensor s u v) u)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s u (Tensor s v u)) (Tensor s (Tensor s u v) u)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor LinearFunction
s (Tensor s u (Tensor s v u)) (Tensor s (Tensor s u v) u)
-> LinearFunction
s
(Tensor s (Tensor s u v) w, Tensor s (Tensor s u v) x)
(Tensor s u (Tensor s v u))
-> LinearFunction
s
(Tensor s (Tensor s u v) w, Tensor s (Tensor s u v) x)
(Tensor s (Tensor s u v) u)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< LinearFunction s (Tensor s v w, Tensor s v x) (Tensor s v u)
-> LinearFunction
s
(Tensor s u (Tensor s v w), Tensor s u (Tensor s v x))
(Tensor s u (Tensor s v u))
forall a b c.
(ObjectPair (LinearFunction s) a b, Object (LinearFunction s) c,
ObjectPair (LinearFunction s) (Tensor s u a) (Tensor s u b),
Object (LinearFunction s) (Tensor s u c)) =>
LinearFunction s (a, b) c
-> LinearFunction s (Tensor s u a, Tensor s u b) (Tensor s u c)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b c.
(Monoidal f r t, ObjectPair r a b, Object r c,
ObjectPair t (f a) (f b), Object t (f c)) =>
r (a, b) c -> t (f a, f b) (f c)
fzipWith (LinearFunction s (w, x) u
-> LinearFunction s (Tensor s v w, Tensor s v x) (Tensor s v u)
forall a b c.
(ObjectPair (LinearFunction s) a b, Object (LinearFunction s) c,
ObjectPair (LinearFunction s) (Tensor s v a) (Tensor s v b),
Object (LinearFunction s) (Tensor s v c)) =>
LinearFunction s (a, b) c
-> LinearFunction s (Tensor s v a, Tensor s v b) (Tensor s v c)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b c.
(Monoidal f r t, ObjectPair r a b, Object r c,
ObjectPair t (f a) (f b), Object t (f c)) =>
r (a, b) c -> t (f a, f b) (f c)
fzipWith LinearFunction s (w, x) u
f)
LinearFunction
s
(Tensor s u (Tensor s v w), Tensor s u (Tensor s v x))
(Tensor s u (Tensor s v u))
-> LinearFunction
s
(Tensor s (Tensor s u v) w, Tensor s (Tensor s u v) x)
(Tensor s u (Tensor s v w), Tensor s u (Tensor s v x))
-> LinearFunction
s
(Tensor s (Tensor s u v) w, Tensor s (Tensor s u v) x)
(Tensor s u (Tensor s v u))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) x) (Tensor s u (Tensor s v x))
-> LinearFunction
s
(Tensor s (Tensor s u v) w, Tensor s (Tensor s u v) x)
(Tensor s u (Tensor s v w), Tensor s u (Tensor s v x))
forall b b' c c'.
(ObjectPair (LinearFunction s) b b',
ObjectPair (LinearFunction s) c c') =>
LinearFunction s b c
-> LinearFunction s b' c' -> LinearFunction s (b, b') (c, c')
forall (a :: Type -> Type -> Type) b b' c c'.
(Morphism a, ObjectPair a b b', ObjectPair a c c') =>
a b c -> a b' c' -> a (b, b') (c, c')
*** VSCCoercion
s (Tensor s (Tensor s u v) x) (Tensor s u (Tensor s v x))
-> LinearFunction
s (Tensor s (Tensor s u v) x) (Tensor s u (Tensor s v x))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (Tensor s u v) x) (Tensor s u (Tensor s v x))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
tensorUnsafeFromArrayWithOffset :: ∀ nm w o α
. ( nm`Dimensional`Tensor s u v
, TensorSpace w, o`Dimensional`w, Scalar w ~ s
, GArr.Vector α s )
=> Int -> α s -> (Tensor s u v⊗w)
tensorUnsafeFromArrayWithOffset :: forall (nm :: Nat) w (o :: Nat) (α :: Type -> Type).
(Dimensional nm (Tensor s u v), TensorSpace w, Dimensional o w,
Scalar w ~ s, Vector α s) =>
Int -> α s -> Tensor s u v ⊗ w
tensorUnsafeFromArrayWithOffset
= case ( forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @u, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u
, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v ) of
( DimensionalityWitness u
IsStaticDimensional, SJust Sing n
sn
,DimensionalityWitness v
IsStaticDimensional, SJust Sing n
sm )
-> SNat (n * o)
-> (KnownNat (n * o) => Int -> α s -> Tensor s (Tensor s u v) w)
-> Int
-> α s
-> Tensor s (Tensor s u v) w
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (Sing n
Sing n
smSing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w) (
SNat (n * (n * o))
-> (KnownNat (n * (n * o)) =>
Int -> α s -> Tensor s (Tensor s u v) w)
-> Int
-> α s
-> Tensor s (Tensor s u v) w
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (Sing n
Sing n
snSing n -> Sing (n * o) -> Sing (Apply (Apply (*@#@$) n) (n * o))
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*(Sing n
Sing n
smSing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w)) (
\Int
i -> VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> Tensor s u (Tensor s v w) -> Tensor s (Tensor s u v) w
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c, Object (->) b,
Object (->) c) =>
VSCCoercion s b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor @s @u @v @w)
(Tensor s u (Tensor s v w) -> Tensor s (Tensor s u v) w)
-> (α s -> Tensor s u (Tensor s v w))
-> α s
-> Tensor s (Tensor s u v) w
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Int
-> α (Scalar (Tensor s u (Tensor s v w)))
-> Tensor s u (Tensor s v w)
forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
forall (α :: Type -> Type).
Vector α (Scalar (Tensor s u (Tensor s v w))) =>
Int
-> α (Scalar (Tensor s u (Tensor s v w)))
-> Tensor s u (Tensor s v w)
unsafeFromArrayWithOffset Int
i))
tensorUnsafeWriteArrayWithOffset :: ∀ nm w o α σ
. ( nm`Dimensional`Tensor s u v
, TensorSpace w, o`Dimensional`w, Scalar w ~ s
, GArr.Vector α s )
=> GArr.Mutable α σ s -> Int -> (Tensor s u v⊗w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset :: forall (nm :: Nat) w (o :: Nat) (α :: Type -> Type) σ.
(Dimensional nm (Tensor s u v), TensorSpace w, Dimensional o w,
Scalar w ~ s, Vector α s) =>
Mutable α σ s -> Int -> (Tensor s u v ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset
= case ( forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @u, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u
, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v ) of
( DimensionalityWitness u
IsStaticDimensional, SJust Sing n
sn
,DimensionalityWitness v
IsStaticDimensional, SJust Sing n
sm )
-> SNat (n * o)
-> (KnownNat (n * o) =>
Mutable α σ s -> Int -> Tensor s (Tensor s u v) w -> ST σ ())
-> Mutable α σ s
-> Int
-> Tensor s (Tensor s u v) w
-> ST σ ()
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (Sing n
Sing n
smSing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w) (
SNat (n * (n * o))
-> (KnownNat (n * (n * o)) =>
Mutable α σ s -> Int -> Tensor s (Tensor s u v) w -> ST σ ())
-> Mutable α σ s
-> Int
-> Tensor s (Tensor s u v) w
-> ST σ ()
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (Sing n
Sing n
snSing n -> Sing (n * o) -> Sing (Apply (Apply (*@#@$) n) (n * o))
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*(Sing n
Sing n
smSing n -> Sing o -> Sing (Apply (Apply (*@#@$) n) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w)) (
\Mutable α σ s
ar Int
i -> Mutable α σ (Scalar (Tensor s u (Tensor s v w)))
-> Int -> Tensor s u (Tensor s v w) -> ST σ ()
forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
forall (α :: Type -> Type) σ.
Vector α (Scalar (Tensor s u (Tensor s v w))) =>
Mutable α σ (Scalar (Tensor s u (Tensor s v w)))
-> Int -> Tensor s u (Tensor s v w) -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ s
Mutable α σ (Scalar (Tensor s u (Tensor s v w)))
ar Int
i
(Tensor s u (Tensor s v w) -> ST σ ())
-> (Tensor s (Tensor s u v) w -> Tensor s u (Tensor s v w))
-> Tensor s (Tensor s u v) w
-> ST σ ()
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> Tensor s (Tensor s u v) w -> Tensor s u (Tensor s v w)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c, Object (->) b,
Object (->) c) =>
VSCCoercion s b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor @s @u @v @w) ))
coerceFmapTensorProduct :: ∀ a b p . ( TensorSpace a, Scalar a ~ s
, TensorSpace b, Scalar b ~ s )
=> p (Tensor s u v) -> VSCCoercion s a b
-> Coercion (TensorProduct u (Tensor s v a))
(TensorProduct u (Tensor s v b))
coerceFmapTensorProduct :: forall a b (p :: Type -> Type).
(TensorSpace a, Scalar a ~ s, TensorSpace b, Scalar b ~ s) =>
p (Tensor s u v)
-> VSCCoercion s a b
-> Coercion
(TensorProduct u (Tensor s v a)) (TensorProduct u (Tensor s v b))
coerceFmapTensorProduct p (Tensor s u v)
_ VSCCoercion s a b
c = [u]
-> VSCCoercion (Scalar u) (Tensor s v a) (Tensor s v b)
-> Coercion
(TensorProduct u (Tensor s v a)) (TensorProduct u (Tensor s v b))
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar u, TensorSpace b,
Scalar b ~ Scalar u) =>
p u
-> VSCCoercion (Scalar u) a b
-> Coercion (TensorProduct u a) (TensorProduct u b)
coerceFmapTensorProduct ([]::[u])
(VSCCoercion s a b -> VSCCoercion s (Tensor s v a) (Tensor s v b)
forall a b.
(Object (VSCCoercion s) a, Object (VSCCoercion s) (Tensor s v a),
Object (VSCCoercion s) b, Object (VSCCoercion s) (Tensor s v b)) =>
VSCCoercion s a b -> VSCCoercion s (Tensor s v a) (Tensor s v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion s a b
c :: VSCCoercion s (v⊗a) (v⊗b))
wellDefinedVector :: Tensor s u v -> Maybe (Tensor s u v)
wellDefinedVector = Tensor s u v -> Maybe (Tensor s u v)
(u ⊗ v) -> Maybe (u ⊗ v)
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) -> Maybe (u ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor
wellDefinedTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) =>
(Tensor s u v ⊗ w) -> Maybe (Tensor s u v ⊗ w)
wellDefinedTensor = Coercion (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> Tensor s (Tensor s u v) w -> Tensor s u (Tensor s v w)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> Coercion (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor)
(Tensor s (Tensor s u v) w -> Tensor s u (Tensor s v w))
-> (Tensor s u (Tensor s v w) -> Maybe (Tensor s (Tensor s u v) w))
-> Tensor s (Tensor s u v) w
-> Maybe (Tensor s (Tensor s u v) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> Tensor s u (Tensor s v w) -> Maybe (Tensor s u (Tensor s v w))
(u ⊗ Tensor s v w) -> Maybe (u ⊗ Tensor s v w)
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) -> Maybe (u ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor (Tensor s u (Tensor s v w) -> Maybe (Tensor s u (Tensor s v w)))
-> (Maybe (Tensor s u (Tensor s v w))
-> Maybe (Tensor s (Tensor s u v) w))
-> Tensor s u (Tensor s v w)
-> Maybe (Tensor s (Tensor s u v) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> Coercion
(Maybe (Tensor s u (Tensor s v w)))
(Maybe (Tensor s (Tensor s u v) w))
-> Maybe (Tensor s u (Tensor s v w))
-> Maybe (Tensor s (Tensor s u v) w)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (Coercion (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> Coercion
(Maybe (Tensor s u (Tensor s v w)))
(Maybe (Tensor s (Tensor s u v) w))
forall a b.
(Object Coercion a, Object Coercion (Maybe a), Object Coercion b,
Object Coercion (Maybe b)) =>
Coercion a b -> Coercion (Maybe a) (Maybe b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> Coercion (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor))
instance ∀ s u v . (LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s)
=> LinearSpace (Tensor s u v) where
type DualVector (Tensor s u v) = LinearMap s u (DualVector v)
linearId :: Tensor s u v +> Tensor s u v
linearId = Tensor s u v +> Tensor s u v
(u ⊗ v) +> (u ⊗ v)
forall w.
(LinearSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) +> (u ⊗ w)
forall v w.
(LinearSpace v, LinearSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) +> (v ⊗ w)
tensorId
tensorId :: forall w.
(LinearSpace w, Scalar w ~ Scalar (Tensor s u v)) =>
(Tensor s u v ⊗ w) +> (Tensor s u v ⊗ w)
tensorId = VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
-> VSCCoercion
s
(LinearMap
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w)))
(LinearMap
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w))
forall a b.
(Object (VSCCoercion s) a,
Object (VSCCoercion s) (LinearMap s (Tensor s (Tensor s u v) w) a),
Object (VSCCoercion s) b,
Object
(VSCCoercion s) (LinearMap s (Tensor s (Tensor s u v) w) b)) =>
VSCCoercion s a b
-> VSCCoercion
s
(LinearMap s (Tensor s (Tensor s u v) w) a)
(LinearMap s (Tensor s (Tensor s u v) w) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s u v) w)
lassocTensor VSCCoercion
s
(LinearMap
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w)))
(LinearMap
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w))
-> VSCCoercion
s
(LinearMap
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w)))
(LinearMap
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w)))
-> VSCCoercion
s
(LinearMap
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w)))
(LinearMap
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearMap
s (Tensor s u v) (LinearMap s w (Tensor s u (Tensor s v w))))
(LinearMap
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w)))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMap VSCCoercion
s
(LinearMap
s (Tensor s u v) (LinearMap s w (Tensor s u (Tensor s v w))))
(LinearMap
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w)))
-> VSCCoercion
s
(LinearMap
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w)))
(LinearMap
s (Tensor s u v) (LinearMap s w (Tensor s u (Tensor s v w))))
-> VSCCoercion
s
(LinearMap
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w)))
(LinearMap
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w)))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearMap
s u (LinearMap s v (LinearMap s w (Tensor s u (Tensor s v w)))))
(LinearMap
s (Tensor s u v) (LinearMap s w (Tensor s u (Tensor s v w))))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMap
VSCCoercion
s
(LinearMap
s u (LinearMap s v (LinearMap s w (Tensor s u (Tensor s v w)))))
(LinearMap
s (Tensor s u v) (LinearMap s w (Tensor s u (Tensor s v w))))
-> VSCCoercion
s
(LinearMap
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w)))
(LinearMap
s u (LinearMap s v (LinearMap s w (Tensor s u (Tensor s v w)))))
-> VSCCoercion
s
(LinearMap
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w)))
(LinearMap
s (Tensor s u v) (LinearMap s w (Tensor s u (Tensor s v w))))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearMap s (Tensor s v w) (Tensor s u (Tensor s v w)))
(LinearMap s v (LinearMap s w (Tensor s u (Tensor s v w))))
-> VSCCoercion
s
(LinearMap
s u (LinearMap s (Tensor s v w) (Tensor s u (Tensor s v w))))
(LinearMap
s u (LinearMap s v (LinearMap s w (Tensor s u (Tensor s v w)))))
forall a b.
(Object (VSCCoercion s) a,
Object (VSCCoercion s) (LinearMap s u a), Object (VSCCoercion s) b,
Object (VSCCoercion s) (LinearMap s u b)) =>
VSCCoercion s a b
-> VSCCoercion s (LinearMap s u a) (LinearMap s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion
s
(LinearMap s (Tensor s v w) (Tensor s u (Tensor s v w)))
(LinearMap s v (LinearMap s w (Tensor s u (Tensor s v w))))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap VSCCoercion
s
(LinearMap
s u (LinearMap s (Tensor s v w) (Tensor s u (Tensor s v w))))
(LinearMap
s u (LinearMap s v (LinearMap s w (Tensor s u (Tensor s v w)))))
-> VSCCoercion
s
(LinearMap
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w)))
(LinearMap
s u (LinearMap s (Tensor s v w) (Tensor s u (Tensor s v w))))
-> VSCCoercion
s
(LinearMap
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w)))
(LinearMap
s u (LinearMap s v (LinearMap s w (Tensor s u (Tensor s v w)))))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearMap
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w)))
(LinearMap
s u (LinearMap s (Tensor s v w) (Tensor s u (Tensor s v w))))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap VSCCoercion
s
(LinearMap
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w)))
(LinearMap
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w))
-> LinearMap
s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w))
-> LinearMap
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s u v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s (Tensor s u (Tensor s v w)) (Tensor s u (Tensor s v w))
(u ⊗ Tensor s v w) +> (u ⊗ Tensor s v w)
forall w.
(LinearSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) +> (u ⊗ w)
forall v w.
(LinearSpace v, LinearSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) +> (v ⊗ w)
tensorId
coerceDoubleDual :: VSCCoercion
(Scalar (Tensor s u v))
(Tensor s u v)
(DualVector (DualVector (Tensor s u v)))
coerceDoubleDual = case ( DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness) -> VSCCoercion s (Tensor s u v) (Tensor s u v)
VSCCoercion
(Scalar (Tensor s u v))
(Tensor s u v)
(DualVector (DualVector (Tensor s u v)))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
dualSpaceWitness :: DualSpaceWitness (Tensor s u v)
dualSpaceWitness = case ( DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness) -> DualSpaceWitness (Tensor s u v)
forall v.
(LinearSpace (Scalar v), DualVector (Scalar v) ~ Scalar v,
LinearSpace (DualVector v), Scalar (DualVector v) ~ Scalar v,
DualVector (DualVector v) ~ v,
StaticDimension (DualVector v) ~ StaticDimension v) =>
DualSpaceWitness v
DualSpaceWitness
applyLinear :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) =>
Bilinear (Tensor s u v +> w) (Tensor s u v) w
applyLinear = LinearFunction
(Scalar (Tensor s u v +> w))
(Tensor s u v +> w)
(LinearFunction (Scalar (Tensor s u v +> w)) (Tensor s u v) w)
Bilinear ((u ⊗ v) +> w) (u ⊗ v) w
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar u,
Scalar w ~ Scalar u) =>
Bilinear ((u ⊗ u) +> w) (u ⊗ u) w
applyTensorLinMap
applyDualVector :: LinearSpace (Tensor s u v) =>
Bilinear
(DualVector (Tensor s u v)) (Tensor s u v) (Scalar (Tensor s u v))
applyDualVector = Bilinear
(DualVector (Tensor s u v)) (Tensor s u v) (Scalar (Tensor s u v))
Bilinear (DualVector (u ⊗ v)) (u ⊗ v) (Scalar u)
forall u.
(LinearSpace u, Scalar u ~ Scalar u) =>
Bilinear (DualVector (u ⊗ u)) (u ⊗ u) (Scalar u)
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctional
applyTensorFunctional :: forall u.
(LinearSpace u, Scalar u ~ Scalar (Tensor s u v)) =>
Bilinear
(DualVector (Tensor s u v ⊗ u))
(Tensor s u v ⊗ u)
(Scalar (Tensor s u v))
applyTensorFunctional = ScalarSpaceWitness u
-> DualSpaceWitness u
-> Bilinear
(LinearMap s (Tensor s u v) (DualVector u))
(Tensor s (Tensor s u v) u)
s
forall w.
(LinearSpace w, Scalar w ~ s) =>
ScalarSpaceWitness u
-> DualSpaceWitness w
-> Bilinear
(LinearMap s (Tensor s u v) (DualVector w))
(Tensor s (Tensor s u v) w)
s
atf ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness
where atf :: ∀ w . (LinearSpace w, Scalar w ~ s)
=> ScalarSpaceWitness u -> DualSpaceWitness w
-> Bilinear (LinearMap s (Tensor s u v) (DualVector w))
(Tensor s (Tensor s u v) w)
s
atf :: forall w.
(LinearSpace w, Scalar w ~ s) =>
ScalarSpaceWitness u
-> DualSpaceWitness w
-> Bilinear
(LinearMap s (Tensor s u v) (DualVector w))
(Tensor s (Tensor s u v) w)
s
atf ScalarSpaceWitness u
ScalarSpaceWitness DualSpaceWitness w
DualSpaceWitness
= VSCCoercion
s
(LinearMap s (Tensor s u v) (DualVector w))
(LinearMap s u (LinearMap s v (DualVector w)))
-> LinearFunction
s
(LinearMap s (Tensor s u v) (DualVector w))
(LinearMap s u (LinearMap s v (DualVector w)))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s
(LinearMap s (Tensor s u v) (DualVector w))
(LinearMap s u (LinearMap s v (DualVector w)))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap LinearFunction
s
(LinearMap s (Tensor s u v) (DualVector w))
(LinearMap s u (LinearMap s v (DualVector w)))
-> LinearFunction
s
(LinearMap s u (LinearMap s v (DualVector w)))
(LinearFunction s (Tensor s (Tensor s u v) w) s)
-> LinearFunction
s
(LinearMap s (Tensor s u v) (DualVector w))
(LinearFunction s (Tensor s (Tensor s u v) w) s)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
s
(LinearMap s u (LinearMap s v (DualVector w)))
(LinearFunction s (Tensor s u (Tensor s v w)) s)
Bilinear
(DualVector (u ⊗ Tensor s v w)) (u ⊗ Tensor s v w) (Scalar u)
forall u.
(LinearSpace u, Scalar u ~ Scalar u) =>
Bilinear (DualVector (u ⊗ u)) (u ⊗ u) (Scalar u)
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctional
LinearFunction
s
(LinearMap s u (LinearMap s v (DualVector w)))
(LinearFunction s (Tensor s u (Tensor s v w)) s)
-> LinearFunction
s
(LinearFunction s (Tensor s u (Tensor s v w)) s)
(LinearFunction s (Tensor s (Tensor s u v) w) s)
-> LinearFunction
s
(LinearMap s u (LinearMap s v (DualVector w)))
(LinearFunction s (Tensor s (Tensor s u v) w) s)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> (LinearFunction s (Tensor s u (Tensor s v w)) s
-> LinearFunction s (Tensor s (Tensor s u v) w) s)
-> LinearFunction
s
(LinearFunction s (Tensor s u (Tensor s v w)) s)
(LinearFunction s (Tensor s (Tensor s u v) w) s)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction((LinearFunction s (Tensor s u (Tensor s v w)) s
-> LinearFunction s (Tensor s (Tensor s u v) w) s)
-> LinearFunction
s
(LinearFunction s (Tensor s u (Tensor s v w)) s)
(LinearFunction s (Tensor s (Tensor s u v) w) s))
-> (LinearFunction s (Tensor s u (Tensor s v w)) s
-> LinearFunction s (Tensor s (Tensor s u v) w) s)
-> LinearFunction
s
(LinearFunction s (Tensor s u (Tensor s v w)) s)
(LinearFunction s (Tensor s (Tensor s u v) w) s)
forall a. Object (->) a => a -> a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
`id`\LinearFunction s (Tensor s u (Tensor s v w)) s
f -> LinearFunction s (Tensor s u (Tensor s v w)) s
f LinearFunction s (Tensor s u (Tensor s v w)) s
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction s (Tensor s (Tensor s u v) w) s
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
applyTensorLinMap :: forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (Tensor s u v),
Scalar w ~ Scalar (Tensor s u v)) =>
Bilinear ((Tensor s u v ⊗ u) +> w) (Tensor s u v ⊗ u) w
applyTensorLinMap = (LinearMap s (Tensor s (Tensor s u v) u) w
-> LinearFunction s (Tensor s (Tensor s u v) u) w)
-> LinearFunction
s
(LinearMap s (Tensor s (Tensor s u v) u) w)
(LinearFunction s (Tensor s (Tensor s u v) u) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearMap s (Tensor s (Tensor s u v) u) w
-> LinearFunction s (Tensor s (Tensor s u v) u) w)
-> LinearFunction
s
(LinearMap s (Tensor s (Tensor s u v) u) w)
(LinearFunction s (Tensor s (Tensor s u v) u) w))
-> (LinearMap s (Tensor s (Tensor s u v) u) w
-> LinearFunction s (Tensor s (Tensor s u v) u) w)
-> LinearFunction
s
(LinearMap s (Tensor s (Tensor s u v) u) w)
(LinearFunction s (Tensor s (Tensor s u v) u) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ VSCCoercion
s
(LinearMap s (Tensor s (Tensor s u v) u) w)
(LinearMap s (Tensor s u (Tensor s v u)) w)
-> LinearMap s (Tensor s (Tensor s u v) u) w
-> LinearMap s (Tensor s u (Tensor s v u)) w
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c, Object (->) b,
Object (->) c) =>
VSCCoercion s b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (VSCCoercion
s
(LinearMap s (Tensor s (Tensor s u v) u) w)
(LinearMap s (Tensor s u v) (LinearMap s u w))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMapVSCCoercion
s
(LinearMap s (Tensor s (Tensor s u v) u) w)
(LinearMap s (Tensor s u v) (LinearMap s u w))
-> VSCCoercion
s
(LinearMap s (Tensor s u v) (LinearMap s u w))
(LinearMap s (Tensor s u (Tensor s v u)) w)
-> VSCCoercion
s
(LinearMap s (Tensor s (Tensor s u v) u) w)
(LinearMap s (Tensor s u (Tensor s v u)) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>>VSCCoercion
s
(LinearMap s (Tensor s u v) (LinearMap s u w))
(LinearMap s u (LinearMap s v (LinearMap s u w)))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap
VSCCoercion
s
(LinearMap s (Tensor s u v) (LinearMap s u w))
(LinearMap s u (LinearMap s v (LinearMap s u w)))
-> VSCCoercion
s
(LinearMap s u (LinearMap s v (LinearMap s u w)))
(LinearMap s (Tensor s u (Tensor s v u)) w)
-> VSCCoercion
s
(LinearMap s (Tensor s u v) (LinearMap s u w))
(LinearMap s (Tensor s u (Tensor s v u)) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>>VSCCoercion
s (LinearMap s v (LinearMap s u w)) (LinearMap s (Tensor s v u) w)
-> VSCCoercion
s
(LinearMap s u (LinearMap s v (LinearMap s u w)))
(LinearMap s u (LinearMap s (Tensor s v u) w))
forall a b.
(Object (VSCCoercion s) a,
Object (VSCCoercion s) (LinearMap s u a), Object (VSCCoercion s) b,
Object (VSCCoercion s) (LinearMap s u b)) =>
VSCCoercion s a b
-> VSCCoercion s (LinearMap s u a) (LinearMap s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion
s (LinearMap s v (LinearMap s u w)) (LinearMap s (Tensor s v u) w)
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMapVSCCoercion
s
(LinearMap s u (LinearMap s v (LinearMap s u w)))
(LinearMap s u (LinearMap s (Tensor s v u) w))
-> VSCCoercion
s
(LinearMap s u (LinearMap s (Tensor s v u) w))
(LinearMap s (Tensor s u (Tensor s v u)) w)
-> VSCCoercion
s
(LinearMap s u (LinearMap s v (LinearMap s u w)))
(LinearMap s (Tensor s u (Tensor s v u)) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>>VSCCoercion
s
(LinearMap s u (LinearMap s (Tensor s v u) w))
(LinearMap s (Tensor s u (Tensor s v u)) w)
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMap)
(LinearMap s (Tensor s (Tensor s u v) u) w
-> LinearMap s (Tensor s u (Tensor s v u)) w)
-> (LinearMap s (Tensor s u (Tensor s v u)) w
-> LinearFunction s (Tensor s (Tensor s u v) u) w)
-> LinearMap s (Tensor s (Tensor s u v) u) w
-> LinearFunction s (Tensor s (Tensor s u v) u) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> \LinearMap
(Scalar u) (Tensor (Scalar u) u (Tensor (Scalar u) v u)) w
f -> (LinearFunction
(Scalar u)
(LinearMap
(Scalar u) (Tensor (Scalar u) u (Tensor (Scalar u) v u)) w)
(LinearFunction
(Scalar u) (Tensor (Scalar u) u (Tensor (Scalar u) v u)) w)
Bilinear
(Tensor (Scalar u) u (Tensor (Scalar u) v u) +> w)
(Tensor (Scalar u) u (Tensor (Scalar u) v u))
w
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar u,
Scalar w ~ Scalar u) =>
Bilinear ((u ⊗ u) +> w) (u ⊗ u) w
applyTensorLinMapLinearFunction
(Scalar u)
(LinearMap
(Scalar u) (Tensor (Scalar u) u (Tensor (Scalar u) v u)) w)
(LinearFunction
(Scalar u) (Tensor (Scalar u) u (Tensor (Scalar u) v u)) w)
-> LinearMap
(Scalar u) (Tensor (Scalar u) u (Tensor (Scalar u) v u)) w
-> LinearFunction
(Scalar u) (Tensor (Scalar u) u (Tensor (Scalar u) v u)) w
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap
(Scalar u) (Tensor (Scalar u) u (Tensor (Scalar u) v u)) w
f) LinearFunction
(Scalar u) (Tensor (Scalar u) u (Tensor (Scalar u) v u)) w
-> LinearFunction
(Scalar u)
(Tensor (Scalar u) (u ⊗ v) u)
(Tensor (Scalar u) u (Tensor (Scalar u) v u))
-> LinearFunction (Scalar u) (Tensor (Scalar u) (u ⊗ v) u) w
forall a b c.
(Object (LinearFunction (Scalar u)) a,
Object (LinearFunction (Scalar u)) b,
Object (LinearFunction (Scalar u)) c) =>
LinearFunction (Scalar u) b c
-> LinearFunction (Scalar u) a b -> LinearFunction (Scalar u) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar u)
(Tensor (Scalar u) (u ⊗ v) u)
(Tensor (Scalar u) u (Tensor (Scalar u) v u))
-> LinearFunction
(Scalar u)
(Tensor (Scalar u) (u ⊗ v) u)
(Tensor (Scalar u) u (Tensor (Scalar u) v u))
forall b c.
(Object (VSCCoercion (Scalar u)) b,
Object (VSCCoercion (Scalar u)) c,
Object (LinearFunction (Scalar u)) b,
Object (LinearFunction (Scalar u)) c) =>
VSCCoercion (Scalar u) b c -> LinearFunction (Scalar u) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
(Scalar u)
(Tensor (Scalar u) (u ⊗ v) u)
(Tensor (Scalar u) u (Tensor (Scalar u) v u))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
composeLinear :: forall w x.
(LinearSpace w, TensorSpace x, Scalar w ~ Scalar (Tensor s u v),
Scalar x ~ Scalar (Tensor s u v)) =>
Bilinear (w +> x) (Tensor s u v +> w) (Tensor s u v +> x)
composeLinear = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> (LinearMap s w x
-> LinearMap s (Tensor s u v) w -> LinearMap s (Tensor s u v) x)
-> LinearFunction
s
(LinearMap s w x)
(LinearFunction
s (LinearMap s (Tensor s u v) w) (LinearMap s (Tensor s u v) x))
(LinearMap s w x
-> LinearMap s (Tensor s u v) w -> LinearMap s (Tensor s u v) x)
-> Bilinear
(LinearMap s w x)
(LinearMap s (Tensor s u v) w)
(LinearMap s (Tensor s u v) x)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s w x
-> LinearMap s (Tensor s u v) w -> LinearMap s (Tensor s u v) x)
-> LinearFunction
s
(LinearMap s w x)
(LinearFunction
s (LinearMap s (Tensor s u v) w) (LinearMap s (Tensor s u v) x)))
-> (LinearMap s w x
-> LinearMap s (Tensor s u v) w -> LinearMap s (Tensor s u v) x)
-> LinearFunction
s
(LinearMap s w x)
(LinearFunction
s (LinearMap s (Tensor s u v) w) (LinearMap s (Tensor s u v) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearMap s w x
f LinearMap s (Tensor s u v) w
g
-> VSCCoercion
s (LinearMap s u (LinearMap s v x)) (LinearMap s (Tensor s u v) x)
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMap VSCCoercion
s (LinearMap s u (LinearMap s v x)) (LinearMap s (Tensor s u v) x)
-> LinearMap s u (LinearMap s v x) -> LinearMap s (Tensor s u v) x
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction s (LinearMap s v w) (LinearMap s v x)
-> LinearFunction
s
(LinearMap s u (LinearMap s v w))
(LinearMap s u (LinearMap s v x))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s u b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s u a) (LinearMap s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction s w x
-> LinearFunction s (LinearMap s v w) (LinearMap s v x)
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s v a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s v b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s v a) (LinearMap s v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction s w x
-> LinearFunction s (LinearMap s v w) (LinearMap s v x))
-> LinearFunction s w x
-> LinearFunction s (LinearMap s v w) (LinearMap s v x)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction (Scalar w) (LinearMap s w x) (LinearFunction s w x)
Bilinear (w +> x) w x
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar w) =>
Bilinear (w +> w) w w
applyLinearLinearFunction (Scalar w) (LinearMap s w x) (LinearFunction s w x)
-> LinearMap s w x -> LinearFunction s w x
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap s w x
f) LinearFunction
s
(LinearMap s u (LinearMap s v w))
(LinearMap s u (LinearMap s v x))
-> LinearMap s u (LinearMap s v w)
-> LinearMap s u (LinearMap s v x)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMapVSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
-> LinearMap s (Tensor s u v) w -> LinearMap s u (LinearMap s v w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$LinearMap s (Tensor s u v) w
g)
contractTensorMap :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) =>
(Tensor s u v +> (Tensor s u v ⊗ w)) -+> w
contractTensorMap = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> LinearFunction s (LinearMap s u (Tensor s u w)) w
(u +> (u ⊗ w)) -+> w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v +> (v ⊗ w)) -+> w
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u +> (u ⊗ w)) -+> w
contractTensorMap
LinearFunction s (LinearMap s u (Tensor s u w)) w
-> LinearFunction
s
(LinearMap s (Tensor s u v) (Tensor s (Tensor s u v) w))
(LinearMap s u (Tensor s u w))
-> LinearFunction
s (LinearMap s (Tensor s u v) (Tensor s (Tensor s u v) w)) w
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar w)
(LinearMap s v (Tensor s (Tensor s u v) w))
(Tensor s u w)
-> LinearFunction
s
(LinearMap s u (LinearMap s v (Tensor s (Tensor s u v) w)))
(LinearMap s u (Tensor s u w))
forall a b.
(Object (LinearFunction (Scalar w)) a,
Object (LinearFunction s) (LinearMap s u a),
Object (LinearFunction (Scalar w)) b,
Object (LinearFunction s) (LinearMap s u b)) =>
LinearFunction (Scalar w) a b
-> LinearFunction s (LinearMap s u a) (LinearMap s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction (Scalar w) (Tensor (Scalar w) w u) (Tensor s u w)
Tensor (Scalar w) w u -+> (u ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar w) =>
(w ⊗ w) -+> (w ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor LinearFunction (Scalar w) (Tensor (Scalar w) w u) (Tensor s u w)
-> LinearFunction
(Scalar w)
(LinearMap s v (Tensor s (Tensor s u v) w))
(Tensor (Scalar w) w u)
-> LinearFunction
(Scalar w)
(LinearMap s v (Tensor s (Tensor s u v) w))
(Tensor s u w)
forall a b c.
(Object (LinearFunction (Scalar w)) a,
Object (LinearFunction (Scalar w)) b,
Object (LinearFunction (Scalar w)) c) =>
LinearFunction (Scalar w) b c
-> LinearFunction (Scalar w) a b -> LinearFunction (Scalar w) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar w)
(LinearMap s v (Tensor s v (Tensor s w u)))
(Tensor (Scalar w) w u)
(v +> (v ⊗ Tensor (Scalar w) w u)) -+> Tensor (Scalar w) w u
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v +> (v ⊗ w)) -+> w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v +> (v ⊗ w)) -+> w
contractTensorMap
LinearFunction
(Scalar w)
(LinearMap s v (Tensor s v (Tensor s w u)))
(Tensor (Scalar w) w u)
-> LinearFunction
(Scalar w)
(LinearMap s v (Tensor s (Tensor s u v) w))
(LinearMap s v (Tensor s v (Tensor s w u)))
-> LinearFunction
(Scalar w)
(LinearMap s v (Tensor s (Tensor s u v) w))
(Tensor (Scalar w) w u)
forall a b c.
(Object (LinearFunction (Scalar w)) a,
Object (LinearFunction (Scalar w)) b,
Object (LinearFunction (Scalar w)) c) =>
LinearFunction (Scalar w) b c
-> LinearFunction (Scalar w) a b -> LinearFunction (Scalar w) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s v (Tensor s w u))
-> LinearFunction
(Scalar w)
(LinearMap s v (Tensor s (Tensor s u v) w))
(LinearMap s v (Tensor s v (Tensor s w u)))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction (Scalar w)) (LinearMap s v a),
Object (LinearFunction s) b,
Object (LinearFunction (Scalar w)) (LinearMap s v b)) =>
LinearFunction s a b
-> LinearFunction (Scalar w) (LinearMap s v a) (LinearMap s v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (VSCCoercion
s (Tensor s (Tensor s v w) u) (Tensor s v (Tensor s w u))
-> LinearFunction
s (Tensor s (Tensor s v w) u) (Tensor s v (Tensor s w u))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (Tensor s v w) u) (Tensor s v (Tensor s w u))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor LinearFunction
s (Tensor s (Tensor s v w) u) (Tensor s v (Tensor s w u))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s v w) u)
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s v (Tensor s w u))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s v w) u)
(u ⊗ Tensor s v w) -+> (Tensor s v w ⊗ u)
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) -+> (w ⊗ u)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor LinearFunction
s (Tensor s u (Tensor s v w)) (Tensor s (Tensor s v w) u)
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s (Tensor s v w) u)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor))
LinearFunction
s
(LinearMap s u (LinearMap s v (Tensor s (Tensor s u v) w)))
(LinearMap s u (Tensor s u w))
-> LinearFunction
s
(LinearMap s (Tensor s u v) (Tensor s (Tensor s u v) w))
(LinearMap s u (LinearMap s v (Tensor s (Tensor s u v) w)))
-> LinearFunction
s
(LinearMap s (Tensor s u v) (Tensor s (Tensor s u v) w))
(LinearMap s u (Tensor s u w))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearMap s (Tensor s u v) (Tensor s (Tensor s u v) w))
(LinearMap s u (LinearMap s v (Tensor s (Tensor s u v) w)))
-> LinearFunction
s
(LinearMap s (Tensor s u v) (Tensor s (Tensor s u v) w))
(LinearMap s u (LinearMap s v (Tensor s (Tensor s u v) w)))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s
(LinearMap s (Tensor s u v) (Tensor s (Tensor s u v) w))
(LinearMap s u (LinearMap s v (Tensor s (Tensor s u v) w)))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap
contractMapTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) =>
(Tensor s u v ⊗ (Tensor s u v +> w)) -+> w
contractMapTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> LinearFunction s (LinearMap s v (Tensor s v w)) w
(v +> (v ⊗ w)) -+> w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v +> (v ⊗ w)) -+> w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v +> (v ⊗ w)) -+> w
contractTensorMap LinearFunction s (LinearMap s v (Tensor s v w)) w
-> LinearFunction
s
(Tensor s (Tensor s u v) (LinearMap s (Tensor s u v) w))
(LinearMap s v (Tensor s v w))
-> LinearFunction
s (Tensor s (Tensor s u v) (LinearMap s (Tensor s u v) w)) w
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction (Scalar w) (Tensor (Scalar w) w v) (Tensor s v w)
-> LinearFunction
s
(LinearMap s v (Tensor (Scalar w) w v))
(LinearMap s v (Tensor s v w))
forall a b.
(Object (LinearFunction (Scalar w)) a,
Object (LinearFunction s) (LinearMap s v a),
Object (LinearFunction (Scalar w)) b,
Object (LinearFunction s) (LinearMap s v b)) =>
LinearFunction (Scalar w) a b
-> LinearFunction s (LinearMap s v a) (LinearMap s v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction (Scalar w) (Tensor (Scalar w) w v) (Tensor s v w)
Tensor (Scalar w) w v -+> (v ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar w) =>
(w ⊗ w) -+> (w ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor LinearFunction
s
(LinearMap s v (Tensor (Scalar w) w v))
(LinearMap s v (Tensor s v w))
-> LinearFunction
s
(Tensor s (Tensor s u v) (LinearMap s (Tensor s u v) w))
(LinearMap s v (Tensor (Scalar w) w v))
-> LinearFunction
s
(Tensor s (Tensor s u v) (LinearMap s (Tensor s u v) w))
(LinearMap s v (Tensor s v w))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
s
(Tensor s u (LinearMap s u (LinearMap s v (Tensor s w v))))
(LinearMap s v (Tensor (Scalar w) w v))
(u ⊗ (u +> LinearMap s v (Tensor (Scalar w) w v)))
-+> LinearMap s v (Tensor (Scalar w) w v)
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ (v +> w)) -+> w
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u ⊗ (u +> w)) -+> w
contractMapTensor
LinearFunction
s
(Tensor s u (LinearMap s u (LinearMap s v (Tensor s w v))))
(LinearMap s v (Tensor (Scalar w) w v))
-> LinearFunction
s
(Tensor s (Tensor s u v) (LinearMap s (Tensor s u v) w))
(Tensor s u (LinearMap s u (LinearMap s v (Tensor s w v))))
-> LinearFunction
s
(Tensor s (Tensor s u v) (LinearMap s (Tensor s u v) w))
(LinearMap s v (Tensor (Scalar w) w v))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
s
(Tensor s v (LinearMap s (Tensor s u v) w))
(LinearMap s u (LinearMap s v (Tensor s w v)))
-> LinearFunction
s
(Tensor s u (Tensor s v (LinearMap s (Tensor s u v) w)))
(Tensor s u (LinearMap s u (LinearMap s v (Tensor s w v))))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s u b)) =>
LinearFunction s a b
-> LinearFunction s (Tensor s u a) (Tensor s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (VSCCoercion
s
(Tensor s (LinearMap s (Tensor s u v) w) v)
(LinearMap s u (LinearMap s v (Tensor s w v)))
-> LinearFunction
s
(Tensor s (LinearMap s (Tensor s u v) w) v)
(LinearMap s u (LinearMap s v (Tensor s w v)))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (VSCCoercion
s
(LinearMap s (Tensor s u v) (Tensor s w v))
(LinearMap s u (LinearMap s v (Tensor s w v)))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap VSCCoercion
s
(LinearMap s (Tensor s u v) (Tensor s w v))
(LinearMap s u (LinearMap s v (Tensor s w v)))
-> VSCCoercion
s
(Tensor s (LinearMap s (Tensor s u v) w) v)
(LinearMap s (Tensor s u v) (Tensor s w v))
-> VSCCoercion
s
(Tensor s (LinearMap s (Tensor s u v) w) v)
(LinearMap s u (LinearMap s v (Tensor s w v)))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(Tensor s (LinearMap s (Tensor s u v) w) v)
(LinearMap s (Tensor s u v) (Tensor s w v))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap) LinearFunction
s
(Tensor s (LinearMap s (Tensor s u v) w) v)
(LinearMap s u (LinearMap s v (Tensor s w v)))
-> LinearFunction
s
(Tensor s v (LinearMap s (Tensor s u v) w))
(Tensor s (LinearMap s (Tensor s u v) w) v)
-> LinearFunction
s
(Tensor s v (LinearMap s (Tensor s u v) w))
(LinearMap s u (LinearMap s v (Tensor s w v)))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
s
(Tensor s v (LinearMap s (Tensor s u v) w))
(Tensor s (LinearMap s (Tensor s u v) w) v)
(v ⊗ LinearMap s (Tensor s u v) w)
-+> (LinearMap s (Tensor s u v) w ⊗ v)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor)
LinearFunction
s
(Tensor s u (Tensor s v (LinearMap s (Tensor s u v) w)))
(Tensor s u (LinearMap s u (LinearMap s v (Tensor s w v))))
-> LinearFunction
s
(Tensor s (Tensor s u v) (LinearMap s (Tensor s u v) w))
(Tensor s u (Tensor s v (LinearMap s (Tensor s u v) w)))
-> LinearFunction
s
(Tensor s (Tensor s u v) (LinearMap s (Tensor s u v) w))
(Tensor s u (LinearMap s u (LinearMap s v (Tensor s w v))))
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(Tensor s (Tensor s u v) (LinearMap s (Tensor s u v) w))
(Tensor s u (Tensor s v (LinearMap s (Tensor s u v) w)))
-> LinearFunction
s
(Tensor s (Tensor s u v) (LinearMap s (Tensor s u v) w))
(Tensor s u (Tensor s v (LinearMap s (Tensor s u v) w)))
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s
(Tensor s (Tensor s u v) (LinearMap s (Tensor s u v) w))
(Tensor s u (Tensor s v (LinearMap s (Tensor s u v) w)))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
useTupleLinearSpaceComponents :: forall x y φ.
(Tensor s u v ~ (x, y)) =>
((LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ) -> φ
useTupleLinearSpaceComponents (LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ
_ = φ
forall a. a
usingNonTupleTypeAsTupleError
type DualSpace v = v+>Scalar v
type Fractional' s = (Num' s, Fractional s, Eq s, VectorSpace s)
instance (TensorSpace v, Num' s, Scalar v ~ s)
=> Functor (Tensor s v) (LinearFunction s) (LinearFunction s) where
fmap :: forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s v a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s v b)) =>
LinearFunction s a b
-> LinearFunction s (Tensor s v a) (Tensor s v b)
fmap LinearFunction s a b
f = LinearFunction
s
(LinearFunction s a b)
(LinearFunction s (Tensor s v a) (Tensor s v b))
-> LinearFunction s a b
-> LinearFunction s (Tensor s v a) (Tensor s v b)
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
s
(LinearFunction s a b)
(LinearFunction s (Tensor s v a) (Tensor s v b))
Bilinear (a -+> b) (v ⊗ a) (v ⊗ b)
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
fmapTensor LinearFunction s a b
f
instance (Num' s, TensorSpace v, Scalar v ~ s)
=> Monoidal (Tensor s v) (LinearFunction s) (LinearFunction s) where
pureUnit :: LinearFunction
s
(UnitObject (LinearFunction s))
(Tensor s v (UnitObject (LinearFunction s)))
pureUnit = LinearFunction
s
(UnitObject (LinearFunction s))
(Tensor s v (UnitObject (LinearFunction s)))
LinearFunction s (ZeroDim s) (Tensor s v (ZeroDim s))
forall w s v. AdditiveGroup w => LinearFunction s v w
const0
fzipWith :: forall a b c.
(ObjectPair (LinearFunction s) a b, Object (LinearFunction s) c,
ObjectPair (LinearFunction s) (Tensor s v a) (Tensor s v b),
Object (LinearFunction s) (Tensor s v c)) =>
LinearFunction s (a, b) c
-> LinearFunction s (Tensor s v a, Tensor s v b) (Tensor s v c)
fzipWith LinearFunction s (a, b) c
f = LinearFunction
s
(LinearFunction s (a, b) c)
(LinearFunction s (Tensor s v a, Tensor s v b) (Tensor s v c))
-> LinearFunction s (a, b) c
-> LinearFunction s (Tensor s v a, Tensor s v b) (Tensor s v c)
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
s
(LinearFunction s (a, b) c)
(LinearFunction s (Tensor s v a, Tensor s v b) (Tensor s v c))
Bilinear ((a, b) -+> c) (v ⊗ a, v ⊗ b) (v ⊗ c)
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar v,
Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
fzipTensorWith LinearFunction s (a, b) c
f
instance (LinearSpace v, Num' s, Scalar v ~ s)
=> Functor (LinearMap s v) (LinearFunction s) (LinearFunction s) where
fmap :: forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s v a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s v b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s v a) (LinearMap s v b)
fmap = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> \LinearFunction s a b
f -> VSCCoercion s (Tensor s (DualVector v) b) (LinearMap s v b)
-> LinearFunction s (Tensor s (DualVector v) b) (LinearMap s v b)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion s (Tensor s (DualVector v) b) (LinearMap s v b)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor LinearFunction s (Tensor s (DualVector v) b) (LinearMap s v b)
-> LinearFunction s (LinearMap s v a) (Tensor s (DualVector v) b)
-> LinearFunction s (LinearMap s v a) (LinearMap s v b)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s a b
-> LinearFunction
s (Tensor s (DualVector v) a) (Tensor s (DualVector v) b)
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s (DualVector v) a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s (DualVector v) b)) =>
LinearFunction s a b
-> LinearFunction
s (Tensor s (DualVector v) a) (Tensor s (DualVector v) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction s a b
f LinearFunction
s (Tensor s (DualVector v) a) (Tensor s (DualVector v) b)
-> LinearFunction s (LinearMap s v a) (Tensor s (DualVector v) a)
-> LinearFunction s (LinearMap s v a) (Tensor s (DualVector v) b)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion s (LinearMap s v a) (Tensor s (DualVector v) a)
-> LinearFunction s (LinearMap s v a) (Tensor s (DualVector v) a)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion s (LinearMap s v a) (Tensor s (DualVector v) a)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor
instance (Num' s, LinearSpace v, Scalar v ~ s)
=> Monoidal (LinearMap s v) (LinearFunction s) (LinearFunction s) where
pureUnit :: LinearFunction
s
(UnitObject (LinearFunction s))
(LinearMap s v (UnitObject (LinearFunction s)))
pureUnit = LinearFunction
s
(UnitObject (LinearFunction s))
(LinearMap s v (UnitObject (LinearFunction s)))
LinearFunction s (ZeroDim s) (LinearMap s v (ZeroDim s))
forall w s v. AdditiveGroup w => LinearFunction s v w
const0
fzipWith :: forall a b c.
(ObjectPair (LinearFunction s) a b, Object (LinearFunction s) c,
ObjectPair (LinearFunction s) (LinearMap s v a) (LinearMap s v b),
Object (LinearFunction s) (LinearMap s v c)) =>
LinearFunction s (a, b) c
-> LinearFunction
s (LinearMap s v a, LinearMap s v b) (LinearMap s v c)
fzipWith = case DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v of
DualSpaceWitness v
DualSpaceWitness -> \LinearFunction s (a, b) c
f -> VSCCoercion s (LinearMap s v a) (Tensor s (DualVector v) a)
-> LinearFunction s (LinearMap s v a) (Tensor s (DualVector v) a)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion s (LinearMap s v a) (Tensor s (DualVector v) a)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor LinearFunction s (LinearMap s v a) (Tensor s (DualVector v) a)
-> LinearFunction s (LinearMap s v b) (Tensor s (DualVector v) b)
-> LinearFunction
s
(LinearMap s v a, LinearMap s v b)
(Tensor s (DualVector v) a, Tensor s (DualVector v) b)
forall b b' c c'.
(ObjectPair (LinearFunction s) b b',
ObjectPair (LinearFunction s) c c') =>
LinearFunction s b c
-> LinearFunction s b' c' -> LinearFunction s (b, b') (c, c')
forall (a :: Type -> Type -> Type) b b' c c'.
(Morphism a, ObjectPair a b b', ObjectPair a c c') =>
a b c -> a b' c' -> a (b, b') (c, c')
*** VSCCoercion s (LinearMap s v b) (Tensor s (DualVector v) b)
-> LinearFunction s (LinearMap s v b) (Tensor s (DualVector v) b)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion s (LinearMap s v b) (Tensor s (DualVector v) b)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor LinearFunction
s
(LinearMap s v a, LinearMap s v b)
(Tensor s (DualVector v) a, Tensor s (DualVector v) b)
-> LinearFunction
s
(Tensor s (DualVector v) a, Tensor s (DualVector v) b)
(LinearMap s v c)
-> LinearFunction
s (LinearMap s v a, LinearMap s v b) (LinearMap s v c)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction s (a, b) c
-> LinearFunction
s
(Tensor s (DualVector v) a, Tensor s (DualVector v) b)
(Tensor s (DualVector v) c)
forall a b c.
(ObjectPair (LinearFunction s) a b, Object (LinearFunction s) c,
ObjectPair
(LinearFunction s)
(Tensor s (DualVector v) a)
(Tensor s (DualVector v) b),
Object (LinearFunction s) (Tensor s (DualVector v) c)) =>
LinearFunction s (a, b) c
-> LinearFunction
s
(Tensor s (DualVector v) a, Tensor s (DualVector v) b)
(Tensor s (DualVector v) c)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b c.
(Monoidal f r t, ObjectPair r a b, Object r c,
ObjectPair t (f a) (f b), Object t (f c)) =>
r (a, b) c -> t (f a, f b) (f c)
fzipWith LinearFunction s (a, b) c
f LinearFunction
s
(Tensor s (DualVector v) a, Tensor s (DualVector v) b)
(Tensor s (DualVector v) c)
-> LinearFunction s (Tensor s (DualVector v) c) (LinearMap s v c)
-> LinearFunction
s
(Tensor s (DualVector v) a, Tensor s (DualVector v) b)
(LinearMap s v c)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> VSCCoercion s (Tensor s (DualVector v) c) (LinearMap s v c)
-> LinearFunction s (Tensor s (DualVector v) c) (LinearMap s v c)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion s (Tensor s (DualVector v) c) (LinearMap s v c)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor
instance ∀ v s . (TensorSpace v, Scalar v ~ s)
=> Functor (Tensor s v) (VSCCoercion s) (VSCCoercion s) where
fmap :: ∀ a b . ( TensorSpace a, Scalar a ~ s
, TensorSpace b, Scalar b ~ s )
=> VSCCoercion s a b -> VSCCoercion s (Tensor s v a) (Tensor s v b)
fmap :: forall a b.
(TensorSpace a, Scalar a ~ s, TensorSpace b, Scalar b ~ s) =>
VSCCoercion s a b -> VSCCoercion s (Tensor s v a) (Tensor s v b)
fmap f :: VSCCoercion s a b
f@VSCCoercion s a b
VSCCoercion = case forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
coerceFmapTensorProduct @v [] VSCCoercion s a b
VSCCoercion (Scalar v) a b
f of
Coercion (TensorProduct v a) (TensorProduct v b)
Coercion -> VSCCoercion s (Tensor s v a) (Tensor s v b)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
instance ∀ v s . (LinearSpace v, Scalar v ~ s)
=> Functor (LinearMap s v) (VSCCoercion s) (VSCCoercion s) where
fmap :: ∀ a b . ( TensorSpace a, Scalar a ~ s
, TensorSpace b, Scalar b ~ s )
=> VSCCoercion s a b -> VSCCoercion s (LinearMap s v a) (LinearMap s v b)
fmap :: forall a b.
(TensorSpace a, Scalar a ~ s, TensorSpace b, Scalar b ~ s) =>
VSCCoercion s a b
-> VSCCoercion s (LinearMap s v a) (LinearMap s v b)
fmap f :: VSCCoercion s a b
f@VSCCoercion s a b
VSCCoercion = case forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @v of
DualSpaceWitness v
DualSpaceWitness -> case forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
coerceFmapTensorProduct @(DualVector v) [] VSCCoercion s a b
VSCCoercion (Scalar (DualVector v)) a b
f of
Coercion
(TensorProduct (DualVector v) a) (TensorProduct (DualVector v) b)
Coercion -> VSCCoercion s (LinearMap s v a) (LinearMap s v b)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
instance Category (LinearFunction s) where
type Object (LinearFunction s) v = (TensorSpace v, Scalar v ~ s)
id :: forall a. Object (LinearFunction s) a => LinearFunction s a a
id = (a -> a) -> LinearFunction s a a
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction a -> a
forall a. Object (->) a => a -> a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id
LinearFunction b -> c
f . :: forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
. LinearFunction a -> b
g = (a -> c) -> LinearFunction s a c
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((a -> c) -> LinearFunction s a c)
-> (a -> c) -> LinearFunction s a c
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ b -> c
f(b -> c) -> (a -> b) -> a -> c
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
.a -> b
g
instance Num' s => Cartesian (LinearFunction s) where
type UnitObject (LinearFunction s) = ZeroDim s
swap :: forall a b.
(ObjectPair (LinearFunction s) a b,
ObjectPair (LinearFunction s) b a) =>
LinearFunction s (a, b) (b, a)
swap = ((a, b) -> (b, a)) -> LinearFunction s (a, b) (b, a)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (a, b) -> (b, a)
forall a b.
(ObjectPair (->) a b, ObjectPair (->) b a) =>
(a, b) -> (b, a)
forall (k :: Type -> Type -> Type) a b.
(Cartesian k, ObjectPair k a b, ObjectPair k b a) =>
k (a, b) (b, a)
swap
attachUnit :: forall unit a.
(unit ~ UnitObject (LinearFunction s),
ObjectPair (LinearFunction s) a unit) =>
LinearFunction s a (a, unit)
attachUnit = (a -> (a, unit)) -> LinearFunction s a (a, unit)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (, ZeroDim s
forall s. ZeroDim s
Origin)
detachUnit :: forall unit a.
(unit ~ UnitObject (LinearFunction s),
ObjectPair (LinearFunction s) a unit) =>
LinearFunction s (a, unit) a
detachUnit = ((a, unit) -> a) -> LinearFunction s (a, unit) a
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (a, unit) -> a
(a, ZeroDim s) -> a
forall x y. ObjectPair (->) x y => (x, y) -> x
forall (a :: Type -> Type -> Type) x y.
(PreArrow a, ObjectPair a x y) =>
a (x, y) x
fst
regroup :: forall a b c.
(ObjectPair (LinearFunction s) a b,
ObjectPair (LinearFunction s) b c,
ObjectPair (LinearFunction s) a (b, c),
ObjectPair (LinearFunction s) (a, b) c) =>
LinearFunction s (a, (b, c)) ((a, b), c)
regroup = ((a, (b, c)) -> ((a, b), c))
-> LinearFunction s (a, (b, c)) ((a, b), c)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (a, (b, c)) -> ((a, b), c)
forall a b c.
(ObjectPair (->) a b, ObjectPair (->) b c,
ObjectPair (->) a (b, c), ObjectPair (->) (a, b) c) =>
(a, (b, c)) -> ((a, b), c)
forall (k :: Type -> Type -> Type) a b c.
(Cartesian k, ObjectPair k a b, ObjectPair k b c,
ObjectPair k a (b, c), ObjectPair k (a, b) c) =>
k (a, (b, c)) ((a, b), c)
regroup
regroup' :: forall a b c.
(ObjectPair (LinearFunction s) a b,
ObjectPair (LinearFunction s) b c,
ObjectPair (LinearFunction s) a (b, c),
ObjectPair (LinearFunction s) (a, b) c) =>
LinearFunction s ((a, b), c) (a, (b, c))
regroup' = (((a, b), c) -> (a, (b, c)))
-> LinearFunction s ((a, b), c) (a, (b, c))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((a, b), c) -> (a, (b, c))
forall a b c.
(ObjectPair (->) a b, ObjectPair (->) b c,
ObjectPair (->) a (b, c), ObjectPair (->) (a, b) c) =>
((a, b), c) -> (a, (b, c))
forall (k :: Type -> Type -> Type) a b c.
(Cartesian k, ObjectPair k a b, ObjectPair k b c,
ObjectPair k a (b, c), ObjectPair k (a, b) c) =>
k ((a, b), c) (a, (b, c))
regroup'
instance Num' s => Morphism (LinearFunction s) where
LinearFunction b -> c
f*** :: forall b b' c c'.
(ObjectPair (LinearFunction s) b b',
ObjectPair (LinearFunction s) c c') =>
LinearFunction s b c
-> LinearFunction s b' c' -> LinearFunction s (b, b') (c, c')
***LinearFunction b' -> c'
g = ((b, b') -> (c, c')) -> LinearFunction s (b, b') (c, c')
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (((b, b') -> (c, c')) -> LinearFunction s (b, b') (c, c'))
-> ((b, b') -> (c, c')) -> LinearFunction s (b, b') (c, c')
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ b -> c
f(b -> c) -> (b' -> c') -> (b, b') -> (c, c')
forall b b' c c'.
(ObjectPair (->) b b', ObjectPair (->) c c') =>
(b -> c) -> (b' -> c') -> (b, b') -> (c, c')
forall (a :: Type -> Type -> Type) b b' c c'.
(Morphism a, ObjectPair a b b', ObjectPair a c c') =>
a b c -> a b' c' -> a (b, b') (c, c')
***b' -> c'
g
instance Num' s => PreArrow (LinearFunction s) where
LinearFunction b -> c
f&&& :: forall b c c'.
(Object (LinearFunction s) b,
ObjectPair (LinearFunction s) c c') =>
LinearFunction s b c
-> LinearFunction s b c' -> LinearFunction s b (c, c')
&&&LinearFunction b -> c'
g = (b -> (c, c')) -> LinearFunction s b (c, c')
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((b -> (c, c')) -> LinearFunction s b (c, c'))
-> (b -> (c, c')) -> LinearFunction s b (c, c')
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ b -> c
f(b -> c) -> (b -> c') -> b -> (c, c')
forall b c c'.
(Object (->) b, ObjectPair (->) c c') =>
(b -> c) -> (b -> c') -> b -> (c, c')
forall (a :: Type -> Type -> Type) b c c'.
(PreArrow a, Object a b, ObjectPair a c c') =>
a b c -> a b c' -> a b (c, c')
&&&b -> c'
g
fst :: forall x y.
ObjectPair (LinearFunction s) x y =>
LinearFunction s (x, y) x
fst = ((x, y) -> x) -> LinearFunction s (x, y) x
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (x, y) -> x
forall x y. ObjectPair (->) x y => (x, y) -> x
forall (a :: Type -> Type -> Type) x y.
(PreArrow a, ObjectPair a x y) =>
a (x, y) x
fst; snd :: forall x y.
ObjectPair (LinearFunction s) x y =>
LinearFunction s (x, y) y
snd = ((x, y) -> y) -> LinearFunction s (x, y) y
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (x, y) -> y
forall x y. ObjectPair (->) x y => (x, y) -> y
forall (a :: Type -> Type -> Type) x y.
(PreArrow a, ObjectPair a x y) =>
a (x, y) y
snd
terminal :: forall b.
Object (LinearFunction s) b =>
LinearFunction s b (UnitObject (LinearFunction s))
terminal = LinearFunction s b (UnitObject (LinearFunction s))
LinearFunction s b (ZeroDim s)
forall w s v. AdditiveGroup w => LinearFunction s v w
const0
instance EnhancedCat (->) (LinearFunction s) where
arr :: forall b c.
(Object (LinearFunction s) b, Object (LinearFunction s) c,
Object (->) b, Object (->) c) =>
LinearFunction s b c -> b -> c
arr = LinearFunction s b c -> b -> c
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction
instance EnhancedCat (LinearFunction s) (VSCCoercion s) where
arr :: forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
arr VSCCoercion s b c
VSCCoercion = (b -> c) -> LinearFunction s b c
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction b -> c
forall a b. Coercible a b => a -> b
coerce
instance (LinearSpace w, Num' s, Scalar w ~ s)
=> Functor (LinearFunction s w) (LinearFunction s) (LinearFunction s) where
fmap :: forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearFunction s w a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearFunction s w b)) =>
LinearFunction s a b
-> LinearFunction s (LinearFunction s w a) (LinearFunction s w b)
fmap LinearFunction s a b
f = (LinearFunction s w a -> LinearFunction s w b)
-> LinearFunction s (LinearFunction s w a) (LinearFunction s w b)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (LinearFunction s a b
fLinearFunction s a b
-> LinearFunction s w a -> LinearFunction s w b
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
.)
sampleLinearFunctionFn :: ( LinearSpace u, LinearSpace v, TensorSpace w
, Scalar u ~ Scalar v, Scalar v ~ Scalar w)
=> ((u-+>v)-+>w) -+> ((u+>v)+>w)
sampleLinearFunctionFn :: forall u v w.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ Scalar v,
Scalar v ~ Scalar w) =>
((u -+> v) -+> w) -+> ((u +> v) +> w)
sampleLinearFunctionFn = (LinearFunction (Scalar w) (LinearFunction (Scalar w) u v) w
-> LinearMap (Scalar w) (LinearMap (Scalar w) u v) w)
-> LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (LinearFunction (Scalar w) u v) w)
(LinearMap (Scalar w) (LinearMap (Scalar w) u v) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction (Scalar w) (LinearFunction (Scalar w) u v) w
-> LinearMap (Scalar w) (LinearMap (Scalar w) u v) w)
-> LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (LinearFunction (Scalar w) u v) w)
(LinearMap (Scalar w) (LinearMap (Scalar w) u v) w))
-> (LinearFunction (Scalar w) (LinearFunction (Scalar w) u v) w
-> LinearMap (Scalar w) (LinearMap (Scalar w) u v) w)
-> LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (LinearFunction (Scalar w) u v) w)
(LinearMap (Scalar w) (LinearMap (Scalar w) u v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction (Scalar w) (LinearFunction (Scalar w) u v) w
f -> LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (LinearMap (Scalar w) u v) w)
(LinearMap (Scalar w) (LinearMap (Scalar w) u v) w)
LinearFunction (Scalar w) (LinearMap (Scalar w) u v) w
-+> (LinearMap (Scalar w) u v +> w)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar (LinearMap (Scalar w) u v) ~ Scalar w) =>
(LinearMap (Scalar w) u v -+> w)
-+> (LinearMap (Scalar w) u v +> w)
sampleLinearFunction LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (LinearMap (Scalar w) u v) w)
(LinearMap (Scalar w) (LinearMap (Scalar w) u v) w)
-> LinearFunction (Scalar w) (LinearMap (Scalar w) u v) w
-> LinearMap (Scalar w) (LinearMap (Scalar w) u v) w
forall s v w. LinearFunction s v w -> v -> w
-+$> LinearFunction (Scalar w) (LinearFunction (Scalar w) u v) w
f LinearFunction (Scalar w) (LinearFunction (Scalar w) u v) w
-> LinearFunction
(Scalar w)
(LinearMap (Scalar w) u v)
(LinearFunction (Scalar w) u v)
-> LinearFunction (Scalar w) (LinearMap (Scalar w) u v) w
forall a b c.
(Object (LinearFunction (Scalar w)) a,
Object (LinearFunction (Scalar w)) b,
Object (LinearFunction (Scalar w)) c) =>
LinearFunction (Scalar w) b c
-> LinearFunction (Scalar w) a b -> LinearFunction (Scalar w) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar w)
(LinearMap (Scalar w) u v)
(LinearFunction (Scalar w) u v)
Bilinear (u +> v) u v
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
Bilinear (u +> w) u w
applyLinear
fromLinearFn :: ∀ s u v w . (DimensionAware u, DimensionAware v, DimensionAware w)
=> VSCCoercion s (LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
fromLinearFn :: forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
fromLinearFn
= Sing (StaticDimension u)
-> Sing (StaticDimension v)
-> ((ZipWithTimes (StaticDimension u) (StaticDimension v)
~ ZipWithTimes (StaticDimension v) (StaticDimension u)) =>
VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w))
-> VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
forall (a :: Maybe Nat) (b :: Maybe Nat) r.
Sing a
-> Sing b -> ((ZipWithTimes a b ~ ZipWithTimes b a) => r) -> r
Maybe.zipWithTimesCommu (forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u) (forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v) VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
(ZipWithTimes (StaticDimension u) (StaticDimension v)
~ ZipWithTimes (StaticDimension v) (StaticDimension u)) =>
VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
asLinearFn :: ∀ s u v w . (DimensionAware u, DimensionAware v, DimensionAware w)
=> VSCCoercion s (Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFn :: forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFn
= Sing (StaticDimension u)
-> Sing (StaticDimension v)
-> ((ZipWithTimes (StaticDimension u) (StaticDimension v)
~ ZipWithTimes (StaticDimension v) (StaticDimension u)) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w))
-> VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
forall (a :: Maybe Nat) (b :: Maybe Nat) r.
Sing a
-> Sing b -> ((ZipWithTimes a b ~ ZipWithTimes b a) => r) -> r
Maybe.zipWithTimesCommu (forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u) (forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v) VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
(ZipWithTimes (StaticDimension u) (StaticDimension v)
~ ZipWithTimes (StaticDimension v) (StaticDimension u)) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
instance ∀ s u v . ( LinearSpace u, LinearSpace v
, DimensionAware u, DimensionAware v
, Scalar u ~ s, Scalar v ~ s)
=> DimensionAware (LinearFunction s u v) where
type StaticDimension (LinearFunction s u v)
= Maybe.ZipWithTimes (StaticDimension u) (StaticDimension v)
dimensionalityWitness :: DimensionalityWitness (LinearFunction s u v)
dimensionalityWitness = case (forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @u, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v) of
(DimensionalityWitness u
IsStaticDimensional, DimensionalityWitness v
IsStaticDimensional)
-> SNat (n * n)
-> (KnownNat (n * n) =>
DimensionalityWitness (LinearFunction s u v))
-> DimensionalityWitness (LinearFunction s u v)
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @u Sing n -> Sing n -> Sing (Apply (Apply (*@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%* forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @v)
DimensionalityWitness (LinearFunction s u v)
KnownNat (n * n) => DimensionalityWitness (LinearFunction s u v)
forall (n :: Nat) v. Dimensional n v => DimensionalityWitness v
IsStaticDimensional
(DimensionalityWitness u
IsFlexibleDimensional, DimensionalityWitness v
_) -> DimensionalityWitness (LinearFunction s u v)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
(DimensionalityWitness u
_, DimensionalityWitness v
IsFlexibleDimensional) -> DimensionalityWitness (LinearFunction s u v)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
instance ∀ s n u m v nm . ( n`Dimensional`u, m`Dimensional`v
, LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s
, nm ~ (n*m) )
=> nm`Dimensional`(LinearFunction s u v) where
knownDimensionalitySing :: Sing nm
knownDimensionalitySing = forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @u Sing n -> Sing m -> Sing (Apply (Apply (*@#@$) n) m)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%* forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @v
unsafeFromArrayWithOffset :: forall (α :: Type -> Type).
Vector α (Scalar (LinearFunction s u v)) =>
Int -> α (Scalar (LinearFunction s u v)) -> LinearFunction s u v
unsafeFromArrayWithOffset Int
i α (Scalar (LinearFunction s u v))
ar
= LinearFunction s (LinearMap s u v) (LinearFunction s u v)
Bilinear (u +> v) u v
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
Bilinear (u +> w) u w
applyLinearLinearFunction s (LinearMap s u v) (LinearFunction s u v)
-> LinearMap s u v -> LinearFunction s u v
forall s v w. LinearFunction s v w -> v -> w
-+$>(Int -> α (Scalar (LinearMap s u v)) -> LinearMap s u v
forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
forall (α :: Type -> Type).
Vector α (Scalar (LinearMap s u v)) =>
Int -> α (Scalar (LinearMap s u v)) -> LinearMap s u v
unsafeFromArrayWithOffset Int
i α (Scalar (LinearFunction s u v))
α (Scalar (LinearMap s u v))
ar :: LinearMap s u v)
unsafeWriteArrayWithOffset :: forall (α :: Type -> Type) σ.
Vector α (Scalar (LinearFunction s u v)) =>
Mutable α σ (Scalar (LinearFunction s u v))
-> Int -> LinearFunction s u v -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (LinearFunction s u v))
ar Int
i
= Mutable α σ (Scalar (LinearMap s u v))
-> Int -> LinearMap s u v -> ST σ ()
forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
forall (α :: Type -> Type) σ.
Vector α (Scalar (LinearMap s u v)) =>
Mutable α σ (Scalar (LinearMap s u v))
-> Int -> LinearMap s u v -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (LinearFunction s u v))
Mutable α σ (Scalar (LinearMap s u v))
ar Int
i (LinearMap s u v -> ST σ ())
-> (LinearFunction s u v -> LinearMap s u v)
-> LinearFunction s u v
-> ST σ ()
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. (LinearFunction (Scalar v) (LinearFunction s u v) (LinearMap s u v)
(u -+> v) -+> (u +> v)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar u ~ Scalar w) =>
(u -+> w) -+> (u +> w)
sampleLinearFunctionLinearFunction (Scalar v) (LinearFunction s u v) (LinearMap s u v)
-> LinearFunction s u v -> LinearMap s u v
forall s v w. LinearFunction s v w -> v -> w
-+$>)
instance ∀ s u v . (LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s)
=> TensorSpace (LinearFunction s u v) where
type TensorProduct (LinearFunction s u v) w = LinearFunction s (LinearFunction s v u) w
scalarSpaceWitness :: ScalarSpaceWitness (LinearFunction s u v)
scalarSpaceWitness = case ( ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u
, ScalarSpaceWitness v
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness v ) of
(ScalarSpaceWitness u
ScalarSpaceWitness, ScalarSpaceWitness v
ScalarSpaceWitness) -> ScalarSpaceWitness (LinearFunction s u v)
forall v.
(Num' (Scalar v), Scalar (Scalar v) ~ Scalar v) =>
ScalarSpaceWitness v
ScalarSpaceWitness
linearManifoldWitness :: LinearManifoldWitness (LinearFunction s u v)
linearManifoldWitness = case ( LinearManifoldWitness u
forall v. TensorSpace v => LinearManifoldWitness v
linearManifoldWitness :: LinearManifoldWitness u
, LinearManifoldWitness v
forall v. TensorSpace v => LinearManifoldWitness v
linearManifoldWitness :: LinearManifoldWitness v ) of
( LinearManifoldWitness u
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
,LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
)
-> LinearManifoldWitness (LinearFunction s u v)
forall v.
(Needle v ~ v, AffineSpace v, Diff v ~ v) =>
LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
zeroTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) =>
LinearFunction s u v ⊗ w
zeroTensor = VSCCoercion
s
(LinearFunction s (LinearFunction s v u) w)
(Tensor s (LinearFunction s u v) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
fromLinearFn VSCCoercion
s
(LinearFunction s (LinearFunction s v u) w)
(Tensor s (LinearFunction s u v) w)
-> LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearFunction s (LinearFunction s v u) w
forall w s v. AdditiveGroup w => LinearFunction s v w
const0
toFlatTensor :: LinearFunction s u v
-+> (LinearFunction s u v ⊗ Scalar (LinearFunction s u v))
toFlatTensor = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> Coercion
(LinearFunction s (LinearFunction s v u) s)
(Tensor s (LinearFunction s u v) s)
-> Coercion
(LinearFunction
s
(LinearFunction s u v)
(LinearFunction s (LinearFunction s v u) s))
(LinearFunction
s (LinearFunction s u v) (Tensor s (LinearFunction s u v) s))
forall a b.
(Object Coercion a,
Object Coercion (LinearFunction s (LinearFunction s u v) a),
Object Coercion b,
Object Coercion (LinearFunction s (LinearFunction s u v) b)) =>
Coercion a b
-> Coercion
(LinearFunction s (LinearFunction s u v) a)
(LinearFunction s (LinearFunction s u v) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (VSCCoercion
s
(LinearFunction s (LinearFunction s v u) s)
(Tensor s (LinearFunction s u v) s)
-> Coercion
(LinearFunction s (LinearFunction s v u) s)
(Tensor s (LinearFunction s u v) s)
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion VSCCoercion
s
(LinearFunction s (LinearFunction s v u) s)
(Tensor s (LinearFunction s u v) s)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
fromLinearFn) Coercion
(LinearFunction
s
(LinearFunction s u v)
(LinearFunction s (LinearFunction s v u) s))
(LinearFunction
s (LinearFunction s u v) (Tensor s (LinearFunction s u v) s))
-> LinearFunction
s
(LinearFunction s u v)
(LinearFunction s (LinearFunction s v u) s)
-> LinearFunction
s (LinearFunction s u v) (Tensor s (LinearFunction s u v) s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction
s
(LinearFunction s u v)
(LinearFunction s (LinearFunction s v u) s)
Bilinear
(DualVector (LinearFunction s v u))
(LinearFunction s v u)
(Scalar (LinearFunction s v u))
forall v.
(LinearSpace v, LinearSpace v) =>
Bilinear (DualVector v) v (Scalar v)
applyDualVector
fromFlatTensor :: (LinearFunction s u v ⊗ Scalar (LinearFunction s u v))
-+> LinearFunction s u v
fromFlatTensor = case ( ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u
, DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u ) of
(ScalarSpaceWitness u
ScalarSpaceWitness, DualSpaceWitness u
DualSpaceWitness)
-> VSCCoercion
s
(Tensor s (LinearFunction s u v) s)
(LinearFunction s (LinearFunction s v u) s)
-> LinearFunction
s
(Tensor s (LinearFunction s u v) s)
(LinearFunction s (LinearFunction s v u) s)
forall b c.
(Object (VSCCoercion s) b, Object (VSCCoercion s) c,
Object (LinearFunction s) b, Object (LinearFunction s) c) =>
VSCCoercion s b c -> LinearFunction s b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr VSCCoercion
s
(Tensor s (LinearFunction s u v) s)
(LinearFunction s (LinearFunction s v u) s)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFn LinearFunction
s
(Tensor s (LinearFunction s u v) s)
(LinearFunction s (LinearFunction s v u) s)
-> LinearFunction
s
(LinearFunction s (LinearFunction s v u) s)
(LinearFunction s u v)
-> LinearFunction
s (Tensor s (LinearFunction s u v) s) (LinearFunction s u v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> (LinearFunction s (LinearFunction s v u) s -> LinearFunction s u v)
-> LinearFunction
s
(LinearFunction s (LinearFunction s v u) s)
(LinearFunction s u v)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction((LinearFunction s (LinearFunction s v u) s
-> LinearFunction s u v)
-> LinearFunction
s
(LinearFunction s (LinearFunction s v u) s)
(LinearFunction s u v))
-> (LinearFunction s (LinearFunction s v u) s
-> LinearFunction s u v)
-> LinearFunction
s
(LinearFunction s (LinearFunction s v u) s)
(LinearFunction s u v)
forall a. Object (->) a => a -> a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
`id`
\LinearFunction s (LinearFunction s v u) s
f -> let t :: Tensor (Scalar v) (DualVector u) v
t = LinearFunction
(Scalar v)
(Tensor (Scalar v) v (DualVector u))
(Tensor (Scalar v) (DualVector u) v)
Tensor (Scalar v) v (DualVector u) -+> (DualVector u ⊗ v)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor LinearFunction
(Scalar v)
(Tensor (Scalar v) v (DualVector u))
(Tensor (Scalar v) (DualVector u) v)
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) v (LinearMap (Scalar v) u (Scalar u)))
(Tensor (Scalar v) v (DualVector u))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) v (LinearMap (Scalar v) u (Scalar u)))
(Tensor (Scalar v) (DualVector u) v)
forall a b c.
(Object (LinearFunction (Scalar v)) a,
Object (LinearFunction (Scalar v)) b,
Object (LinearFunction (Scalar v)) c) =>
LinearFunction (Scalar v) b c
-> LinearFunction (Scalar v) a b -> LinearFunction (Scalar v) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. (LinearFunction
(Scalar v)
(LinearFunction
(Scalar v) (LinearMap (Scalar v) u (Scalar u)) (DualVector u))
(LinearFunction
(Scalar v)
(Tensor (Scalar v) v (LinearMap (Scalar v) u (Scalar u)))
(Tensor (Scalar v) v (DualVector u)))
Bilinear
(LinearMap (Scalar v) u (Scalar u) -+> DualVector u)
(Tensor (Scalar v) v (LinearMap (Scalar v) u (Scalar u)))
(Tensor (Scalar v) v (DualVector u))
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
fmapTensorLinearFunction
(Scalar v)
(LinearFunction
(Scalar v) (LinearMap (Scalar v) u (Scalar u)) (DualVector u))
(LinearFunction
(Scalar v)
(Tensor (Scalar v) v (LinearMap (Scalar v) u (Scalar u)))
(Tensor (Scalar v) v (DualVector u)))
-> LinearFunction
(Scalar v) (LinearMap (Scalar v) u (Scalar u)) (DualVector u)
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) v (LinearMap (Scalar v) u (Scalar u)))
(Tensor (Scalar v) v (DualVector u))
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction
(Scalar v) (LinearMap (Scalar v) u (Scalar u)) (DualVector u)
(u +> Scalar u) -+> DualVector u
forall v. LinearSpace v => (v +> Scalar v) -+> DualVector v
fromLinearForm)
LinearFunction
(Scalar v)
(Tensor (Scalar v) v (LinearMap (Scalar v) u (Scalar u)))
(Tensor (Scalar v) (DualVector u) v)
-> Tensor (Scalar v) v (LinearMap (Scalar v) u (Scalar u))
-> Tensor (Scalar v) (DualVector u) v
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
(Scalar v)
(LinearMap (Scalar v) (LinearMap (Scalar v) v u) (Scalar u))
(Tensor (Scalar v) v (LinearMap (Scalar v) u (Scalar u)))
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (LinearMap s u v) w) (Tensor s u (LinearMap s v w))
coCurryLinearMap
VSCCoercion
(Scalar v)
(LinearMap (Scalar v) (LinearMap (Scalar v) v u) (Scalar u))
(Tensor (Scalar v) v (LinearMap (Scalar v) u (Scalar u)))
-> LinearMap (Scalar v) (LinearMap (Scalar v) v u) (Scalar u)
-> Tensor (Scalar v) v (LinearMap (Scalar v) u (Scalar u))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction
(Scalar v)
(LinearFunction s (LinearMap s v u) s)
(LinearMap (Scalar v) (LinearMap (Scalar v) v u) (Scalar u))
(LinearMap (Scalar v) v u -+> Scalar u)
-+> (LinearMap (Scalar v) v u +> Scalar u)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar (LinearMap (Scalar v) v u) ~ Scalar w) =>
(LinearMap (Scalar v) v u -+> w)
-+> (LinearMap (Scalar v) v u +> w)
sampleLinearFunctionLinearFunction
(Scalar v)
(LinearFunction s (LinearMap s v u) s)
(LinearMap (Scalar v) (LinearMap (Scalar v) v u) (Scalar u))
-> LinearFunction s (LinearMap s v u) s
-> LinearMap (Scalar v) (LinearMap (Scalar v) v u) (Scalar u)
forall s v w. LinearFunction s v w -> v -> w
-+$> LinearFunction s (LinearFunction s v u) s
f LinearFunction s (LinearFunction s v u) s
-> LinearFunction s (LinearMap s v u) (LinearFunction s v u)
-> LinearFunction s (LinearMap s v u) s
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s (LinearMap s v u) (LinearFunction s v u)
Bilinear (LinearMap (Scalar v) v u) v u
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
applyLinear
in LinearFunction
(Scalar u) (LinearMap (Scalar u) u v) (LinearFunction s u v)
Bilinear (LinearMap (Scalar u) u v) u v
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
Bilinear (u +> w) u w
applyLinear LinearFunction
(Scalar u) (LinearMap (Scalar u) u v) (LinearFunction s u v)
-> LinearMap (Scalar u) u v -> LinearFunction s u v
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ VSCCoercion
(Scalar u)
(Tensor (Scalar u) (DualVector u) v)
(LinearMap (Scalar u) u v)
VSCCoercion
(Scalar u)
(Tensor (Scalar v) (DualVector u) v)
(LinearMap (Scalar u) u v)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar u)
(Tensor (Scalar v) (DualVector u) v)
(LinearMap (Scalar u) u v)
-> Tensor (Scalar v) (DualVector u) v -> LinearMap (Scalar u) u v
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) (DualVector u) v
t
addTensors :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) =>
(LinearFunction s u v ⊗ w)
-> (LinearFunction s u v ⊗ w) -> LinearFunction s u v ⊗ w
addTensors LinearFunction s u v ⊗ w
t LinearFunction s u v ⊗ w
s = VSCCoercion
s
(LinearFunction s (LinearFunction s v u) w)
(Tensor s (LinearFunction s u v) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
fromLinearFn VSCCoercion
s
(LinearFunction s (LinearFunction s v u) w)
(Tensor s (LinearFunction s u v) w)
-> LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=> (VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFnVSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>Tensor s (LinearFunction s u v) w
LinearFunction s u v ⊗ w
t)LinearFunction s (LinearFunction s v u) w
-> LinearFunction s (LinearFunction s v u) w
-> LinearFunction s (LinearFunction s v u) w
forall v. AdditiveGroup v => v -> v -> v
^+^(VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFnVSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>Tensor s (LinearFunction s u v) w
LinearFunction s u v ⊗ w
s)
subtractTensors :: forall w.
(TensorSpace (LinearFunction s u v), TensorSpace w,
Scalar w ~ Scalar (LinearFunction s u v)) =>
(LinearFunction s u v ⊗ w)
-> (LinearFunction s u v ⊗ w) -> LinearFunction s u v ⊗ w
subtractTensors LinearFunction s u v ⊗ w
t LinearFunction s u v ⊗ w
s = VSCCoercion
s
(LinearFunction s (LinearFunction s v u) w)
(Tensor s (LinearFunction s u v) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
fromLinearFn VSCCoercion
s
(LinearFunction s (LinearFunction s v u) w)
(Tensor s (LinearFunction s u v) w)
-> LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=> (VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFnVSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>Tensor s (LinearFunction s u v) w
LinearFunction s u v ⊗ w
t)LinearFunction s (LinearFunction s v u) w
-> LinearFunction s (LinearFunction s v u) w
-> LinearFunction s (LinearFunction s v u) w
forall v. AdditiveGroup v => v -> v -> v
^-^(VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFnVSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>Tensor s (LinearFunction s u v) w
LinearFunction s u v ⊗ w
s)
scaleTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) =>
Bilinear
(Scalar (LinearFunction s u v))
(LinearFunction s u v ⊗ w)
(LinearFunction s u v ⊗ w)
scaleTensor = (s
-> Tensor s (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) w)
-> LinearFunction
(Scalar s)
s
(LinearFunction
(Scalar s)
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) w))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((s
-> Tensor s (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) w)
-> LinearFunction
(Scalar s)
s
(LinearFunction
(Scalar s)
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) w)))
-> (s
-> Tensor s (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) w)
-> LinearFunction
(Scalar s)
s
(LinearFunction
(Scalar s)
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \s
μ (Tensor TensorProduct (LinearFunction s u v) w
f) -> LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w
TensorProduct (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w)
-> LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ s
Scalar (LinearFunction s (LinearFunction s v u) w)
μ Scalar (LinearFunction s (LinearFunction s v u) w)
-> LinearFunction s (LinearFunction s v u) w
-> LinearFunction s (LinearFunction s v u) w
forall v. VectorSpace v => Scalar v -> v -> v
*^ LinearFunction s (LinearFunction s v u) w
TensorProduct (LinearFunction s u v) w
f
negateTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) =>
(LinearFunction s u v ⊗ w) -+> (LinearFunction s u v ⊗ w)
negateTensor = (Tensor s (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) w)
-> LinearFunction
s
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor s (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) w)
-> LinearFunction
s
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) w))
-> (Tensor s (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) w)
-> LinearFunction
s
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Tensor TensorProduct (LinearFunction s u v) w
f) -> LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w
TensorProduct (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w)
-> LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction s (LinearFunction s v u) w
-> LinearFunction s (LinearFunction s v u) w
forall v. AdditiveGroup v => v -> v
negateV LinearFunction s (LinearFunction s v u) w
TensorProduct (LinearFunction s u v) w
f
tensorProduct :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) =>
Bilinear (LinearFunction s u v) w (LinearFunction s u v ⊗ w)
tensorProduct = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> (LinearFunction s u v -> w -> Tensor s (LinearFunction s u v) w)
-> LinearFunction
s
(LinearFunction s u v)
(LinearFunction s w (Tensor s (LinearFunction s u v) w))
(LinearFunction s u v -> w -> Tensor s (LinearFunction s u v) w)
-> Bilinear
(LinearFunction s u v) w (Tensor s (LinearFunction s u v) w)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction s u v -> w -> Tensor s (LinearFunction s u v) w)
-> LinearFunction
s
(LinearFunction s u v)
(LinearFunction s w (Tensor s (LinearFunction s u v) w)))
-> (LinearFunction s u v -> w -> Tensor s (LinearFunction s u v) w)
-> LinearFunction
s
(LinearFunction s u v)
(LinearFunction s w (Tensor s (LinearFunction s u v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction s u v
uv w
w -> LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w
TensorProduct (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w)
-> LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
(LinearFunction
s
(LinearFunction s u v)
(LinearFunction s (LinearFunction s v u) s)
Bilinear
(DualVector (LinearFunction s v u))
(LinearFunction s v u)
(Scalar (LinearFunction s v u))
forall v.
(LinearSpace v, LinearSpace v) =>
Bilinear (DualVector v) v (Scalar v)
applyDualVectorLinearFunction
s
(LinearFunction s u v)
(LinearFunction s (LinearFunction s v u) s)
-> LinearFunction s u v
-> LinearFunction s (LinearFunction s v u) s
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction s u v
uv) LinearFunction s (LinearFunction s v u) s
-> LinearFunction s s w
-> LinearFunction s (LinearFunction s v u) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> w -> LinearFunction s s w
forall v s.
(VectorSpace v, Scalar v ~ s) =>
v -> LinearFunction s s v
scaleV w
w
transposeTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) =>
(LinearFunction s u v ⊗ w) -+> (w ⊗ LinearFunction s u v)
transposeTensor = ScalarSpaceWitness u
-> DualSpaceWitness u
-> Tensor s (LinearFunction s u v) w
-+> Tensor s w (LinearFunction s u v)
forall w.
(TensorSpace w, Scalar w ~ s) =>
ScalarSpaceWitness u
-> DualSpaceWitness u
-> Tensor s (LinearFunction s u v) w
-+> Tensor s w (LinearFunction s u v)
tt ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness
where tt :: ∀ w . (TensorSpace w, Scalar w ~ s)
=> ScalarSpaceWitness u -> DualSpaceWitness u
-> Tensor s (LinearFunction s u v) w
-+> Tensor s w (LinearFunction s u v)
tt :: forall w.
(TensorSpace w, Scalar w ~ s) =>
ScalarSpaceWitness u
-> DualSpaceWitness u
-> Tensor s (LinearFunction s u v) w
-+> Tensor s w (LinearFunction s u v)
tt ScalarSpaceWitness u
ScalarSpaceWitness DualSpaceWitness u
DualSpaceWitness
= (Tensor s (LinearFunction s u v) w
-> Tensor s w (LinearFunction s u v))
-> LinearFunction
s
(Tensor s (LinearFunction s u v) w)
(Tensor s w (LinearFunction s u v))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor s (LinearFunction s u v) w
-> Tensor s w (LinearFunction s u v))
-> LinearFunction
s
(Tensor s (LinearFunction s u v) w)
(Tensor s w (LinearFunction s u v)))
-> (Tensor s (LinearFunction s u v) w
-> Tensor s w (LinearFunction s u v))
-> LinearFunction
s
(Tensor s (LinearFunction s u v) w)
(Tensor s w (LinearFunction s u v))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFnVSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>) (Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w)
-> (LinearFunction s (LinearFunction s v u) w
-> Tensor s w (LinearFunction s u v))
-> Tensor s (LinearFunction s u v) w
-> Tensor s w (LinearFunction s u v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> \LinearFunction (Scalar w) (LinearFunction (Scalar w) v u) w
f
-> (LinearFunction
(Scalar w)
(LinearFunction
(Scalar w)
(LinearMap (Scalar w) u v)
(LinearFunction (Scalar w) u v))
(LinearFunction
(Scalar w)
(Tensor (Scalar w) w (LinearMap (Scalar w) u v))
(Tensor (Scalar w) w (LinearFunction (Scalar w) u v)))
Bilinear
(LinearMap (Scalar w) u v -+> LinearFunction (Scalar w) u v)
(Tensor (Scalar w) w (LinearMap (Scalar w) u v))
(Tensor (Scalar w) w (LinearFunction (Scalar w) u v))
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar w,
Scalar x ~ Scalar w) =>
Bilinear (w -+> x) (w ⊗ w) (w ⊗ x)
fmapTensorLinearFunction
(Scalar w)
(LinearFunction
(Scalar w)
(LinearMap (Scalar w) u v)
(LinearFunction (Scalar w) u v))
(LinearFunction
(Scalar w)
(Tensor (Scalar w) w (LinearMap (Scalar w) u v))
(Tensor (Scalar w) w (LinearFunction (Scalar w) u v)))
-> LinearFunction
(Scalar w)
(LinearMap (Scalar w) u v)
(LinearFunction (Scalar w) u v)
-> LinearFunction
(Scalar w)
(Tensor (Scalar w) w (LinearMap (Scalar w) u v))
(Tensor (Scalar w) w (LinearFunction (Scalar w) u v))
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction
(Scalar w)
(LinearMap (Scalar w) u v)
(LinearFunction (Scalar w) u v)
Bilinear (LinearMap (Scalar u) u v) u v
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
Bilinear (u +> w) u w
applyLinear)
LinearFunction
(Scalar w)
(Tensor (Scalar w) w (LinearMap (Scalar w) u v))
(Tensor (Scalar w) w (LinearFunction (Scalar w) u v))
-> Tensor (Scalar w) w (LinearMap (Scalar w) u v)
-> Tensor (Scalar w) w (LinearFunction (Scalar w) u v)
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
(Scalar w)
(Tensor (Scalar w) (DualVector u) v)
(LinearMap (Scalar w) u v)
-> VSCCoercion
(Scalar w)
(Tensor (Scalar w) w (Tensor (Scalar w) (DualVector u) v))
(Tensor (Scalar w) w (LinearMap (Scalar w) u v))
forall a b.
(Object (VSCCoercion (Scalar w)) a,
Object (VSCCoercion (Scalar w)) (Tensor (Scalar w) w a),
Object (VSCCoercion (Scalar w)) b,
Object (VSCCoercion (Scalar w)) (Tensor (Scalar w) w b)) =>
VSCCoercion (Scalar w) a b
-> VSCCoercion
(Scalar w) (Tensor (Scalar w) w a) (Tensor (Scalar w) w b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion
(Scalar w)
(Tensor (Scalar w) (DualVector u) v)
(LinearMap (Scalar w) u v)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar w)
(Tensor (Scalar w) w (Tensor (Scalar w) (DualVector u) v))
(Tensor (Scalar w) w (LinearMap (Scalar w) u v))
-> VSCCoercion
(Scalar w)
(Tensor (Scalar w) (Tensor (Scalar w) w (DualVector u)) v)
(Tensor (Scalar w) w (Tensor (Scalar w) (DualVector u) v))
-> VSCCoercion
(Scalar w)
(Tensor (Scalar w) (Tensor (Scalar w) w (DualVector u)) v)
(Tensor (Scalar w) w (LinearMap (Scalar w) u v))
forall a b c.
(Object (VSCCoercion (Scalar w)) a,
Object (VSCCoercion (Scalar w)) b,
Object (VSCCoercion (Scalar w)) c) =>
VSCCoercion (Scalar w) b c
-> VSCCoercion (Scalar w) a b -> VSCCoercion (Scalar w) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar w)
(Tensor (Scalar w) (Tensor (Scalar w) w (DualVector u)) v)
(Tensor (Scalar w) w (Tensor (Scalar w) (DualVector u) v))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (Tensor s u v) w) (Tensor s u (Tensor s v w))
rassocTensor
VSCCoercion
(Scalar w)
(Tensor (Scalar w) (Tensor (Scalar w) w (DualVector u)) v)
(Tensor (Scalar w) w (LinearMap (Scalar w) u v))
-> Tensor (Scalar w) (Tensor (Scalar w) w (DualVector u)) v
-> Tensor (Scalar w) w (LinearMap (Scalar w) u v)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction
(Scalar w)
(Tensor (Scalar w) v (Tensor (Scalar w) w (DualVector u)))
(Tensor (Scalar w) (Tensor (Scalar w) w (DualVector u)) v)
(v ⊗ Tensor (Scalar w) w (DualVector u))
-+> (Tensor (Scalar w) w (DualVector u) ⊗ v)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor LinearFunction
(Scalar w)
(Tensor (Scalar w) v (Tensor (Scalar w) w (DualVector u)))
(Tensor (Scalar w) (Tensor (Scalar w) w (DualVector u)) v)
-> LinearFunction
(Scalar w)
(Tensor
(Scalar w) v (Tensor (Scalar (DualVector u)) (DualVector u) w))
(Tensor (Scalar w) v (Tensor (Scalar w) w (DualVector u)))
-> LinearFunction
(Scalar w)
(Tensor
(Scalar w) v (Tensor (Scalar (DualVector u)) (DualVector u) w))
(Tensor (Scalar w) (Tensor (Scalar w) w (DualVector u)) v)
forall a b c.
(Object (LinearFunction (Scalar w)) a,
Object (LinearFunction (Scalar w)) b,
Object (LinearFunction (Scalar w)) c) =>
LinearFunction (Scalar w) b c
-> LinearFunction (Scalar w) a b -> LinearFunction (Scalar w) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar (DualVector u))
(Tensor (Scalar (DualVector u)) (DualVector u) w)
(Tensor (Scalar w) w (DualVector u))
-> LinearFunction
(Scalar w)
(Tensor
(Scalar w) v (Tensor (Scalar (DualVector u)) (DualVector u) w))
(Tensor (Scalar w) v (Tensor (Scalar w) w (DualVector u)))
forall a b.
(Object (LinearFunction (Scalar (DualVector u))) a,
Object (LinearFunction (Scalar w)) (Tensor (Scalar w) v a),
Object (LinearFunction (Scalar (DualVector u))) b,
Object (LinearFunction (Scalar w)) (Tensor (Scalar w) v b)) =>
LinearFunction (Scalar (DualVector u)) a b
-> LinearFunction
(Scalar w) (Tensor (Scalar w) v a) (Tensor (Scalar w) v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap Tensor (Scalar (DualVector u)) (DualVector u) w
-+> Tensor (Scalar w) w (DualVector u)
LinearFunction
(Scalar (DualVector u))
(Tensor (Scalar (DualVector u)) (DualVector u) w)
(Tensor (Scalar w) w (DualVector u))
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector u)) =>
(DualVector u ⊗ w) -+> (w ⊗ DualVector u)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
(Scalar w)
(Tensor
(Scalar w) v (Tensor (Scalar (DualVector u)) (DualVector u) w))
(Tensor (Scalar w) (Tensor (Scalar w) w (DualVector u)) v)
-> Tensor
(Scalar w) v (Tensor (Scalar (DualVector u)) (DualVector u) w)
-> Tensor (Scalar w) (Tensor (Scalar w) w (DualVector u)) v
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
(Scalar w)
(LinearMap (Scalar w) u w)
(Tensor (Scalar (DualVector u)) (DualVector u) w)
-> VSCCoercion
(Scalar w)
(Tensor (Scalar w) v (LinearMap (Scalar w) u w))
(Tensor
(Scalar w) v (Tensor (Scalar (DualVector u)) (DualVector u) w))
forall a b.
(Object (VSCCoercion (Scalar w)) a,
Object (VSCCoercion (Scalar w)) (Tensor (Scalar w) v a),
Object (VSCCoercion (Scalar w)) b,
Object (VSCCoercion (Scalar w)) (Tensor (Scalar w) v b)) =>
VSCCoercion (Scalar w) a b
-> VSCCoercion
(Scalar w) (Tensor (Scalar w) v a) (Tensor (Scalar w) v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion
(Scalar w)
(LinearMap (Scalar w) u w)
(Tensor (Scalar w) (DualVector u) w)
VSCCoercion
(Scalar w)
(LinearMap (Scalar w) u w)
(Tensor (Scalar (DualVector u)) (DualVector u) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
(Scalar w)
(Tensor (Scalar w) v (LinearMap (Scalar w) u w))
(Tensor
(Scalar w) v (Tensor (Scalar (DualVector u)) (DualVector u) w))
-> VSCCoercion
(Scalar w)
(LinearMap (Scalar w) (LinearMap (Scalar w) v u) w)
(Tensor (Scalar w) v (LinearMap (Scalar w) u w))
-> VSCCoercion
(Scalar w)
(LinearMap (Scalar w) (LinearMap (Scalar w) v u) w)
(Tensor
(Scalar w) v (Tensor (Scalar (DualVector u)) (DualVector u) w))
forall a b c.
(Object (VSCCoercion (Scalar w)) a,
Object (VSCCoercion (Scalar w)) b,
Object (VSCCoercion (Scalar w)) c) =>
VSCCoercion (Scalar w) b c
-> VSCCoercion (Scalar w) a b -> VSCCoercion (Scalar w) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar w)
(LinearMap (Scalar w) (LinearMap (Scalar w) v u) w)
(Tensor (Scalar w) v (LinearMap (Scalar w) u w))
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (LinearMap s u v) w) (Tensor s u (LinearMap s v w))
coCurryLinearMap
VSCCoercion
(Scalar w)
(LinearMap (Scalar w) (LinearMap (Scalar w) v u) w)
(Tensor
(Scalar w) v (Tensor (Scalar (DualVector u)) (DualVector u) w))
-> LinearMap (Scalar w) (LinearMap (Scalar w) v u) w
-> Tensor
(Scalar w) v (Tensor (Scalar (DualVector u)) (DualVector u) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (LinearFunction (Scalar w) v u) w)
(LinearMap (Scalar w) (LinearMap (Scalar w) v u) w)
((v -+> u) -+> w) -+> (LinearMap (Scalar v) v u +> w)
forall u v w.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ Scalar v,
Scalar v ~ Scalar w) =>
((u -+> v) -+> w) -+> ((u +> v) +> w)
sampleLinearFunctionFn LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (LinearFunction (Scalar w) v u) w)
(LinearMap (Scalar w) (LinearMap (Scalar w) v u) w)
-> LinearFunction (Scalar w) (LinearFunction (Scalar w) v u) w
-> LinearMap (Scalar w) (LinearMap (Scalar w) v u) w
forall s v w. LinearFunction s v w -> v -> w
-+$> LinearFunction (Scalar w) (LinearFunction (Scalar w) v u) w
f
fmapTensor :: forall w x.
(TensorSpace w, TensorSpace x,
Scalar w ~ Scalar (LinearFunction s u v),
Scalar x ~ Scalar (LinearFunction s u v)) =>
Bilinear
(w -+> x) (LinearFunction s u v ⊗ w) (LinearFunction s u v ⊗ x)
fmapTensor = (LinearFunction s w x
-> Tensor s (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) x)
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction
s
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) x))
(LinearFunction s w x
-> Tensor s (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) x)
-> Bilinear
(LinearFunction s w x)
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) x)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction s w x
-> Tensor s (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) x)
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction
s
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) x)))
-> (LinearFunction s w x
-> Tensor s (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) x)
-> LinearFunction
s
(LinearFunction s w x)
(LinearFunction
s
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction s w x
f -> (VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFnVSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
(Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w)
-> (LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) x)
-> Tensor s (LinearFunction s u v) w
-> Tensor s (LinearFunction s u v) x
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> \LinearFunction s (LinearFunction s v u) w
g -> VSCCoercion
s
(LinearFunction s (LinearFunction s v u) x)
(Tensor s (LinearFunction s u v) x)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
fromLinearFn VSCCoercion
s
(LinearFunction s (LinearFunction s v u) x)
(Tensor s (LinearFunction s u v) x)
-> LinearFunction s (LinearFunction s v u) x
-> Tensor s (LinearFunction s u v) x
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearFunction s w x
f LinearFunction s w x
-> LinearFunction s (LinearFunction s v u) w
-> LinearFunction s (LinearFunction s v u) x
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s (LinearFunction s v u) w
g
fzipTensorWith :: forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (LinearFunction s u v),
Scalar w ~ Scalar (LinearFunction s u v),
Scalar x ~ Scalar (LinearFunction s u v)) =>
Bilinear
((w, x) -+> u)
(LinearFunction s u v ⊗ w, LinearFunction s u v ⊗ x)
(LinearFunction s u v ⊗ u)
fzipTensorWith = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> (LinearFunction s (w, x) u
-> (Tensor s (LinearFunction s u v) w,
Tensor s (LinearFunction s u v) x)
-> Tensor s (LinearFunction s u v) u)
-> LinearFunction
s
(LinearFunction s (w, x) u)
(LinearFunction
s
(Tensor s (LinearFunction s u v) w,
Tensor s (LinearFunction s u v) x)
(Tensor s (LinearFunction s u v) u))
(LinearFunction s (w, x) u
-> (Tensor s (LinearFunction s u v) w,
Tensor s (LinearFunction s u v) x)
-> Tensor s (LinearFunction s u v) u)
-> Bilinear
(LinearFunction s (w, x) u)
(Tensor s (LinearFunction s u v) w,
Tensor s (LinearFunction s u v) x)
(Tensor s (LinearFunction s u v) u)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction s (w, x) u
-> (Tensor s (LinearFunction s u v) w,
Tensor s (LinearFunction s u v) x)
-> Tensor s (LinearFunction s u v) u)
-> LinearFunction
s
(LinearFunction s (w, x) u)
(LinearFunction
s
(Tensor s (LinearFunction s u v) w,
Tensor s (LinearFunction s u v) x)
(Tensor s (LinearFunction s u v) u)))
-> (LinearFunction s (w, x) u
-> (Tensor s (LinearFunction s u v) w,
Tensor s (LinearFunction s u v) x)
-> Tensor s (LinearFunction s u v) u)
-> LinearFunction
s
(LinearFunction s (w, x) u)
(LinearFunction
s
(Tensor s (LinearFunction s u v) w,
Tensor s (LinearFunction s u v) x)
(Tensor s (LinearFunction s u v) u))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction s (w, x) u
f (Tensor s (LinearFunction s u v) w
g,Tensor s (LinearFunction s u v) x
h)
-> VSCCoercion
s
(LinearFunction s (LinearFunction s v u) u)
(Tensor s (LinearFunction s u v) u)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
fromLinearFn VSCCoercion
s
(LinearFunction s (LinearFunction s v u) u)
(Tensor s (LinearFunction s u v) u)
-> LinearFunction s (LinearFunction s v u) u
-> Tensor s (LinearFunction s u v) u
forall s a b. VSCCoercion s a b -> a -> b
-+$=>
LinearFunction s (w, x) u
f LinearFunction s (w, x) u
-> LinearFunction s (LinearFunction s v u) (w, x)
-> LinearFunction s (LinearFunction s v u) u
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. ((VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFnVSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>Tensor s (LinearFunction s u v) w
g)LinearFunction s (LinearFunction s v u) w
-> LinearFunction s (LinearFunction s v u) x
-> LinearFunction s (LinearFunction s v u) (w, x)
forall b c c'.
(Object (LinearFunction s) b,
ObjectPair (LinearFunction s) c c') =>
LinearFunction s b c
-> LinearFunction s b c' -> LinearFunction s b (c, c')
forall (a :: Type -> Type -> Type) b c c'.
(PreArrow a, Object a b, ObjectPair a c c') =>
a b c -> a b c' -> a b (c, c')
&&&(VSCCoercion
s
(Tensor s (LinearFunction s u v) x)
(LinearFunction s (LinearFunction s v u) x)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFnVSCCoercion
s
(Tensor s (LinearFunction s u v) x)
(LinearFunction s (LinearFunction s v u) x)
-> Tensor s (LinearFunction s u v) x
-> LinearFunction s (LinearFunction s v u) x
forall s a b. VSCCoercion s a b -> a -> b
-+$=>Tensor s (LinearFunction s u v) x
h))
tensorUnsafeFromArrayWithOffset :: ∀ nm w o α
. ( nm`Dimensional`LinearFunction s u v
, TensorSpace w, o`Dimensional`w, Scalar w ~ s
, GArr.Vector α s )
=> Int -> α s -> (LinearFunction s u v⊗w)
tensorUnsafeFromArrayWithOffset :: forall (nm :: Nat) w (o :: Nat) (α :: Type -> Type).
(Dimensional nm (LinearFunction s u v), TensorSpace w,
Dimensional o w, Scalar w ~ s, Vector α s) =>
Int -> α s -> LinearFunction s u v ⊗ w
tensorUnsafeFromArrayWithOffset
= case ( forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @u, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u
, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v ) of
( DimensionalityWitness u
IsStaticDimensional, SJust Sing n
sn
,DimensionalityWitness v
IsStaticDimensional, SJust Sing n
sm )
-> SNat (n * n)
-> (KnownNat (n * n) =>
Int -> α s -> Tensor s (LinearFunction s u v) w)
-> Int
-> α s
-> Tensor s (LinearFunction s u v) w
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (Sing n
Sing n
smSing n -> Sing n -> Sing (Apply (Apply (*@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*Sing n
Sing n
sn) (
SNat ((n * n) * o)
-> (KnownNat ((n * n) * o) =>
Int -> α s -> Tensor s (LinearFunction s u v) w)
-> Int
-> α s
-> Tensor s (LinearFunction s u v) w
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat ((Sing n
Sing n
smSing n -> Sing n -> Sing (Apply (Apply (*@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*Sing n
Sing n
sn)Sing (n * n) -> Sing o -> Sing (Apply (Apply (*@#@$) (n * n)) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w) (
\Int
i -> (forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
fromLinearFn @s @v @u @w VSCCoercion
s
(LinearFunction s (LinearFunction s v u) w)
(Tensor s (LinearFunction s u v) w)
-> LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
(LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w)
-> (α s -> LinearFunction s (LinearFunction s v u) w)
-> α s
-> Tensor s (LinearFunction s u v) w
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. (LinearFunction
s
(LinearMap s (LinearFunction s v u) w)
(LinearFunction s (LinearFunction s v u) w)
Bilinear (LinearFunction s v u +> w) (LinearFunction s v u) w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearFunction s v u)) =>
Bilinear (LinearFunction s v u +> w) (LinearFunction s v u) w
applyLinearLinearFunction
s
(LinearMap s (LinearFunction s v u) w)
(LinearFunction s (LinearFunction s v u) w)
-> LinearMap s (LinearFunction s v u) w
-> LinearFunction s (LinearFunction s v u) w
forall s v w. LinearFunction s v w -> v -> w
-+$>)
(LinearMap s (LinearFunction s v u) w
-> LinearFunction s (LinearFunction s v u) w)
-> (α s -> LinearMap s (LinearFunction s v u) w)
-> α s
-> LinearFunction s (LinearFunction s v u) w
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Int
-> α (Scalar (LinearMap s (LinearFunction s v u) w))
-> LinearMap s (LinearFunction s v u) w
forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
forall (α :: Type -> Type).
Vector α (Scalar (LinearMap s (LinearFunction s v u) w)) =>
Int
-> α (Scalar (LinearMap s (LinearFunction s v u) w))
-> LinearMap s (LinearFunction s v u) w
unsafeFromArrayWithOffset Int
i ))
tensorUnsafeWriteArrayWithOffset :: ∀ nm w o α σ
. ( nm`Dimensional`LinearFunction s u v
, TensorSpace w, o`Dimensional`w, Scalar w ~ s
, GArr.Vector α s )
=> GArr.Mutable α σ s -> Int -> (LinearFunction s u v⊗w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset :: forall (nm :: Nat) w (o :: Nat) (α :: Type -> Type) σ.
(Dimensional nm (LinearFunction s u v), TensorSpace w,
Dimensional o w, Scalar w ~ s, Vector α s) =>
Mutable α σ s -> Int -> (LinearFunction s u v ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset
= case ( forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @u, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u
, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v, forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v ) of
( DimensionalityWitness u
IsStaticDimensional, SJust Sing n
sn
,DimensionalityWitness v
IsStaticDimensional, SJust Sing n
sm )
-> SNat (n * n)
-> (KnownNat (n * n) =>
Mutable α σ s
-> Int -> Tensor s (LinearFunction s u v) w -> ST σ ())
-> Mutable α σ s
-> Int
-> Tensor s (LinearFunction s u v) w
-> ST σ ()
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (Sing n
Sing n
smSing n -> Sing n -> Sing (Apply (Apply (*@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*Sing n
Sing n
sn) (
SNat ((n * n) * o)
-> (KnownNat ((n * n) * o) =>
Mutable α σ s
-> Int -> Tensor s (LinearFunction s u v) w -> ST σ ())
-> Mutable α σ s
-> Int
-> Tensor s (LinearFunction s u v) w
-> ST σ ()
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat ((Sing n
Sing n
smSing n -> Sing n -> Sing (Apply (Apply (*@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*Sing n
Sing n
sn)Sing (n * n) -> Sing o -> Sing (Apply (Apply (*@#@$) (n * n)) o)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (*@#@$) t1) t2)
%*forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @w) (
\Mutable α σ (Scalar (LinearMap s (LinearFunction s v u) w))
ar Int
i -> Mutable α σ (Scalar (LinearMap s (LinearFunction s v u) w))
-> Int -> LinearMap s (LinearFunction s v u) w -> ST σ ()
forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
forall (α :: Type -> Type) σ.
Vector α (Scalar (LinearMap s (LinearFunction s v u) w)) =>
Mutable α σ (Scalar (LinearMap s (LinearFunction s v u) w))
-> Int -> LinearMap s (LinearFunction s v u) w -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (LinearMap s (LinearFunction s v u) w))
ar Int
i
(LinearMap s (LinearFunction s v u) w -> ST σ ())
-> (Tensor s (LinearFunction s u v) w
-> LinearMap s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> ST σ ()
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. (LinearFunction
(Scalar w)
(LinearFunction s (LinearFunction s v u) w)
(LinearMap s (LinearFunction s v u) w)
(LinearFunction s v u -+> w) -+> (LinearFunction s v u +> w)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar (LinearFunction s v u) ~ Scalar w) =>
(LinearFunction s v u -+> w) -+> (LinearFunction s v u +> w)
sampleLinearFunctionLinearFunction
(Scalar w)
(LinearFunction s (LinearFunction s v u) w)
(LinearMap s (LinearFunction s v u) w)
-> LinearFunction s (LinearFunction s v u) w
-> LinearMap s (LinearFunction s v u) w
forall s v w. LinearFunction s v w -> v -> w
-+$>)
(LinearFunction s (LinearFunction s v u) w
-> LinearMap s (LinearFunction s v u) w)
-> (Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> LinearMap s (LinearFunction s v u) w
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. (forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFn @s @u @v @w VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
))
coerceFmapTensorProduct :: forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a,
Scalar a ~ Scalar (LinearFunction s u v), TensorSpace b,
Scalar b ~ Scalar (LinearFunction s u v)) =>
p (LinearFunction s u v)
-> VSCCoercion (Scalar (LinearFunction s u v)) a b
-> Coercion
(TensorProduct (LinearFunction s u v) a)
(TensorProduct (LinearFunction s u v) b)
coerceFmapTensorProduct p (LinearFunction s u v)
_ VSCCoercion (Scalar (LinearFunction s u v)) a b
VSCCoercion = Coercion
(LinearFunction s (LinearFunction s v u) a)
(LinearFunction s (LinearFunction s v u) b)
Coercion
(TensorProduct (LinearFunction s u v) a)
(TensorProduct (LinearFunction s u v) b)
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion
wellDefinedVector :: LinearFunction s u v -> Maybe (LinearFunction s u v)
wellDefinedVector = LinearFunction (Scalar v) (LinearFunction s u v) (LinearMap s u v)
-> LinearFunction s u v -> LinearMap s u v
forall b c.
(Object (LinearFunction (Scalar v)) b,
Object (LinearFunction (Scalar v)) c, Object (->) b,
Object (->) c) =>
LinearFunction (Scalar v) b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr LinearFunction (Scalar v) (LinearFunction s u v) (LinearMap s u v)
(u -+> v) -+> LinearMap (Scalar u) u v
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar u ~ Scalar w) =>
(u -+> w) -+> (u +> w)
sampleLinearFunction (LinearFunction s u v -> LinearMap s u v)
-> (LinearMap s u v -> Maybe (LinearFunction s u v))
-> LinearFunction s u v
-> Maybe (LinearFunction s u v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearMap s u v -> Maybe (LinearMap s u v)
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector
(LinearMap s u v -> Maybe (LinearMap s u v))
-> (Maybe (LinearMap s u v) -> Maybe (LinearFunction s u v))
-> LinearMap s u v
-> Maybe (LinearFunction s u v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> (LinearMap s u v -> LinearFunction s u v)
-> Maybe (LinearMap s u v) -> Maybe (LinearFunction s u v)
forall a b.
(Object (->) a, Object (->) (Maybe a), Object (->) b,
Object (->) (Maybe b)) =>
(a -> b) -> Maybe a -> Maybe b
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (LinearFunction (Scalar u) (LinearMap s u v) (LinearFunction s u v)
-> LinearMap s u v -> LinearFunction s u v
forall b c.
(Object (LinearFunction (Scalar u)) b,
Object (LinearFunction (Scalar u)) c, Object (->) b,
Object (->) c) =>
LinearFunction (Scalar u) b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr LinearFunction (Scalar u) (LinearMap s u v) (LinearFunction s u v)
Bilinear (LinearMap (Scalar u) u v) u v
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
Bilinear (u +> w) u w
applyLinear)
wellDefinedTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) =>
(LinearFunction s u v ⊗ w) -> Maybe (LinearFunction s u v ⊗ w)
wellDefinedTensor = (VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFnVSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>) (Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w)
-> (LinearFunction s (LinearFunction s v u) w
-> Maybe (Tensor s (LinearFunction s u v) w))
-> Tensor s (LinearFunction s u v) w
-> Maybe (Tensor s (LinearFunction s u v) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> (LinearFunction s (LinearFunction s v u) w
-> LinearFunction s (LinearMap s v u) (LinearFunction s v u)
-> LinearFunction s (LinearMap s v u) w
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s (LinearMap s v u) (LinearFunction s v u)
Bilinear (LinearMap (Scalar v) v u) v u
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
applyLinear)
(LinearFunction s (LinearFunction s v u) w
-> LinearFunction s (LinearMap s v u) w)
-> (LinearFunction s (LinearMap s v u) w
-> Maybe (Tensor s (LinearFunction s u v) w))
-> LinearFunction s (LinearFunction s v u) w
-> Maybe (Tensor s (LinearFunction s u v) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar w)
(LinearFunction s (LinearMap s v u) w)
(LinearMap s (LinearMap s v u) w)
-> LinearFunction s (LinearMap s v u) w
-> LinearMap s (LinearMap s v u) w
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar w)
(LinearFunction s (LinearMap s v u) w)
(LinearMap s (LinearMap s v u) w)
(LinearMap s v u -+> w) -+> (LinearMap s v u +> w)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar (LinearMap s v u) ~ Scalar w) =>
(LinearMap s v u -+> w) -+> (LinearMap s v u +> w)
sampleLinearFunction
(LinearFunction s (LinearMap s v u) w
-> LinearMap s (LinearMap s v u) w)
-> (LinearMap s (LinearMap s v u) w
-> Maybe (Tensor s (LinearFunction s u v) w))
-> LinearFunction s (LinearMap s v u) w
-> Maybe (Tensor s (LinearFunction s u v) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearMap s (LinearMap s v u) w
-> Maybe (LinearMap s (LinearMap s v u) w)
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector
(LinearMap s (LinearMap s v u) w
-> Maybe (LinearMap s (LinearMap s v u) w))
-> (Maybe (LinearMap s (LinearMap s v u) w)
-> Maybe (Tensor s (LinearFunction s u v) w))
-> LinearMap s (LinearMap s v u) w
-> Maybe (Tensor s (LinearFunction s u v) w)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> (LinearMap s (LinearMap s v u) w
-> Tensor s (LinearFunction s u v) w)
-> Maybe (LinearMap s (LinearMap s v u) w)
-> Maybe (Tensor s (LinearFunction s u v) w)
forall a b.
(Object (->) a, Object (->) (Maybe a), Object (->) b,
Object (->) (Maybe b)) =>
(a -> b) -> Maybe a -> Maybe b
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap ((VSCCoercion
s
(LinearFunction s (LinearFunction s v u) w)
(Tensor s (LinearFunction s u v) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(Tensor s (LinearFunction s v u) w)
fromLinearFnVSCCoercion
s
(LinearFunction s (LinearFunction s v u) w)
(Tensor s (LinearFunction s u v) w)
-> LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>) (LinearFunction s (LinearFunction s v u) w
-> Tensor s (LinearFunction s u v) w)
-> (LinearMap s (LinearMap s v u) w
-> LinearFunction s (LinearFunction s v u) w)
-> LinearMap s (LinearMap s v u) w
-> Tensor s (LinearFunction s u v) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< \LinearMap (Scalar u) (LinearMap (Scalar u) v u) w
m
-> LinearFunction (Scalar u) (v -+> u) (LinearMap (Scalar u) v u)
(v -+> u) -+> LinearMap (Scalar v) v u
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
sampleLinearFunction
LinearFunction (Scalar u) (v -+> u) (LinearMap (Scalar u) v u)
-> LinearFunction (Scalar u) (LinearMap (Scalar u) v u) w
-> LinearFunction (Scalar u) (v -+> u) w
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar u)
(LinearMap (Scalar u) (LinearMap (Scalar u) v u) w)
(LinearFunction (Scalar u) (LinearMap (Scalar u) v u) w)
-> LinearMap (Scalar u) (LinearMap (Scalar u) v u) w
-> LinearFunction (Scalar u) (LinearMap (Scalar u) v u) w
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar u)
(LinearMap (Scalar u) (LinearMap (Scalar u) v u) w)
(LinearFunction (Scalar u) (LinearMap (Scalar u) v u) w)
Bilinear
(LinearMap (Scalar u) v u +> w) (LinearMap (Scalar u) v u) w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap (Scalar u) v u)) =>
Bilinear
(LinearMap (Scalar u) v u +> w) (LinearMap (Scalar u) v u) w
applyLinear LinearMap (Scalar u) (LinearMap (Scalar u) v u) w
m)
exposeLinearFn :: VSCCoercion s (LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
exposeLinearFn :: forall s u v w.
VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
exposeLinearFn = VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
instance (LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s)
=> LinearSpace (LinearFunction s u v) where
type DualVector (LinearFunction s u v) = LinearFunction s v u
dualSpaceWitness :: DualSpaceWitness (LinearFunction s u v)
dualSpaceWitness = case ( DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness u
, DualSpaceWitness v
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness v ) of
(DualSpaceWitness u
DualSpaceWitness, DualSpaceWitness v
DualSpaceWitness)
-> Sing (StaticDimension u)
-> Sing (StaticDimension v)
-> ((ZipWithTimes (StaticDimension u) (StaticDimension v)
~ ZipWithTimes (StaticDimension v) (StaticDimension u)) =>
DualSpaceWitness (LinearFunction s u v))
-> DualSpaceWitness (LinearFunction s u v)
forall (a :: Maybe Nat) (b :: Maybe Nat) r.
Sing a
-> Sing b -> ((ZipWithTimes a b ~ ZipWithTimes b a) => r) -> r
Maybe.zipWithTimesCommu (forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @u) (forall v. DimensionAware v => Sing (StaticDimension v)
staticDimensionSing @v)
DualSpaceWitness (LinearFunction s u v)
(ZipWithTimes (StaticDimension u) (StaticDimension v)
~ ZipWithTimes (StaticDimension v) (StaticDimension u)) =>
DualSpaceWitness (LinearFunction s u v)
forall v.
(LinearSpace (Scalar v), DualVector (Scalar v) ~ Scalar v,
LinearSpace (DualVector v), Scalar (DualVector v) ~ Scalar v,
DualVector (DualVector v) ~ v,
StaticDimension (DualVector v) ~ StaticDimension v) =>
DualSpaceWitness v
DualSpaceWitness
linearId :: LinearFunction s u v +> LinearFunction s u v
linearId = VSCCoercion
s
(LinearMap s (LinearFunction s u v) (LinearFunction s u v))
(LinearFunction s (LinearFunction s u v) (LinearFunction s u v))
-> VSCCoercion
s
(LinearFunction s (LinearFunction s u v) (LinearFunction s u v))
(LinearMap s (LinearFunction s u v) (LinearFunction s u v))
forall s a b. VSCCoercion s a b -> VSCCoercion s b a
symVSC VSCCoercion
s
(LinearMap s (LinearFunction s u v) (LinearFunction s u v))
(LinearFunction s (LinearFunction s u v) (LinearFunction s u v))
forall s u v w.
VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
exposeLinearFn VSCCoercion
s
(LinearFunction s (LinearFunction s u v) (LinearFunction s u v))
(LinearMap s (LinearFunction s u v) (LinearFunction s u v))
-> LinearFunction s (LinearFunction s u v) (LinearFunction s u v)
-> LinearMap s (LinearFunction s u v) (LinearFunction s u v)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction s (LinearFunction s u v) (LinearFunction s u v)
forall a. Object (LinearFunction s) a => LinearFunction s a a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
id
tensorId :: forall w.
(LinearSpace w, Scalar w ~ Scalar (LinearFunction s u v)) =>
(LinearFunction s u v ⊗ w) +> (LinearFunction s u v ⊗ w)
tensorId = VSCCoercion
s
(LinearMap
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
(LinearMap
s
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) w))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMap VSCCoercion
s
(LinearMap
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
(LinearMap
s
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) w))
-> VSCCoercion
s
(LinearFunction
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
(LinearMap
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
-> VSCCoercion
s
(LinearFunction
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
(LinearMap
s
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) w))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearMap
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
(LinearFunction
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
-> VSCCoercion
s
(LinearFunction
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
(LinearMap
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
forall s a b. VSCCoercion s a b -> VSCCoercion s b a
symVSC VSCCoercion
s
(LinearMap
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
(LinearFunction
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
forall s u v w.
VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
exposeLinearFn
VSCCoercion
s
(LinearFunction
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
(LinearMap
s
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) w))
-> LinearFunction
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w))
-> LinearMap
s
(Tensor s (LinearFunction s u v) w)
(Tensor s (LinearFunction s u v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (LinearFunction s u v
-> LinearMap s w (Tensor s (LinearFunction s u v) w))
-> LinearFunction
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction s u v
-> LinearMap s w (Tensor s (LinearFunction s u v) w))
-> LinearFunction
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w)))
-> (LinearFunction s u v
-> LinearMap s w (Tensor s (LinearFunction s u v) w))
-> LinearFunction
s
(LinearFunction s u v)
(LinearMap s w (Tensor s (LinearFunction s u v) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction s u v
f -> LinearFunction
(Scalar (Tensor s (LinearFunction s u v) w))
(LinearFunction
(Scalar (Tensor s (LinearFunction s u v) w))
w
(Tensor s (LinearFunction s u v) w))
(LinearMap s w (Tensor s (LinearFunction s u v) w))
LinearFunction
(Scalar (Tensor s (LinearFunction s u v) w))
w
(Tensor s (LinearFunction s u v) w)
-+> (w +> Tensor s (LinearFunction s u v) w)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar w ~ Scalar w) =>
(w -+> w) -+> (w +> w)
sampleLinearFunctionLinearFunction
(Scalar (Tensor s (LinearFunction s u v) w))
(LinearFunction
(Scalar (Tensor s (LinearFunction s u v) w))
w
(Tensor s (LinearFunction s u v) w))
(LinearMap s w (Tensor s (LinearFunction s u v) w))
-> LinearFunction
(Scalar (Tensor s (LinearFunction s u v) w))
w
(Tensor s (LinearFunction s u v) w)
-> LinearMap s w (Tensor s (LinearFunction s u v) w)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction
s
(LinearFunction s u v)
(LinearFunction
(Scalar (Tensor s (LinearFunction s u v) w))
w
(Tensor s (LinearFunction s u v) w))
Bilinear
(LinearFunction s u v)
w
(Tensor (Scalar (LinearFunction s u v)) (LinearFunction s u v) w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) =>
Bilinear (LinearFunction s u v) w (LinearFunction s u v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductLinearFunction
s
(LinearFunction s u v)
(LinearFunction
(Scalar (Tensor s (LinearFunction s u v) w))
w
(Tensor s (LinearFunction s u v) w))
-> LinearFunction s u v
-> LinearFunction
(Scalar (Tensor s (LinearFunction s u v) w))
w
(Tensor s (LinearFunction s u v) w)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction s u v
f
coerceDoubleDual :: VSCCoercion
(Scalar (LinearFunction s u v))
(LinearFunction s u v)
(DualVector (DualVector (LinearFunction s u v)))
coerceDoubleDual = VSCCoercion s (LinearFunction s u v) (LinearFunction s u v)
VSCCoercion
(Scalar (LinearFunction s u v))
(LinearFunction s u v)
(DualVector (DualVector (LinearFunction s u v)))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
sampleLinearFunction :: forall w.
(TensorSpace w, Scalar (LinearFunction s u v) ~ Scalar w) =>
(LinearFunction s u v -+> w) -+> (LinearFunction s u v +> w)
sampleLinearFunction = (LinearFunction s (LinearFunction s u v) w
-> LinearMap s (LinearFunction s u v) w)
-> LinearFunction
s
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction s (LinearFunction s u v) w
-> LinearMap s (LinearFunction s u v) w)
-> LinearFunction
s
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w))
-> (VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w)
-> LinearFunction s (LinearFunction s u v) w
-> LinearMap s (LinearFunction s u v) w)
-> VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w)
-> LinearFunction
s
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w)
-> LinearFunction s (LinearFunction s u v) w
-> LinearMap s (LinearFunction s u v) w
forall s a b. VSCCoercion s a b -> a -> b
(-+$=>) (VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w)
-> LinearFunction
s
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w))
-> VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w)
-> LinearFunction
s
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
-> VSCCoercion
s
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w)
forall s a b. VSCCoercion s a b -> VSCCoercion s b a
symVSC VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
forall s u v w.
VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
exposeLinearFn
applyDualVector :: LinearSpace (LinearFunction s u v) =>
Bilinear
(DualVector (LinearFunction s u v))
(LinearFunction s u v)
(Scalar (LinearFunction s u v))
applyDualVector = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> (LinearFunction s v u -> LinearFunction s u v -> s)
-> LinearFunction
s
(LinearFunction s v u)
(LinearFunction s (LinearFunction s u v) s)
(LinearFunction s v u -> LinearFunction s u v -> s)
-> Bilinear (LinearFunction s v u) (LinearFunction s u v) s
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction s v u -> LinearFunction s u v -> s)
-> LinearFunction
s
(LinearFunction s v u)
(LinearFunction s (LinearFunction s u v) s))
-> (LinearFunction s v u -> LinearFunction s u v -> s)
-> LinearFunction
s
(LinearFunction s v u)
(LinearFunction s (LinearFunction s u v) s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction s v u
f LinearFunction s u v
g -> LinearFunction (Scalar (Scalar u)) (LinearMap (Scalar u) u u) s
LinearMap (Scalar u) u u -+> Scalar u
forall v. LinearSpace v => LinearMap (Scalar v) v v -+> Scalar v
trace LinearFunction (Scalar (Scalar u)) (LinearMap (Scalar u) u u) s
-> LinearFunction
(Scalar (Scalar u))
(LinearFunction s u u)
(LinearMap (Scalar u) u u)
-> LinearFunction (Scalar (Scalar u)) (LinearFunction s u u) s
forall a b c.
(Object (LinearFunction (Scalar (Scalar u))) a,
Object (LinearFunction (Scalar (Scalar u))) b,
Object (LinearFunction (Scalar (Scalar u))) c) =>
LinearFunction (Scalar (Scalar u)) b c
-> LinearFunction (Scalar (Scalar u)) a b
-> LinearFunction (Scalar (Scalar u)) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar (Scalar u))
(LinearFunction s u u)
(LinearMap (Scalar u) u u)
(u -+> u) -+> LinearMap (Scalar u) u u
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar u ~ Scalar w) =>
(u -+> w) -+> (u +> w)
sampleLinearFunction LinearFunction (Scalar (Scalar u)) (LinearFunction s u u) s
-> LinearFunction s u u -> s
forall s v w. LinearFunction s v w -> v -> w
-+$> LinearFunction s v u
f LinearFunction s v u
-> LinearFunction s u v -> LinearFunction s u u
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s u v
g
applyLinear :: forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) =>
Bilinear (LinearFunction s u v +> w) (LinearFunction s u v) w
applyLinear = (LinearMap s (LinearFunction s u v) w -> LinearFunction s u v -> w)
-> LinearFunction
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
(LinearMap s (LinearFunction s u v) w -> LinearFunction s u v -> w)
-> Bilinear
(LinearMap s (LinearFunction s u v) w) (LinearFunction s u v) w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s (LinearFunction s u v) w
-> LinearFunction s u v -> w)
-> LinearFunction
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w))
-> (LinearMap s (LinearFunction s u v) w
-> LinearFunction s u v -> w)
-> LinearFunction
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearMap s (LinearFunction s u v) w
f LinearFunction s u v
g -> (VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
forall s u v w.
VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
exposeLinearFn VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
-> LinearMap s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s u v) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearMap s (LinearFunction s u v) w
f) LinearFunction s (LinearFunction s u v) w
-> LinearFunction s u v -> w
forall s v w. LinearFunction s v w -> v -> w
-+$> LinearFunction s u v
g
applyTensorFunctional :: forall u.
(LinearSpace u, Scalar u ~ Scalar (LinearFunction s u v)) =>
Bilinear
(DualVector (LinearFunction s u v ⊗ u))
(LinearFunction s u v ⊗ u)
(Scalar (LinearFunction s u v))
applyTensorFunctional = ScalarSpaceWitness u
-> DualSpaceWitness u
-> LinearFunction
s
(LinearMap s (LinearFunction s u v) (DualVector u))
(LinearFunction s (Tensor s (LinearFunction s u v) u) s)
forall w.
(LinearSpace w, Scalar w ~ s) =>
ScalarSpaceWitness u
-> DualSpaceWitness w
-> LinearFunction
s
(LinearMap s (LinearFunction s u v) (DualVector w))
(LinearFunction s (Tensor s (LinearFunction s u v) w) s)
atf ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness DualSpaceWitness u
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness
where atf :: ∀ w . (LinearSpace w, Scalar w ~ s)
=> ScalarSpaceWitness u -> DualSpaceWitness w
-> LinearFunction s
(LinearMap s (LinearFunction s u v) (DualVector w))
(LinearFunction s (Tensor s (LinearFunction s u v) w) s)
atf :: forall w.
(LinearSpace w, Scalar w ~ s) =>
ScalarSpaceWitness u
-> DualSpaceWitness w
-> LinearFunction
s
(LinearMap s (LinearFunction s u v) (DualVector w))
(LinearFunction s (Tensor s (LinearFunction s u v) w) s)
atf ScalarSpaceWitness u
ScalarSpaceWitness DualSpaceWitness w
DualSpaceWitness = (LinearMap s (LinearFunction s u v) (DualVector w)
-> Tensor s (LinearFunction s u v) w -> s)
-> LinearFunction
s
(LinearMap s (LinearFunction s u v) (DualVector w))
(LinearFunction s (Tensor s (LinearFunction s u v) w) s)
(LinearMap s (LinearFunction s u v) (DualVector w)
-> Tensor s (LinearFunction s u v) w -> s)
-> Bilinear
(LinearMap s (LinearFunction s u v) (DualVector w))
(Tensor s (LinearFunction s u v) w)
s
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s (LinearFunction s u v) (DualVector w)
-> Tensor s (LinearFunction s u v) w -> s)
-> LinearFunction
s
(LinearMap s (LinearFunction s u v) (DualVector w))
(LinearFunction s (Tensor s (LinearFunction s u v) w) s))
-> (LinearMap s (LinearFunction s u v) (DualVector w)
-> Tensor s (LinearFunction s u v) w -> s)
-> LinearFunction
s
(LinearMap s (LinearFunction s u v) (DualVector w))
(LinearFunction s (Tensor s (LinearFunction s u v) w) s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearMap s (LinearFunction s u v) (DualVector w)
f Tensor s (LinearFunction s u v) w
g
-> LinearFunction (Scalar (Scalar w)) (LinearMap (Scalar w) w w) s
LinearMap (Scalar w) w w -+> Scalar w
forall v. LinearSpace v => LinearMap (Scalar v) v v -+> Scalar v
trace LinearFunction (Scalar (Scalar w)) (LinearMap (Scalar w) w w) s
-> LinearMap (Scalar w) w w -> s
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
(Scalar w) (Tensor s (DualVector w) w) (LinearMap (Scalar w) w w)
VSCCoercion
(Scalar w)
(Tensor (Scalar w) (DualVector w) w)
(LinearMap (Scalar w) w w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar w) (Tensor s (DualVector w) w) (LinearMap (Scalar w) w w)
-> Tensor s (DualVector w) w -> LinearMap (Scalar w) w w
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearFunction
(Scalar w) (Tensor s w (DualVector w)) (Tensor s (DualVector w) w)
(w ⊗ DualVector w) -+> (DualVector w ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar w) =>
(w ⊗ w) -+> (w ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
(Scalar w) (Tensor s w (DualVector w)) (Tensor s (DualVector w) w)
-> Tensor s w (DualVector w) -> Tensor s (DualVector w) w
forall s v w. LinearFunction s v w -> v -> w
-+$> LinearFunction s (LinearMap s u v) (DualVector w)
-> LinearFunction
s (Tensor s w (LinearMap s u v)) (Tensor s w (DualVector w))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s w a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s w b)) =>
LinearFunction s a b
-> LinearFunction s (Tensor s w a) (Tensor s w b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap ((VSCCoercion
s
(LinearMap s (LinearFunction s u v) (DualVector w))
(LinearFunction s (LinearFunction s u v) (DualVector w))
forall s u v w.
VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
exposeLinearFn VSCCoercion
s
(LinearMap s (LinearFunction s u v) (DualVector w))
(LinearFunction s (LinearFunction s u v) (DualVector w))
-> LinearMap s (LinearFunction s u v) (DualVector w)
-> LinearFunction s (LinearFunction s u v) (DualVector w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s (LinearFunction s u v) (DualVector w)
f) LinearFunction s (LinearFunction s u v) (DualVector w)
-> LinearFunction s (LinearMap s u v) (LinearFunction s u v)
-> LinearFunction s (LinearMap s u v) (DualVector w)
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s (LinearMap s u v) (LinearFunction s u v)
Bilinear (u +> v) u v
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
Bilinear (u +> w) u w
applyLinear)
LinearFunction
s (Tensor s w (LinearMap s u v)) (Tensor s w (DualVector w))
-> Tensor s w (LinearMap s u v) -> Tensor s w (DualVector w)
forall s v w. LinearFunction s v w -> v -> w
-+$> ( LinearFunction
s (Tensor s (LinearMap s u v) w) (Tensor s w (LinearMap s u v))
(LinearMap s u v ⊗ w) -+> (w ⊗ LinearMap s u v)
forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) =>
(LinearMap s u v ⊗ w) -+> (w ⊗ LinearMap s u v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
s (Tensor s (LinearMap s u v) w) (Tensor s w (LinearMap s u v))
-> Tensor s (LinearMap s u v) w -> Tensor s w (LinearMap s u v)
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
-> LinearMap s u (Tensor s v w) -> Tensor s (LinearMap s u v) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearFunction s (Tensor s w v) (Tensor s v w)
-> LinearFunction
s (LinearMap s u (Tensor s w v)) (LinearMap s u (Tensor s v w))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s u a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s u b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s u a) (LinearMap s u b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction s (Tensor s w v) (Tensor s v w)
(w ⊗ v) -+> (v ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar w) =>
(w ⊗ w) -+> (w ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
s (LinearMap s u (Tensor s w v)) (LinearMap s u (Tensor s v w))
-> LinearMap s u (Tensor s w v) -> LinearMap s u (Tensor s v w)
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
s (Tensor s (LinearMap s u w) v) (LinearMap s u (Tensor s w v))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap
VSCCoercion
s (Tensor s (LinearMap s u w) v) (LinearMap s u (Tensor s w v))
-> Tensor s (LinearMap s u w) v -> LinearMap s u (Tensor s w v)
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearFunction
s (Tensor s v (LinearMap s u w)) (Tensor s (LinearMap s u w) v)
(v ⊗ LinearMap s u w) -+> (LinearMap s u w ⊗ v)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
s (Tensor s v (LinearMap s u w)) (Tensor s (LinearMap s u w) v)
-> Tensor s v (LinearMap s u w) -> Tensor s (LinearMap s u w) v
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
s (LinearMap s (LinearMap s v u) w) (Tensor s v (LinearMap s u w))
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (LinearMap s u v) w) (Tensor s u (LinearMap s v w))
coCurryLinearMap
VSCCoercion
s (LinearMap s (LinearMap s v u) w) (Tensor s v (LinearMap s u w))
-> LinearMap s (LinearMap s v u) w -> Tensor s v (LinearMap s u w)
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearFunction
s
(LinearFunction s (LinearFunction s v u) w)
(LinearMap s (LinearMap s v u) w)
((v -+> u) -+> w) -+> ((v +> u) +> w)
forall u v w.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ Scalar v,
Scalar v ~ Scalar w) =>
((u -+> v) -+> w) -+> ((u +> v) +> w)
sampleLinearFunctionFn
LinearFunction
s
(LinearFunction s (LinearFunction s v u) w)
(LinearMap s (LinearMap s v u) w)
-> LinearFunction s (LinearFunction s v u) w
-> LinearMap s (LinearMap s v u) w
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFn VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
-> Tensor s (LinearFunction s u v) w
-> LinearFunction s (LinearFunction s v u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=> Tensor s (LinearFunction s u v) w
g )
applyTensorLinMap :: forall u w.
(LinearSpace u, TensorSpace w,
Scalar u ~ Scalar (LinearFunction s u v),
Scalar w ~ Scalar (LinearFunction s u v)) =>
Bilinear
((LinearFunction s u v ⊗ u) +> w) (LinearFunction s u v ⊗ u) w
applyTensorLinMap = case ScalarSpaceWitness u
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness u of
ScalarSpaceWitness u
ScalarSpaceWitness -> (LinearMap s (Tensor s (LinearFunction s u v) u) w
-> Tensor s (LinearFunction s u v) u -> w)
-> LinearFunction
s
(LinearMap s (Tensor s (LinearFunction s u v) u) w)
(LinearFunction s (Tensor s (LinearFunction s u v) u) w)
(LinearMap s (Tensor s (LinearFunction s u v) u) w
-> Tensor s (LinearFunction s u v) u -> w)
-> Bilinear
(LinearMap s (Tensor s (LinearFunction s u v) u) w)
(Tensor s (LinearFunction s u v) u)
w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s (Tensor s (LinearFunction s u v) u) w
-> Tensor s (LinearFunction s u v) u -> w)
-> LinearFunction
s
(LinearMap s (Tensor s (LinearFunction s u v) u) w)
(LinearFunction s (Tensor s (LinearFunction s u v) u) w))
-> (LinearMap s (Tensor s (LinearFunction s u v) u) w
-> Tensor s (LinearFunction s u v) u -> w)
-> LinearFunction
s
(LinearMap s (Tensor s (LinearFunction s u v) u) w)
(LinearFunction s (Tensor s (LinearFunction s u v) u) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearMap s (Tensor s (LinearFunction s u v) u) w
f Tensor s (LinearFunction s u v) u
g
-> LinearFunction s (Tensor s u (LinearMap s u w)) w
(u ⊗ (u +> w)) -+> w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ (v +> w)) -+> w
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u ⊗ (u +> w)) -+> w
contractMapTensor LinearFunction s (Tensor s u (LinearMap s u w)) w
-> LinearFunction
s (Tensor s (LinearMap s u w) u) (Tensor s u (LinearMap s u w))
-> LinearFunction s (Tensor s (LinearMap s u w) u) w
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
s (Tensor s (LinearMap s u w) u) (Tensor s u (LinearMap s u w))
(LinearMap s u w ⊗ u) -+> (u ⊗ LinearMap s u w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s u w)) =>
(LinearMap s u w ⊗ w) -+> (w ⊗ LinearMap s u w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction s (Tensor s (LinearMap s u w) u) w
-> Tensor s (LinearMap s u w) u -> w
forall s v w. LinearFunction s v w -> v -> w
-+$> LinearFunction s (LinearMap s v u) u
-> LinearFunction
s
(Tensor s (LinearMap s u w) (LinearMap s v u))
(Tensor s (LinearMap s u w) u)
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (Tensor s (LinearMap s u w) a),
Object (LinearFunction s) b,
Object (LinearFunction s) (Tensor s (LinearMap s u w) b)) =>
LinearFunction s a b
-> LinearFunction
s (Tensor s (LinearMap s u w) a) (Tensor s (LinearMap s u w) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap ((VSCCoercion
s
(Tensor s (LinearFunction s u v) u)
(LinearFunction s (LinearFunction s v u) u)
forall s u v w.
(DimensionAware u, DimensionAware v, DimensionAware w) =>
VSCCoercion
s
(Tensor s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s v u) w)
asLinearFnVSCCoercion
s
(Tensor s (LinearFunction s u v) u)
(LinearFunction s (LinearFunction s v u) u)
-> Tensor s (LinearFunction s u v) u
-> LinearFunction s (LinearFunction s v u) u
forall s a b. VSCCoercion s a b -> a -> b
-+$=>Tensor s (LinearFunction s u v) u
g) LinearFunction s (LinearFunction s v u) u
-> LinearFunction s (LinearMap s v u) (LinearFunction s v u)
-> LinearFunction s (LinearMap s v u) u
forall a b c.
(Object (LinearFunction s) a, Object (LinearFunction s) b,
Object (LinearFunction s) c) =>
LinearFunction s b c
-> LinearFunction s a b -> LinearFunction s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction s (LinearMap s v u) (LinearFunction s v u)
Bilinear (v +> u) v u
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
applyLinear)
LinearFunction
s
(Tensor s (LinearMap s u w) (LinearMap s v u))
(Tensor s (LinearMap s u w) u)
-> Tensor s (LinearMap s u w) (LinearMap s v u)
-> Tensor s (LinearMap s u w) u
forall s v w. LinearFunction s v w -> v -> w
-+$> ( LinearFunction
s
(Tensor s (LinearMap s v u) (LinearMap s u w))
(Tensor s (LinearMap s u w) (LinearMap s v u))
(LinearMap s v u ⊗ LinearMap s u w)
-+> (LinearMap s u w ⊗ LinearMap s v u)
forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s v u)) =>
(LinearMap s v u ⊗ w) -+> (w ⊗ LinearMap s v u)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
s
(Tensor s (LinearMap s v u) (LinearMap s u w))
(Tensor s (LinearMap s u w) (LinearMap s v u))
-> Tensor s (LinearMap s v u) (LinearMap s u w)
-> Tensor s (LinearMap s u w) (LinearMap s v u)
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
s
(LinearMap s v (Tensor s u (LinearMap s u w)))
(Tensor s (LinearMap s v u) (LinearMap s u w))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (LinearMap s u (Tensor s v w)) (Tensor s (LinearMap s u v) w)
deferLinearMap
VSCCoercion
s
(LinearMap s v (Tensor s u (LinearMap s u w)))
(Tensor s (LinearMap s v u) (LinearMap s u w))
-> LinearMap s v (Tensor s u (LinearMap s u w))
-> Tensor s (LinearMap s v u) (LinearMap s u w)
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearFunction
s (Tensor s (LinearMap s u w) u) (Tensor s u (LinearMap s u w))
-> LinearFunction
s
(LinearMap s v (Tensor s (LinearMap s u w) u))
(LinearMap s v (Tensor s u (LinearMap s u w)))
forall a b.
(Object (LinearFunction s) a,
Object (LinearFunction s) (LinearMap s v a),
Object (LinearFunction s) b,
Object (LinearFunction s) (LinearMap s v b)) =>
LinearFunction s a b
-> LinearFunction s (LinearMap s v a) (LinearMap s v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap LinearFunction
s (Tensor s (LinearMap s u w) u) (Tensor s u (LinearMap s u w))
(LinearMap s u w ⊗ u) -+> (u ⊗ LinearMap s u w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (LinearMap s u w)) =>
(LinearMap s u w ⊗ w) -+> (w ⊗ LinearMap s u w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
s
(LinearMap s v (Tensor s (LinearMap s u w) u))
(LinearMap s v (Tensor s u (LinearMap s u w)))
-> LinearMap s v (Tensor s (LinearMap s u w) u)
-> LinearMap s v (Tensor s u (LinearMap s u w))
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
s
(Tensor s (LinearMap s v (LinearMap s u w)) u)
(LinearMap s v (Tensor s (LinearMap s u w) u))
forall s u v w.
(TensorSpace u, TensorSpace v, TensorSpace w) =>
VSCCoercion
s (Tensor s (LinearMap s u v) w) (LinearMap s u (Tensor s v w))
hasteLinearMap
VSCCoercion
s
(Tensor s (LinearMap s v (LinearMap s u w)) u)
(LinearMap s v (Tensor s (LinearMap s u w) u))
-> Tensor s (LinearMap s v (LinearMap s u w)) u
-> LinearMap s v (Tensor s (LinearMap s u w) u)
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearFunction
s
(Tensor s u (LinearMap s v (LinearMap s u w)))
(Tensor s (LinearMap s v (LinearMap s u w)) u)
(u ⊗ LinearMap s v (LinearMap s u w))
-+> (LinearMap s v (LinearMap s u w) ⊗ u)
forall w.
(TensorSpace w, Scalar w ~ Scalar u) =>
(u ⊗ w) -+> (w ⊗ u)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
LinearFunction
s
(Tensor s u (LinearMap s v (LinearMap s u w)))
(Tensor s (LinearMap s v (LinearMap s u w)) u)
-> Tensor s u (LinearMap s v (LinearMap s u w))
-> Tensor s (LinearMap s v (LinearMap s u w)) u
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
s
(LinearMap s (LinearMap s u v) (LinearMap s u w))
(Tensor s u (LinearMap s v (LinearMap s u w)))
forall s u v w.
(LinearSpace u, Scalar u ~ s, LinearSpace v, Scalar v ~ s,
TensorSpace w, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (LinearMap s u v) w) (Tensor s u (LinearMap s v w))
coCurryLinearMap
VSCCoercion
s
(LinearMap s (LinearMap s u v) (LinearMap s u w))
(Tensor s u (LinearMap s v (LinearMap s u w)))
-> LinearMap s (LinearMap s u v) (LinearMap s u w)
-> Tensor s u (LinearMap s v (LinearMap s u w))
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearFunction
s
(LinearFunction s (LinearFunction s u v) (LinearMap s u w))
(LinearMap s (LinearMap s u v) (LinearMap s u w))
((u -+> v) -+> LinearMap s u w) -+> ((u +> v) +> LinearMap s u w)
forall u v w.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ Scalar v,
Scalar v ~ Scalar w) =>
((u -+> v) -+> w) -+> ((u +> v) +> w)
sampleLinearFunctionFn
LinearFunction
s
(LinearFunction s (LinearFunction s u v) (LinearMap s u w))
(LinearMap s (LinearMap s u v) (LinearMap s u w))
-> LinearFunction s (LinearFunction s u v) (LinearMap s u w)
-> LinearMap s (LinearMap s u v) (LinearMap s u w)
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
s
(LinearMap s (LinearFunction s u v) (LinearMap s u w))
(LinearFunction s (LinearFunction s u v) (LinearMap s u w))
forall s u v w.
VSCCoercion
s
(LinearMap s (LinearFunction s u v) w)
(LinearFunction s (LinearFunction s u v) w)
exposeLinearFn
VSCCoercion
s
(LinearMap s (LinearFunction s u v) (LinearMap s u w))
(LinearFunction s (LinearFunction s u v) (LinearMap s u w))
-> LinearMap s (LinearFunction s u v) (LinearMap s u w)
-> LinearFunction s (LinearFunction s u v) (LinearMap s u w)
forall s a b. VSCCoercion s a b -> a -> b
-+$=> VSCCoercion
s
(LinearMap s (Tensor s (LinearFunction s u v) u) w)
(LinearMap s (LinearFunction s u v) (LinearMap s u w))
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s (Tensor s u v) w) (LinearMap s u (LinearMap s v w))
curryLinearMap VSCCoercion
s
(LinearMap s (Tensor s (LinearFunction s u v) u) w)
(LinearMap s (LinearFunction s u v) (LinearMap s u w))
-> LinearMap s (Tensor s (LinearFunction s u v) u) w
-> LinearMap s (LinearFunction s u v) (LinearMap s u w)
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearMap s (Tensor s (LinearFunction s u v) u) w
f )
useTupleLinearSpaceComponents :: forall x y φ.
(LinearFunction s u v ~ (x, y)) =>
((LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ) -> φ
useTupleLinearSpaceComponents (LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ
_ = φ
forall a. a
usingNonTupleTypeAsTupleError
instance (TensorSpace u, TensorSpace v, s~Scalar u, s~Scalar v)
=> AffineSpace (Tensor s u v) where
type Diff (Tensor s u v) = Tensor s u v
.-. :: Tensor s u v -> Tensor s u v -> Diff (Tensor s u v)
(.-.) = Tensor s u v -> Tensor s u v -> Diff (Tensor s u v)
Tensor s u v -> Tensor s u v -> Tensor s u v
forall v. AdditiveGroup v => v -> v -> v
(^-^)
.+^ :: Tensor s u v -> Diff (Tensor s u v) -> Tensor s u v
(.+^) = Tensor s u v -> Diff (Tensor s u v) -> Tensor s u v
Tensor s u v -> Tensor s u v -> Tensor s u v
forall v. AdditiveGroup v => v -> v -> v
(^+^)
instance (LinearSpace u, TensorSpace v, s~Scalar u, s~Scalar v)
=> AffineSpace (LinearMap s u v) where
type Diff (LinearMap s u v) = LinearMap s u v
.-. :: LinearMap s u v -> LinearMap s u v -> Diff (LinearMap s u v)
(.-.) = LinearMap s u v -> LinearMap s u v -> Diff (LinearMap s u v)
LinearMap s u v -> LinearMap s u v -> LinearMap s u v
forall v. AdditiveGroup v => v -> v -> v
(^-^)
.+^ :: LinearMap s u v -> Diff (LinearMap s u v) -> LinearMap s u v
(.+^) = LinearMap s u v -> Diff (LinearMap s u v) -> LinearMap s u v
LinearMap s u v -> LinearMap s u v -> LinearMap s u v
forall v. AdditiveGroup v => v -> v -> v
(^+^)
instance (TensorSpace u, TensorSpace v, s~Scalar u, s~Scalar v)
=> AffineSpace (LinearFunction s u v) where
type Diff (LinearFunction s u v) = LinearFunction s u v
.-. :: LinearFunction s u v
-> LinearFunction s u v -> Diff (LinearFunction s u v)
(.-.) = LinearFunction s u v
-> LinearFunction s u v -> Diff (LinearFunction s u v)
LinearFunction s u v
-> LinearFunction s u v -> LinearFunction s u v
forall v. AdditiveGroup v => v -> v -> v
(^-^)
.+^ :: LinearFunction s u v
-> Diff (LinearFunction s u v) -> LinearFunction s u v
(.+^) = LinearFunction s u v
-> Diff (LinearFunction s u v) -> LinearFunction s u v
LinearFunction s u v
-> LinearFunction s u v -> LinearFunction s u v
forall v. AdditiveGroup v => v -> v -> v
(^+^)
lfun :: ( EnhancedCat f (LinearFunction s)
, LinearSpace u, TensorSpace v, Scalar u ~ s, Scalar v ~ s
, Object f u, Object f v ) => (u->v) -> f u v
lfun :: forall (f :: Type -> Type -> Type) s u v.
(EnhancedCat f (LinearFunction s), LinearSpace u, TensorSpace v,
Scalar u ~ s, Scalar v ~ s, Object f u, Object f v) =>
(u -> v) -> f u v
lfun = LinearFunction s u v -> f u v
forall b c.
(Object (LinearFunction s) b, Object (LinearFunction s) c,
Object f b, Object f c) =>
LinearFunction s b c -> f b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (LinearFunction s u v -> f u v)
-> ((u -> v) -> LinearFunction s u v) -> (u -> v) -> f u v
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. (u -> v) -> LinearFunction s u v
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction
genericTensorspaceError :: a
genericTensorspaceError :: forall a. a
genericTensorspaceError = [Char] -> a
forall a. HasCallStack => [Char] -> a
error [Char]
"GHC.Generics types can not be used as tensor spaces."
usingNonTupleTypeAsTupleError :: a
usingNonTupleTypeAsTupleError :: forall a. a
usingNonTupleTypeAsTupleError = [Char] -> a
forall a. HasCallStack => [Char] -> a
error [Char]
"This is not a tuple type, the method should not be callable."
instance ∀ v s . DimensionAware v => DimensionAware (Gnrx.Rec0 v s) where
type StaticDimension (Gnrx.Rec0 v s) = StaticDimension v
dimensionalityWitness :: DimensionalityWitness (Rec0 v s)
dimensionalityWitness = case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v of
DimensionalityWitness v
IsStaticDimensional -> DimensionalityWitness (Rec0 v s)
forall (n :: Nat) v. Dimensional n v => DimensionalityWitness v
IsStaticDimensional
DimensionalityWitness v
IsFlexibleDimensional -> DimensionalityWitness (Rec0 v s)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
instance ∀ n v s . n`Dimensional`v => n`Dimensional`(Gnrx.Rec0 v s) where
knownDimensionalitySing :: Sing n
knownDimensionalitySing = forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @v
unsafeFromArrayWithOffset :: forall (α :: Type -> Type).
Vector α (Scalar (Rec0 v s)) =>
Int -> α (Scalar (Rec0 v s)) -> Rec0 v s
unsafeFromArrayWithOffset Int
i α (Scalar (Rec0 v s))
ar
= v -> Rec0 v s
forall a b. Coercible a b => a -> b
coerce (forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
unsafeFromArrayWithOffset @n @v Int
i α (Scalar v)
α (Scalar (Rec0 v s))
ar)
unsafeWriteArrayWithOffset :: forall (α :: Type -> Type) σ.
Vector α (Scalar (Rec0 v s)) =>
Mutable α σ (Scalar (Rec0 v s)) -> Int -> Rec0 v s -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (Rec0 v s))
i Int
ar
= (v -> ST σ ()) -> Rec0 v s -> ST σ ()
forall a b. Coercible a b => a -> b
coerce (forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
unsafeWriteArrayWithOffset @n @v Mutable α σ (Scalar v)
Mutable α σ (Scalar (Rec0 v s))
i Int
ar)
instance ∀ v s . TensorSpace v => TensorSpace (Gnrx.Rec0 v s) where
type TensorProduct (Gnrx.Rec0 v s) w = TensorProduct v w
wellDefinedVector :: Rec0 v s -> Maybe (Rec0 v s)
wellDefinedVector = (v -> Rec0 v s) -> Maybe v -> Maybe (Rec0 v s)
forall a b.
(Object (->) a, Object (->) (Maybe a), Object (->) b,
Object (->) (Maybe b)) =>
(a -> b) -> Maybe a -> Maybe b
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1 (Maybe v -> Maybe (Rec0 v s))
-> (Rec0 v s -> Maybe v) -> Rec0 v s -> Maybe (Rec0 v s)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. v -> Maybe v
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector (v -> Maybe v) -> (Rec0 v s -> v) -> Rec0 v s -> Maybe v
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Rec0 v s -> v
forall k i c (p :: k). K1 i c p -> c
Gnrx.unK1
wellDefinedTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) =>
(Rec0 v s ⊗ w) -> Maybe (Rec0 v s ⊗ w)
wellDefinedTensor = Coercion
(Maybe (Tensor (Scalar v) v w))
(Maybe (Tensor (Scalar v) (Rec0 v s) w))
-> Maybe (Tensor (Scalar v) v w)
-> Maybe (Tensor (Scalar v) (Rec0 v s) w)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (Coercion (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> Coercion
(Maybe (Tensor (Scalar v) v w))
(Maybe (Tensor (Scalar v) (Rec0 v s) w))
forall a b.
(Object Coercion a, Object Coercion (Maybe a), Object Coercion b,
Object Coercion (Maybe b)) =>
Coercion a b -> Coercion (Maybe a) (Maybe b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (Coercion (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> Coercion
(Maybe (Tensor (Scalar v) v w))
(Maybe (Tensor (Scalar v) (Rec0 v s) w)))
-> (VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> Coercion
(Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w))
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> Coercion
(Maybe (Tensor (Scalar v) v w))
(Maybe (Tensor (Scalar v) (Rec0 v s) w))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> Coercion
(Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion (VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> Coercion
(Maybe (Tensor (Scalar v) v w))
(Maybe (Tensor (Scalar v) (Rec0 v s) w)))
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> Coercion
(Maybe (Tensor (Scalar v) v w))
(Maybe (Tensor (Scalar v) (Rec0 v s) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (v -> Rec0 v s)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1)
(Maybe (Tensor (Scalar v) v w)
-> Maybe (Tensor (Scalar v) (Rec0 v s) w))
-> (Tensor (Scalar v) (Rec0 v s) w
-> Maybe (Tensor (Scalar v) v w))
-> Tensor (Scalar v) (Rec0 v s) w
-> Maybe (Tensor (Scalar v) (Rec0 v s) w)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Tensor (Scalar v) v w -> Maybe (Tensor (Scalar v) v w)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor (Tensor (Scalar v) v w -> Maybe (Tensor (Scalar v) v w))
-> (Tensor (Scalar v) (Rec0 v s) w -> Tensor (Scalar v) v w)
-> Tensor (Scalar v) (Rec0 v s) w
-> Maybe (Tensor (Scalar v) v w)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) w) (Tensor (Scalar v) v w)
-> Tensor (Scalar v) (Rec0 v s) w -> Tensor (Scalar v) v w
forall b c.
(Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c, Object (->) b, Object (->) c) =>
VSCCoercion (Scalar v) b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr ((Rec0 v s -> v)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) w) (Tensor (Scalar v) v w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Rec0 v s -> v
forall k i c (p :: k). K1 i c p -> c
Gnrx.unK1)
scalarSpaceWitness :: ScalarSpaceWitness (Rec0 v s)
scalarSpaceWitness = ScalarSpaceWitness (Rec0 v s)
forall a. a
genericTensorspaceError
linearManifoldWitness :: LinearManifoldWitness (Rec0 v s)
linearManifoldWitness = LinearManifoldWitness (Rec0 v s)
forall a. a
genericTensorspaceError
zeroTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) =>
Rec0 v s ⊗ w
zeroTensor = (v -> Rec0 v s)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1 VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> Tensor (Scalar v) v w -> Tensor (Scalar v) (Rec0 v s) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) v w
forall w. (TensorSpace w, Scalar w ~ Scalar v) => v ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor
toFlatTensor :: Rec0 v s -+> (Rec0 v s ⊗ Scalar (Rec0 v s))
toFlatTensor = (Rec0 v s -> Tensor (Scalar v) (Rec0 v s) (Scalar v))
-> LinearFunction
(Scalar v) (Rec0 v s) (Tensor (Scalar v) (Rec0 v s) (Scalar v))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Rec0 v s -> Tensor (Scalar v) (Rec0 v s) (Scalar v))
-> LinearFunction
(Scalar v) (Rec0 v s) (Tensor (Scalar v) (Rec0 v s) (Scalar v)))
-> (Rec0 v s -> Tensor (Scalar v) (Rec0 v s) (Scalar v))
-> LinearFunction
(Scalar v) (Rec0 v s) (Tensor (Scalar v) (Rec0 v s) (Scalar v))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Rec0 v s -> v
forall k i c (p :: k). K1 i c p -> c
Gnrx.unK1 (Rec0 v s -> v)
-> (v -> Tensor (Scalar v) (Rec0 v s) (Scalar v))
-> Rec0 v s
-> Tensor (Scalar v) (Rec0 v s) (Scalar v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction (Scalar v) v (Tensor (Scalar v) v (Scalar v))
-> v -> Tensor (Scalar v) v (Scalar v)
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction (Scalar v) v (Tensor (Scalar v) v (Scalar v))
v -+> Tensor (Scalar v) v (Scalar v)
forall v. TensorSpace v => v -+> (v ⊗ Scalar v)
toFlatTensor
(v -> Tensor (Scalar v) v (Scalar v))
-> (Tensor (Scalar v) v (Scalar v)
-> Tensor (Scalar v) (Rec0 v s) (Scalar v))
-> v
-> Tensor (Scalar v) (Rec0 v s) (Scalar v)
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> ((v -> Rec0 v s)
-> VSCCoercion
(Scalar v)
(Tensor (Scalar v) v (Scalar v))
(Tensor (Scalar v) (Rec0 v s) (Scalar v))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1VSCCoercion
(Scalar v)
(Tensor (Scalar v) v (Scalar v))
(Tensor (Scalar v) (Rec0 v s) (Scalar v))
-> Tensor (Scalar v) v (Scalar v)
-> Tensor (Scalar v) (Rec0 v s) (Scalar v)
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
fromFlatTensor :: (Rec0 v s ⊗ Scalar (Rec0 v s)) -+> Rec0 v s
fromFlatTensor = (Tensor (Scalar v) (Rec0 v s) (Scalar v) -> Rec0 v s)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) (Rec0 v s) (Scalar v)) (Rec0 v s)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor (Scalar v) (Rec0 v s) (Scalar v) -> Rec0 v s)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) (Rec0 v s) (Scalar v)) (Rec0 v s))
-> (Tensor (Scalar v) (Rec0 v s) (Scalar v) -> Rec0 v s)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) (Rec0 v s) (Scalar v)) (Rec0 v s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1 (v -> Rec0 v s)
-> (Tensor (Scalar v) (Rec0 v s) (Scalar v) -> v)
-> Tensor (Scalar v) (Rec0 v s) (Scalar v)
-> Rec0 v s
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< LinearFunction (Scalar v) (Tensor (Scalar v) v (Scalar v)) v
-> Tensor (Scalar v) v (Scalar v) -> v
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction (Scalar v) (Tensor (Scalar v) v (Scalar v)) v
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor
(Tensor (Scalar v) v (Scalar v) -> v)
-> (Tensor (Scalar v) (Rec0 v s) (Scalar v)
-> Tensor (Scalar v) v (Scalar v))
-> Tensor (Scalar v) (Rec0 v s) (Scalar v)
-> v
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< ((Rec0 v s -> v)
-> VSCCoercion
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) (Scalar v))
(Tensor (Scalar v) v (Scalar v))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Rec0 v s -> v
forall k i c (p :: k). K1 i c p -> c
Gnrx.unK1VSCCoercion
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) (Scalar v))
(Tensor (Scalar v) v (Scalar v))
-> Tensor (Scalar v) (Rec0 v s) (Scalar v)
-> Tensor (Scalar v) v (Scalar v)
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
addTensors :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) =>
(Rec0 v s ⊗ w) -> (Rec0 v s ⊗ w) -> Rec0 v s ⊗ w
addTensors (Tensor TensorProduct (Rec0 v s) w
s) (Tensor TensorProduct (Rec0 v s) w
t)
= (v -> Rec0 v s)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1 VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> Tensor (Scalar v) v w -> Tensor (Scalar v) (Rec0 v s) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) v w
-> Tensor (Scalar v) v w -> Tensor (Scalar v) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
addTensors (TensorProduct v w -> Tensor (Scalar v) v w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct v w
TensorProduct (Rec0 v s) w
s) (TensorProduct v w -> Tensor (Scalar v) v w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct v w
TensorProduct (Rec0 v s) w
t)
subtractTensors :: forall w.
(TensorSpace (Rec0 v s), TensorSpace w,
Scalar w ~ Scalar (Rec0 v s)) =>
(Rec0 v s ⊗ w) -> (Rec0 v s ⊗ w) -> Rec0 v s ⊗ w
subtractTensors (Tensor TensorProduct (Rec0 v s) w
s) (Tensor TensorProduct (Rec0 v s) w
t)
= (v -> Rec0 v s)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1 VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> Tensor (Scalar v) v w -> Tensor (Scalar v) (Rec0 v s) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) v w
-> Tensor (Scalar v) v w -> Tensor (Scalar v) v w
forall v w.
(TensorSpace v, TensorSpace v, TensorSpace w,
Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
forall w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
subtractTensors (TensorProduct v w -> Tensor (Scalar v) v w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct v w
TensorProduct (Rec0 v s) w
s) (TensorProduct v w -> Tensor (Scalar v) v w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct v w
TensorProduct (Rec0 v s) w
t)
scaleTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) =>
Bilinear (Scalar (Rec0 v s)) (Rec0 v s ⊗ w) (Rec0 v s ⊗ w)
scaleTensor = (Scalar v
-> LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w))
-> LinearFunction
(Scalar (Scalar v))
(Scalar v)
(LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Scalar v
-> LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w))
-> LinearFunction
(Scalar (Scalar v))
(Scalar v)
(LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w)))
-> (Scalar v
-> LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w))
-> LinearFunction
(Scalar (Scalar v))
(Scalar v)
(LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \Scalar v
μ -> (v -> Rec0 v s)
-> LinearFunction
(Scalar (Scalar v)) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
-> LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1
(LinearFunction
(Scalar (Scalar v)) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
-> LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w))
-> LinearFunction
(Scalar (Scalar v)) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
-> LinearFunction
(Scalar (Scalar v))
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Bilinear (Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
scaleTensorBilinear (Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
-> Scalar v
-> LinearFunction
(Scalar (Scalar v)) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
forall s v w. LinearFunction s v w -> v -> w
-+$>Scalar v
μ
negateTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) =>
(Rec0 v s ⊗ w) -+> (Rec0 v s ⊗ w)
negateTensor = (v -> Rec0 v s)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1 LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
Tensor (Scalar v) v w -+> Tensor (Scalar v) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
negateTensor
tensorProduct :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) =>
Bilinear (Rec0 v s) w (Rec0 v s ⊗ w)
tensorProduct = (Rec0 v s -> w -> Tensor (Scalar v) (Rec0 v s) w)
-> LinearFunction
(Scalar v)
(Rec0 v s)
(LinearFunction (Scalar v) w (Tensor (Scalar v) (Rec0 v s) w))
(Rec0 v s -> w -> Tensor (Scalar v) (Rec0 v s) w)
-> Bilinear (Rec0 v s) w (Tensor (Scalar v) (Rec0 v s) w)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((Rec0 v s -> w -> Tensor (Scalar v) (Rec0 v s) w)
-> LinearFunction
(Scalar v)
(Rec0 v s)
(LinearFunction (Scalar v) w (Tensor (Scalar v) (Rec0 v s) w)))
-> (Rec0 v s -> w -> Tensor (Scalar v) (Rec0 v s) w)
-> LinearFunction
(Scalar v)
(Rec0 v s)
(LinearFunction (Scalar v) w (Tensor (Scalar v) (Rec0 v s) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Gnrx.K1 v
v) w
w
-> (v -> Rec0 v s)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1
VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> Tensor (Scalar v) v w -> Tensor (Scalar v) (Rec0 v s) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Bilinear v w (Tensor (Scalar v) v w)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductBilinear v w (Tensor (Scalar v) v w)
-> v -> LinearFunction (Scalar v) w (Tensor (Scalar v) v w)
forall s v w. LinearFunction s v w -> v -> w
-+$>v
v)LinearFunction (Scalar v) w (Tensor (Scalar v) v w)
-> w -> Tensor (Scalar v) v w
forall s v w. LinearFunction s v w -> v -> w
-+$>w
w
transposeTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) =>
(Rec0 v s ⊗ w) -+> (w ⊗ Rec0 v s)
transposeTensor = (Rec0 v s ⊗ w) -+> (w ⊗ Rec0 v s)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(Rec0 v s ⊗ w) -+> (w ⊗ Rec0 v s)
tT
where tT :: ∀ w . (TensorSpace w, Scalar w ~ Scalar v)
=> (Gnrx.Rec0 v s ⊗ w) -+> (w ⊗ Gnrx.Rec0 v s)
tT :: forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(Rec0 v s ⊗ w) -+> (w ⊗ Rec0 v s)
tT = (Tensor (Scalar v) (Rec0 v s) w -> Tensor (Scalar v) w (Rec0 v s))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) w (Rec0 v s))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction
((Tensor (Scalar v) (Rec0 v s) w -> Tensor (Scalar v) w (Rec0 v s))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) w (Rec0 v s)))
-> (Tensor (Scalar v) (Rec0 v s) w
-> Tensor (Scalar v) w (Rec0 v s))
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) w (Rec0 v s))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Coercion (Tensor (Scalar v) w v) (Tensor (Scalar v) w (Rec0 v s))
-> Tensor (Scalar v) w v -> Tensor (Scalar v) w (Rec0 v s)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (Coercion
(TensorProduct w (Rec0 v s)) (Tensor (Scalar v) w (Rec0 v s))
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion Coercion
(TensorProduct w (Rec0 v s)) (Tensor (Scalar v) w (Rec0 v s))
-> Coercion (Tensor (Scalar v) w v) (TensorProduct w (Rec0 v s))
-> Coercion
(Tensor (Scalar v) w v) (Tensor (Scalar v) w (Rec0 v s))
forall a b c.
(Object Coercion a, Object Coercion b, Object Coercion c) =>
Coercion b c -> Coercion a b -> Coercion a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
coerceFmapTensorProduct @w []
(VSCCoercion (Scalar v) v (Rec0 v s)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion :: VSCCoercion (Scalar v) v (Gnrx.Rec0 v s))
Coercion (TensorProduct w v) (TensorProduct w (Rec0 v s))
-> Coercion (Tensor (Scalar v) w v) (TensorProduct w v)
-> Coercion (Tensor (Scalar v) w v) (TensorProduct w (Rec0 v s))
forall a b c.
(Object Coercion a, Object Coercion b, Object Coercion c) =>
Coercion b c -> Coercion a b -> Coercion a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Coercion (Tensor (Scalar v) w v) (TensorProduct w v)
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion)
(Tensor (Scalar v) w v -> Tensor (Scalar v) w (Rec0 v s))
-> (Tensor (Scalar v) (Rec0 v s) w -> Tensor (Scalar v) w v)
-> Tensor (Scalar v) (Rec0 v s) w
-> Tensor (Scalar v) w (Rec0 v s)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) w v)
-> Tensor (Scalar v) v w -> Tensor (Scalar v) w v
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) w v)
Tensor (Scalar v) v w -+> (w ⊗ v)
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor (Tensor (Scalar v) v w -> Tensor (Scalar v) w v)
-> (Tensor (Scalar v) (Rec0 v s) w -> Tensor (Scalar v) v w)
-> Tensor (Scalar v) (Rec0 v s) w
-> Tensor (Scalar v) w v
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. ((Rec0 v s -> v)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) w) (Tensor (Scalar v) v w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Rec0 v s -> v
forall k i c (p :: k). K1 i c p -> c
Gnrx.unK1VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) w) (Tensor (Scalar v) v w)
-> Tensor (Scalar v) (Rec0 v s) w -> Tensor (Scalar v) v w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
fmapTensor :: forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (Rec0 v s),
Scalar x ~ Scalar (Rec0 v s)) =>
Bilinear (w -+> x) (Rec0 v s ⊗ w) (Rec0 v s ⊗ x)
fmapTensor = (LinearFunction (Scalar v) w x
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) x))
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) x))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction (Scalar v) w x
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) x))
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) x)))
-> (LinearFunction (Scalar v) w x
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) x))
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction (Scalar v) w x
f -> (v -> Rec0 v s)
-> LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v x)
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) x)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1 (LinearFunction
(Scalar v)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v x))
Bilinear
(LinearFunction (Scalar x) w x)
(Tensor (Scalar v) v w)
(Tensor (Scalar v) v x)
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
fmapTensorLinearFunction
(Scalar v)
(LinearFunction (Scalar v) w x)
(LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v x))
-> LinearFunction (Scalar v) w x
-> LinearFunction
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar v) w x
f)
fzipTensorWith :: forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (Rec0 v s), Scalar w ~ Scalar (Rec0 v s),
Scalar x ~ Scalar (Rec0 v s)) =>
Bilinear ((w, x) -+> u) (Rec0 v s ⊗ w, Rec0 v s ⊗ x) (Rec0 v s ⊗ u)
fzipTensorWith = (LinearFunction (Scalar v) (w, x) u
-> (Tensor (Scalar v) (Rec0 v s) w, Tensor (Scalar v) (Rec0 v s) x)
-> Tensor (Scalar v) (Rec0 v s) u)
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w, Tensor (Scalar v) (Rec0 v s) x)
(Tensor (Scalar v) (Rec0 v s) u))
(LinearFunction (Scalar v) (w, x) u
-> (Tensor (Scalar v) (Rec0 v s) w, Tensor (Scalar v) (Rec0 v s) x)
-> Tensor (Scalar v) (Rec0 v s) u)
-> Bilinear
(LinearFunction (Scalar v) (w, x) u)
(Tensor (Scalar v) (Rec0 v s) w, Tensor (Scalar v) (Rec0 v s) x)
(Tensor (Scalar v) (Rec0 v s) u)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction (Scalar v) (w, x) u
-> (Tensor (Scalar v) (Rec0 v s) w, Tensor (Scalar v) (Rec0 v s) x)
-> Tensor (Scalar v) (Rec0 v s) u)
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w, Tensor (Scalar v) (Rec0 v s) x)
(Tensor (Scalar v) (Rec0 v s) u)))
-> (LinearFunction (Scalar v) (w, x) u
-> (Tensor (Scalar v) (Rec0 v s) w, Tensor (Scalar v) (Rec0 v s) x)
-> Tensor (Scalar v) (Rec0 v s) u)
-> LinearFunction
(Scalar v)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w, Tensor (Scalar v) (Rec0 v s) x)
(Tensor (Scalar v) (Rec0 v s) u))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction (Scalar v) (w, x) u
f (Tensor (Scalar v) (Rec0 v s) w
wt, Tensor (Scalar v) (Rec0 v s) x
xt) -> (v -> Rec0 v s)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) v u) (Tensor (Scalar v) (Rec0 v s) u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1
VSCCoercion
(Scalar v) (Tensor (Scalar v) v u) (Tensor (Scalar v) (Rec0 v s) u)
-> Tensor (Scalar v) v u -> Tensor (Scalar v) (Rec0 v s) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (LinearFunction
(Scalar v)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) v w, Tensor (Scalar v) v x)
(Tensor (Scalar v) v u))
Bilinear
(LinearFunction (Scalar u) (w, x) u)
(Tensor (Scalar v) v w, Tensor (Scalar v) v x)
(Tensor (Scalar v) v u)
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar v,
Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
fzipTensorWithLinearFunction
(Scalar v)
(LinearFunction (Scalar v) (w, x) u)
(LinearFunction
(Scalar v)
(Tensor (Scalar v) v w, Tensor (Scalar v) v x)
(Tensor (Scalar v) v u))
-> LinearFunction (Scalar v) (w, x) u
-> LinearFunction
(Scalar v)
(Tensor (Scalar v) v w, Tensor (Scalar v) v x)
(Tensor (Scalar v) v u)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar v) (w, x) u
f)
LinearFunction
(Scalar v)
(Tensor (Scalar v) v w, Tensor (Scalar v) v x)
(Tensor (Scalar v) v u)
-> (Tensor (Scalar v) v w, Tensor (Scalar v) v x)
-> Tensor (Scalar v) v u
forall s v w. LinearFunction s v w -> v -> w
-+$>( (Rec0 v s -> v)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) w) (Tensor (Scalar v) v w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Rec0 v s -> v
forall k i c (p :: k). K1 i c p -> c
Gnrx.unK1 VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) w) (Tensor (Scalar v) v w)
-> Tensor (Scalar v) (Rec0 v s) w -> Tensor (Scalar v) v w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) (Rec0 v s) w
wt
, (Rec0 v s -> v)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) x) (Tensor (Scalar v) v x)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Rec0 v s -> v
forall k i c (p :: k). K1 i c p -> c
Gnrx.unK1 VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) x) (Tensor (Scalar v) v x)
-> Tensor (Scalar v) (Rec0 v s) x -> Tensor (Scalar v) v x
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) (Rec0 v s) x
xt )
tensorUnsafeFromArrayWithOffset
:: ∀ w m a . ( TensorSpace w, m`Dimensional`w, Scalar w ~ Scalar v
, GArr.Vector a (Scalar v) )
=> Int -> a (Scalar v) -> (Gnrx.Rec0 v s⊗w)
tensorUnsafeFromArrayWithOffset :: forall w (m :: Nat) (a :: Type -> Type).
(TensorSpace w, Dimensional m w, Scalar w ~ Scalar v,
Vector a (Scalar v)) =>
Int -> a (Scalar v) -> Rec0 v s ⊗ w
tensorUnsafeFromArrayWithOffset = case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v of
DimensionalityWitness v
IsFlexibleDimensional -> [Char] -> Int -> a (Scalar v) -> Tensor (Scalar v) (Rec0 v s) w
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `v` is static-dimensional."
DimensionalityWitness v
IsStaticDimensional -> \Int
i a (Scalar v)
ar
-> Tensor (Scalar v) v w -> Tensor (Scalar v) (Rec0 v s) w
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v ⊗ w
tensorUnsafeFromArrayWithOffset @v @w Int
i a (Scalar v)
ar)
tensorUnsafeWriteArrayWithOffset
:: ∀ w m α σ . ( TensorSpace w, m`Dimensional`w, Scalar w ~ Scalar v
, GArr.Vector α (Scalar v) )
=> GArr.Mutable α σ (Scalar v) -> Int -> (Gnrx.Rec0 v s⊗w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset :: forall w (m :: Nat) (α :: Type -> Type) σ.
(TensorSpace w, Dimensional m w, Scalar w ~ Scalar v,
Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> (Rec0 v s ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset = case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @v of
DimensionalityWitness v
IsFlexibleDimensional -> [Char]
-> Mutable α σ (Scalar v)
-> Int
-> Tensor (Scalar v) (Rec0 v s) w
-> ST σ ()
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `v` is static-dimensional."
DimensionalityWitness v
IsStaticDimensional -> \Mutable α σ (Scalar v)
ar -> (Int -> Tensor (Scalar v) v w -> ST σ ())
-> Int -> Tensor (Scalar v) (Rec0 v s) w -> ST σ ()
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) σ (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> (v ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset @v @w Mutable α σ (Scalar v)
ar)
coerceFmapTensorProduct :: forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (Rec0 v s),
TensorSpace b, Scalar b ~ Scalar (Rec0 v s)) =>
p (Rec0 v s)
-> VSCCoercion (Scalar (Rec0 v s)) a b
-> Coercion
(TensorProduct (Rec0 v s) a) (TensorProduct (Rec0 v s) b)
coerceFmapTensorProduct = p (Rec0 v s)
-> VSCCoercion (Scalar v) a b
-> Coercion
(TensorProduct (Rec0 v s) a) (TensorProduct (Rec0 v s) b)
p (Rec0 v s)
-> VSCCoercion (Scalar (Rec0 v s)) a b
-> Coercion
(TensorProduct (Rec0 v s) a) (TensorProduct (Rec0 v s) b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar v, TensorSpace b,
Scalar b ~ Scalar v) =>
p (Rec0 v s)
-> VSCCoercion (Scalar v) a b
-> Coercion
(TensorProduct (Rec0 v s) a) (TensorProduct (Rec0 v s) b)
cmtp
where cmtp :: ∀ p a b . ( Hask.Functor p
, TensorSpace a, Scalar a ~ Scalar v
, TensorSpace b, Scalar b ~ Scalar v )
=> p (Gnrx.Rec0 v s) -> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct (Gnrx.Rec0 v s) a)
(TensorProduct (Gnrx.Rec0 v s) b)
cmtp :: forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar v, TensorSpace b,
Scalar b ~ Scalar v) =>
p (Rec0 v s)
-> VSCCoercion (Scalar v) a b
-> Coercion
(TensorProduct (Rec0 v s) a) (TensorProduct (Rec0 v s) b)
cmtp p (Rec0 v s)
p VSCCoercion (Scalar v) a b
crc = case forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
coerceFmapTensorProduct @v [] VSCCoercion (Scalar v) a b
crc of
Coercion (TensorProduct v a) (TensorProduct v b)
Coercion -> Coercion (TensorProduct v a) (TensorProduct v b)
Coercion (TensorProduct (Rec0 v s) a) (TensorProduct (Rec0 v s) b)
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion
instance ∀ i c f p . DimensionAware (f p) => DimensionAware (Gnrx.M1 i c f p) where
type StaticDimension (Gnrx.M1 i c f p) = StaticDimension (f p)
dimensionalityWitness :: DimensionalityWitness (M1 i c f p)
dimensionalityWitness = case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(f p) of
DimensionalityWitness (f p)
IsStaticDimensional -> DimensionalityWitness (M1 i c f p)
forall (n :: Nat) v. Dimensional n v => DimensionalityWitness v
IsStaticDimensional
DimensionalityWitness (f p)
IsFlexibleDimensional -> DimensionalityWitness (M1 i c f p)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
instance ∀ n i c f p . n`Dimensional`f p => n`Dimensional`Gnrx.M1 i c f p where
knownDimensionalitySing :: Sing n
knownDimensionalitySing = forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(f p)
unsafeFromArrayWithOffset :: forall (α :: Type -> Type).
Vector α (Scalar (M1 i c f p)) =>
Int -> α (Scalar (M1 i c f p)) -> M1 i c f p
unsafeFromArrayWithOffset Int
i α (Scalar (M1 i c f p))
ar
= f p -> M1 i c f p
forall a b. Coercible a b => a -> b
coerce (forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
unsafeFromArrayWithOffset @n @(f p) Int
i α (Scalar (f p))
α (Scalar (M1 i c f p))
ar)
unsafeWriteArrayWithOffset :: forall (α :: Type -> Type) σ.
Vector α (Scalar (M1 i c f p)) =>
Mutable α σ (Scalar (M1 i c f p)) -> Int -> M1 i c f p -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (M1 i c f p))
i Int
ar
= (f p -> ST σ ()) -> M1 i c f p -> ST σ ()
forall a b. Coercible a b => a -> b
coerce (forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
unsafeWriteArrayWithOffset @n @(f p) Mutable α σ (Scalar (f p))
Mutable α σ (Scalar (M1 i c f p))
i Int
ar)
instance ∀ i c f p . TensorSpace (f p) => TensorSpace (Gnrx.M1 i c f p) where
type TensorProduct (Gnrx.M1 i c f p) w = TensorProduct (f p) w
wellDefinedVector :: M1 i c f p -> Maybe (M1 i c f p)
wellDefinedVector = (f p -> M1 i c f p) -> Maybe (f p) -> Maybe (M1 i c f p)
forall a b.
(Object (->) a, Object (->) (Maybe a), Object (->) b,
Object (->) (Maybe b)) =>
(a -> b) -> Maybe a -> Maybe b
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1 (Maybe (f p) -> Maybe (M1 i c f p))
-> (M1 i c f p -> Maybe (f p)) -> M1 i c f p -> Maybe (M1 i c f p)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. f p -> Maybe (f p)
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector (f p -> Maybe (f p))
-> (M1 i c f p -> f p) -> M1 i c f p -> Maybe (f p)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. M1 i c f p -> f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
Gnrx.unM1
wellDefinedTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (M1 i c f p)) =>
(M1 i c f p ⊗ w) -> Maybe (M1 i c f p ⊗ w)
wellDefinedTensor = Coercion
(Maybe (Tensor (Scalar (f p)) (f p) w))
(Maybe (Tensor (Scalar (f p)) (M1 i c f p) w))
-> Maybe (Tensor (Scalar (f p)) (f p) w)
-> Maybe (Tensor (Scalar (f p)) (M1 i c f p) w)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (Coercion
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> Coercion
(Maybe (Tensor (Scalar (f p)) (f p) w))
(Maybe (Tensor (Scalar (f p)) (M1 i c f p) w))
forall a b.
(Object Coercion a, Object Coercion (Maybe a), Object Coercion b,
Object Coercion (Maybe b)) =>
Coercion a b -> Coercion (Maybe a) (Maybe b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (Coercion
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> Coercion
(Maybe (Tensor (Scalar (f p)) (f p) w))
(Maybe (Tensor (Scalar (f p)) (M1 i c f p) w)))
-> (VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> Coercion
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> Coercion
(Maybe (Tensor (Scalar (f p)) (f p) w))
(Maybe (Tensor (Scalar (f p)) (M1 i c f p) w))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> Coercion
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion (VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> Coercion
(Maybe (Tensor (Scalar (f p)) (f p) w))
(Maybe (Tensor (Scalar (f p)) (M1 i c f p) w)))
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> Coercion
(Maybe (Tensor (Scalar (f p)) (f p) w))
(Maybe (Tensor (Scalar (f p)) (M1 i c f p) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (f p -> M1 i c f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1)
(Maybe (Tensor (Scalar (f p)) (f p) w)
-> Maybe (Tensor (Scalar (f p)) (M1 i c f p) w))
-> (Tensor (Scalar (f p)) (M1 i c f p) w
-> Maybe (Tensor (Scalar (f p)) (f p) w))
-> Tensor (Scalar (f p)) (M1 i c f p) w
-> Maybe (Tensor (Scalar (f p)) (M1 i c f p) w)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Tensor (Scalar (f p)) (f p) w
-> Maybe (Tensor (Scalar (f p)) (f p) w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
(f p ⊗ w) -> Maybe (f p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor (Tensor (Scalar (f p)) (f p) w
-> Maybe (Tensor (Scalar (f p)) (f p) w))
-> (Tensor (Scalar (f p)) (M1 i c f p) w
-> Tensor (Scalar (f p)) (f p) w)
-> Tensor (Scalar (f p)) (M1 i c f p) w
-> Maybe (Tensor (Scalar (f p)) (f p) w)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (f p) w)
-> Tensor (Scalar (f p)) (M1 i c f p) w
-> Tensor (Scalar (f p)) (f p) w
forall b c.
(Object (VSCCoercion (Scalar (f p))) b,
Object (VSCCoercion (Scalar (f p))) c, Object (->) b,
Object (->) c) =>
VSCCoercion (Scalar (f p)) b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr ((M1 i c f p -> f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (f p) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS M1 i c f p -> f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
Gnrx.unM1)
scalarSpaceWitness :: ScalarSpaceWitness (M1 i c f p)
scalarSpaceWitness = ScalarSpaceWitness (M1 i c f p)
forall a. a
genericTensorspaceError
linearManifoldWitness :: LinearManifoldWitness (M1 i c f p)
linearManifoldWitness = LinearManifoldWitness (M1 i c f p)
forall a. a
genericTensorspaceError
zeroTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (M1 i c f p)) =>
M1 i c f p ⊗ w
zeroTensor = (f p -> M1 i c f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1 VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> Tensor (Scalar (f p)) (f p) w
-> Tensor (Scalar (f p)) (M1 i c f p) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (f p)) (f p) w
forall w. (TensorSpace w, Scalar w ~ Scalar (f p)) => f p ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor
toFlatTensor :: M1 i c f p -+> (M1 i c f p ⊗ Scalar (M1 i c f p))
toFlatTensor = (M1 i c f p -> Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
-> LinearFunction
(Scalar (f p))
(M1 i c f p)
(Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((M1 i c f p -> Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
-> LinearFunction
(Scalar (f p))
(M1 i c f p)
(Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p))))
-> (M1 i c f p
-> Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
-> LinearFunction
(Scalar (f p))
(M1 i c f p)
(Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ M1 i c f p -> f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
Gnrx.unM1 (M1 i c f p -> f p)
-> (f p -> Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
-> M1 i c f p
-> Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar (f p)) (f p) (Tensor (Scalar (f p)) (f p) (Scalar (f p)))
-> f p -> Tensor (Scalar (f p)) (f p) (Scalar (f p))
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar (f p)) (f p) (Tensor (Scalar (f p)) (f p) (Scalar (f p)))
f p -+> Tensor (Scalar (f p)) (f p) (Scalar (f p))
forall v. TensorSpace v => v -+> (v ⊗ Scalar v)
toFlatTensor
(f p -> Tensor (Scalar (f p)) (f p) (Scalar (f p)))
-> (Tensor (Scalar (f p)) (f p) (Scalar (f p))
-> Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
-> f p
-> Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p))
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> ((f p -> M1 i c f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) (Scalar (f p)))
(Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) (Scalar (f p)))
(Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
-> Tensor (Scalar (f p)) (f p) (Scalar (f p))
-> Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p))
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
fromFlatTensor :: (M1 i c f p ⊗ Scalar (M1 i c f p)) -+> M1 i c f p
fromFlatTensor = (Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)) -> M1 i c f p)
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
(M1 i c f p)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)) -> M1 i c f p)
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
(M1 i c f p))
-> (Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p))
-> M1 i c f p)
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
(M1 i c f p)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1 (f p -> M1 i c f p)
-> (Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)) -> f p)
-> Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p))
-> M1 i c f p
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< LinearFunction
(Scalar (f p)) (Tensor (Scalar (f p)) (f p) (Scalar (f p))) (f p)
-> Tensor (Scalar (f p)) (f p) (Scalar (f p)) -> f p
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar (f p)) (Tensor (Scalar (f p)) (f p) (Scalar (f p))) (f p)
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor
(Tensor (Scalar (f p)) (f p) (Scalar (f p)) -> f p)
-> (Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p))
-> Tensor (Scalar (f p)) (f p) (Scalar (f p)))
-> Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p))
-> f p
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
<<< ((M1 i c f p -> f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
(Tensor (Scalar (f p)) (f p) (Scalar (f p)))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS M1 i c f p -> f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
Gnrx.unM1VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p)))
(Tensor (Scalar (f p)) (f p) (Scalar (f p)))
-> Tensor (Scalar (f p)) (M1 i c f p) (Scalar (f p))
-> Tensor (Scalar (f p)) (f p) (Scalar (f p))
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
addTensors :: forall w.
(TensorSpace w, Scalar w ~ Scalar (M1 i c f p)) =>
(M1 i c f p ⊗ w) -> (M1 i c f p ⊗ w) -> M1 i c f p ⊗ w
addTensors (Tensor TensorProduct (M1 i c f p) w
s) (Tensor TensorProduct (M1 i c f p) w
t)
= (f p -> M1 i c f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1 VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> Tensor (Scalar (f p)) (f p) w
-> Tensor (Scalar (f p)) (M1 i c f p) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (f p)) (f p) w
-> Tensor (Scalar (f p)) (f p) w -> Tensor (Scalar (f p)) (f p) w
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
(f p ⊗ w) -> (f p ⊗ w) -> f p ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
addTensors (TensorProduct (f p) w -> Tensor (Scalar (f p)) (f p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (f p) w
TensorProduct (M1 i c f p) w
s) (TensorProduct (f p) w -> Tensor (Scalar (f p)) (f p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (f p) w
TensorProduct (M1 i c f p) w
t)
subtractTensors :: forall w.
(TensorSpace (M1 i c f p), TensorSpace w,
Scalar w ~ Scalar (M1 i c f p)) =>
(M1 i c f p ⊗ w) -> (M1 i c f p ⊗ w) -> M1 i c f p ⊗ w
subtractTensors (Tensor TensorProduct (M1 i c f p) w
s) (Tensor TensorProduct (M1 i c f p) w
t)
= (f p -> M1 i c f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1 VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> Tensor (Scalar (f p)) (f p) w
-> Tensor (Scalar (f p)) (M1 i c f p) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (f p)) (f p) w
-> Tensor (Scalar (f p)) (f p) w -> Tensor (Scalar (f p)) (f p) w
forall v w.
(TensorSpace v, TensorSpace v, TensorSpace w,
Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
forall w.
(TensorSpace (f p), TensorSpace w, Scalar w ~ Scalar (f p)) =>
(f p ⊗ w) -> (f p ⊗ w) -> f p ⊗ w
subtractTensors (TensorProduct (f p) w -> Tensor (Scalar (f p)) (f p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (f p) w
TensorProduct (M1 i c f p) w
s) (TensorProduct (f p) w -> Tensor (Scalar (f p)) (f p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (f p) w
TensorProduct (M1 i c f p) w
t)
scaleTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (M1 i c f p)) =>
Bilinear (Scalar (M1 i c f p)) (M1 i c f p ⊗ w) (M1 i c f p ⊗ w)
scaleTensor = (Scalar (f p)
-> LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
-> LinearFunction
(Scalar (Scalar (f p)))
(Scalar (f p))
(LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Scalar (f p)
-> LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
-> LinearFunction
(Scalar (Scalar (f p)))
(Scalar (f p))
(LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)))
-> (Scalar (f p)
-> LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
-> LinearFunction
(Scalar (Scalar (f p)))
(Scalar (f p))
(LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \Scalar (f p)
μ -> (f p -> M1 i c f p)
-> LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w)
-> LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1
(LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w)
-> LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
-> LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w)
-> LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Bilinear
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
Bilinear (Scalar (f p)) (f p ⊗ w) (f p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
scaleTensorBilinear
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w)
-> Scalar (f p)
-> LinearFunction
(Scalar (Scalar (f p)))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w)
forall s v w. LinearFunction s v w -> v -> w
-+$>Scalar (f p)
μ
negateTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (M1 i c f p)) =>
(M1 i c f p ⊗ w) -+> (M1 i c f p ⊗ w)
negateTensor = (f p -> M1 i c f p)
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w)
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1 LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w)
Tensor (Scalar (f p)) (f p) w -+> Tensor (Scalar (f p)) (f p) w
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
(f p ⊗ w) -+> (f p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
negateTensor
tensorProduct :: forall w.
(TensorSpace w, Scalar w ~ Scalar (M1 i c f p)) =>
Bilinear (M1 i c f p) w (M1 i c f p ⊗ w)
tensorProduct = (M1 i c f p -> w -> Tensor (Scalar (f p)) (M1 i c f p) w)
-> LinearFunction
(Scalar (f p))
(M1 i c f p)
(LinearFunction
(Scalar (f p)) w (Tensor (Scalar (f p)) (M1 i c f p) w))
(M1 i c f p -> w -> Tensor (Scalar (f p)) (M1 i c f p) w)
-> Bilinear (M1 i c f p) w (Tensor (Scalar (f p)) (M1 i c f p) w)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((M1 i c f p -> w -> Tensor (Scalar (f p)) (M1 i c f p) w)
-> LinearFunction
(Scalar (f p))
(M1 i c f p)
(LinearFunction
(Scalar (f p)) w (Tensor (Scalar (f p)) (M1 i c f p) w)))
-> (M1 i c f p -> w -> Tensor (Scalar (f p)) (M1 i c f p) w)
-> LinearFunction
(Scalar (f p))
(M1 i c f p)
(LinearFunction
(Scalar (f p)) w (Tensor (Scalar (f p)) (M1 i c f p) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Gnrx.M1 f p
v) w
w
-> (f p -> M1 i c f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1
VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> Tensor (Scalar (f p)) (f p) w
-> Tensor (Scalar (f p)) (M1 i c f p) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Bilinear (f p) w (Tensor (Scalar (f p)) (f p) w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
Bilinear (f p) w (f p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductBilinear (f p) w (Tensor (Scalar (f p)) (f p) w)
-> f p
-> LinearFunction (Scalar (f p)) w (Tensor (Scalar (f p)) (f p) w)
forall s v w. LinearFunction s v w -> v -> w
-+$>f p
v)LinearFunction (Scalar (f p)) w (Tensor (Scalar (f p)) (f p) w)
-> w -> Tensor (Scalar (f p)) (f p) w
forall s v w. LinearFunction s v w -> v -> w
-+$>w
w
transposeTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (M1 i c f p)) =>
(M1 i c f p ⊗ w) -+> (w ⊗ M1 i c f p)
transposeTensor = (M1 i c f p ⊗ w) -+> (w ⊗ M1 i c f p)
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
(M1 i c f p ⊗ w) -+> (w ⊗ M1 i c f p)
tT
where tT :: ∀ w . (TensorSpace w, Scalar w ~ Scalar (f p))
=> (Gnrx.M1 i c f p ⊗ w) -+> (w ⊗ Gnrx.M1 i c f p)
tT :: forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
(M1 i c f p ⊗ w) -+> (w ⊗ M1 i c f p)
tT = (Tensor (Scalar (f p)) (M1 i c f p) w
-> Tensor (Scalar (f p)) w (M1 i c f p))
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) w (M1 i c f p))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction
((Tensor (Scalar (f p)) (M1 i c f p) w
-> Tensor (Scalar (f p)) w (M1 i c f p))
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) w (M1 i c f p)))
-> (Tensor (Scalar (f p)) (M1 i c f p) w
-> Tensor (Scalar (f p)) w (M1 i c f p))
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) w (M1 i c f p))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Coercion
(Tensor (Scalar (f p)) w (f p))
(Tensor (Scalar (f p)) w (M1 i c f p))
-> Tensor (Scalar (f p)) w (f p)
-> Tensor (Scalar (f p)) w (M1 i c f p)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (Coercion
(TensorProduct w (M1 i c f p))
(Tensor (Scalar (f p)) w (M1 i c f p))
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion Coercion
(TensorProduct w (M1 i c f p))
(Tensor (Scalar (f p)) w (M1 i c f p))
-> Coercion
(Tensor (Scalar (f p)) w (f p)) (TensorProduct w (M1 i c f p))
-> Coercion
(Tensor (Scalar (f p)) w (f p))
(Tensor (Scalar (f p)) w (M1 i c f p))
forall a b c.
(Object Coercion a, Object Coercion b, Object Coercion c) =>
Coercion b c -> Coercion a b -> Coercion a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. [w]
-> VSCCoercion (Scalar w) (f p) (M1 i c f p)
-> Coercion (TensorProduct w (f p)) (TensorProduct w (M1 i c f p))
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar w, TensorSpace b,
Scalar b ~ Scalar w) =>
p w
-> VSCCoercion (Scalar w) a b
-> Coercion (TensorProduct w a) (TensorProduct w b)
coerceFmapTensorProduct ([]::[w])
(VSCCoercion s (f p) (M1 i c f p)
forall {s}. VSCCoercion s (f p) (M1 i c f p)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion :: VSCCoercion s (f p) (Gnrx.M1 i c f p))
Coercion (TensorProduct w (f p)) (TensorProduct w (M1 i c f p))
-> Coercion (Tensor (Scalar (f p)) w (f p)) (TensorProduct w (f p))
-> Coercion
(Tensor (Scalar (f p)) w (f p)) (TensorProduct w (M1 i c f p))
forall a b c.
(Object Coercion a, Object Coercion b, Object Coercion c) =>
Coercion b c -> Coercion a b -> Coercion a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Coercion (Tensor (Scalar (f p)) w (f p)) (TensorProduct w (f p))
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion)
(Tensor (Scalar (f p)) w (f p)
-> Tensor (Scalar (f p)) w (M1 i c f p))
-> (Tensor (Scalar (f p)) (M1 i c f p) w
-> Tensor (Scalar (f p)) w (f p))
-> Tensor (Scalar (f p)) (M1 i c f p) w
-> Tensor (Scalar (f p)) w (M1 i c f p)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) w (f p))
-> Tensor (Scalar (f p)) (f p) w -> Tensor (Scalar (f p)) w (f p)
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) w (f p))
Tensor (Scalar (f p)) (f p) w -+> (w ⊗ f p)
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
(f p ⊗ w) -+> (w ⊗ f p)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor (Tensor (Scalar (f p)) (f p) w -> Tensor (Scalar (f p)) w (f p))
-> (Tensor (Scalar (f p)) (M1 i c f p) w
-> Tensor (Scalar (f p)) (f p) w)
-> Tensor (Scalar (f p)) (M1 i c f p) w
-> Tensor (Scalar (f p)) w (f p)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. ((M1 i c f p -> f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (f p) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS M1 i c f p -> f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
Gnrx.unM1VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (f p) w)
-> Tensor (Scalar (f p)) (M1 i c f p) w
-> Tensor (Scalar (f p)) (f p) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
fmapTensor :: forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (M1 i c f p),
Scalar x ~ Scalar (M1 i c f p)) =>
Bilinear (w -+> x) (M1 i c f p ⊗ w) (M1 i c f p ⊗ x)
fmapTensor = (LinearFunction (Scalar (f p)) w x
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) x))
-> LinearFunction
(Scalar (f p))
(LinearFunction (Scalar (f p)) w x)
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) x))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction (Scalar (f p)) w x
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) x))
-> LinearFunction
(Scalar (f p))
(LinearFunction (Scalar (f p)) w x)
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) x)))
-> (LinearFunction (Scalar (f p)) w x
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) x))
-> LinearFunction
(Scalar (f p))
(LinearFunction (Scalar (f p)) w x)
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction (Scalar (f p)) w x
f -> (f p -> M1 i c f p)
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) x)
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) x)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1 (LinearFunction
(Scalar (f p))
(LinearFunction (Scalar (f p)) w x)
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) x))
Bilinear
(LinearFunction (Scalar x) w x)
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) x)
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (f p),
Scalar x ~ Scalar (f p)) =>
Bilinear (w -+> x) (f p ⊗ w) (f p ⊗ x)
fmapTensorLinearFunction
(Scalar (f p))
(LinearFunction (Scalar (f p)) w x)
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) x))
-> LinearFunction (Scalar (f p)) w x
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (f p)) w x
f)
fzipTensorWith :: forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (M1 i c f p), Scalar w ~ Scalar (M1 i c f p),
Scalar x ~ Scalar (M1 i c f p)) =>
Bilinear
((w, x) -+> u) (M1 i c f p ⊗ w, M1 i c f p ⊗ x) (M1 i c f p ⊗ u)
fzipTensorWith = (LinearFunction (Scalar (f p)) (w, x) u
-> (Tensor (Scalar (f p)) (M1 i c f p) w,
Tensor (Scalar (f p)) (M1 i c f p) x)
-> Tensor (Scalar (f p)) (M1 i c f p) u)
-> LinearFunction
(Scalar (f p))
(LinearFunction (Scalar (f p)) (w, x) u)
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w,
Tensor (Scalar (f p)) (M1 i c f p) x)
(Tensor (Scalar (f p)) (M1 i c f p) u))
(LinearFunction (Scalar (f p)) (w, x) u
-> (Tensor (Scalar (f p)) (M1 i c f p) w,
Tensor (Scalar (f p)) (M1 i c f p) x)
-> Tensor (Scalar (f p)) (M1 i c f p) u)
-> Bilinear
(LinearFunction (Scalar (f p)) (w, x) u)
(Tensor (Scalar (f p)) (M1 i c f p) w,
Tensor (Scalar (f p)) (M1 i c f p) x)
(Tensor (Scalar (f p)) (M1 i c f p) u)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction (Scalar (f p)) (w, x) u
-> (Tensor (Scalar (f p)) (M1 i c f p) w,
Tensor (Scalar (f p)) (M1 i c f p) x)
-> Tensor (Scalar (f p)) (M1 i c f p) u)
-> LinearFunction
(Scalar (f p))
(LinearFunction (Scalar (f p)) (w, x) u)
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w,
Tensor (Scalar (f p)) (M1 i c f p) x)
(Tensor (Scalar (f p)) (M1 i c f p) u)))
-> (LinearFunction (Scalar (f p)) (w, x) u
-> (Tensor (Scalar (f p)) (M1 i c f p) w,
Tensor (Scalar (f p)) (M1 i c f p) x)
-> Tensor (Scalar (f p)) (M1 i c f p) u)
-> LinearFunction
(Scalar (f p))
(LinearFunction (Scalar (f p)) (w, x) u)
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w,
Tensor (Scalar (f p)) (M1 i c f p) x)
(Tensor (Scalar (f p)) (M1 i c f p) u))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction (Scalar (f p)) (w, x) u
f (Tensor (Scalar (f p)) (M1 i c f p) w
wt, Tensor (Scalar (f p)) (M1 i c f p) x
xt) -> (f p -> M1 i c f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) u)
(Tensor (Scalar (f p)) (M1 i c f p) u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1
VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) u)
(Tensor (Scalar (f p)) (M1 i c f p) u)
-> Tensor (Scalar (f p)) (f p) u
-> Tensor (Scalar (f p)) (M1 i c f p) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (LinearFunction
(Scalar (f p))
(LinearFunction (Scalar (f p)) (w, x) u)
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w, Tensor (Scalar (f p)) (f p) x)
(Tensor (Scalar (f p)) (f p) u))
Bilinear
(LinearFunction (Scalar u) (w, x) u)
(Tensor (Scalar (f p)) (f p) w, Tensor (Scalar (f p)) (f p) x)
(Tensor (Scalar (f p)) (f p) u)
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (f p), Scalar w ~ Scalar (f p),
Scalar x ~ Scalar (f p)) =>
Bilinear ((w, x) -+> u) (f p ⊗ w, f p ⊗ x) (f p ⊗ u)
fzipTensorWithLinearFunction
(Scalar (f p))
(LinearFunction (Scalar (f p)) (w, x) u)
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w, Tensor (Scalar (f p)) (f p) x)
(Tensor (Scalar (f p)) (f p) u))
-> LinearFunction (Scalar (f p)) (w, x) u
-> LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w, Tensor (Scalar (f p)) (f p) x)
(Tensor (Scalar (f p)) (f p) u)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (f p)) (w, x) u
f)
LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w, Tensor (Scalar (f p)) (f p) x)
(Tensor (Scalar (f p)) (f p) u)
-> (Tensor (Scalar (f p)) (f p) w, Tensor (Scalar (f p)) (f p) x)
-> Tensor (Scalar (f p)) (f p) u
forall s v w. LinearFunction s v w -> v -> w
-+$>( (M1 i c f p -> f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (f p) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS M1 i c f p -> f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
Gnrx.unM1 VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (f p) w)
-> Tensor (Scalar (f p)) (M1 i c f p) w
-> Tensor (Scalar (f p)) (f p) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (f p)) (M1 i c f p) w
wt
, (M1 i c f p -> f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) x)
(Tensor (Scalar (f p)) (f p) x)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS M1 i c f p -> f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
Gnrx.unM1 VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) x)
(Tensor (Scalar (f p)) (f p) x)
-> Tensor (Scalar (f p)) (M1 i c f p) x
-> Tensor (Scalar (f p)) (f p) x
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (f p)) (M1 i c f p) x
xt )
tensorUnsafeFromArrayWithOffset
:: ∀ w m a . ( TensorSpace w, m`Dimensional`w, Scalar w ~ Scalar (f p)
, GArr.Vector a (Scalar (f p)) )
=> Int -> a (Scalar (f p)) -> (Gnrx.M1 i c f p⊗w)
tensorUnsafeFromArrayWithOffset :: forall w (m :: Nat) (a :: Type -> Type).
(TensorSpace w, Dimensional m w, Scalar w ~ Scalar (f p),
Vector a (Scalar (f p))) =>
Int -> a (Scalar (f p)) -> M1 i c f p ⊗ w
tensorUnsafeFromArrayWithOffset = case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(f p) of
DimensionalityWitness (f p)
IsFlexibleDimensional -> [Char]
-> Int -> a (Scalar (f p)) -> Tensor (Scalar (f p)) (M1 i c f p) w
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `f p` is static-dimensional."
DimensionalityWitness (f p)
IsStaticDimensional -> \Int
i a (Scalar (f p))
ar
-> Tensor (Scalar (f p)) (f p) w
-> Tensor (Scalar (f p)) (M1 i c f p) w
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v ⊗ w
tensorUnsafeFromArrayWithOffset @(f p) @w Int
i a (Scalar (f p))
ar)
tensorUnsafeWriteArrayWithOffset
:: ∀ w m α σ . ( TensorSpace w, m`Dimensional`w, Scalar w ~ Scalar (f p)
, GArr.Vector α (Scalar (f p)) )
=> GArr.Mutable α σ (Scalar (f p)) -> Int -> (Gnrx.M1 i c f p⊗w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset :: forall w (m :: Nat) (α :: Type -> Type) σ.
(TensorSpace w, Dimensional m w, Scalar w ~ Scalar (f p),
Vector α (Scalar (f p))) =>
Mutable α σ (Scalar (f p)) -> Int -> (M1 i c f p ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset = case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(f p) of
DimensionalityWitness (f p)
IsFlexibleDimensional -> [Char]
-> Mutable α σ (Scalar (f p))
-> Int
-> Tensor (Scalar (f p)) (M1 i c f p) w
-> ST σ ()
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `f p` is static-dimensional."
DimensionalityWitness (f p)
IsStaticDimensional -> \Mutable α σ (Scalar (f p))
ar ->
(Int -> Tensor (Scalar (f p)) (f p) w -> ST σ ())
-> Int -> Tensor (Scalar (f p)) (M1 i c f p) w -> ST σ ()
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) σ (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> (v ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset @(f p) @w Mutable α σ (Scalar (f p))
ar)
coerceFmapTensorProduct :: ∀ ぴ a b
. (Hask.Functor ぴ, TensorSpace a, Scalar a ~ Scalar (f p)
, TensorSpace b, Scalar b ~ Scalar (f p) )
=> ぴ (Gnrx.M1 i c f p) -> VSCCoercion (Scalar (f p)) a b
-> Coercion (TensorProduct (Gnrx.M1 i c f p) a)
(TensorProduct (Gnrx.M1 i c f p) b)
coerceFmapTensorProduct :: forall (ぴ :: Type -> Type) a b.
(Functor ぴ, TensorSpace a, Scalar a ~ Scalar (f p), TensorSpace b,
Scalar b ~ Scalar (f p)) =>
ぴ (M1 i c f p)
-> VSCCoercion (Scalar (f p)) a b
-> Coercion
(TensorProduct (M1 i c f p) a) (TensorProduct (M1 i c f p) b)
coerceFmapTensorProduct ぴ (M1 i c f p)
p VSCCoercion (Scalar (f p)) a b
crc = case [f p]
-> VSCCoercion (Scalar (f p)) a b
-> Coercion (TensorProduct (f p) a) (TensorProduct (f p) b)
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (f p), TensorSpace b,
Scalar b ~ Scalar (f p)) =>
p (f p)
-> VSCCoercion (Scalar (f p)) a b
-> Coercion (TensorProduct (f p) a) (TensorProduct (f p) b)
coerceFmapTensorProduct ([]::[f p]) VSCCoercion (Scalar (f p)) a b
crc of
Coercion (TensorProduct (f p) a) (TensorProduct (f p) b)
Coercion -> Coercion (TensorProduct (f p) a) (TensorProduct (f p) b)
Coercion
(TensorProduct (M1 i c f p) a) (TensorProduct (M1 i c f p) b)
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion
instance ∀ f g p . ( DimensionAware (f p), DimensionAware (g p)
, Scalar (f p) ~ Scalar (g p) )
=> DimensionAware ((f:*:g) p) where
type StaticDimension ((f:*:g) p)
= Maybe.ZipWithPlus (StaticDimension (f p)) (StaticDimension (g p))
dimensionalityWitness :: DimensionalityWitness ((:*:) f g p)
dimensionalityWitness = case ( forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(f p)
, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(g p) ) of
(DimensionalityWitness (f p)
IsStaticDimensional, DimensionalityWitness (g p)
IsStaticDimensional)
-> SNat (n + n)
-> (KnownNat (n + n) => DimensionalityWitness ((:*:) f g p))
-> DimensionalityWitness ((:*:) f g p)
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(f p) Sing n -> Sing n -> Sing (Apply (Apply (+@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
%+ forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(g p))
DimensionalityWitness ((:*:) f g p)
KnownNat (n + n) => DimensionalityWitness ((:*:) f g p)
forall (n :: Nat) v. Dimensional n v => DimensionalityWitness v
IsStaticDimensional
(DimensionalityWitness (f p)
IsFlexibleDimensional, DimensionalityWitness (g p)
_) -> DimensionalityWitness ((:*:) f g p)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
(DimensionalityWitness (f p)
_, DimensionalityWitness (g p)
IsFlexibleDimensional) -> DimensionalityWitness ((:*:) f g p)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
instance ∀ n f m g p nm . ( n`Dimensional`(f p), m`Dimensional`(g p)
, Scalar (f p) ~ Scalar (g p)
, nm ~ (n+m) )
=> nm`Dimensional`((f:*:g) p) where
knownDimensionalitySing :: Sing nm
knownDimensionalitySing = forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(f p) Sing n -> Sing m -> Sing (Apply (Apply (+@#@$) n) m)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
%+ forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(g p)
unsafeFromArrayWithOffset :: forall (α :: Type -> Type).
Vector α (Scalar ((:*:) f g p)) =>
Int -> α (Scalar ((:*:) f g p)) -> (:*:) f g p
unsafeFromArrayWithOffset Int
i α (Scalar ((:*:) f g p))
ar
= Int -> α (Scalar (f p)) -> f p
forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
forall (α :: Type -> Type).
Vector α (Scalar (f p)) =>
Int -> α (Scalar (f p)) -> f p
unsafeFromArrayWithOffset Int
i α (Scalar (f p))
α (Scalar ((:*:) f g p))
ar
f p -> g p -> (:*:) f g p
forall k (f :: k -> Type) (g :: k -> Type) (p :: k).
f p -> g p -> (:*:) f g p
:*: Int -> α (Scalar (g p)) -> g p
forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
forall (α :: Type -> Type).
Vector α (Scalar (g p)) =>
Int -> α (Scalar (g p)) -> g p
unsafeFromArrayWithOffset (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ forall v (n :: Nat) a. (Dimensional n v, Integral a) => a
dimension @(f p)) α (Scalar (g p))
α (Scalar ((:*:) f g p))
ar
unsafeWriteArrayWithOffset :: forall (α :: Type -> Type) σ.
Vector α (Scalar ((:*:) f g p)) =>
Mutable α σ (Scalar ((:*:) f g p)) -> Int -> (:*:) f g p -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar ((:*:) f g p))
ar Int
i (f p
x:*:g p
y) = do
Mutable α σ (Scalar (f p)) -> Int -> f p -> ST σ ()
forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
forall (α :: Type -> Type) σ.
Vector α (Scalar (f p)) =>
Mutable α σ (Scalar (f p)) -> Int -> f p -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (f p))
Mutable α σ (Scalar ((:*:) f g p))
ar Int
i f p
x
Mutable α σ (Scalar (g p)) -> Int -> g p -> ST σ ()
forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
forall (α :: Type -> Type) σ.
Vector α (Scalar (g p)) =>
Mutable α σ (Scalar (g p)) -> Int -> g p -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (g p))
Mutable α σ (Scalar ((:*:) f g p))
ar (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ forall v (n :: Nat) a. (Dimensional n v, Integral a) => a
dimension @(f p)) g p
y
instance ∀ f g p . ( TensorSpace (f p), TensorSpace (g p), Scalar (f p) ~ Scalar (g p) )
=> TensorSpace ((f:*:g) p) where
type TensorProduct ((f:*:g) p) w = (f p⊗w, g p⊗w)
scalarSpaceWitness :: ScalarSpaceWitness ((:*:) f g p)
scalarSpaceWitness = case ( ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p)
, ScalarSpaceWitness (g p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (g p) ) of
(ScalarSpaceWitness (f p)
ScalarSpaceWitness, ScalarSpaceWitness (g p)
ScalarSpaceWitness) -> ScalarSpaceWitness ((:*:) f g p)
forall v.
(Num' (Scalar v), Scalar (Scalar v) ~ Scalar v) =>
ScalarSpaceWitness v
ScalarSpaceWitness
linearManifoldWitness :: LinearManifoldWitness ((:*:) f g p)
linearManifoldWitness = LinearManifoldWitness ((:*:) f g p)
forall a. a
genericTensorspaceError
zeroTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar ((:*:) f g p)) =>
(:*:) f g p ⊗ w
zeroTensor = TensorProduct ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (f p ⊗ w
Tensor (Scalar (g p)) (f p) w
forall w. (TensorSpace w, Scalar w ~ Scalar (f p)) => f p ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor, g p ⊗ w
forall w. (TensorSpace w, Scalar w ~ Scalar (g p)) => g p ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor)
scaleTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar ((:*:) f g p)) =>
Bilinear (Scalar ((:*:) f g p)) ((:*:) f g p ⊗ w) ((:*:) f g p ⊗ w)
scaleTensor = (Scalar (g p)
-> Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (Scalar (g p)))
(Scalar (g p))
(LinearFunction
(Scalar (Scalar (g p)))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((Scalar (g p)
-> Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (Scalar (g p)))
(Scalar (g p))
(LinearFunction
(Scalar (Scalar (g p)))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) ((:*:) f g p) w)))
-> (Scalar (g p)
-> Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (Scalar (g p)))
(Scalar (g p))
(LinearFunction
(Scalar (Scalar (g p)))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \Scalar (g p)
μ (Tensor (Tensor (Scalar (g p)) (f p) w
v,Tensor (Scalar (g p)) (g p) w
w)) ->
TensorProduct ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ( (Bilinear (Scalar (f p)) (f p ⊗ w) (f p ⊗ w)
LinearFunction
(Scalar (Scalar (f p)))
(Scalar (g p))
(LinearFunction
(Scalar (Scalar (g p)))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar (g p)) (f p) w))
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
Bilinear (Scalar (f p)) (f p ⊗ w) (f p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
scaleTensorLinearFunction
(Scalar (Scalar (f p)))
(Scalar (g p))
(LinearFunction
(Scalar (Scalar (g p)))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar (g p)) (f p) w))
-> Scalar (g p)
-> LinearFunction
(Scalar (Scalar (g p)))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar (g p)) (f p) w)
forall s v w. LinearFunction s v w -> v -> w
-+$>Scalar (g p)
μ)LinearFunction
(Scalar (Scalar (g p)))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar (g p)) (f p) w)
-> Tensor (Scalar (g p)) (f p) w -> Tensor (Scalar (g p)) (f p) w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (f p) w
v, (Bilinear
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar (g p)) (g p) w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (g p)) =>
Bilinear (Scalar (g p)) (g p ⊗ w) (g p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
scaleTensorBilinear
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar (g p)) (g p) w)
-> Scalar (g p)
-> LinearFunction
(Scalar (Scalar (g p)))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar (g p)) (g p) w)
forall s v w. LinearFunction s v w -> v -> w
-+$>Scalar (g p)
μ)LinearFunction
(Scalar (Scalar (g p)))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar (g p)) (g p) w)
-> Tensor (Scalar (g p)) (g p) w -> Tensor (Scalar (g p)) (g p) w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (g p) w
w )
negateTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar ((:*:) f g p)) =>
((:*:) f g p ⊗ w) -+> ((:*:) f g p ⊗ w)
negateTensor = (Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) ((:*:) f g p) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
-> (Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) ((:*:) f g p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Tensor (Tensor (Scalar (g p)) (f p) w
v,Tensor (Scalar (g p)) (g p) w
w))
-> TensorProduct ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (LinearFunction
(Scalar (f p))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar (g p)) (f p) w)
(f p ⊗ w) -+> (f p ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
(f p ⊗ w) -+> (f p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
negateTensorLinearFunction
(Scalar (f p))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar (g p)) (f p) w)
-> Tensor (Scalar (g p)) (f p) w -> Tensor (Scalar (g p)) (f p) w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (f p) w
v, LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar (g p)) (g p) w)
Tensor (Scalar (g p)) (g p) w -+> Tensor (Scalar (g p)) (g p) w
forall w.
(TensorSpace w, Scalar w ~ Scalar (g p)) =>
(g p ⊗ w) -+> (g p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
negateTensorLinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar (g p)) (g p) w)
-> Tensor (Scalar (g p)) (g p) w -> Tensor (Scalar (g p)) (g p) w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (g p) w
w)
addTensors :: forall w.
(TensorSpace w, Scalar w ~ Scalar ((:*:) f g p)) =>
((:*:) f g p ⊗ w) -> ((:*:) f g p ⊗ w) -> (:*:) f g p ⊗ w
addTensors (Tensor (Tensor (Scalar (g p)) (f p) w
fu, Tensor (Scalar (g p)) (g p) w
fv)) (Tensor (Tensor (Scalar (g p)) (f p) w
fu', Tensor (Scalar (g p)) (g p) w
fv'))
= TensorProduct ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (Tensor (Scalar (g p)) (f p) w
fu Tensor (Scalar (g p)) (f p) w
-> Tensor (Scalar (g p)) (f p) w -> Tensor (Scalar (g p)) (f p) w
forall v. AdditiveGroup v => v -> v -> v
^+^ Tensor (Scalar (g p)) (f p) w
fu', Tensor (Scalar (g p)) (g p) w
fv Tensor (Scalar (g p)) (g p) w
-> Tensor (Scalar (g p)) (g p) w -> Tensor (Scalar (g p)) (g p) w
forall v. AdditiveGroup v => v -> v -> v
^+^ Tensor (Scalar (g p)) (g p) w
fv')
subtractTensors :: forall w.
(TensorSpace ((:*:) f g p), TensorSpace w,
Scalar w ~ Scalar ((:*:) f g p)) =>
((:*:) f g p ⊗ w) -> ((:*:) f g p ⊗ w) -> (:*:) f g p ⊗ w
subtractTensors (Tensor (Tensor (Scalar (g p)) (f p) w
fu, Tensor (Scalar (g p)) (g p) w
fv)) (Tensor (Tensor (Scalar (g p)) (f p) w
fu', Tensor (Scalar (g p)) (g p) w
fv'))
= TensorProduct ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (Tensor (Scalar (g p)) (f p) w
fu Tensor (Scalar (g p)) (f p) w
-> Tensor (Scalar (g p)) (f p) w -> Tensor (Scalar (g p)) (f p) w
forall v. AdditiveGroup v => v -> v -> v
^-^ Tensor (Scalar (g p)) (f p) w
fu', Tensor (Scalar (g p)) (g p) w
fv Tensor (Scalar (g p)) (g p) w
-> Tensor (Scalar (g p)) (g p) w -> Tensor (Scalar (g p)) (g p) w
forall v. AdditiveGroup v => v -> v -> v
^-^ Tensor (Scalar (g p)) (g p) w
fv')
toFlatTensor :: (:*:) f g p -+> ((:*:) f g p ⊗ Scalar ((:*:) f g p))
toFlatTensor = ((:*:) f g p -> Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p)))
-> LinearFunction
(Scalar (g p))
((:*:) f g p)
(Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p)))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction
(((:*:) f g p
-> Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p)))
-> LinearFunction
(Scalar (g p))
((:*:) f g p)
(Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p))))
-> ((:*:) f g p
-> Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p)))
-> LinearFunction
(Scalar (g p))
((:*:) f g p)
(Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p)))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(f p
u:*:g p
v) -> TensorProduct ((:*:) f g p) (Scalar (g p))
-> Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p))
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (LinearFunction
(Scalar (g p)) (f p) (Tensor (Scalar (g p)) (f p) (Scalar (g p)))
f p -+> (f p ⊗ Scalar (f p))
forall v. TensorSpace v => v -+> (v ⊗ Scalar v)
toFlatTensorLinearFunction
(Scalar (g p)) (f p) (Tensor (Scalar (g p)) (f p) (Scalar (g p)))
-> f p -> Tensor (Scalar (g p)) (f p) (Scalar (g p))
forall s v w. LinearFunction s v w -> v -> w
-+$>f p
u, LinearFunction
(Scalar (g p)) (g p) (Tensor (Scalar (g p)) (g p) (Scalar (g p)))
g p -+> Tensor (Scalar (g p)) (g p) (Scalar (g p))
forall v. TensorSpace v => v -+> (v ⊗ Scalar v)
toFlatTensorLinearFunction
(Scalar (g p)) (g p) (Tensor (Scalar (g p)) (g p) (Scalar (g p)))
-> g p -> Tensor (Scalar (g p)) (g p) (Scalar (g p))
forall s v w. LinearFunction s v w -> v -> w
-+$>g p
v)
fromFlatTensor :: ((:*:) f g p ⊗ Scalar ((:*:) f g p)) -+> (:*:) f g p
fromFlatTensor = (Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p)) -> (:*:) f g p)
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p)))
((:*:) f g p)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction
((Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p))
-> (:*:) f g p)
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p)))
((:*:) f g p))
-> (Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p))
-> (:*:) f g p)
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) (Scalar (g p)))
((:*:) f g p)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Tensor (Tensor (Scalar (g p)) (f p) (Scalar (g p))
u,Tensor (Scalar (g p)) (g p) (Scalar (g p))
v)) -> ((f p ⊗ Scalar (f p)) -+> f p
LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) (f p) (Scalar (g p))) (f p)
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensorLinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) (f p) (Scalar (g p))) (f p)
-> Tensor (Scalar (g p)) (f p) (Scalar (g p)) -> f p
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (f p) (Scalar (g p))
u)f p -> g p -> (:*:) f g p
forall k (f :: k -> Type) (g :: k -> Type) (p :: k).
f p -> g p -> (:*:) f g p
:*:(Tensor (Scalar (g p)) (g p) (Scalar (g p)) -+> g p
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor(Tensor (Scalar (g p)) (g p) (Scalar (g p)) -+> g p)
-> Tensor (Scalar (g p)) (g p) (Scalar (g p)) -> g p
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (g p) (Scalar (g p))
v)
tensorProduct :: forall w.
(TensorSpace w, Scalar w ~ Scalar ((:*:) f g p)) =>
Bilinear ((:*:) f g p) w ((:*:) f g p ⊗ w)
tensorProduct = ((:*:) f g p -> w -> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p))
((:*:) f g p)
(LinearFunction
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w))
((:*:) f g p -> w -> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> Bilinear ((:*:) f g p) w (Tensor (Scalar (g p)) ((:*:) f g p) w)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction (((:*:) f g p -> w -> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p))
((:*:) f g p)
(LinearFunction
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w)))
-> ((:*:) f g p -> w -> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p))
((:*:) f g p)
(LinearFunction
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(f p
u:*:g p
v) w
w ->
TensorProduct ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ((Bilinear (f p) w (f p ⊗ w)
LinearFunction
(Scalar (g p))
(f p)
(LinearFunction (Scalar (g p)) w (Tensor (Scalar (g p)) (f p) w))
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
Bilinear (f p) w (f p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductLinearFunction
(Scalar (g p))
(f p)
(LinearFunction (Scalar (g p)) w (Tensor (Scalar (g p)) (f p) w))
-> f p
-> LinearFunction (Scalar (g p)) w (Tensor (Scalar (g p)) (f p) w)
forall s v w. LinearFunction s v w -> v -> w
-+$>f p
u)LinearFunction (Scalar (g p)) w (Tensor (Scalar (g p)) (f p) w)
-> w -> Tensor (Scalar (g p)) (f p) w
forall s v w. LinearFunction s v w -> v -> w
-+$>w
w, (Bilinear (g p) w (g p ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (g p)) =>
Bilinear (g p) w (g p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductBilinear (g p) w (g p ⊗ w)
-> g p -> LinearFunction (Scalar (g p)) w (g p ⊗ w)
forall s v w. LinearFunction s v w -> v -> w
-+$>g p
v)LinearFunction (Scalar (g p)) w (g p ⊗ w) -> w -> g p ⊗ w
forall s v w. LinearFunction s v w -> v -> w
-+$>w
w)
transposeTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar ((:*:) f g p)) =>
((:*:) f g p ⊗ w) -+> (w ⊗ (:*:) f g p)
transposeTensor = (Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) w ((:*:) f g p))
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) w ((:*:) f g p))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) w ((:*:) f g p))
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) w ((:*:) f g p)))
-> (Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) w ((:*:) f g p))
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) w ((:*:) f g p))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Tensor (Tensor (Scalar (g p)) (f p) w
uw,Tensor (Scalar (g p)) (g p) w
vw))
-> (LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (f p, g p) ((:*:) f g p))
(LinearFunction
(Scalar w)
(Tensor (Scalar w) w (f p), Tensor (Scalar w) w (g p))
(Tensor (Scalar (g p)) w ((:*:) f g p)))
Bilinear
((f p, g p) -+> (:*:) f g p)
(Tensor (Scalar w) w (f p), Tensor (Scalar w) w (g p))
(Tensor (Scalar w) w ((:*:) f g p))
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar w,
Scalar w ~ Scalar w, Scalar x ~ Scalar w) =>
Bilinear ((w, x) -+> u) (w ⊗ w, w ⊗ x) (w ⊗ u)
fzipTensorWithLinearFunction
(Scalar w)
(LinearFunction (Scalar w) (f p, g p) ((:*:) f g p))
(LinearFunction
(Scalar w)
(Tensor (Scalar w) w (f p), Tensor (Scalar w) w (g p))
(Tensor (Scalar (g p)) w ((:*:) f g p)))
-> LinearFunction (Scalar w) (f p, g p) ((:*:) f g p)
-> LinearFunction
(Scalar w)
(Tensor (Scalar w) w (f p), Tensor (Scalar w) w (g p))
(Tensor (Scalar (g p)) w ((:*:) f g p))
forall s v w. LinearFunction s v w -> v -> w
-+$>((f p, g p) -> (:*:) f g p)
-> LinearFunction (Scalar w) (f p, g p) ((:*:) f g p)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (\(f p
u,g p
v)->f p
uf p -> g p -> (:*:) f g p
forall k (f :: k -> Type) (g :: k -> Type) (p :: k).
f p -> g p -> (:*:) f g p
:*:g p
v))
LinearFunction
(Scalar w)
(Tensor (Scalar w) w (f p), Tensor (Scalar w) w (g p))
(Tensor (Scalar (g p)) w ((:*:) f g p))
-> (Tensor (Scalar w) w (f p), Tensor (Scalar w) w (g p))
-> Tensor (Scalar (g p)) w ((:*:) f g p)
forall s v w. LinearFunction s v w -> v -> w
-+$>(LinearFunction
(Scalar (f p))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar w) w (f p))
(f p ⊗ w) -+> Tensor (Scalar w) w (f p)
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
(f p ⊗ w) -+> (w ⊗ f p)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensorLinearFunction
(Scalar (f p))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar w) w (f p))
-> Tensor (Scalar (g p)) (f p) w -> Tensor (Scalar w) w (f p)
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (f p) w
uw,LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar w) w (g p))
Tensor (Scalar (g p)) (g p) w -+> Tensor (Scalar w) w (g p)
forall w.
(TensorSpace w, Scalar w ~ Scalar (g p)) =>
(g p ⊗ w) -+> (w ⊗ g p)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensorLinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar w) w (g p))
-> Tensor (Scalar (g p)) (g p) w -> Tensor (Scalar w) w (g p)
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (g p) w
vw)
fmapTensor :: forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar ((:*:) f g p),
Scalar x ~ Scalar ((:*:) f g p)) =>
Bilinear (w -+> x) ((:*:) f g p ⊗ w) ((:*:) f g p ⊗ x)
fmapTensor = (LinearFunction (Scalar (g p)) w x
-> Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) x)
-> LinearFunction
(Scalar (g p))
(LinearFunction (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) ((:*:) f g p) x))
(LinearFunction (Scalar (g p)) w x
-> Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) x)
-> Bilinear
(LinearFunction (Scalar (g p)) w x)
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) ((:*:) f g p) x)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction (Scalar (g p)) w x
-> Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) x)
-> LinearFunction
(Scalar (g p))
(LinearFunction (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) ((:*:) f g p) x)))
-> (LinearFunction (Scalar (g p)) w x
-> Tensor (Scalar (g p)) ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) x)
-> LinearFunction
(Scalar (g p))
(LinearFunction (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) ((:*:) f g p) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction (Scalar (g p)) w x
f (Tensor (Tensor (Scalar (g p)) (f p) w
uw,Tensor (Scalar (g p)) (g p) w
vw)) -> TensorProduct ((:*:) f g p) x
-> Tensor (Scalar (g p)) ((:*:) f g p) x
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ((LinearFunction
(Scalar (f p))
(LinearFunction (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar (g p)) (f p) x))
Bilinear (LinearFunction (Scalar x) w x) (f p ⊗ w) (f p ⊗ x)
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (f p),
Scalar x ~ Scalar (f p)) =>
Bilinear (w -+> x) (f p ⊗ w) (f p ⊗ x)
fmapTensorLinearFunction
(Scalar (f p))
(LinearFunction (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar (g p)) (f p) x))
-> LinearFunction (Scalar (g p)) w x
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar (g p)) (f p) x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (g p)) w x
f)LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (f p) w)
(Tensor (Scalar (g p)) (f p) x)
-> Tensor (Scalar (g p)) (f p) w -> Tensor (Scalar (g p)) (f p) x
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (f p) w
uw, (LinearFunction
(Scalar (g p))
(LinearFunction (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar (g p)) (g p) x))
Bilinear
(LinearFunction (Scalar x) w x)
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar (g p)) (g p) x)
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (g p),
Scalar x ~ Scalar (g p)) =>
Bilinear (w -+> x) (g p ⊗ w) (g p ⊗ x)
fmapTensorLinearFunction
(Scalar (g p))
(LinearFunction (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar (g p)) (g p) x))
-> LinearFunction (Scalar (g p)) w x
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar (g p)) (g p) x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (g p)) w x
f)LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w)
(Tensor (Scalar (g p)) (g p) x)
-> Tensor (Scalar (g p)) (g p) w -> Tensor (Scalar (g p)) (g p) x
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (g p) w
vw)
fzipTensorWith :: forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar ((:*:) f g p), Scalar w ~ Scalar ((:*:) f g p),
Scalar x ~ Scalar ((:*:) f g p)) =>
Bilinear
((w, x) -+> u) ((:*:) f g p ⊗ w, (:*:) f g p ⊗ x) ((:*:) f g p ⊗ u)
fzipTensorWith = (LinearFunction (Scalar (g p)) (w, x) u
-> (Tensor (Scalar (g p)) ((:*:) f g p) w,
Tensor (Scalar (g p)) ((:*:) f g p) x)
-> Tensor (Scalar (g p)) ((:*:) f g p) u)
-> LinearFunction
(Scalar (g p))
(LinearFunction (Scalar (g p)) (w, x) u)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w,
Tensor (Scalar (g p)) ((:*:) f g p) x)
(Tensor (Scalar (g p)) ((:*:) f g p) u))
(LinearFunction (Scalar (g p)) (w, x) u
-> (Tensor (Scalar (g p)) ((:*:) f g p) w,
Tensor (Scalar (g p)) ((:*:) f g p) x)
-> Tensor (Scalar (g p)) ((:*:) f g p) u)
-> Bilinear
(LinearFunction (Scalar (g p)) (w, x) u)
(Tensor (Scalar (g p)) ((:*:) f g p) w,
Tensor (Scalar (g p)) ((:*:) f g p) x)
(Tensor (Scalar (g p)) ((:*:) f g p) u)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction
((LinearFunction (Scalar (g p)) (w, x) u
-> (Tensor (Scalar (g p)) ((:*:) f g p) w,
Tensor (Scalar (g p)) ((:*:) f g p) x)
-> Tensor (Scalar (g p)) ((:*:) f g p) u)
-> LinearFunction
(Scalar (g p))
(LinearFunction (Scalar (g p)) (w, x) u)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w,
Tensor (Scalar (g p)) ((:*:) f g p) x)
(Tensor (Scalar (g p)) ((:*:) f g p) u)))
-> (LinearFunction (Scalar (g p)) (w, x) u
-> (Tensor (Scalar (g p)) ((:*:) f g p) w,
Tensor (Scalar (g p)) ((:*:) f g p) x)
-> Tensor (Scalar (g p)) ((:*:) f g p) u)
-> LinearFunction
(Scalar (g p))
(LinearFunction (Scalar (g p)) (w, x) u)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w,
Tensor (Scalar (g p)) ((:*:) f g p) x)
(Tensor (Scalar (g p)) ((:*:) f g p) u))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction (Scalar (g p)) (w, x) u
f (Tensor (Tensor (Scalar (g p)) (f p) w
uw, Tensor (Scalar (g p)) (g p) w
vw), Tensor (Tensor (Scalar (g p)) (f p) x
ux, Tensor (Scalar (g p)) (g p) x
vx))
-> TensorProduct ((:*:) f g p) u
-> Tensor (Scalar (g p)) ((:*:) f g p) u
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ( (LinearFunction
(Scalar (f p))
(LinearFunction (Scalar (g p)) (w, x) u)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (f p) w, Tensor (Scalar (g p)) (f p) x)
(Tensor (Scalar (g p)) (f p) u))
Bilinear
(LinearFunction (Scalar u) (w, x) u) (f p ⊗ w, f p ⊗ x) (f p ⊗ u)
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (f p), Scalar w ~ Scalar (f p),
Scalar x ~ Scalar (f p)) =>
Bilinear ((w, x) -+> u) (f p ⊗ w, f p ⊗ x) (f p ⊗ u)
fzipTensorWithLinearFunction
(Scalar (f p))
(LinearFunction (Scalar (g p)) (w, x) u)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (f p) w, Tensor (Scalar (g p)) (f p) x)
(Tensor (Scalar (g p)) (f p) u))
-> LinearFunction (Scalar (g p)) (w, x) u
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (f p) w, Tensor (Scalar (g p)) (f p) x)
(Tensor (Scalar (g p)) (f p) u)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (g p)) (w, x) u
f)LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (f p) w, Tensor (Scalar (g p)) (f p) x)
(Tensor (Scalar (g p)) (f p) u)
-> (Tensor (Scalar (g p)) (f p) w, Tensor (Scalar (g p)) (f p) x)
-> Tensor (Scalar (g p)) (f p) u
forall s v w. LinearFunction s v w -> v -> w
-+$>(Tensor (Scalar (g p)) (f p) w
uw,Tensor (Scalar (g p)) (f p) x
ux)
, (LinearFunction
(Scalar (g p))
(LinearFunction (Scalar (g p)) (w, x) u)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w, Tensor (Scalar (g p)) (g p) x)
(Tensor (Scalar (g p)) (g p) u))
Bilinear
(LinearFunction (Scalar u) (w, x) u)
(Tensor (Scalar (g p)) (g p) w, Tensor (Scalar (g p)) (g p) x)
(Tensor (Scalar (g p)) (g p) u)
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (g p), Scalar w ~ Scalar (g p),
Scalar x ~ Scalar (g p)) =>
Bilinear ((w, x) -+> u) (g p ⊗ w, g p ⊗ x) (g p ⊗ u)
fzipTensorWithLinearFunction
(Scalar (g p))
(LinearFunction (Scalar (g p)) (w, x) u)
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w, Tensor (Scalar (g p)) (g p) x)
(Tensor (Scalar (g p)) (g p) u))
-> LinearFunction (Scalar (g p)) (w, x) u
-> LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w, Tensor (Scalar (g p)) (g p) x)
(Tensor (Scalar (g p)) (g p) u)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (g p)) (w, x) u
f)LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) (g p) w, Tensor (Scalar (g p)) (g p) x)
(Tensor (Scalar (g p)) (g p) u)
-> (Tensor (Scalar (g p)) (g p) w, Tensor (Scalar (g p)) (g p) x)
-> Tensor (Scalar (g p)) (g p) u
forall s v w. LinearFunction s v w -> v -> w
-+$>(Tensor (Scalar (g p)) (g p) w
vw,Tensor (Scalar (g p)) (g p) x
vx) )
tensorUnsafeFromArrayWithOffset
:: ∀ w m α . ( TensorSpace w, m`Dimensional`w, Scalar w ~ Scalar (f p)
, GArr.Vector α (Scalar (f p)) )
=> Int -> α (Scalar (f p)) -> ((f:*:g) p⊗w)
tensorUnsafeFromArrayWithOffset :: forall w (m :: Nat) (α :: Type -> Type).
(TensorSpace w, Dimensional m w, Scalar w ~ Scalar (f p),
Vector α (Scalar (f p))) =>
Int -> α (Scalar (f p)) -> (:*:) f g p ⊗ w
tensorUnsafeFromArrayWithOffset
= case (forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(f p), forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(g p)) of
(DimensionalityWitness (f p)
IsFlexibleDimensional, DimensionalityWitness (g p)
_) -> [Char]
-> Int -> α (Scalar (g p)) -> Tensor (Scalar (g p)) ((:*:) f g p) w
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `f p` is static-dimensional."
(DimensionalityWitness (f p)
_, DimensionalityWitness (g p)
IsFlexibleDimensional) -> [Char]
-> Int -> α (Scalar (g p)) -> Tensor (Scalar (g p)) ((:*:) f g p) w
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `g p` is static-dimensional."
(DimensionalityWitness (f p)
IsStaticDimensional, DimensionalityWitness (g p)
IsStaticDimensional)
-> SNat (n + n)
-> (KnownNat (n + n) =>
Int -> α (Scalar (g p)) -> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> Int
-> α (Scalar (g p))
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(f p) Sing n -> Sing n -> Sing (Apply (Apply (+@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
%+ forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(g p))
(\Int
i α (Scalar (g p))
ar
-> Tensor (Scalar (g p)) (f p, g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v ⊗ w
tensorUnsafeFromArrayWithOffset @(f p, g p) @w Int
i α (Scalar (g p))
α (Scalar (f p, g p))
ar) )
tensorUnsafeWriteArrayWithOffset
:: ∀ w m α σ . ( TensorSpace w, m`Dimensional`w, Scalar w ~ Scalar (f p)
, GArr.Vector α (Scalar (f p)) )
=> GArr.Mutable α σ (Scalar (f p)) -> Int -> ((f:*:g) p⊗w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset :: forall w (m :: Nat) (α :: Type -> Type) σ.
(TensorSpace w, Dimensional m w, Scalar w ~ Scalar (f p),
Vector α (Scalar (f p))) =>
Mutable α σ (Scalar (f p)) -> Int -> ((:*:) f g p ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset
= case (forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(f p), forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(g p)) of
(DimensionalityWitness (f p)
IsFlexibleDimensional, DimensionalityWitness (g p)
_) -> [Char]
-> Mutable α σ (Scalar (g p))
-> Int
-> Tensor (Scalar (g p)) ((:*:) f g p) w
-> ST σ ()
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `f p` is static-dimensional."
(DimensionalityWitness (f p)
_, DimensionalityWitness (g p)
IsFlexibleDimensional) -> [Char]
-> Mutable α σ (Scalar (g p))
-> Int
-> Tensor (Scalar (g p)) ((:*:) f g p) w
-> ST σ ()
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `g p` is static-dimensional."
(DimensionalityWitness (f p)
IsStaticDimensional, DimensionalityWitness (g p)
IsStaticDimensional)
-> SNat (n + n)
-> (KnownNat (n + n) =>
Mutable α σ (Scalar (g p))
-> Int -> Tensor (Scalar (g p)) ((:*:) f g p) w -> ST σ ())
-> Mutable α σ (Scalar (g p))
-> Int
-> Tensor (Scalar (g p)) ((:*:) f g p) w
-> ST σ ()
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(f p) Sing n -> Sing n -> Sing (Apply (Apply (+@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
%+ forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(g p))
(\Mutable α σ (Scalar (g p))
ar
-> (Int -> Tensor (Scalar (g p)) (f p, g p) w -> ST σ ())
-> Int -> Tensor (Scalar (g p)) ((:*:) f g p) w -> ST σ ()
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) σ (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> (v ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset @(f p, g p) @w Mutable α σ (Scalar (g p))
Mutable α σ (Scalar (f p, g p))
ar) )
coerceFmapTensorProduct :: forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar ((:*:) f g p),
TensorSpace b, Scalar b ~ Scalar ((:*:) f g p)) =>
p ((:*:) f g p)
-> VSCCoercion (Scalar ((:*:) f g p)) a b
-> Coercion
(TensorProduct ((:*:) f g p) a) (TensorProduct ((:*:) f g p) b)
coerceFmapTensorProduct p ((:*:) f g p)
p VSCCoercion (Scalar ((:*:) f g p)) a b
cab = case
( p (f p)
-> VSCCoercion (Scalar (f p)) a b
-> Coercion (TensorProduct (f p) a) (TensorProduct (f p) b)
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (f p), TensorSpace b,
Scalar b ~ Scalar (f p)) =>
p (f p)
-> VSCCoercion (Scalar (f p)) a b
-> Coercion (TensorProduct (f p) a) (TensorProduct (f p) b)
coerceFmapTensorProduct ((\(f p
u:*:g p
_)->f p
u)((:*:) f g p -> f p) -> p ((:*:) f g p) -> p (f p)
forall (f :: Type -> Type) (r :: Type -> Type -> Type) a b.
(Functor f r (->), Object r a, Object r b) =>
r a b -> f a -> f b
<$>p ((:*:) f g p)
p) VSCCoercion (Scalar (f p)) a b
VSCCoercion (Scalar ((:*:) f g p)) a b
cab
, p (g p)
-> VSCCoercion (Scalar (g p)) a b
-> Coercion (TensorProduct (g p) a) (TensorProduct (g p) b)
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (g p), TensorSpace b,
Scalar b ~ Scalar (g p)) =>
p (g p)
-> VSCCoercion (Scalar (g p)) a b
-> Coercion (TensorProduct (g p) a) (TensorProduct (g p) b)
coerceFmapTensorProduct ((\(f p
_:*:g p
v)->g p
v)((:*:) f g p -> g p) -> p ((:*:) f g p) -> p (g p)
forall (f :: Type -> Type) (r :: Type -> Type -> Type) a b.
(Functor f r (->), Object r a, Object r b) =>
r a b -> f a -> f b
<$>p ((:*:) f g p)
p) VSCCoercion (Scalar (g p)) a b
VSCCoercion (Scalar ((:*:) f g p)) a b
cab ) of
(Coercion (TensorProduct (f p) a) (TensorProduct (f p) b)
Coercion, Coercion (TensorProduct (g p) a) (TensorProduct (g p) b)
Coercion) -> Coercion
(Tensor (Scalar (g p)) (f p) a, Tensor (Scalar (g p)) (g p) a)
(Tensor (Scalar (g p)) (f p) b, Tensor (Scalar (g p)) (g p) b)
Coercion
(TensorProduct ((:*:) f g p) a) (TensorProduct ((:*:) f g p) b)
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion
wellDefinedVector :: (:*:) f g p -> Maybe ((:*:) f g p)
wellDefinedVector (f p
u:*:g p
v) = (f p -> g p -> (:*:) f g p)
-> Maybe (f p) -> Maybe (g p) -> Maybe ((:*:) f g p)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) c b a.
(Applicative f r t, Object r c, ObjectMorphism r b c,
Object t (f c), ObjectMorphism t (f b) (f c), ObjectPair r a b,
ObjectPair t (f a) (f b)) =>
r a (r b c) -> t (f a) (t (f b) (f c))
liftA2 f p -> g p -> (:*:) f g p
forall k (f :: k -> Type) (g :: k -> Type) (p :: k).
f p -> g p -> (:*:) f g p
(:*:) (f p -> Maybe (f p)
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector f p
u) (g p -> Maybe (g p)
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector g p
v)
wellDefinedTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar ((:*:) f g p)) =>
((:*:) f g p ⊗ w) -> Maybe ((:*:) f g p ⊗ w)
wellDefinedTensor (Tensor (Tensor (Scalar (g p)) (f p) w
u,Tensor (Scalar (g p)) (g p) w
v))
= (Tensor (Scalar (g p)) (f p) w
-> Tensor (Scalar (g p)) (g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> Maybe (Tensor (Scalar (g p)) (f p) w)
-> Maybe (Tensor (Scalar (g p)) (g p) w)
-> Maybe (Tensor (Scalar (g p)) ((:*:) f g p) w)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) c b a.
(Applicative f r t, Object r c, ObjectMorphism r b c,
Object t (f c), ObjectMorphism t (f b) (f c), ObjectPair r a b,
ObjectPair t (f a) (f b)) =>
r a (r b c) -> t (f a) (t (f b) (f c))
liftA2 (((Tensor (Scalar (g p)) (f p) w, Tensor (Scalar (g p)) (g p) w)
-> Tensor (Scalar (g p)) ((:*:) f g p) w
TensorProduct ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor((Tensor (Scalar (g p)) (f p) w, Tensor (Scalar (g p)) (g p) w)
-> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> (Tensor (Scalar (g p)) (g p) w
-> (Tensor (Scalar (g p)) (f p) w, Tensor (Scalar (g p)) (g p) w))
-> Tensor (Scalar (g p)) (g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
.) ((Tensor (Scalar (g p)) (g p) w
-> (Tensor (Scalar (g p)) (f p) w, Tensor (Scalar (g p)) (g p) w))
-> Tensor (Scalar (g p)) (g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> (Tensor (Scalar (g p)) (f p) w
-> Tensor (Scalar (g p)) (g p) w
-> (Tensor (Scalar (g p)) (f p) w, Tensor (Scalar (g p)) (g p) w))
-> Tensor (Scalar (g p)) (f p) w
-> Tensor (Scalar (g p)) (g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. (,)) ((f p ⊗ w) -> Maybe (f p ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
(f p ⊗ w) -> Maybe (f p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor f p ⊗ w
Tensor (Scalar (g p)) (f p) w
u) (Tensor (Scalar (g p)) (g p) w
-> Maybe (Tensor (Scalar (g p)) (g p) w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (g p)) =>
(g p ⊗ w) -> Maybe (g p ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor Tensor (Scalar (g p)) (g p) w
v)
instance ∀ m . ( Semimanifold m, DimensionAware (Needle (VRep m))
, Scalar (Needle m) ~ Scalar (Needle (VRep m)) )
=> DimensionAware (GenericNeedle m) where
type StaticDimension (GenericNeedle m) = StaticDimension (Needle (VRep m))
dimensionalityWitness :: DimensionalityWitness (GenericNeedle m)
dimensionalityWitness = case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(Needle (VRep m)) of
DimensionalityWitness (Needle (VRep m))
IsStaticDimensional -> DimensionalityWitness (GenericNeedle m)
forall (n :: Nat) v. Dimensional n v => DimensionalityWitness v
IsStaticDimensional
DimensionalityWitness (Needle (VRep m))
IsFlexibleDimensional -> DimensionalityWitness (GenericNeedle m)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
instance ∀ n m . ( Semimanifold m, n`Dimensional`Needle (VRep m)
, Scalar (Needle m) ~ Scalar (Needle (VRep m)) )
=> n`Dimensional`GenericNeedle m where
knownDimensionalitySing :: Sing n
knownDimensionalitySing = forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(Needle (VRep m))
unsafeFromArrayWithOffset :: forall (α :: Type -> Type).
Vector α (Scalar (GenericNeedle m)) =>
Int -> α (Scalar (GenericNeedle m)) -> GenericNeedle m
unsafeFromArrayWithOffset Int
i α (Scalar (GenericNeedle m))
ar
= Needle (VRep m) -> GenericNeedle m
forall a b. Coercible a b => a -> b
coerce (forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
unsafeFromArrayWithOffset @n @(Needle (VRep m)) Int
i α (Scalar (GenericNeedle m))
α (Scalar (Needle (VRep m)))
ar)
unsafeWriteArrayWithOffset :: forall (α :: Type -> Type) σ.
Vector α (Scalar (GenericNeedle m)) =>
Mutable α σ (Scalar (GenericNeedle m))
-> Int -> GenericNeedle m -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (GenericNeedle m))
ar Int
i
= (Needle (VRep m) -> ST σ ()) -> GenericNeedle m -> ST σ ()
forall a b. Coercible a b => a -> b
coerce (forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
unsafeWriteArrayWithOffset @n @(Needle (VRep m)) Mutable α σ (Scalar (GenericNeedle m))
Mutable α σ (Scalar (Needle (VRep m)))
ar Int
i)
instance ∀ m . ( Semimanifold m, TensorSpace (Needle (VRep m))
, Scalar (Needle m) ~ Scalar (Needle (VRep m)) )
=> TensorSpace (GenericNeedle m) where
type TensorProduct (GenericNeedle m) w = TensorProduct (Needle (VRep m)) w
wellDefinedVector :: GenericNeedle m -> Maybe (GenericNeedle m)
wellDefinedVector = (Needle (VRep m) -> GenericNeedle m)
-> Maybe (Needle (VRep m)) -> Maybe (GenericNeedle m)
forall a b.
(Object (->) a, Object (->) (Maybe a), Object (->) b,
Object (->) (Maybe b)) =>
(a -> b) -> Maybe a -> Maybe b
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle (Maybe (Needle (VRep m)) -> Maybe (GenericNeedle m))
-> (GenericNeedle m -> Maybe (Needle (VRep m)))
-> GenericNeedle m
-> Maybe (GenericNeedle m)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Needle (VRep m) -> Maybe (Needle (VRep m))
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector (Needle (VRep m) -> Maybe (Needle (VRep m)))
-> (GenericNeedle m -> Needle (VRep m))
-> GenericNeedle m
-> Maybe (Needle (VRep m))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. GenericNeedle m -> Needle (VRep m)
forall x. GenericNeedle x -> Needle (VRep x)
getGenericNeedle
wellDefinedTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) =>
(GenericNeedle m ⊗ w) -> Maybe (GenericNeedle m ⊗ w)
wellDefinedTensor = Coercion
(Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w))
(Maybe (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
-> Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> Maybe (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (Coercion
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Coercion
(Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w))
(Maybe (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
forall a b.
(Object Coercion a, Object Coercion (Maybe a), Object Coercion b,
Object Coercion (Maybe b)) =>
Coercion a b -> Coercion (Maybe a) (Maybe b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (Coercion
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Coercion
(Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w))
(Maybe (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)))
-> (VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Coercion
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Coercion
(Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w))
(Maybe (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Coercion
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion (VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Coercion
(Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w))
(Maybe (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)))
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Coercion
(Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w))
(Maybe (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Needle (VRep m) -> GenericNeedle m)
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle)
(Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> Maybe (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
-> (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w))
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Maybe (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle (VRep m))) =>
(Needle (VRep m) ⊗ w) -> Maybe (Needle (VRep m) ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w))
-> (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Maybe (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. ((GenericNeedle m -> Needle (VRep m))
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle m -> Needle (VRep m)
forall x. GenericNeedle x -> Needle (VRep x)
getGenericNeedleVSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
scalarSpaceWitness :: ScalarSpaceWitness (GenericNeedle m)
scalarSpaceWitness = case ScalarSpaceWitness (Needle (VRep m))
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness
:: ScalarSpaceWitness (Needle (VRep m)) of
ScalarSpaceWitness (Needle (VRep m))
ScalarSpaceWitness -> ScalarSpaceWitness (GenericNeedle m)
forall v.
(Num' (Scalar v), Scalar (Scalar v) ~ Scalar v) =>
ScalarSpaceWitness v
ScalarSpaceWitness
linearManifoldWitness :: LinearManifoldWitness (GenericNeedle m)
linearManifoldWitness = case LinearManifoldWitness (Needle (VRep m))
forall v. TensorSpace v => LinearManifoldWitness v
linearManifoldWitness
:: LinearManifoldWitness (Needle (VRep m)) of
LinearManifoldWitness (Needle (VRep m))
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
-> LinearManifoldWitness (GenericNeedle m)
forall v.
(Needle v ~ v, AffineSpace v, Diff v ~ v) =>
LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
zeroTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) =>
GenericNeedle m ⊗ w
zeroTensor = (Needle (VRep m) -> GenericNeedle m)
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle (VRep m))) =>
Needle (VRep m) ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor
toFlatTensor :: GenericNeedle m -+> (GenericNeedle m ⊗ Scalar (GenericNeedle m))
toFlatTensor = (GenericNeedle m
-> Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
-> LinearFunction
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((GenericNeedle m
-> Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
-> LinearFunction
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m)))))
-> (GenericNeedle m
-> Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
-> LinearFunction
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ ((Needle (VRep m) -> GenericNeedle m)
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m))))
(Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedleVSCCoercion
(Scalar (Needle (VRep m)))
(Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m))))
(Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
-> Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m)))
-> Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m)))
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
(Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m)))
-> Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
-> (GenericNeedle m
-> Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m))))
-> GenericNeedle m
-> Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m)))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m))))
-> Needle (VRep m)
-> Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m)))
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m))))
Needle (VRep m)
-+> Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m)))
forall v. TensorSpace v => v -+> (v ⊗ Scalar v)
toFlatTensor
(Needle (VRep m)
-> Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m))))
-> (GenericNeedle m -> Needle (VRep m))
-> GenericNeedle m
-> Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m)))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. GenericNeedle m -> Needle (VRep m)
forall x. GenericNeedle x -> Needle (VRep x)
getGenericNeedle
fromFlatTensor :: (GenericNeedle m ⊗ Scalar (GenericNeedle m)) -+> GenericNeedle m
fromFlatTensor = (Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m)))
-> GenericNeedle m)
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
(GenericNeedle m)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m)))
-> GenericNeedle m)
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
(GenericNeedle m))
-> (Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m)))
-> GenericNeedle m)
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
(GenericNeedle m)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ ((GenericNeedle m -> Needle (VRep m))
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
(Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m))))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle m -> Needle (VRep m)
forall x. GenericNeedle x -> Needle (VRep x)
getGenericNeedleVSCCoercion
(Scalar (Needle (VRep m)))
(Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m))))
(Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m))))
-> Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m)))
-> Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m)))
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
(Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m)))
-> Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m))))
-> (Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m)))
-> GenericNeedle m)
-> Tensor
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(Scalar (Needle (VRep m)))
-> GenericNeedle m
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m))))
(Needle (VRep m))
-> Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m)))
-> Needle (VRep m)
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar (Needle (VRep m)))
(Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m))))
(Needle (VRep m))
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor
(Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m)))
-> Needle (VRep m))
-> (Needle (VRep m) -> GenericNeedle m)
-> Tensor
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m)))
-> GenericNeedle m
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle
addTensors :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) =>
(GenericNeedle m ⊗ w)
-> (GenericNeedle m ⊗ w) -> GenericNeedle m ⊗ w
addTensors (Tensor TensorProduct (GenericNeedle m) w
s) (Tensor TensorProduct (GenericNeedle m) w
t)
= (Needle (VRep m) -> GenericNeedle m)
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle (VRep m))) =>
(Needle (VRep m) ⊗ w)
-> (Needle (VRep m) ⊗ w) -> Needle (VRep m) ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
addTensors (TensorProduct (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (GenericNeedle m) w
TensorProduct (Needle (VRep m)) w
s) (TensorProduct (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (GenericNeedle m) w
TensorProduct (Needle (VRep m)) w
t)
subtractTensors :: forall w.
(TensorSpace (GenericNeedle m), TensorSpace w,
Scalar w ~ Scalar (GenericNeedle m)) =>
(GenericNeedle m ⊗ w)
-> (GenericNeedle m ⊗ w) -> GenericNeedle m ⊗ w
subtractTensors (Tensor TensorProduct (GenericNeedle m) w
s) (Tensor TensorProduct (GenericNeedle m) w
t)
= (Needle (VRep m) -> GenericNeedle m)
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall v w.
(TensorSpace v, TensorSpace v, TensorSpace w,
Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
forall w.
(TensorSpace (Needle (VRep m)), TensorSpace w,
Scalar w ~ Scalar (Needle (VRep m))) =>
(Needle (VRep m) ⊗ w)
-> (Needle (VRep m) ⊗ w) -> Needle (VRep m) ⊗ w
subtractTensors (TensorProduct (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (GenericNeedle m) w
TensorProduct (Needle (VRep m)) w
s) (TensorProduct (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (GenericNeedle m) w
TensorProduct (Needle (VRep m)) w
t)
scaleTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) =>
Bilinear
(Scalar (GenericNeedle m))
(GenericNeedle m ⊗ w)
(GenericNeedle m ⊗ w)
scaleTensor = (Scalar (Needle (VRep m))
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Scalar (Needle (VRep m)))
(LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Scalar (Needle (VRep m))
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Scalar (Needle (VRep m)))
(LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)))
-> (Scalar (Needle (VRep m))
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Scalar (Needle (VRep m)))
(LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \Scalar (Needle (VRep m))
μ -> (Needle (VRep m) -> GenericNeedle m)
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle
(LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Bilinear
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle (VRep m))) =>
Bilinear
(Scalar (Needle (VRep m)))
(Needle (VRep m) ⊗ w)
(Needle (VRep m) ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
scaleTensorBilinear
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> Scalar (Needle (VRep m))
-> LinearFunction
(Scalar (Scalar (Needle (VRep m))))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
forall s v w. LinearFunction s v w -> v -> w
-+$>Scalar (Needle (VRep m))
μ
negateTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) =>
(GenericNeedle m ⊗ w) -+> (GenericNeedle m ⊗ w)
negateTensor = (Needle (VRep m) -> GenericNeedle m)
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-+> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle (VRep m))) =>
(Needle (VRep m) ⊗ w) -+> (Needle (VRep m) ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
negateTensor
tensorProduct :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) =>
Bilinear (GenericNeedle m) w (GenericNeedle m ⊗ w)
tensorProduct = (GenericNeedle m
-> w -> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Bilinear
(GenericNeedle m)
w
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(GenericNeedle m
-> w -> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> LinearFunction
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(LinearFunction
(Scalar (Needle (VRep m)))
w
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((GenericNeedle m
-> w -> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> LinearFunction
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(LinearFunction
(Scalar (Needle (VRep m)))
w
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)))
-> (GenericNeedle m
-> w -> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> LinearFunction
(Scalar (Needle (VRep m)))
(GenericNeedle m)
(LinearFunction
(Scalar (Needle (VRep m)))
w
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(GenericNeedle Needle (VRep m)
v) w
w
-> (Needle (VRep m) -> GenericNeedle m)
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle
VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Bilinear
(Needle (VRep m))
w
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle (VRep m))) =>
Bilinear (Needle (VRep m)) w (Needle (VRep m) ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductBilinear
(Needle (VRep m))
w
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> Needle (VRep m)
-> LinearFunction
(Scalar (Needle (VRep m)))
w
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
forall s v w. LinearFunction s v w -> v -> w
-+$>Needle (VRep m)
v)LinearFunction
(Scalar (Needle (VRep m)))
w
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> w -> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall s v w. LinearFunction s v w -> v -> w
-+$>w
w
transposeTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) =>
(GenericNeedle m ⊗ w) -+> (w ⊗ GenericNeedle m)
transposeTensor = (GenericNeedle m ⊗ w) -+> (w ⊗ GenericNeedle m)
forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle m)) =>
(GenericNeedle m ⊗ w) -+> (w ⊗ GenericNeedle m)
tT
where tT :: ∀ w . (TensorSpace w, Scalar w ~ Scalar (Needle m))
=> (GenericNeedle m ⊗ w) -+> (w ⊗ GenericNeedle m)
tT :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle m)) =>
(GenericNeedle m ⊗ w) -+> (w ⊗ GenericNeedle m)
tT = (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m))
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction
((Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m))
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m)))
-> (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m))
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Coercion
(Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m))
-> Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m))
-> Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (Coercion
(TensorProduct w (GenericNeedle m))
(Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m))
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion Coercion
(TensorProduct w (GenericNeedle m))
(Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m))
-> Coercion
(Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m)))
(TensorProduct w (GenericNeedle m))
-> Coercion
(Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m))
forall a b c.
(Object Coercion a, Object Coercion b, Object Coercion c) =>
Coercion b c -> Coercion a b -> Coercion a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. [w]
-> VSCCoercion (Scalar w) (Needle (VRep m)) (GenericNeedle m)
-> Coercion
(TensorProduct w (Needle (VRep m)))
(TensorProduct w (GenericNeedle m))
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar w, TensorSpace b,
Scalar b ~ Scalar w) =>
p w
-> VSCCoercion (Scalar w) a b
-> Coercion (TensorProduct w a) (TensorProduct w b)
coerceFmapTensorProduct ([]::[w])
(VSCCoercion (Scalar (Needle m)) (Needle (VRep m)) (GenericNeedle m)
VSCCoercion
(Scalar (Needle (VRep m))) (Needle (VRep m)) (GenericNeedle m)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion :: VSCCoercion (Scalar (Needle m))
(Needle (VRep m))
(GenericNeedle m))
Coercion
(TensorProduct w (Needle (VRep m)))
(TensorProduct w (GenericNeedle m))
-> Coercion
(Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m)))
(TensorProduct w (Needle (VRep m)))
-> Coercion
(Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m)))
(TensorProduct w (GenericNeedle m))
forall a b c.
(Object Coercion a, Object Coercion b, Object Coercion c) =>
Coercion b c -> Coercion a b -> Coercion a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Coercion
(Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m)))
(TensorProduct w (Needle (VRep m)))
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion)
(Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m))
-> Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m))
-> (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m)))
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Tensor (Scalar (Needle (VRep m))) w (GenericNeedle m)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m)))
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m))
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m)))
Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-+> (w ⊗ Needle (VRep m))
forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle (VRep m))) =>
(Needle (VRep m) ⊗ w) -+> (w ⊗ Needle (VRep m))
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m)))
-> (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Tensor (Scalar (Needle (VRep m))) w (Needle (VRep m))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. ((GenericNeedle m -> Needle (VRep m))
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle m -> Needle (VRep m)
forall x. GenericNeedle x -> Needle (VRep x)
getGenericNeedleVSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
fmapTensor :: forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (GenericNeedle m),
Scalar x ~ Scalar (GenericNeedle m)) =>
Bilinear (w -+> x) (GenericNeedle m ⊗ w) (GenericNeedle m ⊗ x)
fmapTensor = (LinearFunction (Scalar (Needle (VRep m))) w x
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x))
-> LinearFunction
(Scalar (Needle (VRep m)))
(LinearFunction (Scalar (Needle (VRep m))) w x)
(LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction (Scalar (Needle (VRep m))) w x
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x))
-> LinearFunction
(Scalar (Needle (VRep m)))
(LinearFunction (Scalar (Needle (VRep m))) w x)
(LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)))
-> (LinearFunction (Scalar (Needle (VRep m))) w x
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x))
-> LinearFunction
(Scalar (Needle (VRep m)))
(LinearFunction (Scalar (Needle (VRep m))) w x)
(LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction (Scalar (Needle (VRep m))) w x
f -> (Needle (VRep m) -> GenericNeedle m)
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x)
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle (LinearFunction
(Scalar (Needle (VRep m)))
(LinearFunction (Scalar (Needle (VRep m))) w x)
(LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x))
Bilinear
(LinearFunction (Scalar x) w x)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x)
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x, Scalar w ~ Scalar (Needle (VRep m)),
Scalar x ~ Scalar (Needle (VRep m))) =>
Bilinear (w -+> x) (Needle (VRep m) ⊗ w) (Needle (VRep m) ⊗ x)
fmapTensorLinearFunction
(Scalar (Needle (VRep m)))
(LinearFunction (Scalar (Needle (VRep m))) w x)
(LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x))
-> LinearFunction (Scalar (Needle (VRep m))) w x
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (Needle (VRep m))) w x
f)
fzipTensorWith :: forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (GenericNeedle m),
Scalar w ~ Scalar (GenericNeedle m),
Scalar x ~ Scalar (GenericNeedle m)) =>
Bilinear
((w, x) -+> u)
(GenericNeedle m ⊗ w, GenericNeedle m ⊗ x)
(GenericNeedle m ⊗ u)
fzipTensorWith = (LinearFunction (Scalar (Needle (VRep m))) (w, x) u
-> (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w,
Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) u)
-> LinearFunction
(Scalar (Needle (VRep m)))
(LinearFunction (Scalar (Needle (VRep m))) (w, x) u)
(LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w,
Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) u))
(LinearFunction (Scalar (Needle (VRep m))) (w, x) u
-> (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w,
Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) u)
-> Bilinear
(LinearFunction (Scalar (Needle (VRep m))) (w, x) u)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w,
Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) u)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction (Scalar (Needle (VRep m))) (w, x) u
-> (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w,
Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) u)
-> LinearFunction
(Scalar (Needle (VRep m)))
(LinearFunction (Scalar (Needle (VRep m))) (w, x) u)
(LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w,
Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) u)))
-> (LinearFunction (Scalar (Needle (VRep m))) (w, x) u
-> (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w,
Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) u)
-> LinearFunction
(Scalar (Needle (VRep m)))
(LinearFunction (Scalar (Needle (VRep m))) (w, x) u)
(LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w,
Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) u))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction (Scalar (Needle (VRep m))) (w, x) u
f (Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
wt, Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x
xt) -> (Needle (VRep m) -> GenericNeedle m)
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) u)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle
VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) u)
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) u)
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) u
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (LinearFunction
(Scalar (Needle (VRep m)))
(LinearFunction (Scalar (Needle (VRep m))) (w, x) u)
(LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w,
Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) u))
Bilinear
(LinearFunction (Scalar u) (w, x) u)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w,
Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) u)
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (Needle (VRep m)),
Scalar w ~ Scalar (Needle (VRep m)),
Scalar x ~ Scalar (Needle (VRep m))) =>
Bilinear
((w, x) -+> u)
(Needle (VRep m) ⊗ w, Needle (VRep m) ⊗ x)
(Needle (VRep m) ⊗ u)
fzipTensorWithLinearFunction
(Scalar (Needle (VRep m)))
(LinearFunction (Scalar (Needle (VRep m))) (w, x) u)
(LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w,
Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) u))
-> LinearFunction (Scalar (Needle (VRep m))) (w, x) u
-> LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w,
Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) u)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (Needle (VRep m))) (w, x) u
f)
LinearFunction
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w,
Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) u)
-> (Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w,
Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x)
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) u
forall s v w. LinearFunction s v w -> v -> w
-+$>( (GenericNeedle m -> Needle (VRep m))
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle m -> Needle (VRep m)
forall x. GenericNeedle x -> Needle (VRep x)
getGenericNeedle VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w)
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
wt
, (GenericNeedle m -> Needle (VRep m))
-> VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle m -> Needle (VRep m)
forall x. GenericNeedle x -> Needle (VRep x)
getGenericNeedle VSCCoercion
(Scalar (Needle (VRep m)))
(Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x)
(Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x)
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) x
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) x
xt )
tensorUnsafeFromArrayWithOffset
:: ∀ w nn α . ( TensorSpace w, nn`Dimensional`w
, Scalar w ~ (Scalar (Needle (VRep m)))
, GArr.Vector α (Scalar (Needle (VRep m))) )
=> Int -> α (Scalar (Needle (VRep m)))
-> (GenericNeedle m⊗w)
tensorUnsafeFromArrayWithOffset :: forall w (nn :: Nat) (α :: Type -> Type).
(TensorSpace w, Dimensional nn w,
Scalar w ~ Scalar (Needle (VRep m)),
Vector α (Scalar (Needle (VRep m)))) =>
Int -> α (Scalar (Needle (VRep m))) -> GenericNeedle m ⊗ w
tensorUnsafeFromArrayWithOffset
= case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(Needle (VRep m)) of
DimensionalityWitness (Needle (VRep m))
IsFlexibleDimensional -> [Char]
-> Int
-> α (Scalar (Needle (VRep m)))
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `Needle (VRep m)` is static-dimensional."
DimensionalityWitness (Needle (VRep m))
IsStaticDimensional -> \Int
i α (Scalar (Needle (VRep m)))
ar
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v ⊗ w
tensorUnsafeFromArrayWithOffset @(Needle (VRep m)) @w Int
i α (Scalar (Needle (VRep m)))
ar)
tensorUnsafeWriteArrayWithOffset
:: ∀ w nn α σ . ( TensorSpace w, nn`Dimensional`w
, Scalar w ~ (Scalar (Needle (VRep m)))
, GArr.Vector α (Scalar (Needle (VRep m))) )
=> GArr.Mutable α σ (Scalar (Needle (VRep m)))
-> Int -> (GenericNeedle m⊗w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset :: forall w (nn :: Nat) (α :: Type -> Type) σ.
(TensorSpace w, Dimensional nn w,
Scalar w ~ Scalar (Needle (VRep m)),
Vector α (Scalar (Needle (VRep m)))) =>
Mutable α σ (Scalar (Needle (VRep m)))
-> Int -> (GenericNeedle m ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset
= case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(Needle (VRep m)) of
DimensionalityWitness (Needle (VRep m))
IsFlexibleDimensional -> [Char]
-> Mutable α σ (Scalar (Needle (VRep m)))
-> Int
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> ST σ ()
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `Needle (VRep m)` is static-dimensional."
DimensionalityWitness (Needle (VRep m))
IsStaticDimensional -> \Mutable α σ (Scalar (Needle (VRep m)))
ar
-> (Int
-> Tensor (Scalar (Needle (VRep m))) (Needle (VRep m)) w
-> ST σ ())
-> Int
-> Tensor (Scalar (Needle (VRep m))) (GenericNeedle m) w
-> ST σ ()
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) σ (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> (v ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset @(Needle (VRep m)) @w Mutable α σ (Scalar (Needle (VRep m)))
ar)
coerceFmapTensorProduct :: forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (GenericNeedle m),
TensorSpace b, Scalar b ~ Scalar (GenericNeedle m)) =>
p (GenericNeedle m)
-> VSCCoercion (Scalar (GenericNeedle m)) a b
-> Coercion
(TensorProduct (GenericNeedle m) a)
(TensorProduct (GenericNeedle m) b)
coerceFmapTensorProduct = p (GenericNeedle m)
-> VSCCoercion (Scalar a) a b
-> Coercion
(TensorProduct (GenericNeedle m) a)
(TensorProduct (GenericNeedle m) b)
p (GenericNeedle m)
-> VSCCoercion (Scalar (GenericNeedle m)) a b
-> Coercion
(TensorProduct (GenericNeedle m) a)
(TensorProduct (GenericNeedle m) b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (Needle (VRep m)),
TensorSpace b, Scalar b ~ Scalar (Needle (VRep m))) =>
p (GenericNeedle m)
-> VSCCoercion (Scalar a) a b
-> Coercion
(TensorProduct (GenericNeedle m) a)
(TensorProduct (GenericNeedle m) b)
cmtp
where cmtp :: ∀ p a b . ( Hask.Functor p
, TensorSpace a, Scalar a ~ Scalar (Needle (VRep m))
, TensorSpace b, Scalar b ~ Scalar (Needle (VRep m)) )
=> p (GenericNeedle m) -> VSCCoercion (Scalar a) a b
-> Coercion (TensorProduct (GenericNeedle m) a)
(TensorProduct (GenericNeedle m) b)
cmtp :: forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (Needle (VRep m)),
TensorSpace b, Scalar b ~ Scalar (Needle (VRep m))) =>
p (GenericNeedle m)
-> VSCCoercion (Scalar a) a b
-> Coercion
(TensorProduct (GenericNeedle m) a)
(TensorProduct (GenericNeedle m) b)
cmtp p (GenericNeedle m)
p VSCCoercion (Scalar a) a b
crc = case forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
coerceFmapTensorProduct @(Needle (VRep m)) [] VSCCoercion (Scalar a) a b
VSCCoercion (Scalar (Needle (VRep m))) a b
crc of
Coercion
(TensorProduct (Needle (VRep m)) a)
(TensorProduct (Needle (VRep m)) b)
Coercion -> Coercion
(TensorProduct (GenericNeedle m) a)
(TensorProduct (GenericNeedle m) b)
Coercion
(TensorProduct (Needle (VRep m)) a)
(TensorProduct (Needle (VRep m)) b)
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion
instance ∀ v s . (LinearSpace v, Num (Scalar v)) => LinearSpace (Gnrx.Rec0 v s) where
type DualVector (Gnrx.Rec0 v s) = DualVector v
dualSpaceWitness :: DualSpaceWitness (Rec0 v s)
dualSpaceWitness = DualSpaceWitness (Rec0 v s)
forall a. a
genericTensorspaceError
linearId :: Rec0 v s +> Rec0 v s
linearId = (Rec0 v s -> v)
-> VSCCoercion
(Scalar v)
(LinearMap (Scalar v) v (Rec0 v s))
(LinearMap (Scalar v) (Rec0 v s) (Rec0 v s))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w,
StaticDimension v ~ StaticDimension v') =>
c v' v -> VSCCoercion s (LinearMap s v w) (LinearMap s v' w)
pseudoPrecomposeLinmap Rec0 v s -> v
forall k i c (p :: k). K1 i c p -> c
Gnrx.unK1
VSCCoercion
(Scalar v)
(LinearMap (Scalar v) v (Rec0 v s))
(LinearMap (Scalar v) (Rec0 v s) (Rec0 v s))
-> VSCCoercion
(Scalar v)
(LinearMap (Scalar v) v v)
(LinearMap (Scalar v) v (Rec0 v s))
-> VSCCoercion
(Scalar v)
(LinearMap (Scalar v) v v)
(LinearMap (Scalar v) (Rec0 v s) (Rec0 v s))
forall a b c.
(Object (VSCCoercion (Scalar v)) a,
Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c) =>
VSCCoercion (Scalar v) b c
-> VSCCoercion (Scalar v) a b -> VSCCoercion (Scalar v) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion (Scalar v) v (Rec0 v s)
-> VSCCoercion
(Scalar v)
(LinearMap (Scalar v) v v)
(LinearMap (Scalar v) v (Rec0 v s))
forall a b.
(Object (VSCCoercion (Scalar v)) a,
Object (VSCCoercion (Scalar v)) (LinearMap (Scalar v) v a),
Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) (LinearMap (Scalar v) v b)) =>
VSCCoercion (Scalar v) a b
-> VSCCoercion
(Scalar v) (LinearMap (Scalar v) v a) (LinearMap (Scalar v) v b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion (Scalar v) v (Rec0 v s)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
VSCCoercion
(Scalar v)
(LinearMap (Scalar v) v v)
(LinearMap (Scalar v) (Rec0 v s) (Rec0 v s))
-> LinearMap (Scalar v) v v
-> LinearMap (Scalar v) (Rec0 v s) (Rec0 v s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar v) v v
forall v. LinearSpace v => LinearMap (Scalar v) v v
linearId
applyDualVector :: LinearSpace (Rec0 v s) =>
Bilinear (DualVector (Rec0 v s)) (Rec0 v s) (Scalar (Rec0 v s))
applyDualVector = (DualVector v -> Rec0 v s -> Scalar v)
-> LinearFunction
(Scalar (DualVector v))
(DualVector v)
(LinearFunction (Scalar (DualVector v)) (Rec0 v s) (Scalar v))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((DualVector v -> Rec0 v s -> Scalar v)
-> LinearFunction
(Scalar (DualVector v))
(DualVector v)
(LinearFunction (Scalar (DualVector v)) (Rec0 v s) (Scalar v)))
-> (DualVector v -> Rec0 v s -> Scalar v)
-> LinearFunction
(Scalar (DualVector v))
(DualVector v)
(LinearFunction (Scalar (DualVector v)) (Rec0 v s) (Scalar v))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \DualVector v
dv (Gnrx.K1 v
v) -> (Bilinear (DualVector v) v (Scalar v)
forall v.
(LinearSpace v, LinearSpace v) =>
Bilinear (DualVector v) v (Scalar v)
applyDualVectorBilinear (DualVector v) v (Scalar v)
-> DualVector v
-> LinearFunction (Scalar (DualVector v)) v (Scalar v)
forall s v w. LinearFunction s v w -> v -> w
-+$>DualVector v
dv)LinearFunction (Scalar (DualVector v)) v (Scalar v)
-> v -> Scalar v
forall s v w. LinearFunction s v w -> v -> w
-+$>v
v
applyLinear :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) =>
Bilinear (Rec0 v s +> w) (Rec0 v s) w
applyLinear = (LinearMap (Scalar v) (Rec0 v s) w -> Rec0 v s -> w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Rec0 v s) w)
(LinearFunction (Scalar v) (Rec0 v s) w)
(LinearMap (Scalar v) (Rec0 v s) w -> Rec0 v s -> w)
-> Bilinear (LinearMap (Scalar v) (Rec0 v s) w) (Rec0 v s) w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap (Scalar v) (Rec0 v s) w -> Rec0 v s -> w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Rec0 v s) w)
(LinearFunction (Scalar v) (Rec0 v s) w))
-> (LinearMap (Scalar v) (Rec0 v s) w -> Rec0 v s -> w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Rec0 v s) w)
(LinearFunction (Scalar v) (Rec0 v s) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (Rec0 v s)) w
f) (Gnrx.K1 v
v)
-> (LinearFunction
(Scalar v)
(LinearMap (Scalar v) v w)
(LinearFunction (Scalar v) v w)
Bilinear (LinearMap (Scalar v) v w) v w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
applyLinearLinearFunction
(Scalar v)
(LinearMap (Scalar v) v w)
(LinearFunction (Scalar v) v w)
-> LinearMap (Scalar v) v w -> LinearFunction (Scalar v) v w
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct (DualVector v) w -> LinearMap (Scalar v) v w
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector v) w
TensorProduct (DualVector (Rec0 v s)) w
f)LinearFunction (Scalar v) v w -> v -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>v
v
tensorId :: forall w.
(LinearSpace w, Scalar w ~ Scalar (Rec0 v s)) =>
(Rec0 v s ⊗ w) +> (Rec0 v s ⊗ w)
tensorId = VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) w) (Tensor (Scalar v) v w)
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v)
(Tensor (Scalar v) v w)
(Tensor (Scalar v) (Rec0 v s) w))
(LinearMap
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w,
StaticDimension v ~ StaticDimension v') =>
c v' v -> VSCCoercion s (LinearMap s v w) (LinearMap s v' w)
pseudoPrecomposeLinmap ((Rec0 v s -> v)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) w) (Tensor (Scalar v) v w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Rec0 v s -> v
forall k i c (p :: k). K1 i c p -> c
Gnrx.unK1)
VSCCoercion
(Scalar v)
(LinearMap
(Scalar v)
(Tensor (Scalar v) v w)
(Tensor (Scalar v) (Rec0 v s) w))
(LinearMap
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w))
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w))
(LinearMap
(Scalar v)
(Tensor (Scalar v) v w)
(Tensor (Scalar v) (Rec0 v s) w))
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w))
(LinearMap
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w))
forall a b c.
(Object (VSCCoercion (Scalar v)) a,
Object (VSCCoercion (Scalar v)) b,
Object (VSCCoercion (Scalar v)) c) =>
VSCCoercion (Scalar v) b c
-> VSCCoercion (Scalar v) a b -> VSCCoercion (Scalar v) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
-> VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w))
(LinearMap
(Scalar v)
(Tensor (Scalar v) v w)
(Tensor (Scalar v) (Rec0 v s) w))
forall a b.
(Object (VSCCoercion (Scalar v)) a,
Object
(VSCCoercion (Scalar v))
(LinearMap (Scalar v) (Tensor (Scalar v) v w) a),
Object (VSCCoercion (Scalar v)) b,
Object
(VSCCoercion (Scalar v))
(LinearMap (Scalar v) (Tensor (Scalar v) v w) b)) =>
VSCCoercion (Scalar v) a b
-> VSCCoercion
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) v w) a)
(LinearMap (Scalar v) (Tensor (Scalar v) v w) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap ((v -> Rec0 v s)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) (Rec0 v s) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS v -> Rec0 v s
forall k i c (p :: k). c -> K1 i c p
Gnrx.K1) VSCCoercion
(Scalar v)
(LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w))
(LinearMap
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w))
-> LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
-> LinearMap
(Scalar v)
(Tensor (Scalar v) (Rec0 v s) w)
(Tensor (Scalar v) (Rec0 v s) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap
(Scalar v) (Tensor (Scalar v) v w) (Tensor (Scalar v) v w)
Tensor (Scalar v) v w +> Tensor (Scalar v) v w
forall w.
(LinearSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) +> (v ⊗ w)
forall v w.
(LinearSpace v, LinearSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) +> (v ⊗ w)
tensorId
applyTensorFunctional :: forall u.
(LinearSpace u, Scalar u ~ Scalar (Rec0 v s)) =>
Bilinear
(DualVector (Rec0 v s ⊗ u)) (Rec0 v s ⊗ u) (Scalar (Rec0 v s))
applyTensorFunctional = (LinearMap (Scalar v) (Rec0 v s) (DualVector u)
-> Tensor (Scalar v) (Rec0 v s) u -> Scalar v)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Rec0 v s) (DualVector u))
(LinearFunction
(Scalar v) (Tensor (Scalar v) (Rec0 v s) u) (Scalar v))
(LinearMap (Scalar v) (Rec0 v s) (DualVector u)
-> Tensor (Scalar v) (Rec0 v s) u -> Scalar v)
-> Bilinear
(LinearMap (Scalar v) (Rec0 v s) (DualVector u))
(Tensor (Scalar v) (Rec0 v s) u)
(Scalar v)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap (Scalar v) (Rec0 v s) (DualVector u)
-> Tensor (Scalar v) (Rec0 v s) u -> Scalar v)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Rec0 v s) (DualVector u))
(LinearFunction
(Scalar v) (Tensor (Scalar v) (Rec0 v s) u) (Scalar v)))
-> (LinearMap (Scalar v) (Rec0 v s) (DualVector u)
-> Tensor (Scalar v) (Rec0 v s) u -> Scalar v)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Rec0 v s) (DualVector u))
(LinearFunction
(Scalar v) (Tensor (Scalar v) (Rec0 v s) u) (Scalar v))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (Rec0 v s)) (DualVector u)
f) Tensor (Scalar v) (Rec0 v s) u
t ->
(LinearFunction
(Scalar v)
(LinearMap (Scalar v) v (DualVector u))
(LinearFunction (Scalar v) (Tensor (Scalar v) v u) (Scalar v))
Bilinear
(DualVector (Tensor (Scalar v) v u))
(Tensor (Scalar v) v u)
(Scalar v)
forall u.
(LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctionalLinearFunction
(Scalar v)
(LinearMap (Scalar v) v (DualVector u))
(LinearFunction (Scalar v) (Tensor (Scalar v) v u) (Scalar v))
-> LinearMap (Scalar v) v (DualVector u)
-> LinearFunction (Scalar v) (Tensor (Scalar v) v u) (Scalar v)
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct (DualVector v) (DualVector u)
-> LinearMap (Scalar v) v (DualVector u)
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector v) (DualVector u)
TensorProduct (DualVector (Rec0 v s)) (DualVector u)
f)LinearFunction (Scalar v) (Tensor (Scalar v) v u) (Scalar v)
-> Tensor (Scalar v) v u -> Scalar v
forall s v w. LinearFunction s v w -> v -> w
-+$>(Rec0 v s -> v)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) u) (Tensor (Scalar v) v u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Rec0 v s -> v
forall k i c (p :: k). K1 i c p -> c
Gnrx.unK1 VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) u) (Tensor (Scalar v) v u)
-> Tensor (Scalar v) (Rec0 v s) u -> Tensor (Scalar v) v u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) (Rec0 v s) u
t
applyTensorLinMap :: forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (Rec0 v s),
Scalar w ~ Scalar (Rec0 v s)) =>
Bilinear ((Rec0 v s ⊗ u) +> w) (Rec0 v s ⊗ u) w
applyTensorLinMap = (LinearMap (Scalar v) (Tensor (Scalar v) (Rec0 v s) u) w
-> Tensor (Scalar v) (Rec0 v s) u -> w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) (Rec0 v s) u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) (Rec0 v s) u) w)
(LinearMap (Scalar v) (Tensor (Scalar v) (Rec0 v s) u) w
-> Tensor (Scalar v) (Rec0 v s) u -> w)
-> Bilinear
(LinearMap (Scalar v) (Tensor (Scalar v) (Rec0 v s) u) w)
(Tensor (Scalar v) (Rec0 v s) u)
w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap (Scalar v) (Tensor (Scalar v) (Rec0 v s) u) w
-> Tensor (Scalar v) (Rec0 v s) u -> w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) (Rec0 v s) u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) (Rec0 v s) u) w))
-> (LinearMap (Scalar v) (Tensor (Scalar v) (Rec0 v s) u) w
-> Tensor (Scalar v) (Rec0 v s) u -> w)
-> LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) (Rec0 v s) u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) (Rec0 v s) u) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (Tensor (Scalar v) (Rec0 v s) u)) w
f) Tensor (Scalar v) (Rec0 v s) u
t
-> (LinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) v u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) v u) w)
Bilinear (Tensor (Scalar v) v u +> w) (Tensor (Scalar v) v u) w
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
applyTensorLinMapLinearFunction
(Scalar v)
(LinearMap (Scalar v) (Tensor (Scalar v) v u) w)
(LinearFunction (Scalar v) (Tensor (Scalar v) v u) w)
-> LinearMap (Scalar v) (Tensor (Scalar v) v u) w
-> LinearFunction (Scalar v) (Tensor (Scalar v) v u) w
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct (DualVector (Tensor (Scalar v) v u)) w
-> LinearMap (Scalar v) (Tensor (Scalar v) v u) w
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector (Tensor (Scalar v) v u)) w
TensorProduct (DualVector (Tensor (Scalar v) (Rec0 v s) u)) w
f)LinearFunction (Scalar v) (Tensor (Scalar v) v u) w
-> Tensor (Scalar v) v u -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>(Rec0 v s -> v)
-> VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) u) (Tensor (Scalar v) v u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Rec0 v s -> v
forall k i c (p :: k). K1 i c p -> c
Gnrx.unK1 VSCCoercion
(Scalar v) (Tensor (Scalar v) (Rec0 v s) u) (Tensor (Scalar v) v u)
-> Tensor (Scalar v) (Rec0 v s) u -> Tensor (Scalar v) v u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar v) (Rec0 v s) u
t
useTupleLinearSpaceComponents :: forall x y φ.
(Rec0 v s ~ (x, y)) =>
((LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ) -> φ
useTupleLinearSpaceComponents (LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ
_ = φ
forall a. a
usingNonTupleTypeAsTupleError
coerceDoubleDual :: VSCCoercion
(Scalar (Rec0 v s)) (Rec0 v s) (DualVector (DualVector (Rec0 v s)))
coerceDoubleDual = case forall v.
LinearSpace v =>
VSCCoercion (Scalar v) v (DualVector (DualVector v))
coerceDoubleDual @v of
VSCCoercion (Scalar v) v (DualVector (DualVector v))
VSCCoercion -> VSCCoercion (Scalar v) (Rec0 v s) (DualVector (DualVector v))
VSCCoercion
(Scalar (Rec0 v s)) (Rec0 v s) (DualVector (DualVector (Rec0 v s)))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
instance (LinearSpace (f p), Num (Scalar (f p))) => LinearSpace (Gnrx.M1 i c f p) where
type DualVector (Gnrx.M1 i c f p) = DualVector (f p)
dualSpaceWitness :: DualSpaceWitness (M1 i c f p)
dualSpaceWitness = DualSpaceWitness (M1 i c f p)
forall a. a
genericTensorspaceError
linearId :: M1 i c f p +> M1 i c f p
linearId = (M1 i c f p -> f p)
-> VSCCoercion
(Scalar (f p))
(LinearMap (Scalar (f p)) (f p) (M1 i c f p))
(LinearMap (Scalar (f p)) (M1 i c f p) (M1 i c f p))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w,
StaticDimension v ~ StaticDimension v') =>
c v' v -> VSCCoercion s (LinearMap s v w) (LinearMap s v' w)
pseudoPrecomposeLinmap M1 i c f p -> f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
Gnrx.unM1
VSCCoercion
(Scalar (f p))
(LinearMap (Scalar (f p)) (f p) (M1 i c f p))
(LinearMap (Scalar (f p)) (M1 i c f p) (M1 i c f p))
-> VSCCoercion
(Scalar (f p))
(LinearMap (Scalar (f p)) (f p) (f p))
(LinearMap (Scalar (f p)) (f p) (M1 i c f p))
-> VSCCoercion
(Scalar (f p))
(LinearMap (Scalar (f p)) (f p) (f p))
(LinearMap (Scalar (f p)) (M1 i c f p) (M1 i c f p))
forall a b c.
(Object (VSCCoercion (Scalar (f p))) a,
Object (VSCCoercion (Scalar (f p))) b,
Object (VSCCoercion (Scalar (f p))) c) =>
VSCCoercion (Scalar (f p)) b c
-> VSCCoercion (Scalar (f p)) a b -> VSCCoercion (Scalar (f p)) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion (Scalar (f p)) (f p) (M1 i c f p)
-> VSCCoercion
(Scalar (f p))
(LinearMap (Scalar (f p)) (f p) (f p))
(LinearMap (Scalar (f p)) (f p) (M1 i c f p))
forall a b.
(Object (VSCCoercion (Scalar (f p))) a,
Object
(VSCCoercion (Scalar (f p))) (LinearMap (Scalar (f p)) (f p) a),
Object (VSCCoercion (Scalar (f p))) b,
Object
(VSCCoercion (Scalar (f p))) (LinearMap (Scalar (f p)) (f p) b)) =>
VSCCoercion (Scalar (f p)) a b
-> VSCCoercion
(Scalar (f p))
(LinearMap (Scalar (f p)) (f p) a)
(LinearMap (Scalar (f p)) (f p) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion (Scalar (f p)) (f p) (M1 i c f p)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
VSCCoercion
(Scalar (f p))
(LinearMap (Scalar (f p)) (f p) (f p))
(LinearMap (Scalar (f p)) (M1 i c f p) (M1 i c f p))
-> LinearMap (Scalar (f p)) (f p) (f p)
-> LinearMap (Scalar (f p)) (M1 i c f p) (M1 i c f p)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar (f p)) (f p) (f p)
forall v. LinearSpace v => LinearMap (Scalar v) v v
linearId
applyDualVector :: LinearSpace (M1 i c f p) =>
Bilinear
(DualVector (M1 i c f p)) (M1 i c f p) (Scalar (M1 i c f p))
applyDualVector = (DualVector (f p) -> M1 i c f p -> Scalar (f p))
-> LinearFunction
(Scalar (DualVector (f p)))
(DualVector (f p))
(LinearFunction
(Scalar (DualVector (f p))) (M1 i c f p) (Scalar (f p)))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((DualVector (f p) -> M1 i c f p -> Scalar (f p))
-> LinearFunction
(Scalar (DualVector (f p)))
(DualVector (f p))
(LinearFunction
(Scalar (DualVector (f p))) (M1 i c f p) (Scalar (f p))))
-> (DualVector (f p) -> M1 i c f p -> Scalar (f p))
-> LinearFunction
(Scalar (DualVector (f p)))
(DualVector (f p))
(LinearFunction
(Scalar (DualVector (f p))) (M1 i c f p) (Scalar (f p)))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \DualVector (f p)
dv (Gnrx.M1 f p
v) -> (Bilinear (DualVector (f p)) (f p) (Scalar (f p))
forall v.
(LinearSpace v, LinearSpace v) =>
Bilinear (DualVector v) v (Scalar v)
applyDualVectorBilinear (DualVector (f p)) (f p) (Scalar (f p))
-> DualVector (f p)
-> LinearFunction (Scalar (DualVector (f p))) (f p) (Scalar (f p))
forall s v w. LinearFunction s v w -> v -> w
-+$>DualVector (f p)
dv)LinearFunction (Scalar (DualVector (f p))) (f p) (Scalar (f p))
-> f p -> Scalar (f p)
forall s v w. LinearFunction s v w -> v -> w
-+$>f p
v
applyLinear :: forall w.
(TensorSpace w, Scalar w ~ Scalar (M1 i c f p)) =>
Bilinear (M1 i c f p +> w) (M1 i c f p) w
applyLinear = (LinearMap (Scalar (f p)) (M1 i c f p) w -> M1 i c f p -> w)
-> LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (M1 i c f p) w)
(LinearFunction (Scalar (f p)) (M1 i c f p) w)
(LinearMap (Scalar (f p)) (M1 i c f p) w -> M1 i c f p -> w)
-> Bilinear
(LinearMap (Scalar (f p)) (M1 i c f p) w) (M1 i c f p) w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap (Scalar (f p)) (M1 i c f p) w -> M1 i c f p -> w)
-> LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (M1 i c f p) w)
(LinearFunction (Scalar (f p)) (M1 i c f p) w))
-> (LinearMap (Scalar (f p)) (M1 i c f p) w -> M1 i c f p -> w)
-> LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (M1 i c f p) w)
(LinearFunction (Scalar (f p)) (M1 i c f p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (M1 i c f p)) w
f) (Gnrx.M1 f p
v)
-> (LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (f p) w)
(LinearFunction (Scalar (f p)) (f p) w)
Bilinear (LinearMap (Scalar (f p)) (f p) w) (f p) w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
Bilinear (f p +> w) (f p) w
applyLinearLinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (f p) w)
(LinearFunction (Scalar (f p)) (f p) w)
-> LinearMap (Scalar (f p)) (f p) w
-> LinearFunction (Scalar (f p)) (f p) w
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct (DualVector (f p)) w
-> LinearMap (Scalar (f p)) (f p) w
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector (f p)) w
TensorProduct (DualVector (M1 i c f p)) w
f)LinearFunction (Scalar (f p)) (f p) w -> f p -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>f p
v
tensorId :: forall w.
(LinearSpace w, Scalar w ~ Scalar (M1 i c f p)) =>
(M1 i c f p ⊗ w) +> (M1 i c f p ⊗ w)
tensorId = VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (f p) w)
-> VSCCoercion
(Scalar (f p))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w,
StaticDimension v ~ StaticDimension v') =>
c v' v -> VSCCoercion s (LinearMap s v w) (LinearMap s v' w)
pseudoPrecomposeLinmap ((M1 i c f p -> f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (f p) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS M1 i c f p -> f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
Gnrx.unM1)
VSCCoercion
(Scalar (f p))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
-> VSCCoercion
(Scalar (f p))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
-> VSCCoercion
(Scalar (f p))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
forall a b c.
(Object (VSCCoercion (Scalar (f p))) a,
Object (VSCCoercion (Scalar (f p))) b,
Object (VSCCoercion (Scalar (f p))) c) =>
VSCCoercion (Scalar (f p)) b c
-> VSCCoercion (Scalar (f p)) a b -> VSCCoercion (Scalar (f p)) a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
-> VSCCoercion
(Scalar (f p))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
forall a b.
(Object (VSCCoercion (Scalar (f p))) a,
Object
(VSCCoercion (Scalar (f p)))
(LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (f p) w) a),
Object (VSCCoercion (Scalar (f p))) b,
Object
(VSCCoercion (Scalar (f p)))
(LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (f p) w) b)) =>
VSCCoercion (Scalar (f p)) a b
-> VSCCoercion
(Scalar (f p))
(LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (f p) w) a)
(LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (f p) w) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap ((f p -> M1 i c f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS f p -> M1 i c f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). f p -> M1 i c f p
Gnrx.M1) VSCCoercion
(Scalar (f p))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w))
(LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w))
-> LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w)
-> LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) w)
(Tensor (Scalar (f p)) (M1 i c f p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap
(Scalar (f p))
(Tensor (Scalar (f p)) (f p) w)
(Tensor (Scalar (f p)) (f p) w)
Tensor (Scalar (f p)) (f p) w +> Tensor (Scalar (f p)) (f p) w
forall w.
(LinearSpace w, Scalar w ~ Scalar (f p)) =>
(f p ⊗ w) +> (f p ⊗ w)
forall v w.
(LinearSpace v, LinearSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) +> (v ⊗ w)
tensorId
applyTensorFunctional :: forall u.
(LinearSpace u, Scalar u ~ Scalar (M1 i c f p)) =>
Bilinear
(DualVector (M1 i c f p ⊗ u))
(M1 i c f p ⊗ u)
(Scalar (M1 i c f p))
applyTensorFunctional = (LinearMap (Scalar (f p)) (M1 i c f p) (DualVector u)
-> Tensor (Scalar (f p)) (M1 i c f p) u -> Scalar (f p))
-> LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (M1 i c f p) (DualVector u))
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) u)
(Scalar (f p)))
(LinearMap (Scalar (f p)) (M1 i c f p) (DualVector u)
-> Tensor (Scalar (f p)) (M1 i c f p) u -> Scalar (f p))
-> Bilinear
(LinearMap (Scalar (f p)) (M1 i c f p) (DualVector u))
(Tensor (Scalar (f p)) (M1 i c f p) u)
(Scalar (f p))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap (Scalar (f p)) (M1 i c f p) (DualVector u)
-> Tensor (Scalar (f p)) (M1 i c f p) u -> Scalar (f p))
-> LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (M1 i c f p) (DualVector u))
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) u)
(Scalar (f p))))
-> (LinearMap (Scalar (f p)) (M1 i c f p) (DualVector u)
-> Tensor (Scalar (f p)) (M1 i c f p) u -> Scalar (f p))
-> LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (M1 i c f p) (DualVector u))
(LinearFunction
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) u)
(Scalar (f p)))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (M1 i c f p)) (DualVector u)
f) Tensor (Scalar (f p)) (M1 i c f p) u
t ->
(LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (f p) (DualVector u))
(LinearFunction
(Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) (Scalar (f p)))
Bilinear
(DualVector (Tensor (Scalar (f p)) (f p) u))
(Tensor (Scalar (f p)) (f p) u)
(Scalar (f p))
forall u.
(LinearSpace u, Scalar u ~ Scalar (f p)) =>
Bilinear (DualVector (f p ⊗ u)) (f p ⊗ u) (Scalar (f p))
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctionalLinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (f p) (DualVector u))
(LinearFunction
(Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) (Scalar (f p)))
-> LinearMap (Scalar (f p)) (f p) (DualVector u)
-> LinearFunction
(Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) (Scalar (f p))
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct (DualVector (f p)) (DualVector u)
-> LinearMap (Scalar (f p)) (f p) (DualVector u)
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector (f p)) (DualVector u)
TensorProduct (DualVector (M1 i c f p)) (DualVector u)
f)LinearFunction
(Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) (Scalar (f p))
-> Tensor (Scalar (f p)) (f p) u -> Scalar (f p)
forall s v w. LinearFunction s v w -> v -> w
-+$>(M1 i c f p -> f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) u)
(Tensor (Scalar (f p)) (f p) u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS M1 i c f p -> f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
Gnrx.unM1 VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) u)
(Tensor (Scalar (f p)) (f p) u)
-> Tensor (Scalar (f p)) (M1 i c f p) u
-> Tensor (Scalar (f p)) (f p) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (f p)) (M1 i c f p) u
t
applyTensorLinMap :: forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (M1 i c f p),
Scalar w ~ Scalar (M1 i c f p)) =>
Bilinear ((M1 i c f p ⊗ u) +> w) (M1 i c f p ⊗ u) w
applyTensorLinMap = (LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (M1 i c f p) u) w
-> Tensor (Scalar (f p)) (M1 i c f p) u -> w)
-> LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (M1 i c f p) u) w)
(LinearFunction
(Scalar (f p)) (Tensor (Scalar (f p)) (M1 i c f p) u) w)
(LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (M1 i c f p) u) w
-> Tensor (Scalar (f p)) (M1 i c f p) u -> w)
-> Bilinear
(LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (M1 i c f p) u) w)
(Tensor (Scalar (f p)) (M1 i c f p) u)
w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (M1 i c f p) u) w
-> Tensor (Scalar (f p)) (M1 i c f p) u -> w)
-> LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (M1 i c f p) u) w)
(LinearFunction
(Scalar (f p)) (Tensor (Scalar (f p)) (M1 i c f p) u) w))
-> (LinearMap
(Scalar (f p)) (Tensor (Scalar (f p)) (M1 i c f p) u) w
-> Tensor (Scalar (f p)) (M1 i c f p) u -> w)
-> LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (M1 i c f p) u) w)
(LinearFunction
(Scalar (f p)) (Tensor (Scalar (f p)) (M1 i c f p) u) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (Tensor (Scalar (f p)) (M1 i c f p) u)) w
f) Tensor (Scalar (f p)) (M1 i c f p) u
t
-> (LinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) w)
(LinearFunction (Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) w)
Bilinear
(Tensor (Scalar (f p)) (f p) u +> w)
(Tensor (Scalar (f p)) (f p) u)
w
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (f p),
Scalar w ~ Scalar (f p)) =>
Bilinear ((f p ⊗ u) +> w) (f p ⊗ u) w
applyTensorLinMapLinearFunction
(Scalar (f p))
(LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) w)
(LinearFunction (Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) w)
-> LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) w
-> LinearFunction (Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) w
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct (DualVector (Tensor (Scalar (f p)) (f p) u)) w
-> LinearMap (Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) w
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector (Tensor (Scalar (f p)) (f p) u)) w
TensorProduct (DualVector (Tensor (Scalar (f p)) (M1 i c f p) u)) w
f)LinearFunction (Scalar (f p)) (Tensor (Scalar (f p)) (f p) u) w
-> Tensor (Scalar (f p)) (f p) u -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>(M1 i c f p -> f p)
-> VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) u)
(Tensor (Scalar (f p)) (f p) u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS M1 i c f p -> f p
forall k i (c :: Meta) (f :: k -> Type) (p :: k). M1 i c f p -> f p
Gnrx.unM1 VSCCoercion
(Scalar (f p))
(Tensor (Scalar (f p)) (M1 i c f p) u)
(Tensor (Scalar (f p)) (f p) u)
-> Tensor (Scalar (f p)) (M1 i c f p) u
-> Tensor (Scalar (f p)) (f p) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (f p)) (M1 i c f p) u
t
useTupleLinearSpaceComponents :: forall x y φ.
(M1 i c f p ~ (x, y)) =>
((LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ) -> φ
useTupleLinearSpaceComponents (LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ
_ = φ
forall a. a
usingNonTupleTypeAsTupleError
coerceDoubleDual :: VSCCoercion
(Scalar (M1 i c f p))
(M1 i c f p)
(DualVector (DualVector (M1 i c f p)))
coerceDoubleDual = case forall v.
LinearSpace v =>
VSCCoercion (Scalar v) v (DualVector (DualVector v))
coerceDoubleDual @(f p) of
VSCCoercion (Scalar (f p)) (f p) (DualVector (DualVector (f p)))
VSCCoercion -> VSCCoercion
(Scalar (f p)) (M1 i c f p) (DualVector (DualVector (f p)))
VSCCoercion
(Scalar (M1 i c f p))
(M1 i c f p)
(DualVector (DualVector (M1 i c f p)))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
data GenericTupleDual f g p
= GenericTupleDual !(DualVector (f p)) !(DualVector (g p)) deriving ((forall x.
GenericTupleDual f g p -> Rep (GenericTupleDual f g p) x)
-> (forall x.
Rep (GenericTupleDual f g p) x -> GenericTupleDual f g p)
-> Generic (GenericTupleDual f g p)
forall x. Rep (GenericTupleDual f g p) x -> GenericTupleDual f g p
forall x. GenericTupleDual f g p -> Rep (GenericTupleDual f g p) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (f :: Type -> Type) (g :: Type -> Type) p x.
Rep (GenericTupleDual f g p) x -> GenericTupleDual f g p
forall (f :: Type -> Type) (g :: Type -> Type) p x.
GenericTupleDual f g p -> Rep (GenericTupleDual f g p) x
$cfrom :: forall (f :: Type -> Type) (g :: Type -> Type) p x.
GenericTupleDual f g p -> Rep (GenericTupleDual f g p) x
from :: forall x. GenericTupleDual f g p -> Rep (GenericTupleDual f g p) x
$cto :: forall (f :: Type -> Type) (g :: Type -> Type) p x.
Rep (GenericTupleDual f g p) x -> GenericTupleDual f g p
to :: forall x. Rep (GenericTupleDual f g p) x -> GenericTupleDual f g p
Generic)
instance (AdditiveGroup (DualVector (f p)), AdditiveGroup (DualVector (g p)))
=> AdditiveGroup (GenericTupleDual f g p)
instance ( VectorSpace (DualVector (f p)), VectorSpace (DualVector (g p))
, Scalar (DualVector (f p)) ~ Scalar (DualVector (g p)) )
=> VectorSpace (GenericTupleDual f g p)
instance ( InnerSpace (DualVector (f p)), InnerSpace (DualVector (g p))
, Scalar (DualVector (f p)) ~ Scalar (DualVector (g p))
, AdditiveGroup (Scalar (DualVector (g p)))
, Num (Scalar (DualVector (f p))) )
=> InnerSpace (GenericTupleDual f g p)
instance (AdditiveGroup (DualVector (f p)), AdditiveGroup (DualVector (g p)))
=> AffineSpace (GenericTupleDual f g p) where
type Diff (GenericTupleDual f g p) = GenericTupleDual f g p
.+^ :: GenericTupleDual f g p
-> Diff (GenericTupleDual f g p) -> GenericTupleDual f g p
(.+^) = GenericTupleDual f g p
-> Diff (GenericTupleDual f g p) -> GenericTupleDual f g p
GenericTupleDual f g p
-> GenericTupleDual f g p -> GenericTupleDual f g p
forall v. AdditiveGroup v => v -> v -> v
(^+^)
.-. :: GenericTupleDual f g p
-> GenericTupleDual f g p -> Diff (GenericTupleDual f g p)
(.-.) = GenericTupleDual f g p
-> GenericTupleDual f g p -> Diff (GenericTupleDual f g p)
GenericTupleDual f g p
-> GenericTupleDual f g p -> GenericTupleDual f g p
forall v. AdditiveGroup v => v -> v -> v
(^-^)
instance (AdditiveGroup (DualVector (f p)), AdditiveGroup (DualVector (g p)))
=> Semimanifold (GenericTupleDual f g p) where
type Needle (GenericTupleDual f g p) = GenericTupleDual f g p
.+~^ :: GenericTupleDual f g p
-> Needle (GenericTupleDual f g p) -> GenericTupleDual f g p
(.+~^) = GenericTupleDual f g p
-> Needle (GenericTupleDual f g p) -> GenericTupleDual f g p
GenericTupleDual f g p
-> GenericTupleDual f g p -> GenericTupleDual f g p
forall v. AdditiveGroup v => v -> v -> v
(^+^)
#if !MIN_VERSION_manifolds_core(0,6,0)
fromInterior = id
toInterior = pure
translateP = Tagged (^+^)
#endif
instance (AdditiveGroup (DualVector (f p)), AdditiveGroup (DualVector (g p)))
=> PseudoAffine (GenericTupleDual f g p) where
GenericTupleDual f g p
p.-~. :: GenericTupleDual f g p
-> GenericTupleDual f g p
-> Maybe (Needle (GenericTupleDual f g p))
.-~.GenericTupleDual f g p
q = GenericTupleDual f g p -> Maybe (GenericTupleDual f g p)
forall a. a -> Maybe a
Just (GenericTupleDual f g p -> Maybe (GenericTupleDual f g p))
-> GenericTupleDual f g p -> Maybe (GenericTupleDual f g p)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ GenericTupleDual f g p
pGenericTupleDual f g p
-> GenericTupleDual f g p -> Diff (GenericTupleDual f g p)
forall p. AffineSpace p => p -> p -> Diff p
.-.GenericTupleDual f g p
q
.-~! :: HasCallStack =>
GenericTupleDual f g p
-> GenericTupleDual f g p -> Needle (GenericTupleDual f g p)
(.-~!) = GenericTupleDual f g p
-> GenericTupleDual f g p -> Diff (GenericTupleDual f g p)
GenericTupleDual f g p
-> GenericTupleDual f g p -> Needle (GenericTupleDual f g p)
forall p. AffineSpace p => p -> p -> Diff p
(.-.)
instance ( DimensionAware (f p), DimensionAware (g p)
, VectorSpace (DualVector (f p)), VectorSpace (DualVector (g p))
, Scalar (f p) ~ Scalar (g p)
, Scalar (f p) ~ Scalar (DualVector (f p))
, Scalar (g p) ~ Scalar (DualVector (g p)) )
=> DimensionAware (GenericTupleDual f g p) where
type StaticDimension (GenericTupleDual f g p)
= Maybe.ZipWithPlus (StaticDimension (f p)) (StaticDimension (g p))
dimensionalityWitness :: DimensionalityWitness (GenericTupleDual f g p)
dimensionalityWitness = case ( forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(f p)
, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(g p) ) of
(DimensionalityWitness (f p)
IsStaticDimensional, DimensionalityWitness (g p)
IsStaticDimensional)
-> SNat (n + n)
-> (KnownNat (n + n) =>
DimensionalityWitness (GenericTupleDual f g p))
-> DimensionalityWitness (GenericTupleDual f g p)
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(f p) Sing n -> Sing n -> Sing (Apply (Apply (+@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
%+ forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(g p))
DimensionalityWitness (GenericTupleDual f g p)
KnownNat (n + n) => DimensionalityWitness (GenericTupleDual f g p)
forall (n :: Nat) v. Dimensional n v => DimensionalityWitness v
IsStaticDimensional
(DimensionalityWitness (f p)
IsFlexibleDimensional, DimensionalityWitness (g p)
_) -> DimensionalityWitness (GenericTupleDual f g p)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
(DimensionalityWitness (f p)
_, DimensionalityWitness (g p)
IsFlexibleDimensional) -> DimensionalityWitness (GenericTupleDual f g p)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
instance ∀ n f m g p nm .
( n`Dimensional`f p, m`Dimensional`g p
, VectorSpace (DualVector (f p)), VectorSpace (DualVector (g p))
, Scalar (f p) ~ Scalar (g p)
, Scalar (f p) ~ Scalar (DualVector (f p))
, Scalar (g p) ~ Scalar (DualVector (g p))
, nm ~ (n+m) )
=> nm`Dimensional`GenericTupleDual f g p where
knownDimensionalitySing :: Sing nm
knownDimensionalitySing = forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(f p) Sing n -> Sing m -> Sing (Apply (Apply (+@#@$) n) m)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
%+ forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(g p)
unsafeFromArrayWithOffset :: forall (α :: Type -> Type).
Vector α (Scalar (GenericTupleDual f g p)) =>
Int
-> α (Scalar (GenericTupleDual f g p)) -> GenericTupleDual f g p
unsafeFromArrayWithOffset Int
i α (Scalar (GenericTupleDual f g p))
ar
= GenericTupleDual f g p -> GenericTupleDual f g p
forall a b. Coercible a b => a -> b
coerce (forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
unsafeFromArrayWithOffset @nm @(GenericTupleDual f g p) Int
i α (Scalar (GenericTupleDual f g p))
ar)
unsafeWriteArrayWithOffset :: forall (α :: Type -> Type) σ.
Vector α (Scalar (GenericTupleDual f g p)) =>
Mutable α σ (Scalar (GenericTupleDual f g p))
-> Int -> GenericTupleDual f g p -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (GenericTupleDual f g p))
i Int
ar
= (GenericTupleDual f g p -> ST σ ())
-> GenericTupleDual f g p -> ST σ ()
forall a b. Coercible a b => a -> b
coerce (forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
unsafeWriteArrayWithOffset @nm @(GenericTupleDual f g p) Mutable α σ (Scalar (GenericTupleDual f g p))
i Int
ar)
instance ( LinearSpace (f p), LinearSpace (g p)
, VectorSpace (DualVector (f p)), VectorSpace (DualVector (g p))
, Scalar (f p) ~ Scalar (DualVector (f p))
, Scalar (g p) ~ Scalar (DualVector (g p))
, Scalar (DualVector (f p)) ~ Scalar (DualVector (g p)) )
=> TensorSpace (GenericTupleDual f g p) where
type TensorProduct (GenericTupleDual f g p) w = (f p+>w, g p+>w)
wellDefinedVector :: GenericTupleDual f g p -> Maybe (GenericTupleDual f g p)
wellDefinedVector = case ( DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> \(GenericTupleDual DualVector (f p)
fv DualVector (g p)
gv)
-> (DualVector (f p) -> DualVector (g p) -> GenericTupleDual f g p)
-> Maybe (DualVector (f p))
-> Maybe (DualVector (g p))
-> Maybe (GenericTupleDual f g p)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) c b a.
(Applicative f r t, Object r c, ObjectMorphism r b c,
Object t (f c), ObjectMorphism t (f b) (f c), ObjectPair r a b,
ObjectPair t (f a) (f b)) =>
r a (r b c) -> t (f a) (t (f b) (f c))
liftA2 DualVector (f p) -> DualVector (g p) -> GenericTupleDual f g p
forall (f :: Type -> Type) (g :: Type -> Type) p.
DualVector (f p) -> DualVector (g p) -> GenericTupleDual f g p
GenericTupleDual (DualVector (f p) -> Maybe (DualVector (f p))
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector DualVector (f p)
fv) (DualVector (g p) -> Maybe (DualVector (g p))
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector DualVector (g p)
gv)
wellDefinedTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericTupleDual f g p)) =>
(GenericTupleDual f g p ⊗ w) -> Maybe (GenericTupleDual f g p ⊗ w)
wellDefinedTensor = case ( DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> \(Tensor (LinearMap (Scalar (DualVector (g p))) (f p) w
ft, LinearMap (Scalar (DualVector (g p))) (g p) w
gt))
-> (LinearMap (Scalar (DualVector (g p))) (f p) w,
LinearMap (Scalar (DualVector (g p))) (g p) w)
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
TensorProduct (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ((LinearMap (Scalar (DualVector (g p))) (f p) w,
LinearMap (Scalar (DualVector (g p))) (g p) w)
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> Maybe
(LinearMap (Scalar (DualVector (g p))) (f p) w,
LinearMap (Scalar (DualVector (g p))) (g p) w)
-> Maybe
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
forall (f :: Type -> Type) (r :: Type -> Type -> Type) a b.
(Functor f r (->), Object r a, Object r b) =>
r a b -> f a -> f b
<$> (LinearMap (Scalar (DualVector (g p))) (f p) w
-> LinearMap (Scalar (DualVector (g p))) (g p) w
-> (LinearMap (Scalar (DualVector (g p))) (f p) w,
LinearMap (Scalar (DualVector (g p))) (g p) w))
-> Maybe (LinearMap (Scalar (DualVector (g p))) (f p) w)
-> Maybe (LinearMap (Scalar (DualVector (g p))) (g p) w)
-> Maybe
(LinearMap (Scalar (DualVector (g p))) (f p) w,
LinearMap (Scalar (DualVector (g p))) (g p) w)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) c b a.
(Applicative f r t, Object r c, ObjectMorphism r b c,
Object t (f c), ObjectMorphism t (f b) (f c), ObjectPair r a b,
ObjectPair t (f a) (f b)) =>
r a (r b c) -> t (f a) (t (f b) (f c))
liftA2 (,) (Coercion
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(LinearMap (Scalar (DualVector (g p))) (f p) w)
-> Coercion
(Maybe (Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w))
(Maybe (LinearMap (Scalar (DualVector (g p))) (f p) w))
forall a b.
(Object Coercion a, Object Coercion (Maybe a), Object Coercion b,
Object Coercion (Maybe b)) =>
Coercion a b -> Coercion (Maybe a) (Maybe b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(LinearMap (Scalar (DualVector (g p))) (f p) w)
-> Coercion
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(LinearMap (Scalar (DualVector (g p))) (f p) w)
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(LinearMap (Scalar (DualVector (g p))) (f p) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor)
Coercion
(Maybe (Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w))
(Maybe (LinearMap (Scalar (DualVector (g p))) (f p) w))
-> Maybe (Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
-> Maybe (LinearMap (Scalar (DualVector (g p))) (f p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (DualVector (f p) ⊗ w) -> Maybe (DualVector (f p) ⊗ w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector (f p))) =>
(DualVector (f p) ⊗ w) -> Maybe (DualVector (f p) ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor (VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (f p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap
(Scalar (DualVector (g p))) (DualVector (DualVector (f p))) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (LinearMap s (DualVector v) w) (Tensor s v w)
fromLinearMap VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (f p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
-> LinearMap (Scalar (DualVector (g p))) (f p) w
-> Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar (DualVector (g p))) (f p) w
ft))
(Coercion
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(LinearMap (Scalar (DualVector (g p))) (g p) w)
-> Coercion
(Maybe (Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w))
(Maybe (LinearMap (Scalar (DualVector (g p))) (g p) w))
forall a b.
(Object Coercion a, Object Coercion (Maybe a), Object Coercion b,
Object Coercion (Maybe b)) =>
Coercion a b -> Coercion (Maybe a) (Maybe b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(LinearMap (Scalar (DualVector (g p))) (g p) w)
-> Coercion
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(LinearMap (Scalar (DualVector (g p))) (g p) w)
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(LinearMap (Scalar (DualVector (g p))) (g p) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor)
Coercion
(Maybe (Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w))
(Maybe (LinearMap (Scalar (DualVector (g p))) (g p) w))
-> Maybe (Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
-> Maybe (LinearMap (Scalar (DualVector (g p))) (g p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
-> Maybe (Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector (g p))) =>
(DualVector (g p) ⊗ w) -> Maybe (DualVector (g p) ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor (VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (g p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap
(Scalar (DualVector (g p))) (DualVector (DualVector (g p))) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
forall s v w.
(LinearSpace v, Scalar v ~ s) =>
VSCCoercion s (LinearMap s (DualVector v) w) (Tensor s v w)
fromLinearMap VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (g p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
-> LinearMap (Scalar (DualVector (g p))) (g p) w
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar (DualVector (g p))) (g p) w
gt))
scalarSpaceWitness :: ScalarSpaceWitness (GenericTupleDual f g p)
scalarSpaceWitness = case ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p) of
ScalarSpaceWitness (f p)
ScalarSpaceWitness -> ScalarSpaceWitness (GenericTupleDual f g p)
forall v.
(Num' (Scalar v), Scalar (Scalar v) ~ Scalar v) =>
ScalarSpaceWitness v
ScalarSpaceWitness
linearManifoldWitness :: LinearManifoldWitness (GenericTupleDual f g p)
linearManifoldWitness = LinearManifoldWitness (GenericTupleDual f g p)
forall v.
(Needle v ~ v, AffineSpace v, Diff v ~ v) =>
LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
zeroTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericTupleDual f g p)) =>
GenericTupleDual f g p ⊗ w
zeroTensor = case ( LinearManifoldWitness (f p)
forall v. TensorSpace v => LinearManifoldWitness v
linearManifoldWitness :: LinearManifoldWitness (f p)
, DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
( LinearManifoldWitness (f p)
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
,DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness )
-> TensorProduct (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(LinearMap (Scalar (DualVector (g p))) (f p) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(LinearMap (Scalar (DualVector (g p))) (f p) w)
-> Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w
-> LinearMap (Scalar (DualVector (g p))) (f p) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ DualVector (f p) ⊗ w
Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector (f p))) =>
DualVector (f p) ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor, VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(LinearMap (Scalar (DualVector (g p))) (g p) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(LinearMap (Scalar (DualVector (g p))) (g p) w)
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
-> LinearMap (Scalar (DualVector (g p))) (g p) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector (g p))) =>
DualVector (g p) ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor)
toFlatTensor :: GenericTupleDual f g p
-+> (GenericTupleDual f g p ⊗ Scalar (GenericTupleDual f g p))
toFlatTensor = case ( ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p)
, DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(ScalarSpaceWitness (f p)
ScalarSpaceWitness, DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> (GenericTupleDual f g p
-> Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p))))
-> LinearFunction
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p))))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((GenericTupleDual f g p
-> Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p))))
-> LinearFunction
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p)))))
-> (GenericTupleDual f g p
-> Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p))))
-> LinearFunction
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p))))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(GenericTupleDual DualVector (f p)
tf DualVector (g p)
tg)
-> TensorProduct (GenericTupleDual f g p) (Scalar (DualVector (g p)))
-> Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p)))
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ( LinearFunction
(Scalar (f p))
(DualVector (f p))
(LinearMap
(Scalar (DualVector (g p))) (f p) (Scalar (DualVector (g p))))
DualVector (f p) -+> (f p +> Scalar (f p))
forall v. LinearSpace v => DualVector v -+> (v +> Scalar v)
toLinearForm LinearFunction
(Scalar (f p))
(DualVector (f p))
(LinearMap
(Scalar (DualVector (g p))) (f p) (Scalar (DualVector (g p))))
-> DualVector (f p)
-> LinearMap
(Scalar (DualVector (g p))) (f p) (Scalar (DualVector (g p)))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ DualVector (f p)
tf, LinearFunction
(Scalar (g p))
(DualVector (g p))
(LinearMap
(Scalar (DualVector (g p))) (g p) (Scalar (DualVector (g p))))
DualVector (g p) -+> (g p +> Scalar (g p))
forall v. LinearSpace v => DualVector v -+> (v +> Scalar v)
toLinearForm LinearFunction
(Scalar (g p))
(DualVector (g p))
(LinearMap
(Scalar (DualVector (g p))) (g p) (Scalar (DualVector (g p))))
-> DualVector (g p)
-> LinearMap
(Scalar (DualVector (g p))) (g p) (Scalar (DualVector (g p)))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ DualVector (g p)
tg )
fromFlatTensor :: (GenericTupleDual f g p ⊗ Scalar (GenericTupleDual f g p))
-+> GenericTupleDual f g p
fromFlatTensor = case ( ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p)
, DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(ScalarSpaceWitness (f p)
ScalarSpaceWitness, DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> (Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p)))
-> GenericTupleDual f g p)
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p))))
(GenericTupleDual f g p)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p)))
-> GenericTupleDual f g p)
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p))))
(GenericTupleDual f g p))
-> (Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p)))
-> GenericTupleDual f g p)
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(Scalar (DualVector (g p))))
(GenericTupleDual f g p)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Tensor (LinearMap
(Scalar (DualVector (g p))) (f p) (Scalar (DualVector (g p)))
tf,LinearMap
(Scalar (DualVector (g p))) (g p) (Scalar (DualVector (g p)))
tg))
-> DualVector (f p) -> DualVector (g p) -> GenericTupleDual f g p
forall (f :: Type -> Type) (g :: Type -> Type) p.
DualVector (f p) -> DualVector (g p) -> GenericTupleDual f g p
GenericTupleDual ((f p +> Scalar (f p)) -+> DualVector (f p)
LinearFunction
(Scalar (DualVector (f p)))
(LinearMap
(Scalar (DualVector (g p))) (f p) (Scalar (DualVector (g p))))
(DualVector (f p))
forall v. LinearSpace v => (v +> Scalar v) -+> DualVector v
fromLinearForm LinearFunction
(Scalar (DualVector (f p)))
(LinearMap
(Scalar (DualVector (g p))) (f p) (Scalar (DualVector (g p))))
(DualVector (f p))
-> LinearMap
(Scalar (DualVector (g p))) (f p) (Scalar (DualVector (g p)))
-> DualVector (f p)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap
(Scalar (DualVector (g p))) (f p) (Scalar (DualVector (g p)))
tf) ((g p +> Scalar (g p)) -+> DualVector (g p)
LinearFunction
(Scalar (DualVector (g p)))
(LinearMap
(Scalar (DualVector (g p))) (g p) (Scalar (DualVector (g p))))
(DualVector (g p))
forall v. LinearSpace v => (v +> Scalar v) -+> DualVector v
fromLinearForm LinearFunction
(Scalar (DualVector (g p)))
(LinearMap
(Scalar (DualVector (g p))) (g p) (Scalar (DualVector (g p))))
(DualVector (g p))
-> LinearMap
(Scalar (DualVector (g p))) (g p) (Scalar (DualVector (g p)))
-> DualVector (g p)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap
(Scalar (DualVector (g p))) (g p) (Scalar (DualVector (g p)))
tg)
addTensors :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericTupleDual f g p)) =>
(GenericTupleDual f g p ⊗ w)
-> (GenericTupleDual f g p ⊗ w) -> GenericTupleDual f g p ⊗ w
addTensors (Tensor (LinearMap (Scalar (DualVector (g p))) (f p) w
sf,LinearMap (Scalar (DualVector (g p))) (g p) w
sg)) (Tensor (LinearMap (Scalar (DualVector (g p))) (f p) w
tf,LinearMap (Scalar (DualVector (g p))) (g p) w
tg)) = TensorProduct (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (LinearMap (Scalar (DualVector (g p))) (f p) w
sfLinearMap (Scalar (DualVector (g p))) (f p) w
-> LinearMap (Scalar (DualVector (g p))) (f p) w
-> LinearMap (Scalar (DualVector (g p))) (f p) w
forall v. AdditiveGroup v => v -> v -> v
^+^LinearMap (Scalar (DualVector (g p))) (f p) w
tf, LinearMap (Scalar (DualVector (g p))) (g p) w
sgLinearMap (Scalar (DualVector (g p))) (g p) w
-> LinearMap (Scalar (DualVector (g p))) (g p) w
-> LinearMap (Scalar (DualVector (g p))) (g p) w
forall v. AdditiveGroup v => v -> v -> v
^+^LinearMap (Scalar (DualVector (g p))) (g p) w
tg)
negateTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericTupleDual f g p)) =>
(GenericTupleDual f g p ⊗ w) -+> (GenericTupleDual f g p ⊗ w)
negateTensor = (Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w))
-> (Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Tensor (LinearMap (Scalar (DualVector (g p))) (f p) w
tf,LinearMap (Scalar (DualVector (g p))) (g p) w
tg))
-> TensorProduct (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (LinearMap (Scalar (DualVector (g p))) (f p) w
-> LinearMap (Scalar (DualVector (g p))) (f p) w
forall v. AdditiveGroup v => v -> v
negateV LinearMap (Scalar (DualVector (g p))) (f p) w
tf, LinearMap (Scalar (DualVector (g p))) (g p) w
-> LinearMap (Scalar (DualVector (g p))) (g p) w
forall v. AdditiveGroup v => v -> v
negateV LinearMap (Scalar (DualVector (g p))) (g p) w
tg)
scaleTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericTupleDual f g p)) =>
Bilinear
(Scalar (GenericTupleDual f g p))
(GenericTupleDual f g p ⊗ w)
(GenericTupleDual f g p ⊗ w)
scaleTensor = (Scalar (DualVector (g p))
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> LinearFunction
(Scalar (Scalar (DualVector (g p))))
(Scalar (DualVector (g p)))
(LinearFunction
(Scalar (Scalar (DualVector (g p))))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((Scalar (DualVector (g p))
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> LinearFunction
(Scalar (Scalar (DualVector (g p))))
(Scalar (DualVector (g p)))
(LinearFunction
(Scalar (Scalar (DualVector (g p))))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)))
-> (Scalar (DualVector (g p))
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> LinearFunction
(Scalar (Scalar (DualVector (g p))))
(Scalar (DualVector (g p)))
(LinearFunction
(Scalar (Scalar (DualVector (g p))))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \Scalar (DualVector (g p))
μ (Tensor (LinearMap (Scalar (DualVector (g p))) (f p) w
tf,LinearMap (Scalar (DualVector (g p))) (g p) w
tg)) -> TensorProduct (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (Scalar (LinearMap (Scalar (DualVector (g p))) (f p) w)
Scalar (DualVector (g p))
μScalar (LinearMap (Scalar (DualVector (g p))) (f p) w)
-> LinearMap (Scalar (DualVector (g p))) (f p) w
-> LinearMap (Scalar (DualVector (g p))) (f p) w
forall v. VectorSpace v => Scalar v -> v -> v
*^LinearMap (Scalar (DualVector (g p))) (f p) w
tf, Scalar (LinearMap (Scalar (DualVector (g p))) (g p) w)
Scalar (DualVector (g p))
μScalar (LinearMap (Scalar (DualVector (g p))) (g p) w)
-> LinearMap (Scalar (DualVector (g p))) (g p) w
-> LinearMap (Scalar (DualVector (g p))) (g p) w
forall v. VectorSpace v => Scalar v -> v -> v
*^LinearMap (Scalar (DualVector (g p))) (g p) w
tg)
tensorProduct :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericTupleDual f g p)) =>
Bilinear (GenericTupleDual f g p) w (GenericTupleDual f g p ⊗ w)
tensorProduct = case ( ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p)
, DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(ScalarSpaceWitness (f p)
ScalarSpaceWitness, DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> (GenericTupleDual f g p
-> w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> Bilinear
(GenericTupleDual f g p)
w
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(GenericTupleDual f g p
-> w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> LinearFunction
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(LinearFunction
(Scalar (DualVector (g p)))
w
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((GenericTupleDual f g p
-> w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> LinearFunction
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(LinearFunction
(Scalar (DualVector (g p)))
w
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)))
-> (GenericTupleDual f g p
-> w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> LinearFunction
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(LinearFunction
(Scalar (DualVector (g p)))
w
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(GenericTupleDual DualVector (f p)
fw DualVector (g p)
gw) w
x
-> TensorProduct (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(LinearMap (Scalar (DualVector (g p))) (f p) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(LinearMap (Scalar (DualVector (g p))) (f p) w)
-> Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w
-> LinearMap (Scalar (DualVector (g p))) (f p) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ DualVector (f p)
fwDualVector (f p) -> w -> DualVector (f p) ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v,
Num' (Scalar v)) =>
v -> w -> v ⊗ w
⊗w
x, VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(LinearMap (Scalar (DualVector (g p))) (g p) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(LinearMap (Scalar (DualVector (g p))) (g p) w)
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
-> LinearMap (Scalar (DualVector (g p))) (g p) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ DualVector (g p)
gwDualVector (g p)
-> w -> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v,
Num' (Scalar v)) =>
v -> w -> v ⊗ w
⊗w
x)
transposeTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericTupleDual f g p)) =>
(GenericTupleDual f g p ⊗ w) -+> (w ⊗ GenericTupleDual f g p)
transposeTensor = case ( ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p)
, DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(ScalarSpaceWitness (f p)
ScalarSpaceWitness, DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> (Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) w (GenericTupleDual f g p))
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) w (GenericTupleDual f g p))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) w (GenericTupleDual f g p))
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) w (GenericTupleDual f g p)))
-> (Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) w (GenericTupleDual f g p))
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) w (GenericTupleDual f g p))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(Tensor (LinearMap (Scalar (DualVector (g p))) (f p) w
fw, LinearMap (Scalar (DualVector (g p))) (g p) w
gw))
-> (LinearFunction
(Scalar w)
(LinearFunction
(Scalar w)
(DualVector (f p), DualVector (g p))
(GenericTupleDual f g p))
(LinearFunction
(Scalar w)
(Tensor (Scalar w) w (DualVector (f p)),
Tensor (Scalar w) w (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) w (GenericTupleDual f g p)))
Bilinear
((DualVector (f p), DualVector (g p)) -+> GenericTupleDual f g p)
(Tensor (Scalar w) w (DualVector (f p)),
Tensor (Scalar w) w (DualVector (g p)))
(w ⊗ GenericTupleDual f g p)
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar w,
Scalar w ~ Scalar w, Scalar x ~ Scalar w) =>
Bilinear ((w, x) -+> u) (w ⊗ w, w ⊗ x) (w ⊗ u)
fzipTensorWithLinearFunction
(Scalar w)
(LinearFunction
(Scalar w)
(DualVector (f p), DualVector (g p))
(GenericTupleDual f g p))
(LinearFunction
(Scalar w)
(Tensor (Scalar w) w (DualVector (f p)),
Tensor (Scalar w) w (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) w (GenericTupleDual f g p)))
-> LinearFunction
(Scalar w)
(DualVector (f p), DualVector (g p))
(GenericTupleDual f g p)
-> LinearFunction
(Scalar w)
(Tensor (Scalar w) w (DualVector (f p)),
Tensor (Scalar w) w (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) w (GenericTupleDual f g p))
forall s v w. LinearFunction s v w -> v -> w
-+$>((DualVector (f p), DualVector (g p)) -> GenericTupleDual f g p)
-> LinearFunction
(Scalar (DualVector (g p)))
(DualVector (f p), DualVector (g p))
(GenericTupleDual f g p)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction(((DualVector (f p), DualVector (g p)) -> GenericTupleDual f g p)
-> LinearFunction
(Scalar (DualVector (g p)))
(DualVector (f p), DualVector (g p))
(GenericTupleDual f g p))
-> ((DualVector (f p), DualVector (g p)) -> GenericTupleDual f g p)
-> LinearFunction
(Scalar w)
(DualVector (f p), DualVector (g p))
(GenericTupleDual f g p)
(((DualVector (f p), DualVector (g p)) -> GenericTupleDual f g p)
-> LinearFunction
(Scalar (DualVector (g p)))
(DualVector (f p), DualVector (g p))
(GenericTupleDual f g p))
-> ((DualVector (f p), DualVector (g p)) -> GenericTupleDual f g p)
-> LinearFunction
(Scalar (DualVector (g p)))
(DualVector (f p), DualVector (g p))
(GenericTupleDual f g p)
forall a. Object (->) a => a -> a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
`id`(DualVector (f p) -> DualVector (g p) -> GenericTupleDual f g p)
-> (DualVector (f p), DualVector (g p)) -> GenericTupleDual f g p
forall a b c.
(ObjectPair (->) a b, ObjectMorphism (->) b c) =>
(a -> b -> c) -> (a, b) -> c
forall (k :: Type -> Type -> Type) a b c.
(Curry k, ObjectPair k a b, ObjectMorphism k b c) =>
k a (k b c) -> k (a, b) c
uncurry DualVector (f p) -> DualVector (g p) -> GenericTupleDual f g p
forall (f :: Type -> Type) (g :: Type -> Type) p.
DualVector (f p) -> DualVector (g p) -> GenericTupleDual f g p
GenericTupleDual)
LinearFunction
(Scalar w)
(Tensor (Scalar w) w (DualVector (f p)),
Tensor (Scalar w) w (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) w (GenericTupleDual f g p))
-> (Tensor (Scalar w) w (DualVector (f p)),
Tensor (Scalar w) w (DualVector (g p)))
-> Tensor (Scalar (DualVector (g p))) w (GenericTupleDual f g p)
forall s v w. LinearFunction s v w -> v -> w
-+$> ( Tensor (Scalar (DualVector (f p))) (DualVector (f p)) w
-+> Tensor (Scalar w) w (DualVector (f p))
LinearFunction
(Scalar (DualVector (f p)))
(Tensor (Scalar (DualVector (f p))) (DualVector (f p)) w)
(Tensor (Scalar w) w (DualVector (f p)))
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector (f p))) =>
(DualVector (f p) ⊗ w) -+> (w ⊗ DualVector (f p))
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensorLinearFunction
(Scalar (DualVector (f p)))
(Tensor (Scalar (DualVector (f p))) (DualVector (f p)) w)
(Tensor (Scalar w) w (DualVector (f p)))
-> Tensor (Scalar (DualVector (f p))) (DualVector (f p)) w
-> Tensor (Scalar w) w (DualVector (f p))
forall s v w. LinearFunction s v w -> v -> w
-+$>VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (f p) w)
(Tensor (Scalar (DualVector (f p))) (DualVector (f p)) w)
VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (f p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (f p) w)
(Tensor (Scalar (DualVector (f p))) (DualVector (f p)) w)
-> LinearMap (Scalar (DualVector (g p))) (f p) w
-> Tensor (Scalar (DualVector (f p))) (DualVector (f p)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar (DualVector (g p))) (f p) w
fw
, Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
-+> Tensor (Scalar w) w (DualVector (g p))
LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(Tensor (Scalar w) w (DualVector (g p)))
forall w.
(TensorSpace w, Scalar w ~ Scalar (DualVector (g p))) =>
(DualVector (g p) ⊗ w) -+> (w ⊗ DualVector (g p))
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensorLinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(Tensor (Scalar w) w (DualVector (g p)))
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
-> Tensor (Scalar w) w (DualVector (g p))
forall s v w. LinearFunction s v w -> v -> w
-+$>VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (g p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (g p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
-> LinearMap (Scalar (DualVector (g p))) (g p) w
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar (DualVector (g p))) (g p) w
gw )
fmapTensor :: forall w x.
(TensorSpace w, TensorSpace x,
Scalar w ~ Scalar (GenericTupleDual f g p),
Scalar x ~ Scalar (GenericTupleDual f g p)) =>
Bilinear
(w -+> x) (GenericTupleDual f g p ⊗ w) (GenericTupleDual f g p ⊗ x)
fmapTensor = case ( ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p)
, DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(ScalarSpaceWitness (f p)
ScalarSpaceWitness, DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> (LinearFunction (Scalar (DualVector (g p))) w x
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
-> Bilinear
(LinearFunction (Scalar (DualVector (g p))) w x)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
(LinearFunction (Scalar (DualVector (g p))) w x
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
-> LinearFunction
(Scalar (DualVector (g p)))
(LinearFunction (Scalar (DualVector (g p))) w x)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction (Scalar (DualVector (g p))) w x
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
-> LinearFunction
(Scalar (DualVector (g p)))
(LinearFunction (Scalar (DualVector (g p))) w x)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)))
-> (LinearFunction (Scalar (DualVector (g p))) w x
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
-> LinearFunction
(Scalar (DualVector (g p)))
(LinearFunction (Scalar (DualVector (g p))) w x)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction (Scalar (DualVector (g p))) w x
f (Tensor (LinearMap (Scalar (DualVector (g p))) (f p) w
fw, LinearMap (Scalar (DualVector (g p))) (g p) w
gw))
-> TensorProduct (GenericTupleDual f g p) x
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ( VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x)
(LinearMap (Scalar (DualVector (g p))) (f p) x)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x)
(LinearMap (Scalar (DualVector (g p))) (f p) x)
-> Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x
-> LinearMap (Scalar (DualVector (g p))) (f p) x
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Bilinear (w -+> x) (DualVector (f p) ⊗ w) (DualVector (f p) ⊗ x)
LinearFunction
(Scalar (DualVector (f p)))
(LinearFunction (Scalar (DualVector (g p))) w x)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x))
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x,
Scalar w ~ Scalar (DualVector (f p)),
Scalar x ~ Scalar (DualVector (f p))) =>
Bilinear (w -+> x) (DualVector (f p) ⊗ w) (DualVector (f p) ⊗ x)
fmapTensorLinearFunction
(Scalar (DualVector (f p)))
(LinearFunction (Scalar (DualVector (g p))) w x)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x))
-> LinearFunction (Scalar (DualVector (g p))) w x
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (DualVector (g p))) w x
f) LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x)
-> Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w
-> Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (f p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (f p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
-> LinearMap (Scalar (DualVector (g p))) (f p) w
-> Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar (DualVector (g p))) (f p) w
fw
, VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
(LinearMap (Scalar (DualVector (g p))) (g p) x)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
(LinearMap (Scalar (DualVector (g p))) (g p) x)
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x
-> LinearMap (Scalar (DualVector (g p))) (g p) x
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Bilinear
(w -+> x)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
LinearFunction
(Scalar (DualVector (g p)))
(LinearFunction (Scalar (DualVector (g p))) w x)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x))
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x,
Scalar w ~ Scalar (DualVector (g p)),
Scalar x ~ Scalar (DualVector (g p))) =>
Bilinear (w -+> x) (DualVector (g p) ⊗ w) (DualVector (g p) ⊗ x)
fmapTensorLinearFunction
(Scalar (DualVector (g p)))
(LinearFunction (Scalar (DualVector (g p))) w x)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x))
-> LinearFunction (Scalar (DualVector (g p))) w x
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (DualVector (g p))) w x
f) LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (g p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (g p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
-> LinearMap (Scalar (DualVector (g p))) (g p) w
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar (DualVector (g p))) (g p) w
gw )
fzipTensorWith :: forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (GenericTupleDual f g p),
Scalar w ~ Scalar (GenericTupleDual f g p),
Scalar x ~ Scalar (GenericTupleDual f g p)) =>
Bilinear
((w, x) -+> u)
(GenericTupleDual f g p ⊗ w, GenericTupleDual f g p ⊗ x)
(GenericTupleDual f g p ⊗ u)
fzipTensorWith = case ( ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p)
, DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(ScalarSpaceWitness (f p)
ScalarSpaceWitness, DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> (LinearFunction (Scalar (DualVector (g p))) (w, x) u
-> (Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w,
Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) u)
-> Bilinear
(LinearFunction (Scalar (DualVector (g p))) (w, x) u)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w,
Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) u)
(LinearFunction (Scalar (DualVector (g p))) (w, x) u
-> (Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w,
Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) u)
-> LinearFunction
(Scalar (DualVector (g p)))
(LinearFunction (Scalar (DualVector (g p))) (w, x) u)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w,
Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) u))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction (Scalar (DualVector (g p))) (w, x) u
-> (Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w,
Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) u)
-> LinearFunction
(Scalar (DualVector (g p)))
(LinearFunction (Scalar (DualVector (g p))) (w, x) u)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w,
Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) u)))
-> (LinearFunction (Scalar (DualVector (g p))) (w, x) u
-> (Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w,
Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) u)
-> LinearFunction
(Scalar (DualVector (g p)))
(LinearFunction (Scalar (DualVector (g p))) (w, x) u)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w,
Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) x)
(Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) u))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearFunction (Scalar (DualVector (g p))) (w, x) u
f (Tensor (LinearMap (Scalar (DualVector (g p))) (f p) w
fw, LinearMap (Scalar (DualVector (g p))) (g p) w
gw), Tensor (LinearMap (Scalar (DualVector (g p))) (f p) x
fx, LinearMap (Scalar (DualVector (g p))) (g p) x
gx))
-> TensorProduct (GenericTupleDual f g p) u
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) u
forall s v w. TensorProduct v w -> Tensor s v w
Tensor ( VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) u)
(LinearMap (Scalar (DualVector (g p))) (f p) u)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) u)
(LinearMap (Scalar (DualVector (g p))) (f p) u)
-> Tensor (Scalar (DualVector (g p))) (DualVector (f p)) u
-> LinearMap (Scalar (DualVector (g p))) (f p) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Bilinear
((w, x) -+> u)
(DualVector (f p) ⊗ w, DualVector (f p) ⊗ x)
(DualVector (f p) ⊗ u)
LinearFunction
(Scalar (DualVector (f p)))
(LinearFunction (Scalar (DualVector (g p))) (w, x) u)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w,
Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) u))
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (DualVector (f p)),
Scalar w ~ Scalar (DualVector (f p)),
Scalar x ~ Scalar (DualVector (f p))) =>
Bilinear
((w, x) -+> u)
(DualVector (f p) ⊗ w, DualVector (f p) ⊗ x)
(DualVector (f p) ⊗ u)
fzipTensorWithLinearFunction
(Scalar (DualVector (f p)))
(LinearFunction (Scalar (DualVector (g p))) (w, x) u)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w,
Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) u))
-> LinearFunction (Scalar (DualVector (g p))) (w, x) u
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w,
Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) u)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (DualVector (g p))) (w, x) u
f) LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w,
Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) u)
-> (Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w,
Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x)
-> Tensor (Scalar (DualVector (g p))) (DualVector (f p)) u
forall s v w. LinearFunction s v w -> v -> w
-+$> ( VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (f p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (f p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w)
-> LinearMap (Scalar (DualVector (g p))) (f p) w
-> Tensor (Scalar (DualVector (g p))) (DualVector (f p)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar (DualVector (g p))) (f p) w
fw
, VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (f p) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (f p) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x)
-> LinearMap (Scalar (DualVector (g p))) (f p) x
-> Tensor (Scalar (DualVector (g p))) (DualVector (f p)) x
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar (DualVector (g p))) (f p) x
fx )
, VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) u)
(LinearMap (Scalar (DualVector (g p))) (g p) u)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) u)
(LinearMap (Scalar (DualVector (g p))) (g p) u)
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) u
-> LinearMap (Scalar (DualVector (g p))) (g p) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Bilinear
((w, x) -+> u)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w,
Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) u)
LinearFunction
(Scalar (DualVector (g p)))
(LinearFunction (Scalar (DualVector (g p))) (w, x) u)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w,
Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) u))
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (DualVector (g p)),
Scalar w ~ Scalar (DualVector (g p)),
Scalar x ~ Scalar (DualVector (g p))) =>
Bilinear
((w, x) -+> u)
(DualVector (g p) ⊗ w, DualVector (g p) ⊗ x)
(DualVector (g p) ⊗ u)
fzipTensorWithLinearFunction
(Scalar (DualVector (g p)))
(LinearFunction (Scalar (DualVector (g p))) (w, x) u)
(LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w,
Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) u))
-> LinearFunction (Scalar (DualVector (g p))) (w, x) u
-> LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w,
Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) u)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (DualVector (g p))) (w, x) u
f) LinearFunction
(Scalar (DualVector (g p)))
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w,
Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) u)
-> (Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w,
Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) u
forall s v w. LinearFunction s v w -> v -> w
-+$> ( VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (g p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (g p) w)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w)
-> LinearMap (Scalar (DualVector (g p))) (g p) w
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar (DualVector (g p))) (g p) w
gw
, VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (g p) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor VSCCoercion
(Scalar (DualVector (g p)))
(LinearMap (Scalar (DualVector (g p))) (g p) x)
(Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x)
-> LinearMap (Scalar (DualVector (g p))) (g p) x
-> Tensor (Scalar (DualVector (g p))) (DualVector (g p)) x
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap (Scalar (DualVector (g p))) (g p) x
gx ) )
tensorUnsafeFromArrayWithOffset
:: ∀ w m α . ( TensorSpace w, m`Dimensional`w, Scalar w ~ Scalar (f p)
, GArr.Vector α (Scalar (f p)) )
=> Int -> α (Scalar (f p)) -> (GenericTupleDual f g p⊗w)
tensorUnsafeFromArrayWithOffset :: forall w (m :: Nat) (α :: Type -> Type).
(TensorSpace w, Dimensional m w, Scalar w ~ Scalar (f p),
Vector α (Scalar (f p))) =>
Int -> α (Scalar (f p)) -> GenericTupleDual f g p ⊗ w
tensorUnsafeFromArrayWithOffset
= case ( forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @(f p), forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @(g p) ) of
(DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness) -> case
( forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(DualVector (f p))
, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(DualVector (g p)) ) of
(DimensionalityWitness (DualVector (f p))
IsFlexibleDimensional, DimensionalityWitness (DualVector (g p))
_)
-> [Char]
-> Int
-> α (Scalar (DualVector (g p)))
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `f p` is static-dimensional."
(DimensionalityWitness (DualVector (f p))
_, DimensionalityWitness (DualVector (g p))
IsFlexibleDimensional) -> [Char]
-> Int
-> α (Scalar (DualVector (g p)))
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `g p` is static-dimensional."
(DimensionalityWitness (DualVector (f p))
IsStaticDimensional, DimensionalityWitness (DualVector (g p))
IsStaticDimensional)
-> SNat (n + n)
-> (KnownNat (n + n) =>
Int
-> α (Scalar (DualVector (g p)))
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w)
-> Int
-> α (Scalar (DualVector (g p)))
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(DualVector (f p))
Sing n -> Sing n -> Sing (Apply (Apply (+@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
%+ forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(DualVector (g p)))
(\Int
i α (Scalar (DualVector (g p)))
ar
-> Tensor
(Scalar (DualVector (g p))) (DualVector (f p), DualVector (g p)) w
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v ⊗ w
tensorUnsafeFromArrayWithOffset
@(DualVector (f p), DualVector (g p)) @w Int
i α (Scalar (DualVector (f p), DualVector (g p)))
α (Scalar (DualVector (g p)))
ar) )
tensorUnsafeWriteArrayWithOffset
:: ∀ w m α σ . ( TensorSpace w, m`Dimensional`w, Scalar w ~ Scalar (f p)
, GArr.Vector α (Scalar (f p)) )
=> GArr.Mutable α σ (Scalar (f p)) -> Int -> (GenericTupleDual f g p⊗w)
-> ST σ ()
tensorUnsafeWriteArrayWithOffset :: forall w (m :: Nat) (α :: Type -> Type) σ.
(TensorSpace w, Dimensional m w, Scalar w ~ Scalar (f p),
Vector α (Scalar (f p))) =>
Mutable α σ (Scalar (f p))
-> Int -> (GenericTupleDual f g p ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset
= case ( forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @(f p), forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @(g p) ) of
(DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness) -> case
( forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(DualVector (f p))
, forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(DualVector (g p)) ) of
(DimensionalityWitness (DualVector (f p))
IsFlexibleDimensional, DimensionalityWitness (DualVector (g p))
_)
-> [Char]
-> Mutable α σ (Scalar (DualVector (g p)))
-> Int
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> ST σ ()
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `f p` is static-dimensional."
(DimensionalityWitness (DualVector (f p))
_, DimensionalityWitness (DualVector (g p))
IsFlexibleDimensional) -> [Char]
-> Mutable α σ (Scalar (DualVector (g p)))
-> Int
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> ST σ ()
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `g p` is static-dimensional."
(DimensionalityWitness (DualVector (f p))
IsStaticDimensional, DimensionalityWitness (DualVector (g p))
IsStaticDimensional)
-> SNat (n + n)
-> (KnownNat (n + n) =>
Mutable α σ (Scalar (DualVector (g p)))
-> Int
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> ST σ ())
-> Mutable α σ (Scalar (DualVector (g p)))
-> Int
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> ST σ ()
forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
withKnownNat (forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(DualVector (f p))
Sing n -> Sing n -> Sing (Apply (Apply (+@#@$) n) n)
forall (t1 :: Nat) (t2 :: Nat).
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
forall a (t1 :: a) (t2 :: a).
SNum a =>
Sing t1 -> Sing t2 -> Sing (Apply (Apply (+@#@$) t1) t2)
%+ forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(DualVector (g p)))
(\Mutable α σ (Scalar (DualVector (g p)))
ar
-> (Int
-> Tensor
(Scalar (DualVector (g p))) (DualVector (f p), DualVector (g p)) w
-> ST σ ())
-> Int
-> Tensor (Scalar (DualVector (g p))) (GenericTupleDual f g p) w
-> ST σ ()
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) σ (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> (v ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset
@(DualVector (f p), DualVector (g p)) @w Mutable α σ (Scalar (DualVector (f p), DualVector (g p)))
Mutable α σ (Scalar (DualVector (g p)))
ar) )
coerceFmapTensorProduct :: forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a,
Scalar a ~ Scalar (GenericTupleDual f g p), TensorSpace b,
Scalar b ~ Scalar (GenericTupleDual f g p)) =>
p (GenericTupleDual f g p)
-> VSCCoercion (Scalar (GenericTupleDual f g p)) a b
-> Coercion
(TensorProduct (GenericTupleDual f g p) a)
(TensorProduct (GenericTupleDual f g p) b)
coerceFmapTensorProduct p (GenericTupleDual f g p)
p VSCCoercion (Scalar (GenericTupleDual f g p)) a b
cab = case ( DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness) -> case
( p (DualVector (f p))
-> VSCCoercion (Scalar (DualVector (f p))) a b
-> Coercion
(TensorProduct (DualVector (f p)) a)
(TensorProduct (DualVector (f p)) b)
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (DualVector (f p)),
TensorSpace b, Scalar b ~ Scalar (DualVector (f p))) =>
p (DualVector (f p))
-> VSCCoercion (Scalar (DualVector (f p))) a b
-> Coercion
(TensorProduct (DualVector (f p)) a)
(TensorProduct (DualVector (f p)) b)
coerceFmapTensorProduct ((\(GenericTupleDual DualVector (f p)
u DualVector (g p)
_)->DualVector (f p)
u)(GenericTupleDual f g p -> DualVector (f p))
-> p (GenericTupleDual f g p) -> p (DualVector (f p))
forall (f :: Type -> Type) (r :: Type -> Type -> Type) a b.
(Functor f r (->), Object r a, Object r b) =>
r a b -> f a -> f b
<$>p (GenericTupleDual f g p)
p) VSCCoercion (Scalar (GenericTupleDual f g p)) a b
VSCCoercion (Scalar (DualVector (f p))) a b
cab
, p (DualVector (g p))
-> VSCCoercion (Scalar (DualVector (g p))) a b
-> Coercion
(TensorProduct (DualVector (g p)) a)
(TensorProduct (DualVector (g p)) b)
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar (DualVector (g p)),
TensorSpace b, Scalar b ~ Scalar (DualVector (g p))) =>
p (DualVector (g p))
-> VSCCoercion (Scalar (DualVector (g p))) a b
-> Coercion
(TensorProduct (DualVector (g p)) a)
(TensorProduct (DualVector (g p)) b)
coerceFmapTensorProduct ((\(GenericTupleDual DualVector (f p)
_ DualVector (g p)
v)->DualVector (g p)
v)(GenericTupleDual f g p -> DualVector (g p))
-> p (GenericTupleDual f g p) -> p (DualVector (g p))
forall (f :: Type -> Type) (r :: Type -> Type -> Type) a b.
(Functor f r (->), Object r a, Object r b) =>
r a b -> f a -> f b
<$>p (GenericTupleDual f g p)
p) VSCCoercion (Scalar (GenericTupleDual f g p)) a b
VSCCoercion (Scalar (DualVector (g p))) a b
cab ) of
(Coercion
(TensorProduct (DualVector (f p)) a)
(TensorProduct (DualVector (f p)) b)
Coercion, Coercion
(TensorProduct (DualVector (g p)) a)
(TensorProduct (DualVector (g p)) b)
Coercion) -> Coercion
(LinearMap (Scalar (DualVector (g p))) (f p) a,
LinearMap (Scalar (DualVector (g p))) (g p) a)
(LinearMap (Scalar (DualVector (g p))) (f p) b,
LinearMap (Scalar (DualVector (g p))) (g p) b)
Coercion
(TensorProduct (GenericTupleDual f g p) a)
(TensorProduct (GenericTupleDual f g p) b)
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion
instance ∀ f g p . ( LinearSpace (f p), LinearSpace (g p), Scalar (f p) ~ Scalar (g p) )
=> LinearSpace ((f:*:g) p) where
type DualVector ((f:*:g) p) = GenericTupleDual f g p
dualSpaceWitness :: DualSpaceWitness ((:*:) f g p)
dualSpaceWitness = DualSpaceWitness ((:*:) f g p)
forall a. a
genericTensorspaceError
linearId :: (:*:) f g p +> (:*:) f g p
linearId = case ( ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p)
, DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(ScalarSpaceWitness (f p)
ScalarSpaceWitness, DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> TensorProduct (DualVector ((:*:) f g p)) ((:*:) f g p)
-> LinearMap (Scalar (g p)) ((:*:) f g p) ((:*:) f g p)
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap ( LinearFunction (Scalar (g p)) (f p) ((:*:) f g p)
-> LinearMap (Scalar (g p)) (f p) ((:*:) f g p)
forall b c.
(Object (LinearFunction (Scalar (g p))) b,
Object (LinearFunction (Scalar (g p))) c,
Object (LinearMap (Scalar (g p))) b,
Object (LinearMap (Scalar (g p))) c) =>
LinearFunction (Scalar (g p)) b c -> LinearMap (Scalar (g p)) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (LinearFunction (Scalar (g p)) (f p) ((:*:) f g p)
-> LinearMap (Scalar (g p)) (f p) ((:*:) f g p))
-> LinearFunction (Scalar (g p)) (f p) ((:*:) f g p)
-> LinearMap (Scalar (g p)) (f p) ((:*:) f g p)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (f p -> (:*:) f g p)
-> LinearFunction (Scalar (g p)) (f p) ((:*:) f g p)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (\f p
vf->(f p
vff p -> g p -> (:*:) f g p
forall k (f :: k -> Type) (g :: k -> Type) (p :: k).
f p -> g p -> (:*:) f g p
:*:g p
forall v. AdditiveGroup v => v
zeroV))
, LinearFunction (Scalar (g p)) (g p) ((:*:) f g p)
-> LinearMap (Scalar (g p)) (g p) ((:*:) f g p)
forall b c.
(Object (LinearFunction (Scalar (g p))) b,
Object (LinearFunction (Scalar (g p))) c,
Object (LinearMap (Scalar (g p))) b,
Object (LinearMap (Scalar (g p))) c) =>
LinearFunction (Scalar (g p)) b c -> LinearMap (Scalar (g p)) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (LinearFunction (Scalar (g p)) (g p) ((:*:) f g p)
-> LinearMap (Scalar (g p)) (g p) ((:*:) f g p))
-> LinearFunction (Scalar (g p)) (g p) ((:*:) f g p)
-> LinearMap (Scalar (g p)) (g p) ((:*:) f g p)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (g p -> (:*:) f g p)
-> LinearFunction (Scalar (g p)) (g p) ((:*:) f g p)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (\g p
vg->(f p
forall v. AdditiveGroup v => v
zeroVf p -> g p -> (:*:) f g p
forall k (f :: k -> Type) (g :: k -> Type) (p :: k).
f p -> g p -> (:*:) f g p
:*:g p
vg)) )
tensorId :: forall w.
(LinearSpace w, Scalar w ~ Scalar ((:*:) f g p)) =>
((:*:) f g p ⊗ w) +> ((:*:) f g p ⊗ w)
tensorId = ScalarSpaceWitness (f p)
-> DualSpaceWitness (f p)
-> DualSpaceWitness (g p)
-> DualSpaceWitness w
-> LinearMap
(Scalar ((:*:) f g p ⊗ w)) ((:*:) f g p ⊗ w) ((:*:) f g p ⊗ w)
forall w.
(LinearSpace w, Scalar w ~ Scalar (f p)) =>
ScalarSpaceWitness (f p)
-> DualSpaceWitness (f p)
-> DualSpaceWitness (g p)
-> DualSpaceWitness w
-> ((:*:) f g p ⊗ w) +> ((:*:) f g p ⊗ w)
tI ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness DualSpaceWitness w
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness
where tI :: ∀ w . (LinearSpace w, Scalar w ~ Scalar (f p))
=> ScalarSpaceWitness (f p) -> DualSpaceWitness (f p)
-> DualSpaceWitness (g p) -> DualSpaceWitness w
-> (((f:*:g) p)⊗w)+>(((f:*:g) p)⊗w)
tI :: forall w.
(LinearSpace w, Scalar w ~ Scalar (f p)) =>
ScalarSpaceWitness (f p)
-> DualSpaceWitness (f p)
-> DualSpaceWitness (g p)
-> DualSpaceWitness w
-> ((:*:) f g p ⊗ w) +> ((:*:) f g p ⊗ w)
tI ScalarSpaceWitness (f p)
ScalarSpaceWitness DualSpaceWitness (f p)
DualSpaceWitness DualSpaceWitness (g p)
DualSpaceWitness DualSpaceWitness w
DualSpaceWitness
= TensorProduct
(DualVector (Tensor (Scalar (g p)) ((:*:) f g p) w))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearMap
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) w)
(Tensor (Scalar (g p)) ((:*:) f g p) w)
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap
( LinearFunction
(Scalar (g p))
(f p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
-> LinearMap
(Scalar (g p))
(f p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
forall b c.
(Object (LinearFunction (Scalar (g p))) b,
Object (LinearFunction (Scalar (g p))) c,
Object (LinearMap (Scalar (g p))) b,
Object (LinearMap (Scalar (g p))) c) =>
LinearFunction (Scalar (g p)) b c -> LinearMap (Scalar (g p)) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (LinearFunction
(Scalar (g p))
(f p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
-> LinearMap
(Scalar (g p))
(f p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w)))
-> LinearFunction
(Scalar (g p))
(f p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
-> LinearMap
(Scalar (g p))
(f p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (f p
-> Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
-> LinearFunction
(Scalar (g p))
(f p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (\f p
vf -> VSCCoercion
(Scalar (g p))
(LinearMap
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w))
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor
VSCCoercion
(Scalar (g p))
(LinearMap
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w))
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
-> LinearMap
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w)
-> Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearMap
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w)
forall b c.
(Object (LinearFunction (Scalar (g p))) b,
Object (LinearFunction (Scalar (g p))) c,
Object (LinearMap (Scalar (g p))) b,
Object (LinearMap (Scalar (g p))) c) =>
LinearFunction (Scalar (g p)) b c -> LinearMap (Scalar (g p)) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr ((w -> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((w -> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w))
-> (w -> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \w
w -> TensorProduct ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (f p
vff p -> w -> f p ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v,
Num' (Scalar v)) =>
v -> w -> v ⊗ w
⊗w
w, Tensor (Scalar (g p)) (g p) w
forall v. AdditiveGroup v => v
zeroV)))
, LinearFunction
(Scalar (g p))
(g p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
-> LinearMap
(Scalar (g p))
(g p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
forall b c.
(Object (LinearFunction (Scalar (g p))) b,
Object (LinearFunction (Scalar (g p))) c,
Object (LinearMap (Scalar (g p))) b,
Object (LinearMap (Scalar (g p))) c) =>
LinearFunction (Scalar (g p)) b c -> LinearMap (Scalar (g p)) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (LinearFunction
(Scalar (g p))
(g p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
-> LinearMap
(Scalar (g p))
(g p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w)))
-> LinearFunction
(Scalar (g p))
(g p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
-> LinearMap
(Scalar (g p))
(g p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (g p
-> Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
-> LinearFunction
(Scalar (g p))
(g p)
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction (\g p
vg -> VSCCoercion
(Scalar (g p))
(LinearMap
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w))
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
forall s v w.
LinearSpace v =>
VSCCoercion s (LinearMap s v w) (Tensor s (DualVector v) w)
asTensor
VSCCoercion
(Scalar (g p))
(LinearMap
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w))
(Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w))
-> LinearMap
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w)
-> Tensor
(Scalar (g p))
(DualVector w)
(Tensor (Scalar (g p)) ((:*:) f g p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearFunction
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearMap
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w)
forall b c.
(Object (LinearFunction (Scalar (g p))) b,
Object (LinearFunction (Scalar (g p))) c,
Object (LinearMap (Scalar (g p))) b,
Object (LinearMap (Scalar (g p))) c) =>
LinearFunction (Scalar (g p)) b c -> LinearMap (Scalar (g p)) b c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr ((w -> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((w -> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w))
-> (w -> Tensor (Scalar (g p)) ((:*:) f g p) w)
-> LinearFunction
(Scalar (g p)) w (Tensor (Scalar (g p)) ((:*:) f g p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \w
w -> TensorProduct ((:*:) f g p) w
-> Tensor (Scalar (g p)) ((:*:) f g p) w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor (Tensor (Scalar (g p)) (f p) w
forall v. AdditiveGroup v => v
zeroV, g p
vgg p -> w -> Tensor (Scalar (g p)) (g p) w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v,
Num' (Scalar v)) =>
v -> w -> v ⊗ w
⊗w
w))) )
sampleLinearFunction :: forall w.
(TensorSpace w, Scalar ((:*:) f g p) ~ Scalar w) =>
((:*:) f g p -+> w) -+> ((:*:) f g p +> w)
sampleLinearFunction = case ( ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p)
, DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(ScalarSpaceWitness (f p)
ScalarSpaceWitness, DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> (((:*:) f g p -+> w) -> LinearMap (Scalar w) ((:*:) f g p) w)
-> LinearFunction
(Scalar w)
((:*:) f g p -+> w)
(LinearMap (Scalar w) ((:*:) f g p) w)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((((:*:) f g p -+> w) -> LinearMap (Scalar w) ((:*:) f g p) w)
-> LinearFunction
(Scalar w)
((:*:) f g p -+> w)
(LinearMap (Scalar w) ((:*:) f g p) w))
-> (((:*:) f g p -+> w) -> LinearMap (Scalar w) ((:*:) f g p) w)
-> LinearFunction
(Scalar w)
((:*:) f g p -+> w)
(LinearMap (Scalar w) ((:*:) f g p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(:*:) f g p -+> w
f -> TensorProduct (DualVector ((:*:) f g p)) w
-> LinearMap (Scalar w) ((:*:) f g p) w
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap
( LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (f p) w)
(LinearMap (Scalar w) (f p) w)
LinearFunction (Scalar w) (f p) w -+> (f p +> w)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar (f p) ~ Scalar w) =>
(f p -+> w) -+> (f p +> w)
sampleLinearFunction LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (f p) w)
(LinearMap (Scalar w) (f p) w)
-> LinearFunction (Scalar w) (f p) w
-> LinearMap (Scalar w) (f p) w
forall s v w. LinearFunction s v w -> v -> w
-+$> (f p -> w) -> LinearFunction (Scalar w) (f p) w
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction((f p -> w) -> LinearFunction (Scalar w) (f p) w)
-> (f p -> w) -> LinearFunction (Scalar w) (f p) w
forall a. Object (->) a => a -> a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
`id`
\f p
vf -> (:*:) f g p -+> w
f ((:*:) f g p -+> w) -> (:*:) f g p -> w
forall s v w. LinearFunction s v w -> v -> w
-+$> (f p
vff p -> g p -> (:*:) f g p
forall k (f :: k -> Type) (g :: k -> Type) (p :: k).
f p -> g p -> (:*:) f g p
:*:g p
forall v. AdditiveGroup v => v
zeroV)
, LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (g p) w)
(LinearMap (Scalar w) (g p) w)
LinearFunction (Scalar w) (g p) w -+> (g p +> w)
forall v w.
(LinearSpace v, TensorSpace w, Scalar v ~ Scalar w) =>
(v -+> w) -+> (v +> w)
forall w.
(TensorSpace w, Scalar (g p) ~ Scalar w) =>
(g p -+> w) -+> (g p +> w)
sampleLinearFunction LinearFunction
(Scalar w)
(LinearFunction (Scalar w) (g p) w)
(LinearMap (Scalar w) (g p) w)
-> LinearFunction (Scalar w) (g p) w
-> LinearMap (Scalar w) (g p) w
forall s v w. LinearFunction s v w -> v -> w
-+$> (g p -> w) -> LinearFunction (Scalar w) (g p) w
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction((g p -> w) -> LinearFunction (Scalar w) (g p) w)
-> (g p -> w) -> LinearFunction (Scalar w) (g p) w
forall a. Object (->) a => a -> a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
`id`
\g p
vg -> (:*:) f g p -+> w
f ((:*:) f g p -+> w) -> (:*:) f g p -> w
forall s v w. LinearFunction s v w -> v -> w
-+$> (f p
forall v. AdditiveGroup v => v
zeroVf p -> g p -> (:*:) f g p
forall k (f :: k -> Type) (g :: k -> Type) (p :: k).
f p -> g p -> (:*:) f g p
:*:g p
vg) )
applyDualVector :: LinearSpace ((:*:) f g p) =>
Bilinear
(DualVector ((:*:) f g p)) ((:*:) f g p) (Scalar ((:*:) f g p))
applyDualVector = case ( ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p)
, DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(ScalarSpaceWitness (f p)
ScalarSpaceWitness, DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> (GenericTupleDual f g p -> (:*:) f g p -> Scalar (g p))
-> LinearFunction
(Scalar (g p))
(GenericTupleDual f g p)
(LinearFunction (Scalar (g p)) ((:*:) f g p) (Scalar (g p)))
(GenericTupleDual f g p -> (:*:) f g p -> Scalar (g p))
-> Bilinear (GenericTupleDual f g p) ((:*:) f g p) (Scalar (g p))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((GenericTupleDual f g p -> (:*:) f g p -> Scalar (g p))
-> LinearFunction
(Scalar (g p))
(GenericTupleDual f g p)
(LinearFunction (Scalar (g p)) ((:*:) f g p) (Scalar (g p))))
-> (GenericTupleDual f g p -> (:*:) f g p -> Scalar (g p))
-> LinearFunction
(Scalar (g p))
(GenericTupleDual f g p)
(LinearFunction (Scalar (g p)) ((:*:) f g p) (Scalar (g p)))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(GenericTupleDual DualVector (f p)
du DualVector (g p)
dv) (f p
u:*:g p
v)
-> ((LinearFunction
(Scalar (g p))
(DualVector (f p))
(LinearFunction (Scalar (g p)) (f p) (Scalar (g p)))
Bilinear (DualVector (f p)) (f p) (Scalar (f p))
forall v.
(LinearSpace v, LinearSpace v) =>
Bilinear (DualVector v) v (Scalar v)
applyDualVectorLinearFunction
(Scalar (g p))
(DualVector (f p))
(LinearFunction (Scalar (g p)) (f p) (Scalar (g p)))
-> DualVector (f p)
-> LinearFunction (Scalar (g p)) (f p) (Scalar (g p))
forall s v w. LinearFunction s v w -> v -> w
-+$>DualVector (f p)
du)LinearFunction (Scalar (g p)) (f p) (Scalar (g p))
-> f p -> Scalar (g p)
forall s v w. LinearFunction s v w -> v -> w
-+$>f p
u) Scalar (g p) -> Scalar (g p) -> Scalar (g p)
forall v. AdditiveGroup v => v -> v -> v
^+^ ((LinearFunction
(Scalar (g p))
(DualVector (g p))
(LinearFunction (Scalar (g p)) (g p) (Scalar (g p)))
Bilinear (DualVector (g p)) (g p) (Scalar (g p))
forall v.
(LinearSpace v, LinearSpace v) =>
Bilinear (DualVector v) v (Scalar v)
applyDualVectorLinearFunction
(Scalar (g p))
(DualVector (g p))
(LinearFunction (Scalar (g p)) (g p) (Scalar (g p)))
-> DualVector (g p)
-> LinearFunction (Scalar (g p)) (g p) (Scalar (g p))
forall s v w. LinearFunction s v w -> v -> w
-+$>DualVector (g p)
dv)LinearFunction (Scalar (g p)) (g p) (Scalar (g p))
-> g p -> Scalar (g p)
forall s v w. LinearFunction s v w -> v -> w
-+$>g p
v)
applyLinear :: forall w.
(TensorSpace w, Scalar w ~ Scalar ((:*:) f g p)) =>
Bilinear ((:*:) f g p +> w) ((:*:) f g p) w
applyLinear = case ( ScalarSpaceWitness (f p)
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness :: ScalarSpaceWitness (f p)
, DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(ScalarSpaceWitness (f p)
ScalarSpaceWitness, DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> (LinearMap (Scalar (g p)) ((:*:) f g p) w -> (:*:) f g p -> w)
-> LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) ((:*:) f g p) w)
(LinearFunction (Scalar (g p)) ((:*:) f g p) w)
(LinearMap (Scalar (g p)) ((:*:) f g p) w -> (:*:) f g p -> w)
-> Bilinear
(LinearMap (Scalar (g p)) ((:*:) f g p) w) ((:*:) f g p) w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap (Scalar (g p)) ((:*:) f g p) w -> (:*:) f g p -> w)
-> LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) ((:*:) f g p) w)
(LinearFunction (Scalar (g p)) ((:*:) f g p) w))
-> (LinearMap (Scalar (g p)) ((:*:) f g p) w -> (:*:) f g p -> w)
-> LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) ((:*:) f g p) w)
(LinearFunction (Scalar (g p)) ((:*:) f g p) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap (LinearMap (Scalar (g p)) (f p) w
fu, LinearMap (Scalar (g p)) (g p) w
fv)) (f p
u:*:g p
v)
-> ((LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (f p) w)
(LinearFunction (Scalar (g p)) (f p) w)
Bilinear (f p +> w) (f p) w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar (f p)) =>
Bilinear (f p +> w) (f p) w
applyLinearLinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (f p) w)
(LinearFunction (Scalar (g p)) (f p) w)
-> LinearMap (Scalar (g p)) (f p) w
-> LinearFunction (Scalar (g p)) (f p) w
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar (g p)) (f p) w
fu)LinearFunction (Scalar (g p)) (f p) w -> f p -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>f p
u) w -> w -> w
forall v. AdditiveGroup v => v -> v -> v
^+^ ((LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (g p) w)
(LinearFunction (Scalar (g p)) (g p) w)
Bilinear (LinearMap (Scalar (g p)) (g p) w) (g p) w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar (g p)) =>
Bilinear (g p +> w) (g p) w
applyLinearLinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (g p) w)
(LinearFunction (Scalar (g p)) (g p) w)
-> LinearMap (Scalar (g p)) (g p) w
-> LinearFunction (Scalar (g p)) (g p) w
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar (g p)) (g p) w
fv)LinearFunction (Scalar (g p)) (g p) w -> g p -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>g p
v)
composeLinear :: forall w x.
(LinearSpace w, TensorSpace x, Scalar w ~ Scalar ((:*:) f g p),
Scalar x ~ Scalar ((:*:) f g p)) =>
Bilinear (w +> x) ((:*:) f g p +> w) ((:*:) f g p +> x)
composeLinear = case ( DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness)
-> (LinearMap (Scalar (g p)) w x
-> LinearMap (Scalar (g p)) ((:*:) f g p) w
-> LinearMap (Scalar (g p)) ((:*:) f g p) x)
-> LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) ((:*:) f g p) w)
(LinearMap (Scalar (g p)) ((:*:) f g p) x))
(LinearMap (Scalar (g p)) w x
-> LinearMap (Scalar (g p)) ((:*:) f g p) w
-> LinearMap (Scalar (g p)) ((:*:) f g p) x)
-> Bilinear
(LinearMap (Scalar (g p)) w x)
(LinearMap (Scalar (g p)) ((:*:) f g p) w)
(LinearMap (Scalar (g p)) ((:*:) f g p) x)
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap (Scalar (g p)) w x
-> LinearMap (Scalar (g p)) ((:*:) f g p) w
-> LinearMap (Scalar (g p)) ((:*:) f g p) x)
-> LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) ((:*:) f g p) w)
(LinearMap (Scalar (g p)) ((:*:) f g p) x)))
-> (LinearMap (Scalar (g p)) w x
-> LinearMap (Scalar (g p)) ((:*:) f g p) w
-> LinearMap (Scalar (g p)) ((:*:) f g p) x)
-> LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) ((:*:) f g p) w)
(LinearMap (Scalar (g p)) ((:*:) f g p) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \LinearMap (Scalar (g p)) w x
f (LinearMap (LinearMap (Scalar (g p)) (f p) w
fu, LinearMap (Scalar (g p)) (g p) w
fv))
-> TensorProduct (DualVector ((:*:) f g p)) x
-> LinearMap (Scalar (g p)) ((:*:) f g p) x
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap ( (LinearFunction
(Scalar (f p))
(LinearMap (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (f p) w)
(LinearMap (Scalar (g p)) (f p) x))
Bilinear (w +> x) (f p +> w) (f p +> x)
forall v w x.
(LinearSpace v, LinearSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w +> x) (v +> w) (v +> x)
forall w x.
(LinearSpace w, TensorSpace x, Scalar w ~ Scalar (f p),
Scalar x ~ Scalar (f p)) =>
Bilinear (w +> x) (f p +> w) (f p +> x)
composeLinearLinearFunction
(Scalar (f p))
(LinearMap (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (f p) w)
(LinearMap (Scalar (g p)) (f p) x))
-> LinearMap (Scalar (g p)) w x
-> LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (f p) w)
(LinearMap (Scalar (g p)) (f p) x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar (g p)) w x
f)LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (f p) w)
(LinearMap (Scalar (g p)) (f p) x)
-> LinearMap (Scalar (g p)) (f p) w
-> LinearMap (Scalar (g p)) (f p) x
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar (g p)) (f p) w
fu
, (LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (g p) w)
(LinearMap (Scalar (g p)) (g p) x))
Bilinear
(w +> x)
(LinearMap (Scalar (g p)) (g p) w)
(LinearMap (Scalar (g p)) (g p) x)
forall v w x.
(LinearSpace v, LinearSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w +> x) (v +> w) (v +> x)
forall w x.
(LinearSpace w, TensorSpace x, Scalar w ~ Scalar (g p),
Scalar x ~ Scalar (g p)) =>
Bilinear (w +> x) (g p +> w) (g p +> x)
composeLinearLinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) w x)
(LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (g p) w)
(LinearMap (Scalar (g p)) (g p) x))
-> LinearMap (Scalar (g p)) w x
-> LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (g p) w)
(LinearMap (Scalar (g p)) (g p) x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar (g p)) w x
f)LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (g p) w)
(LinearMap (Scalar (g p)) (g p) x)
-> LinearMap (Scalar (g p)) (g p) w
-> LinearMap (Scalar (g p)) (g p) x
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar (g p)) (g p) w
fv )
applyTensorFunctional :: forall u.
(LinearSpace u, Scalar u ~ Scalar ((:*:) f g p)) =>
Bilinear
(DualVector ((:*:) f g p ⊗ u))
((:*:) f g p ⊗ u)
(Scalar ((:*:) f g p))
applyTensorFunctional = case ( DualSpaceWitness (f p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (f p)
, DualSpaceWitness (g p)
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (g p) ) of
(DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness) -> (LinearMap (Scalar (g p)) ((:*:) f g p) (DualVector u)
-> Tensor (Scalar (g p)) ((:*:) f g p) u -> Scalar (g p))
-> LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) ((:*:) f g p) (DualVector u))
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) u)
(Scalar (g p)))
(LinearMap (Scalar (g p)) ((:*:) f g p) (DualVector u)
-> Tensor (Scalar (g p)) ((:*:) f g p) u -> Scalar (g p))
-> Bilinear
(LinearMap (Scalar (g p)) ((:*:) f g p) (DualVector u))
(Tensor (Scalar (g p)) ((:*:) f g p) u)
(Scalar (g p))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap (Scalar (g p)) ((:*:) f g p) (DualVector u)
-> Tensor (Scalar (g p)) ((:*:) f g p) u -> Scalar (g p))
-> LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) ((:*:) f g p) (DualVector u))
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) u)
(Scalar (g p))))
-> (LinearMap (Scalar (g p)) ((:*:) f g p) (DualVector u)
-> Tensor (Scalar (g p)) ((:*:) f g p) u -> Scalar (g p))
-> LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) ((:*:) f g p) (DualVector u))
(LinearFunction
(Scalar (g p))
(Tensor (Scalar (g p)) ((:*:) f g p) u)
(Scalar (g p)))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\(LinearMap (LinearMap (Scalar (g p)) (f p) (DualVector u)
fu,LinearMap (Scalar (g p)) (g p) (DualVector u)
fv)) (Tensor (Tensor (Scalar (g p)) (f p) u
tu,Tensor (Scalar (g p)) (g p) u
tv))
-> ((LinearFunction
(Scalar (f p))
(LinearMap (Scalar (g p)) (f p) (DualVector u))
(LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) (Scalar (g p)))
Bilinear (DualVector (f p ⊗ u)) (f p ⊗ u) (Scalar (f p))
forall u.
(LinearSpace u, Scalar u ~ Scalar (f p)) =>
Bilinear (DualVector (f p ⊗ u)) (f p ⊗ u) (Scalar (f p))
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctionalLinearFunction
(Scalar (f p))
(LinearMap (Scalar (g p)) (f p) (DualVector u))
(LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) (Scalar (g p)))
-> LinearMap (Scalar (g p)) (f p) (DualVector u)
-> LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) (Scalar (g p))
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar (g p)) (f p) (DualVector u)
fu)LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) (Scalar (g p))
-> Tensor (Scalar (g p)) (f p) u -> Scalar (g p)
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (f p) u
tu) Scalar (g p) -> Scalar (g p) -> Scalar (g p)
forall a. Num a => a -> a -> a
+ ((LinearFunction
(Scalar (f p))
(LinearMap (Scalar (g p)) (f p) (DualVector u))
(LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) (Scalar (g p)))
Bilinear (DualVector (f p ⊗ u)) (f p ⊗ u) (Scalar (f p))
forall u.
(LinearSpace u, Scalar u ~ Scalar (f p)) =>
Bilinear (DualVector (f p ⊗ u)) (f p ⊗ u) (Scalar (f p))
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctionalLinearFunction
(Scalar (f p))
(LinearMap (Scalar (g p)) (f p) (DualVector u))
(LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) (Scalar (g p)))
-> LinearMap (Scalar (g p)) (f p) (DualVector u)
-> LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) (Scalar (g p))
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearMap (Scalar (g p)) (f p) (DualVector u)
fu)LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) (Scalar (g p))
-> Tensor (Scalar (g p)) (f p) u -> Scalar (g p)
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (f p) u
tu)
applyTensorLinMap :: ∀ u w . ( LinearSpace u, TensorSpace w
, Scalar u ~ Scalar (g p), Scalar w ~ Scalar (g p) )
=> LinearFunction (Scalar (g p))
(LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w)
(LinearFunction (Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w)
applyTensorLinMap :: forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (g p),
Scalar w ~ Scalar (g p)) =>
LinearFunction
(Scalar (g p))
(LinearMap
(Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w)
(LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w)
applyTensorLinMap = case ( forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @(f p)
, forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @(g p)
, forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @u ) of
(DualSpaceWitness (f p)
DualSpaceWitness, DualSpaceWitness (g p)
DualSpaceWitness, DualSpaceWitness u
DualSpaceWitness) -> (LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w
-> Tensor (Scalar (g p)) ((:*:) f g p) u -> w)
-> LinearFunction
(Scalar (g p))
(LinearMap
(Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w)
(LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w)
(LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w
-> Tensor (Scalar (g p)) ((:*:) f g p) u -> w)
-> Bilinear
(LinearMap
(Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w)
(Tensor (Scalar (g p)) ((:*:) f g p) u)
w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction((LinearMap
(Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w
-> Tensor (Scalar (g p)) ((:*:) f g p) u -> w)
-> LinearFunction
(Scalar (g p))
(LinearMap
(Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w)
(LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w))
-> (LinearMap
(Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w
-> Tensor (Scalar (g p)) ((:*:) f g p) u -> w)
-> LinearFunction
(Scalar (g p))
(LinearMap
(Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w)
(LinearFunction
(Scalar (g p)) (Tensor (Scalar (g p)) ((:*:) f g p) u) w)
forall a. Object (->) a => a -> a
forall κ (k :: κ -> κ -> Type) (a :: κ).
(Category k, Object k a) =>
k a a
`id`
\(LinearMap (LinearMap
(Scalar (g p)) (f p) (Tensor (Scalar (g p)) (DualVector u) w)
fu,LinearMap
(Scalar (g p)) (g p) (Tensor (Scalar (g p)) (DualVector u) w)
fv)) (Tensor (Tensor (Scalar (g p)) (f p) u
tu,Tensor (Scalar (g p)) (g p) u
tv))
-> ((LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) w)
(LinearFunction (Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) w)
Bilinear ((f p ⊗ u) +> w) (f p ⊗ u) w
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (f p),
Scalar w ~ Scalar (f p)) =>
Bilinear ((f p ⊗ u) +> w) (f p ⊗ u) w
applyTensorLinMap LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) w)
(LinearFunction (Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) w)
-> LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) w
-> LinearFunction (Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) w
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
(Scalar (g p))
(LinearMap (Scalar (g p)) (f p) (LinearMap (Scalar (g p)) u w))
(LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) w)
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMap VSCCoercion
(Scalar (g p))
(LinearMap (Scalar (g p)) (f p) (LinearMap (Scalar (g p)) u w))
(LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) w)
-> LinearMap (Scalar (g p)) (f p) (LinearMap (Scalar (g p)) u w)
-> LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=> VSCCoercion
(Scalar (g p))
(Tensor (Scalar (g p)) (DualVector u) w)
(LinearMap (Scalar (g p)) u w)
-> VSCCoercion
(Scalar (g p))
(LinearMap
(Scalar (g p)) (f p) (Tensor (Scalar (g p)) (DualVector u) w))
(LinearMap (Scalar (g p)) (f p) (LinearMap (Scalar (g p)) u w))
forall a b.
(Object (VSCCoercion (Scalar (g p))) a,
Object
(VSCCoercion (Scalar (g p))) (LinearMap (Scalar (g p)) (f p) a),
Object (VSCCoercion (Scalar (g p))) b,
Object
(VSCCoercion (Scalar (g p))) (LinearMap (Scalar (g p)) (f p) b)) =>
VSCCoercion (Scalar (g p)) a b
-> VSCCoercion
(Scalar (g p))
(LinearMap (Scalar (g p)) (f p) a)
(LinearMap (Scalar (g p)) (f p) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion
(Scalar (g p))
(Tensor (Scalar (g p)) (DualVector u) w)
(LinearMap (Scalar (g p)) u w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar (g p))
(LinearMap
(Scalar (g p)) (f p) (Tensor (Scalar (g p)) (DualVector u) w))
(LinearMap (Scalar (g p)) (f p) (LinearMap (Scalar (g p)) u w))
-> LinearMap
(Scalar (g p)) (f p) (Tensor (Scalar (g p)) (DualVector u) w)
-> LinearMap (Scalar (g p)) (f p) (LinearMap (Scalar (g p)) u w)
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearMap
(Scalar (g p)) (f p) (Tensor (Scalar (g p)) (DualVector u) w)
fu)LinearFunction (Scalar (g p)) (Tensor (Scalar (g p)) (f p) u) w
-> Tensor (Scalar (g p)) (f p) u -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (f p) u
tu)
w -> w -> w
forall v. AdditiveGroup v => v -> v -> v
^+^ ((LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (g p) u) w)
(LinearFunction (Scalar (g p)) (Tensor (Scalar (g p)) (g p) u) w)
Bilinear
(Tensor (Scalar (g p)) (g p) u +> w)
(Tensor (Scalar (g p)) (g p) u)
w
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (g p),
Scalar w ~ Scalar (g p)) =>
Bilinear ((g p ⊗ u) +> w) (g p ⊗ u) w
applyTensorLinMap LinearFunction
(Scalar (g p))
(LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (g p) u) w)
(LinearFunction (Scalar (g p)) (Tensor (Scalar (g p)) (g p) u) w)
-> LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (g p) u) w
-> LinearFunction (Scalar (g p)) (Tensor (Scalar (g p)) (g p) u) w
forall s v w. LinearFunction s v w -> v -> w
-+$> VSCCoercion
(Scalar (g p))
(LinearMap (Scalar (g p)) (g p) (LinearMap (Scalar (g p)) u w))
(LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (g p) u) w)
forall u v w s.
(LinearSpace u, LinearSpace v, TensorSpace w, Scalar u ~ s,
Scalar v ~ s, Scalar w ~ s) =>
VSCCoercion
s (LinearMap s u (LinearMap s v w)) (LinearMap s (Tensor s u v) w)
uncurryLinearMap VSCCoercion
(Scalar (g p))
(LinearMap (Scalar (g p)) (g p) (LinearMap (Scalar (g p)) u w))
(LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (g p) u) w)
-> LinearMap (Scalar (g p)) (g p) (LinearMap (Scalar (g p)) u w)
-> LinearMap (Scalar (g p)) (Tensor (Scalar (g p)) (g p) u) w
forall s a b. VSCCoercion s a b -> a -> b
-+$=> VSCCoercion
(Scalar (g p))
(Tensor (Scalar (g p)) (DualVector u) w)
(LinearMap (Scalar (g p)) u w)
-> VSCCoercion
(Scalar (g p))
(LinearMap
(Scalar (g p)) (g p) (Tensor (Scalar (g p)) (DualVector u) w))
(LinearMap (Scalar (g p)) (g p) (LinearMap (Scalar (g p)) u w))
forall a b.
(Object (VSCCoercion (Scalar (g p))) a,
Object
(VSCCoercion (Scalar (g p))) (LinearMap (Scalar (g p)) (g p) a),
Object (VSCCoercion (Scalar (g p))) b,
Object
(VSCCoercion (Scalar (g p))) (LinearMap (Scalar (g p)) (g p) b)) =>
VSCCoercion (Scalar (g p)) a b
-> VSCCoercion
(Scalar (g p))
(LinearMap (Scalar (g p)) (g p) a)
(LinearMap (Scalar (g p)) (g p) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion
(Scalar (g p))
(Tensor (Scalar (g p)) (DualVector u) w)
(LinearMap (Scalar (g p)) u w)
forall s v w.
LinearSpace v =>
VSCCoercion s (Tensor s (DualVector v) w) (LinearMap s v w)
fromTensor VSCCoercion
(Scalar (g p))
(LinearMap
(Scalar (g p)) (g p) (Tensor (Scalar (g p)) (DualVector u) w))
(LinearMap (Scalar (g p)) (g p) (LinearMap (Scalar (g p)) u w))
-> LinearMap
(Scalar (g p)) (g p) (Tensor (Scalar (g p)) (DualVector u) w)
-> LinearMap (Scalar (g p)) (g p) (LinearMap (Scalar (g p)) u w)
forall s a b. VSCCoercion s a b -> a -> b
-+$=> LinearMap
(Scalar (g p)) (g p) (Tensor (Scalar (g p)) (DualVector u) w)
fv)LinearFunction (Scalar (g p)) (Tensor (Scalar (g p)) (g p) u) w
-> Tensor (Scalar (g p)) (g p) u -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>Tensor (Scalar (g p)) (g p) u
tv)
useTupleLinearSpaceComponents :: forall x y φ.
((:*:) f g p ~ (x, y)) =>
((LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ) -> φ
useTupleLinearSpaceComponents (LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ
_ = φ
forall a. a
usingNonTupleTypeAsTupleError
coerceDoubleDual :: VSCCoercion
(Scalar ((:*:) f g p))
((:*:) f g p)
(DualVector (DualVector ((:*:) f g p)))
coerceDoubleDual = case ( forall v.
LinearSpace v =>
VSCCoercion (Scalar v) v (DualVector (DualVector v))
coerceDoubleDual @(f p), forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @(f p)
, forall v.
LinearSpace v =>
VSCCoercion (Scalar v) v (DualVector (DualVector v))
coerceDoubleDual @(g p), forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @(g p)) of
(VSCCoercion (Scalar (g p)) (f p) (DualVector (DualVector (f p)))
VSCCoercion, DualSpaceWitness (f p)
DualSpaceWitness, VSCCoercion (Scalar (g p)) (g p) (DualVector (DualVector (g p)))
VSCCoercion, DualSpaceWitness (g p)
DualSpaceWitness) -> VSCCoercion (Scalar (g p)) ((:*:) f g p) ((:*:) f g p)
VSCCoercion
(Scalar ((:*:) f g p))
((:*:) f g p)
(DualVector (DualVector ((:*:) f g p)))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
instance ( LinearSpace (f p), LinearSpace (g p)
, VectorSpace (DualVector (f p)), VectorSpace (DualVector (g p))
, Scalar (f p) ~ Scalar (DualVector (f p))
, Scalar (g p) ~ Scalar (DualVector (g p))
, Scalar (DualVector (f p)) ~ Scalar (DualVector (g p)) )
=> LinearSpace (GenericTupleDual f g p) where
type DualVector (GenericTupleDual f g p) = (f:*:g) p
coerceDoubleDual :: VSCCoercion
(Scalar (GenericTupleDual f g p))
(GenericTupleDual f g p)
(DualVector (DualVector (GenericTupleDual f g p)))
coerceDoubleDual = case ( forall v.
LinearSpace v =>
VSCCoercion (Scalar v) v (DualVector (DualVector v))
coerceDoubleDual @(f p), forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @(f p)
, forall v.
LinearSpace v =>
VSCCoercion (Scalar v) v (DualVector (DualVector v))
coerceDoubleDual @(g p), forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness @(g p)) of
(VSCCoercion
(Scalar (DualVector (g p))) (f p) (DualVector (DualVector (f p)))
VSCCoercion, DualSpaceWitness (f p)
DualSpaceWitness, VSCCoercion
(Scalar (DualVector (g p))) (g p) (DualVector (DualVector (g p)))
VSCCoercion, DualSpaceWitness (g p)
DualSpaceWitness) -> VSCCoercion
(Scalar (GenericTupleDual f g p))
(GenericTupleDual f g p)
(DualVector (DualVector (GenericTupleDual f g p)))
VSCCoercion
(Scalar (DualVector (g p)))
(GenericTupleDual f g p)
(GenericTupleDual f g p)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
newtype GenericNeedle' m
= GenericNeedle' { forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle' :: DualVector (Needle (VRep m)) }
deriving ((forall x. GenericNeedle' m -> Rep (GenericNeedle' m) x)
-> (forall x. Rep (GenericNeedle' m) x -> GenericNeedle' m)
-> Generic (GenericNeedle' m)
forall x. Rep (GenericNeedle' m) x -> GenericNeedle' m
forall x. GenericNeedle' m -> Rep (GenericNeedle' m) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall m x. Rep (GenericNeedle' m) x -> GenericNeedle' m
forall m x. GenericNeedle' m -> Rep (GenericNeedle' m) x
$cfrom :: forall m x. GenericNeedle' m -> Rep (GenericNeedle' m) x
from :: forall x. GenericNeedle' m -> Rep (GenericNeedle' m) x
$cto :: forall m x. Rep (GenericNeedle' m) x -> GenericNeedle' m
to :: forall x. Rep (GenericNeedle' m) x -> GenericNeedle' m
Generic)
instance AdditiveGroup (DualVector (Needle (VRep m)))
=> AdditiveGroup (GenericNeedle' m)
instance ( VectorSpace (DualVector (Needle (VRep m)))
, Scalar (Needle m) ~ Scalar (DualVector (Needle (VRep m))) )
=> VectorSpace (GenericNeedle' m) where
type Scalar (GenericNeedle' m) = Scalar (Needle m)
instance AdditiveGroup (DualVector (Needle (VRep m)))
=> AffineSpace (GenericNeedle' m) where
type Diff (GenericNeedle' m) = GenericNeedle' m
.-. :: GenericNeedle' m -> GenericNeedle' m -> Diff (GenericNeedle' m)
(.-.) = GenericNeedle' m -> GenericNeedle' m -> Diff (GenericNeedle' m)
GenericNeedle' m -> GenericNeedle' m -> GenericNeedle' m
forall v. AdditiveGroup v => v -> v -> v
(^-^)
.+^ :: GenericNeedle' m -> Diff (GenericNeedle' m) -> GenericNeedle' m
(.+^) = GenericNeedle' m -> Diff (GenericNeedle' m) -> GenericNeedle' m
GenericNeedle' m -> GenericNeedle' m -> GenericNeedle' m
forall v. AdditiveGroup v => v -> v -> v
(^+^)
instance AdditiveGroup (DualVector (Needle (VRep m)))
=> Semimanifold (GenericNeedle' m) where
type Needle (GenericNeedle' m) = GenericNeedle' m
#if !MIN_VERSION_manifolds_core(0,6,0)
type Interior (GenericNeedle' m) = GenericNeedle' m
toInterior = pure
fromInterior = id
translateP = Tagged (^+^)
#endif
.+~^ :: GenericNeedle' m -> Needle (GenericNeedle' m) -> GenericNeedle' m
(.+~^) = GenericNeedle' m -> Needle (GenericNeedle' m) -> GenericNeedle' m
GenericNeedle' m -> GenericNeedle' m -> GenericNeedle' m
forall v. AdditiveGroup v => v -> v -> v
(^+^)
instance AdditiveGroup (DualVector (Needle (VRep m)))
=> PseudoAffine (GenericNeedle' m) where
GenericNeedle' m
p.-~. :: GenericNeedle' m
-> GenericNeedle' m -> Maybe (Needle (GenericNeedle' m))
.-~.GenericNeedle' m
q = GenericNeedle' m -> Maybe (GenericNeedle' m)
forall a. (Object (->) a, Object (->) (Maybe a)) => a -> Maybe a
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a.
(Applicative f r t, Object r a, Object t (f a)) =>
t a (f a)
pure (GenericNeedle' m
pGenericNeedle' m -> GenericNeedle' m -> GenericNeedle' m
forall v. AdditiveGroup v => v -> v -> v
^-^GenericNeedle' m
q)
.-~! :: HasCallStack =>
GenericNeedle' m -> GenericNeedle' m -> Needle (GenericNeedle' m)
(.-~!) = GenericNeedle' m -> GenericNeedle' m -> Needle (GenericNeedle' m)
GenericNeedle' m -> GenericNeedle' m -> GenericNeedle' m
forall v. AdditiveGroup v => v -> v -> v
(^-^)
instance ∀ m . ( Semimanifold m, DimensionAware (DualVector (Needle (VRep m)))
, Scalar (Needle m) ~ Scalar (DualVector (Needle (VRep m))) )
=> DimensionAware (GenericNeedle' m) where
type StaticDimension (GenericNeedle' m)
= StaticDimension (DualVector (Needle (VRep m)))
dimensionalityWitness :: DimensionalityWitness (GenericNeedle' m)
dimensionalityWitness = case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness
@(DualVector (Needle (VRep m))) of
DimensionalityWitness (DualVector (Needle (VRep m)))
IsStaticDimensional -> DimensionalityWitness (GenericNeedle' m)
forall (n :: Nat) v. Dimensional n v => DimensionalityWitness v
IsStaticDimensional
DimensionalityWitness (DualVector (Needle (VRep m)))
IsFlexibleDimensional -> DimensionalityWitness (GenericNeedle' m)
forall v. (StaticDimension v ~ 'Nothing) => DimensionalityWitness v
IsFlexibleDimensional
instance ∀ n m . ( Semimanifold m, n`Dimensional`DualVector (Needle (VRep m))
, Scalar (Needle m) ~ Scalar (DualVector (Needle (VRep m))) )
=> n`Dimensional`GenericNeedle' m where
knownDimensionalitySing :: Sing n
knownDimensionalitySing = forall v (n :: Nat). Dimensional n v => Sing n
dimensionalitySing @(DualVector (Needle (VRep m)))
unsafeFromArrayWithOffset :: forall (α :: Type -> Type).
Vector α (Scalar (GenericNeedle' m)) =>
Int -> α (Scalar (GenericNeedle' m)) -> GenericNeedle' m
unsafeFromArrayWithOffset Int
i α (Scalar (GenericNeedle' m))
ar
= DualVector (Needle (VRep m)) -> GenericNeedle' m
forall a b. Coercible a b => a -> b
coerce (forall (n :: Nat) v (α :: Type -> Type).
(Dimensional n v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v
unsafeFromArrayWithOffset @n @(DualVector (Needle (VRep m))) Int
i α (Scalar (GenericNeedle' m))
α (Scalar (DualVector (Needle (VRep m))))
ar)
unsafeWriteArrayWithOffset :: forall (α :: Type -> Type) σ.
Vector α (Scalar (GenericNeedle' m)) =>
Mutable α σ (Scalar (GenericNeedle' m))
-> Int -> GenericNeedle' m -> ST σ ()
unsafeWriteArrayWithOffset Mutable α σ (Scalar (GenericNeedle' m))
ar
= (Int -> DualVector (Needle (VRep m)) -> ST σ ())
-> Int -> GenericNeedle' m -> ST σ ()
forall a b. Coercible a b => a -> b
coerce (forall (n :: Nat) v (α :: Type -> Type) σ.
(Dimensional n v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> v -> ST σ ()
unsafeWriteArrayWithOffset @n @(DualVector (Needle (VRep m))) Mutable α σ (Scalar (GenericNeedle' m))
Mutable α σ (Scalar (DualVector (Needle (VRep m))))
ar)
instance ∀ m . ( Semimanifold m, TensorSpace (DualVector (Needle (VRep m)))
, Scalar (Needle m) ~ Scalar (DualVector (Needle (VRep m))) )
=> TensorSpace (GenericNeedle' m) where
type TensorProduct (GenericNeedle' m) w
= TensorProduct (DualVector (Needle (VRep m))) w
wellDefinedVector :: GenericNeedle' m -> Maybe (GenericNeedle' m)
wellDefinedVector = (DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> Maybe (DualVector (Needle (VRep m))) -> Maybe (GenericNeedle' m)
forall a b.
(Object (->) a, Object (->) (Maybe a), Object (->) b,
Object (->) (Maybe b)) =>
(a -> b) -> Maybe a -> Maybe b
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle' (Maybe (DualVector (Needle (VRep m))) -> Maybe (GenericNeedle' m))
-> (GenericNeedle' m -> Maybe (DualVector (Needle (VRep m))))
-> GenericNeedle' m
-> Maybe (GenericNeedle' m)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. DualVector (Needle (VRep m))
-> Maybe (DualVector (Needle (VRep m)))
forall v. TensorSpace v => v -> Maybe v
wellDefinedVector (DualVector (Needle (VRep m))
-> Maybe (DualVector (Needle (VRep m))))
-> (GenericNeedle' m -> DualVector (Needle (VRep m)))
-> GenericNeedle' m
-> Maybe (DualVector (Needle (VRep m)))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. GenericNeedle' m -> DualVector (Needle (VRep m))
forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle'
wellDefinedTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle' m)) =>
(GenericNeedle' m ⊗ w) -> Maybe (GenericNeedle' m ⊗ w)
wellDefinedTensor = Coercion
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w))
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
-> Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (Coercion
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Coercion
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w))
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
forall a b.
(Object Coercion a, Object Coercion (Maybe a), Object Coercion b,
Object Coercion (Maybe b)) =>
Coercion a b -> Coercion (Maybe a) (Maybe b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap (Coercion
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Coercion
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w))
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)))
-> (VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Coercion
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Coercion
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w))
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Coercion
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
forall s a b. VSCCoercion s a b -> Coercion a b
getVSCCoercion (VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Coercion
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w))
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)))
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Coercion
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w))
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle')
(Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
-> (Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w))
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
forall w.
(TensorSpace w,
Scalar w ~ Scalar (DualVector (Needle (VRep m)))) =>
(DualVector (Needle (VRep m)) ⊗ w)
-> Maybe (DualVector (Needle (VRep m)) ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> Maybe (v ⊗ w)
wellDefinedTensor (Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w))
-> (Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Maybe
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. ((GenericNeedle' m -> DualVector (Needle (VRep m)))
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle' m -> DualVector (Needle (VRep m))
forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle'VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
scalarSpaceWitness :: ScalarSpaceWitness (GenericNeedle' m)
scalarSpaceWitness = case ScalarSpaceWitness (DualVector (Needle (VRep m)))
forall v. TensorSpace v => ScalarSpaceWitness v
scalarSpaceWitness
:: ScalarSpaceWitness (DualVector (Needle (VRep m))) of
ScalarSpaceWitness (DualVector (Needle (VRep m)))
ScalarSpaceWitness -> ScalarSpaceWitness (GenericNeedle' m)
forall v.
(Num' (Scalar v), Scalar (Scalar v) ~ Scalar v) =>
ScalarSpaceWitness v
ScalarSpaceWitness
linearManifoldWitness :: LinearManifoldWitness (GenericNeedle' m)
linearManifoldWitness = case LinearManifoldWitness (DualVector (Needle (VRep m)))
forall v. TensorSpace v => LinearManifoldWitness v
linearManifoldWitness
:: LinearManifoldWitness (DualVector (Needle (VRep m))) of
LinearManifoldWitness (DualVector (Needle (VRep m)))
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
-> LinearManifoldWitness (GenericNeedle' m)
forall v.
(Needle v ~ v, AffineSpace v, Diff v ~ v) =>
LinearManifoldWitness v
LinearManifoldWitness
#if !MIN_VERSION_manifolds_core(0,6,0)
BoundarylessWitness
#endif
zeroTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle' m)) =>
GenericNeedle' m ⊗ w
zeroTensor = (DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle' VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
forall w.
(TensorSpace w,
Scalar w ~ Scalar (DualVector (Needle (VRep m)))) =>
DualVector (Needle (VRep m)) ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
v ⊗ w
zeroTensor
toFlatTensor :: GenericNeedle' m -+> (GenericNeedle' m ⊗ Scalar (GenericNeedle' m))
toFlatTensor = (GenericNeedle' m
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((GenericNeedle' m
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m))))))
-> (GenericNeedle' m
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ ((DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle'VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m))))
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m))))
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m))))
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
-> (GenericNeedle' m
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m)))))
-> GenericNeedle' m
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m))))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m)))))
-> DualVector (Needle (VRep m))
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m))))
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction DualVector (Needle (VRep m))
-+> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m))))
LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m)))))
forall v. TensorSpace v => v -+> (v ⊗ Scalar v)
toFlatTensor
(DualVector (Needle (VRep m))
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m)))))
-> (GenericNeedle' m -> DualVector (Needle (VRep m)))
-> GenericNeedle' m
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m))))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. GenericNeedle' m -> DualVector (Needle (VRep m))
forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle'
fromFlatTensor :: (GenericNeedle' m ⊗ Scalar (GenericNeedle' m)) -+> GenericNeedle' m
fromFlatTensor = (Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m))))
-> GenericNeedle' m)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
(GenericNeedle' m)
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m))))
-> GenericNeedle' m)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
(GenericNeedle' m))
-> (Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m))))
-> GenericNeedle' m)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
(GenericNeedle' m)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ ((GenericNeedle' m -> DualVector (Needle (VRep m)))
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m)))))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle' m -> DualVector (Needle (VRep m))
forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle'VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m)))))
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m))))
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m))))
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m))))
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m)))))
-> (Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m))))
-> GenericNeedle' m)
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(Scalar (DualVector (Needle (VRep m))))
-> GenericNeedle' m
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m)))))
(DualVector (Needle (VRep m)))
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m))))
-> DualVector (Needle (VRep m))
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m)))))
(DualVector (Needle (VRep m)))
forall v. TensorSpace v => (v ⊗ Scalar v) -+> v
fromFlatTensor
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m))))
-> DualVector (Needle (VRep m)))
-> (DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m))))
-> GenericNeedle' m
forall (k :: Type -> Type -> Type) a b c.
(Category k, Object k a, Object k b, Object k c) =>
k a b -> k b c -> k a c
>>> DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle'
addTensors :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle' m)) =>
(GenericNeedle' m ⊗ w)
-> (GenericNeedle' m ⊗ w) -> GenericNeedle' m ⊗ w
addTensors (Tensor TensorProduct (GenericNeedle' m) w
s) (Tensor TensorProduct (GenericNeedle' m) w
t)
= (DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle' VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
forall w.
(TensorSpace w,
Scalar w ~ Scalar (DualVector (Needle (VRep m)))) =>
(DualVector (Needle (VRep m)) ⊗ w)
-> (DualVector (Needle (VRep m)) ⊗ w)
-> DualVector (Needle (VRep m)) ⊗ w
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
addTensors (TensorProduct (DualVector (Needle (VRep m))) w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (GenericNeedle' m) w
TensorProduct (DualVector (Needle (VRep m))) w
s) (TensorProduct (DualVector (Needle (VRep m))) w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (GenericNeedle' m) w
TensorProduct (DualVector (Needle (VRep m))) w
t)
subtractTensors :: forall w.
(TensorSpace (GenericNeedle' m), TensorSpace w,
Scalar w ~ Scalar (GenericNeedle' m)) =>
(GenericNeedle' m ⊗ w)
-> (GenericNeedle' m ⊗ w) -> GenericNeedle' m ⊗ w
subtractTensors (Tensor TensorProduct (GenericNeedle' m) w
s) (Tensor TensorProduct (GenericNeedle' m) w
t)
= (DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle' VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
forall v w.
(TensorSpace v, TensorSpace v, TensorSpace w,
Scalar w ~ Scalar v) =>
(v ⊗ w) -> (v ⊗ w) -> v ⊗ w
forall w.
(TensorSpace (DualVector (Needle (VRep m))), TensorSpace w,
Scalar w ~ Scalar (DualVector (Needle (VRep m)))) =>
(DualVector (Needle (VRep m)) ⊗ w)
-> (DualVector (Needle (VRep m)) ⊗ w)
-> DualVector (Needle (VRep m)) ⊗ w
subtractTensors (TensorProduct (DualVector (Needle (VRep m))) w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (GenericNeedle' m) w
TensorProduct (DualVector (Needle (VRep m))) w
s) (TensorProduct (DualVector (Needle (VRep m))) w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
forall s v w. TensorProduct v w -> Tensor s v w
Tensor TensorProduct (GenericNeedle' m) w
TensorProduct (DualVector (Needle (VRep m))) w
t)
scaleTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle' m)) =>
Bilinear
(Scalar (GenericNeedle' m))
(GenericNeedle' m ⊗ w)
(GenericNeedle' m ⊗ w)
scaleTensor = (Scalar (DualVector (Needle (VRep m)))
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((Scalar (DualVector (Needle (VRep m)))
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)))
-> (Scalar (DualVector (Needle (VRep m)))
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \Scalar (DualVector (Needle (VRep m)))
μ -> (DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle'
(LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Bilinear
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
forall w.
(TensorSpace w,
Scalar w ~ Scalar (DualVector (Needle (VRep m)))) =>
Bilinear
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)) ⊗ w)
(DualVector (Needle (VRep m)) ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
scaleTensorBilinear
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> Scalar (DualVector (Needle (VRep m)))
-> LinearFunction
(Scalar (Scalar (DualVector (Needle (VRep m)))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
forall s v w. LinearFunction s v w -> v -> w
-+$>Scalar (DualVector (Needle (VRep m)))
μ
negateTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle' m)) =>
(GenericNeedle' m ⊗ w) -+> (GenericNeedle' m ⊗ w)
negateTensor = (DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle' Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-+> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
forall w.
(TensorSpace w,
Scalar w ~ Scalar (DualVector (Needle (VRep m)))) =>
(DualVector (Needle (VRep m)) ⊗ w)
-+> (DualVector (Needle (VRep m)) ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (v ⊗ w)
negateTensor
tensorProduct :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle' m)) =>
Bilinear (GenericNeedle' m) w (GenericNeedle' m ⊗ w)
tensorProduct = (GenericNeedle' m
-> w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Bilinear
(GenericNeedle' m)
w
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(GenericNeedle' m
-> w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
w
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((GenericNeedle' m
-> w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
w
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)))
-> (GenericNeedle' m
-> w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(GenericNeedle' m)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
w
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(GenericNeedle' DualVector (Needle (VRep m))
v) w
w
-> (DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle'
VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Bilinear
(DualVector (Needle (VRep m)))
w
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
forall w.
(TensorSpace w,
Scalar w ~ Scalar (DualVector (Needle (VRep m)))) =>
Bilinear
(DualVector (Needle (VRep m))) w (DualVector (Needle (VRep m)) ⊗ w)
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear v w (v ⊗ w)
tensorProductBilinear
(DualVector (Needle (VRep m)))
w
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> DualVector (Needle (VRep m))
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
w
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
forall s v w. LinearFunction s v w -> v -> w
-+$>DualVector (Needle (VRep m))
v)LinearFunction
(Scalar (DualVector (Needle (VRep m))))
w
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
forall s v w. LinearFunction s v w -> v -> w
-+$>w
w
transposeTensor :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle' m)) =>
(GenericNeedle' m ⊗ w) -+> (w ⊗ GenericNeedle' m)
transposeTensor = (GenericNeedle' m ⊗ w) -+> (w ⊗ GenericNeedle' m)
forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle m)) =>
(GenericNeedle' m ⊗ w) -+> (w ⊗ GenericNeedle' m)
tT
where tT :: ∀ w . (TensorSpace w, Scalar w ~ Scalar (Needle m))
=> (GenericNeedle' m ⊗ w) -+> (w ⊗ GenericNeedle' m)
tT :: forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle m)) =>
(GenericNeedle' m ⊗ w) -+> (w ⊗ GenericNeedle' m)
tT = (Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m))
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction
((Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m))
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m)))
-> (Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m))
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Coercion
(Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m))
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m)))
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m)
forall b c.
(Object Coercion b, Object Coercion c, Object (->) b,
Object (->) c) =>
Coercion b c -> b -> c
forall (a :: Type -> Type -> Type) (k :: Type -> Type -> Type) b c.
(EnhancedCat a k, Object k b, Object k c, Object a b,
Object a c) =>
k b c -> a b c
arr (Coercion
(TensorProduct w (GenericNeedle' m))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m))
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion Coercion
(TensorProduct w (GenericNeedle' m))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m))
-> Coercion
(Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m))))
(TensorProduct w (GenericNeedle' m))
-> Coercion
(Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m))
forall a b c.
(Object Coercion a, Object Coercion b, Object Coercion c) =>
Coercion b c -> Coercion a b -> Coercion a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. [w]
-> VSCCoercion
(Scalar w) (DualVector (Needle (VRep m))) (GenericNeedle' m)
-> Coercion
(TensorProduct w (DualVector (Needle (VRep m))))
(TensorProduct w (GenericNeedle' m))
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a, Scalar a ~ Scalar w, TensorSpace b,
Scalar b ~ Scalar w) =>
p w
-> VSCCoercion (Scalar w) a b
-> Coercion (TensorProduct w a) (TensorProduct w b)
coerceFmapTensorProduct ([]::[w])
(VSCCoercion
(Scalar (Needle m))
(DualVector (Needle (VRep m)))
(GenericNeedle' m)
VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(GenericNeedle' m)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion :: VSCCoercion
(Scalar (Needle m))
(DualVector (Needle (VRep m)))
(GenericNeedle' m))
Coercion
(TensorProduct w (DualVector (Needle (VRep m))))
(TensorProduct w (GenericNeedle' m))
-> Coercion
(Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m))))
(TensorProduct w (DualVector (Needle (VRep m))))
-> Coercion
(Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m))))
(TensorProduct w (GenericNeedle' m))
forall a b c.
(Object Coercion a, Object Coercion b, Object Coercion c) =>
Coercion b c -> Coercion a b -> Coercion a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. Coercion
(Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m))))
(TensorProduct w (DualVector (Needle (VRep m))))
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m)))
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m))
-> (Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m))))
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) w (GenericNeedle' m)
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m))))
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m)))
forall s v w. LinearFunction s v w -> v -> w
getLinearFunction Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-+> (w ⊗ DualVector (Needle (VRep m)))
LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m))))
forall w.
(TensorSpace w,
Scalar w ~ Scalar (DualVector (Needle (VRep m)))) =>
(DualVector (Needle (VRep m)) ⊗ w)
-+> (w ⊗ DualVector (Needle (VRep m)))
forall v w.
(TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) -+> (w ⊗ v)
transposeTensor
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m))))
-> (Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
w
(DualVector (Needle (VRep m)))
forall a b c.
(Object (->) a, Object (->) b, Object (->) c) =>
(b -> c) -> (a -> b) -> a -> c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. ((GenericNeedle' m -> DualVector (Needle (VRep m)))
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle' m -> DualVector (Needle (VRep m))
forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle'VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
forall s a b. VSCCoercion s a b -> a -> b
-+$=>)
fmapTensor :: forall w x.
(TensorSpace w, TensorSpace x,
Scalar w ~ Scalar (GenericNeedle' m),
Scalar x ~ Scalar (GenericNeedle' m)) =>
Bilinear (w -+> x) (GenericNeedle' m ⊗ w) (GenericNeedle' m ⊗ x)
fmapTensor = (LinearFunction (Scalar (DualVector (Needle (VRep m)))) w x
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x))
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) w x)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x))
forall s v w. (v -> w) -> LinearFunction s v w
LinearFunction ((LinearFunction (Scalar (DualVector (Needle (VRep m)))) w x
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x))
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) w x)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)))
-> (LinearFunction (Scalar (DualVector (Needle (VRep m)))) w x
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x))
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) w x)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction (Scalar (DualVector (Needle (VRep m)))) w x
f -> (DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)
forall v w v' w' (c :: Type -> Type -> Type) s' s.
(TensorProduct v w ~ TensorProduct v' w,
TensorProduct v w' ~ TensorProduct v' w') =>
c v v'
-> LinearFunction s' (Tensor s v w) (Tensor s v w')
-> LinearFunction s' (Tensor s v' w) (Tensor s v' w')
envTensorLHSCoercion DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle' (Bilinear
(LinearFunction (Scalar x) w x)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x)
LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) w x)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x))
forall v w x.
(TensorSpace v, TensorSpace w, TensorSpace x, Scalar w ~ Scalar v,
Scalar x ~ Scalar v) =>
Bilinear (w -+> x) (v ⊗ w) (v ⊗ x)
forall w x.
(TensorSpace w, TensorSpace x,
Scalar w ~ Scalar (DualVector (Needle (VRep m))),
Scalar x ~ Scalar (DualVector (Needle (VRep m)))) =>
Bilinear
(w -+> x)
(DualVector (Needle (VRep m)) ⊗ w)
(DualVector (Needle (VRep m)) ⊗ x)
fmapTensorLinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) w x)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x))
-> LinearFunction (Scalar (DualVector (Needle (VRep m)))) w x
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (DualVector (Needle (VRep m)))) w x
f)
fzipTensorWith :: forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (GenericNeedle' m),
Scalar w ~ Scalar (GenericNeedle' m),
Scalar x ~ Scalar (GenericNeedle' m)) =>
Bilinear
((w, x) -+> u)
(GenericNeedle' m ⊗ w, GenericNeedle' m ⊗ x)
(GenericNeedle' m ⊗ u)
fzipTensorWith = (LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u
-> (Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w,
Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) u)
-> Bilinear
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w,
Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) u)
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u
-> (Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w,
Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) u)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w,
Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) u))
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u
-> (Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w,
Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) u)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w,
Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) u)))
-> (LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u
-> (Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w,
Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) u)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w,
Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) u))
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$
\LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u
f (Tensor (Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
wt, Tensor (Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x
xt) -> (DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
u)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle'
VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
u)
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) u)
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
u
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ (Bilinear
(LinearFunction (Scalar u) (w, x) u)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w,
Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
u)
LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w,
Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
u))
forall v u w x.
(TensorSpace v, TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar v, Scalar w ~ Scalar v, Scalar x ~ Scalar v) =>
Bilinear ((w, x) -+> u) (v ⊗ w, v ⊗ x) (v ⊗ u)
forall u w x.
(TensorSpace u, TensorSpace w, TensorSpace x,
Scalar u ~ Scalar (DualVector (Needle (VRep m))),
Scalar w ~ Scalar (DualVector (Needle (VRep m))),
Scalar x ~ Scalar (DualVector (Needle (VRep m)))) =>
Bilinear
((w, x) -+> u)
(DualVector (Needle (VRep m)) ⊗ w,
DualVector (Needle (VRep m)) ⊗ x)
(DualVector (Needle (VRep m)) ⊗ u)
fzipTensorWithLinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u)
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w,
Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
u))
-> LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w,
Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
u)
forall s v w. LinearFunction s v w -> v -> w
-+$>LinearFunction (Scalar (DualVector (Needle (VRep m)))) (w, x) u
f)
LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w,
Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
u)
-> (Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w,
Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x)
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
u
forall s v w. LinearFunction s v w -> v -> w
-+$>( (GenericNeedle' m -> DualVector (Needle (VRep m)))
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle' m -> DualVector (Needle (VRep m))
forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle' VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w)
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
wt
, (GenericNeedle' m -> DualVector (Needle (VRep m)))
-> VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle' m -> DualVector (Needle (VRep m))
forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle' VSCCoercion
(Scalar (DualVector (Needle (VRep m))))
(Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x)
(Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x)
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
x
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor (Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) x
xt )
tensorUnsafeFromArrayWithOffset
:: ∀ w nn α . ( TensorSpace w, nn`Dimensional`w
, Scalar w ~ (Scalar (DualVector (Needle (VRep m))))
, GArr.Vector α (Scalar (DualVector (Needle (VRep m)))) )
=> Int -> α (Scalar (DualVector (Needle (VRep m))))
-> (GenericNeedle' m⊗w)
tensorUnsafeFromArrayWithOffset :: forall w (nn :: Nat) (α :: Type -> Type).
(TensorSpace w, Dimensional nn w,
Scalar w ~ Scalar (DualVector (Needle (VRep m))),
Vector α (Scalar (DualVector (Needle (VRep m))))) =>
Int
-> α (Scalar (DualVector (Needle (VRep m))))
-> GenericNeedle' m ⊗ w
tensorUnsafeFromArrayWithOffset
= case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(DualVector (Needle (VRep m))) of
DimensionalityWitness (DualVector (Needle (VRep m)))
IsFlexibleDimensional -> [Char]
-> Int
-> α (Scalar (DualVector (Needle (VRep m))))
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `Needle (VRep m)` is static-dimensional."
DimensionalityWitness (DualVector (Needle (VRep m)))
IsStaticDimensional -> \Int
i α (Scalar (DualVector (Needle (VRep m))))
ar
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Int -> α (Scalar v) -> v ⊗ w
tensorUnsafeFromArrayWithOffset
@(DualVector (Needle (VRep m))) @w Int
i α (Scalar (DualVector (Needle (VRep m))))
ar)
tensorUnsafeWriteArrayWithOffset
:: ∀ w nn α σ . ( TensorSpace w, nn`Dimensional`w
, Scalar w ~ (Scalar (DualVector (Needle (VRep m))))
, GArr.Vector α (Scalar (DualVector (Needle (VRep m)))) )
=> GArr.Mutable α σ (Scalar (DualVector (Needle (VRep m))))
-> Int -> (GenericNeedle' m⊗w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset :: forall w (nn :: Nat) (α :: Type -> Type) σ.
(TensorSpace w, Dimensional nn w,
Scalar w ~ Scalar (DualVector (Needle (VRep m))),
Vector α (Scalar (DualVector (Needle (VRep m))))) =>
Mutable α σ (Scalar (DualVector (Needle (VRep m))))
-> Int -> (GenericNeedle' m ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset
= case forall v. DimensionAware v => DimensionalityWitness v
dimensionalityWitness @(DualVector (Needle (VRep m))) of
DimensionalityWitness (DualVector (Needle (VRep m)))
IsFlexibleDimensional -> [Char]
-> Mutable α σ (Scalar (DualVector (Needle (VRep m))))
-> Int
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> ST σ ()
forall a. HasCallStack => [Char] -> a
error [Char]
"This is impossible, since this can only be evaluated if `Needle (VRep m)` is static-dimensional."
DimensionalityWitness (DualVector (Needle (VRep m)))
IsStaticDimensional -> \Mutable α σ (Scalar (DualVector (Needle (VRep m))))
ar
-> (Int
-> Tensor
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
w
-> ST σ ())
-> Int
-> Tensor
(Scalar (DualVector (Needle (VRep m)))) (GenericNeedle' m) w
-> ST σ ()
forall a b. Coercible a b => a -> b
coerce (forall v w (α :: Type -> Type) σ (n :: Nat) (m :: Nat).
(TensorSpace v, Dimensional n v, TensorSpace w, Dimensional m w,
Scalar w ~ Scalar v, Vector α (Scalar v)) =>
Mutable α σ (Scalar v) -> Int -> (v ⊗ w) -> ST σ ()
tensorUnsafeWriteArrayWithOffset
@(DualVector (Needle (VRep m))) @w Mutable α σ (Scalar (DualVector (Needle (VRep m))))
ar)
coerceFmapTensorProduct :: ∀ p a b
. ( Hask.Functor p
, TensorSpace a, Scalar a ~ Scalar (DualVector (Needle (VRep m)))
, TensorSpace b, Scalar b ~ Scalar (DualVector (Needle (VRep m))) )
=> p (GenericNeedle' m) -> VSCCoercion (Scalar a) a b
-> Coercion (TensorProduct (GenericNeedle' m) a)
(TensorProduct (GenericNeedle' m) b)
coerceFmapTensorProduct :: forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a,
Scalar a ~ Scalar (DualVector (Needle (VRep m))), TensorSpace b,
Scalar b ~ Scalar (DualVector (Needle (VRep m)))) =>
p (GenericNeedle' m)
-> VSCCoercion (Scalar a) a b
-> Coercion
(TensorProduct (GenericNeedle' m) a)
(TensorProduct (GenericNeedle' m) b)
coerceFmapTensorProduct p (GenericNeedle' m)
p VSCCoercion (Scalar a) a b
crc = case [DualVector (Needle (VRep m))]
-> VSCCoercion (Scalar (DualVector (Needle (VRep m)))) a b
-> Coercion
(TensorProduct (DualVector (Needle (VRep m))) a)
(TensorProduct (DualVector (Needle (VRep m))) b)
forall v (p :: Type -> Type) a b.
(TensorSpace v, Functor p, TensorSpace a, Scalar a ~ Scalar v,
TensorSpace b, Scalar b ~ Scalar v) =>
p v
-> VSCCoercion (Scalar v) a b
-> Coercion (TensorProduct v a) (TensorProduct v b)
forall (p :: Type -> Type) a b.
(Functor p, TensorSpace a,
Scalar a ~ Scalar (DualVector (Needle (VRep m))), TensorSpace b,
Scalar b ~ Scalar (DualVector (Needle (VRep m)))) =>
p (DualVector (Needle (VRep m)))
-> VSCCoercion (Scalar (DualVector (Needle (VRep m)))) a b
-> Coercion
(TensorProduct (DualVector (Needle (VRep m))) a)
(TensorProduct (DualVector (Needle (VRep m))) b)
coerceFmapTensorProduct
([]::[DualVector (Needle (VRep m))]) VSCCoercion (Scalar a) a b
VSCCoercion (Scalar (DualVector (Needle (VRep m)))) a b
crc of
Coercion
(TensorProduct (DualVector (Needle (VRep m))) a)
(TensorProduct (DualVector (Needle (VRep m))) b)
Coercion -> Coercion
(TensorProduct (GenericNeedle' m) a)
(TensorProduct (GenericNeedle' m) b)
Coercion
(TensorProduct (DualVector (Needle (VRep m))) a)
(TensorProduct (DualVector (Needle (VRep m))) b)
forall {k} (a :: k) (b :: k). Coercible a b => Coercion a b
Coercion
instance ∀ s m . ( Num s, Num' s
, Semimanifold m, LinearSpace (Needle (VRep m))
, Scalar (Needle m) ~ s
, Scalar (Needle (VRep m)) ~ s )
=> LinearSpace (GenericNeedle m) where
type DualVector (GenericNeedle m) = GenericNeedle' m
linearId :: GenericNeedle m +> GenericNeedle m
linearId = VSCCoercion s (Needle (VRep m)) (GenericNeedle m)
-> VSCCoercion
s
(LinearMap s (GenericNeedle m) (Needle (VRep m)))
(LinearMap s (GenericNeedle m) (GenericNeedle m))
forall a b.
(Object (VSCCoercion s) a,
Object (VSCCoercion s) (LinearMap s (GenericNeedle m) a),
Object (VSCCoercion s) b,
Object (VSCCoercion s) (LinearMap s (GenericNeedle m) b)) =>
VSCCoercion s a b
-> VSCCoercion
s
(LinearMap s (GenericNeedle m) a)
(LinearMap s (GenericNeedle m) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion s (Needle (VRep m)) (GenericNeedle m)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
VSCCoercion
s
(LinearMap s (GenericNeedle m) (Needle (VRep m)))
(LinearMap s (GenericNeedle m) (GenericNeedle m))
-> VSCCoercion
s
(LinearMap s (Needle (VRep m)) (Needle (VRep m)))
(LinearMap s (GenericNeedle m) (Needle (VRep m)))
-> VSCCoercion
s
(LinearMap s (Needle (VRep m)) (Needle (VRep m)))
(LinearMap s (GenericNeedle m) (GenericNeedle m))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. (GenericNeedle m -> Needle (VRep m))
-> VSCCoercion
s
(LinearMap s (Needle (VRep m)) (Needle (VRep m)))
(LinearMap s (GenericNeedle m) (Needle (VRep m)))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w,
StaticDimension v ~ StaticDimension v') =>
c v' v -> VSCCoercion s (LinearMap s v w) (LinearMap s v' w)
pseudoPrecomposeLinmap GenericNeedle m -> Needle (VRep m)
forall x. GenericNeedle x -> Needle (VRep x)
getGenericNeedle
VSCCoercion
s
(LinearMap s (Needle (VRep m)) (Needle (VRep m)))
(LinearMap s (GenericNeedle m) (GenericNeedle m))
-> LinearMap s (Needle (VRep m)) (Needle (VRep m))
-> LinearMap s (GenericNeedle m) (GenericNeedle m)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap s (Needle (VRep m)) (Needle (VRep m))
Needle (VRep m) +> Needle (VRep m)
forall v. LinearSpace v => LinearMap (Scalar v) v v
linearId
dualSpaceWitness :: DualSpaceWitness (GenericNeedle m)
dualSpaceWitness = case ( ClosedScalarWitness s
forall s. Num' s => ClosedScalarWitness s
closedScalarWitness :: ClosedScalarWitness s
, DualSpaceWitness (Needle (VRep m))
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (Needle (VRep m)) ) of
(ClosedScalarWitness s
ClosedScalarWitness, DualSpaceWitness (Needle (VRep m))
DualSpaceWitness) -> DualSpaceWitness (GenericNeedle m)
forall v.
(LinearSpace (Scalar v), DualVector (Scalar v) ~ Scalar v,
LinearSpace (DualVector v), Scalar (DualVector v) ~ Scalar v,
DualVector (DualVector v) ~ v,
StaticDimension (DualVector v) ~ StaticDimension v) =>
DualSpaceWitness v
DualSpaceWitness
applyDualVector :: LinearSpace (GenericNeedle m) =>
Bilinear
(DualVector (GenericNeedle m))
(GenericNeedle m)
(Scalar (GenericNeedle m))
applyDualVector = (GenericNeedle' m -> GenericNeedle m -> s)
-> LinearFunction
s (GenericNeedle' m) (LinearFunction s (GenericNeedle m) s)
(GenericNeedle' m -> GenericNeedle m -> s)
-> Bilinear (GenericNeedle' m) (GenericNeedle m) s
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((GenericNeedle' m -> GenericNeedle m -> s)
-> LinearFunction
s (GenericNeedle' m) (LinearFunction s (GenericNeedle m) s))
-> (GenericNeedle' m -> GenericNeedle m -> s)
-> LinearFunction
s (GenericNeedle' m) (LinearFunction s (GenericNeedle m) s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(GenericNeedle' DualVector (Needle (VRep m))
dv) (GenericNeedle Needle (VRep m)
v)
-> (LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(LinearFunction
(Scalar (DualVector (Needle (VRep m)))) (Needle (VRep m)) s)
Bilinear
(DualVector (Needle (VRep m)))
(Needle (VRep m))
(Scalar (Needle (VRep m)))
forall v.
(LinearSpace v, LinearSpace v) =>
Bilinear (DualVector v) v (Scalar v)
applyDualVectorLinearFunction
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(LinearFunction
(Scalar (DualVector (Needle (VRep m)))) (Needle (VRep m)) s)
-> DualVector (Needle (VRep m))
-> LinearFunction
(Scalar (DualVector (Needle (VRep m)))) (Needle (VRep m)) s
forall s v w. LinearFunction s v w -> v -> w
-+$>DualVector (Needle (VRep m))
dv)LinearFunction
(Scalar (DualVector (Needle (VRep m)))) (Needle (VRep m)) s
-> Needle (VRep m) -> s
forall s v w. LinearFunction s v w -> v -> w
-+$>Needle (VRep m)
v
applyLinear :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) =>
Bilinear (GenericNeedle m +> w) (GenericNeedle m) w
applyLinear = (LinearMap s (GenericNeedle m) w -> GenericNeedle m -> w)
-> LinearFunction
s
(LinearMap s (GenericNeedle m) w)
(LinearFunction s (GenericNeedle m) w)
(LinearMap s (GenericNeedle m) w -> GenericNeedle m -> w)
-> Bilinear (LinearMap s (GenericNeedle m) w) (GenericNeedle m) w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s (GenericNeedle m) w -> GenericNeedle m -> w)
-> LinearFunction
s
(LinearMap s (GenericNeedle m) w)
(LinearFunction s (GenericNeedle m) w))
-> (LinearMap s (GenericNeedle m) w -> GenericNeedle m -> w)
-> LinearFunction
s
(LinearMap s (GenericNeedle m) w)
(LinearFunction s (GenericNeedle m) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (GenericNeedle m)) w
f) (GenericNeedle Needle (VRep m)
v)
-> (LinearFunction
s
(LinearMap s (Needle (VRep m)) w)
(LinearFunction s (Needle (VRep m)) w)
Bilinear (Needle (VRep m) +> w) (Needle (VRep m)) w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w, Scalar w ~ Scalar (Needle (VRep m))) =>
Bilinear (Needle (VRep m) +> w) (Needle (VRep m)) w
applyLinearLinearFunction
s
(LinearMap s (Needle (VRep m)) w)
(LinearFunction s (Needle (VRep m)) w)
-> LinearMap s (Needle (VRep m)) w
-> LinearFunction s (Needle (VRep m)) w
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct (DualVector (Needle (VRep m))) w
-> LinearMap s (Needle (VRep m)) w
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector (GenericNeedle m)) w
TensorProduct (DualVector (Needle (VRep m))) w
f)LinearFunction s (Needle (VRep m)) w -> Needle (VRep m) -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>Needle (VRep m)
v
tensorId :: forall w.
(LinearSpace w, Scalar w ~ Scalar (GenericNeedle m)) =>
(GenericNeedle m ⊗ w) +> (GenericNeedle m ⊗ w)
tensorId = VSCCoercion
s (Tensor s (GenericNeedle m) w) (Tensor s (Needle (VRep m)) w)
-> VSCCoercion
s
(LinearMap
s (Tensor s (Needle (VRep m)) w) (Tensor s (GenericNeedle m) w))
(LinearMap
s (Tensor s (GenericNeedle m) w) (Tensor s (GenericNeedle m) w))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w,
StaticDimension v ~ StaticDimension v') =>
c v' v -> VSCCoercion s (LinearMap s v w) (LinearMap s v' w)
pseudoPrecomposeLinmap ((GenericNeedle m -> Needle (VRep m))
-> VSCCoercion
s (Tensor s (GenericNeedle m) w) (Tensor s (Needle (VRep m)) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle m -> Needle (VRep m)
forall x. GenericNeedle x -> Needle (VRep x)
getGenericNeedle)
VSCCoercion
s
(LinearMap
s (Tensor s (Needle (VRep m)) w) (Tensor s (GenericNeedle m) w))
(LinearMap
s (Tensor s (GenericNeedle m) w) (Tensor s (GenericNeedle m) w))
-> VSCCoercion
s
(LinearMap
s (Tensor s (Needle (VRep m)) w) (Tensor s (Needle (VRep m)) w))
(LinearMap
s (Tensor s (Needle (VRep m)) w) (Tensor s (GenericNeedle m) w))
-> VSCCoercion
s
(LinearMap
s (Tensor s (Needle (VRep m)) w) (Tensor s (Needle (VRep m)) w))
(LinearMap
s (Tensor s (GenericNeedle m) w) (Tensor s (GenericNeedle m) w))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s (Tensor s (Needle (VRep m)) w) (Tensor s (GenericNeedle m) w)
-> VSCCoercion
s
(LinearMap
s (Tensor s (Needle (VRep m)) w) (Tensor s (Needle (VRep m)) w))
(LinearMap
s (Tensor s (Needle (VRep m)) w) (Tensor s (GenericNeedle m) w))
forall a b.
(Object (VSCCoercion s) a,
Object
(VSCCoercion s) (LinearMap s (Tensor s (Needle (VRep m)) w) a),
Object (VSCCoercion s) b,
Object
(VSCCoercion s) (LinearMap s (Tensor s (Needle (VRep m)) w) b)) =>
VSCCoercion s a b
-> VSCCoercion
s
(LinearMap s (Tensor s (Needle (VRep m)) w) a)
(LinearMap s (Tensor s (Needle (VRep m)) w) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap ((Needle (VRep m) -> GenericNeedle m)
-> VSCCoercion
s (Tensor s (Needle (VRep m)) w) (Tensor s (GenericNeedle m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS Needle (VRep m) -> GenericNeedle m
forall x. Needle (VRep x) -> GenericNeedle x
GenericNeedle) VSCCoercion
s
(LinearMap
s (Tensor s (Needle (VRep m)) w) (Tensor s (Needle (VRep m)) w))
(LinearMap
s (Tensor s (GenericNeedle m) w) (Tensor s (GenericNeedle m) w))
-> LinearMap
s (Tensor s (Needle (VRep m)) w) (Tensor s (Needle (VRep m)) w)
-> LinearMap
s (Tensor s (GenericNeedle m) w) (Tensor s (GenericNeedle m) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap
s (Tensor s (Needle (VRep m)) w) (Tensor s (Needle (VRep m)) w)
(Needle (VRep m) ⊗ w) +> (Needle (VRep m) ⊗ w)
forall w.
(LinearSpace w, Scalar w ~ Scalar (Needle (VRep m))) =>
(Needle (VRep m) ⊗ w) +> (Needle (VRep m) ⊗ w)
forall v w.
(LinearSpace v, LinearSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) +> (v ⊗ w)
tensorId
applyTensorFunctional :: forall u.
(LinearSpace u, Scalar u ~ Scalar (GenericNeedle m)) =>
Bilinear
(DualVector (GenericNeedle m ⊗ u))
(GenericNeedle m ⊗ u)
(Scalar (GenericNeedle m))
applyTensorFunctional = (LinearMap s (GenericNeedle m) (DualVector u)
-> Tensor s (GenericNeedle m) u -> s)
-> LinearFunction
s
(LinearMap s (GenericNeedle m) (DualVector u))
(LinearFunction s (Tensor s (GenericNeedle m) u) s)
(LinearMap s (GenericNeedle m) (DualVector u)
-> Tensor s (GenericNeedle m) u -> s)
-> Bilinear
(LinearMap s (GenericNeedle m) (DualVector u))
(Tensor s (GenericNeedle m) u)
s
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s (GenericNeedle m) (DualVector u)
-> Tensor s (GenericNeedle m) u -> s)
-> LinearFunction
s
(LinearMap s (GenericNeedle m) (DualVector u))
(LinearFunction s (Tensor s (GenericNeedle m) u) s))
-> (LinearMap s (GenericNeedle m) (DualVector u)
-> Tensor s (GenericNeedle m) u -> s)
-> LinearFunction
s
(LinearMap s (GenericNeedle m) (DualVector u))
(LinearFunction s (Tensor s (GenericNeedle m) u) s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (GenericNeedle m)) (DualVector u)
f) Tensor s (GenericNeedle m) u
t ->
(LinearFunction
(Scalar (Needle (VRep m)))
(LinearMap
(Scalar (Needle (VRep m))) (Needle (VRep m)) (DualVector u))
(LinearFunction
(Scalar (Needle (VRep m))) (Tensor s (Needle (VRep m)) u) s)
Bilinear
(DualVector (Needle (VRep m) ⊗ u))
(Needle (VRep m) ⊗ u)
(Scalar (Needle (VRep m)))
forall u.
(LinearSpace u, Scalar u ~ Scalar (Needle (VRep m))) =>
Bilinear
(DualVector (Needle (VRep m) ⊗ u))
(Needle (VRep m) ⊗ u)
(Scalar (Needle (VRep m)))
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctionalLinearFunction
(Scalar (Needle (VRep m)))
(LinearMap
(Scalar (Needle (VRep m))) (Needle (VRep m)) (DualVector u))
(LinearFunction
(Scalar (Needle (VRep m))) (Tensor s (Needle (VRep m)) u) s)
-> LinearMap
(Scalar (Needle (VRep m))) (Needle (VRep m)) (DualVector u)
-> LinearFunction
(Scalar (Needle (VRep m))) (Tensor s (Needle (VRep m)) u) s
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct (DualVector (Needle (VRep m))) (DualVector u)
-> LinearMap
(Scalar (Needle (VRep m))) (Needle (VRep m)) (DualVector u)
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector (GenericNeedle m)) (DualVector u)
TensorProduct (DualVector (Needle (VRep m))) (DualVector u)
f)
LinearFunction
(Scalar (Needle (VRep m))) (Tensor s (Needle (VRep m)) u) s
-> Tensor s (Needle (VRep m)) u -> s
forall s v w. LinearFunction s v w -> v -> w
-+$>(GenericNeedle m -> Needle (VRep m))
-> VSCCoercion
s (Tensor s (GenericNeedle m) u) (Tensor s (Needle (VRep m)) u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle m -> Needle (VRep m)
forall x. GenericNeedle x -> Needle (VRep x)
getGenericNeedle VSCCoercion
s (Tensor s (GenericNeedle m) u) (Tensor s (Needle (VRep m)) u)
-> Tensor s (GenericNeedle m) u -> Tensor s (Needle (VRep m)) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor s (GenericNeedle m) u
t
applyTensorLinMap :: forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (GenericNeedle m),
Scalar w ~ Scalar (GenericNeedle m)) =>
Bilinear ((GenericNeedle m ⊗ u) +> w) (GenericNeedle m ⊗ u) w
applyTensorLinMap = (LinearMap s (Tensor s (GenericNeedle m) u) w
-> Tensor s (GenericNeedle m) u -> w)
-> LinearFunction
s
(LinearMap s (Tensor s (GenericNeedle m) u) w)
(LinearFunction s (Tensor s (GenericNeedle m) u) w)
(LinearMap s (Tensor s (GenericNeedle m) u) w
-> Tensor s (GenericNeedle m) u -> w)
-> Bilinear
(LinearMap s (Tensor s (GenericNeedle m) u) w)
(Tensor s (GenericNeedle m) u)
w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s (Tensor s (GenericNeedle m) u) w
-> Tensor s (GenericNeedle m) u -> w)
-> LinearFunction
s
(LinearMap s (Tensor s (GenericNeedle m) u) w)
(LinearFunction s (Tensor s (GenericNeedle m) u) w))
-> (LinearMap s (Tensor s (GenericNeedle m) u) w
-> Tensor s (GenericNeedle m) u -> w)
-> LinearFunction
s
(LinearMap s (Tensor s (GenericNeedle m) u) w)
(LinearFunction s (Tensor s (GenericNeedle m) u) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (Tensor s (GenericNeedle m) u)) w
f) Tensor s (GenericNeedle m) u
t
-> (LinearFunction
s
(LinearMap s (Tensor s (Needle (VRep m)) u) w)
(LinearFunction s (Tensor s (Needle (VRep m)) u) w)
Bilinear ((Needle (VRep m) ⊗ u) +> w) (Needle (VRep m) ⊗ u) w
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w, Scalar u ~ Scalar (Needle (VRep m)),
Scalar w ~ Scalar (Needle (VRep m))) =>
Bilinear ((Needle (VRep m) ⊗ u) +> w) (Needle (VRep m) ⊗ u) w
applyTensorLinMapLinearFunction
s
(LinearMap s (Tensor s (Needle (VRep m)) u) w)
(LinearFunction s (Tensor s (Needle (VRep m)) u) w)
-> LinearMap s (Tensor s (Needle (VRep m)) u) w
-> LinearFunction s (Tensor s (Needle (VRep m)) u) w
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct (DualVector (Tensor s (Needle (VRep m)) u)) w
-> LinearMap s (Tensor s (Needle (VRep m)) u) w
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector (Tensor s (GenericNeedle m) u)) w
TensorProduct (DualVector (Tensor s (Needle (VRep m)) u)) w
f)
LinearFunction s (Tensor s (Needle (VRep m)) u) w
-> Tensor s (Needle (VRep m)) u -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>(GenericNeedle m -> Needle (VRep m))
-> VSCCoercion
s (Tensor s (GenericNeedle m) u) (Tensor s (Needle (VRep m)) u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle m -> Needle (VRep m)
forall x. GenericNeedle x -> Needle (VRep x)
getGenericNeedle VSCCoercion
s (Tensor s (GenericNeedle m) u) (Tensor s (Needle (VRep m)) u)
-> Tensor s (GenericNeedle m) u -> Tensor s (Needle (VRep m)) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor s (GenericNeedle m) u
t
useTupleLinearSpaceComponents :: forall x y φ.
(GenericNeedle m ~ (x, y)) =>
((LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ) -> φ
useTupleLinearSpaceComponents (LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ
_ = φ
forall a. a
usingNonTupleTypeAsTupleError
coerceDoubleDual :: VSCCoercion
(Scalar (GenericNeedle m))
(GenericNeedle m)
(DualVector (DualVector (GenericNeedle m)))
coerceDoubleDual = case forall v.
LinearSpace v =>
VSCCoercion (Scalar v) v (DualVector (DualVector v))
coerceDoubleDual @(Needle (VRep m)) of
VSCCoercion
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(DualVector (DualVector (Needle (VRep m))))
VSCCoercion -> VSCCoercion s (GenericNeedle m) (GenericNeedle m)
VSCCoercion
(Scalar (GenericNeedle m))
(GenericNeedle m)
(DualVector (DualVector (GenericNeedle m)))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
instance ∀ s m . ( Num s, Num' s
, Semimanifold m
, LinearSpace (Needle (VRep m))
, TensorSpace (DualVector (Needle (VRep m)))
, Scalar (Needle m) ~ s
, Scalar (Needle (VRep m)) ~ s
, Scalar (DualVector (Needle (VRep m))) ~ s )
=> LinearSpace (GenericNeedle' m) where
type DualVector (GenericNeedle' m) = GenericNeedle m
linearId :: GenericNeedle' m +> GenericNeedle' m
linearId = case DualSpaceWitness (Needle (VRep m))
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (Needle (VRep m)) of
DualSpaceWitness (Needle (VRep m))
DualSpaceWitness -> VSCCoercion s (DualVector (Needle (VRep m))) (GenericNeedle' m)
-> VSCCoercion
s
(LinearMap s (GenericNeedle' m) (DualVector (Needle (VRep m))))
(LinearMap s (GenericNeedle' m) (GenericNeedle' m))
forall a b.
(Object (VSCCoercion s) a,
Object (VSCCoercion s) (LinearMap s (GenericNeedle' m) a),
Object (VSCCoercion s) b,
Object (VSCCoercion s) (LinearMap s (GenericNeedle' m) b)) =>
VSCCoercion s a b
-> VSCCoercion
s
(LinearMap s (GenericNeedle' m) a)
(LinearMap s (GenericNeedle' m) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap VSCCoercion s (DualVector (Needle (VRep m))) (GenericNeedle' m)
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion
VSCCoercion
s
(LinearMap s (GenericNeedle' m) (DualVector (Needle (VRep m))))
(LinearMap s (GenericNeedle' m) (GenericNeedle' m))
-> VSCCoercion
s
(LinearMap
s (DualVector (Needle (VRep m))) (DualVector (Needle (VRep m))))
(LinearMap s (GenericNeedle' m) (DualVector (Needle (VRep m))))
-> VSCCoercion
s
(LinearMap
s (DualVector (Needle (VRep m))) (DualVector (Needle (VRep m))))
(LinearMap s (GenericNeedle' m) (GenericNeedle' m))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. (GenericNeedle' m -> DualVector (Needle (VRep m)))
-> VSCCoercion
s
(LinearMap
s (DualVector (Needle (VRep m))) (DualVector (Needle (VRep m))))
(LinearMap s (GenericNeedle' m) (DualVector (Needle (VRep m))))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w,
StaticDimension v ~ StaticDimension v') =>
c v' v -> VSCCoercion s (LinearMap s v w) (LinearMap s v' w)
pseudoPrecomposeLinmap GenericNeedle' m -> DualVector (Needle (VRep m))
forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle' VSCCoercion
s
(LinearMap
s (DualVector (Needle (VRep m))) (DualVector (Needle (VRep m))))
(LinearMap s (GenericNeedle' m) (GenericNeedle' m))
-> LinearMap
s (DualVector (Needle (VRep m))) (DualVector (Needle (VRep m)))
-> LinearMap s (GenericNeedle' m) (GenericNeedle' m)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap
s (DualVector (Needle (VRep m))) (DualVector (Needle (VRep m)))
DualVector (Needle (VRep m)) +> DualVector (Needle (VRep m))
forall v. LinearSpace v => LinearMap (Scalar v) v v
linearId
dualSpaceWitness :: DualSpaceWitness (GenericNeedle' m)
dualSpaceWitness = case ( ClosedScalarWitness s
forall s. Num' s => ClosedScalarWitness s
closedScalarWitness :: ClosedScalarWitness s
, DualSpaceWitness (Needle (VRep m))
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (Needle (VRep m)) ) of
(ClosedScalarWitness s
ClosedScalarWitness, DualSpaceWitness (Needle (VRep m))
DualSpaceWitness) -> DualSpaceWitness (GenericNeedle' m)
forall v.
(LinearSpace (Scalar v), DualVector (Scalar v) ~ Scalar v,
LinearSpace (DualVector v), Scalar (DualVector v) ~ Scalar v,
DualVector (DualVector v) ~ v,
StaticDimension (DualVector v) ~ StaticDimension v) =>
DualSpaceWitness v
DualSpaceWitness
applyDualVector :: LinearSpace (GenericNeedle' m) =>
Bilinear
(DualVector (GenericNeedle' m))
(GenericNeedle' m)
(Scalar (GenericNeedle' m))
applyDualVector = case DualSpaceWitness (Needle (VRep m))
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (Needle (VRep m)) of
DualSpaceWitness (Needle (VRep m))
DualSpaceWitness -> (GenericNeedle m -> GenericNeedle' m -> s)
-> LinearFunction
s (GenericNeedle m) (LinearFunction s (GenericNeedle' m) s)
(GenericNeedle m -> GenericNeedle' m -> s)
-> Bilinear (GenericNeedle m) (GenericNeedle' m) s
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((GenericNeedle m -> GenericNeedle' m -> s)
-> LinearFunction
s (GenericNeedle m) (LinearFunction s (GenericNeedle' m) s))
-> (GenericNeedle m -> GenericNeedle' m -> s)
-> LinearFunction
s (GenericNeedle m) (LinearFunction s (GenericNeedle' m) s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(GenericNeedle Needle (VRep m)
dv) (GenericNeedle' DualVector (Needle (VRep m))
v)
-> (LinearFunction
(Scalar (DualVector (DualVector (Needle (VRep m)))))
(DualVector (DualVector (Needle (VRep m))))
(LinearFunction
(Scalar (DualVector (DualVector (Needle (VRep m)))))
(DualVector (Needle (VRep m)))
s)
Bilinear
(DualVector (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(Scalar (DualVector (Needle (VRep m))))
forall v.
(LinearSpace v, LinearSpace v) =>
Bilinear (DualVector v) v (Scalar v)
applyDualVectorLinearFunction
(Scalar (DualVector (DualVector (Needle (VRep m)))))
(DualVector (DualVector (Needle (VRep m))))
(LinearFunction
(Scalar (DualVector (DualVector (Needle (VRep m)))))
(DualVector (Needle (VRep m)))
s)
-> DualVector (DualVector (Needle (VRep m)))
-> LinearFunction
(Scalar (DualVector (DualVector (Needle (VRep m)))))
(DualVector (Needle (VRep m)))
s
forall s v w. LinearFunction s v w -> v -> w
-+$>Needle (VRep m)
DualVector (DualVector (Needle (VRep m)))
dv)LinearFunction
(Scalar (DualVector (DualVector (Needle (VRep m)))))
(DualVector (Needle (VRep m)))
s
-> DualVector (Needle (VRep m)) -> s
forall s v w. LinearFunction s v w -> v -> w
-+$>DualVector (Needle (VRep m))
v
applyLinear :: forall w.
(TensorSpace w, Scalar w ~ Scalar (GenericNeedle' m)) =>
Bilinear (GenericNeedle' m +> w) (GenericNeedle' m) w
applyLinear = case DualSpaceWitness (Needle (VRep m))
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (Needle (VRep m)) of
DualSpaceWitness (Needle (VRep m))
DualSpaceWitness -> (LinearMap s (GenericNeedle' m) w -> GenericNeedle' m -> w)
-> LinearFunction
s
(LinearMap s (GenericNeedle' m) w)
(LinearFunction s (GenericNeedle' m) w)
(LinearMap s (GenericNeedle' m) w -> GenericNeedle' m -> w)
-> Bilinear (LinearMap s (GenericNeedle' m) w) (GenericNeedle' m) w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s (GenericNeedle' m) w -> GenericNeedle' m -> w)
-> LinearFunction
s
(LinearMap s (GenericNeedle' m) w)
(LinearFunction s (GenericNeedle' m) w))
-> (LinearMap s (GenericNeedle' m) w -> GenericNeedle' m -> w)
-> LinearFunction
s
(LinearMap s (GenericNeedle' m) w)
(LinearFunction s (GenericNeedle' m) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (GenericNeedle' m)) w
f) (GenericNeedle' DualVector (Needle (VRep m))
v)
-> (LinearFunction
s
(LinearMap s (DualVector (Needle (VRep m))) w)
(LinearFunction s (DualVector (Needle (VRep m))) w)
Bilinear
(DualVector (Needle (VRep m)) +> w)
(DualVector (Needle (VRep m)))
w
forall v w.
(LinearSpace v, TensorSpace w, Scalar w ~ Scalar v) =>
Bilinear (v +> w) v w
forall w.
(TensorSpace w,
Scalar w ~ Scalar (DualVector (Needle (VRep m)))) =>
Bilinear
(DualVector (Needle (VRep m)) +> w)
(DualVector (Needle (VRep m)))
w
applyLinearLinearFunction
s
(LinearMap s (DualVector (Needle (VRep m))) w)
(LinearFunction s (DualVector (Needle (VRep m))) w)
-> LinearMap s (DualVector (Needle (VRep m))) w
-> LinearFunction s (DualVector (Needle (VRep m))) w
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct (DualVector (DualVector (Needle (VRep m)))) w
-> LinearMap s (DualVector (Needle (VRep m))) w
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector (GenericNeedle' m)) w
TensorProduct (DualVector (DualVector (Needle (VRep m)))) w
f)LinearFunction s (DualVector (Needle (VRep m))) w
-> DualVector (Needle (VRep m)) -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>DualVector (Needle (VRep m))
v
tensorId :: forall w.
(LinearSpace w, Scalar w ~ Scalar (GenericNeedle' m)) =>
(GenericNeedle' m ⊗ w) +> (GenericNeedle' m ⊗ w)
tensorId = case DualSpaceWitness (Needle (VRep m))
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (Needle (VRep m)) of
DualSpaceWitness (Needle (VRep m))
DualSpaceWitness -> VSCCoercion
s
(Tensor s (GenericNeedle' m) w)
(Tensor s (DualVector (Needle (VRep m))) w)
-> VSCCoercion
s
(LinearMap
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (GenericNeedle' m) w))
(LinearMap
s (Tensor s (GenericNeedle' m) w) (Tensor s (GenericNeedle' m) w))
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct (DualVector v) w ~ TensorProduct (DualVector v') w,
StaticDimension v ~ StaticDimension v') =>
c v' v -> VSCCoercion s (LinearMap s v w) (LinearMap s v' w)
pseudoPrecomposeLinmap ((GenericNeedle' m -> DualVector (Needle (VRep m)))
-> VSCCoercion
s
(Tensor s (GenericNeedle' m) w)
(Tensor s (DualVector (Needle (VRep m))) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle' m -> DualVector (Needle (VRep m))
forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle')
VSCCoercion
s
(LinearMap
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (GenericNeedle' m) w))
(LinearMap
s (Tensor s (GenericNeedle' m) w) (Tensor s (GenericNeedle' m) w))
-> VSCCoercion
s
(LinearMap
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (DualVector (Needle (VRep m))) w))
(LinearMap
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (GenericNeedle' m) w))
-> VSCCoercion
s
(LinearMap
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (DualVector (Needle (VRep m))) w))
(LinearMap
s (Tensor s (GenericNeedle' m) w) (Tensor s (GenericNeedle' m) w))
forall a b c.
(Object (VSCCoercion s) a, Object (VSCCoercion s) b,
Object (VSCCoercion s) c) =>
VSCCoercion s b c -> VSCCoercion s a b -> VSCCoercion s a c
forall κ (k :: κ -> κ -> Type) (a :: κ) (b :: κ) (c :: κ).
(Category k, Object k a, Object k b, Object k c) =>
k b c -> k a b -> k a c
. VSCCoercion
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (GenericNeedle' m) w)
-> VSCCoercion
s
(LinearMap
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (DualVector (Needle (VRep m))) w))
(LinearMap
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (GenericNeedle' m) w))
forall a b.
(Object (VSCCoercion s) a,
Object
(VSCCoercion s)
(LinearMap s (Tensor s (DualVector (Needle (VRep m))) w) a),
Object (VSCCoercion s) b,
Object
(VSCCoercion s)
(LinearMap s (Tensor s (DualVector (Needle (VRep m))) w) b)) =>
VSCCoercion s a b
-> VSCCoercion
s
(LinearMap s (Tensor s (DualVector (Needle (VRep m))) w) a)
(LinearMap s (Tensor s (DualVector (Needle (VRep m))) w) b)
forall (f :: Type -> Type) (r :: Type -> Type -> Type)
(t :: Type -> Type -> Type) a b.
(Functor f r t, Object r a, Object t (f a), Object r b,
Object t (f b)) =>
r a b -> t (f a) (f b)
fmap ((DualVector (Needle (VRep m)) -> GenericNeedle' m)
-> VSCCoercion
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (GenericNeedle' m) w)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS DualVector (Needle (VRep m)) -> GenericNeedle' m
forall m. DualVector (Needle (VRep m)) -> GenericNeedle' m
GenericNeedle') VSCCoercion
s
(LinearMap
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (DualVector (Needle (VRep m))) w))
(LinearMap
s (Tensor s (GenericNeedle' m) w) (Tensor s (GenericNeedle' m) w))
-> LinearMap
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (DualVector (Needle (VRep m))) w)
-> LinearMap
s (Tensor s (GenericNeedle' m) w) (Tensor s (GenericNeedle' m) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ LinearMap
s
(Tensor s (DualVector (Needle (VRep m))) w)
(Tensor s (DualVector (Needle (VRep m))) w)
(DualVector (Needle (VRep m)) ⊗ w)
+> (DualVector (Needle (VRep m)) ⊗ w)
forall w.
(LinearSpace w,
Scalar w ~ Scalar (DualVector (Needle (VRep m)))) =>
(DualVector (Needle (VRep m)) ⊗ w)
+> (DualVector (Needle (VRep m)) ⊗ w)
forall v w.
(LinearSpace v, LinearSpace w, Scalar w ~ Scalar v) =>
(v ⊗ w) +> (v ⊗ w)
tensorId
applyTensorFunctional :: forall u.
(LinearSpace u, Scalar u ~ Scalar (GenericNeedle' m)) =>
Bilinear
(DualVector (GenericNeedle' m ⊗ u))
(GenericNeedle' m ⊗ u)
(Scalar (GenericNeedle' m))
applyTensorFunctional = case DualSpaceWitness (Needle (VRep m))
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (Needle (VRep m)) of
DualSpaceWitness (Needle (VRep m))
DualSpaceWitness -> (LinearMap s (GenericNeedle' m) (DualVector u)
-> Tensor s (GenericNeedle' m) u -> s)
-> LinearFunction
s
(LinearMap s (GenericNeedle' m) (DualVector u))
(LinearFunction s (Tensor s (GenericNeedle' m) u) s)
(LinearMap s (GenericNeedle' m) (DualVector u)
-> Tensor s (GenericNeedle' m) u -> s)
-> Bilinear
(LinearMap s (GenericNeedle' m) (DualVector u))
(Tensor s (GenericNeedle' m) u)
s
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s (GenericNeedle' m) (DualVector u)
-> Tensor s (GenericNeedle' m) u -> s)
-> LinearFunction
s
(LinearMap s (GenericNeedle' m) (DualVector u))
(LinearFunction s (Tensor s (GenericNeedle' m) u) s))
-> (LinearMap s (GenericNeedle' m) (DualVector u)
-> Tensor s (GenericNeedle' m) u -> s)
-> LinearFunction
s
(LinearMap s (GenericNeedle' m) (DualVector u))
(LinearFunction s (Tensor s (GenericNeedle' m) u) s)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (GenericNeedle' m)) (DualVector u)
f) Tensor s (GenericNeedle' m) u
t ->
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearMap
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(DualVector u))
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor s (DualVector (Needle (VRep m))) u)
s)
Bilinear
(DualVector (DualVector (Needle (VRep m)) ⊗ u))
(DualVector (Needle (VRep m)) ⊗ u)
(Scalar (DualVector (Needle (VRep m))))
forall u.
(LinearSpace u,
Scalar u ~ Scalar (DualVector (Needle (VRep m)))) =>
Bilinear
(DualVector (DualVector (Needle (VRep m)) ⊗ u))
(DualVector (Needle (VRep m)) ⊗ u)
(Scalar (DualVector (Needle (VRep m))))
forall v u.
(LinearSpace v, LinearSpace u, Scalar u ~ Scalar v) =>
Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v)
applyTensorFunctionalLinearFunction
(Scalar (DualVector (Needle (VRep m))))
(LinearMap
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(DualVector u))
(LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor s (DualVector (Needle (VRep m))) u)
s)
-> LinearMap
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(DualVector u)
-> LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor s (DualVector (Needle (VRep m))) u)
s
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct
(DualVector (DualVector (Needle (VRep m)))) (DualVector u)
-> LinearMap
(Scalar (DualVector (Needle (VRep m))))
(DualVector (Needle (VRep m)))
(DualVector u)
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector (GenericNeedle' m)) (DualVector u)
TensorProduct
(DualVector (DualVector (Needle (VRep m)))) (DualVector u)
f)
LinearFunction
(Scalar (DualVector (Needle (VRep m))))
(Tensor s (DualVector (Needle (VRep m))) u)
s
-> Tensor s (DualVector (Needle (VRep m))) u -> s
forall s v w. LinearFunction s v w -> v -> w
-+$>(GenericNeedle' m -> DualVector (Needle (VRep m)))
-> VSCCoercion
s
(Tensor s (GenericNeedle' m) u)
(Tensor s (DualVector (Needle (VRep m))) u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle' m -> DualVector (Needle (VRep m))
forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle' VSCCoercion
s
(Tensor s (GenericNeedle' m) u)
(Tensor s (DualVector (Needle (VRep m))) u)
-> Tensor s (GenericNeedle' m) u
-> Tensor s (DualVector (Needle (VRep m))) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor s (GenericNeedle' m) u
t
applyTensorLinMap :: forall u w.
(LinearSpace u, TensorSpace w,
Scalar u ~ Scalar (GenericNeedle' m),
Scalar w ~ Scalar (GenericNeedle' m)) =>
Bilinear ((GenericNeedle' m ⊗ u) +> w) (GenericNeedle' m ⊗ u) w
applyTensorLinMap = case DualSpaceWitness (Needle (VRep m))
forall v. LinearSpace v => DualSpaceWitness v
dualSpaceWitness :: DualSpaceWitness (Needle (VRep m)) of
DualSpaceWitness (Needle (VRep m))
DualSpaceWitness -> (LinearMap s (Tensor s (GenericNeedle' m) u) w
-> Tensor s (GenericNeedle' m) u -> w)
-> LinearFunction
s
(LinearMap s (Tensor s (GenericNeedle' m) u) w)
(LinearFunction s (Tensor s (GenericNeedle' m) u) w)
(LinearMap s (Tensor s (GenericNeedle' m) u) w
-> Tensor s (GenericNeedle' m) u -> w)
-> Bilinear
(LinearMap s (Tensor s (GenericNeedle' m) u) w)
(Tensor s (GenericNeedle' m) u)
w
forall v w y. (v -> w -> y) -> Bilinear v w y
bilinearFunction ((LinearMap s (Tensor s (GenericNeedle' m) u) w
-> Tensor s (GenericNeedle' m) u -> w)
-> LinearFunction
s
(LinearMap s (Tensor s (GenericNeedle' m) u) w)
(LinearFunction s (Tensor s (GenericNeedle' m) u) w))
-> (LinearMap s (Tensor s (GenericNeedle' m) u) w
-> Tensor s (GenericNeedle' m) u -> w)
-> LinearFunction
s
(LinearMap s (Tensor s (GenericNeedle' m) u) w)
(LinearFunction s (Tensor s (GenericNeedle' m) u) w)
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ \(LinearMap TensorProduct (DualVector (Tensor s (GenericNeedle' m) u)) w
f) Tensor s (GenericNeedle' m) u
t
-> (LinearFunction
s
(LinearMap s (Tensor s (DualVector (Needle (VRep m))) u) w)
(LinearFunction s (Tensor s (DualVector (Needle (VRep m))) u) w)
Bilinear
((DualVector (Needle (VRep m)) ⊗ u) +> w)
(DualVector (Needle (VRep m)) ⊗ u)
w
forall v u w.
(LinearSpace v, LinearSpace u, TensorSpace w, Scalar u ~ Scalar v,
Scalar w ~ Scalar v) =>
Bilinear ((v ⊗ u) +> w) (v ⊗ u) w
forall u w.
(LinearSpace u, TensorSpace w,
Scalar u ~ Scalar (DualVector (Needle (VRep m))),
Scalar w ~ Scalar (DualVector (Needle (VRep m)))) =>
Bilinear
((DualVector (Needle (VRep m)) ⊗ u) +> w)
(DualVector (Needle (VRep m)) ⊗ u)
w
applyTensorLinMapLinearFunction
s
(LinearMap s (Tensor s (DualVector (Needle (VRep m))) u) w)
(LinearFunction s (Tensor s (DualVector (Needle (VRep m))) u) w)
-> LinearMap s (Tensor s (DualVector (Needle (VRep m))) u) w
-> LinearFunction s (Tensor s (DualVector (Needle (VRep m))) u) w
forall s v w. LinearFunction s v w -> v -> w
-+$>TensorProduct
(DualVector (Tensor s (DualVector (Needle (VRep m))) u)) w
-> LinearMap s (Tensor s (DualVector (Needle (VRep m))) u) w
forall s v w. TensorProduct (DualVector v) w -> LinearMap s v w
LinearMap TensorProduct (DualVector (Tensor s (GenericNeedle' m) u)) w
TensorProduct
(DualVector (Tensor s (DualVector (Needle (VRep m))) u)) w
f)
LinearFunction s (Tensor s (DualVector (Needle (VRep m))) u) w
-> Tensor s (DualVector (Needle (VRep m))) u -> w
forall s v w. LinearFunction s v w -> v -> w
-+$>(GenericNeedle' m -> DualVector (Needle (VRep m)))
-> VSCCoercion
s
(Tensor s (GenericNeedle' m) u)
(Tensor s (DualVector (Needle (VRep m))) u)
forall v w v' (c :: Type -> Type -> Type) s.
(TensorProduct v w ~ TensorProduct v' w,
StaticDimension v ~ StaticDimension v') =>
c v v' -> VSCCoercion s (Tensor s v w) (Tensor s v' w)
pseudoFmapTensorLHS GenericNeedle' m -> DualVector (Needle (VRep m))
forall m. GenericNeedle' m -> DualVector (Needle (VRep m))
getGenericNeedle' VSCCoercion
s
(Tensor s (GenericNeedle' m) u)
(Tensor s (DualVector (Needle (VRep m))) u)
-> Tensor s (GenericNeedle' m) u
-> Tensor s (DualVector (Needle (VRep m))) u
forall (f :: Type -> Type -> Type) a b.
(Function f, Object f a, Object f b) =>
f a b -> a -> b
$ Tensor s (GenericNeedle' m) u
t
useTupleLinearSpaceComponents :: forall x y φ.
(GenericNeedle' m ~ (x, y)) =>
((LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ) -> φ
useTupleLinearSpaceComponents (LinearSpace x, LinearSpace y, Scalar x ~ Scalar y) => φ
_ = φ
forall a. a
usingNonTupleTypeAsTupleError
coerceDoubleDual :: VSCCoercion
(Scalar (GenericNeedle' m))
(GenericNeedle' m)
(DualVector (DualVector (GenericNeedle' m)))
coerceDoubleDual = case forall v.
LinearSpace v =>
VSCCoercion (Scalar v) v (DualVector (DualVector v))
coerceDoubleDual @(Needle (VRep m)) of
VSCCoercion
(Scalar (Needle (VRep m)))
(Needle (VRep m))
(DualVector (DualVector (Needle (VRep m))))
VSCCoercion -> VSCCoercion s (GenericNeedle' m) (GenericNeedle' m)
VSCCoercion
(Scalar (GenericNeedle' m))
(GenericNeedle' m)
(DualVector (DualVector (GenericNeedle' m)))
forall a b s.
(Coercible a b, StaticDimension a ~ StaticDimension b) =>
VSCCoercion s a b
VSCCoercion