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

Copyright (c) Justus Sagemüller 2016 GPL v3 (@) jsag $hvl.no experimental portable None Haskell2010 Math.LinearMap.Category 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 FieldsgetLinearFunction :: v -> w Instances  Num' s => Morphism (LinearFunction s) Source # Instance detailsDefined in Math.LinearMap.Category.Class Methodsfirst :: (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 detailsDefined in Math.LinearMap.Category.Class Methods(&&&) :: (Object (LinearFunction s) b, ObjectPair (LinearFunction s) c c') => LinearFunction s b c -> LinearFunction s b c' -> LinearFunction s b (c, c') #terminal :: Object (LinearFunction s) b => LinearFunction s b (UnitObject (LinearFunction s)) #fst :: ObjectPair (LinearFunction s) x y => LinearFunction s (x, y) x #snd :: ObjectPair (LinearFunction s) x y => LinearFunction s (x, y) y # Source # Instance detailsDefined in Math.LinearMap.Category.Class Associated Typestype Object (LinearFunction s) o :: Constraint # Methodsid :: Object (LinearFunction s) a => LinearFunction s a a #(.) :: (Object (LinearFunction s) a, Object (LinearFunction s) b, Object (LinearFunction s) c) => LinearFunction s b c -> LinearFunction s a b -> LinearFunction s a c # Num' s => Cartesian (LinearFunction s) Source # Instance detailsDefined in Math.LinearMap.Category.Class Associated Typestype PairObjects (LinearFunction s) a b :: Constraint #type UnitObject (LinearFunction s) :: Type # Methodsswap :: (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 detailsDefined in Math.LinearMap.Category.Class Methodsarr :: (Object Coercion b, Object Coercion c, Object (LinearFunction s) b, Object (LinearFunction s) c) => Coercion b c -> LinearFunction s b c # Num' s => EnhancedCat (LinearFunction s) (LinearMap s) Source # Instance detailsDefined in Math.LinearMap.Category.Class Methodsarr :: (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 detailsDefined in Math.LinearMap.Category.Class Methodsarr :: (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 detailsDefined in Math.LinearMap.Category.Class Methodsarr :: (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 detailsDefined in Math.LinearMap.Category.Class MethodspureUnit :: LinearFunction s (UnitObject (LinearFunction s)) (Tensor s v (UnitObject (LinearFunction s))) #fzipWith :: (ObjectPair (LinearFunction s) a b, Object (LinearFunction s) c, ObjectPair (LinearFunction s) (Tensor s v a) (Tensor s v b), Object (LinearFunction s) (Tensor s v c)) => LinearFunction s (a, b) c -> LinearFunction s (Tensor s v a, Tensor s v b) (Tensor s v c) # (Num' s, LinearSpace v, Scalar v ~ s) => Monoidal (LinearMap s v) (LinearFunction s) (LinearFunction s) Source # Instance detailsDefined in Math.LinearMap.Category.Class MethodspureUnit :: LinearFunction s (UnitObject (LinearFunction s)) (LinearMap s v (UnitObject (LinearFunction s))) #fzipWith :: (ObjectPair (LinearFunction s) a b, Object (LinearFunction s) c, ObjectPair (LinearFunction s) (LinearMap s v a) (LinearMap s v b), Object (LinearFunction s) (LinearMap s v c)) => LinearFunction s (a, b) c -> LinearFunction s (LinearMap s v a, LinearMap s v b) (LinearMap s v c) # Functor (LinearFunction s v) (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # Instance detailsDefined in Math.LinearMap.Asserted Methodsfmap :: (Object Coercion a, Object Coercion (LinearFunction s v a), Object Coercion b, Object Coercion (LinearFunction s v b)) => Coercion a b -> Coercion (LinearFunction s v a) (LinearFunction s v b) # (LinearSpace w, Num' s, Scalar w ~ s) => Functor (LinearFunction s w) (LinearFunction s) (LinearFunction s) Source # Instance detailsDefined in Math.LinearMap.Category.Class Methodsfmap :: (Object (LinearFunction s) a, Object (LinearFunction s) (LinearFunction s w a), Object (LinearFunction s) b, Object (LinearFunction s) (LinearFunction s w b)) => LinearFunction s a b -> LinearFunction s (LinearFunction s w a) (LinearFunction s w b) # (TensorSpace v, Num' s, Scalar v ~ s) => Functor (Tensor s v) (LinearFunction s) (LinearFunction s) Source # Instance detailsDefined in Math.LinearMap.Category.Class Methodsfmap :: (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 detailsDefined in Math.LinearMap.Category.Class Methodsfmap :: (Object (LinearFunction s) a, Object (LinearFunction s) (LinearMap s v a), Object (LinearFunction s) b, Object (LinearFunction s) (LinearMap s v b)) => LinearFunction s a b -> LinearFunction s (LinearMap s v a) (LinearMap s v b) # (FiniteDimensional u, LSpace v, FiniteFreeSpace v, Scalar u ~ s, Scalar v ~ s) => FiniteFreeSpace (LinearFunction s u v) Source # Instance detailsDefined in Math.VectorSpace.Docile MethodsfreeDimension :: Functor p => p (LinearFunction s u v) -> Int #toFullUnboxVect :: LinearFunction s u v -> Vector (Scalar (LinearFunction s u v)) #unsafeFromFullUnboxVect :: Vector (Scalar (LinearFunction s u v)) -> LinearFunction s u v #fromUnboxVect :: Vector (Scalar (LinearFunction s u v)) -> LinearFunction s u v # AdditiveGroup w => AdditiveGroup (LinearFunction s v w) Source # Instance detailsDefined in Math.LinearMap.Asserted MethodszeroV :: LinearFunction s v w #(^+^) :: LinearFunction s v w -> LinearFunction s v w -> LinearFunction s v w #negateV :: LinearFunction s v w -> LinearFunction s v w #(^-^) :: LinearFunction s v w -> LinearFunction s v w -> LinearFunction s v w # VectorSpace w => VectorSpace (LinearFunction s v w) Source # Instance detailsDefined in Math.LinearMap.Asserted Associated Typestype 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 detailsDefined in Math.LinearMap.Category.Class Associated Typestype 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 detailsDefined in Math.LinearMap.Asserted Associated Typestype Needle (LinearFunction s v w) :: Type #type Interior (LinearFunction s v w) :: Type # Methods(.+~^) :: Interior (LinearFunction s v w) -> Needle (LinearFunction s v w) -> LinearFunction s v w #fromInterior :: Interior (LinearFunction s v w) -> LinearFunction s v w #toInterior :: LinearFunction s v w -> Maybe (Interior (LinearFunction s v w)) #translateP :: Tagged (LinearFunction s v w) (Interior (LinearFunction s v w) -> Needle (LinearFunction s v w) -> Interior (LinearFunction s v w)) #(.-~^) :: Interior (LinearFunction s v w) -> Needle (LinearFunction s v w) -> LinearFunction s v w # VectorSpace w => PseudoAffine (LinearFunction s v w) Source # Instance detailsDefined in Math.LinearMap.Asserted Methods(.-~.) :: LinearFunction s v w -> LinearFunction s v w -> Maybe (Needle (LinearFunction s v w)) #(.-~!) :: LinearFunction s v w -> LinearFunction s v w -> Needle (LinearFunction s v w) # (LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s) => LinearSpace (LinearFunction s u v) Source # Instance detailsDefined in Math.LinearMap.Category.Class Associated Typestype DualVector (LinearFunction s u v) :: Type Source # MethodslinearId :: 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 detailsDefined in Math.LinearMap.Category.Class Associated Typestype TensorProduct (LinearFunction s u v) w :: Type Source # MethodszeroTensor :: (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 detailsDefined in Math.LinearMap.Category.Class type UnitObject (LinearFunction s) = ZeroDim s type Object (LinearFunction s) v Source # Instance detailsDefined in Math.LinearMap.Category.Class type Object (LinearFunction s) v = (TensorSpace v, Scalar v ~ s) type PairObjects (LinearFunction s) a b Source # Instance detailsDefined in Math.LinearMap.Category.Class type PairObjects (LinearFunction s) a b = () type Scalar (LinearFunction s v w) Source # Instance detailsDefined in Math.LinearMap.Asserted type Scalar (LinearFunction s v w) = Scalar w type Diff (LinearFunction s u v) Source # Instance detailsDefined in Math.LinearMap.Category.Class type Diff (LinearFunction s u v) = LinearFunction s u v type Interior (LinearFunction s v w) Source # Instance detailsDefined in Math.LinearMap.Asserted type Interior (LinearFunction s v w) = LinearFunction s v w type Needle (LinearFunction s v w) Source # Instance detailsDefined in Math.LinearMap.Asserted type Needle (LinearFunction s v w) = LinearFunction s v w type DualVector (LinearFunction s u v) Source # Instance detailsDefined in Math.LinearMap.Category.Class type DualVector (LinearFunction s u v) = LinearFunction s v u type TensorProduct (LinearFunction s u v) w Source # Instance detailsDefined in Math.LinearMap.Category.Class type TensorProduct (LinearFunction s u v) w = LinearFunction s (LinearFunction s v u) w 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 FieldsgetLinearMap :: TensorProduct (DualVector v) w Instances  (Show (SubBasis (DualVector u)), Show (SubBasis v)) => Show (SubBasis (LinearMap s u v)) Source # Instance detailsDefined in Math.VectorSpace.Docile MethodsshowsPrec :: 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 detailsDefined in Math.LinearMap.Category.Class Methodsfirst :: (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 detailsDefined 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 # Source # Instance detailsDefined in Math.LinearMap.Category.Class Associated Typestype Object (LinearMap s) o :: Constraint # Methodsid :: 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 detailsDefined in Math.LinearMap.Category.Class Associated Typestype PairObjects (LinearMap s) a b :: Constraint #type UnitObject (LinearMap s) :: Type # Methodsswap :: (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 detailsDefined in Math.LinearMap.Category.Class Methodsarr :: (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 detailsDefined in Math.LinearMap.Category.Class Methodsarr :: (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 detailsDefined in Math.LinearMap.Category.Class Methodsarr :: (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 detailsDefined in Math.LinearMap.Category.Class MethodspureUnit :: LinearFunction s (UnitObject (LinearFunction s)) (LinearMap s v (UnitObject (LinearFunction s))) #fzipWith :: (ObjectPair (LinearFunction s) a b, Object (LinearFunction s) c, ObjectPair (LinearFunction s) (LinearMap s v a) (LinearMap s v b), Object (LinearFunction s) (LinearMap s v c)) => LinearFunction s (a, b) c -> LinearFunction s (LinearMap s v a, LinearMap s v b) (LinearMap s v c) # (LinearSpace v, Scalar v ~ s) => Functor (LinearMap s v) (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # Instance detailsDefined in Math.LinearMap.Category.Class Methodsfmap :: (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 detailsDefined in Math.LinearMap.Category.Class Methodsfmap :: (Object (LinearFunction s) a, Object (LinearFunction s) (LinearMap s v a), Object (LinearFunction s) b, Object (LinearFunction s) (LinearMap s v b)) => LinearFunction s a b -> LinearFunction s (LinearMap s v a) (LinearMap s v b) # (Fractional' n, TensorProduct (DualVector n) n ~ n) => Fractional (LinearMap n n n) Source # Instance detailsDefined 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 detailsDefined 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 detailsDefined in Math.VectorSpace.Docile MethodsshowsPrec :: 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 detailsDefined in Math.VectorSpace.Docile MethodsshowsPrec :: 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 detailsDefined in Math.VectorSpace.Docile MethodsshowsPrec :: 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 detailsDefined in Math.VectorSpace.Docile MethodsshowsPrec :: 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 detailsDefined in Math.VectorSpace.Docile MethodsfreeDimension :: Functor p => p (LinearMap s u v) -> Int #toFullUnboxVect :: LinearMap s u v -> Vector (Scalar (LinearMap s u v)) #unsafeFromFullUnboxVect :: Vector (Scalar (LinearMap s u v)) -> LinearMap s u v #fromUnboxVect :: Vector (Scalar (LinearMap s u v)) -> LinearMap s u v # (LinearSpace v, TensorSpace w, Scalar v ~ s, Scalar w ~ s) => AdditiveGroup (LinearMap s v w) Source # Instance detailsDefined in Math.LinearMap.Category.Class MethodszeroV :: 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 detailsDefined in Math.LinearMap.Category.Class Associated Typestype 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 detailsDefined in Math.LinearMap.Category.Class Associated Typestype 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 detailsDefined in Math.LinearMap.Category.Class Associated Typestype Needle (LinearMap s v w) :: Type #type Interior (LinearMap s v w) :: Type # Methods(.+~^) :: Interior (LinearMap s v w) -> Needle (LinearMap s v w) -> LinearMap s v w #fromInterior :: Interior (LinearMap s v w) -> LinearMap s v w #toInterior :: LinearMap s v w -> Maybe (Interior (LinearMap s v w)) #translateP :: Tagged (LinearMap s v w) (Interior (LinearMap s v w) -> Needle (LinearMap s v w) -> Interior (LinearMap s v w)) #(.-~^) :: Interior (LinearMap s v w) -> Needle (LinearMap s v w) -> LinearMap s v w # (LinearSpace v, TensorSpace w, Scalar v ~ s, Scalar w ~ s) => PseudoAffine (LinearMap s v w) Source # Instance detailsDefined 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) # (LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s) => LinearSpace (LinearMap s u v) Source # Instance detailsDefined in Math.LinearMap.Category.Class Associated Typestype DualVector (LinearMap s u v) :: Type Source # MethodslinearId :: 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 detailsDefined in Math.LinearMap.Category.Class Associated Typestype TensorProduct (LinearMap s u v) w :: Type Source # MethodszeroTensor :: (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 detailsDefined in Math.VectorSpace.Docile Associated Typesdata SubBasis (LinearMap s u v) :: Type Source # MethodsentireBasis :: 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 # (LinearSpace u, SemiInner (DualVector u), SemiInner v, Scalar u ~ s, Scalar v ~ s) => SemiInner (LinearMap s u v) Source # Instance detailsDefined in Math.VectorSpace.Docile MethodsdualBasisCandidates :: [(Int, LinearMap s u v)] -> Forest (Int, DualVector (LinearMap s u v)) Source #tensorDualBasisCandidates :: (SemiInner w, Scalar w ~ Scalar (LinearMap s u v)) => [(Int, LinearMap s u v ⊗ w)] -> Forest (Int, DualVector (LinearMap s u v ⊗ w)) Source #symTensorDualBasisCandidates :: [(Int, SymmetricTensor (Scalar (LinearMap s u v)) (LinearMap s u v))] -> Forest (Int, SymmetricTensor (Scalar (LinearMap s u v)) (DualVector (LinearMap s u v))) Source #symTensorTensorDualBasisCandidates :: (SemiInner w, Scalar w ~ Scalar (LinearMap s u v)) => [(Int, SymmetricTensor (Scalar (LinearMap s u v)) (LinearMap s u v) ⊗ w)] -> Forest (Int, SymmetricTensor (Scalar (LinearMap s u v)) (LinearMap s u v) +> DualVector w) Source # type UnitObject (LinearMap s) Source # Instance detailsDefined in Math.LinearMap.Category.Class type UnitObject (LinearMap s) = ZeroDim s type Object (LinearMap s) v Source # Instance detailsDefined in Math.LinearMap.Category.Class type Object (LinearMap s) v = (LinearSpace v, Scalar v ~ s) type PairObjects (LinearMap s) a b Source # Instance detailsDefined in Math.LinearMap.Category.Class type PairObjects (LinearMap s) a b = () type Scalar (LinearMap s v w) Source # Instance detailsDefined in Math.LinearMap.Category.Class type Scalar (LinearMap s v w) = s type Diff (LinearMap s u v) Source # Instance detailsDefined in Math.LinearMap.Category.Class type Diff (LinearMap s u v) = LinearMap s u v type Interior (LinearMap s v w) Source # Instance detailsDefined in Math.LinearMap.Category.Class type Interior (LinearMap s v w) = LinearMap s v w type Needle (LinearMap s v w) Source # Instance detailsDefined in Math.LinearMap.Category.Class type Needle (LinearMap s v w) = LinearMap s v w type DualVector (LinearMap s u v) Source # Instance detailsDefined in Math.LinearMap.Category.Class type DualVector (LinearMap s u v) = Tensor s u (DualVector v) data SubBasis (LinearMap s u v) Source # Instance detailsDefined in Math.VectorSpace.Docile data SubBasis (LinearMap s u v) = LinMapBasis !(SubBasis (DualVector u)) !(SubBasis v) type TensorProduct (LinearMap s u v) w Source # Instance detailsDefined in Math.LinearMap.Category.Class type TensorProduct (LinearMap s u v) w = TensorProduct (DualVector u) (Tensor s v w) 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 FieldsgetTensorProduct :: TensorProduct v w Instances  (Show (SubBasis u), Show (SubBasis v)) => Show (SubBasis (Tensor s u v)) Source # Instance detailsDefined in Math.VectorSpace.Docile MethodsshowsPrec :: 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 detailsDefined in Math.LinearMap.Category.Class MethodspureUnit :: LinearFunction s (UnitObject (LinearFunction s)) (Tensor s v (UnitObject (LinearFunction s))) #fzipWith :: (ObjectPair (LinearFunction s) a b, Object (LinearFunction s) c, ObjectPair (LinearFunction s) (Tensor s v a) (Tensor s v b), Object (LinearFunction s) (Tensor s v c)) => LinearFunction s (a, b) c -> LinearFunction s (Tensor s v a, Tensor s v b) (Tensor s v c) # (TensorSpace v, Scalar v ~ s) => Functor (Tensor s v) (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # Instance detailsDefined in Math.LinearMap.Category.Class Methodsfmap :: (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 detailsDefined in Math.LinearMap.Category.Class Methodsfmap :: (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 detailsDefined in Math.LinearMap.Category.Instances Associated Typestype Item (Tensor s (FinSuppSeq s) v) :: Type # MethodsfromList :: [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 detailsDefined in Math.LinearMap.Category.Instances Associated Typestype Item (Tensor s (Sequence s) v) :: Type # MethodsfromList :: [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 detailsDefined in Math.VectorSpace.Docile MethodsshowsPrec :: 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 detailsDefined in Math.VectorSpace.Docile MethodsshowsPrec :: 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 detailsDefined in Math.VectorSpace.Docile MethodsfreeDimension :: 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 detailsDefined in Math.LinearMap.Category.Class MethodszeroV :: 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 detailsDefined in Math.LinearMap.Category.Class Associated Typestype 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 detailsDefined in Math.LinearMap.Category.Class Associated Typestype 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 detailsDefined in Math.LinearMap.Category.Class Associated Typestype 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 # (TensorSpace v, TensorSpace w, Scalar v ~ s, Scalar w ~ s) => PseudoAffine (Tensor s v w) Source # Instance detailsDefined 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) # (LinearSpace u, LinearSpace v, Scalar u ~ s, Scalar v ~ s) => LinearSpace (Tensor s u v) Source # Instance detailsDefined in Math.LinearMap.Category.Class Associated Typestype DualVector (Tensor s u v) :: Type Source # MethodslinearId :: 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 detailsDefined in Math.LinearMap.Category.Class Associated Typestype TensorProduct (Tensor s u v) w :: Type Source # MethodszeroTensor :: (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 detailsDefined in Math.VectorSpace.Docile Associated Typesdata SubBasis (Tensor s u v) :: Type Source # MethodsentireBasis :: 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 detailsDefined in Math.VectorSpace.Docile MethodsdualBasisCandidates :: [(Int, Tensor s u v)] -> Forest (Int, DualVector (Tensor s u v)) Source #tensorDualBasisCandidates :: (SemiInner w, Scalar w ~ Scalar (Tensor s u v)) => [(Int, Tensor s u v ⊗ w)] -> Forest (Int, DualVector (Tensor s u v ⊗ w)) Source #symTensorDualBasisCandidates :: [(Int, SymmetricTensor (Scalar (Tensor s u v)) (Tensor s u v))] -> Forest (Int, SymmetricTensor (Scalar (Tensor s u v)) (DualVector (Tensor s u v))) Source #symTensorTensorDualBasisCandidates :: (SemiInner w, Scalar w ~ Scalar (Tensor s u v)) => [(Int, SymmetricTensor (Scalar (Tensor s u v)) (Tensor s u v) ⊗ w)] -> Forest (Int, SymmetricTensor (Scalar (Tensor s u v)) (Tensor s u v) +> DualVector w) Source # type Item (Tensor s (FinSuppSeq s) v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances type Item (Tensor s (FinSuppSeq s) v) = v type Item (Tensor s (Sequence s) v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances type Item (Tensor s (Sequence s) v) = v type Scalar (Tensor s v w) Source # Instance detailsDefined in Math.LinearMap.Category.Class type Scalar (Tensor s v w) = s type Diff (Tensor s u v) Source # Instance detailsDefined in Math.LinearMap.Category.Class type Diff (Tensor s u v) = Tensor s u v type Interior (Tensor s v w) Source # Instance detailsDefined in Math.LinearMap.Category.Class type Interior (Tensor s v w) = Tensor s v w type Needle (Tensor s v w) Source # Instance detailsDefined in Math.LinearMap.Category.Class type Needle (Tensor s v w) = Tensor s v w type DualVector (Tensor s u v) Source # Instance detailsDefined in Math.LinearMap.Category.Class type DualVector (Tensor s u v) = LinearMap s u (DualVector v) data SubBasis (Tensor s u v) Source # Instance detailsDefined in Math.VectorSpace.Docile data SubBasis (Tensor s u v) = TensorBasis !(SubBasis u) !(SubBasis v) type TensorProduct (Tensor s u v) w Source # Instance detailsDefined 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 FieldsgetSymmetricTensor :: Tensor s v v Instances  Show (SubBasis v) => Show (SubBasis (SymmetricTensor s v)) Source # Instance detailsDefined in Math.VectorSpace.Docile MethodsshowsPrec :: Int -> SubBasis (SymmetricTensor s v) -> ShowS #show :: SubBasis (SymmetricTensor s v) -> String #showList :: [SubBasis (SymmetricTensor s v)] -> ShowS # Show (Tensor s v v) => Show (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances MethodsshowsPrec :: Int -> SymmetricTensor s v -> ShowS #show :: SymmetricTensor s v -> String #showList :: [SymmetricTensor s v] -> ShowS # (TensorSpace v, Scalar v ~ s) => AdditiveGroup (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances Methods(^+^) :: SymmetricTensor s v -> SymmetricTensor s v -> SymmetricTensor s v #negateV :: SymmetricTensor s v -> SymmetricTensor s v #(^-^) :: SymmetricTensor s v -> SymmetricTensor s v -> SymmetricTensor s v # (TensorSpace v, Scalar v ~ s) => VectorSpace (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances Associated Typestype Scalar (SymmetricTensor s v) :: Type # Methods(*^) :: Scalar (SymmetricTensor s v) -> SymmetricTensor s v -> SymmetricTensor s v # (TensorSpace v, Scalar v ~ s) => AffineSpace (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances Associated Typestype Diff (SymmetricTensor s v) :: Type # Methods(.-.) :: SymmetricTensor s v -> SymmetricTensor s v -> Diff (SymmetricTensor s v) #(.+^) :: SymmetricTensor s v -> Diff (SymmetricTensor s v) -> SymmetricTensor s v # (TensorSpace v, Scalar v ~ s) => Semimanifold (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances Associated Typestype Needle (SymmetricTensor s v) :: Type #type Interior (SymmetricTensor s v) :: Type # Methods(.+~^) :: Interior (SymmetricTensor s v) -> Needle (SymmetricTensor s v) -> SymmetricTensor s v #fromInterior :: Interior (SymmetricTensor s v) -> SymmetricTensor s v #toInterior :: SymmetricTensor s v -> Maybe (Interior (SymmetricTensor s v)) #translateP :: Tagged (SymmetricTensor s v) (Interior (SymmetricTensor s v) -> Needle (SymmetricTensor s v) -> Interior (SymmetricTensor s v)) #(.-~^) :: Interior (SymmetricTensor s v) -> Needle (SymmetricTensor s v) -> SymmetricTensor s v # (TensorSpace v, Scalar v ~ s) => PseudoAffine (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances Methods(.-~.) :: SymmetricTensor s v -> SymmetricTensor s v -> Maybe (Needle (SymmetricTensor s v)) #(.-~!) :: SymmetricTensor s v -> SymmetricTensor s v -> Needle (SymmetricTensor s v) # (Num' s, LinearSpace v, Scalar v ~ s) => LinearSpace (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances Associated Typestype DualVector (SymmetricTensor s v) :: Type Source # MethodssampleLinearFunction :: (TensorSpace w, Scalar (SymmetricTensor s v) ~ Scalar w) => (SymmetricTensor s v -+> w) -+> (SymmetricTensor s v +> w) 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 detailsDefined in Math.LinearMap.Category.Instances Associated Typestype TensorProduct (SymmetricTensor s v) w :: Type Source # MethodszeroTensor :: (TensorSpace w, Scalar w ~ Scalar (SymmetricTensor s v)) => SymmetricTensor s v ⊗ w 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 #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 detailsDefined in Math.VectorSpace.Docile Associated Typesdata SubBasis (SymmetricTensor s v) :: Type Source # MethodsenumerateSubBasis :: SubBasis (SymmetricTensor s v) -> [SymmetricTensor s v] 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 # (Num' s, SemiInner v, Scalar v ~ s) => SemiInner (SymmetricTensor s v) Source # Instance detailsDefined in Math.VectorSpace.Docile MethodsdualBasisCandidates :: [(Int, SymmetricTensor s v)] -> Forest (Int, DualVector (SymmetricTensor s v)) Source #tensorDualBasisCandidates :: (SemiInner w, Scalar w ~ Scalar (SymmetricTensor s v)) => [(Int, SymmetricTensor s v ⊗ w)] -> Forest (Int, DualVector (SymmetricTensor s v ⊗ w)) Source #symTensorDualBasisCandidates :: [(Int, SymmetricTensor (Scalar (SymmetricTensor s v)) (SymmetricTensor s v))] -> Forest (Int, SymmetricTensor (Scalar (SymmetricTensor s v)) (DualVector (SymmetricTensor s v))) Source #symTensorTensorDualBasisCandidates :: (SemiInner w, Scalar w ~ Scalar (SymmetricTensor s v)) => [(Int, SymmetricTensor (Scalar (SymmetricTensor s v)) (SymmetricTensor s v) ⊗ w)] -> Forest (Int, SymmetricTensor (Scalar (SymmetricTensor s v)) (SymmetricTensor s v) +> DualVector w) Source # type Scalar (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances type Scalar (SymmetricTensor s v) = s type Diff (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances type Diff (SymmetricTensor s v) = SymmetricTensor s v type Interior (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances type Interior (SymmetricTensor s v) = SymmetricTensor s v type Needle (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances type Needle (SymmetricTensor s v) = SymmetricTensor s v type DualVector (SymmetricTensor s v) Source # Instance detailsDefined in Math.LinearMap.Category.Instances type DualVector (SymmetricTensor s v) = SymmetricTensor s (DualVector v) newtype SubBasis (SymmetricTensor s v) Source # Instance detailsDefined in Math.VectorSpace.Docile newtype SubBasis (SymmetricTensor s v) = SymTensBasis (SubBasis v) type TensorProduct (SymmetricTensor s v) x Source # Instance detailsDefined 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 FieldsapplyNorm :: v -+> DualVector v Instances  (SimpleSpace v, Show (DualVector v)) => Show (Norm v) Source # Instance detailsDefined in Math.LinearMap.Category MethodsshowsPrec :: 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 detailsDefined 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 detailsDefined in Math.LinearMap.Category Methodsmappend :: 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).

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 #

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.

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.

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 Fieldsev_Eigenvalue :: Scalar vThe estimated eigenvalue λ.ev_Eigenvector :: vNormalised vector v that gets mapped to a multiple, namely:ev_FunctionApplied :: vf $v ≡ λ *^ v .ev_Deviation :: vDeviation of v to (f$v)^/λ. Ideally, this would of course be equal.ev_Badness :: Scalar vSquared norm of the deviation.
Instances
 (Show v, Show (Scalar v)) => Show (Eigenvector v) Source # Instance detailsDefined in Math.LinearMap.Category MethodsshowsPrec :: Int -> Eigenvector v -> ShowS #show :: Eigenvector v -> String #showList :: [Eigenvector v] -> ShowS #

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

Minimal complete definition

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

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