linearmap-category 0.3.5.0 → 0.4.0.0
raw patch · 9 files changed
+163/−58 lines, 9 filesdep +QuickCheckdep ~manifolds-corePVP ok
version bump matches the API change (PVP)
Dependencies added: QuickCheck
Dependency ranges changed: manifolds-core
API changes (from Hackage documentation)
- Math.LinearMap.Category: instance Math.LinearMap.Category.Class.LSpace v => Data.Semigroup.Semigroup (Math.LinearMap.Category.Norm v)
+ Math.LinearMap.Category: --
+ Math.LinearMap.Category: -- <a>SubBasis</a> value represents a collection of such basis vectors,
+ Math.LinearMap.Category: -- <tt><a>DualVector</a> v = v</tt>. (In this case, a dual vector will be
+ Math.LinearMap.Category: -- <tt>s</tt> scalar field in the <tt>v</tt> vector with an entire
+ Math.LinearMap.Category: -- <tt>v</tt> is a <tt>DualVector</tt> / “row vector”, a matrix.
+ Math.LinearMap.Category: -- <tt>w</tt> vector. I.e., you have then a “nested vector” or, if
+ Math.LinearMap.Category: -- For spaces with a canonical finite basis, <a>SubBasis</a> does not
+ Math.LinearMap.Category: -- actually need to contain any information, it can simply have the full
+ Math.LinearMap.Category: -- finite basis as its only value. Even for large sparse spaces, it
+ Math.LinearMap.Category: -- its field.
+ Math.LinearMap.Category: -- just a “row vector” if you consider <tt>v</tt>-vectors as “column
+ Math.LinearMap.Category: -- layout.)
+ Math.LinearMap.Category: -- should only have a very coarse structure that can be shared by many
+ Math.LinearMap.Category: -- vectors.
+ Math.LinearMap.Category: -- vectors”. <a>LinearMap</a> will then effectively have a matrix
+ Math.LinearMap.Category: -- which can be used to associate a vector with a list of coefficients.
+ Math.LinearMap.Category: -- | Whereas <a>Basis</a>-values refer to a single basis vector, a single
+ Math.LinearMap.Category: [TrivialTensorWitness] :: w ~ TensorProduct s w => TrivialTensorWitness s w
+ Math.LinearMap.Category: data TrivialTensorWitness s w
+ Math.LinearMap.Category: instance Math.LinearMap.Category.Class.LSpace v => GHC.Base.Semigroup (Math.LinearMap.Category.Norm v)
+ Math.LinearMap.Category: trivialTensorWitness :: (Num' s, w ~ TensorProduct s w) => TrivialTensorWitness s w
- Math.LinearMap.Category: (·) :: TensorQuot v w => v ⨸ w -> v -> w
+ Math.LinearMap.Category: (·) :: TensorQuot v w => (v ⨸ w) -> v -> w
- Math.LinearMap.Category: Norm :: v -+> DualVector v -> Norm v
+ Math.LinearMap.Category: Norm :: (v -+> DualVector v) -> Norm v
- Math.LinearMap.Category: addTensors :: (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) => (v ⊗ w) -> (v ⊗ w) -> v ⊗ w
+ Math.LinearMap.Category: addTensors :: (TensorSpace v, AdditiveGroup (TensorProduct v w)) => (v ⊗ w) -> (v ⊗ w) -> v ⊗ w
- Math.LinearMap.Category: cartesianDualBasisCandidates :: [DualVector v] -> (v -> [ℝ]) -> ([(Int, v)] -> Forest (Int, DualVector v))
+ Math.LinearMap.Category: cartesianDualBasisCandidates :: [DualVector v] -> (v -> [ℝ]) -> [(Int, v)] -> Forest (Int, DualVector v)
- Math.LinearMap.Category: class (Num s, LinearSpace s) => Num' s
+ Math.LinearMap.Category: class (Num s, LinearSpace s, FreeVectorSpace s) => Num' s
- Math.LinearMap.Category: closedScalarWitness :: Num' s => ClosedScalarWitness s
+ Math.LinearMap.Category: closedScalarWitness :: (Num' s, Scalar s ~ s, DualVector s ~ s) => ClosedScalarWitness s
- Math.LinearMap.Category: dependence :: forall u v. (SimpleSpace u, SimpleSpace v, Scalar u ~ Scalar v) => Variance (u, v) -> (u +> v)
+ Math.LinearMap.Category: dependence :: forall u v. (SimpleSpace u, SimpleSpace v, Scalar u ~ Scalar v) => Variance (u, v) -> u +> v
- Math.LinearMap.Category: linearRegression :: forall s x m y. (LinearSpace x, SimpleSpace y, SimpleSpace m, Scalar x ~ s, Scalar y ~ s, Scalar m ~ s, RealFrac' s) => (x -> (m +> y)) -> [(x, (y, Norm y))] -> LinearRegressionResult x y m
+ Math.LinearMap.Category: linearRegression :: forall s x m y. (LinearSpace x, SimpleSpace y, SimpleSpace m, Scalar x ~ s, Scalar y ~ s, Scalar m ~ s, RealFrac' s) => (x -> m +> y) -> [(x, (y, Norm y))] -> LinearRegressionResult x y m
- Math.LinearMap.Category: linearRegressionW :: forall s x m y. (LinearSpace x, SimpleSpace y, SimpleSpace m, Scalar x ~ s, Scalar y ~ s, Scalar m ~ s, RealFrac' s) => Norm y -> (x -> (m +> y)) -> [(x, y)] -> m
+ Math.LinearMap.Category: linearRegressionW :: forall s x m y. (LinearSpace x, SimpleSpace y, SimpleSpace m, Scalar x ~ s, Scalar y ~ s, Scalar m ~ s, RealFrac' s) => Norm y -> (x -> m +> y) -> [(x, y)] -> m
- Math.LinearMap.Category: negateTensor :: (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) => (v ⊗ w) -+> (v ⊗ w)
+ Math.LinearMap.Category: negateTensor :: (TensorSpace v, AdditiveGroup (TensorProduct v w)) => (v ⊗ w) -+> (v ⊗ w)
- Math.LinearMap.Category: scaleTensor :: (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) => Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
+ Math.LinearMap.Category: scaleTensor :: (TensorSpace v, VectorSpace (TensorProduct v w), Scalar (TensorProduct v w) ~ Scalar v) => Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)
- Math.LinearMap.Category: subtractTensors :: (TensorSpace v, TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) => (v ⊗ w) -> (v ⊗ w) -> v ⊗ w
+ Math.LinearMap.Category: subtractTensors :: (TensorSpace v, AdditiveGroup (TensorProduct v w)) => (v ⊗ w) -> (v ⊗ w) -> v ⊗ w
- Math.LinearMap.Category: tensorProducts :: (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) => [(v, w)] -> (v ⊗ w)
+ Math.LinearMap.Category: tensorProducts :: (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) => [(v, w)] -> v ⊗ w
- Math.LinearMap.Category: wellDefinedTensor :: (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) => v ⊗ w -> Maybe (v ⊗ w)
+ Math.LinearMap.Category: wellDefinedTensor :: (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) => (v ⊗ w) -> Maybe (v ⊗ w)
- Math.VectorSpace.ZeroDimensional: data ZeroDim s :: * -> *
+ Math.VectorSpace.ZeroDimensional: data ZeroDim s
Files
- Math/LinearMap/Asserted.hs +1/−1
- Math/LinearMap/Category.hs +3/−3
- Math/LinearMap/Category/Class.hs +29/−4
- Math/LinearMap/Category/Derivatives.hs +1/−1
- Math/LinearMap/Category/Instances.hs +119/−40
- Math/LinearMap/Category/TensorQuot.hs +1/−1
- Math/VectorSpace/Docile.hs +1/−1
- Math/VectorSpace/ZeroDimensional.hs +1/−1
- linearmap-category.cabal +7/−6
Math/LinearMap/Asserted.hs view
@@ -3,7 +3,7 @@ -- Copyright : (c) Justus Sagemüller 2016 -- License : GPL v3 -- --- Maintainer : (@) sagemueller $ geo.uni-koeln.de+-- Maintainer : (@) jsag $ hvl.no -- Stability : experimental -- Portability : portable --
Math/LinearMap/Category.hs view
@@ -3,7 +3,7 @@ -- Copyright : (c) Justus Sagemüller 2016 -- License : GPL v3 -- --- Maintainer : (@) sagemueller $ geo.uni-koeln.de+-- Maintainer : (@) jsag $ hvl.no -- Stability : experimental -- Portability : portable -- @@ -89,8 +89,8 @@ , Fractional' , RealFrac', RealFloat', LinearShowable -- ** Double-dual, scalar-scalar etc. identity- , ClosedScalarWitness(..), ScalarSpaceWitness(..), DualSpaceWitness(..)- , LinearManifoldWitness(..)+ , ClosedScalarWitness(..), TrivialTensorWitness(..)+ , ScalarSpaceWitness(..), DualSpaceWitness(..), LinearManifoldWitness(..) -- ** Misc , relaxNorm, transformNorm, transformVariance , findNormalLength, normalLength
Math/LinearMap/Category/Class.hs view
@@ -3,7 +3,7 @@ -- Copyright : (c) Justus Sagemüller 2016 -- License : GPL v3 -- --- Maintainer : (@) sagemueller $ geo.uni-koeln.de+-- Maintainer : (@) jsag $ hvl.no -- Stability : experimental -- Portability : portable -- @@ -43,15 +43,23 @@ import Math.Manifold.Core.PseudoAffine import Math.LinearMap.Asserted import Math.VectorSpace.ZeroDimensional+import Data.VectorSpace.Free import qualified GHC.Generics as Gnrx import GHC.Generics (Generic, (:*:)((:*:))) data ClosedScalarWitness s where ClosedScalarWitness :: (Scalar s ~ s, DualVector s ~ s) => ClosedScalarWitness s+data TrivialTensorWitness s w where+ TrivialTensorWitness :: w ~ TensorProduct s w => TrivialTensorWitness s w -class (Num s, LinearSpace s) => Num' s where+class (Num s, LinearSpace s, FreeVectorSpace s) => Num' s where closedScalarWitness :: ClosedScalarWitness s+ default closedScalarWitness :: (Scalar s ~ s, DualVector s ~ s) => ClosedScalarWitness s+ closedScalarWitness = ClosedScalarWitness+ trivialTensorWitness :: TrivialTensorWitness s w+ default trivialTensorWitness :: (w ~ TensorProduct s w) => TrivialTensorWitness s w+ trivialTensorWitness = TrivialTensorWitness data ScalarSpaceWitness v where ScalarSpaceWitness :: (Num' (Scalar v), Scalar (Scalar v) ~ Scalar v)@@ -63,7 +71,7 @@ class (VectorSpace v, PseudoAffine v) => TensorSpace v where -- | The internal representation of a 'Tensor' product. -- - -- For euclidean spaces, this is generally constructed by replacing each @s@+ -- 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. type TensorProduct v w :: *@@ -75,13 +83,22 @@ fromFlatTensor :: (v ⊗ Scalar v) -+> v addTensors :: (TensorSpace w, Scalar w ~ Scalar v) => (v ⊗ w) -> (v ⊗ w) -> v ⊗ w+ default addTensors :: AdditiveGroup (TensorProduct v w) => (v ⊗ w) -> (v ⊗ w) -> v ⊗ w+ addTensors (Tensor vw₀) (Tensor vw₁) = Tensor $ vw₀ ^+^ vw₁ subtractTensors :: (TensorSpace v, TensorSpace w, Scalar w ~ Scalar v) => (v ⊗ w) -> (v ⊗ w) -> v ⊗ w- subtractTensors m n = addTensors m (getLinearFunction negateTensor n)+ default subtractTensors :: AdditiveGroup (TensorProduct v w) => (v ⊗ w) -> (v ⊗ w) -> v ⊗ w+ subtractTensors (Tensor vw₀) (Tensor vw₁) = Tensor $ vw₀ ^-^ vw₁ scaleTensor :: (TensorSpace w, Scalar w ~ Scalar v) => Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)+ default scaleTensor+ :: (VectorSpace (TensorProduct v w), Scalar (TensorProduct v w) ~ Scalar v)+ => Bilinear (Scalar v) (v ⊗ w) (v ⊗ w)+ scaleTensor = bilinearFunction $ \μ (Tensor vw) -> Tensor $ μ*^vw negateTensor :: (TensorSpace w, Scalar w ~ Scalar v) => (v ⊗ w) -+> (v ⊗ w)+ default negateTensor :: AdditiveGroup (TensorProduct v w) => (v ⊗ w) -+> (v ⊗ w)+ negateTensor = LinearFunction $ \(Tensor vw) -> Tensor $ negateV vw tensorProduct :: (TensorSpace w, Scalar w ~ Scalar v) => Bilinear v w (v ⊗ w) tensorProducts :: (TensorSpace w, Scalar w ~ Scalar v)@@ -1036,6 +1053,8 @@ <<< arr (pseudoFmapTensorLHS Gnrx.unK1) addTensors (Tensor s) (Tensor t) = pseudoFmapTensorLHS Gnrx.K1 $ addTensors (Tensor s) (Tensor t)+ subtractTensors (Tensor s) (Tensor t)+ = pseudoFmapTensorLHS Gnrx.K1 $ subtractTensors (Tensor s) (Tensor t) scaleTensor = LinearFunction $ \μ -> envTensorLHSCoercion Gnrx.K1 $ scaleTensor-+$>μ negateTensor = envTensorLHSCoercion Gnrx.K1 negateTensor@@ -1078,6 +1097,8 @@ <<< arr (pseudoFmapTensorLHS Gnrx.unM1) addTensors (Tensor s) (Tensor t) = pseudoFmapTensorLHS Gnrx.M1 $ addTensors (Tensor s) (Tensor t)+ subtractTensors (Tensor s) (Tensor t)+ = pseudoFmapTensorLHS Gnrx.M1 $ subtractTensors (Tensor s) (Tensor t) scaleTensor = LinearFunction $ \μ -> envTensorLHSCoercion Gnrx.M1 $ scaleTensor-+$>μ negateTensor = envTensorLHSCoercion Gnrx.M1 negateTensor@@ -1169,6 +1190,8 @@ >>> GenericNeedle addTensors (Tensor s) (Tensor t) = pseudoFmapTensorLHS GenericNeedle $ addTensors (Tensor s) (Tensor t)+ subtractTensors (Tensor s) (Tensor t)+ = pseudoFmapTensorLHS GenericNeedle $ subtractTensors (Tensor s) (Tensor t) scaleTensor = LinearFunction $ \μ -> envTensorLHSCoercion GenericNeedle $ scaleTensor-+$>μ negateTensor = envTensorLHSCoercion GenericNeedle negateTensor@@ -1450,6 +1473,8 @@ >>> GenericNeedle' addTensors (Tensor s) (Tensor t) = pseudoFmapTensorLHS GenericNeedle' $ addTensors (Tensor s) (Tensor t)+ subtractTensors (Tensor s) (Tensor t)+ = pseudoFmapTensorLHS GenericNeedle' $ subtractTensors (Tensor s) (Tensor t) scaleTensor = LinearFunction $ \μ -> envTensorLHSCoercion GenericNeedle' $ scaleTensor-+$>μ negateTensor = envTensorLHSCoercion GenericNeedle' negateTensor
Math/LinearMap/Category/Derivatives.hs view
@@ -3,7 +3,7 @@ -- Copyright : (c) Justus Sagemüller 2016 -- License : GPL v3 -- --- Maintainer : (@) sagemueller $ geo.uni-koeln.de+-- Maintainer : (@) jsag $ hvl.no -- Stability : experimental -- Portability : portable --
Math/LinearMap/Category/Instances.hs view
@@ -1,9 +1,9 @@ -- | -- Module : Math.LinearMap.Category.Instances--- Copyright : (c) Justus Sagemüller 2016+-- Copyright : (c) Justus Sagemüller 2016-2019 -- License : GPL v3 -- --- Maintainer : (@) sagemueller $ geo.uni-koeln.de+-- Maintainer : (@) jsag $ hvl.no -- Stability : experimental -- Portability : portable -- @@ -56,7 +56,10 @@ import Math.LinearMap.Asserted import Math.VectorSpace.ZeroDimensional +import qualified Test.QuickCheck as QC+ import qualified GHC.Exts as GHC+import qualified GHC.Generics as GHC infixr 7 <.>^ (<.>^) :: LinearSpace v => DualVector v -> v -> Scalar v@@ -65,45 +68,47 @@ type ℝ = Double -instance Num' ℝ where- closedScalarWitness = ClosedScalarWitness+#define LinearScalarSpace(S) \+instance Num' (S) where {closedScalarWitness = ClosedScalarWitness}; \+instance TensorSpace (S) where { \+ type TensorProduct (S) w = w; \+ scalarSpaceWitness = ScalarSpaceWitness; \+ linearManifoldWitness = LinearManifoldWitness BoundarylessWitness; \+ zeroTensor = Tensor zeroV; \+ scaleTensor = bilinearFunction $ \μ (Tensor t) -> Tensor $ μ*^t; \+ addTensors (Tensor v) (Tensor w) = Tensor $ v ^+^ w; \+ subtractTensors (Tensor v) (Tensor w) = Tensor $ v ^-^ w; \+ negateTensor = pretendLike Tensor lNegateV; \+ toFlatTensor = follow Tensor; \+ fromFlatTensor = flout Tensor; \+ tensorProduct = LinearFunction $ \μ -> follow Tensor . scaleWith μ; \+ transposeTensor = toFlatTensor . flout Tensor; \+ fmapTensor = LinearFunction $ pretendLike Tensor; \+ fzipTensorWith = LinearFunction \+ $ \f -> follow Tensor <<< f <<< flout Tensor *** flout Tensor; \+ coerceFmapTensorProduct _ Coercion = Coercion; \+ wellDefinedTensor (Tensor w) = Tensor <$> wellDefinedVector w }; \+instance LinearSpace (S) where { \+ type DualVector (S) = (S); \+ dualSpaceWitness = DualSpaceWitness; \+ linearId = LinearMap 1; \+ tensorId = uncurryLinearMap $ LinearMap $ fmap (follow Tensor) -+$> id; \+ idTensor = Tensor 1; \+ fromLinearForm = flout LinearMap; \+ coerceDoubleDual = Coercion; \+ contractTensorMap = flout Tensor . flout LinearMap; \+ contractMapTensor = flout LinearMap . flout Tensor; \+ applyDualVector = scale; \+ applyLinear = LinearFunction $ \(LinearMap w) -> scaleV w; \+ applyTensorFunctional = bilinearFunction $ \(LinearMap du) (Tensor u) -> du<.>^u; \+ applyTensorLinMap = bilinearFunction $ \fℝuw (Tensor u) \+ -> let LinearMap fuw = curryLinearMap $ fℝuw \+ in (applyLinear-+$>fuw) -+$> u; \+ composeLinear = bilinearFunction $ \f (LinearMap g) \+ -> LinearMap $ (applyLinear-+$>f)-+$>g } -instance TensorSpace ℝ where- type TensorProduct ℝ w = w- scalarSpaceWitness = ScalarSpaceWitness- linearManifoldWitness = LinearManifoldWitness BoundarylessWitness- zeroTensor = Tensor zeroV- scaleTensor = bilinearFunction $ \μ (Tensor t) -> Tensor $ μ*^t- addTensors (Tensor v) (Tensor w) = Tensor $ v ^+^ w- subtractTensors (Tensor v) (Tensor w) = Tensor $ v ^-^ w- negateTensor = pretendLike Tensor lNegateV- toFlatTensor = follow Tensor- fromFlatTensor = flout Tensor- tensorProduct = LinearFunction $ \μ -> follow Tensor . scaleWith μ- transposeTensor = toFlatTensor . flout Tensor- fmapTensor = LinearFunction $ pretendLike Tensor- fzipTensorWith = LinearFunction- $ \f -> follow Tensor <<< f <<< flout Tensor *** flout Tensor- coerceFmapTensorProduct _ Coercion = Coercion- wellDefinedTensor (Tensor w) = Tensor <$> wellDefinedVector w-instance LinearSpace ℝ where- type DualVector ℝ = ℝ- dualSpaceWitness = DualSpaceWitness- linearId = LinearMap 1- tensorId = uncurryLinearMap $ LinearMap $ fmap (follow Tensor) -+$> id- idTensor = Tensor 1- fromLinearForm = flout LinearMap- coerceDoubleDual = Coercion- contractTensorMap = flout Tensor . flout LinearMap- contractMapTensor = flout LinearMap . flout Tensor- applyDualVector = scale- applyLinear = LinearFunction $ \(LinearMap w) -> scaleV w- applyTensorFunctional = bilinearFunction $ \(LinearMap du) (Tensor u) -> du<.>^u- applyTensorLinMap = bilinearFunction $ \fℝuw (Tensor u)- -> let LinearMap fuw = curryLinearMap $ fℝuw- in (applyLinear-+$>fuw) -+$> u- composeLinear = bilinearFunction $ \f (LinearMap g)- -> LinearMap $ (applyLinear-+$>f)-+$>g+LinearScalarSpace(ℝ)+LinearScalarSpace(Rational) #define FreeLinearSpace(V, LV, tp, tenspl, tenid, dspan, contraction, contraaction) \ instance Num s => Semimanifold (V s) where { \@@ -274,6 +279,7 @@ toFlatTensor = LinearFunction $ Tensor . UArr.toList . getFiniteSeq fromFlatTensor = LinearFunction $ FinSuppSeq . UArr.fromList . getTensorProduct addTensors (Tensor s) (Tensor t) = Tensor $ Mat.liftU2 (^+^) s t+ subtractTensors (Tensor s) (Tensor t) = Tensor $ Mat.liftU2 (^-^) s t scaleTensor = bilinearFunction $ \μ (Tensor t) -> Tensor $ (μ*^)<$>t negateTensor = LinearFunction $ \(Tensor t) -> Tensor $ negateV<$>t tensorProduct = bilinearFunction@@ -311,6 +317,7 @@ toFlatTensor = LinearFunction $ Tensor . GHC.toList fromFlatTensor = LinearFunction $ GHC.fromList . getTensorProduct addTensors (Tensor s) (Tensor t) = Tensor $ Mat.liftU2 (^+^) s t+ subtractTensors (Tensor s) (Tensor t) = Tensor $ Mat.liftU2 (^-^) s t scaleTensor = bilinearFunction $ \μ (Tensor t) -> Tensor $ (μ*^)<$>t negateTensor = LinearFunction $ \(Tensor t) -> Tensor $ negateV<$>t tensorProduct = bilinearFunction@@ -491,3 +498,75 @@ currySymBilin :: LinearSpace v => (v⊗〃+>w) -+> (v+>(v+>w)) currySymBilin = LinearFunction . arr $ fmap fromTensor . fromTensor . flout LinearMap++++++newtype LinearApplicativeSpace f y+ = LinearApplicativeSpace { getLinearApplicativeSpace :: f y }++instance ( GHC.Generic1 f, TensorSpace y+ , TensorSpace (f y), Scalar (f y) ~ Scalar y+ , Monoidal f (LinearFunction (Scalar y)) (LinearFunction (Scalar y)) )+ => AffineSpace (LinearApplicativeSpace f y) where+ type Diff (LinearApplicativeSpace f y) = LinearApplicativeSpace f y+ (.+^) = (^+^)+ (.-.) = (^-^)++instance ∀ f y . ( GHC.Generic1 f, TensorSpace y+ , TensorSpace (f y), Scalar (f y) ~ Scalar y+ , Monoidal f (LinearFunction (Scalar y)) (LinearFunction (Scalar y)) )+ => AdditiveGroup (LinearApplicativeSpace f y) where+ zeroV = LinearApplicativeSpace $ getLinearFunction+ ( fmap zeroV+ . (pureUnit :: LinearFunction (Scalar y) (ZeroDim (Scalar y))+ (f (ZeroDim (Scalar y)))) ) zeroV+ LinearApplicativeSpace a^+^LinearApplicativeSpace b+ = LinearApplicativeSpace+ $ getLinearFunction+ (fzipWith (LinearFunction $ uncurry (^+^)))+ (a,b)+ LinearApplicativeSpace a^-^LinearApplicativeSpace b+ = LinearApplicativeSpace+ $ getLinearFunction+ (fzipWith (LinearFunction $ uncurry (^-^)))+ (a,b)+ negateV (LinearApplicativeSpace a) = LinearApplicativeSpace+ $ getLinearFunction (fmap $ LinearFunction negateV) a++instance ( GHC.Generic1 f, TensorSpace y+ , TensorSpace (f y), Scalar (f y) ~ Scalar y+ , Monoidal f (LinearFunction (Scalar y)) (LinearFunction (Scalar y)) )+ => VectorSpace (LinearApplicativeSpace f y) where+ type Scalar (LinearApplicativeSpace f y) = Scalar y+ (*^) = undefined++instance ( GHC.Generic1 f, TensorSpace y+ , TensorSpace (f y), Scalar (f y) ~ Scalar y+ , Monoidal f (LinearFunction (Scalar y)) (LinearFunction (Scalar y)) )+ => Semimanifold (LinearApplicativeSpace f y) where+ type Needle (LinearApplicativeSpace f y) = LinearApplicativeSpace f y+ type Interior (LinearApplicativeSpace f y) = LinearApplicativeSpace f y+ toInterior = Just; fromInterior = id+ translateP = Tagged (^+^)++instance ( GHC.Generic1 f, TensorSpace y+ , TensorSpace (f y), Scalar (f y) ~ Scalar y+ , Monoidal f (LinearFunction (Scalar y)) (LinearFunction (Scalar y)) )+ => PseudoAffine (LinearApplicativeSpace f y) where+ (.-~!) = (.-.)++++instance (InnerSpace v, Scalar v ~ ℝ, TensorSpace v)+ => InnerSpace (Tensor ℝ ℝ v) where+ Tensor t <.> Tensor u = t <.> u++instance (Show v) => Show (Tensor ℝ ℝ v) where+ showsPrec p (Tensor t) = showParen (p>9) $ ("Tensor "++) . showsPrec 10 t++instance (QC.Arbitrary v, Scalar v ~ ℝ) => QC.Arbitrary (Tensor ℝ ℝ v) where+ arbitrary = Tensor <$> QC.arbitrary+ shrink (Tensor t) = Tensor <$> QC.shrink t+
Math/LinearMap/Category/TensorQuot.hs view
@@ -3,7 +3,7 @@ -- Copyright : (c) Justus Sagemüller 2016 -- License : GPL v3 -- --- Maintainer : (@) sagemueller $ geo.uni-koeln.de+-- Maintainer : (@) jsag $ hvl.no -- Stability : experimental -- Portability : portable --
Math/VectorSpace/Docile.hs view
@@ -3,7 +3,7 @@ -- Copyright : (c) Justus Sagemüller 2016 -- License : GPL v3 -- --- Maintainer : (@) sagemueller $ geo.uni-koeln.de+-- Maintainer : (@) jsag $ hvl.no -- Stability : experimental -- Portability : portable --
Math/VectorSpace/ZeroDimensional.hs view
@@ -3,7 +3,7 @@ -- Copyright : (c) Justus Sagemüller 2016 -- License : GPL v3 -- --- Maintainer : (@) sagemueller $ geo.uni-koeln.de+-- Maintainer : (@) jsag $ hvl.no -- Stability : experimental -- Portability : portable --
linearmap-category.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: linearmap-category-version: 0.3.5.0+version: 0.4.0.0 synopsis: Native, complete, matrix-free linear algebra. description: The term /numerical linear algebra/ is often used almost synonymous with /matrix modifications/. However, what's interesting@@ -30,7 +30,7 @@ license: GPL-3 license-file: LICENSE author: Justus Sagemüller-maintainer: (@) sagemueller $ geo.uni-koeln.de+maintainer: (@) jsag $ hvl.no -- copyright: category: Math build-type: Simple@@ -48,15 +48,16 @@ Math.VectorSpace.Docile other-extensions: FlexibleInstances, UndecidableInstances, FunctionalDependencies, TypeOperators, TypeFamilies build-depends: base >=4.8 && <5,- vector-space >=0.11 && <0.13,- constrained-categories >=0.3 && <0.4,+ vector-space >=0.11 && <0.18,+ constrained-categories >=0.3 && <0.5, containers, vector, tagged, free-vector-spaces >= 0.1.4 && < 0.2, linear, lens, transformers,- manifolds-core >= 0.4.4 && < 0.6,+ manifolds-core >= 0.5.0.4 && < 0.6, semigroups, ieee754 >= 0.7 && < 0.9,- call-stack+ call-stack,+ QuickCheck >=2.11 && <2.15 -- hs-source-dirs: default-language: Haskell2010