packages feed

linear 1.10.1.2 → 1.11

raw patch · 10 files changed

+36/−32 lines, 10 files

Files

linear.cabal view
@@ -1,6 +1,6 @@ name:          linear category:      Math, Algebra-version:       1.10.1.2+version:       1.11 license:       BSD3 cabal-version: >= 1.8 license-file:  LICENSE
src/Linear/Metric.hs view
@@ -15,7 +15,7 @@ -- Free metric spaces ---------------------------------------------------------------------------- module Linear.Metric-  ( Metric(..), normalize+  ( Metric(..), normalize, project   ) where  import Data.Foldable as Foldable@@ -82,3 +82,8 @@ normalize :: (Floating a, Metric f, Epsilon a) => f a -> f a normalize v = if nearZero l || nearZero (1-l) then v else fmap (/sqrt l) v   where l = quadrance v++-- | @project u v@ computes the projection of @v@ onto @u@.+project :: (Metric v, Fractional a) => v a -> v a -> v a+project u v = ((v `dot` u) / quadrance u) *^ u+
src/Linear/Plucker.hs view
@@ -279,12 +279,12 @@ -- | These elements form a basis for the Plücker space, or the Grassmanian manifold @Gr(2,V4)@. -- -- @--- 'p01' :: Lens' ('Plucker' a) a--- 'p02' :: Lens' ('Plucker' a) a--- 'p03' :: Lens' ('Plucker' a) a--- 'p23' :: Lens' ('Plucker' a) a--- 'p31' :: Lens' ('Plucker' a) a--- 'p12' :: Lens' ('Plucker' a) a+-- 'p01' :: 'Lens'' ('Plucker' a) a+-- 'p02' :: 'Lens'' ('Plucker' a) a+-- 'p03' :: 'Lens'' ('Plucker' a) a+-- 'p23' :: 'Lens'' ('Plucker' a) a+-- 'p31' :: 'Lens'' ('Plucker' a) a+-- 'p12' :: 'Lens'' ('Plucker' a) a -- @ p01, p02, p03, p23, p31, p12 :: Lens' (Plucker a) a p01 g (Plucker a b c d e f) = (\a' -> Plucker a' b c d e f) <$> g a@@ -303,12 +303,12 @@ -- | These elements form an alternate basis for the Plücker space, or the Grassmanian manifold @Gr(2,V4)@. -- -- @--- 'p10' :: 'Num' a => Lens' ('Plucker' a) a--- 'p20' :: 'Num' a => Lens' ('Plucker' a) a--- 'p30' :: 'Num' a => Lens' ('Plucker' a) a--- 'p32' :: 'Num' a => Lens' ('Plucker' a) a--- 'p13' :: 'Num' a => Lens' ('Plucker' a) a--- 'p21' :: 'Num' a => Lens' ('Plucker' a) a+-- 'p10' :: 'Num' a => 'Lens'' ('Plucker' a) a+-- 'p20' :: 'Num' a => 'Lens'' ('Plucker' a) a+-- 'p30' :: 'Num' a => 'Lens'' ('Plucker' a) a+-- 'p32' :: 'Num' a => 'Lens'' ('Plucker' a) a+-- 'p13' :: 'Num' a => 'Lens'' ('Plucker' a) a+-- 'p21' :: 'Num' a => 'Lens'' ('Plucker' a) a -- @ p10, p20, p30, p32, p13, p21 :: (Functor f, Num a) => (a -> f a) -> Plucker a -> f (Plucker a) p10 = anti p01
src/Linear/V.hs view
@@ -34,7 +34,7 @@ ----------------------------------------------------------------------------  module Linear.V-  ( V(toVector)+  ( V(V,toVector)   , int   , dim   , Dim(..)@@ -269,11 +269,10 @@ #endif  instance Dim n => Representable (V n) where-  type Rep (V n) = E (V n)-  tabulate f = V $ generate (reflectDim (Proxy :: Proxy n)) $ \i -> f $ E $ \g (V v) ->-    (\a -> V $ v V.// [(i,a)]) <$> g (unsafeIndex v i)+  type Rep (V n) = Int+  tabulate = V . generate (reflectDim (Proxy :: Proxy n))   {-# INLINE tabulate #-}-  index xs (E l) = view l xs+  index (V xs) i = xs V.! i   {-# INLINE index #-}  type instance Index (V n a) = E (V n)
src/Linear/V0.hs view
@@ -90,7 +90,7 @@  instance Apply V0 where   V0 <.> V0 = V0-  {-@ INLINE (<.>) #-}+  {-# INLINE (<.>) #-}  instance Applicative V0 where   pure _ = V0
src/Linear/V1.hs view
@@ -108,13 +108,13 @@  instance Apply V1 where   V1 f <.> V1 x = V1 (f x)-  {-@ INLINE (<.>) #-}+  {-# INLINE (<.>) #-}  instance Applicative V1 where   pure = V1   {-# INLINE pure #-}   V1 f <*> V1 x = V1 (f x)-  {-@ INLINE (<*>) #-}+  {-# INLINE (<*>) #-}  instance Additive V1 where   zero = pure 0
src/Linear/V2.hs view
@@ -183,7 +183,7 @@   -- V2 1 3   --   -- @-  -- '_y' :: Lens' (t a) a+  -- '_y' :: 'Lens'' (t a) a   -- @   _y :: Functor f => (a -> f a) -> t a -> f (t a)   _y = _xy._y@@ -191,7 +191,7 @@    -- |   -- @-  -- '_xy' :: Lens' (t a) ('V2' a)+  -- '_xy' :: 'Lens'' (t a) ('V2' a)   -- @   _xy :: Functor f => (V2 a -> f (V2 a)) -> t a -> f (t a) 
src/Linear/V3.hs view
@@ -167,12 +167,12 @@ class R2 t => R3 t where   -- |   -- @-  -- '_z' :: Lens' (t a) a+  -- '_z' :: 'Lens'' (t a) a   -- @   _z :: Functor f => (a -> f a) -> t a -> f (t a)   -- |   -- @-  -- '_xyz' :: Lens' (t a) ('V3' a)+  -- '_xyz' :: 'Lens'' (t a) ('V3' a)   -- @   _xyz :: Functor f => (V3 a -> f (V3 a)) -> t a -> f (t a) 
src/Linear/V4.hs view
@@ -173,12 +173,12 @@ class R3 t => R4 t where   -- |   -- @-  -- '_w' :: Lens' (t a) a+  -- '_w' :: 'Lens'' (t a) a   -- @   _w :: Functor f => (a -> f a) -> t a -> f (t a)   -- |   -- @-  -- '_xyzw' :: Lens' (t a) ('V4' a)+  -- '_xyzw' :: 'Lens'' (t a) ('V4' a)   -- @   _xyzw :: Functor f => (V4 a -> f (V4 a)) -> t a -> f (t a) 
src/Linear/Vector.hs view
@@ -376,8 +376,8 @@  -- | Produce a default basis for a vector space. If the dimensionality -- of the vector space is not statically known, see 'basisFor'.-basis :: (Applicative t, Traversable t, Num a) => [t a]-basis = choices $ traverse (\a -> SetOne 0 [a]) (pure 1)+basis :: (Additive t, Traversable t, Num a) => [t a]+basis = basisFor (zero :: Additive v => v Int)  -- | Produce a default basis for a vector space from which the -- argument is drawn.@@ -392,8 +392,8 @@ -- -- >>> unit _x :: V2 Int -- V2 1 0-unit :: (Applicative t, Num a) => ASetter' (t a) a -> t a-unit l = set' l 1 (pure 0)+unit :: (Additive t, Num a) => ASetter' (t a) a -> t a+unit l = set' l 1 zero  fillFromList :: Traversable t => [a] -> t b -> t a fillFromList l = snd . mapAccumL aux l