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 LinearFunction
s – 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
.
Instances
Num' s => EnhancedCat (LinearFunction s) (LinearMap s) # | |
|
Num' s => EnhancedCat (LinearMap s) (LinearFunction s) # | |
|
(Num' s, TensorSpace v, (~) * (Scalar v) s) => Monoidal (Tensor s v) (LinearFunction s) (LinearFunction s) # | |
|
(Num' s, LinearSpace v, (~) * (Scalar v) s) => Monoidal (LinearMap s v) (LinearFunction s) (LinearFunction s) # | |
|
Functor (LinearFunction s v) (Coercion *) (Coercion *) Source # | |
|
(TensorSpace v, Num' s, (~) * (Scalar v) s) => Functor (Tensor s v) (LinearFunction s) (LinearFunction s) # | |
|
(LinearSpace v, Num' s, (~) * (Scalar v) s) => Functor (LinearMap s v) (LinearFunction s) (LinearFunction s) # | |
|
AdditiveGroup w => AdditiveGroup (LinearFunction s v w) Source # | |
|
VectorSpace w => VectorSpace (LinearFunction s v w) Source # | |
|
VectorSpace w => Semimanifold (LinearFunction s v w) Source # | |
|
VectorSpace w => PseudoAffine (LinearFunction s v w) Source # | |
|
(LinearSpace u, LinearSpace v, (~) * (Scalar u) s, (~) * (Scalar v) s) => LinearSpace (LinearFunction s u v) 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 u, (* ~ Scalar u) (Scalar (LinearFunction s u v))) => Bilinear (DualVector (LinearFunction s u v ⊗ u)) (LinearFunction s u v ⊗ u) (Scalar (LinearFunction s u v)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar (LinearFunction s u v)), (* ~ Scalar w) (Scalar (LinearFunction s u v))) => Bilinear ((LinearFunction s u v ⊗ u) +> w) (LinearFunction s u v ⊗ u) w Source # |
(LinearSpace u, LinearSpace v, (~) * (Scalar u) s, (~) * (Scalar v) s) => TensorSpace (LinearFunction s u v) 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 u, TensorSpace w, TensorSpace x, (* ~ Scalar u) (Scalar (LinearFunction s u v)), (* ~ Scalar w) (Scalar (LinearFunction s u v)), (* ~ Scalar x) (Scalar (LinearFunction s u v))) => Bilinear ((w, x) -+> u) (LinearFunction s u v ⊗ w, LinearFunction s u v ⊗ x) (LinearFunction s u v ⊗ u) 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) # | |
|
type Object (LinearFunction s) v # | |
|
type PairObjects (LinearFunction s) a b # | |
|
type Scalar (LinearFunction s v w) Source # | |
|
type Diff (LinearFunction s u v) # | |
|
type Interior (LinearFunction s v w) Source # | |
|
type Needle (LinearFunction s v w) Source # | |
|
type DualVector (LinearFunction s u v) Source # | |
|
type TensorProduct (LinearFunction s u v) w Source # | |
|
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).
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.
Instances
(Show (SubBasis (DualVector u)), Show (SubBasis v)) => Show (SubBasis (LinearMap s u v)) # | |
|
Num' s => Morphism (LinearMap s) Source # | |
|
Num' s => PreArrow (LinearMap s) Source # | |
|
Category (LinearMap s) Source # | |
|
Num' s => Cartesian (LinearMap s) Source # | |
Methods swap :: (ObjectPair (LinearMap s) a b, ObjectPair (LinearMap s) b a) => LinearMap s (a, b) (b, a) # attachUnit :: ((* ~ u) (UnitObject (LinearMap s)), ObjectPair (LinearMap s) a u) => LinearMap s a (a, u) # detachUnit :: ((* ~ u) (UnitObject (LinearMap s)), ObjectPair (LinearMap s) a u) => LinearMap s (a, u) 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 # | |
|
Num' s => EnhancedCat (LinearMap s) (LinearFunction s) Source # | |
|
Num' s => EnhancedCat ((->) LiftedRep LiftedRep) (LinearMap s) Source # | |
|
(Num' s, LinearSpace v, (~) * (Scalar v) s) => Monoidal (LinearMap s v) (LinearFunction s) (LinearFunction s) Source # | |
|
(LinearSpace v, (~) * (Scalar v) s) => Functor (LinearMap s v) (Coercion *) (Coercion *) Source # | |
|
(LinearSpace v, Num' s, (~) * (Scalar v) s) => Functor (LinearMap s v) (LinearFunction s) (LinearFunction s) Source # | |
|
(LinearSpace v, TensorSpace w, (~) * (Scalar v) s, (~) * (Scalar w) s) => AdditiveGroup (LinearMap s v w) Source # | |
|
(LinearSpace v, TensorSpace w, (~) * (Scalar v) s, (~) * (Scalar w) s) => VectorSpace (LinearMap s v w) Source # | |
|
(LinearSpace u, TensorSpace v, (~) * s (Scalar u), (~) * s (Scalar v)) => AffineSpace (LinearMap s u v) Source # | |
|
(LinearSpace v, TensorSpace w, (~) * (Scalar v) s, (~) * (Scalar w) s) => Semimanifold (LinearMap s v w) Source # | |
|
(LinearSpace v, TensorSpace w, (~) * (Scalar v) s, (~) * (Scalar w) s) => PseudoAffine (LinearMap s v w) Source # | |
|
(LinearSpace u, LinearSpace v, (~) * (Scalar u) s, (~) * (Scalar v) s) => LinearSpace (LinearMap s u v) 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 u, (* ~ Scalar u) (Scalar (LinearMap s u v))) => Bilinear (DualVector (LinearMap s u v ⊗ u)) (LinearMap s u v ⊗ u) (Scalar (LinearMap s u v)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar (LinearMap s u v)), (* ~ Scalar w) (Scalar (LinearMap s u v))) => Bilinear ((LinearMap s u v ⊗ u) +> w) (LinearMap s u v ⊗ u) w Source # |
(LinearSpace u, TensorSpace v, (~) * (Scalar u) s, (~) * (Scalar v) s) => TensorSpace (LinearMap s u v) 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 u, TensorSpace w, TensorSpace x, (* ~ Scalar u) (Scalar (LinearMap s u v)), (* ~ Scalar w) (Scalar (LinearMap s u v)), (* ~ Scalar x) (Scalar (LinearMap s u v))) => Bilinear ((w, x) -+> u) (LinearMap s u v ⊗ w, LinearMap s u v ⊗ x) (LinearMap s u v ⊗ u) 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 # | |
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 u, LinearSpace w, (* ~ Scalar u) (Scalar (LinearMap s u v)), (* ~ Scalar w) (Scalar (LinearMap s u v)), Functor f) => (f (Scalar w) -> w) -> f (LinearMap s u v +> DualVector u) -> (LinearMap s u v ⊗ u) +> 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 # | |
Methods dualBasisCandidates :: [(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 # | |
|
type Object (LinearMap s) v Source # | |
|
type PairObjects (LinearMap s) a b Source # | |
|
type Scalar (LinearMap s v w) Source # | |
|
type Diff (LinearMap s u v) Source # | |
|
type Interior (LinearMap s v w) Source # | |
|
type Needle (LinearMap s v w) Source # | |
|
type DualVector (LinearMap s u v) Source # | |
|
data SubBasis (LinearMap s u v) Source # | |
|
type TensorProduct (LinearMap s u v) w Source # | |
|
(⊕) :: (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.
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
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.
Instances
(Show (SubBasis u), Show (SubBasis v)) => Show (SubBasis (Tensor s u v)) # | |
|
(Num' s, TensorSpace v, (~) * (Scalar v) s) => Monoidal (Tensor s v) (LinearFunction s) (LinearFunction s) Source # | |
|
(TensorSpace v, (~) * (Scalar v) s) => Functor (Tensor s v) (Coercion *) (Coercion *) Source # | |
|
(TensorSpace v, Num' s, (~) * (Scalar v) s) => Functor (Tensor s v) (LinearFunction s) (LinearFunction s) Source # | |
|
(TensorSpace v, TensorSpace w, (~) * (Scalar v) s, (~) * (Scalar w) s) => AdditiveGroup (Tensor s v w) Source # | |
|
(TensorSpace v, TensorSpace w, (~) * (Scalar v) s, (~) * (Scalar w) s) => VectorSpace (Tensor s v w) Source # | |
|
(TensorSpace u, TensorSpace v, (~) * s (Scalar u), (~) * s (Scalar v)) => AffineSpace (Tensor s u v) Source # | |
|
(TensorSpace v, TensorSpace w, (~) * (Scalar v) s, (~) * (Scalar w) s) => Semimanifold (Tensor s v w) Source # | |
|
(TensorSpace v, TensorSpace w, (~) * (Scalar v) s, (~) * (Scalar w) s) => PseudoAffine (Tensor s v w) Source # | |
|
(LinearSpace u, LinearSpace v, (~) * (Scalar u) s, (~) * (Scalar v) s) => LinearSpace (Tensor s u v) 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 u, (* ~ Scalar u) (Scalar (Tensor s u v))) => Bilinear (DualVector (Tensor s u v ⊗ u)) (Tensor s u v ⊗ u) (Scalar (Tensor s u v)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar (Tensor s u v)), (* ~ Scalar w) (Scalar (Tensor s u v))) => Bilinear ((Tensor s u v ⊗ u) +> w) (Tensor s u v ⊗ u) w Source # |
(TensorSpace u, TensorSpace v, (~) * (Scalar u) s, (~) * (Scalar v) s) => TensorSpace (Tensor s u v) 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 u, TensorSpace w, TensorSpace x, (* ~ Scalar u) (Scalar (Tensor s u v)), (* ~ Scalar w) (Scalar (Tensor s u v)), (* ~ Scalar x) (Scalar (Tensor s u v))) => Bilinear ((w, x) -+> u) (Tensor s u v ⊗ w, Tensor s u v ⊗ x) (Tensor s u v ⊗ u) 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 # | |
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 u, LinearSpace w, (* ~ Scalar u) (Scalar (Tensor s u v)), (* ~ Scalar w) (Scalar (Tensor s u v)), Functor f) => (f (Scalar w) -> w) -> f (Tensor s u v +> DualVector u) -> (Tensor s u v ⊗ u) +> 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 # | |
Methods dualBasisCandidates :: [(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) # | |
|
type Item (Tensor s (Sequence s) v) # | |
|
type Scalar (Tensor s v w) Source # | |
|
type Diff (Tensor s u v) Source # | |
|
type Interior (Tensor s v w) Source # | |
|
type Needle (Tensor s v w) Source # | |
|
type DualVector (Tensor s u v) Source # | |
|
data SubBasis (Tensor s u v) Source # | |
|
type TensorProduct (Tensor s u v) w Source # | |
|
Symmetric
newtype SymmetricTensor s v Source #
Instances
Show (SubBasis v) => Show (SubBasis (SymmetricTensor s v)) # | |
|
Show (Tensor s v v) => Show (SymmetricTensor s v) Source # | |
|
(TensorSpace v, (~) * (Scalar v) s) => AdditiveGroup (SymmetricTensor s v) Source # | |
|
(TensorSpace v, (~) * (Scalar v) s) => VectorSpace (SymmetricTensor s v) Source # | |
|
(TensorSpace v, (~) * (Scalar v) s) => AffineSpace (SymmetricTensor s v) Source # | |
|
(TensorSpace v, (~) * (Scalar v) s) => Semimanifold (SymmetricTensor s v) Source # | |
|
(TensorSpace v, (~) * (Scalar v) s) => PseudoAffine (SymmetricTensor s v) Source # | |
|
(Num' s, LinearSpace v, (~) * (Scalar v) s) => LinearSpace (SymmetricTensor s v) 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 # | |
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 # | |
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 # | |
Methods dualBasisCandidates :: [(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 # | |
|
type Diff (SymmetricTensor s v) Source # | |
|
type Interior (SymmetricTensor s v) Source # | |
|
type Needle (SymmetricTensor s v) Source # | |
|
type DualVector (SymmetricTensor s v) Source # | |
|
data SubBasis (SymmetricTensor s v) Source # | |
|
type TensorProduct (SymmetricTensor s v) x 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 Seminorm
s (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.
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).
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
.
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.
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.
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₂, ...]
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.
Eigenvalue problems
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.
The classes of suitable vector spaces
class (VectorSpace v, PseudoAffine v) => TensorSpace v where Source #
Minimal complete definition
scalarSpaceWitness, linearManifoldWitness, zeroTensor, toFlatTensor, fromFlatTensor, addTensors, scaleTensor, negateTensor, tensorProduct, transposeTensor, fmapTensor, fzipTensorWith, coerceFmapTensorProduct, wellDefinedTensor
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 #
subtractTensors :: (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) => (v ⊗ w) -> (v ⊗ w) -> v ⊗ w Source #
scaleTensor :: (TensorSpace w, Scalar w ~ Scalar v) => Bilinear (Scalar v) (v ⊗ w) (v ⊗ w) Source #
negateTensor :: (TensorSpace w, Scalar w ~ Scalar v) => (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
(Semimanifold m, TensorSpace (Needle (VRep m)), (~) * (Scalar (Needle m)) (Scalar (Needle (VRep m)))) => TensorSpace (GenericNeedle m) 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 # | |
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 # | |
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 u, TensorSpace w, TensorSpace x, (* ~ Scalar u) (Scalar (u, v)), (* ~ Scalar w) (Scalar (u, v)), (* ~ Scalar x) (Scalar (u, v))) => Bilinear ((w, x) -+> u) ((u, v) ⊗ w, (u, v) ⊗ x) ((u, v) ⊗ u) 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 # | |
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 # | |
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 # | |
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 u, TensorSpace w, TensorSpace x, (* ~ Scalar u) (Scalar (LinearFunction s u v)), (* ~ Scalar w) (Scalar (LinearFunction s u v)), (* ~ Scalar x) (Scalar (LinearFunction s u v))) => Bilinear ((w, x) -+> u) (LinearFunction s u v ⊗ w, LinearFunction s u v ⊗ x) (LinearFunction s u v ⊗ u) 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 # | |
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 u, TensorSpace w, TensorSpace x, (* ~ Scalar u) (Scalar (Tensor s u v)), (* ~ Scalar w) (Scalar (Tensor s u v)), (* ~ Scalar x) (Scalar (Tensor s u v))) => Bilinear ((w, x) -+> u) (Tensor s u v ⊗ w, Tensor s u v ⊗ x) (Tensor s u v ⊗ u) 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 # | |
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 u, TensorSpace w, TensorSpace x, (* ~ Scalar u) (Scalar (LinearMap s u v)), (* ~ Scalar w) (Scalar (LinearMap s u v)), (* ~ Scalar x) (Scalar (LinearMap s u v))) => Bilinear ((w, x) -+> u) (LinearMap s u v ⊗ w, LinearMap s u v ⊗ x) (LinearMap s u v ⊗ u) 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 # | |
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) -+> u) ((* :*: f) g p ⊗ w, (* :*: f) g p ⊗ x) ((* :*: f) g p ⊗ u) Source # coerceFmapTensorProduct :: Functor p => p ((* :*: f) g p) -> Coercion * a b -> Coercion * (TensorProduct ((* :*: f) g p) a) (TensorProduct ((* :*: f) g p) b) Source # wellDefinedVector :: (* :*: f) g p -> Maybe ((* :*: f) g p) Source # wellDefinedTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar ((* :*: f) g p))) => ((* :*: f) g p ⊗ w) -> Maybe ((* :*: f) g p ⊗ w) Source # |
TensorSpace (f p) => TensorSpace (M1 * i c f p) Source # | |
Methods scalarSpaceWitness :: ScalarSpaceWitness (M1 * i c f p) Source # linearManifoldWitness :: LinearManifoldWitness (M1 * i c f p) Source # zeroTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => M1 * i c f p ⊗ w Source # toFlatTensor :: M1 * i c f p -+> (M1 * i c f p ⊗ Scalar (M1 * i c f p)) Source # fromFlatTensor :: (M1 * i c f p ⊗ Scalar (M1 * i c f p)) -+> M1 * i c f p Source # addTensors :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => (M1 * i c f p ⊗ w) -> (M1 * i c f p ⊗ w) -> M1 * i c f p ⊗ w Source # subtractTensors :: (TensorSpace (M1 * i c f p), TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => (M1 * i c f p ⊗ w) -> (M1 * i c f p ⊗ w) -> M1 * i c f p ⊗ w Source # scaleTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => Bilinear (Scalar (M1 * i c f p)) (M1 * i c f p ⊗ w) (M1 * i c f p ⊗ w) Source # negateTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => (M1 * i c f p ⊗ w) -+> (M1 * i c f p ⊗ w) Source # tensorProduct :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => Bilinear (M1 * i c f p) w (M1 * i c f p ⊗ w) Source # tensorProducts :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => [(M1 * i c f p, w)] -> M1 * i c f p ⊗ w Source # transposeTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => (M1 * i c f p ⊗ w) -+> (w ⊗ M1 * i c f p) Source # fmapTensor :: (TensorSpace w, TensorSpace x, (* ~ Scalar w) (Scalar (M1 * i c f p)), (* ~ Scalar x) (Scalar (M1 * i c f p))) => Bilinear (w -+> x) (M1 * i c f p ⊗ w) (M1 * i c f p ⊗ x) Source # fzipTensorWith :: (TensorSpace u, TensorSpace w, TensorSpace x, (* ~ Scalar u) (Scalar (M1 * i c f p)), (* ~ Scalar w) (Scalar (M1 * i c f p)), (* ~ Scalar x) (Scalar (M1 * i c f p))) => Bilinear ((w, x) -+> u) (M1 * i c f p ⊗ w, M1 * i c f p ⊗ x) (M1 * i c f p ⊗ u) Source # coerceFmapTensorProduct :: Functor p => p (M1 * i c f p) -> Coercion * a b -> Coercion * (TensorProduct (M1 * i c f p) a) (TensorProduct (M1 * i c f p) b) Source # wellDefinedVector :: M1 * i c f p -> Maybe (M1 * i c f p) Source # wellDefinedTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => (M1 * i c f p ⊗ w) -> Maybe (M1 * i c f p ⊗ w) Source # |
class (TensorSpace v, Num (Scalar v)) => LinearSpace v where Source #
The class of vector spaces v
for which LinearMap
s v w
is well-implemented.
Associated Types
type DualVector v :: * Source #
Suitable representation of a linear map from the space v
to its field.
For the usual euclidean spaces, you can just define DualVector
v = v
.
(In this case, a dual vector will be just a “row vector” if you consider
v
-vectors as “column vectors”. LinearMap
will then effectively have
a matrix layout.)
Methods
dualSpaceWitness :: DualSpaceWitness v Source #
linearId :: v +> v Source #
idTensor :: v ⊗ DualVector v Source #
sampleLinearFunction :: (TensorSpace w, Scalar v ~ Scalar w) => (v -+> w) -+> (v +> w) Source #
toLinearForm :: DualVector v -+> (v +> Scalar v) Source #
fromLinearForm :: (v +> Scalar v) -+> DualVector v Source #
coerceDoubleDual :: Coercion v (DualVector (DualVector v)) Source #
trace :: (v +> v) -+> Scalar v Source #
contractTensorMap :: (TensorSpace w, Scalar w ~ Scalar v) => (v +> (v ⊗ w)) -+> w Source #
contractMapTensor :: (TensorSpace w, Scalar w ~ Scalar v) => (v ⊗ (v +> w)) -+> w Source #
contractTensorFn :: forall w. (TensorSpace w, Scalar w ~ Scalar v) => (v -+> (v ⊗ w)) -+> w Source #
contractLinearMapAgainst :: (LinearSpace w, Scalar w ~ Scalar v) => Bilinear (v +> w) (w -+> v) (Scalar v) Source #
applyDualVector :: LinearSpace v => Bilinear (DualVector v) v (Scalar v) Source #
applyLinear :: (TensorSpace w, Scalar w ~ Scalar v) => Bilinear (v +> w) v w Source #
composeLinear :: (LinearSpace w, TensorSpace x, Scalar w ~ Scalar v, Scalar x ~ Scalar v) => Bilinear (w +> x) (v +> w) (v +> x) Source #
tensorId :: (LinearSpace w, Scalar w ~ Scalar v) => (v ⊗ w) +> (v ⊗ w) Source #
applyTensorFunctional :: (LinearSpace u, Scalar u ~ Scalar v) => Bilinear (DualVector (v ⊗ u)) (v ⊗ u) (Scalar v) Source #
applyTensorLinMap :: (LinearSpace u, TensorSpace w, Scalar u ~ Scalar v, Scalar w ~ Scalar v) => Bilinear ((v ⊗ u) +> w) (v ⊗ u) w Source #
Instances
(Num' s, Semimanifold m, LinearSpace (Needle (VRep m)), (~) * (Scalar (Needle m)) s, (~) * (Scalar (Needle (VRep m))) s) => LinearSpace (GenericNeedle m) Source # | |
Methods dualSpaceWitness :: DualSpaceWitness (GenericNeedle m) Source # linearId :: GenericNeedle m +> GenericNeedle m Source # idTensor :: GenericNeedle m ⊗ DualVector (GenericNeedle m) Source # sampleLinearFunction :: (TensorSpace w, (* ~ Scalar (GenericNeedle m)) (Scalar w)) => (GenericNeedle m -+> w) -+> (GenericNeedle m +> w) Source # toLinearForm :: DualVector (GenericNeedle m) -+> (GenericNeedle m +> Scalar (GenericNeedle m)) Source # fromLinearForm :: (GenericNeedle m +> Scalar (GenericNeedle m)) -+> DualVector (GenericNeedle m) Source # coerceDoubleDual :: Coercion * (GenericNeedle m) (DualVector (DualVector (GenericNeedle m))) Source # trace :: (GenericNeedle m +> GenericNeedle m) -+> Scalar (GenericNeedle m) Source # contractTensorMap :: (TensorSpace w, (* ~ Scalar w) (Scalar (GenericNeedle m))) => (GenericNeedle m +> (GenericNeedle m ⊗ w)) -+> w Source # contractMapTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar (GenericNeedle m))) => (GenericNeedle m ⊗ (GenericNeedle m +> w)) -+> w Source # contractTensorFn :: (TensorSpace w, (* ~ Scalar w) (Scalar (GenericNeedle m))) => (GenericNeedle m -+> (GenericNeedle m ⊗ w)) -+> w Source # contractLinearMapAgainst :: (LinearSpace w, (* ~ Scalar w) (Scalar (GenericNeedle m))) => Bilinear (GenericNeedle m +> w) (w -+> GenericNeedle m) (Scalar (GenericNeedle m)) Source # applyDualVector :: Bilinear (DualVector (GenericNeedle m)) (GenericNeedle m) (Scalar (GenericNeedle m)) Source # applyLinear :: (TensorSpace w, (* ~ Scalar w) (Scalar (GenericNeedle m))) => Bilinear (GenericNeedle m +> w) (GenericNeedle m) w Source # composeLinear :: (LinearSpace w, TensorSpace x, (* ~ Scalar w) (Scalar (GenericNeedle m)), (* ~ Scalar x) (Scalar (GenericNeedle m))) => Bilinear (w +> x) (GenericNeedle m +> w) (GenericNeedle m +> x) Source # tensorId :: (LinearSpace w, (* ~ Scalar w) (Scalar (GenericNeedle m))) => (GenericNeedle m ⊗ w) +> (GenericNeedle m ⊗ w) Source # applyTensorFunctional :: (LinearSpace u, (* ~ Scalar u) (Scalar (GenericNeedle m))) => Bilinear (DualVector (GenericNeedle m ⊗ u)) (GenericNeedle m ⊗ u) (Scalar (GenericNeedle m)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar (GenericNeedle m)), (* ~ Scalar w) (Scalar (GenericNeedle m))) => Bilinear ((GenericNeedle m ⊗ u) +> w) (GenericNeedle m ⊗ u) w Source # |
Num' s => LinearSpace (ZeroDim s) Source # | |
Methods dualSpaceWitness :: DualSpaceWitness (ZeroDim s) Source # linearId :: ZeroDim s +> ZeroDim s Source # idTensor :: ZeroDim s ⊗ DualVector (ZeroDim s) Source # sampleLinearFunction :: (TensorSpace w, (* ~ Scalar (ZeroDim s)) (Scalar w)) => (ZeroDim s -+> w) -+> (ZeroDim s +> w) Source # toLinearForm :: DualVector (ZeroDim s) -+> (ZeroDim s +> Scalar (ZeroDim s)) Source # fromLinearForm :: (ZeroDim s +> Scalar (ZeroDim s)) -+> DualVector (ZeroDim s) Source # coerceDoubleDual :: Coercion * (ZeroDim s) (DualVector (DualVector (ZeroDim s))) Source # trace :: (ZeroDim s +> ZeroDim s) -+> Scalar (ZeroDim s) Source # contractTensorMap :: (TensorSpace w, (* ~ Scalar w) (Scalar (ZeroDim s))) => (ZeroDim s +> (ZeroDim s ⊗ w)) -+> w Source # contractMapTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar (ZeroDim s))) => (ZeroDim s ⊗ (ZeroDim s +> w)) -+> w Source # contractTensorFn :: (TensorSpace w, (* ~ Scalar w) (Scalar (ZeroDim s))) => (ZeroDim s -+> (ZeroDim s ⊗ w)) -+> w Source # contractLinearMapAgainst :: (LinearSpace w, (* ~ Scalar w) (Scalar (ZeroDim s))) => Bilinear (ZeroDim s +> w) (w -+> ZeroDim s) (Scalar (ZeroDim s)) Source # applyDualVector :: Bilinear (DualVector (ZeroDim s)) (ZeroDim s) (Scalar (ZeroDim s)) Source # applyLinear :: (TensorSpace w, (* ~ Scalar w) (Scalar (ZeroDim s))) => Bilinear (ZeroDim s +> w) (ZeroDim s) w Source # composeLinear :: (LinearSpace w, TensorSpace x, (* ~ Scalar w) (Scalar (ZeroDim s)), (* ~ Scalar x) (Scalar (ZeroDim s))) => Bilinear (w +> x) (ZeroDim s +> w) (ZeroDim s +> x) Source # tensorId :: (LinearSpace w, (* ~ Scalar w) (Scalar (ZeroDim s))) => (ZeroDim s ⊗ w) +> (ZeroDim s ⊗ w) Source # applyTensorFunctional :: (LinearSpace u, (* ~ Scalar u) (Scalar (ZeroDim s))) => Bilinear (DualVector (ZeroDim s ⊗ u)) (ZeroDim s ⊗ u) (Scalar (ZeroDim s)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar (ZeroDim s)), (* ~ Scalar w) (Scalar (ZeroDim s))) => Bilinear ((ZeroDim s ⊗ u) +> w) (ZeroDim s ⊗ u) w Source # |
(LinearSpace u, LinearSpace v, (~) * (Scalar u) (Scalar v)) => LinearSpace (u, v) Source # | |
Methods dualSpaceWitness :: DualSpaceWitness (u, v) Source # linearId :: (u, v) +> (u, v) Source # idTensor :: (u, v) ⊗ DualVector (u, v) Source # sampleLinearFunction :: (TensorSpace w, (* ~ Scalar (u, v)) (Scalar w)) => ((u, v) -+> w) -+> ((u, v) +> w) Source # toLinearForm :: DualVector (u, v) -+> ((u, v) +> Scalar (u, v)) Source # fromLinearForm :: ((u, v) +> Scalar (u, v)) -+> DualVector (u, v) Source # coerceDoubleDual :: Coercion * (u, v) (DualVector (DualVector (u, v))) Source # trace :: ((u, v) +> (u, v)) -+> Scalar (u, v) Source # contractTensorMap :: (TensorSpace w, (* ~ Scalar w) (Scalar (u, v))) => ((u, v) +> ((u, v) ⊗ w)) -+> w Source # contractMapTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar (u, v))) => ((u, v) ⊗ ((u, v) +> w)) -+> w Source # contractTensorFn :: (TensorSpace w, (* ~ Scalar w) (Scalar (u, v))) => ((u, v) -+> ((u, v) ⊗ w)) -+> w Source # contractLinearMapAgainst :: (LinearSpace w, (* ~ Scalar w) (Scalar (u, v))) => Bilinear ((u, v) +> w) (w -+> (u, v)) (Scalar (u, v)) Source # applyDualVector :: Bilinear (DualVector (u, v)) (u, v) (Scalar (u, v)) Source # applyLinear :: (TensorSpace w, (* ~ Scalar w) (Scalar (u, v))) => Bilinear ((u, v) +> w) (u, v) w Source # composeLinear :: (LinearSpace w, TensorSpace x, (* ~ Scalar w) (Scalar (u, v)), (* ~ Scalar x) (Scalar (u, v))) => Bilinear (w +> x) ((u, v) +> w) ((u, v) +> x) Source # tensorId :: (LinearSpace w, (* ~ Scalar w) (Scalar (u, v))) => ((u, v) ⊗ w) +> ((u, v) ⊗ w) Source # applyTensorFunctional :: (LinearSpace u, (* ~ Scalar u) (Scalar (u, v))) => Bilinear (DualVector ((u, v) ⊗ u)) ((u, v) ⊗ u) (Scalar (u, v)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar (u, v)), (* ~ Scalar w) (Scalar (u, v))) => Bilinear (((u, v) ⊗ u) +> w) ((u, v) ⊗ u) w Source # |
(Num' s, LinearSpace v, (~) * (Scalar v) s) => LinearSpace (SymmetricTensor s v) 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 # |
(LinearSpace v, Num (Scalar v)) => LinearSpace (Rec0 * v s) Source # | |
Methods dualSpaceWitness :: DualSpaceWitness (Rec0 * v s) Source # linearId :: Rec0 * v s +> Rec0 * v s Source # idTensor :: Rec0 * v s ⊗ DualVector (Rec0 * v s) Source # sampleLinearFunction :: (TensorSpace w, (* ~ Scalar (Rec0 * v s)) (Scalar w)) => (Rec0 * v s -+> w) -+> (Rec0 * v s +> w) Source # toLinearForm :: DualVector (Rec0 * v s) -+> (Rec0 * v s +> Scalar (Rec0 * v s)) Source # fromLinearForm :: (Rec0 * v s +> Scalar (Rec0 * v s)) -+> DualVector (Rec0 * v s) Source # coerceDoubleDual :: Coercion * (Rec0 * v s) (DualVector (DualVector (Rec0 * v s))) Source # trace :: (Rec0 * v s +> Rec0 * v s) -+> Scalar (Rec0 * v s) Source # contractTensorMap :: (TensorSpace w, (* ~ Scalar w) (Scalar (Rec0 * v s))) => (Rec0 * v s +> (Rec0 * v s ⊗ w)) -+> w Source # contractMapTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar (Rec0 * v s))) => (Rec0 * v s ⊗ (Rec0 * v s +> w)) -+> w Source # contractTensorFn :: (TensorSpace w, (* ~ Scalar w) (Scalar (Rec0 * v s))) => (Rec0 * v s -+> (Rec0 * v s ⊗ w)) -+> w Source # contractLinearMapAgainst :: (LinearSpace w, (* ~ Scalar w) (Scalar (Rec0 * v s))) => Bilinear (Rec0 * v s +> w) (w -+> Rec0 * v s) (Scalar (Rec0 * v s)) Source # applyDualVector :: Bilinear (DualVector (Rec0 * v s)) (Rec0 * v s) (Scalar (Rec0 * v s)) Source # applyLinear :: (TensorSpace w, (* ~ Scalar w) (Scalar (Rec0 * v s))) => Bilinear (Rec0 * v s +> w) (Rec0 * v s) w Source # composeLinear :: (LinearSpace 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 # tensorId :: (LinearSpace w, (* ~ Scalar w) (Scalar (Rec0 * v s))) => (Rec0 * v s ⊗ w) +> (Rec0 * v s ⊗ w) Source # applyTensorFunctional :: (LinearSpace u, (* ~ Scalar u) (Scalar (Rec0 * v s))) => Bilinear (DualVector (Rec0 * v s ⊗ u)) (Rec0 * v s ⊗ u) (Scalar (Rec0 * v s)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar (Rec0 * v s)), (* ~ Scalar w) (Scalar (Rec0 * v s))) => Bilinear ((Rec0 * v s ⊗ u) +> w) (Rec0 * v s ⊗ u) w Source # |
(LinearSpace u, LinearSpace v, (~) * (Scalar u) s, (~) * (Scalar v) s) => LinearSpace (LinearFunction s u v) 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 u, (* ~ Scalar u) (Scalar (LinearFunction s u v))) => Bilinear (DualVector (LinearFunction s u v ⊗ u)) (LinearFunction s u v ⊗ u) (Scalar (LinearFunction s u v)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar (LinearFunction s u v)), (* ~ Scalar w) (Scalar (LinearFunction s u v))) => Bilinear ((LinearFunction s u v ⊗ u) +> w) (LinearFunction s u v ⊗ u) w Source # |
(LinearSpace u, LinearSpace v, (~) * (Scalar u) s, (~) * (Scalar v) s) => LinearSpace (Tensor s u v) 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 u, (* ~ Scalar u) (Scalar (Tensor s u v))) => Bilinear (DualVector (Tensor s u v ⊗ u)) (Tensor s u v ⊗ u) (Scalar (Tensor s u v)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar (Tensor s u v)), (* ~ Scalar w) (Scalar (Tensor s u v))) => Bilinear ((Tensor s u v ⊗ u) +> w) (Tensor s u v ⊗ u) w Source # |
(LinearSpace u, LinearSpace v, (~) * (Scalar u) s, (~) * (Scalar v) s) => LinearSpace (LinearMap s u v) 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 u, (* ~ Scalar u) (Scalar (LinearMap s u v))) => Bilinear (DualVector (LinearMap s u v ⊗ u)) (LinearMap s u v ⊗ u) (Scalar (LinearMap s u v)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar (LinearMap s u v)), (* ~ Scalar w) (Scalar (LinearMap s u v))) => Bilinear ((LinearMap s u v ⊗ u) +> w) (LinearMap s u v ⊗ u) w Source # |
(LinearSpace (f p), LinearSpace (g p), (~) * (Scalar (f p)) (Scalar (g p))) => LinearSpace ((:*:) * f g p) Source # | |
Methods dualSpaceWitness :: DualSpaceWitness ((* :*: f) g p) Source # linearId :: (* :*: f) g p +> (* :*: f) g p Source # idTensor :: (* :*: f) g p ⊗ DualVector ((* :*: f) g p) Source # sampleLinearFunction :: (TensorSpace w, (* ~ Scalar ((* :*: f) g p)) (Scalar w)) => ((* :*: f) g p -+> w) -+> ((* :*: f) g p +> w) Source # toLinearForm :: DualVector ((* :*: f) g p) -+> ((* :*: f) g p +> Scalar ((* :*: f) g p)) Source # fromLinearForm :: ((* :*: f) g p +> Scalar ((* :*: f) g p)) -+> DualVector ((* :*: f) g p) Source # coerceDoubleDual :: Coercion * ((* :*: f) g p) (DualVector (DualVector ((* :*: f) g p))) Source # trace :: ((* :*: f) g p +> (* :*: f) g p) -+> Scalar ((* :*: f) g p) Source # contractTensorMap :: (TensorSpace w, (* ~ Scalar w) (Scalar ((* :*: f) g p))) => ((* :*: f) g p +> ((* :*: f) g p ⊗ w)) -+> w Source # contractMapTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar ((* :*: f) g p))) => ((* :*: f) g p ⊗ ((* :*: f) g p +> w)) -+> w Source # contractTensorFn :: (TensorSpace w, (* ~ Scalar w) (Scalar ((* :*: f) g p))) => ((* :*: f) g p -+> ((* :*: f) g p ⊗ w)) -+> w Source # contractLinearMapAgainst :: (LinearSpace w, (* ~ Scalar w) (Scalar ((* :*: f) g p))) => Bilinear ((* :*: f) g p +> w) (w -+> (* :*: f) g p) (Scalar ((* :*: f) g p)) Source # applyDualVector :: Bilinear (DualVector ((* :*: f) g p)) ((* :*: f) g p) (Scalar ((* :*: f) g p)) Source # applyLinear :: (TensorSpace w, (* ~ Scalar w) (Scalar ((* :*: f) g p))) => Bilinear ((* :*: f) g p +> w) ((* :*: f) g p) w Source # composeLinear :: (LinearSpace w, TensorSpace x, (* ~ Scalar w) (Scalar ((* :*: f) g p)), (* ~ Scalar x) (Scalar ((* :*: f) g p))) => Bilinear (w +> x) ((* :*: f) g p +> w) ((* :*: f) g p +> x) Source # tensorId :: (LinearSpace w, (* ~ Scalar w) (Scalar ((* :*: f) g p))) => ((* :*: f) g p ⊗ w) +> ((* :*: f) g p ⊗ w) Source # applyTensorFunctional :: (LinearSpace u, (* ~ Scalar u) (Scalar ((* :*: f) g p))) => Bilinear (DualVector ((* :*: f) g p ⊗ u)) ((* :*: f) g p ⊗ u) (Scalar ((* :*: f) g p)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar ((* :*: f) g p)), (* ~ Scalar w) (Scalar ((* :*: f) g p))) => Bilinear (((* :*: f) g p ⊗ u) +> w) ((* :*: f) g p ⊗ u) w Source # |
(LinearSpace (f p), Num (Scalar (f p))) => LinearSpace (M1 * i c f p) Source # | |
Methods dualSpaceWitness :: DualSpaceWitness (M1 * i c f p) Source # linearId :: M1 * i c f p +> M1 * i c f p Source # idTensor :: M1 * i c f p ⊗ DualVector (M1 * i c f p) Source # sampleLinearFunction :: (TensorSpace w, (* ~ Scalar (M1 * i c f p)) (Scalar w)) => (M1 * i c f p -+> w) -+> (M1 * i c f p +> w) Source # toLinearForm :: DualVector (M1 * i c f p) -+> (M1 * i c f p +> Scalar (M1 * i c f p)) Source # fromLinearForm :: (M1 * i c f p +> Scalar (M1 * i c f p)) -+> DualVector (M1 * i c f p) Source # coerceDoubleDual :: Coercion * (M1 * i c f p) (DualVector (DualVector (M1 * i c f p))) Source # trace :: (M1 * i c f p +> M1 * i c f p) -+> Scalar (M1 * i c f p) Source # contractTensorMap :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => (M1 * i c f p +> (M1 * i c f p ⊗ w)) -+> w Source # contractMapTensor :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => (M1 * i c f p ⊗ (M1 * i c f p +> w)) -+> w Source # contractTensorFn :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => (M1 * i c f p -+> (M1 * i c f p ⊗ w)) -+> w Source # contractLinearMapAgainst :: (LinearSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => Bilinear (M1 * i c f p +> w) (w -+> M1 * i c f p) (Scalar (M1 * i c f p)) Source # applyDualVector :: Bilinear (DualVector (M1 * i c f p)) (M1 * i c f p) (Scalar (M1 * i c f p)) Source # applyLinear :: (TensorSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => Bilinear (M1 * i c f p +> w) (M1 * i c f p) w Source # composeLinear :: (LinearSpace w, TensorSpace x, (* ~ Scalar w) (Scalar (M1 * i c f p)), (* ~ Scalar x) (Scalar (M1 * i c f p))) => Bilinear (w +> x) (M1 * i c f p +> w) (M1 * i c f p +> x) Source # tensorId :: (LinearSpace w, (* ~ Scalar w) (Scalar (M1 * i c f p))) => (M1 * i c f p ⊗ w) +> (M1 * i c f p ⊗ w) Source # applyTensorFunctional :: (LinearSpace u, (* ~ Scalar u) (Scalar (M1 * i c f p))) => Bilinear (DualVector (M1 * i c f p ⊗ u)) (M1 * i c f p ⊗ u) (Scalar (M1 * i c f p)) Source # applyTensorLinMap :: (LinearSpace u, TensorSpace w, (* ~ Scalar u) (Scalar (M1 * i c f p)), (* ~ Scalar w) (Scalar (M1 * i c f p))) => Bilinear ((M1 * i c f p ⊗ u) +> w) (M1 * i c f p ⊗ u) w Source # |
Orthonormal systems
class LinearSpace v => SemiInner v where Source #
SemiInner
is the class of vector spaces with finite subspaces in which
you can define a basis that can be used to project from the whole space
into the subspace. The usual application is for using a kind of
Galerkin method to
give an approximate solution (see \$
) to a linear equation in a possibly
infinite-dimensional space.
Of course, this also works for spaces which are already finite-dimensional themselves.
Methods
dualBasisCandidates :: [(Int, v)] -> Forest (Int, DualVector v) Source #
Lazily enumerate choices of a basis of functionals that can be made dual
to the given vectors, in order of preference (which roughly means, large in
the normal direction.) I.e., if the vector 𝑣
is assigned early to the
dual vector 𝑣'
, then (𝑣' $ 𝑣)
should be large and all the other products
comparably small.
The purpose is that we should be able to make this basis orthonormal
with a ~Gaussian-elimination approach, in a way that stays numerically
stable. This is otherwise known as the choice of a pivot element.
For simple finite-dimensional array-vectors, you can easily define this
method using cartesianDualBasisCandidates
.
tensorDualBasisCandidates :: (SemiInner w, Scalar w ~ Scalar v) => [(Int, v ⊗ w)] -> Forest (Int, DualVector (v ⊗ w)) Source #
symTensorDualBasisCandidates :: [(Int, SymmetricTensor (Scalar v) v)] -> Forest (Int, SymmetricTensor (Scalar v) (DualVector v)) Source #
symTensorTensorDualBasisCandidates :: forall w. (SemiInner w, Scalar w ~ Scalar v) => [(Int, SymmetricTensor (Scalar v) v ⊗ w)] -> Forest (Int, SymmetricTensor (Scalar v) v +> DualVector w) Source #
Instances
(Fractional' s, Ord s, SemiInner s) => SemiInner (V1 s) Source # | |
Methods dualBasisCandidates :: [(Int, V1 s)] -> Forest (Int, DualVector (V1 s)) Source # tensorDualBasisCandidates :: (SemiInner w, (* ~ Scalar w) (Scalar (V1 s))) => [(Int, V1 s ⊗ w)] -> Forest (Int, DualVector (V1 s ⊗ w)) Source # symTensorDualBasisCandidates :: [(Int, SymmetricTensor (Scalar (V1 s)) (V1 s))] -> Forest (Int, SymmetricTensor (Scalar (V1 s)) (DualVector (V1 s))) Source # symTensorTensorDualBasisCandidates :: (SemiInner w, (* ~ Scalar w) (Scalar (V1 s))) => [(Int, SymmetricTensor (Scalar (V1 s)) (V1 s) ⊗ w)] -> Forest (Int, SymmetricTensor (Scalar (V1 s)) (V1 s) +> DualVector w) Source # |
(Fractional' s, SemiInner s) => SemiInner (V0 s) Source # | |
Methods dualBasisCandidates :: [(Int, V0 s)] -> Forest (Int, DualVector (V0 s)) Source # tensorDualBasisCandidates :: (SemiInner w, (* ~ Scalar w) (Scalar (V0 s))) => [(Int, V0 s ⊗ w)] -> Forest (Int, DualVector (V0 s ⊗ w)) Source # symTensorDualBasisCandidates :: [(Int, SymmetricTensor (Scalar (V0 s)) (V0 s))] -> Forest (Int, SymmetricTensor (Scalar (V0 s)) (DualVector (V0 s))) Source # symTensorTensorDualBasisCandidates :: (SemiInner w, (* ~ Scalar w) (Scalar (V0 s))) => [(Int, SymmetricTensor (Scalar (V0 s)) (V0 s) ⊗ w)] -> Forest (Int, SymmetricTensor (Scalar (V0 s)) (V0 s) +> DualVector w) Source # |
(Fractional' s, SemiInner s) => SemiInner (ZeroDim s) Source # | |
Methods dualBasisCandidates :: [(Int, ZeroDim s)] -> Forest (Int, DualVector (ZeroDim s)) Source # tensorDualBasisCandidates :: (SemiInner w, (* ~ Scalar w) (Scalar (ZeroDim s))) => [(Int, ZeroDim s ⊗ w)] -> Forest (Int, DualVector (ZeroDim s ⊗ w)) Source # symTensorDualBasisCandidates :: [(Int, SymmetricTensor (Scalar (ZeroDim s)) (ZeroDim s))] -> Forest (Int, SymmetricTensor (Scalar (ZeroDim s)) (DualVector (ZeroDim s))) Source # symTensorTensorDualBasisCandidates :: (SemiInner w, (* ~ Scalar w) (Scalar (ZeroDim s))) => [(Int, SymmetricTensor (Scalar (ZeroDim s)) (ZeroDim s) ⊗ w)] -> Forest (Int, SymmetricTensor (Scalar (ZeroDim s)) (ZeroDim s) +> DualVector w) Source # |
(SemiInner u, SemiInner v, (~) * (Scalar u) (Scalar v), Num' (Scalar u)) => SemiInner (u, v) Source # | |
Methods dualBasisCandidates :: [(Int, (u, v))] -> Forest (Int, DualVector (u, v)) Source # tensorDualBasisCandidates :: (SemiInner w, (* ~ Scalar w) (Scalar (u, v))) => [(Int, (u, v) ⊗ w)] -> Forest (Int, DualVector ((u, v) ⊗ w)) Source # symTensorDualBasisCandidates :: [(Int, SymmetricTensor (Scalar (u, v)) (u, v))] -> Forest (Int, SymmetricTensor (Scalar (u, v)) (DualVector (u, v))) Source # symTensorTensorDualBasisCandidates :: (SemiInner w, (* ~ Scalar w) (Scalar (u, v))) => [(Int, SymmetricTensor (Scalar (u, v)) (u, v) ⊗ w)] -> Forest (Int, SymmetricTensor (Scalar (u, v)) (u, v) +> DualVector w) Source # |
(Num' s, SemiInner v, (~) * (Scalar v) s) => SemiInner (SymmetricTensor s v) Source # | |
Methods dualBasisCandidates :: [(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 # |
(SemiInner u, SemiInner v, (~) * (Scalar u) s, (~) * (Scalar v) s) => SemiInner (Tensor s u v) Source # | |
Methods dualBasisCandidates :: [(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 # |
(LinearSpace u, SemiInner (DualVector u), SemiInner v, (~) * (Scalar u) s, (~) * (Scalar v) s) => SemiInner (LinearMap s u v) Source # | |
Methods dualBasisCandidates :: [(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 # |
Finite baseis
class LSpace v => FiniteDimensional v where Source #
Minimal complete definition
entireBasis, enumerateSubBasis, decomposeLinMap, decomposeLinMapWithin, recomposeSB, recomposeSBTensor, recomposeLinMap, recomposeContraLinMap, recomposeContraLinMapTensor, uncanonicallyFromDual, uncanonicallyToDual
Associated Types
data SubBasis v :: * Source #
Whereas Basis
-values refer to a single basis vector, a single
SubBasis
value represents a collection of such basis vectors,
which can be used to associate a vector with a list of coefficients.
For spaces with a canonical finite basis, SubBasis
does not actually
need to contain any information, it can simply have the full finite
basis as its only value. Even for large sparse spaces, it should only
have a very coarse structure that can be shared by many vectors.
Methods
entireBasis :: SubBasis v Source #
enumerateSubBasis :: SubBasis v -> [v] Source #
subbasisDimension :: SubBasis v -> Int Source #
decomposeLinMap :: (LSpace w, Scalar w ~ Scalar v) => (v +> w) -> (SubBasis v, DList w) Source #
Split up a linear map in “column vectors” WRT some suitable basis.
decomposeLinMapWithin :: (LSpace w, Scalar w ~ Scalar v) => SubBasis v -> (v +> w) -> Either (SubBasis v, DList w) (DList w) Source #
Expand in the given basis, if possible. Else yield a superbasis of the given
one, in which this is possible, and the decomposition therein.
recomposeSB :: SubBasis v -> [Scalar v] -> (v, [Scalar v]) Source #
Assemble a vector from coefficients in some basis. Return any excess coefficients.
recomposeSBTensor :: (FiniteDimensional w, Scalar w ~ Scalar v) => SubBasis v -> SubBasis w -> [Scalar v] -> (v ⊗ w, [Scalar v]) Source #
recomposeLinMap :: (LSpace w, Scalar w ~ Scalar v) => SubBasis v -> [w] -> (v +> w, [w]) Source #
recomposeContraLinMap :: (LinearSpace w, Scalar w ~ Scalar v, Functor f) => (f (Scalar w) -> w) -> f (DualVector v) -> v +> w Source #
Given a function that interprets a coefficient-container as a vector representation,
build a linear function mapping to that space.
recomposeContraLinMapTensor :: (FiniteDimensional u, LinearSpace w, Scalar u ~ Scalar v, Scalar w ~ Scalar v, Functor f) => (f (Scalar w) -> w) -> f (v +> DualVector u) -> (v ⊗ u) +> w Source #
uncanonicallyFromDual :: DualVector v -+> v Source #
The existance of a finite basis gives us an isomorphism between a space
and its dual space. Note that this isomorphism is not natural (i.e. it
depends on the actual choice of basis, unlike everything else in this
library).
uncanonicallyToDual :: v -+> DualVector v Source #
Instances
(Num' s, Eq s, LSpace s) => FiniteDimensional (V1 s) Source # | |
Methods entireBasis :: SubBasis (V1 s) Source # enumerateSubBasis :: SubBasis (V1 s) -> [V1 s] Source # subbasisDimension :: SubBasis (V1 s) -> Int Source # decomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (V1 s))) => (V1 s +> w) -> (SubBasis (V1 s), DList w) Source # decomposeLinMapWithin :: (LSpace w, (* ~ Scalar w) (Scalar (V1 s))) => SubBasis (V1 s) -> (V1 s +> w) -> Either (SubBasis (V1 s), DList w) (DList w) Source # recomposeSB :: SubBasis (V1 s) -> [Scalar (V1 s)] -> (V1 s, [Scalar (V1 s)]) Source # recomposeSBTensor :: (FiniteDimensional w, (* ~ Scalar w) (Scalar (V1 s))) => SubBasis (V1 s) -> SubBasis w -> [Scalar (V1 s)] -> (V1 s ⊗ w, [Scalar (V1 s)]) Source # recomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (V1 s))) => SubBasis (V1 s) -> [w] -> (V1 s +> w, [w]) Source # recomposeContraLinMap :: (LinearSpace w, (* ~ Scalar w) (Scalar (V1 s)), Functor f) => (f (Scalar w) -> w) -> f (DualVector (V1 s)) -> V1 s +> w Source # recomposeContraLinMapTensor :: (FiniteDimensional u, LinearSpace w, (* ~ Scalar u) (Scalar (V1 s)), (* ~ Scalar w) (Scalar (V1 s)), Functor f) => (f (Scalar w) -> w) -> f (V1 s +> DualVector u) -> (V1 s ⊗ u) +> w Source # uncanonicallyFromDual :: DualVector (V1 s) -+> V1 s Source # uncanonicallyToDual :: V1 s -+> DualVector (V1 s) Source # |
(Num' s, Eq s, LSpace s) => FiniteDimensional (V2 s) Source # | |
Methods entireBasis :: SubBasis (V2 s) Source # enumerateSubBasis :: SubBasis (V2 s) -> [V2 s] Source # subbasisDimension :: SubBasis (V2 s) -> Int Source # decomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (V2 s))) => (V2 s +> w) -> (SubBasis (V2 s), DList w) Source # decomposeLinMapWithin :: (LSpace w, (* ~ Scalar w) (Scalar (V2 s))) => SubBasis (V2 s) -> (V2 s +> w) -> Either (SubBasis (V2 s), DList w) (DList w) Source # recomposeSB :: SubBasis (V2 s) -> [Scalar (V2 s)] -> (V2 s, [Scalar (V2 s)]) Source # recomposeSBTensor :: (FiniteDimensional w, (* ~ Scalar w) (Scalar (V2 s))) => SubBasis (V2 s) -> SubBasis w -> [Scalar (V2 s)] -> (V2 s ⊗ w, [Scalar (V2 s)]) Source # recomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (V2 s))) => SubBasis (V2 s) -> [w] -> (V2 s +> w, [w]) Source # recomposeContraLinMap :: (LinearSpace w, (* ~ Scalar w) (Scalar (V2 s)), Functor f) => (f (Scalar w) -> w) -> f (DualVector (V2 s)) -> V2 s +> w Source # recomposeContraLinMapTensor :: (FiniteDimensional u, LinearSpace w, (* ~ Scalar u) (Scalar (V2 s)), (* ~ Scalar w) (Scalar (V2 s)), Functor f) => (f (Scalar w) -> w) -> f (V2 s +> DualVector u) -> (V2 s ⊗ u) +> w Source # uncanonicallyFromDual :: DualVector (V2 s) -+> V2 s Source # uncanonicallyToDual :: V2 s -+> DualVector (V2 s) Source # |
(Num' s, Eq s, LSpace s) => FiniteDimensional (V3 s) Source # | |
Methods entireBasis :: SubBasis (V3 s) Source # enumerateSubBasis :: SubBasis (V3 s) -> [V3 s] Source # subbasisDimension :: SubBasis (V3 s) -> Int Source # decomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (V3 s))) => (V3 s +> w) -> (SubBasis (V3 s), DList w) Source # decomposeLinMapWithin :: (LSpace w, (* ~ Scalar w) (Scalar (V3 s))) => SubBasis (V3 s) -> (V3 s +> w) -> Either (SubBasis (V3 s), DList w) (DList w) Source # recomposeSB :: SubBasis (V3 s) -> [Scalar (V3 s)] -> (V3 s, [Scalar (V3 s)]) Source # recomposeSBTensor :: (FiniteDimensional w, (* ~ Scalar w) (Scalar (V3 s))) => SubBasis (V3 s) -> SubBasis w -> [Scalar (V3 s)] -> (V3 s ⊗ w, [Scalar (V3 s)]) Source # recomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (V3 s))) => SubBasis (V3 s) -> [w] -> (V3 s +> w, [w]) Source # recomposeContraLinMap :: (LinearSpace w, (* ~ Scalar w) (Scalar (V3 s)), Functor f) => (f (Scalar w) -> w) -> f (DualVector (V3 s)) -> V3 s +> w Source # recomposeContraLinMapTensor :: (FiniteDimensional u, LinearSpace w, (* ~ Scalar u) (Scalar (V3 s)), (* ~ Scalar w) (Scalar (V3 s)), Functor f) => (f (Scalar w) -> w) -> f (V3 s +> DualVector u) -> (V3 s ⊗ u) +> w Source # uncanonicallyFromDual :: DualVector (V3 s) -+> V3 s Source # uncanonicallyToDual :: V3 s -+> DualVector (V3 s) Source # |
(Num' s, Eq s, LSpace s) => FiniteDimensional (V4 s) Source # | |
Methods entireBasis :: SubBasis (V4 s) Source # enumerateSubBasis :: SubBasis (V4 s) -> [V4 s] Source # subbasisDimension :: SubBasis (V4 s) -> Int Source # decomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (V4 s))) => (V4 s +> w) -> (SubBasis (V4 s), DList w) Source # decomposeLinMapWithin :: (LSpace w, (* ~ Scalar w) (Scalar (V4 s))) => SubBasis (V4 s) -> (V4 s +> w) -> Either (SubBasis (V4 s), DList w) (DList w) Source # recomposeSB :: SubBasis (V4 s) -> [Scalar (V4 s)] -> (V4 s, [Scalar (V4 s)]) Source # recomposeSBTensor :: (FiniteDimensional w, (* ~ Scalar w) (Scalar (V4 s))) => SubBasis (V4 s) -> SubBasis w -> [Scalar (V4 s)] -> (V4 s ⊗ w, [Scalar (V4 s)]) Source # recomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (V4 s))) => SubBasis (V4 s) -> [w] -> (V4 s +> w, [w]) Source # recomposeContraLinMap :: (LinearSpace w, (* ~ Scalar w) (Scalar (V4 s)), Functor f) => (f (Scalar w) -> w) -> f (DualVector (V4 s)) -> V4 s +> w Source # recomposeContraLinMapTensor :: (FiniteDimensional u, LinearSpace w, (* ~ Scalar u) (Scalar (V4 s)), (* ~ Scalar w) (Scalar (V4 s)), Functor f) => (f (Scalar w) -> w) -> f (V4 s +> DualVector u) -> (V4 s ⊗ u) +> w Source # uncanonicallyFromDual :: DualVector (V4 s) -+> V4 s Source # uncanonicallyToDual :: V4 s -+> DualVector (V4 s) Source # |
(Num' s, Eq s, LinearSpace s) => FiniteDimensional (V0 s) Source # | |
Methods entireBasis :: SubBasis (V0 s) Source # enumerateSubBasis :: SubBasis (V0 s) -> [V0 s] Source # subbasisDimension :: SubBasis (V0 s) -> Int Source # decomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (V0 s))) => (V0 s +> w) -> (SubBasis (V0 s), DList w) Source # decomposeLinMapWithin :: (LSpace w, (* ~ Scalar w) (Scalar (V0 s))) => SubBasis (V0 s) -> (V0 s +> w) -> Either (SubBasis (V0 s), DList w) (DList w) Source # recomposeSB :: SubBasis (V0 s) -> [Scalar (V0 s)] -> (V0 s, [Scalar (V0 s)]) Source # recomposeSBTensor :: (FiniteDimensional w, (* ~ Scalar w) (Scalar (V0 s))) => SubBasis (V0 s) -> SubBasis w -> [Scalar (V0 s)] -> (V0 s ⊗ w, [Scalar (V0 s)]) Source # recomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (V0 s))) => SubBasis (V0 s) -> [w] -> (V0 s +> w, [w]) Source # recomposeContraLinMap :: (LinearSpace w, (* ~ Scalar w) (Scalar (V0 s)), Functor f) => (f (Scalar w) -> w) -> f (DualVector (V0 s)) -> V0 s +> w Source # recomposeContraLinMapTensor :: (FiniteDimensional u, LinearSpace w, (* ~ Scalar u) (Scalar (V0 s)), (* ~ Scalar w) (Scalar (V0 s)), Functor f) => (f (Scalar w) -> w) -> f (V0 s +> DualVector u) -> (V0 s ⊗ u) +> w Source # uncanonicallyFromDual :: DualVector (V0 s) -+> V0 s Source # uncanonicallyToDual :: V0 s -+> DualVector (V0 s) Source # |
Num' s => FiniteDimensional (ZeroDim s) Source # | |
Methods entireBasis :: SubBasis (ZeroDim s) Source # enumerateSubBasis :: SubBasis (ZeroDim s) -> [ZeroDim s] Source # subbasisDimension :: SubBasis (ZeroDim s) -> Int Source # decomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (ZeroDim s))) => (ZeroDim s +> w) -> (SubBasis (ZeroDim s), DList w) Source # decomposeLinMapWithin :: (LSpace w, (* ~ Scalar w) (Scalar (ZeroDim s))) => SubBasis (ZeroDim s) -> (ZeroDim s +> w) -> Either (SubBasis (ZeroDim s), DList w) (DList w) Source # recomposeSB :: SubBasis (ZeroDim s) -> [Scalar (ZeroDim s)] -> (ZeroDim s, [Scalar (ZeroDim s)]) Source # recomposeSBTensor :: (FiniteDimensional w, (* ~ Scalar w) (Scalar (ZeroDim s))) => SubBasis (ZeroDim s) -> SubBasis w -> [Scalar (ZeroDim s)] -> (ZeroDim s ⊗ w, [Scalar (ZeroDim s)]) Source # recomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (ZeroDim s))) => SubBasis (ZeroDim s) -> [w] -> (ZeroDim s +> w, [w]) Source # recomposeContraLinMap :: (LinearSpace w, (* ~ Scalar w) (Scalar (ZeroDim s)), Functor f) => (f (Scalar w) -> w) -> f (DualVector (ZeroDim s)) -> ZeroDim s +> w Source # recomposeContraLinMapTensor :: (FiniteDimensional u, LinearSpace w, (* ~ Scalar u) (Scalar (ZeroDim s)), (* ~ Scalar w) (Scalar (ZeroDim s)), Functor f) => (f (Scalar w) -> w) -> f (ZeroDim s +> DualVector u) -> (ZeroDim s ⊗ u) +> w Source # uncanonicallyFromDual :: DualVector (ZeroDim s) -+> ZeroDim s Source # uncanonicallyToDual :: ZeroDim s -+> DualVector (ZeroDim s) Source # |
(FiniteDimensional u, FiniteDimensional v, (~) * (Scalar u) (Scalar v), (~) * (Scalar (DualVector u)) (Scalar (DualVector v))) => FiniteDimensional (u, v) Source # | |
Methods entireBasis :: SubBasis (u, v) Source # enumerateSubBasis :: SubBasis (u, v) -> [(u, v)] Source # subbasisDimension :: SubBasis (u, v) -> Int Source # decomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (u, v))) => ((u, v) +> w) -> (SubBasis (u, v), DList w) Source # decomposeLinMapWithin :: (LSpace w, (* ~ Scalar w) (Scalar (u, v))) => SubBasis (u, v) -> ((u, v) +> w) -> Either (SubBasis (u, v), DList w) (DList w) Source # recomposeSB :: SubBasis (u, v) -> [Scalar (u, v)] -> ((u, v), [Scalar (u, v)]) Source # recomposeSBTensor :: (FiniteDimensional w, (* ~ Scalar w) (Scalar (u, v))) => SubBasis (u, v) -> SubBasis w -> [Scalar (u, v)] -> ((u, v) ⊗ w, [Scalar (u, v)]) Source # recomposeLinMap :: (LSpace w, (* ~ Scalar w) (Scalar (u, v))) => SubBasis (u, v) -> [w] -> ((u, v) +> w, [w]) Source # recomposeContraLinMap :: (LinearSpace w, (* ~ Scalar w) (Scalar (u, v)), Functor f) => (f (Scalar w) -> w) -> f (DualVector (u, v)) -> (u, v) +> w Source # recomposeContraLinMapTensor :: (FiniteDimensional u, LinearSpace w, (* ~ Scalar u) (Scalar (u, v)), (* ~ Scalar w) (Scalar (u, v)), Functor f) => (f (Scalar w) -> w) -> f ((u, v) +> DualVector u) -> ((u, v) ⊗ u) +> w Source # uncanonicallyFromDual :: DualVector (u, v) -+> (u, v) Source # uncanonicallyToDual :: (u, v) -+> DualVector (u, v) Source # |
(FiniteDimensional v, (~) * (Scalar v) s, (~) * (Scalar (DualVector v)) s, RealFloat' s) => FiniteDimensional (SymmetricTensor s v) 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 # |
(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 # | |
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 u, LinearSpace w, (* ~ Scalar u) (Scalar (Tensor s u v)), (* ~ Scalar w) (Scalar (Tensor s u v)), Functor f) => (f (Scalar w) -> w) -> f (Tensor s u v +> DualVector u) -> (Tensor s u v ⊗ u) +> w Source # uncanonicallyFromDual :: DualVector (Tensor s u v) -+> Tensor s u v Source # uncanonicallyToDual :: Tensor s u v -+> DualVector (Tensor s u v) 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 # | |
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 u, LinearSpace w, (* ~ Scalar u) (Scalar (LinearMap s u v)), (* ~ Scalar w) (Scalar (LinearMap s u v)), Functor f) => (f (Scalar w) -> w) -> f (LinearMap s u v +> DualVector u) -> (LinearMap s u v ⊗ u) +> w Source # uncanonicallyFromDual :: DualVector (LinearMap s u v) -+> LinearMap s u v Source # uncanonicallyToDual :: LinearMap s u v -+> DualVector (LinearMap s u v) Source # |
Utility
Linear primitives
Tensors with basis decomposition
Hilbert space operations
(·) :: TensorQuot v w => (v ⨸ w) -> v -> w infixl 7 Source #
Generalised multiplication operation. This subsumes <.>^
and *^
.
For scalars therefore also *
, and for InnerSpace
, <.>
.
Constraint synonyms
type RealSpace v = (LinearSpace v, Scalar v ~ ℝ, TensorQuot v ℝ, (v ⨸ ℝ) ~ DualVector v, TensorQuot v v, (v ⨸ v) ~ ℝ) Source #
A space in which you can use '·' both for scaling with a real number,
and as dot-product for obtaining such a number.
Double-dual, scalar-scalar etc. identity
Misc
relaxNorm :: forall v. SimpleSpace v => Norm v -> [v] -> Norm v Source #
Modify a norm in such a way that the given vectors lie within its unit ball.
(Not optimally – the unit ball may be bigger than necessary.)
sharedSeminormSpanningSystem :: forall v. SimpleSpace v => Seminorm v -> Seminorm v -> [(DualVector v, Maybe (Scalar v))] Source #
Like 'sharedNormSpanningSystem n₀ n₁', but allows either of the norms
to be singular.
n₀ = spanNorm
[dv | (dv, Just _)<-shSys]
and
n₁ = spanNorm
$ [dv^*η | (dv, Just η)<-shSys]
++ [ dv | (dv, Nothing)<-shSys]
You may also interpret a Nothing
here as an “infinite eigenvalue”, i.e.
it is so small as an spanning vector of n₀
that you would need to scale it
by ∞ to use it for spanning n₁
.