vector-space 0.5.6 → 0.5.7
raw patch · 3 files changed
+27/−14 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Basis: instance (Eq a, HasBasis u) => HasBasis (a -> u)
+ Data.VectorSpace: instance (InnerSpace v) => InnerSpace (a -> v)
Files
- src/Data/Basis.hs +8/−8
- src/Data/VectorSpace.hs +18/−5
- vector-space.cabal +1/−1
src/Data/Basis.hs view
@@ -102,14 +102,14 @@ nest3 (a,b,c) = (a,(b,c)) -instance (Eq a, HasBasis u) => HasBasis (a -> u) where- type Basis (a -> u) = (a, Basis u)- basisValue (a,b) = f- where f a' | a == a' = bv- | otherwise = zeroV- bv = basisValue b- decompose = error "decompose: not defined on functions"- decompose' g (a,b) = decompose' (g a) b+-- instance (Eq a, HasBasis u) => HasBasis (a -> u) where+-- type Basis (a -> u) = (a, Basis u)+-- basisValue (a,b) = f+-- where f a' | a == a' = bv+-- | otherwise = zeroV+-- bv = basisValue b+-- decompose = error "decompose: not defined on functions"+-- decompose' g (a,b) = decompose' (g a) b -- Simpler but less efficient:
src/Data/VectorSpace.hs view
@@ -30,6 +30,7 @@ , lerp, magnitudeSq, magnitude, normalized ) where +import Control.Applicative (liftA2) import Data.Complex hiding (magnitude) import Data.AdditiveGroup@@ -160,16 +161,28 @@ type Scalar (Maybe v) = Scalar v (*^) s = fmap (s *^) +-- instance VectorSpace v => VectorSpace (a -> v) where+-- type Scalar (a -> v) = Scalar v+-- (*^) s = fmap (s *^)++-- No 'InnerSpace' instance for @a -> v@.++-- Or the following definition, which is useful for the higher-order+-- shading dsel in Shady (borrowed from Vertigo).+ instance VectorSpace v => VectorSpace (a -> v) where- type Scalar (a -> v) = Scalar v- (*^) s = fmap (s *^)+ type Scalar (a -> v) = a -> Scalar v+ (*^) = liftA2 (*^) -instance (HasTrie a, VectorSpace v)- => VectorSpace (a :->: v) where+instance InnerSpace v => InnerSpace (a -> v) where+ (<.>) = liftA2 (<.>)++++instance (HasTrie a, VectorSpace v) => VectorSpace (a :->: v) where type Scalar (a :->: v) = Scalar v (*^) s = fmap (s *^) --- No 'InnerSpace' instance for @a -> v@. instance (InnerSpace a, AdditiveGroup (Scalar a)) => InnerSpace (Maybe a) where
vector-space.cabal view
@@ -1,5 +1,5 @@ Name: vector-space-Version: 0.5.6+Version: 0.5.7 Cabal-Version: >= 1.2 Synopsis: Vector & affine spaces, linear maps, and derivatives (requires ghc 6.9 or better) Category: math