-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Vector & affine spaces, linear maps, and derivatives
--   
--   vector-space provides classes and generic operations for vector
--   spaces and affine spaces. It also defines a type of infinite towers of
--   generalized derivatives. A generalized derivative is a linear
--   transformation rather than one of the common concrete representations
--   (scalars, vectors, matrices, ...).
--   
--   Warning: this package depends on type families working fairly
--   well, requiring GHC version at least 6.9.
--   
--   Project wiki page: http://haskell.org/haskellwiki/vector-space
--   
--   © 2008-2012 by Conal Elliott; BSD3 license.
@package vector-space
@version 0.19

module Data.AdditiveGroup

-- | Additive group v.
class AdditiveGroup v

-- | The zero element: identity for (^+^)
zeroV :: AdditiveGroup v => v
($dmzeroV) :: (AdditiveGroup v, Generic v, AdditiveGroup (VRep v)) => v

-- | Add vectors
(^+^) :: AdditiveGroup v => v -> v -> v
($dm^+^) :: (AdditiveGroup v, Generic v, AdditiveGroup (VRep v)) => v -> v -> v

-- | Additive inverse
negateV :: AdditiveGroup v => v -> v
($dmnegateV) :: (AdditiveGroup v, Generic v, AdditiveGroup (VRep v)) => v -> v

-- | Group subtraction
(^-^) :: AdditiveGroup v => v -> v -> v
infixl 6 ^+^
infixl 6 ^-^

-- | Sum over several vectors
sumV :: (Foldable f, AdditiveGroup v) => f v -> v

-- | Monoid under group addition. Alternative to the Sum in
--   Data.Monoid, which uses Num instead of
--   AdditiveGroup.
newtype Sum a
Sum :: a -> Sum a
[getSum] :: Sum a -> a

-- | Application a unary function inside a Sum
inSum :: (a -> b) -> Sum a -> Sum b

-- | Application a binary function inside a Sum
inSum2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c
instance (Data.AdditiveGroup.AdditiveGroup (f p), Data.AdditiveGroup.AdditiveGroup (g p)) => Data.AdditiveGroup.AdditiveGroup ((GHC.Internal.Generics.:*:) f g p)
instance (Data.MemoTrie.HasTrie u, Data.AdditiveGroup.AdditiveGroup v) => Data.AdditiveGroup.AdditiveGroup (u Data.MemoTrie.:->: v)
instance Data.AdditiveGroup.AdditiveGroup GHC.Internal.Foreign.C.Types.CDouble
instance Data.AdditiveGroup.AdditiveGroup GHC.Internal.Foreign.C.Types.CFloat
instance Data.AdditiveGroup.AdditiveGroup GHC.Internal.Foreign.C.Types.CInt
instance Data.AdditiveGroup.AdditiveGroup GHC.Internal.Foreign.C.Types.CIntMax
instance Data.AdditiveGroup.AdditiveGroup GHC.Internal.Foreign.C.Types.CLLong
instance Data.AdditiveGroup.AdditiveGroup GHC.Internal.Foreign.C.Types.CLong
instance Data.AdditiveGroup.AdditiveGroup GHC.Internal.Foreign.C.Types.CSChar
instance Data.AdditiveGroup.AdditiveGroup GHC.Internal.Foreign.C.Types.CShort
instance (GHC.Internal.Float.RealFloat v, Data.AdditiveGroup.AdditiveGroup v) => Data.AdditiveGroup.AdditiveGroup (Data.Complex.Complex v)
instance Data.AdditiveGroup.AdditiveGroup GHC.Types.Double
instance Data.AdditiveGroup.AdditiveGroup v => Data.AdditiveGroup.AdditiveGroup (a -> v)
instance Data.AdditiveGroup.AdditiveGroup GHC.Types.Float
instance Data.AdditiveGroup.AdditiveGroup GHC.Types.Int
instance Data.AdditiveGroup.AdditiveGroup GHC.Num.Integer.Integer
instance Data.AdditiveGroup.AdditiveGroup a => Data.AdditiveGroup.AdditiveGroup (GHC.Internal.Generics.Rec0 a s)
instance Data.AdditiveGroup.AdditiveGroup (f p) => Data.AdditiveGroup.AdditiveGroup (GHC.Internal.Generics.M1 i c f p)
instance Data.AdditiveGroup.AdditiveGroup a => Data.AdditiveGroup.AdditiveGroup (GHC.Internal.Maybe.Maybe a)
instance GHC.Internal.Real.Integral a => Data.AdditiveGroup.AdditiveGroup (GHC.Internal.Real.Ratio a)
instance Data.AdditiveGroup.AdditiveGroup a => Data.AdditiveGroup.AdditiveGroup (Data.AdditiveGroup.Sum a)
instance (Data.AdditiveGroup.AdditiveGroup u, Data.AdditiveGroup.AdditiveGroup v) => Data.AdditiveGroup.AdditiveGroup (u, v)
instance (Data.AdditiveGroup.AdditiveGroup u, Data.AdditiveGroup.AdditiveGroup v, Data.AdditiveGroup.AdditiveGroup w) => Data.AdditiveGroup.AdditiveGroup (u, v, w)
instance (Data.AdditiveGroup.AdditiveGroup u, Data.AdditiveGroup.AdditiveGroup v, Data.AdditiveGroup.AdditiveGroup w, Data.AdditiveGroup.AdditiveGroup x) => Data.AdditiveGroup.AdditiveGroup (u, v, w, x)
instance Data.AdditiveGroup.AdditiveGroup ()
instance GHC.Internal.Base.Applicative Data.AdditiveGroup.Sum
instance GHC.Internal.Enum.Bounded a => GHC.Internal.Enum.Bounded (Data.AdditiveGroup.Sum a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.AdditiveGroup.Sum a)
instance GHC.Internal.Base.Functor Data.AdditiveGroup.Sum
instance Data.AdditiveGroup.AdditiveGroup a => GHC.Internal.Base.Monoid (Data.AdditiveGroup.Sum a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.AdditiveGroup.Sum a)
instance GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.AdditiveGroup.Sum a)
instance Data.AdditiveGroup.AdditiveGroup a => GHC.Internal.Base.Semigroup (Data.AdditiveGroup.Sum a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Data.AdditiveGroup.Sum a)

-- | Vector spaces
--   
--   This version uses associated types instead of fundeps and requires
--   ghc-6.10 or later
module Data.VectorSpace

-- | Vector space v.
class AdditiveGroup v => VectorSpace v where {
    type Scalar v;
    type Scalar v = Scalar VRep v;
}

-- | Scale a vector
(*^) :: VectorSpace v => Scalar v -> v -> v
($dm*^) :: (VectorSpace v, Generic v, VectorSpace (VRep v), Scalar (VRep v) ~ Scalar v) => Scalar v -> v -> v
infixr 7 *^

-- | Vector divided by scalar
(^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> v
infixr 7 ^/

-- | Vector multiplied by scalar
(^*) :: (VectorSpace v, s ~ Scalar v) => v -> s -> v
infixl 7 ^*

-- | Adds inner (dot) products.
class (VectorSpace v, AdditiveGroup Scalar v) => InnerSpace v

-- | Inner/dot product
(<.>) :: InnerSpace v => v -> v -> Scalar v
($dm<.>) :: (InnerSpace v, Generic v, InnerSpace (VRep v), Scalar (VRep v) ~ Scalar v) => v -> v -> Scalar v
infixr 7 <.>

-- | Linear interpolation between a (when t==0) and
--   b (when t==1).
lerp :: VectorSpace v => v -> v -> Scalar v -> v

-- | Linear combination of vectors
linearCombo :: VectorSpace v => [(v, Scalar v)] -> v

-- | Square of the length of a vector. Sometimes useful for efficiency. See
--   also magnitude.
magnitudeSq :: (InnerSpace v, s ~ Scalar v) => v -> s

-- | Length of a vector. See also magnitudeSq.
magnitude :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> s

-- | Vector in same direction as given one but with length of one. Divides
--   by zero for the zero vector.
normalized :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> v

-- | project u v computes the projection of v onto
--   u.
project :: (InnerSpace v, s ~ Scalar v, Fractional s) => v -> v -> v
instance (Data.VectorSpace.InnerSpace (f p), Data.VectorSpace.InnerSpace (g p), Data.VectorSpace.Scalar (f p) GHC.Types.~ Data.VectorSpace.Scalar (g p), GHC.Internal.Num.Num (Data.VectorSpace.Scalar (f p))) => Data.VectorSpace.InnerSpace ((GHC.Internal.Generics.:*:) f g p)
instance Data.VectorSpace.InnerSpace GHC.Internal.Foreign.C.Types.CDouble
instance Data.VectorSpace.InnerSpace GHC.Internal.Foreign.C.Types.CFloat
instance Data.VectorSpace.InnerSpace GHC.Internal.Foreign.C.Types.CInt
instance Data.VectorSpace.InnerSpace GHC.Internal.Foreign.C.Types.CIntMax
instance Data.VectorSpace.InnerSpace GHC.Internal.Foreign.C.Types.CLLong
instance Data.VectorSpace.InnerSpace GHC.Internal.Foreign.C.Types.CLong
instance Data.VectorSpace.InnerSpace GHC.Internal.Foreign.C.Types.CSChar
instance Data.VectorSpace.InnerSpace GHC.Internal.Foreign.C.Types.CShort
instance (GHC.Internal.Float.RealFloat v, Data.VectorSpace.InnerSpace v) => Data.VectorSpace.InnerSpace (Data.Complex.Complex v)
instance Data.VectorSpace.InnerSpace GHC.Types.Double
instance Data.VectorSpace.InnerSpace v => Data.VectorSpace.InnerSpace (a -> v)
instance Data.VectorSpace.InnerSpace GHC.Types.Float
instance Data.VectorSpace.InnerSpace GHC.Types.Int
instance Data.VectorSpace.InnerSpace GHC.Num.Integer.Integer
instance Data.VectorSpace.InnerSpace a => Data.VectorSpace.InnerSpace (GHC.Internal.Generics.Rec0 a s)
instance Data.VectorSpace.InnerSpace (f p) => Data.VectorSpace.InnerSpace (GHC.Internal.Generics.M1 i c f p)
instance Data.VectorSpace.InnerSpace a => Data.VectorSpace.InnerSpace (GHC.Internal.Maybe.Maybe a)
instance GHC.Internal.Real.Integral a => Data.VectorSpace.InnerSpace (GHC.Internal.Real.Ratio a)
instance (Data.VectorSpace.InnerSpace u, s GHC.Types.~ Data.VectorSpace.Scalar u, Data.VectorSpace.InnerSpace v, s GHC.Types.~ Data.VectorSpace.Scalar v) => Data.VectorSpace.InnerSpace (u, v)
instance (Data.VectorSpace.InnerSpace u, s GHC.Types.~ Data.VectorSpace.Scalar u, Data.VectorSpace.InnerSpace v, s GHC.Types.~ Data.VectorSpace.Scalar v, Data.VectorSpace.InnerSpace w, s GHC.Types.~ Data.VectorSpace.Scalar w) => Data.VectorSpace.InnerSpace (u, v, w)
instance (Data.VectorSpace.InnerSpace u, s GHC.Types.~ Data.VectorSpace.Scalar u, Data.VectorSpace.InnerSpace v, s GHC.Types.~ Data.VectorSpace.Scalar v, Data.VectorSpace.InnerSpace w, s GHC.Types.~ Data.VectorSpace.Scalar w, Data.VectorSpace.InnerSpace x, s GHC.Types.~ Data.VectorSpace.Scalar x) => Data.VectorSpace.InnerSpace (u, v, w, x)
instance (Data.VectorSpace.VectorSpace (f p), Data.VectorSpace.VectorSpace (g p), Data.VectorSpace.Scalar (f p) GHC.Types.~ Data.VectorSpace.Scalar (g p)) => Data.VectorSpace.VectorSpace ((GHC.Internal.Generics.:*:) f g p)
instance (Data.MemoTrie.HasTrie a, Data.VectorSpace.VectorSpace v) => Data.VectorSpace.VectorSpace (a Data.MemoTrie.:->: v)
instance Data.VectorSpace.VectorSpace GHC.Internal.Foreign.C.Types.CDouble
instance Data.VectorSpace.VectorSpace GHC.Internal.Foreign.C.Types.CFloat
instance Data.VectorSpace.VectorSpace GHC.Internal.Foreign.C.Types.CInt
instance Data.VectorSpace.VectorSpace GHC.Internal.Foreign.C.Types.CIntMax
instance Data.VectorSpace.VectorSpace GHC.Internal.Foreign.C.Types.CLLong
instance Data.VectorSpace.VectorSpace GHC.Internal.Foreign.C.Types.CLong
instance Data.VectorSpace.VectorSpace GHC.Internal.Foreign.C.Types.CSChar
instance Data.VectorSpace.VectorSpace GHC.Internal.Foreign.C.Types.CShort
instance (GHC.Internal.Float.RealFloat v, Data.VectorSpace.VectorSpace v) => Data.VectorSpace.VectorSpace (Data.Complex.Complex v)
instance Data.VectorSpace.VectorSpace GHC.Types.Double
instance Data.VectorSpace.VectorSpace v => Data.VectorSpace.VectorSpace (a -> v)
instance Data.VectorSpace.VectorSpace GHC.Types.Float
instance Data.VectorSpace.VectorSpace GHC.Types.Int
instance Data.VectorSpace.VectorSpace GHC.Num.Integer.Integer
instance Data.VectorSpace.VectorSpace a => Data.VectorSpace.VectorSpace (GHC.Internal.Generics.Rec0 a s)
instance Data.VectorSpace.VectorSpace (f p) => Data.VectorSpace.VectorSpace (GHC.Internal.Generics.M1 i c f p)
instance Data.VectorSpace.VectorSpace v => Data.VectorSpace.VectorSpace (GHC.Internal.Maybe.Maybe v)
instance GHC.Internal.Real.Integral a => Data.VectorSpace.VectorSpace (GHC.Internal.Real.Ratio a)
instance (Data.VectorSpace.VectorSpace u, s GHC.Types.~ Data.VectorSpace.Scalar u, Data.VectorSpace.VectorSpace v, s GHC.Types.~ Data.VectorSpace.Scalar v) => Data.VectorSpace.VectorSpace (u, v)
instance (Data.VectorSpace.VectorSpace u, s GHC.Types.~ Data.VectorSpace.Scalar u, Data.VectorSpace.VectorSpace v, s GHC.Types.~ Data.VectorSpace.Scalar v, Data.VectorSpace.VectorSpace w, s GHC.Types.~ Data.VectorSpace.Scalar w) => Data.VectorSpace.VectorSpace (u, v, w)
instance (Data.VectorSpace.VectorSpace u, s GHC.Types.~ Data.VectorSpace.Scalar u, Data.VectorSpace.VectorSpace v, s GHC.Types.~ Data.VectorSpace.Scalar v, Data.VectorSpace.VectorSpace w, s GHC.Types.~ Data.VectorSpace.Scalar w, Data.VectorSpace.VectorSpace x, s GHC.Types.~ Data.VectorSpace.Scalar x) => Data.VectorSpace.VectorSpace (u, v, w, x)

-- | Basis of a vector space, as an associated type This module requires
--   ghc-6.10 or later
module Data.Basis
class VectorSpace v => HasBasis v where {
    
    -- | Representation of the canonical basis for <tt>v</tt>
    type Basis v;
    type Basis v = Basis VRep v;
}

-- | Interpret basis rep as a vector
basisValue :: HasBasis v => Basis v -> v
($dmbasisValue) :: (HasBasis v, Generic v, HasBasis (VRep v), Basis (VRep v) ~ Basis v) => Basis v -> v

-- | Extract coordinates
decompose :: HasBasis v => v -> [(Basis v, Scalar v)]
($dmdecompose) :: (HasBasis v, Generic v, HasBasis (VRep v), Scalar (VRep v) ~ Scalar v, Basis (VRep v) ~ Basis v) => v -> [(Basis v, Scalar v)]

-- | Experimental version. More elegant definitions, and friendly to
--   infinite-dimensional vector spaces.
decompose' :: HasBasis v => v -> Basis v -> Scalar v
($dmdecompose') :: (HasBasis v, Generic v, HasBasis (VRep v), Scalar (VRep v) ~ Scalar v, Basis (VRep v) ~ Basis v) => v -> Basis v -> Scalar v

-- | Linear combination of vectors
linearCombo :: VectorSpace v => [(v, Scalar v)] -> v
recompose :: HasBasis v => [(Basis v, Scalar v)] -> v
instance (Data.Basis.HasBasis (f p), Data.Basis.HasBasis (g p), Data.VectorSpace.Scalar (f p) GHC.Types.~ Data.VectorSpace.Scalar (g p)) => Data.Basis.HasBasis ((GHC.Internal.Generics.:*:) f g p)
instance Data.Basis.HasBasis GHC.Internal.Foreign.C.Types.CDouble
instance Data.Basis.HasBasis GHC.Internal.Foreign.C.Types.CFloat
instance Data.Basis.HasBasis GHC.Types.Double
instance Data.Basis.HasBasis GHC.Types.Float
instance Data.Basis.HasBasis a => Data.Basis.HasBasis (GHC.Internal.Generics.Rec0 a s)
instance Data.Basis.HasBasis (f p) => Data.Basis.HasBasis (GHC.Internal.Generics.M1 i c f p)
instance GHC.Internal.Real.Integral a => Data.Basis.HasBasis (GHC.Internal.Real.Ratio a)
instance (Data.Basis.HasBasis u, s GHC.Types.~ Data.VectorSpace.Scalar u, Data.Basis.HasBasis v, s GHC.Types.~ Data.VectorSpace.Scalar v) => Data.Basis.HasBasis (u, v)
instance (Data.Basis.HasBasis u, s GHC.Types.~ Data.VectorSpace.Scalar u, Data.Basis.HasBasis v, s GHC.Types.~ Data.VectorSpace.Scalar v, Data.Basis.HasBasis w, s GHC.Types.~ Data.VectorSpace.Scalar w) => Data.Basis.HasBasis (u, v, w)


-- | Affine spaces.
module Data.AffineSpace
class AdditiveGroup Diff p => AffineSpace p where {
    
    -- | Associated vector space
    type Diff p;
    type Diff p = GenericDiff p;
}

-- | Subtract points
(.-.) :: AffineSpace p => p -> p -> Diff p
($dm.-.) :: (AffineSpace p, Generic p, Diff p ~ GenericDiff p, AffineSpace (VRep p)) => p -> p -> Diff p

-- | Point plus vector
(.+^) :: AffineSpace p => p -> Diff p -> p
($dm.+^) :: (AffineSpace p, Generic p, Diff p ~ GenericDiff p, AffineSpace (VRep p)) => p -> Diff p -> p
infix 6 .-.
infixl 6 .+^

-- | Point minus vector
(.-^) :: AffineSpace p => p -> Diff p -> p
infixl 6 .-^

-- | Square of the distance between two points. Sometimes useful for
--   efficiency. See also distance.
distanceSq :: (AffineSpace p, v ~ Diff p, InnerSpace v) => p -> p -> Scalar v

-- | Distance between two points. See also distanceSq.
distance :: (AffineSpace p, v ~ Diff p, InnerSpace v, s ~ Scalar v, Floating (Scalar v)) => p -> p -> s

-- | Affine linear interpolation. Varies from p to p' as
--   s varies from 0 to 1. See also lerp (on vector
--   spaces).
alerp :: (AffineSpace p, VectorSpace (Diff p)) => p -> p -> Scalar (Diff p) -> p

-- | Compute an affine combination (weighted average) of points. The first
--   element is used as origin and is weighted such that all coefficients
--   sum to 1. For example,
--   
--   
--   affineCombo a [(0.3,b), (0.2,c)]
--   
--   
--   is equal to
--   
--   
--   a .+^ (0.3 *^ (b .-. a) ^+^ 0.2 *^ (c .-. a))
--   
--   
--   and if a, b, and c were in a vector space
--   would also be equal to
--   
--   
--   0.5 *^ a ^+^ 0.3 *^ b ^+^ 0.2 *^ c
--   
--   
--   See also linearCombo (on vector spaces).
affineCombo :: (AffineSpace p, v ~ Diff p, VectorSpace v) => p -> [(p, Scalar v)] -> p
instance (Data.AffineSpace.AffineSpace (f p), Data.AffineSpace.AffineSpace (g p)) => Data.AdditiveGroup.AdditiveGroup (Data.AffineSpace.AffineDiffProductSpace f g p)
instance Data.AdditiveGroup.AdditiveGroup (Data.AffineSpace.Diff (Data.VectorSpace.Generic.VRep p)) => Data.AdditiveGroup.AdditiveGroup (Data.AffineSpace.GenericDiff p)
instance (Data.AffineSpace.AffineSpace (f p), Data.AffineSpace.AffineSpace (g p)) => Data.AffineSpace.AffineSpace ((GHC.Internal.Generics.:*:) f g p)
instance (Data.AffineSpace.AffineSpace (f p), Data.AffineSpace.AffineSpace (g p)) => Data.AffineSpace.AffineSpace (Data.AffineSpace.AffineDiffProductSpace f g p)
instance Data.AffineSpace.AffineSpace GHC.Internal.Foreign.C.Types.CDouble
instance Data.AffineSpace.AffineSpace GHC.Internal.Foreign.C.Types.CFloat
instance Data.AffineSpace.AffineSpace GHC.Internal.Foreign.C.Types.CInt
instance Data.AffineSpace.AffineSpace GHC.Internal.Foreign.C.Types.CIntMax
instance Data.AffineSpace.AffineSpace GHC.Internal.Foreign.C.Types.CLLong
instance Data.AffineSpace.AffineSpace GHC.Internal.Foreign.C.Types.CLong
instance Data.AffineSpace.AffineSpace GHC.Internal.Foreign.C.Types.CSChar
instance Data.AffineSpace.AffineSpace GHC.Internal.Foreign.C.Types.CShort
instance Data.AffineSpace.AffineSpace GHC.Types.Double
instance Data.AffineSpace.AffineSpace p => Data.AffineSpace.AffineSpace (a -> p)
instance Data.AffineSpace.AffineSpace GHC.Types.Float
instance Data.AffineSpace.AffineSpace GHC.Types.Int
instance Data.AffineSpace.AffineSpace GHC.Num.Integer.Integer
instance Data.AffineSpace.AffineSpace a => Data.AffineSpace.AffineSpace (GHC.Internal.Generics.Rec0 a s)
instance Data.AffineSpace.AffineSpace (f p) => Data.AffineSpace.AffineSpace (GHC.Internal.Generics.M1 i c f p)
instance GHC.Internal.Real.Integral a => Data.AffineSpace.AffineSpace (GHC.Internal.Real.Ratio a)
instance (Data.AffineSpace.AffineSpace p, Data.AffineSpace.AffineSpace q) => Data.AffineSpace.AffineSpace (p, q)
instance (Data.AffineSpace.AffineSpace p, Data.AffineSpace.AffineSpace q, Data.AffineSpace.AffineSpace r) => Data.AffineSpace.AffineSpace (p, q, r)
instance GHC.Internal.Generics.Generic (Data.AffineSpace.AffineDiffProductSpace f g p)
instance GHC.Internal.Generics.Generic (Data.AffineSpace.GenericDiff p)
instance (Data.AffineSpace.AffineSpace (f p), Data.AffineSpace.AffineSpace (g p), Data.Basis.HasBasis (Data.AffineSpace.Diff (f p)), Data.Basis.HasBasis (Data.AffineSpace.Diff (g p)), Data.VectorSpace.Scalar (Data.AffineSpace.Diff (f p)) GHC.Types.~ Data.VectorSpace.Scalar (Data.AffineSpace.Diff (g p))) => Data.Basis.HasBasis (Data.AffineSpace.AffineDiffProductSpace f g p)
instance Data.Basis.HasBasis (Data.AffineSpace.Diff (Data.VectorSpace.Generic.VRep p)) => Data.Basis.HasBasis (Data.AffineSpace.GenericDiff p)
instance (Data.AdditiveGroup.AdditiveGroup (Data.VectorSpace.Scalar (Data.AffineSpace.Diff (g p))), Data.AffineSpace.AffineSpace (f p), Data.AffineSpace.AffineSpace (g p), Data.VectorSpace.InnerSpace (Data.AffineSpace.Diff (f p)), Data.VectorSpace.InnerSpace (Data.AffineSpace.Diff (g p)), Data.VectorSpace.Scalar (Data.AffineSpace.Diff (f p)) GHC.Types.~ Data.VectorSpace.Scalar (Data.AffineSpace.Diff (g p)), GHC.Internal.Num.Num (Data.VectorSpace.Scalar (Data.AffineSpace.Diff (f p)))) => Data.VectorSpace.InnerSpace (Data.AffineSpace.AffineDiffProductSpace f g p)
instance (Data.AdditiveGroup.AdditiveGroup (Data.VectorSpace.Scalar (Data.AffineSpace.Diff (Data.VectorSpace.Generic.VRep p))), Data.VectorSpace.InnerSpace (Data.AffineSpace.Diff (Data.VectorSpace.Generic.VRep p))) => Data.VectorSpace.InnerSpace (Data.AffineSpace.GenericDiff p)
instance (Data.AffineSpace.AffineSpace (f p), Data.AffineSpace.AffineSpace (g p), Data.VectorSpace.VectorSpace (Data.AffineSpace.Diff (f p)), Data.VectorSpace.VectorSpace (Data.AffineSpace.Diff (g p)), Data.VectorSpace.Scalar (Data.AffineSpace.Diff (f p)) GHC.Types.~ Data.VectorSpace.Scalar (Data.AffineSpace.Diff (g p))) => Data.VectorSpace.VectorSpace (Data.AffineSpace.AffineDiffProductSpace f g p)
instance Data.VectorSpace.VectorSpace (Data.AffineSpace.Diff (Data.VectorSpace.Generic.VRep p)) => Data.VectorSpace.VectorSpace (Data.AffineSpace.GenericDiff p)

-- | Linear maps
module Data.LinearMap

-- | Linear map, represented as an optional memo-trie from basis to values,
--   where Nothing means the zero map (an optimization).
data u :-* v
infixr 1 :-*

-- | Function (assumed linear) as linear map.
linear :: (HasBasis u, HasTrie (Basis u)) => (u -> v) -> u :-* v

-- | Apply a linear map to a vector.
lapply :: (VectorSpace v, Scalar u ~ Scalar v, HasBasis u, HasTrie (Basis u)) => (u :-* v) -> u -> v

-- | Evaluate a linear map on a basis element.
atBasis :: (AdditiveGroup v, HasTrie (Basis u)) => (u :-* v) -> Basis u -> v

-- | Identity linear map
idL :: (HasBasis u, HasTrie (Basis u)) => u :-* u

-- | Compose linear maps
(*.*) :: (HasTrie (Basis u), HasBasis v, HasTrie (Basis v), VectorSpace w, Scalar v ~ Scalar w) => (v :-* w) -> (u :-* v) -> u :-* w
infixr 9 *.*
inLMap :: (LMap' r s -> LMap' t u) -> (r :-* s) -> t :-* u
inLMap2 :: (LMap' r s -> LMap' t u -> LMap' v w) -> (r :-* s) -> (t :-* u) -> v :-* w
inLMap3 :: (LMap' r s -> LMap' t u -> LMap' v w -> LMap' x y) -> (r :-* s) -> (t :-* u) -> (v :-* w) -> x :-* y
liftMS :: (a -> b) -> MSum a -> MSum b
liftMS2 :: (AdditiveGroup a, AdditiveGroup b) => (a -> b -> c) -> MSum a -> MSum b -> MSum c
liftMS3 :: (AdditiveGroup a, AdditiveGroup b, AdditiveGroup c) => (a -> b -> c -> d) -> MSum a -> MSum b -> MSum c -> MSum d

-- | Apply a linear function to each element of a linear map. liftL f l
--   == linear f *.* l, but works more efficiently.
liftL :: Functor f => (a -> b) -> MSum (f a) -> MSum (f b)

-- | Apply a linear binary function (not to be confused with a bilinear
--   function) to each element of a linear map.
liftL2 :: (Applicative f, AdditiveGroup (f a), AdditiveGroup (f b)) => (a -> b -> c) -> MSum (f a) -> MSum (f b) -> MSum (f c)

-- | Apply a linear ternary function (not to be confused with a trilinear
--   function) to each element of a linear map.
liftL3 :: (Applicative f, AdditiveGroup (f a), AdditiveGroup (f b), AdditiveGroup (f c)) => (a -> b -> c -> d) -> MSum (f a) -> MSum (f b) -> MSum (f c) -> MSum (f d)
exlL :: (HasBasis a, HasTrie (Basis a), HasBasis b, HasTrie (Basis b), Scalar a ~ Scalar b) => (a, b) :-* a
exrL :: (HasBasis a, HasTrie (Basis a), HasBasis b, HasTrie (Basis b), Scalar a ~ Scalar b) => (a, b) :-* b
forkL :: (HasTrie (Basis a), HasBasis c, HasBasis d) => (a :-* c) -> (a :-* d) -> a :-* (c, d)
firstL :: (HasBasis u, HasBasis u', HasBasis v, HasTrie (Basis u), HasTrie (Basis v), Scalar u ~ Scalar v, Scalar u ~ Scalar u') => (u :-* u') -> (u, v) :-* (u', v)
secondL :: (HasBasis u, HasBasis v, HasBasis v', HasTrie (Basis u), HasTrie (Basis v), Scalar u ~ Scalar v, Scalar u ~ Scalar v') => (v :-* v') -> (u, v) :-* (u, v')
inlL :: (HasBasis a, HasTrie (Basis a), HasBasis b) => a :-* (a, b)
inrL :: (HasBasis a, HasBasis b, HasTrie (Basis b)) => b :-* (a, b)
joinL :: (HasBasis a, HasTrie (Basis a), HasBasis b, HasTrie (Basis b), Scalar a ~ Scalar b, Scalar a ~ Scalar c, VectorSpace c) => (a :-* c) -> (b :-* c) -> (a, b) :-* c
instance (Data.MemoTrie.HasTrie (Data.Basis.Basis u), Data.AdditiveGroup.AdditiveGroup v) => Data.AdditiveGroup.AdditiveGroup (u Data.LinearMap.:-* v)
instance (Data.MemoTrie.HasTrie (Data.Basis.Basis u), Data.VectorSpace.VectorSpace v) => Data.VectorSpace.VectorSpace (u Data.LinearMap.:-* v)

-- | Infinite derivative towers via linear maps, using the Maclaurin
--   representation. See blog posts
--   http://conal.net/blog/tag/derivative/.
module Data.Maclaurin

-- | Tower of derivatives.
data a :> b
D :: b -> (a :-* (a :> b)) -> (:>) a b
infixr 9 `D`
powVal :: (:>) a b -> b
derivative :: (:>) a b -> a :-* (a :> b)

-- | Sample the derivative at a basis element. Optimized for partial
--   application to save work for non-scalar derivatives.
derivAtBasis :: (HasTrie (Basis a), HasBasis a, AdditiveGroup b) => (a :> b) -> Basis a -> a :> b

-- | Infinitely differentiable functions
type a :~> b = a -> a :> b

-- | Constant derivative tower.
pureD :: (AdditiveGroup b, HasBasis a, HasTrie (Basis a)) => b -> a :> b

-- | Map a linear function over a derivative tower.
fmapD :: HasTrie (Basis a) => (b -> c) -> (a :> b) -> a :> c

-- | Map a linear function over a derivative tower.
(<$>>) :: HasTrie (Basis a) => (b -> c) -> (a :> b) -> a :> c
infixl 4 <$>>

-- | Apply a linear binary function over derivative towers.
liftD2 :: (HasBasis a, HasTrie (Basis a), AdditiveGroup b, AdditiveGroup c) => (b -> c -> d) -> (a :> b) -> (a :> c) -> a :> d

-- | Apply a linear ternary function over derivative towers.
liftD3 :: (HasBasis a, HasTrie (Basis a), AdditiveGroup b, AdditiveGroup c, AdditiveGroup d) => (b -> c -> d -> e) -> (a :> b) -> (a :> c) -> (a :> d) -> a :> e

-- | Differentiable identity function. Sometimes called "the derivation
--   variable" or similar, but it's not really a variable.
idD :: (VectorSpace u, HasBasis u, HasTrie (Basis u)) => u :~> u

-- | Differentiable version of fst
fstD :: (HasBasis a, HasTrie (Basis a), HasBasis b, HasTrie (Basis b), Scalar a ~ Scalar b) => (a, b) :~> a

-- | Differentiable version of snd
sndD :: (HasBasis a, HasTrie (Basis a), HasBasis b, HasTrie (Basis b), Scalar a ~ Scalar b) => (a, b) :~> b

-- | Every linear function has a constant derivative equal to the function
--   itself (as a linear map).
linearD :: (HasBasis u, HasTrie (Basis u), AdditiveGroup v) => (u -> v) -> u :~> v

-- | Derivative tower for applying a binary function that distributes over
--   addition, such as multiplication. A bit weaker assumption than
--   bilinearity. Is bilinearity necessary for correctness here?
distrib :: forall a b c u. (HasBasis a, HasTrie (Basis a), AdditiveGroup u) => (b -> c -> u) -> (a :> b) -> (a :> c) -> a :> u

-- | Specialized chain rule. See also (\@.)
(>-<) :: (HasBasis a, HasTrie (Basis a), VectorSpace u) => (u -> u) -> ((a :> u) -> a :> Scalar u) -> (a :> u) -> a :> u
infix 0 >-<
pairD :: (HasBasis a, HasTrie (Basis a), VectorSpace b, VectorSpace c) => (a :> b, a :> c) -> a :> (b, c)
unpairD :: HasTrie (Basis a) => (a :> (b, c)) -> (a :> b, a :> c)
tripleD :: (HasBasis a, HasTrie (Basis a), VectorSpace b, VectorSpace c, VectorSpace d) => (a :> b, a :> c, a :> d) -> a :> (b, c, d)
untripleD :: HasTrie (Basis a) => (a :> (b, c, d)) -> (a :> b, a :> c, a :> d)
instance (Data.Basis.HasBasis a, Data.MemoTrie.HasTrie (Data.Basis.Basis a), Data.AdditiveGroup.AdditiveGroup u) => Data.AdditiveGroup.AdditiveGroup (a Data.Maclaurin.:> u)
instance GHC.Classes.Eq (a Data.Maclaurin.:> b)
instance (Data.Basis.HasBasis a, s GHC.Types.~ Data.VectorSpace.Scalar a, Data.MemoTrie.HasTrie (Data.Basis.Basis a), GHC.Internal.Float.Floating s, Data.VectorSpace.VectorSpace s, Data.VectorSpace.Scalar s GHC.Types.~ s) => GHC.Internal.Float.Floating (a Data.Maclaurin.:> s)
instance (Data.Basis.HasBasis a, s GHC.Types.~ Data.VectorSpace.Scalar a, Data.MemoTrie.HasTrie (Data.Basis.Basis a), GHC.Internal.Real.Fractional s, Data.VectorSpace.VectorSpace s, Data.VectorSpace.Scalar s GHC.Types.~ s) => GHC.Internal.Real.Fractional (a Data.Maclaurin.:> s)
instance (Data.AdditiveGroup.AdditiveGroup v, Data.Basis.HasBasis u, Data.MemoTrie.HasTrie (Data.Basis.Basis u), Data.Boolean.IfB v) => Data.Boolean.IfB (u Data.Maclaurin.:> v)
instance (Data.VectorSpace.InnerSpace u, s GHC.Types.~ Data.VectorSpace.Scalar u, Data.AdditiveGroup.AdditiveGroup s, Data.Basis.HasBasis a, Data.MemoTrie.HasTrie (Data.Basis.Basis a)) => Data.VectorSpace.InnerSpace (a Data.Maclaurin.:> u)
instance (Data.Basis.HasBasis a, s GHC.Types.~ Data.VectorSpace.Scalar a, Data.MemoTrie.HasTrie (Data.Basis.Basis a), GHC.Internal.Num.Num s, Data.VectorSpace.VectorSpace s, Data.VectorSpace.Scalar s GHC.Types.~ s) => GHC.Internal.Num.Num (a Data.Maclaurin.:> s)
instance (Data.AdditiveGroup.AdditiveGroup b, Data.Basis.HasBasis a, Data.MemoTrie.HasTrie (Data.Basis.Basis a), Data.Boolean.OrdB b, Data.Boolean.IfB b, GHC.Classes.Ord b) => GHC.Classes.Ord (a Data.Maclaurin.:> b)
instance Data.Boolean.OrdB v => Data.Boolean.OrdB (u Data.Maclaurin.:> v)
instance GHC.Internal.Show.Show b => GHC.Internal.Show.Show (a Data.Maclaurin.:> b)
instance (Data.Basis.HasBasis a, Data.MemoTrie.HasTrie (Data.Basis.Basis a), Data.VectorSpace.VectorSpace u) => Data.VectorSpace.VectorSpace (a Data.Maclaurin.:> u)

-- | Module indirection module. For Maclaurin- vs Horner-based derivative
--   towers.
module Data.Derivative

-- | Cross products and normals
module Data.Cross

-- | Thing with a normal vector (not necessarily normalized).
class HasNormal v
normalVec :: HasNormal v => v -> v

-- | Normalized normal vector. See also cross.
normal :: (HasNormal v, InnerSpace v, Floating (Scalar v)) => v -> v

-- | Singleton
type One s = s

-- | Homogeneous pair
type Two s = (s, s)

-- | Homogeneous triple
type Three s = (s, s, s)

-- | Cross product of various forms of 2D vectors
class HasCross2 v
cross2 :: HasCross2 v => v -> v

-- | Cross product of various forms of 3D vectors
class HasCross3 v
cross3 :: HasCross3 v => v -> v -> v
instance (Data.MemoTrie.HasTrie (Data.Basis.Basis a), Data.Cross.HasCross2 v) => Data.Cross.HasCross2 (a Data.Maclaurin.:> v)
instance Data.AdditiveGroup.AdditiveGroup u => Data.Cross.HasCross2 (u, u)
instance (Data.Basis.HasBasis a, Data.MemoTrie.HasTrie (Data.Basis.Basis a), Data.VectorSpace.VectorSpace v, Data.Cross.HasCross3 v) => Data.Cross.HasCross3 (a Data.Maclaurin.:> v)
instance GHC.Internal.Num.Num s => Data.Cross.HasCross3 (s, s, s)
instance (GHC.Internal.Num.Num s, Data.MemoTrie.HasTrie (Data.Basis.Basis (s, s)), Data.Basis.HasBasis s, Data.Basis.Basis s GHC.Types.~ ()) => Data.Cross.HasNormal (Data.Cross.Two s Data.Maclaurin.:> Data.Cross.Three s)
instance (Data.Basis.HasBasis s, Data.MemoTrie.HasTrie (Data.Basis.Basis s), Data.Basis.Basis s GHC.Types.~ ()) => Data.Cross.HasNormal (Data.Cross.One s Data.Maclaurin.:> Data.Cross.Two s)
instance (Data.VectorSpace.VectorSpace s, Data.Basis.HasBasis s, Data.MemoTrie.HasTrie (Data.Basis.Basis s), Data.Basis.Basis s GHC.Types.~ ()) => Data.Cross.HasNormal (Data.Cross.Two (Data.Cross.One s Data.Maclaurin.:> s))
instance (Data.VectorSpace.VectorSpace s, Data.Basis.HasBasis s, Data.MemoTrie.HasTrie (Data.Basis.Basis s), Data.Cross.HasNormal (Data.Cross.Two s Data.Maclaurin.:> Data.Cross.Three s)) => Data.Cross.HasNormal (Data.Cross.Three (Data.Cross.Two s Data.Maclaurin.:> s))
