$      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~(c) Justus Sagemller 2016GPL v3"(@) sagemueller $ geo.uni-koeln.de experimentalportableNone &*34579:>FIKLNZ(c) Justus Sagemller 2016GPL v3"(@) sagemueller $ geo.uni-koeln.de experimentalportableNone&*34579:>FIKLNZA 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 note be uncurried to a linear function with a tuple argument (this would not be linear but quadratic).Infix synonym of ., without explicit mention of the scalar type.sA 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 (s  which you can simply do with the  instance  they will become ever slower to calculate, because the summand-functions are actually computed individually and only the results summed. That's where _ is generally preferrable. You can always convert between these equivalent categories using .elacs "a    .   (c) Justus Sagemller 2016GPL v3"(@) sagemueller $ geo.uni-koeln.de experimentalportableNone &*34579:>FIKLNZ]The workhorse of this package: most functions here work on vector spaces that fulfill the  v! constraint. In summary, this is:A  whose  is a :H (i.e. a number type that has itself all the vector-space instances).You have an implementation for - v w, for any other space w. You have a  space that fulfills  ( v) ~ v. To make a new space of yours an  , you must define instances of , and .Infix synonym for ., without explicit mention of the scalar type.Infix synonym for ., without explicit mention of the scalar type.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.{The tensor product between one space's dual space and another space is the space spanned by vector dual-vector pairs, in  7https://en.wikipedia.org/wiki/Bra%E2%80%93ket_notationabra-ket notation written as  m = " |w''v| JAny linear mapping can be written as such a (possibly infinite) sum. The -w data structure only stores the linear independent parts though; for simple finite-dimensional spaces this means e.g.  ! ! !X effectively boils down to an ordinary matrix type, namely an array of column-vectors |w'.(The 'v|H 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 , instance.The class of vector spaces v for which  s v w is well-implemented.7Suitable representation of a linear map from the space v to its field.4For the usual euclidean spaces, you can just define  v = vQ. (In this case, a dual vector will be just a row vector  if you consider v-vectors as column vectors . 0 will then effectively have a matrix layout.)-!The internal representation of a  product.FFor euclidean spaces, this is generally constructed by replacing each s scalar field in the v vector with an entire w7 vector. I.e., you have then a nested vector  or, if v is a  DualVector / row vector , a matrix.=Infix version of 5.>AThe 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.?ASCII version of '"' (u+>(v"w)) -> (u+>v)"w (u+>v)"w -> u+>(v"w) ((u+>v)+>w) -> v+>(u"w) (u+>(v"w)) -> (v+>u)+>wk  !"#$%&'()*+,-./0123456789:;<=>?I  !"#$%&'()*+,-./0123456789:;<=>?G  !"#$%&'()*+, -./0123456789:;<=>?=>?(c) Justus Sagemller 2016GPL v3"(@) sagemueller $ geo.uni-koeln.de experimentalportableNone&345:>FKLN(c) Justus Sagemller 2016GPL v3"(@) sagemueller $ geo.uni-koeln.de experimentalportableNone&*345:>FKLNUEWhereas 4-values refer to a single basis vector, a single E} 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, E 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.IBSplit up a linear map in column vectors  WRT some suitable basis.JcExpand in the given basis, if possible. Else yield a superbasis of the given one, in which this is) possible, and the decomposition therein.KRAssemble a vector from coefficients in some basis. Return any excess coefficients.NGiven a function that interprets a coefficient-container as a vector representation, build a linear function mapping to that space.PThe 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).RR 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  -https://en.wikipedia.org/wiki/Galerkin_methodGalerkin method) to give an approximate solution (see VC) to a linear equation in a possibly infinite-dimensional space.VOf course, this also works for spaces which are already finite-dimensional themselves.SLazily 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 c) is assigned early to the dual vector c', then (c' $ c)@ 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.XFor simple finite-dimensional array-vectors, you can easily define this method using T.V=Inverse function application, aka solving of a linear system: f V f  v "a v f  f V u "a 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  injective2 (overdetermined system) and the second if it is  surjective.pIf you want to solve for multiple RHS vectors, be sure to partially apply this operator to the linear map, like map (f V) [v , v , ...] fSince most of the work is actually done in triangularising the operator, this may be much faster than [f V v , f V v , ...] If f is injective, then unsafeLeftInverse f . f "a id If f is surjective, then  f . unsafeRightInverse f "a id FInvert an isomorphism. For other linear maps, the result is undefined.XThe  :https://en.wikipedia.org/wiki/Riesz_representation_theoremRiesz representation theoremT provides an isomorphism between a Hilbert space and its (continuous) dual space.ZtFunctions are generally a pain to display, but since linear functionals in a Hilbert space can be represented by vectors7 in that space, this can be used for implementing a  instance.[Outer product of a general v!-vector and a basis element from w~. Note that this operation is in general pretty inefficient; it is provided mostly to lay out matrix definitions neatly.\&For real matrices, this boils down to  transpose@. For free complex spaces it also incurs complex conjugation.'The signature can also be understood as 6adjoint :: (v +> w) -> (DualVector w +> DualVector v) Or 6adjoint :: (DualVector v +> DualVector w) -> (w +> v) But not (v+>w) -> (w+>v)F, in general (though in a Hilbert space, this too is equivalent, via X isomorphism).^@ABCDEFGHIJKLMNOPQRST#Set of canonical basis functionals.Decompose a vector in absolute valueV components. the list indices should correspond to those in the functional list.Suitable definition of S.UVWXYZ[\      !"#$%2@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\<@ABCD EFGHIJKLMNOPQRSTUVWXYZ[\      !"#$%V[(c) Justus Sagemller 2016GPL v3"(@) sagemueller $ geo.uni-koeln.de experimentalportableNone&*345:>FKLN_The estimated eigenvalue .`Normalised vector v( that gets mapped to a multiple, namely:af $ v "a  *^ v .b9Deviation of these two supposedly equivalent expressions.c<Squared norm of the deviation, normalised by the eigenvalue.d&A multidimensional variance of points ve 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.e1A norm  that may explicitly be degenerate, with  m|$|v *u 0 for some  v "` zeroV.fKA positive (semi)definite symmetric bilinear form. This gives rise to a  0https://en.wikipedia.org/wiki/Norm_(mathematics)norm thus:  f n u v = "(n v U v) `Strictly speaking, this type is neither strong enough nor general enough to deserve the name f: it includes proper es (i.e.  m|$|v "a 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.iA seminorm defined by  v  = "("b 'db|v') for some dual vectors dbH. If given a complete basis of the dual space, this generates a proper f.If the db0 are a complete orthonormal system, you get the m (in an inefficient form).kUModify 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.)lAScale the result of a norm with the absolute of the given number. &scaleNorm  n |$| v = abs  * (n|$|v) PEquivalently, this scales the norm's unit ball by the reciprocal of that factor.mGThe canonical standard norm (2-norm) on inner-product / Hilbert spaces.&|The norm induced from the (arbitrary) choice of basis in a finite space. Only use this in contexts where you merely need someE norm, but don't care if it might be biased in some unnatural way.nA 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.qNThe unique positive number whose norm is 1 (if the norm is not constant zero).rUnsafe version of qC, only works reliable if the norm is actually positive definite.s Partially apply  a norm, yielding a dual vector (i.e. a linear form that accepts the second argument of the scalar product). (m s v) U w "a v ' w t&The squared norm. More efficient than u/ because that needs to take the square root.uUse a f* to measure the length / norm of a vector. m |$| v "a "(v ' v) vi / j 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.wLazily 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.)yFind 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.iThis function does not make any guarantees as to how well a single eigenvalue is approximated, though.zqSimple automatic finding of the eigenvalues and -vectors of a Hermitian operator, in reasonable approximation.9This works by spanning a QR-stabilised Krylov basis with w until it is complete (y3), and then properly decoupling the system with x7 (based on two iterations of shifted Givens rotations).=This function is a tradeoff in performance vs. accuracy. Use w and xj directly for more quickly computing a (perhaps incomplete) approximation, or for more precise results.{!Approximation of the determinant.~bFor any two norms, one can find a system of co-vectors that, with suitable coefficients, spans either of them: if &shSys = sharedNormSpanningSystem n n  , then n = i $ fst $shSys and n = i [dv^* | (dv,)<-shSys] cInterpret 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.( mempty|$|v "a 0) $(m<>n|$|v)^2 *u (m|$|v)^2 + (n|$|v)^22]^_`abc*+,-defghijklm&nop.qrstuv/01wThe notion of orthonormality.+Error bound for deviations from eigen-ness.uOperator to calculate the eigensystem of. Must be Hermitian WRT the scalar product defined by the given metric.(Starting vector(s) for the power method.]Infinite sequence of ever more accurate approximations to the eigensystem of the operator.xyz{2|}~3()  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~>?\U=fgheimutsl|}djnvVW{zwyx]^_`abc,-./0123456789 !"#$%&'()*+RSTDEFGHIJKLMNOPQ XYZ[C@<;: BAkopqr~']^_`abc*+,-defghijklm&nop.qrstuv/01wxyz{2|}~3().su4       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_``abcdefghhijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./01223456789:;linea_KOFVqkZ2vQrB06LwOFc1AM Math.VectorSpace.ZeroDimensionalMath.LinearMap.CategoryMath.LinearMap.Asserted LinearMapMath.LinearMap.Category.Class!Math.LinearMap.Category.InstancesMath.VectorSpace.DocileZeroDimOriginBilinear-+>LinearFunctiongetLinearFunctionaddVbilinearFunction flipBilinscaleinner Fractional'' Fractional' DualSpaceLSpace⊗+>TensorgetTensorProduct getLinearMap LinearSpace DualVectorlinearIdidTensorsampleLinearFunction toLinearFormfromLinearFormcoerceDoubleDual blockVectSpanblockVectSpan'tracecontractTensorMapcontractMapTensorcontractFnTensorcontractTensorFncontractTensorWithcontractLinearMapAgainstapplyDualVector applyLinear composeLinear TensorSpace TensorProduct zeroTensor toFlatTensorfromFlatTensor addTensorssubtractTensors scaleTensor negateTensor tensorProducttransposeTensor fmapTensorfzipTensorWithcoerceFmapTensorProductNum'''Num''Num'⊕>+< SimpleSpace RealFloat' RealFrac' HilbertSpaceFiniteDimensionalSubBasis entireBasisenumerateSubBasissubbasisDimensiondecomposeLinMapdecomposeLinMapWithin recomposeSBrecomposeSBTensorrecomposeLinMaprecomposeContraLinMaprecomposeContraLinMapTensoruncanonicallyFromDualuncanonicallyToDual SemiInnerdualBasisCandidatescartesianDualBasisCandidates<.>^\$ pseudoInverserieszcoRieszshowsPrecAsRiesz.<adjoint Eigenvector ev_Eigenvalueev_Eigenvectorev_FunctionApplied ev_Deviation ev_BadnessVarianceSeminormNorm applyNormspanNorm spanVariance relaxNorm scaleNorm euclideanNormdualNorm transformNormtransformVariancefindNormalLength normalLength<$|normSq|$| densifyNormconstructEigenSystemfinishEigenSystemroughEigenSystemeigenroughDetnormSpanningSystemnormSpanningSystem'sharedNormSpanningSystem dependencesummandSpaceNormssumSubspaceNorms$fHasBasisZeroDim$fVectorSpaceZeroDim$fAdditiveGroupZeroDim$fAffineSpaceZeroDim$fMonoidZeroDimvecto_B7ERKFLj74s9E6QjxzRZ7QData.VectorSpace VectorSpaceconst_JlnGQ9MtL15FsXZE3KrcUiControl.Arrow.ConstrainedarrelacslinearFunction scaleWithscaleVconst0lNegateV fmapScalelCoFstlCoSndbiConst0lApply'$fFunctorLinearFunctionCoercionCoercion$fVectorSpaceLinearFunction$fAdditiveGroupLinearFunctionScalar&&&deferLinearMaphasteLinearMapcoCurryLinearMapcoUncurryLinearMapLSpace'asTensor fromTensor asLinearMap fromLinearMap<⊕ lfstBlock lsndBlock lassocTensor rassocTensorcurryLinearMapuncurryLinearMapuncurryLinearFn deferLinearFn hasteLinearFncoCurryLinearFncoUncurryLinearFn$fLinearSpaceLinearFunction$fTensorSpaceLinearFunction3$fFunctorLinearFunctionLinearFunctionLinearFunction#$fEnhancedCatLinearFunctionCoercion$fEnhancedCat(->)LinearFunction$fPreArrowLinearFunction$fMorphismLinearFunction$fCartesianLinearFunction$fCategoryLinearFunction"$fFunctorLinearMapCoercionCoercion$fFunctorTensorCoercionCoercion/$fMonoidalLinearMapLinearFunctionLinearFunction.$fFunctorLinearMapLinearFunctionLinearFunction,$fMonoidalTensorLinearFunctionLinearFunction+$fFunctorTensorLinearFunctionLinearFunction$fLinearSpaceTensor$fTensorSpaceTensor$fLinearSpaceLinearMap$fTensorSpaceLinearMap$fLinearSpace(,)$fTensorSpace(,)$$fEnhancedCatLinearMapLinearFunction$$fEnhancedCatLinearFunctionLinearMap$fEnhancedCat(->)LinearMap$fPreArrowLinearMap$fMorphismLinearMap$fCartesianLinearMap$fCategoryLinearMap$fVectorSpaceTensor$fAdditiveGroupTensor$fVectorSpaceLinearMap$fAdditiveGroupLinearMap$fLinearSpaceZeroDim$fTensorSpaceZeroDimℝ$fAffineSpaceLinearFunction$fAffineSpaceLinearMap$fAffineSpaceTensor$fFractionalLinearMap$fNumLinearMap$fLinearSpaceV4$fTensorSpaceV4$fLinearSpaceV3$fTensorSpaceV3$fLinearSpaceV2$fTensorSpaceV2$fLinearSpaceV1$fTensorSpaceV1$fLinearSpaceV0$fTensorSpaceV0$fLinearSpaceDouble$fTensorSpaceDouble Data.BasisBasis$unsafeLeftInverseunsafeRightInverse unsafeInversebaseGHC.ShowShowDList LinMapBasis TensorBasis TupleBasisV4BasisV3BasisV2BasisV1Basis RealsBasisV0Basis ZeroBasisorthonormaliseDuals dualBasis^/^recomposeMultiple tensorLinmapDecompositionhelperssRiesz^$fFiniteFreeSpaceLinearFunction$fFiniteFreeSpaceTensor$fFiniteFreeSpaceLinearMap$fShowLinearMap$fShowLinearMap0$fShowLinearMap1$fShowLinearMap2$fShowLinearMap3$fShowLinearMap4$fShowLinearMap5$fShowLinearMap6$fShowLinearMap7$fShowLinearMap8$fShowLinearMap9TFCo:R:SubBasisLinearMap$fFiniteDimensionalLinearMapTFCo:R:SubBasisTensor$fFiniteDimensionalTensorTFCo:R:SubBasis(,)$fFiniteDimensional(,)TFCo:R:SubBasisV4$fFiniteDimensionalV4TFCo:R:SubBasisV3$fFiniteDimensionalV3TFCo:R:SubBasisV2$fFiniteDimensionalV2TFCo:R:SubBasisV1$fFiniteDimensionalV1TFCo:R:SubBasisDouble$fFiniteDimensionalDoubleTFCo:R:SubBasisV0$fFiniteDimensionalV0TFCo:R:SubBasisZeroDim$fFiniteDimensionalZeroDim$fSemiInnerLinearMap$fSemiInnerTensor$fSemiInner(,) $fSemiInnerV4 $fSemiInnerV3 $fSemiInnerV2 $fSemiInnerV1$fSemiInnerDouble $fSemiInnerV0$fSemiInnerZeroDim adhocNorm<.> $fMonoidNorm$fSemigroupNormOrthonormalSystemorthonormalityNormorthonormalVectors^%orthonormaliseFussilyorthogonalComplementProj'orthogonalComplementProjorthonormalityError $fShowNorm