linearmap-category-0.4.0.0: Native, complete, matrix-free linear algebra.

Copyright(c) Justus Sagemüller 2016
LicenseGPL v3
Maintainer(@) jsag $ hvl.no
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Math.LinearMap.Category

Contents

Description

 
Synopsis

Linear maps

This library deals with linear functions, i.e. functions f :: v -> w that fulfill

f $ μ ^* u ^+^ v ≡ μ ^* f u ^+^ f v    ∀ u,v :: v;  μ :: Scalar v

Such functions form a cartesian monoidal category (in maths called VectK). This is implemented by PreArrow, which is the preferred interface for dealing with these mappings. The basic “matrix operations” are then:

  • Identity matrix: id
  • Matrix addition: ^+^ (linear maps form an ordinary vector space)
  • Matrix-matrix multiplication: <<< (or >>> or .)
  • Matrix-vector multiplication: $
  • Vertical matrix concatenation: &&&
  • Horizontal matrix concatenation: (aka >+<)

But linear mappings need not necessarily be implemented as matrices:

Function implementation

newtype LinearFunction s v w Source #

A linear map, represented simply as a Haskell function tagged with the type of scalar with respect to which it is linear. Many (sparse) linear mappings can actually be calculated much more efficiently if you don't represent them with any kind of matrix, but just as a function (which is after all, mathematically speaking, what a linear map foremostly is).

However, if you sum up many LinearFunctions – which you can simply do with the VectorSpace instance – they will become ever slower to calculate, because the summand-functions are actually computed individually and only the results summed. That's where LinearMap is generally preferrable. You can always convert between these equivalent categories using arr.

Constructors

LinearFunction 

Fields

Instances
Num' s => Morphism (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

first :: (ObjectPair (LinearFunction s) b d, ObjectPair (LinearFunction s) c d) => LinearFunction s b c -> LinearFunction s (b, d) (c, d) #

second :: (ObjectPair (LinearFunction s) d b, ObjectPair (LinearFunction s) d c) => LinearFunction s b c -> LinearFunction s (d, b) (d, 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') #

Num' s => PreArrow (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Category (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type Object (LinearFunction s) o :: Constraint #

Num' s => Cartesian (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type PairObjects (LinearFunction s) a b :: Constraint #

type UnitObject (LinearFunction s) :: Type #

Methods

swap :: (ObjectPair (LinearFunction s) a b, ObjectPair (LinearFunction s) b a) => LinearFunction s (a, b) (b, a) #

attachUnit :: (unit ~ UnitObject (LinearFunction s), ObjectPair (LinearFunction s) a unit) => LinearFunction s a (a, unit) #

detachUnit :: (unit ~ UnitObject (LinearFunction s), ObjectPair (LinearFunction s) a unit) => LinearFunction s (a, unit) a #

regroup :: (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' :: (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)) #

EnhancedCat (LinearFunction s) (Coercion :: Type -> Type -> Type) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Num' s => EnhancedCat (LinearFunction s) (LinearMap s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

arr :: (Object (LinearMap s) b, Object (LinearMap s) c, Object (LinearFunction s) b, Object (LinearFunction s) c) => LinearMap s b c -> LinearFunction s b c #

Num' s => EnhancedCat (LinearMap s) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

arr :: (Object (LinearFunction s) b, Object (LinearFunction s) c, Object (LinearMap s) b, Object (LinearMap s) c) => LinearFunction s b c -> LinearMap s b c #

EnhancedCat ((->) :: Type -> Type -> Type) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

arr :: (Object (LinearFunction s) b, Object (LinearFunction s) c, Object (->) b, Object (->) c) => LinearFunction s b c -> b -> c #

(Num' s, TensorSpace v, Scalar v ~ s) => Monoidal (Tensor s v) (LinearFunction s) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

(Num' s, LinearSpace v, Scalar v ~ s) => Monoidal (LinearMap s v) (LinearFunction s) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Functor (LinearFunction s v) (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # 
Instance details

Defined in Math.LinearMap.Asserted

(LinearSpace w, Num' s, Scalar w ~ s) => Functor (LinearFunction s w) (LinearFunction s) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

(TensorSpace v, Num' s, Scalar v ~ s) => Functor (Tensor s v) (LinearFunction s) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

fmap :: (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) #

(LinearSpace v, Num' s, Scalar v ~ s) => Functor (LinearMap s v) (LinearFunction s) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

(FiniteDimensional u, LSpace v, FiniteFreeSpace v, Scalar u ~ s, Scalar v ~ s) => FiniteFreeSpace (LinearFunction s u v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

AdditiveGroup w => AdditiveGroup (LinearFunction s v w) Source # 
Instance details

Defined in Math.LinearMap.Asserted

VectorSpace w => VectorSpace (LinearFunction s v w) Source # 
Instance details

Defined in Math.LinearMap.Asserted

Associated Types

type Scalar (LinearFunction s v w) :: Type #

Methods

(*^) :: Scalar (LinearFunction s v w) -> LinearFunction s v w -> LinearFunction s v w #

(TensorSpace u, TensorSpace v, s ~ Scalar u, s ~ Scalar v) => AffineSpace (LinearFunction s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type Diff (LinearFunction s u v) :: Type #

Methods

(.-.) :: LinearFunction s u v -> LinearFunction s u v -> Diff (LinearFunction s u v) #

(.+^) :: LinearFunction s u v -> Diff (LinearFunction s u v) -> LinearFunction s u v #

VectorSpace w => Semimanifold (LinearFunction s v w) Source # 
Instance details

Defined in Math.LinearMap.Asserted

Associated Types

type Needle (LinearFunction s v w) :: Type #

type Interior (LinearFunction s v w) :: Type #

VectorSpace w => PseudoAffine (LinearFunction s v w) Source # 
Instance details

Defined in Math.LinearMap.Asserted

(LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s) => LinearSpace (LinearFunction s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type DualVector (LinearFunction s u v) :: Type Source #

Methods

dualSpaceWitness :: DualSpaceWitness (LinearFunction s u v) Source #

linearId :: LinearFunction s u v +> LinearFunction s u v Source #

idTensor :: LinearFunction s u v DualVector (LinearFunction s u v) Source #

sampleLinearFunction :: (TensorSpace w, Scalar (LinearFunction s u v) ~ Scalar w) => (LinearFunction s u v -+> w) -+> (LinearFunction s u v +> w) Source #

toLinearForm :: DualVector (LinearFunction s u v) -+> (LinearFunction s u v +> Scalar (LinearFunction s u v)) Source #

fromLinearForm :: (LinearFunction s u v +> Scalar (LinearFunction s u v)) -+> DualVector (LinearFunction s u v) Source #

coerceDoubleDual :: Coercion (LinearFunction s u v) (DualVector (DualVector (LinearFunction s u v))) Source #

trace :: (LinearFunction s u v +> LinearFunction s u v) -+> Scalar (LinearFunction s u v) Source #

contractTensorMap :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v +> (LinearFunction s u v w)) -+> w Source #

contractMapTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v (LinearFunction s u v +> w)) -+> w Source #

contractTensorFn :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v -+> (LinearFunction s u v w)) -+> w Source #

contractLinearMapAgainst :: (LinearSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => Bilinear (LinearFunction s u v +> w) (w -+> LinearFunction s u v) (Scalar (LinearFunction s u v)) Source #

applyDualVector :: Bilinear (DualVector (LinearFunction s u v)) (LinearFunction s u v) (Scalar (LinearFunction s u v)) Source #

applyLinear :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => Bilinear (LinearFunction s u v +> w) (LinearFunction s u v) w Source #

composeLinear :: (LinearSpace 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) Source #

tensorId :: (LinearSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v w) +> (LinearFunction s u v w) Source #

applyTensorFunctional :: (LinearSpace u0, Scalar u0 ~ Scalar (LinearFunction s u v)) => Bilinear (DualVector (LinearFunction s u v u0)) (LinearFunction s u v u0) (Scalar (LinearFunction s u v)) Source #

applyTensorLinMap :: (LinearSpace u0, TensorSpace w, Scalar u0 ~ Scalar (LinearFunction s u v), Scalar w ~ Scalar (LinearFunction s u v)) => Bilinear ((LinearFunction s u v u0) +> w) (LinearFunction s u v u0) w Source #

(LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s) => TensorSpace (LinearFunction s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type TensorProduct (LinearFunction s u v) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (LinearFunction s u v) Source #

linearManifoldWitness :: LinearManifoldWitness (LinearFunction s u v) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => LinearFunction s u v w Source #

toFlatTensor :: LinearFunction s u v -+> (LinearFunction s u v Scalar (LinearFunction s u v)) Source #

fromFlatTensor :: (LinearFunction s u v Scalar (LinearFunction s u v)) -+> LinearFunction s u v Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v w) -> (LinearFunction s u v w) -> LinearFunction s u v w Source #

subtractTensors :: (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 Source #

scaleTensor :: (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) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v w) -+> (LinearFunction s u v w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => Bilinear (LinearFunction s u v) w (LinearFunction s u v w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => [(LinearFunction s u v, w)] -> LinearFunction s u v w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v w) -+> (w LinearFunction s u v) Source #

fmapTensor :: (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) Source #

fzipTensorWith :: (TensorSpace u0, TensorSpace w, TensorSpace x, Scalar u0 ~ Scalar (LinearFunction s u v), Scalar w ~ Scalar (LinearFunction s u v), Scalar x ~ Scalar (LinearFunction s u v)) => Bilinear ((w, x) -+> u0) (LinearFunction s u v w, LinearFunction s u v x) (LinearFunction s u v u0) Source #

coerceFmapTensorProduct :: Functor p => p (LinearFunction s u v) -> Coercion a b -> Coercion (TensorProduct (LinearFunction s u v) a) (TensorProduct (LinearFunction s u v) b) Source #

wellDefinedVector :: LinearFunction s u v -> Maybe (LinearFunction s u v) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v w) -> Maybe (LinearFunction s u v w) Source #

type UnitObject (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Object (LinearFunction s) v Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Object (LinearFunction s) v = (TensorSpace v, Scalar v ~ s)
type PairObjects (LinearFunction s) a b Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type PairObjects (LinearFunction s) a b = ()
type Scalar (LinearFunction s v w) Source # 
Instance details

Defined in Math.LinearMap.Asserted

type Scalar (LinearFunction s v w) = Scalar w
type Diff (LinearFunction s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Diff (LinearFunction s u v) = LinearFunction s u v
type Interior (LinearFunction s v w) Source # 
Instance details

Defined in Math.LinearMap.Asserted

type Needle (LinearFunction s v w) Source # 
Instance details

Defined in Math.LinearMap.Asserted

type Needle (LinearFunction s v w) = LinearFunction s v w
type DualVector (LinearFunction s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type TensorProduct (LinearFunction s u v) w Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type (-+>) v w = LinearFunction (Scalar w) v w Source #

Infix synonym of LinearFunction, without explicit mention of the scalar type.

type Bilinear v w y = LinearFunction (Scalar v) v (LinearFunction (Scalar v) w y) Source #

A bilinear function is a linear function mapping to a linear function, or equivalently a 2-argument function that's linear in each argument independently. Note that this can not be uncurried to a linear function with a tuple argument (this would not be linear but quadratic).

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 Source #

Use a function as a linear map. This is only well-defined if the function is linear (this condition is not checked).

Tensor implementation

newtype LinearMap s v w Source #

The tensor product between one space's dual space and another space is the space spanned by vector–dual-vector pairs, in bra-ket notation written as

m = ∑ |w⟩⟨v|

Any linear mapping can be written as such a (possibly infinite) sum. The TensorProduct data structure only stores the linear independent parts though; for simple finite-dimensional spaces this means e.g. LinearMap ℝ ℝ³ ℝ³ effectively boils down to an ordinary matrix type, namely an array of column-vectors |w⟩.

(The ⟨v| dual-vectors are then simply assumed to come from the canonical basis.)

For bigger spaces, the tensor product may be implemented in a more efficient sparse structure; this can be defined in the TensorSpace instance.

Constructors

LinearMap 
Instances
(Show (SubBasis (DualVector u)), Show (SubBasis v)) => Show (SubBasis (LinearMap s u v)) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Methods

showsPrec :: Int -> SubBasis (LinearMap s u v) -> ShowS #

show :: SubBasis (LinearMap s u v) -> String #

showList :: [SubBasis (LinearMap s u v)] -> ShowS #

Num' s => Morphism (LinearMap s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

first :: (ObjectPair (LinearMap s) b d, ObjectPair (LinearMap s) c d) => LinearMap s b c -> LinearMap s (b, d) (c, d) #

second :: (ObjectPair (LinearMap s) d b, ObjectPair (LinearMap s) d c) => LinearMap s b c -> LinearMap s (d, b) (d, 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') #

Num' s => PreArrow (LinearMap s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

(&&&) :: (Object (LinearMap s) b, ObjectPair (LinearMap s) c c') => LinearMap s b c -> LinearMap s b c' -> LinearMap s b (c, c') #

terminal :: Object (LinearMap s) b => LinearMap s b (UnitObject (LinearMap s)) #

fst :: ObjectPair (LinearMap s) x y => LinearMap s (x, y) x #

snd :: ObjectPair (LinearMap s) x y => LinearMap s (x, y) y #

Category (LinearMap s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type Object (LinearMap s) o :: Constraint #

Methods

id :: Object (LinearMap s) a => LinearMap s a a #

(.) :: (Object (LinearMap s) a, Object (LinearMap s) b, Object (LinearMap s) c) => LinearMap s b c -> LinearMap s a b -> LinearMap s a c #

Num' s => Cartesian (LinearMap s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type PairObjects (LinearMap s) a b :: Constraint #

type UnitObject (LinearMap s) :: Type #

Methods

swap :: (ObjectPair (LinearMap s) a b, ObjectPair (LinearMap s) b a) => LinearMap s (a, b) (b, a) #

attachUnit :: (unit ~ UnitObject (LinearMap s), ObjectPair (LinearMap s) a unit) => LinearMap s a (a, unit) #

detachUnit :: (unit ~ UnitObject (LinearMap s), ObjectPair (LinearMap s) a unit) => LinearMap s (a, unit) a #

regroup :: (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' :: (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)) #

Num' s => EnhancedCat (LinearFunction s) (LinearMap s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

arr :: (Object (LinearMap s) b, Object (LinearMap s) c, Object (LinearFunction s) b, Object (LinearFunction s) c) => LinearMap s b c -> LinearFunction s b c #

Num' s => EnhancedCat (LinearMap s) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

arr :: (Object (LinearFunction s) b, Object (LinearFunction s) c, Object (LinearMap s) b, Object (LinearMap s) c) => LinearFunction s b c -> LinearMap s b c #

Num' s => EnhancedCat ((->) :: Type -> Type -> Type) (LinearMap s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

arr :: (Object (LinearMap s) b, Object (LinearMap s) c, Object (->) b, Object (->) c) => LinearMap s b c -> b -> c #

(Num' s, LinearSpace v, Scalar v ~ s) => Monoidal (LinearMap s v) (LinearFunction s) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

(LinearSpace v, Scalar v ~ s) => Functor (LinearMap s v) (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

fmap :: (Object Coercion a, Object Coercion (LinearMap s v a), Object Coercion b, Object Coercion (LinearMap s v b)) => Coercion a b -> Coercion (LinearMap s v a) (LinearMap s v b) #

(LinearSpace v, Num' s, Scalar v ~ s) => Functor (LinearMap s v) (LinearFunction s) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

(Fractional' n, TensorProduct (DualVector n) n ~ n) => Fractional (LinearMap n n n) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Methods

(/) :: LinearMap n n n -> LinearMap n n n -> LinearMap n n n #

recip :: LinearMap n n n -> LinearMap n n n #

fromRational :: Rational -> LinearMap n n n #

(Num' n, TensorProduct (DualVector n) n ~ n) => Num (LinearMap n n n) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Methods

(+) :: LinearMap n n n -> LinearMap n n n -> LinearMap n n n #

(-) :: LinearMap n n n -> LinearMap n n n -> LinearMap n n n #

(*) :: LinearMap n n n -> LinearMap n n n -> LinearMap n n n #

negate :: LinearMap n n n -> LinearMap n n n #

abs :: LinearMap n n n -> LinearMap n n n #

signum :: LinearMap n n n -> LinearMap n n n #

fromInteger :: Integer -> LinearMap n n n #

(FiniteDimensional v, v ~ DualVector v, Show v, RieszDecomposable x, RieszDecomposable y, Scalar x ~ s, Scalar y ~ s, Scalar v ~ s, Scalar (DualVector x) ~ s, Scalar (DualVector y) ~ s) => Show (LinearMap s v (x, y)) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Methods

showsPrec :: Int -> LinearMap s v (x, y) -> ShowS #

show :: LinearMap s v (x, y) -> String #

showList :: [LinearMap s v (x, y)] -> ShowS #

Show (LinearMap s v (V0 s)) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Methods

showsPrec :: Int -> LinearMap s v (V0 s) -> ShowS #

show :: LinearMap s v (V0 s) -> String #

showList :: [LinearMap s v (V0 s)] -> ShowS #

Show (LinearMap s v (ZeroDim s)) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Methods

showsPrec :: Int -> LinearMap s v (ZeroDim s) -> ShowS #

show :: LinearMap s v (ZeroDim s) -> String #

showList :: [LinearMap s v (ZeroDim s)] -> ShowS #

(FiniteDimensional v, InnerSpace v, Show v, FiniteDimensional w, InnerSpace w, Show w, Scalar v ~ s, Scalar w ~ s, HasBasis s, Basis s ~ ()) => Show (LinearMap s (v, w) s) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Methods

showsPrec :: Int -> LinearMap s (v, w) s -> ShowS #

show :: LinearMap s (v, w) s -> String #

showList :: [LinearMap s (v, w) s] -> ShowS #

(FiniteDimensional u, LSpace v, FiniteFreeSpace v, Scalar u ~ s, Scalar v ~ s) => FiniteFreeSpace (LinearMap s u v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

(LinearSpace v, TensorSpace w, Scalar v ~ s, Scalar w ~ s) => AdditiveGroup (LinearMap s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

zeroV :: LinearMap s v w #

(^+^) :: LinearMap s v w -> LinearMap s v w -> LinearMap s v w #

negateV :: LinearMap s v w -> LinearMap s v w #

(^-^) :: LinearMap s v w -> LinearMap s v w -> LinearMap s v w #

(LinearSpace v, TensorSpace w, Scalar v ~ s, Scalar w ~ s) => VectorSpace (LinearMap s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type Scalar (LinearMap s v w) :: Type #

Methods

(*^) :: Scalar (LinearMap s v w) -> LinearMap s v w -> LinearMap s v w #

(LinearSpace u, TensorSpace v, s ~ Scalar u, s ~ Scalar v) => AffineSpace (LinearMap s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type Diff (LinearMap s u v) :: Type #

Methods

(.-.) :: LinearMap s u v -> LinearMap s u v -> Diff (LinearMap s u v) #

(.+^) :: LinearMap s u v -> Diff (LinearMap s u v) -> LinearMap s u v #

(LinearSpace v, TensorSpace w, Scalar v ~ s, Scalar w ~ s) => Semimanifold (LinearMap s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type Needle (LinearMap s v w) :: Type #

type Interior (LinearMap s v w) :: Type #

(LinearSpace v, TensorSpace w, Scalar v ~ s, Scalar w ~ s) => PseudoAffine (LinearMap s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

(.-~.) :: LinearMap s v w -> LinearMap s v w -> Maybe (Needle (LinearMap s v w)) #

(.-~!) :: LinearMap s v w -> LinearMap s v w -> Needle (LinearMap s v w) #

pseudoAffineWitness :: PseudoAffineWitness (LinearMap s v w) #

(LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s) => LinearSpace (LinearMap s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type DualVector (LinearMap s u v) :: Type Source #

Methods

dualSpaceWitness :: DualSpaceWitness (LinearMap s u v) Source #

linearId :: LinearMap s u v +> LinearMap s u v Source #

idTensor :: LinearMap s u v DualVector (LinearMap s u v) Source #

sampleLinearFunction :: (TensorSpace w, Scalar (LinearMap s u v) ~ Scalar w) => (LinearMap s u v -+> w) -+> (LinearMap s u v +> w) Source #

toLinearForm :: DualVector (LinearMap s u v) -+> (LinearMap s u v +> Scalar (LinearMap s u v)) Source #

fromLinearForm :: (LinearMap s u v +> Scalar (LinearMap s u v)) -+> DualVector (LinearMap s u v) Source #

coerceDoubleDual :: Coercion (LinearMap s u v) (DualVector (DualVector (LinearMap s u v))) Source #

trace :: (LinearMap s u v +> LinearMap s u v) -+> Scalar (LinearMap s u v) Source #

contractTensorMap :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v +> (LinearMap s u v w)) -+> w Source #

contractMapTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v (LinearMap s u v +> w)) -+> w Source #

contractTensorFn :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v -+> (LinearMap s u v w)) -+> w Source #

contractLinearMapAgainst :: (LinearSpace w, Scalar w ~ Scalar (LinearMap s u v)) => Bilinear (LinearMap s u v +> w) (w -+> LinearMap s u v) (Scalar (LinearMap s u v)) Source #

applyDualVector :: Bilinear (DualVector (LinearMap s u v)) (LinearMap s u v) (Scalar (LinearMap s u v)) Source #

applyLinear :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => Bilinear (LinearMap s u v +> w) (LinearMap s u v) w Source #

composeLinear :: (LinearSpace 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) Source #

tensorId :: (LinearSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v w) +> (LinearMap s u v w) Source #

applyTensorFunctional :: (LinearSpace u0, Scalar u0 ~ Scalar (LinearMap s u v)) => Bilinear (DualVector (LinearMap s u v u0)) (LinearMap s u v u0) (Scalar (LinearMap s u v)) Source #

applyTensorLinMap :: (LinearSpace u0, TensorSpace w, Scalar u0 ~ Scalar (LinearMap s u v), Scalar w ~ Scalar (LinearMap s u v)) => Bilinear ((LinearMap s u v u0) +> w) (LinearMap s u v u0) w Source #

(LinearSpace u, TensorSpace v, Scalar u ~ s, Scalar v ~ s) => TensorSpace (LinearMap s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type TensorProduct (LinearMap s u v) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (LinearMap s u v) Source #

linearManifoldWitness :: LinearManifoldWitness (LinearMap s u v) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => LinearMap s u v w Source #

toFlatTensor :: LinearMap s u v -+> (LinearMap s u v Scalar (LinearMap s u v)) Source #

fromFlatTensor :: (LinearMap s u v Scalar (LinearMap s u v)) -+> LinearMap s u v Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v w) -> (LinearMap s u v w) -> LinearMap s u v w Source #

subtractTensors :: (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 Source #

scaleTensor :: (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) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v w) -+> (LinearMap s u v w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => Bilinear (LinearMap s u v) w (LinearMap s u v w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => [(LinearMap s u v, w)] -> LinearMap s u v w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v w) -+> (w LinearMap s u v) Source #

fmapTensor :: (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) Source #

fzipTensorWith :: (TensorSpace u0, TensorSpace w, TensorSpace x, Scalar u0 ~ Scalar (LinearMap s u v), Scalar w ~ Scalar (LinearMap s u v), Scalar x ~ Scalar (LinearMap s u v)) => Bilinear ((w, x) -+> u0) (LinearMap s u v w, LinearMap s u v x) (LinearMap s u v u0) Source #

coerceFmapTensorProduct :: Functor p => p (LinearMap s u v) -> Coercion a b -> Coercion (TensorProduct (LinearMap s u v) a) (TensorProduct (LinearMap s u v) b) Source #

wellDefinedVector :: LinearMap s u v -> Maybe (LinearMap s u v) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v w) -> Maybe (LinearMap s u v w) Source #

(LSpace u, FiniteDimensional (DualVector u), FiniteDimensional v, Scalar u ~ s, Scalar v ~ s, Scalar (DualVector v) ~ s, Fractional' (Scalar v)) => FiniteDimensional (LinearMap s u v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Associated Types

data SubBasis (LinearMap s u v) :: Type Source #

Methods

entireBasis :: SubBasis (LinearMap s u v) Source #

enumerateSubBasis :: SubBasis (LinearMap s u v) -> [LinearMap s u v] Source #

subbasisDimension :: SubBasis (LinearMap s u v) -> Int Source #

decomposeLinMap :: (LSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v +> w) -> (SubBasis (LinearMap s u v), DList w) Source #

decomposeLinMapWithin :: (LSpace w, Scalar w ~ Scalar (LinearMap s u v)) => SubBasis (LinearMap s u v) -> (LinearMap s u v +> w) -> Either (SubBasis (LinearMap s u v), DList w) (DList w) Source #

recomposeSB :: SubBasis (LinearMap s u v) -> [Scalar (LinearMap s u v)] -> (LinearMap s u v, [Scalar (LinearMap s u v)]) Source #

recomposeSBTensor :: (FiniteDimensional w, Scalar w ~ Scalar (LinearMap s u v)) => SubBasis (LinearMap s u v) -> SubBasis w -> [Scalar (LinearMap s u v)] -> (LinearMap s u v w, [Scalar (LinearMap s u v)]) Source #

recomposeLinMap :: (LSpace w, Scalar w ~ Scalar (LinearMap s u v)) => SubBasis (LinearMap s u v) -> [w] -> (LinearMap s u v +> w, [w]) Source #

recomposeContraLinMap :: (LinearSpace w, Scalar w ~ Scalar (LinearMap s u v), Functor f) => (f (Scalar w) -> w) -> f (DualVector (LinearMap s u v)) -> LinearMap s u v +> w Source #

recomposeContraLinMapTensor :: (FiniteDimensional u0, LinearSpace w, Scalar u0 ~ Scalar (LinearMap s u v), Scalar w ~ Scalar (LinearMap s u v), Functor f) => (f (Scalar w) -> w) -> f (LinearMap s u v +> DualVector u0) -> (LinearMap s u v u0) +> w Source #

uncanonicallyFromDual :: DualVector (LinearMap s u v) -+> LinearMap s u v Source #

uncanonicallyToDual :: LinearMap s u v -+> DualVector (LinearMap s u v) Source #

(LinearSpace u, SemiInner (DualVector u), SemiInner v, Scalar u ~ s, Scalar v ~ s) => SemiInner (LinearMap s u v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

type UnitObject (LinearMap s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Object (LinearMap s) v Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Object (LinearMap s) v = (LinearSpace v, Scalar v ~ s)
type PairObjects (LinearMap s) a b Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type PairObjects (LinearMap s) a b = ()
type Scalar (LinearMap s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Scalar (LinearMap s v w) = s
type Diff (LinearMap s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Diff (LinearMap s u v) = LinearMap s u v
type Interior (LinearMap s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Interior (LinearMap s v w) = LinearMap s v w
type Needle (LinearMap s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Needle (LinearMap s v w) = LinearMap s v w
type DualVector (LinearMap s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type DualVector (LinearMap s u v) = Tensor s u (DualVector v)
data SubBasis (LinearMap s u v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

type TensorProduct (LinearMap s u v) w Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type (+>) v w = LinearMap (Scalar v) v w Source #

Infix synonym for LinearMap, without explicit mention of the scalar type.

(⊕) :: (u +> w) -> (v +> w) -> (u, v) +> w infixr 6 Source #

The dual operation to the tuple constructor, or rather to the &&& fanout operation: evaluate two (linear) functions in parallel and sum up the results. The typical use is to concatenate “row vectors” in a matrix definition.

(>+<) :: (u +> w) -> (v +> w) -> (u, v) +> w infixr 6 Source #

ASCII version of

adjoint :: forall v w. (LinearSpace v, LinearSpace w, Scalar v ~ Scalar w) => (v +> DualVector w) -+> (w +> DualVector v) Source #

For real matrices, this boils down to transpose. For free complex spaces it also incurs complex conjugation.

The signature can also be understood as

adjoint :: (v +> w) -> (DualVector w +> DualVector v)

Or

adjoint :: (DualVector v +> DualVector w) -> (w +> v)

But not (v+>w) -> (w+>v), in general (though in a Hilbert space, this too is equivalent, via riesz isomorphism).

Dual vectors

A DualVector v is a linear functional or linear form on the vector space v, i.e. it is a linear function from the vector space into its scalar field. However, these functions form themselves a vector space, known as the dual space. In particular, the dual space of any InnerSpace is isomorphic to the space itself.

(More precisely: the continuous dual space of a Hilbert space is isomorphic to that Hilbert space itself; see the riesz isomorphism.)

As a matter of fact, in many applications, no distinction is made between a space and its dual. Indeed, we have for the basic LinearSpace instances DualVector v ~ v, and <.>^ is simply defined as a scalar product. In this case, a general LinearMap is just a tensor product / matrix.

However, scalar products are often not as natural as they are made to look:

  • A scalar product is only preserved under orthogonal transformations. It is not preserved under scalings, and certainly not under general linear transformations. This is very important in applications such as relativity theory (here, people talk about covariant vs contravariant tensors), but also relevant for more mundane manifolds like sphere surfaces: on such a surface, the natural symmetry transformations do generally not preserve a scalar product you might define.
  • There may be more than one meaningful scalar product. For instance, the Sobolev space of weakly differentiable functions also permits the 𝐿² scalar product – each has different and useful properties.

Neither of this is a problem if we keep the dual space a separate type. Effectively, this enables the type system to prevent you from writing code that does not behave natural (i.e. that depends on a concrete choice of basis / scalar product).

For cases when you do have some given notion of orientation/scale in a vector space and need it for an algorithm, you can always provide a Norm, which is essentially a reified scalar product.

Note that DualVector (DualVector v) ~ v in any LSpace: the double-dual space is naturally isomorphic to the original space, by way of

v <.>^ dv  ≡  dv <.>^ v

(<.>^) :: LinearSpace v => DualVector v -> v -> Scalar v infixr 7 Source #

(-+|>) :: (EnhancedCat f (LinearFunction s), LSpace u, LSpace v, Scalar u ~ s, Scalar v ~ s, Object f u, Object f v) => DualVector u -> v -> f u v infixr 7 Source #

A linear map that simply projects from a dual vector in u to a vector in v.

(du -+|> v) u  ≡  v ^* (du <.>^ u)

Tensor spaces

newtype Tensor s v w Source #

Tensor products are most interesting because they can be used to implement linear mappings, but they also form a useful vector space on their own right.

Constructors

Tensor 
Instances
(Show (SubBasis u), Show (SubBasis v)) => Show (SubBasis (Tensor s u v)) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Methods

showsPrec :: Int -> SubBasis (Tensor s u v) -> ShowS #

show :: SubBasis (Tensor s u v) -> String #

showList :: [SubBasis (Tensor s u v)] -> ShowS #

(Num' s, TensorSpace v, Scalar v ~ s) => Monoidal (Tensor s v) (LinearFunction s) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

(TensorSpace v, Scalar v ~ s) => Functor (Tensor s v) (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

fmap :: (Object Coercion a, Object Coercion (Tensor s v a), Object Coercion b, Object Coercion (Tensor s v b)) => Coercion a b -> Coercion (Tensor s v a) (Tensor s v b) #

(TensorSpace v, Num' s, Scalar v ~ s) => Functor (Tensor s v) (LinearFunction s) (LinearFunction s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

fmap :: (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) #

IsList (Tensor s (FinSuppSeq s) v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type Item (Tensor s (FinSuppSeq s) v) :: Type #

Methods

fromList :: [Item (Tensor s (FinSuppSeq s) v)] -> Tensor s (FinSuppSeq s) v #

fromListN :: Int -> [Item (Tensor s (FinSuppSeq s) v)] -> Tensor s (FinSuppSeq s) v #

toList :: Tensor s (FinSuppSeq s) v -> [Item (Tensor s (FinSuppSeq s) v)] #

IsList (Tensor s (Sequence s) v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type Item (Tensor s (Sequence s) v) :: Type #

Methods

fromList :: [Item (Tensor s (Sequence s) v)] -> Tensor s (Sequence s) v #

fromListN :: Int -> [Item (Tensor s (Sequence s) v)] -> Tensor s (Sequence s) v #

toList :: Tensor s (Sequence s) v -> [Item (Tensor s (Sequence s) v)] #

(FiniteDimensional v, v ~ DualVector v, Show v, TensorDecomposable x, TensorDecomposable y, Scalar x ~ s, Scalar y ~ s, Scalar v ~ s) => Show (Tensor s (x, y) v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Methods

showsPrec :: Int -> Tensor s (x, y) v -> ShowS #

show :: Tensor s (x, y) v -> String #

showList :: [Tensor s (x, y) v] -> ShowS #

Show (Tensor s (V0 s) v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Methods

showsPrec :: Int -> Tensor s (V0 s) v -> ShowS #

show :: Tensor s (V0 s) v -> String #

showList :: [Tensor s (V0 s) v] -> ShowS #

(LSpace u, FiniteDimensional (DualVector u), LSpace v, FiniteFreeSpace v, Scalar u ~ s, Scalar v ~ s, Scalar (DualVector u) ~ s, Scalar (DualVector v) ~ s) => FiniteFreeSpace (Tensor s u v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Methods

freeDimension :: Functor p => p (Tensor s u v) -> Int #

toFullUnboxVect :: Tensor s u v -> Vector (Scalar (Tensor s u v)) #

unsafeFromFullUnboxVect :: Vector (Scalar (Tensor s u v)) -> Tensor s u v #

fromUnboxVect :: Vector (Scalar (Tensor s u v)) -> Tensor s u v #

(TensorSpace v, TensorSpace w, Scalar v ~ s, Scalar w ~ s) => AdditiveGroup (Tensor s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

zeroV :: Tensor s v w #

(^+^) :: Tensor s v w -> Tensor s v w -> Tensor s v w #

negateV :: Tensor s v w -> Tensor s v w #

(^-^) :: Tensor s v w -> Tensor s v w -> Tensor s v w #

(TensorSpace v, TensorSpace w, Scalar v ~ s, Scalar w ~ s) => VectorSpace (Tensor s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type Scalar (Tensor s v w) :: Type #

Methods

(*^) :: Scalar (Tensor s v w) -> Tensor s v w -> Tensor s v w #

(TensorSpace u, TensorSpace v, s ~ Scalar u, s ~ Scalar v) => AffineSpace (Tensor s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type Diff (Tensor s u v) :: Type #

Methods

(.-.) :: Tensor s u v -> Tensor s u v -> Diff (Tensor s u v) #

(.+^) :: Tensor s u v -> Diff (Tensor s u v) -> Tensor s u v #

(TensorSpace v, TensorSpace w, Scalar v ~ s, Scalar w ~ s) => Semimanifold (Tensor s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type Needle (Tensor s v w) :: Type #

type Interior (Tensor s v w) :: Type #

Methods

(.+~^) :: Interior (Tensor s v w) -> Needle (Tensor s v w) -> Tensor s v w #

fromInterior :: Interior (Tensor s v w) -> Tensor s v w #

toInterior :: Tensor s v w -> Maybe (Interior (Tensor s v w)) #

translateP :: Tagged (Tensor s v w) (Interior (Tensor s v w) -> Needle (Tensor s v w) -> Interior (Tensor s v w)) #

(.-~^) :: Interior (Tensor s v w) -> Needle (Tensor s v w) -> Tensor s v w #

semimanifoldWitness :: SemimanifoldWitness (Tensor s v w) #

(TensorSpace v, TensorSpace w, Scalar v ~ s, Scalar w ~ s) => PseudoAffine (Tensor s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Methods

(.-~.) :: Tensor s v w -> Tensor s v w -> Maybe (Needle (Tensor s v w)) #

(.-~!) :: Tensor s v w -> Tensor s v w -> Needle (Tensor s v w) #

pseudoAffineWitness :: PseudoAffineWitness (Tensor s v w) #

(LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s) => LinearSpace (Tensor s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type DualVector (Tensor s u v) :: Type Source #

Methods

dualSpaceWitness :: DualSpaceWitness (Tensor s u v) Source #

linearId :: Tensor s u v +> Tensor s u v Source #

idTensor :: Tensor s u v DualVector (Tensor s u v) Source #

sampleLinearFunction :: (TensorSpace w, Scalar (Tensor s u v) ~ Scalar w) => (Tensor s u v -+> w) -+> (Tensor s u v +> w) Source #

toLinearForm :: DualVector (Tensor s u v) -+> (Tensor s u v +> Scalar (Tensor s u v)) Source #

fromLinearForm :: (Tensor s u v +> Scalar (Tensor s u v)) -+> DualVector (Tensor s u v) Source #

coerceDoubleDual :: Coercion (Tensor s u v) (DualVector (DualVector (Tensor s u v))) Source #

trace :: (Tensor s u v +> Tensor s u v) -+> Scalar (Tensor s u v) Source #

contractTensorMap :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v +> (Tensor s u v w)) -+> w Source #

contractMapTensor :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v (Tensor s u v +> w)) -+> w Source #

contractTensorFn :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v -+> (Tensor s u v w)) -+> w Source #

contractLinearMapAgainst :: (LinearSpace w, Scalar w ~ Scalar (Tensor s u v)) => Bilinear (Tensor s u v +> w) (w -+> Tensor s u v) (Scalar (Tensor s u v)) Source #

applyDualVector :: Bilinear (DualVector (Tensor s u v)) (Tensor s u v) (Scalar (Tensor s u v)) Source #

applyLinear :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => Bilinear (Tensor s u v +> w) (Tensor s u v) w Source #

composeLinear :: (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) Source #

tensorId :: (LinearSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v w) +> (Tensor s u v w) Source #

applyTensorFunctional :: (LinearSpace u0, Scalar u0 ~ Scalar (Tensor s u v)) => Bilinear (DualVector (Tensor s u v u0)) (Tensor s u v u0) (Scalar (Tensor s u v)) Source #

applyTensorLinMap :: (LinearSpace u0, TensorSpace w, Scalar u0 ~ Scalar (Tensor s u v), Scalar w ~ Scalar (Tensor s u v)) => Bilinear ((Tensor s u v u0) +> w) (Tensor s u v u0) w Source #

(TensorSpace u, TensorSpace v, Scalar u ~ s, Scalar v ~ s) => TensorSpace (Tensor s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type TensorProduct (Tensor s u v) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (Tensor s u v) Source #

linearManifoldWitness :: LinearManifoldWitness (Tensor s u v) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => Tensor s u v w Source #

toFlatTensor :: Tensor s u v -+> (Tensor s u v Scalar (Tensor s u v)) Source #

fromFlatTensor :: (Tensor s u v Scalar (Tensor s u v)) -+> Tensor s u v Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v w) -> (Tensor s u v w) -> Tensor s u v w Source #

subtractTensors :: (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 Source #

scaleTensor :: (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) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v w) -+> (Tensor s u v w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => Bilinear (Tensor s u v) w (Tensor s u v w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => [(Tensor s u v, w)] -> Tensor s u v w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v w) -+> (w Tensor s u v) Source #

fmapTensor :: (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) Source #

fzipTensorWith :: (TensorSpace u0, TensorSpace w, TensorSpace x, Scalar u0 ~ Scalar (Tensor s u v), Scalar w ~ Scalar (Tensor s u v), Scalar x ~ Scalar (Tensor s u v)) => Bilinear ((w, x) -+> u0) (Tensor s u v w, Tensor s u v x) (Tensor s u v u0) Source #

coerceFmapTensorProduct :: Functor p => p (Tensor s u v) -> Coercion a b -> Coercion (TensorProduct (Tensor s u v) a) (TensorProduct (Tensor s u v) b) Source #

wellDefinedVector :: Tensor s u v -> Maybe (Tensor s u v) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v w) -> Maybe (Tensor s u v w) Source #

(FiniteDimensional u, FiniteDimensional v, Scalar u ~ s, Scalar v ~ s, Scalar (DualVector u) ~ s, Scalar (DualVector v) ~ s, Fractional' (Scalar v)) => FiniteDimensional (Tensor s u v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Associated Types

data SubBasis (Tensor s u v) :: Type Source #

Methods

entireBasis :: SubBasis (Tensor s u v) Source #

enumerateSubBasis :: SubBasis (Tensor s u v) -> [Tensor s u v] Source #

subbasisDimension :: SubBasis (Tensor s u v) -> Int Source #

decomposeLinMap :: (LSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v +> w) -> (SubBasis (Tensor s u v), DList w) Source #

decomposeLinMapWithin :: (LSpace w, Scalar w ~ Scalar (Tensor s u v)) => SubBasis (Tensor s u v) -> (Tensor s u v +> w) -> Either (SubBasis (Tensor s u v), DList w) (DList w) Source #

recomposeSB :: SubBasis (Tensor s u v) -> [Scalar (Tensor s u v)] -> (Tensor s u v, [Scalar (Tensor s u v)]) Source #

recomposeSBTensor :: (FiniteDimensional w, Scalar w ~ Scalar (Tensor s u v)) => SubBasis (Tensor s u v) -> SubBasis w -> [Scalar (Tensor s u v)] -> (Tensor s u v w, [Scalar (Tensor s u v)]) Source #

recomposeLinMap :: (LSpace w, Scalar w ~ Scalar (Tensor s u v)) => SubBasis (Tensor s u v) -> [w] -> (Tensor s u v +> w, [w]) Source #

recomposeContraLinMap :: (LinearSpace w, Scalar w ~ Scalar (Tensor s u v), Functor f) => (f (Scalar w) -> w) -> f (DualVector (Tensor s u v)) -> Tensor s u v +> w Source #

recomposeContraLinMapTensor :: (FiniteDimensional u0, LinearSpace w, Scalar u0 ~ Scalar (Tensor s u v), Scalar w ~ Scalar (Tensor s u v), Functor f) => (f (Scalar w) -> w) -> f (Tensor s u v +> DualVector u0) -> (Tensor s u v u0) +> w Source #

uncanonicallyFromDual :: DualVector (Tensor s u v) -+> Tensor s u v Source #

uncanonicallyToDual :: Tensor s u v -+> DualVector (Tensor s u v) Source #

(SemiInner u, SemiInner v, Scalar u ~ s, Scalar v ~ s) => SemiInner (Tensor s u v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

type Item (Tensor s (FinSuppSeq s) v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

type Item (Tensor s (FinSuppSeq s) v) = v
type Item (Tensor s (Sequence s) v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

type Item (Tensor s (Sequence s) v) = v
type Scalar (Tensor s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Scalar (Tensor s v w) = s
type Diff (Tensor s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Diff (Tensor s u v) = Tensor s u v
type Interior (Tensor s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Interior (Tensor s v w) = Tensor s v w
type Needle (Tensor s v w) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type Needle (Tensor s v w) = Tensor s v w
type DualVector (Tensor s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type DualVector (Tensor s u v) = LinearMap s u (DualVector v)
data SubBasis (Tensor s u v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

data SubBasis (Tensor s u v) = TensorBasis !(SubBasis u) !(SubBasis v)
type TensorProduct (Tensor s u v) w Source # 
Instance details

Defined in Math.LinearMap.Category.Class

type TensorProduct (Tensor s u v) w = TensorProduct u (Tensor s v w)

type (⊗) v w = Tensor (Scalar v) v w infixl 7 Source #

Infix synonym for Tensor, without explicit mention of the scalar type.

(⊗) :: forall v w. (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v, Num' (Scalar v)) => v -> w -> v w infixl 7 Source #

Infix version of tensorProduct.

Symmetric

newtype SymmetricTensor s v Source #

Constructors

SymTensor 

Fields

Instances
Show (SubBasis v) => Show (SubBasis (SymmetricTensor s v)) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Show (Tensor s v v) => Show (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

(TensorSpace v, Scalar v ~ s) => AdditiveGroup (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

(TensorSpace v, Scalar v ~ s) => VectorSpace (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type Scalar (SymmetricTensor s v) :: Type #

(TensorSpace v, Scalar v ~ s) => AffineSpace (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type Diff (SymmetricTensor s v) :: Type #

(TensorSpace v, Scalar v ~ s) => Semimanifold (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type Needle (SymmetricTensor s v) :: Type #

type Interior (SymmetricTensor s v) :: Type #

(TensorSpace v, Scalar v ~ s) => PseudoAffine (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

(Num' s, LinearSpace v, Scalar v ~ s) => LinearSpace (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type DualVector (SymmetricTensor s v) :: Type Source #

Methods

dualSpaceWitness :: DualSpaceWitness (SymmetricTensor s v) Source #

linearId :: SymmetricTensor s v +> SymmetricTensor s v Source #

idTensor :: SymmetricTensor s v DualVector (SymmetricTensor s v) Source #

sampleLinearFunction :: (TensorSpace w, Scalar (SymmetricTensor s v) ~ Scalar w) => (SymmetricTensor s v -+> w) -+> (SymmetricTensor s v +> w) Source #

toLinearForm :: DualVector (SymmetricTensor s v) -+> (SymmetricTensor s v +> Scalar (SymmetricTensor s v)) Source #

fromLinearForm :: (SymmetricTensor s v +> Scalar (SymmetricTensor s v)) -+> DualVector (SymmetricTensor s v) Source #

coerceDoubleDual :: Coercion (SymmetricTensor s v) (DualVector (DualVector (SymmetricTensor s v))) Source #

trace :: (SymmetricTensor s v +> SymmetricTensor s v) -+> Scalar (SymmetricTensor s v) Source #

contractTensorMap :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v +> (SymmetricTensor s v w)) -+> w Source #

contractMapTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v (SymmetricTensor s v +> w)) -+> w Source #

contractTensorFn :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v -+> (SymmetricTensor s v w)) -+> w Source #

contractLinearMapAgainst :: (LinearSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => Bilinear (SymmetricTensor s v +> w) (w -+> SymmetricTensor s v) (Scalar (SymmetricTensor s v)) Source #

applyDualVector :: Bilinear (DualVector (SymmetricTensor s v)) (SymmetricTensor s v) (Scalar (SymmetricTensor s v)) Source #

applyLinear :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => Bilinear (SymmetricTensor s v +> w) (SymmetricTensor s v) w Source #

composeLinear :: (LinearSpace w, TensorSpace x, Scalar w ~ Scalar (SymmetricTensor s v), Scalar x ~ Scalar (SymmetricTensor s v)) => Bilinear (w +> x) (SymmetricTensor s v +> w) (SymmetricTensor s v +> x) Source #

tensorId :: (LinearSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v w) +> (SymmetricTensor s v w) Source #

applyTensorFunctional :: (LinearSpace u, Scalar u ~ Scalar (SymmetricTensor s v)) => Bilinear (DualVector (SymmetricTensor s v u)) (SymmetricTensor s v u) (Scalar (SymmetricTensor s v)) Source #

applyTensorLinMap :: (LinearSpace u, TensorSpace w, Scalar u ~ Scalar (SymmetricTensor s v), Scalar w ~ Scalar (SymmetricTensor s v)) => Bilinear ((SymmetricTensor s v u) +> w) (SymmetricTensor s v u) w Source #

(Num' s, TensorSpace v, Scalar v ~ s) => TensorSpace (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type TensorProduct (SymmetricTensor s v) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (SymmetricTensor s v) Source #

linearManifoldWitness :: LinearManifoldWitness (SymmetricTensor s v) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => SymmetricTensor s v w Source #

toFlatTensor :: SymmetricTensor s v -+> (SymmetricTensor s v Scalar (SymmetricTensor s v)) Source #

fromFlatTensor :: (SymmetricTensor s v Scalar (SymmetricTensor s v)) -+> SymmetricTensor s v Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v w) -> (SymmetricTensor s v w) -> SymmetricTensor s v w Source #

subtractTensors :: (TensorSpace (SymmetricTensor s v), TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v w) -> (SymmetricTensor s v w) -> SymmetricTensor s v w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => Bilinear (Scalar (SymmetricTensor s v)) (SymmetricTensor s v w) (SymmetricTensor s v w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v w) -+> (SymmetricTensor s v w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => Bilinear (SymmetricTensor s v) w (SymmetricTensor s v w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => [(SymmetricTensor s v, w)] -> SymmetricTensor s v w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v w) -+> (w SymmetricTensor s v) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (SymmetricTensor s v), Scalar x ~ Scalar (SymmetricTensor s v)) => Bilinear (w -+> x) (SymmetricTensor s v w) (SymmetricTensor s v x) Source #

fzipTensorWith :: (TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar (SymmetricTensor s v), Scalar w ~ Scalar (SymmetricTensor s v), Scalar x ~ Scalar (SymmetricTensor s v)) => Bilinear ((w, x) -+> u) (SymmetricTensor s v w, SymmetricTensor s v x) (SymmetricTensor s v u) Source #

coerceFmapTensorProduct :: Functor p => p (SymmetricTensor s v) -> Coercion a b -> Coercion (TensorProduct (SymmetricTensor s v) a) (TensorProduct (SymmetricTensor s v) b) Source #

wellDefinedVector :: SymmetricTensor s v -> Maybe (SymmetricTensor s v) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v w) -> Maybe (SymmetricTensor s v w) Source #

(FiniteDimensional v, Scalar v ~ s, Scalar (DualVector v) ~ s, RealFloat' s) => FiniteDimensional (SymmetricTensor s v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

Associated Types

data SubBasis (SymmetricTensor s v) :: Type Source #

Methods

entireBasis :: SubBasis (SymmetricTensor s v) Source #

enumerateSubBasis :: SubBasis (SymmetricTensor s v) -> [SymmetricTensor s v] Source #

subbasisDimension :: SubBasis (SymmetricTensor s v) -> Int Source #

decomposeLinMap :: (LSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v +> w) -> (SubBasis (SymmetricTensor s v), DList w) Source #

decomposeLinMapWithin :: (LSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => SubBasis (SymmetricTensor s v) -> (SymmetricTensor s v +> w) -> Either (SubBasis (SymmetricTensor s v), DList w) (DList w) Source #

recomposeSB :: SubBasis (SymmetricTensor s v) -> [Scalar (SymmetricTensor s v)] -> (SymmetricTensor s v, [Scalar (SymmetricTensor s v)]) Source #

recomposeSBTensor :: (FiniteDimensional w, Scalar w ~ Scalar (SymmetricTensor s v)) => SubBasis (SymmetricTensor s v) -> SubBasis w -> [Scalar (SymmetricTensor s v)] -> (SymmetricTensor s v w, [Scalar (SymmetricTensor s v)]) Source #

recomposeLinMap :: (LSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => SubBasis (SymmetricTensor s v) -> [w] -> (SymmetricTensor s v +> w, [w]) Source #

recomposeContraLinMap :: (LinearSpace w, Scalar w ~ Scalar (SymmetricTensor s v), Functor f) => (f (Scalar w) -> w) -> f (DualVector (SymmetricTensor s v)) -> SymmetricTensor s v +> w Source #

recomposeContraLinMapTensor :: (FiniteDimensional u, LinearSpace w, Scalar u ~ Scalar (SymmetricTensor s v), Scalar w ~ Scalar (SymmetricTensor s v), Functor f) => (f (Scalar w) -> w) -> f (SymmetricTensor s v +> DualVector u) -> (SymmetricTensor s v u) +> w Source #

uncanonicallyFromDual :: DualVector (SymmetricTensor s v) -+> SymmetricTensor s v Source #

uncanonicallyToDual :: SymmetricTensor s v -+> DualVector (SymmetricTensor s v) Source #

(Num' s, SemiInner v, Scalar v ~ s) => SemiInner (SymmetricTensor s v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

type Scalar (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

type Scalar (SymmetricTensor s v) = s
type Diff (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

type Interior (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

type Needle (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

type DualVector (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

newtype SubBasis (SymmetricTensor s v) Source # 
Instance details

Defined in Math.VectorSpace.Docile

type TensorProduct (SymmetricTensor s v) x Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

type TensorProduct (SymmetricTensor s v) x = Tensor s v (Tensor s v x)

squareV :: (Num' s, s ~ Scalar v) => TensorSpace v => v -> SymmetricTensor s v Source #

squareVs :: (Num' s, s ~ Scalar v) => TensorSpace v => [v] -> SymmetricTensor s v Source #

currySymBilin :: LinearSpace v => (v ⊗〃+> w) -+> (v +> (v +> w)) Source #

Norms

A norm is a way to quantify the magnitude/length of different vectors, even if they point in different directions.

In an InnerSpace, a norm is always given by the scalar product, but there are spaces without a canonical scalar product (or situations in which this scalar product does not give the metric you want). Hence, we let the functions like constructEigenSystem, which depend on a norm for orthonormalisation, accept a Norm as an extra argument instead of requiring InnerSpace.

newtype Norm v Source #

A positive (semi)definite symmetric bilinear form. This gives rise to a norm thus:

  Norm n |$| v = √(n v <.>^ v)
  

Strictly speaking, this type is neither strong enough nor general enough to deserve the name Norm: it includes proper Seminorms (i.e. m|$|v ≡ 0 does not guarantee v == zeroV), but not actual norms such as the ℓ₁-norm on ℝⁿ (Taxcab norm) or the supremum norm. However, 𝐿₂-like norms are the only ones that can really be formulated without any basis reference; and guaranteeing positive definiteness through the type system is scarcely practical.

Constructors

Norm 

Fields

Instances
(SimpleSpace v, Show (DualVector v)) => Show (Norm v) Source # 
Instance details

Defined in Math.LinearMap.Category

Methods

showsPrec :: Int -> Norm v -> ShowS #

show :: Norm v -> String #

showList :: [Norm v] -> ShowS #

LSpace v => Semigroup (Norm v) Source #
(m<>n|$|v)^2 ⩵ (m|$|v)^2 + (n|$|v)^2
Instance details

Defined in Math.LinearMap.Category

Methods

(<>) :: Norm v -> Norm v -> Norm v #

sconcat :: NonEmpty (Norm v) -> Norm v #

stimes :: Integral b => b -> Norm v -> Norm v #

LSpace v => Monoid (Seminorm v) Source #
mempty|$|v ≡ 0
Instance details

Defined in Math.LinearMap.Category

Methods

mempty :: Seminorm v #

mappend :: Seminorm v -> Seminorm v -> Seminorm v #

mconcat :: [Seminorm v] -> Seminorm v #

type Seminorm v = Norm v Source #

A “norm” that may explicitly be degenerate, with m|$|v ⩵ 0 for some v ≠ zeroV.

spanNorm :: forall v. LSpace v => [DualVector v] -> Seminorm v Source #

A seminorm defined by

‖v‖ = √(∑ᵢ ⟨dᵢ|v⟩²)

for some dual vectors dᵢ. If given a complete basis of the dual space, this generates a proper Norm.

If the dᵢ are a complete orthonormal system, you get the euclideanNorm (in an inefficient form).

euclideanNorm :: HilbertSpace v => Norm v Source #

The canonical standard norm (2-norm) on inner-product / Hilbert spaces.

(|$|) :: (LSpace v, Floating (Scalar v)) => Seminorm v -> v -> Scalar v infixr 0 Source #

Use a Norm to measure the length / norm of a vector.

euclideanNorm |$| v  ≡  √(v <.> v)

normSq :: LSpace v => Seminorm v -> v -> Scalar v Source #

The squared norm. More efficient than |$| because that needs to take the square root.

(<$|) :: LSpace v => Norm v -> v -> DualVector v infixr 0 Source #

“Partially apply” a norm, yielding a dual vector (i.e. a linear form that accepts the second argument of the scalar product).

(euclideanNorm <$| v) <.>^ w  ≡  v <.> w

See also |&>.

scaleNorm :: forall v. LSpace v => Scalar v -> Norm v -> Norm v Source #

Scale the result of a norm with the absolute of the given number.

scaleNorm μ n |$| v = abs μ * (n|$|v)

Equivalently, this scales the norm's unit ball by the reciprocal of that factor.

Variances

type Variance v = Norm (DualVector v) Source #

A multidimensional variance of points v with some distribution can be considered a norm on the dual space, quantifying for a dual vector dv the expectation value of (dv.^v)^2.

spanVariance :: forall v. LSpace v => [v] -> Variance v Source #

(|&>) :: LSpace v => DualVector v -> Variance v -> v infixl 1 Source #

Flipped, “ket” version of <$|.

v <.>^ (w |&> euclideanNorm)  ≡  v <.> w

varianceSpanningSystem :: forall v. SimpleSpace v => Variance v -> [v] Source #

Inverse of spanVariance. Equivalent to normSpanningSystem on the dual space.

dualNorm :: SimpleSpace v => Norm v -> Variance v Source #

A proper norm induces a norm on the dual space – the “reciprocal norm”. (The orthonormal systems of the norm and its dual are mutually conjugate.) The dual norm of a seminorm is undefined.

dualNorm' :: forall v. SimpleSpace v => Variance v -> Norm v Source #

dualNorm in the opposite direction. This is actually self-inverse; with dualSpaceWitness you can replace each with the other direction.

dependence :: forall u v. (SimpleSpace u, SimpleSpace v, Scalar u ~ Scalar v) => Variance (u, v) -> u +> v Source #

Interpret a variance as a covariance between two subspaces, and normalise it by the variance on u. The result is effectively the linear regression coefficient of a simple regression of the vectors spanning the variance.

Utility

densifyNorm :: forall v. LSpace v => Norm v -> Norm v Source #

spanNorm / spanVariance are inefficient if the number of vectors is similar to the dimension of the space, or even larger than it. Use this function to optimise the underlying operator to a dense matrix representation.

wellDefinedNorm :: forall v. LinearSpace v => Norm v -> Maybe (Norm v) Source #

Like densifyNorm, but also perform a “sanity check” to eliminate NaN etc. problems.

Solving linear equations

(\$) :: forall u v. (SimpleSpace u, SimpleSpace v, Scalar u ~ Scalar v) => (u +> v) -> v -> u infixr 0 Source #

Inverse function application, aka solving of a linear system:

f \$ f $ v  ≡  v

f $ f \$ u  ≡  u

If f does not have full rank, the behaviour is undefined. However, it does not need to be a proper isomorphism: the first of the above equations is still fulfilled if only f is injective (overdetermined system) and the second if it is surjective.

If you want to solve for multiple RHS vectors, be sure to partially apply this operator to the linear map, like

map (f \$) [v₁, v₂, ...]

Since most of the work is actually done in triangularising the operator, this may be much faster than

[f \$ v₁, f \$ v₂, ...]

pseudoInverse :: forall u v. (SimpleSpace u, SimpleSpace v, Scalar u ~ Scalar v) => (u +> v) -> v +> u Source #

roughDet :: (FiniteDimensional v, IEEE (Scalar v)) => (v +> v) -> Scalar v Source #

Approximation of the determinant.

linearRegressionW :: forall s x m y. (LinearSpace x, SimpleSpace y, SimpleSpace m, Scalar x ~ s, Scalar y ~ s, Scalar m ~ s, RealFrac' s) => Norm y -> (x -> m +> y) -> [(x, y)] -> m Source #

Simple wrapper of linearRegression.

linearRegression :: forall s x m y. (LinearSpace x, SimpleSpace y, SimpleSpace m, Scalar x ~ s, Scalar y ~ s, Scalar m ~ s, RealFrac' s) => (x -> m +> y) -> [(x, (y, Norm y))] -> LinearRegressionResult x y m Source #

linearFit_χν² :: LinearRegressionResult x y m -> Scalar m Source #

How well the data uncertainties match the deviations from the model's synthetic data. χν² = 1ν · ∑ δy² σy² Where ν is the number of degrees of freedom (data values minus model parameters), δy = m x - yd is the deviation from given data to the data the model would predict (for each sample point), and σy is the a-priori measurement uncertainty of the data points.

Values χν²>1 indicate that the data could not be described satisfyingly; χν²≪1 suggests overfitting or that the data uncertainties have been postulated too high.

http://adsabs.harvard.edu/abs/1997ieas.book.....T

If the model is exactly determined or even underdetermined (i.e. ν≤0) then χν² is undefined.

linearFit_bestModel :: LinearRegressionResult x y m -> m Source #

The model that best corresponds to the data, in a least-squares sense WRT the supplied norm on the data points. In other words, this is the model that minimises ∑ δy² / σy².

Eigenvalue problems

eigen :: (FiniteDimensional v, HilbertSpace v, IEEE (Scalar v)) => (v +> v) -> [(Scalar v, v)] Source #

Simple automatic finding of the eigenvalues and -vectors of a Hermitian operator, in reasonable approximation.

This works by spanning a QR-stabilised Krylov basis with constructEigenSystem until it is complete (roughEigenSystem), and then properly decoupling the system with finishEigenSystem (based on two iterations of shifted Givens rotations).

This function is a tradeoff in performance vs. accuracy. Use constructEigenSystem and finishEigenSystem directly for more quickly computing a (perhaps incomplete) approximation, or for more precise results.

constructEigenSystem Source #

Arguments

:: (LSpace v, RealFloat (Scalar v)) 
=> Norm v

The notion of orthonormality.

-> Scalar v

Error bound for deviations from eigen-ness.

-> (v -+> v)

Operator to calculate the eigensystem of. Must be Hermitian WRT the scalar product defined by the given metric.

-> [v]

Starting vector(s) for the power method.

-> [[Eigenvector v]]

Infinite sequence of ever more accurate approximations to the eigensystem of the operator.

Lazily compute the eigenbasis of a linear map. The algorithm is essentially a hybrid of Lanczos/Arnoldi style Krylov-spanning and QR-diagonalisation, which we don't do separately but interleave at each step.

The size of the eigen-subbasis increases with each step until the space's dimension is reached. (But the algorithm can also be used for infinite-dimensional spaces.)

roughEigenSystem :: (FiniteDimensional v, IEEE (Scalar v)) => Norm v -> (v +> v) -> [Eigenvector v] Source #

Find a system of vectors that approximate the eigensytem, in the sense that: each true eigenvalue is represented by an approximate one, and that is closer to the true value than all the other approximate EVs.

This function does not make any guarantees as to how well a single eigenvalue is approximated, though.

finishEigenSystem :: forall v. (LSpace v, RealFloat (Scalar v)) => Norm v -> [Eigenvector v] -> [Eigenvector v] Source #

data Eigenvector v Source #

Constructors

Eigenvector 

Fields

Instances
(Show v, Show (Scalar v)) => Show (Eigenvector v) Source # 
Instance details

Defined in Math.LinearMap.Category

The classes of suitable vector spaces

type LSpace v = (LinearSpace v, LinearSpace (Scalar v), LinearSpace (DualVector v), Num' (Scalar v)) Source #

The workhorse of this package: most functions here work on vector spaces that fulfill the LSpace v constraint.

In summary, this is a VectorSpace with an implementation for TensorProduct v w, for any other space w, and with a DualVector space. This fulfills DualVector (DualVector v) ~ v (this constraint is encapsulated in DualSpaceWitness).

To make a new space of yours an LSpace, you must define instances of TensorSpace and LinearSpace. In fact, LSpace is equivalent to LinearSpace, but makes the condition explicit that the scalar and dual vectors also form a linear space. LinearSpace only stores that constraint in dualSpaceWitness (to avoid UndecidableSuperclasses).

class (VectorSpace v, PseudoAffine v) => TensorSpace v where Source #

Associated Types

type TensorProduct v w :: * Source #

The internal representation of a Tensor product.

For Euclidean spaces, this is generally constructed by replacing each s scalar field in the v vector with an entire w vector. I.e., you have then a “nested vector” or, if v is a DualVector / “row vector”, a matrix.

Methods

scalarSpaceWitness :: ScalarSpaceWitness v Source #

linearManifoldWitness :: LinearManifoldWitness v Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar v) => v w Source #

toFlatTensor :: v -+> (v Scalar v) Source #

fromFlatTensor :: (v Scalar v) -+> v Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar v) => (v w) -> (v w) -> v w Source #

addTensors :: AdditiveGroup (TensorProduct v w) => (v w) -> (v w) -> v w Source #

subtractTensors :: (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) => (v w) -> (v w) -> v w Source #

subtractTensors :: AdditiveGroup (TensorProduct v w) => (v w) -> (v w) -> v w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar v) => Bilinear (Scalar v) (v w) (v w) Source #

scaleTensor :: (VectorSpace (TensorProduct v w), Scalar (TensorProduct v w) ~ Scalar v) => Bilinear (Scalar v) (v w) (v w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar v) => (v w) -+> (v w) Source #

negateTensor :: AdditiveGroup (TensorProduct v w) => (v w) -+> (v w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar v) => Bilinear v w (v w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar v) => [(v, w)] -> v w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar v) => (v w) -+> (w v) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar v, Scalar x ~ Scalar v) => Bilinear (w -+> x) (v w) (v x) Source #

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) Source #

coerceFmapTensorProduct :: Functor p => p v -> Coercion a b -> Coercion (TensorProduct v a) (TensorProduct v b) Source #

wellDefinedVector :: v -> Maybe v Source #

“Sanity-check” a vector. This typically amounts to detecting any NaN components, which should trigger a Nothing result. Otherwise, the result should be Just the input, but may also be optimised / memoised if applicable (i.e. for function spaces).

wellDefinedVector :: Eq v => v -> Maybe v Source #

“Sanity-check” a vector. This typically amounts to detecting any NaN components, which should trigger a Nothing result. Otherwise, the result should be Just the input, but may also be optimised / memoised if applicable (i.e. for function spaces).

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar v) => (v w) -> Maybe (v w) Source #

Instances
TensorSpace Rational Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type TensorProduct Rational w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness Rational Source #

linearManifoldWitness :: LinearManifoldWitness Rational Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar Rational) => Rational w Source #

toFlatTensor :: Rational -+> (Rational Scalar Rational) Source #

fromFlatTensor :: (Rational Scalar Rational) -+> Rational Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar Rational) => (Rational w) -> (Rational w) -> Rational w Source #

subtractTensors :: (TensorSpace Rational, TensorSpace w, Scalar w ~ Scalar Rational) => (Rational w) -> (Rational w) -> Rational w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar Rational) => Bilinear (Scalar Rational) (Rational w) (Rational w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar Rational) => (Rational w) -+> (Rational w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar Rational) => Bilinear Rational w (Rational w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar Rational) => [(Rational, w)] -> Rational w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar Rational) => (Rational w) -+> (w Rational) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar Rational, Scalar x ~ Scalar Rational) => Bilinear (w -+> x) (Rational w) (Rational x) Source #

fzipTensorWith :: (TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar Rational, Scalar w ~ Scalar Rational, Scalar x ~ Scalar Rational) => Bilinear ((w, x) -+> u) (Rational w, Rational x) (Rational u) Source #

coerceFmapTensorProduct :: Functor p => p Rational -> Coercion a b -> Coercion (TensorProduct Rational a) (TensorProduct Rational b) Source #

wellDefinedVector :: Rational -> Maybe Rational Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar Rational) => (Rational w) -> Maybe (Rational w) Source #

(Num' n, Unbox n) => TensorSpace (Sequence n) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type TensorProduct (Sequence n) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (Sequence n) Source #

linearManifoldWitness :: LinearManifoldWitness (Sequence n) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (Sequence n)) => Sequence n w Source #

toFlatTensor :: Sequence n -+> (Sequence n Scalar (Sequence n)) Source #

fromFlatTensor :: (Sequence n Scalar (Sequence n)) -+> Sequence n Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (Sequence n)) => (Sequence n w) -> (Sequence n w) -> Sequence n w Source #

subtractTensors :: (TensorSpace (Sequence n), TensorSpace w, Scalar w ~ Scalar (Sequence n)) => (Sequence n w) -> (Sequence n w) -> Sequence n w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (Sequence n)) => Bilinear (Scalar (Sequence n)) (Sequence n w) (Sequence n w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (Sequence n)) => (Sequence n w) -+> (Sequence n w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (Sequence n)) => Bilinear (Sequence n) w (Sequence n w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (Sequence n)) => [(Sequence n, w)] -> Sequence n w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (Sequence n)) => (Sequence n w) -+> (w Sequence n) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (Sequence n), Scalar x ~ Scalar (Sequence n)) => Bilinear (w -+> x) (Sequence n w) (Sequence n x) Source #

fzipTensorWith :: (TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar (Sequence n), Scalar w ~ Scalar (Sequence n), Scalar x ~ Scalar (Sequence n)) => Bilinear ((w, x) -+> u) (Sequence n w, Sequence n x) (Sequence n u) Source #

coerceFmapTensorProduct :: Functor p => p (Sequence n) -> Coercion a b -> Coercion (TensorProduct (Sequence n) a) (TensorProduct (Sequence n) b) Source #

wellDefinedVector :: Sequence n -> Maybe (Sequence n) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (Sequence n)) => (Sequence n w) -> Maybe (Sequence n w) Source #

(Num' n, Unbox n) => TensorSpace (FinSuppSeq n) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type TensorProduct (FinSuppSeq n) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (FinSuppSeq n) Source #

linearManifoldWitness :: LinearManifoldWitness (FinSuppSeq n) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (FinSuppSeq n)) => FinSuppSeq n w Source #

toFlatTensor :: FinSuppSeq n -+> (FinSuppSeq n Scalar (FinSuppSeq n)) Source #

fromFlatTensor :: (FinSuppSeq n Scalar (FinSuppSeq n)) -+> FinSuppSeq n Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (FinSuppSeq n)) => (FinSuppSeq n w) -> (FinSuppSeq n w) -> FinSuppSeq n w Source #

subtractTensors :: (TensorSpace (FinSuppSeq n), TensorSpace w, Scalar w ~ Scalar (FinSuppSeq n)) => (FinSuppSeq n w) -> (FinSuppSeq n w) -> FinSuppSeq n w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (FinSuppSeq n)) => Bilinear (Scalar (FinSuppSeq n)) (FinSuppSeq n w) (FinSuppSeq n w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (FinSuppSeq n)) => (FinSuppSeq n w) -+> (FinSuppSeq n w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (FinSuppSeq n)) => Bilinear (FinSuppSeq n) w (FinSuppSeq n w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (FinSuppSeq n)) => [(FinSuppSeq n, w)] -> FinSuppSeq n w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (FinSuppSeq n)) => (FinSuppSeq n w) -+> (w FinSuppSeq n) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (FinSuppSeq n), Scalar x ~ Scalar (FinSuppSeq n)) => Bilinear (w -+> x) (FinSuppSeq n w) (FinSuppSeq n x) Source #

fzipTensorWith :: (TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar (FinSuppSeq n), Scalar w ~ Scalar (FinSuppSeq n), Scalar x ~ Scalar (FinSuppSeq n)) => Bilinear ((w, x) -+> u) (FinSuppSeq n w, FinSuppSeq n x) (FinSuppSeq n u) Source #

coerceFmapTensorProduct :: Functor p => p (FinSuppSeq n) -> Coercion a b -> Coercion (TensorProduct (FinSuppSeq n) a) (TensorProduct (FinSuppSeq n) b) Source #

wellDefinedVector :: FinSuppSeq n -> Maybe (FinSuppSeq n) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (FinSuppSeq n)) => (FinSuppSeq n w) -> Maybe (FinSuppSeq n w) Source #

(Num' s, Eq s) => TensorSpace (V1 s) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type TensorProduct (V1 s) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (V1 s) Source #

linearManifoldWitness :: LinearManifoldWitness (V1 s) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (V1 s)) => V1 s w Source #

toFlatTensor :: V1 s -+> (V1 s Scalar (V1 s)) Source #

fromFlatTensor :: (V1 s Scalar (V1 s)) -+> V1 s Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (V1 s)) => (V1 s w) -> (V1 s w) -> V1 s w Source #

subtractTensors :: (TensorSpace (V1 s), TensorSpace w, Scalar w ~ Scalar (V1 s)) => (V1 s w) -> (V1 s w) -> V1 s w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (V1 s)) => Bilinear (Scalar (V1 s)) (V1 s w) (V1 s w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (V1 s)) => (V1 s w) -+> (V1 s w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (V1 s)) => Bilinear (V1 s) w (V1 s w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (V1 s)) => [(V1 s, w)] -> V1 s w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (V1 s)) => (V1 s w) -+> (w V1 s) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (V1 s), Scalar x ~ Scalar (V1 s)) => Bilinear (w -+> x) (V1 s w) (V1 s x) Source #

fzipTensorWith :: (TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar (V1 s), Scalar w ~ Scalar (V1 s), Scalar x ~ Scalar (V1 s)) => Bilinear ((w, x) -+> u) (V1 s w, V1 s x) (V1 s u) Source #

coerceFmapTensorProduct :: Functor p => p (V1 s) -> Coercion a b -> Coercion (TensorProduct (V1 s) a) (TensorProduct (V1 s) b) Source #

wellDefinedVector :: V1 s -> Maybe (V1 s) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (V1 s)) => (V1 s w) -> Maybe (V1 s w) Source #

(Num' s, Eq s) => TensorSpace (V2 s) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type TensorProduct (V2 s) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (V2 s) Source #

linearManifoldWitness :: LinearManifoldWitness (V2 s) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (V2 s)) => V2 s w Source #

toFlatTensor :: V2 s -+> (V2 s Scalar (V2 s)) Source #

fromFlatTensor :: (V2 s Scalar (V2 s)) -+> V2 s Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (V2 s)) => (V2 s w) -> (V2 s w) -> V2 s w Source #

subtractTensors :: (TensorSpace (V2 s), TensorSpace w, Scalar w ~ Scalar (V2 s)) => (V2 s w) -> (V2 s w) -> V2 s w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (V2 s)) => Bilinear (Scalar (V2 s)) (V2 s w) (V2 s w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (V2 s)) => (V2 s w) -+> (V2 s w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (V2 s)) => Bilinear (V2 s) w (V2 s w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (V2 s)) => [(V2 s, w)] -> V2 s w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (V2 s)) => (V2 s w) -+> (w V2 s) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (V2 s), Scalar x ~ Scalar (V2 s)) => Bilinear (w -+> x) (V2 s w) (V2 s x) Source #

fzipTensorWith :: (TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar (V2 s), Scalar w ~ Scalar (V2 s), Scalar x ~ Scalar (V2 s)) => Bilinear ((w, x) -+> u) (V2 s w, V2 s x) (V2 s u) Source #

coerceFmapTensorProduct :: Functor p => p (V2 s) -> Coercion a b -> Coercion (TensorProduct (V2 s) a) (TensorProduct (V2 s) b) Source #

wellDefinedVector :: V2 s -> Maybe (V2 s) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (V2 s)) => (V2 s w) -> Maybe (V2 s w) Source #

(Num' s, Eq s) => TensorSpace (V3 s) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type TensorProduct (V3 s) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (V3 s) Source #

linearManifoldWitness :: LinearManifoldWitness (V3 s) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (V3 s)) => V3 s w Source #

toFlatTensor :: V3 s -+> (V3 s Scalar (V3 s)) Source #

fromFlatTensor :: (V3 s Scalar (V3 s)) -+> V3 s Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (V3 s)) => (V3 s w) -> (V3 s w) -> V3 s w Source #

subtractTensors :: (TensorSpace (V3 s), TensorSpace w, Scalar w ~ Scalar (V3 s)) => (V3 s w) -> (V3 s w) -> V3 s w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (V3 s)) => Bilinear (Scalar (V3 s)) (V3 s w) (V3 s w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (V3 s)) => (V3 s w) -+> (V3 s w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (V3 s)) => Bilinear (V3 s) w (V3 s w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (V3 s)) => [(V3 s, w)] -> V3 s w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (V3 s)) => (V3 s w) -+> (w V3 s) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (V3 s), Scalar x ~ Scalar (V3 s)) => Bilinear (w -+> x) (V3 s w) (V3 s x) Source #

fzipTensorWith :: (TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar (V3 s), Scalar w ~ Scalar (V3 s), Scalar x ~ Scalar (V3 s)) => Bilinear ((w, x) -+> u) (V3 s w, V3 s x) (V3 s u) Source #

coerceFmapTensorProduct :: Functor p => p (V3 s) -> Coercion a b -> Coercion (TensorProduct (V3 s) a) (TensorProduct (V3 s) b) Source #

wellDefinedVector :: V3 s -> Maybe (V3 s) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (V3 s)) => (V3 s w) -> Maybe (V3 s w) Source #

(Num' s, Eq s) => TensorSpace (V4 s) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type TensorProduct (V4 s) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (V4 s) Source #

linearManifoldWitness :: LinearManifoldWitness (V4 s) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (V4 s)) => V4 s w Source #

toFlatTensor :: V4 s -+> (V4 s Scalar (V4 s)) Source #

fromFlatTensor :: (V4 s Scalar (V4 s)) -+> V4 s Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (V4 s)) => (V4 s w) -> (V4 s w) -> V4 s w Source #

subtractTensors :: (TensorSpace (V4 s), TensorSpace w, Scalar w ~ Scalar (V4 s)) => (V4 s w) -> (V4 s w) -> V4 s w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (V4 s)) => Bilinear (Scalar (V4 s)) (V4 s w) (V4 s w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (V4 s)) => (V4 s w) -+> (V4 s w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (V4 s)) => Bilinear (V4 s) w (V4 s w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (V4 s)) => [(V4 s, w)] -> V4 s w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (V4 s)) => (V4 s w) -+> (w V4 s) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (V4 s), Scalar x ~ Scalar (V4 s)) => Bilinear (w -+> x) (V4 s w) (V4 s x) Source #

fzipTensorWith :: (TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar (V4 s), Scalar w ~ Scalar (V4 s), Scalar x ~ Scalar (V4 s)) => Bilinear ((w, x) -+> u) (V4 s w, V4 s x) (V4 s u) Source #

coerceFmapTensorProduct :: Functor p => p (V4 s) -> Coercion a b -> Coercion (TensorProduct (V4 s) a) (TensorProduct (V4 s) b) Source #

wellDefinedVector :: V4 s -> Maybe (V4 s) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (V4 s)) => (V4 s w) -> Maybe (V4 s w) Source #

(Num' s, Eq s) => TensorSpace (V0 s) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type TensorProduct (V0 s) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (V0 s) Source #

linearManifoldWitness :: LinearManifoldWitness (V0 s) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (V0 s)) => V0 s w Source #

toFlatTensor :: V0 s -+> (V0 s Scalar (V0 s)) Source #

fromFlatTensor :: (V0 s Scalar (V0 s)) -+> V0 s Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (V0 s)) => (V0 s w) -> (V0 s w) -> V0 s w Source #

subtractTensors :: (TensorSpace (V0 s), TensorSpace w, Scalar w ~ Scalar (V0 s)) => (V0 s w) -> (V0 s w) -> V0 s w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (V0 s)) => Bilinear (Scalar (V0 s)) (V0 s w) (V0 s w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (V0 s)) => (V0 s w) -+> (V0 s w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (V0 s)) => Bilinear (V0 s) w (V0 s w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (V0 s)) => [(V0 s, w)] -> V0 s w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (V0 s)) => (V0 s w) -+> (w V0 s) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (V0 s), Scalar x ~ Scalar (V0 s)) => Bilinear (w -+> x) (V0 s w) (V0 s x) Source #

fzipTensorWith :: (TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar (V0 s), Scalar w ~ Scalar (V0 s), Scalar x ~ Scalar (V0 s)) => Bilinear ((w, x) -+> u) (V0 s w, V0 s x) (V0 s u) Source #

coerceFmapTensorProduct :: Functor p => p (V0 s) -> Coercion a b -> Coercion (TensorProduct (V0 s) a) (TensorProduct (V0 s) b) Source #

wellDefinedVector :: V0 s -> Maybe (V0 s) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (V0 s)) => (V0 s w) -> Maybe (V0 s w) Source #

(Semimanifold m, TensorSpace (Needle (VRep m)), Scalar (Needle m) ~ Scalar (Needle (VRep m))) => TensorSpace (GenericNeedle m) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type TensorProduct (GenericNeedle m) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (GenericNeedle m) Source #

linearManifoldWitness :: LinearManifoldWitness (GenericNeedle m) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) => GenericNeedle m w Source #

toFlatTensor :: GenericNeedle m -+> (GenericNeedle m Scalar (GenericNeedle m)) Source #

fromFlatTensor :: (GenericNeedle m Scalar (GenericNeedle m)) -+> GenericNeedle m Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) => (GenericNeedle m w) -> (GenericNeedle m w) -> GenericNeedle m w Source #

subtractTensors :: (TensorSpace (GenericNeedle m), TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) => (GenericNeedle m w) -> (GenericNeedle m w) -> GenericNeedle m w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) => Bilinear (Scalar (GenericNeedle m)) (GenericNeedle m w) (GenericNeedle m w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) => (GenericNeedle m w) -+> (GenericNeedle m w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) => Bilinear (GenericNeedle m) w (GenericNeedle m w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) => [(GenericNeedle m, w)] -> GenericNeedle m w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) => (GenericNeedle m w) -+> (w GenericNeedle m) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (GenericNeedle m), Scalar x ~ Scalar (GenericNeedle m)) => Bilinear (w -+> x) (GenericNeedle m w) (GenericNeedle m x) Source #

fzipTensorWith :: (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) Source #

coerceFmapTensorProduct :: Functor p => p (GenericNeedle m) -> Coercion a b -> Coercion (TensorProduct (GenericNeedle m) a) (TensorProduct (GenericNeedle m) b) Source #

wellDefinedVector :: GenericNeedle m -> Maybe (GenericNeedle m) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (GenericNeedle m)) => (GenericNeedle m w) -> Maybe (GenericNeedle m w) Source #

Num' s => TensorSpace (ZeroDim s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type TensorProduct (ZeroDim s) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (ZeroDim s) Source #

linearManifoldWitness :: LinearManifoldWitness (ZeroDim s) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) => ZeroDim s w Source #

toFlatTensor :: ZeroDim s -+> (ZeroDim s Scalar (ZeroDim s)) Source #

fromFlatTensor :: (ZeroDim s Scalar (ZeroDim s)) -+> ZeroDim s Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) => (ZeroDim s w) -> (ZeroDim s w) -> ZeroDim s w Source #

subtractTensors :: (TensorSpace (ZeroDim s), TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) => (ZeroDim s w) -> (ZeroDim s w) -> ZeroDim s w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) => Bilinear (Scalar (ZeroDim s)) (ZeroDim s w) (ZeroDim s w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) => (ZeroDim s w) -+> (ZeroDim s w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) => Bilinear (ZeroDim s) w (ZeroDim s w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) => [(ZeroDim s, w)] -> ZeroDim s w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) => (ZeroDim s w) -+> (w ZeroDim s) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (ZeroDim s), Scalar x ~ Scalar (ZeroDim s)) => Bilinear (w -+> x) (ZeroDim s w) (ZeroDim s x) Source #

fzipTensorWith :: (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) Source #

coerceFmapTensorProduct :: Functor p => p (ZeroDim s) -> Coercion a b -> Coercion (TensorProduct (ZeroDim s) a) (TensorProduct (ZeroDim s) b) Source #

wellDefinedVector :: ZeroDim s -> Maybe (ZeroDim s) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (ZeroDim s)) => (ZeroDim s w) -> Maybe (ZeroDim s w) Source #

(TensorSpace u, TensorSpace v, Scalar u ~ Scalar v) => TensorSpace (u, v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type TensorProduct (u, v) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (u, v) Source #

linearManifoldWitness :: LinearManifoldWitness (u, v) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (u, v)) => (u, v) w Source #

toFlatTensor :: (u, v) -+> ((u, v) Scalar (u, v)) Source #

fromFlatTensor :: ((u, v) Scalar (u, v)) -+> (u, v) Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (u, v)) => ((u, v) w) -> ((u, v) w) -> (u, v) w Source #

subtractTensors :: (TensorSpace (u, v), TensorSpace w, Scalar w ~ Scalar (u, v)) => ((u, v) w) -> ((u, v) w) -> (u, v) w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (u, v)) => Bilinear (Scalar (u, v)) ((u, v) w) ((u, v) w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (u, v)) => ((u, v) w) -+> ((u, v) w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (u, v)) => Bilinear (u, v) w ((u, v) w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (u, v)) => [((u, v), w)] -> (u, v) w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (u, v)) => ((u, v) w) -+> (w (u, v)) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (u, v), Scalar x ~ Scalar (u, v)) => Bilinear (w -+> x) ((u, v) w) ((u, v) x) Source #

fzipTensorWith :: (TensorSpace u0, TensorSpace w, TensorSpace x, Scalar u0 ~ Scalar (u, v), Scalar w ~ Scalar (u, v), Scalar x ~ Scalar (u, v)) => Bilinear ((w, x) -+> u0) ((u, v) w, (u, v) x) ((u, v) u0) Source #

coerceFmapTensorProduct :: Functor p => p (u, v) -> Coercion a b -> Coercion (TensorProduct (u, v) a) (TensorProduct (u, v) b) Source #

wellDefinedVector :: (u, v) -> Maybe (u, v) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (u, v)) => ((u, v) w) -> Maybe ((u, v) w) Source #

(Num' s, TensorSpace v, Scalar v ~ s) => TensorSpace (SymmetricTensor s v) Source # 
Instance details

Defined in Math.LinearMap.Category.Instances

Associated Types

type TensorProduct (SymmetricTensor s v) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (SymmetricTensor s v) Source #

linearManifoldWitness :: LinearManifoldWitness (SymmetricTensor s v) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => SymmetricTensor s v w Source #

toFlatTensor :: SymmetricTensor s v -+> (SymmetricTensor s v Scalar (SymmetricTensor s v)) Source #

fromFlatTensor :: (SymmetricTensor s v Scalar (SymmetricTensor s v)) -+> SymmetricTensor s v Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v w) -> (SymmetricTensor s v w) -> SymmetricTensor s v w Source #

subtractTensors :: (TensorSpace (SymmetricTensor s v), TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v w) -> (SymmetricTensor s v w) -> SymmetricTensor s v w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => Bilinear (Scalar (SymmetricTensor s v)) (SymmetricTensor s v w) (SymmetricTensor s v w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v w) -+> (SymmetricTensor s v w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => Bilinear (SymmetricTensor s v) w (SymmetricTensor s v w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => [(SymmetricTensor s v, w)] -> SymmetricTensor s v w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v w) -+> (w SymmetricTensor s v) Source #

fmapTensor :: (TensorSpace w, TensorSpace x, Scalar w ~ Scalar (SymmetricTensor s v), Scalar x ~ Scalar (SymmetricTensor s v)) => Bilinear (w -+> x) (SymmetricTensor s v w) (SymmetricTensor s v x) Source #

fzipTensorWith :: (TensorSpace u, TensorSpace w, TensorSpace x, Scalar u ~ Scalar (SymmetricTensor s v), Scalar w ~ Scalar (SymmetricTensor s v), Scalar x ~ Scalar (SymmetricTensor s v)) => Bilinear ((w, x) -+> u) (SymmetricTensor s v w, SymmetricTensor s v x) (SymmetricTensor s v u) Source #

coerceFmapTensorProduct :: Functor p => p (SymmetricTensor s v) -> Coercion a b -> Coercion (TensorProduct (SymmetricTensor s v) a) (TensorProduct (SymmetricTensor s v) b) Source #

wellDefinedVector :: SymmetricTensor s v -> Maybe (SymmetricTensor s v) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => (SymmetricTensor s v w) -> Maybe (SymmetricTensor s v w) Source #

TensorSpace v => TensorSpace (Rec0 v s) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type TensorProduct (Rec0 v s) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (Rec0 v s) Source #

linearManifoldWitness :: LinearManifoldWitness (Rec0 v s) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) => Rec0 v s w Source #

toFlatTensor :: Rec0 v s -+> (Rec0 v s Scalar (Rec0 v s)) Source #

fromFlatTensor :: (Rec0 v s Scalar (Rec0 v s)) -+> Rec0 v s Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) => (Rec0 v s w) -> (Rec0 v s w) -> Rec0 v s w Source #

subtractTensors :: (TensorSpace (Rec0 v s), TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) => (Rec0 v s w) -> (Rec0 v s w) -> Rec0 v s w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) => Bilinear (Scalar (Rec0 v s)) (Rec0 v s w) (Rec0 v s w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) => (Rec0 v s w) -+> (Rec0 v s w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) => Bilinear (Rec0 v s) w (Rec0 v s w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) => [(Rec0 v s, w)] -> Rec0 v s w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) => (Rec0 v s w) -+> (w Rec0 v s) Source #

fmapTensor :: (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) Source #

fzipTensorWith :: (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) Source #

coerceFmapTensorProduct :: Functor p => p (Rec0 v s) -> Coercion a b -> Coercion (TensorProduct (Rec0 v s) a) (TensorProduct (Rec0 v s) b) Source #

wellDefinedVector :: Rec0 v s -> Maybe (Rec0 v s) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (Rec0 v s)) => (Rec0 v s w) -> Maybe (Rec0 v s w) Source #

(LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s) => TensorSpace (LinearFunction s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type TensorProduct (LinearFunction s u v) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (LinearFunction s u v) Source #

linearManifoldWitness :: LinearManifoldWitness (LinearFunction s u v) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => LinearFunction s u v w Source #

toFlatTensor :: LinearFunction s u v -+> (LinearFunction s u v Scalar (LinearFunction s u v)) Source #

fromFlatTensor :: (LinearFunction s u v Scalar (LinearFunction s u v)) -+> LinearFunction s u v Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v w) -> (LinearFunction s u v w) -> LinearFunction s u v w Source #

subtractTensors :: (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 Source #

scaleTensor :: (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) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v w) -+> (LinearFunction s u v w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => Bilinear (LinearFunction s u v) w (LinearFunction s u v w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => [(LinearFunction s u v, w)] -> LinearFunction s u v w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v w) -+> (w LinearFunction s u v) Source #

fmapTensor :: (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) Source #

fzipTensorWith :: (TensorSpace u0, TensorSpace w, TensorSpace x, Scalar u0 ~ Scalar (LinearFunction s u v), Scalar w ~ Scalar (LinearFunction s u v), Scalar x ~ Scalar (LinearFunction s u v)) => Bilinear ((w, x) -+> u0) (LinearFunction s u v w, LinearFunction s u v x) (LinearFunction s u v u0) Source #

coerceFmapTensorProduct :: Functor p => p (LinearFunction s u v) -> Coercion a b -> Coercion (TensorProduct (LinearFunction s u v) a) (TensorProduct (LinearFunction s u v) b) Source #

wellDefinedVector :: LinearFunction s u v -> Maybe (LinearFunction s u v) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearFunction s u v)) => (LinearFunction s u v w) -> Maybe (LinearFunction s u v w) Source #

(TensorSpace u, TensorSpace v, Scalar u ~ s, Scalar v ~ s) => TensorSpace (Tensor s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type TensorProduct (Tensor s u v) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (Tensor s u v) Source #

linearManifoldWitness :: LinearManifoldWitness (Tensor s u v) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => Tensor s u v w Source #

toFlatTensor :: Tensor s u v -+> (Tensor s u v Scalar (Tensor s u v)) Source #

fromFlatTensor :: (Tensor s u v Scalar (Tensor s u v)) -+> Tensor s u v Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v w) -> (Tensor s u v w) -> Tensor s u v w Source #

subtractTensors :: (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 Source #

scaleTensor :: (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) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v w) -+> (Tensor s u v w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => Bilinear (Tensor s u v) w (Tensor s u v w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => [(Tensor s u v, w)] -> Tensor s u v w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v w) -+> (w Tensor s u v) Source #

fmapTensor :: (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) Source #

fzipTensorWith :: (TensorSpace u0, TensorSpace w, TensorSpace x, Scalar u0 ~ Scalar (Tensor s u v), Scalar w ~ Scalar (Tensor s u v), Scalar x ~ Scalar (Tensor s u v)) => Bilinear ((w, x) -+> u0) (Tensor s u v w, Tensor s u v x) (Tensor s u v u0) Source #

coerceFmapTensorProduct :: Functor p => p (Tensor s u v) -> Coercion a b -> Coercion (TensorProduct (Tensor s u v) a) (TensorProduct (Tensor s u v) b) Source #

wellDefinedVector :: Tensor s u v -> Maybe (Tensor s u v) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (Tensor s u v)) => (Tensor s u v w) -> Maybe (Tensor s u v w) Source #

(LinearSpace u, TensorSpace v, Scalar u ~ s, Scalar v ~ s) => TensorSpace (LinearMap s u v) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type TensorProduct (LinearMap s u v) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness (LinearMap s u v) Source #

linearManifoldWitness :: LinearManifoldWitness (LinearMap s u v) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => LinearMap s u v w Source #

toFlatTensor :: LinearMap s u v -+> (LinearMap s u v Scalar (LinearMap s u v)) Source #

fromFlatTensor :: (LinearMap s u v Scalar (LinearMap s u v)) -+> LinearMap s u v Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v w) -> (LinearMap s u v w) -> LinearMap s u v w Source #

subtractTensors :: (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 Source #

scaleTensor :: (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) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v w) -+> (LinearMap s u v w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => Bilinear (LinearMap s u v) w (LinearMap s u v w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => [(LinearMap s u v, w)] -> LinearMap s u v w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v w) -+> (w LinearMap s u v) Source #

fmapTensor :: (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) Source #

fzipTensorWith :: (TensorSpace u0, TensorSpace w, TensorSpace x, Scalar u0 ~ Scalar (LinearMap s u v), Scalar w ~ Scalar (LinearMap s u v), Scalar x ~ Scalar (LinearMap s u v)) => Bilinear ((w, x) -+> u0) (LinearMap s u v w, LinearMap s u v x) (LinearMap s u v u0) Source #

coerceFmapTensorProduct :: Functor p => p (LinearMap s u v) -> Coercion a b -> Coercion (TensorProduct (LinearMap s u v) a) (TensorProduct (LinearMap s u v) b) Source #

wellDefinedVector :: LinearMap s u v -> Maybe (LinearMap s u v) Source #

wellDefinedTensor :: (TensorSpace w, Scalar w ~ Scalar (LinearMap s u v)) => (LinearMap s u v w) -> Maybe (LinearMap s u v w) Source #

(TensorSpace (f p), TensorSpace (g p), Scalar (f p) ~ Scalar (g p)) => TensorSpace ((f :*: g) p) Source # 
Instance details

Defined in Math.LinearMap.Category.Class

Associated Types

type TensorProduct ((f :*: g) p) w :: Type Source #

Methods

scalarSpaceWitness :: ScalarSpaceWitness ((f :*: g) p) Source #

linearManifoldWitness :: LinearManifoldWitness ((f :*: g) p) Source #

zeroTensor :: (TensorSpace w, Scalar w ~ Scalar ((f :*: g) p)) => (f :*: g) p w Source #

toFlatTensor :: (f :*: g) p -+> ((f :*: g) p Scalar ((f :*: g) p)) Source #

fromFlatTensor :: ((f :*: g) p Scalar ((f :*: g) p)) -+> (f :*: g) p Source #

addTensors :: (TensorSpace w, Scalar w ~ Scalar ((f :*: g) p)) => ((f :*: g) p w) -> ((f :*: g) p w) -> (f :*: g) p w Source #

subtractTensors :: (TensorSpace ((f :*: g) p), TensorSpace w, Scalar w ~ Scalar ((f :*: g) p)) => ((f :*: g) p w) -> ((f :*: g) p w) -> (f :*: g) p w Source #

scaleTensor :: (TensorSpace w, Scalar w ~ Scalar ((f :*: g) p)) => Bilinear (Scalar ((f :*: g) p)) ((f :*: g) p w) ((f :*: g) p w) Source #

negateTensor :: (TensorSpace w, Scalar w ~ Scalar ((f :*: g) p)) => ((f :*: g) p w) -+> ((f :*: g) p w) Source #

tensorProduct :: (TensorSpace w, Scalar w ~ Scalar ((f :*: g) p)) => Bilinear ((f :*: g) p) w ((f :*: g) p w) Source #

tensorProducts :: (TensorSpace w, Scalar w ~ Scalar ((f :*: g) p)) => [((f :*: g) p, w)] -> (f :*: g) p w Source #

transposeTensor :: (TensorSpace w, Scalar w ~ Scalar ((f :*: g) p)) => ((f :*: g) p w) -+> (w (f :*: g) p) Source #

fmapTensor :: (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) Source #

fzipTensorWith :: (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) -+>