packages feed

linear 1.20.2 → 1.20.3

raw patch · 4 files changed

+53/−6 lines, 4 filesdep ~cerealdep ~vector

Dependency ranges changed: cereal, vector

Files

CHANGELOG.markdown view
@@ -1,3 +1,9 @@+1.20.3+------+* Support `vector` 0.11.0.0.+* Support `cereal` 0.5+* You can now unboxed vectors of `V n` vectors.+ 1.20.2 ------ * Modified the `doctest` machinery to work with `stack` and builds to non-standard locations.
linear.cabal view
@@ -1,6 +1,6 @@ name:          linear category:      Math, Algebra-version:       1.20.2+version:       1.20.3 license:       BSD3 cabal-version: >= 1.8 license-file:  LICENSE@@ -46,7 +46,7 @@     base                 >= 4.5   && < 5,     binary               >= 0.5   && < 0.8,     bytes                >= 0.15  && < 1,-    cereal               >= 0.4.1.1 && < 0.5,+    cereal               >= 0.4.1.1 && < 0.6,     containers           >= 0.4   && < 0.6,     deepseq              >= 1.1   && < 1.5,     distributive         >= 0.2.2 && < 1,
src/Linear/Affine.hs view
@@ -54,6 +54,9 @@ #if __GLASGOW_HASKELL__ >= 706 import GHC.Generics (Generic1) #endif+import qualified Data.Vector.Generic.Mutable as M+import qualified Data.Vector.Generic as G+import qualified Data.Vector.Unboxed.Base as U import Linear.Epsilon import Linear.Metric import Linear.Plucker@@ -252,3 +255,36 @@ relative p0 = iso (.-. p0) (p0 .+^) {-# INLINE relative #-} +data instance U.Vector    (Point f a) =  V_P !(U.Vector    (f a))+data instance U.MVector s (Point f a) = MV_P !(U.MVector s (f a))+instance U.Unbox (f a) => U.Unbox (Point f a)++instance U.Unbox (f a) => M.MVector U.MVector (Point f a) where+  {-# INLINE basicLength #-}+  {-# INLINE basicUnsafeSlice #-}+  {-# INLINE basicOverlaps #-}+  {-# INLINE basicUnsafeNew #-}+  {-# INLINE basicUnsafeRead #-}+  {-# INLINE basicUnsafeWrite #-}+  basicLength (MV_P v) = M.basicLength v+  basicUnsafeSlice m n (MV_P v) = MV_P (M.basicUnsafeSlice m n v)+  basicOverlaps (MV_P v) (MV_P u) = M.basicOverlaps v u+  basicUnsafeNew n = MV_P `liftM` M.basicUnsafeNew n+  basicUnsafeRead (MV_P v) i = P `liftM` M.basicUnsafeRead v i+  basicUnsafeWrite (MV_P v) i (P x) = M.basicUnsafeWrite v i x+#if MIN_VERSION_vector(0,11,0)+  basicInitialize (MV_P v) = M.basicInitialize v+  {-# INLINE basicInitialize #-}+#endif++instance U.Unbox (f a) => G.Vector U.Vector (Point f a) where+  {-# INLINE basicUnsafeFreeze #-}+  {-# INLINE basicUnsafeThaw   #-}+  {-# INLINE basicLength       #-}+  {-# INLINE basicUnsafeSlice  #-}+  {-# INLINE basicUnsafeIndexM #-}+  basicUnsafeFreeze (MV_P v) = V_P `liftM` G.basicUnsafeFreeze v+  basicUnsafeThaw   ( V_P v) = MV_P `liftM` G.basicUnsafeThaw   v+  basicLength       ( V_P v) = G.basicLength v+  basicUnsafeSlice m n (V_P v) = V_P (G.basicUnsafeSlice m n v)+  basicUnsafeIndexM (V_P v) i = P `liftM` G.basicUnsafeIndexM v i
src/Linear/V.hs view
@@ -206,8 +206,8 @@   product (V as) = V.product as   {-# INLINE product #-} #endif-   + instance FoldableWithIndex Int (V n) where   ifoldMap f (V as) = ifoldMap f as   {-# INLINE ifoldMap #-}@@ -488,9 +488,14 @@   basicUnsafeRead (MV_VN _ v) i =     liftM V $ V.generateM d (\j -> M.basicUnsafeRead v (d*i+j))     where d = reflectDim (Proxy :: Proxy n)-  basicUnsafeWrite (MV_VN _ v) i (V vn) =-    V.imapM_ (\j -> M.basicUnsafeWrite v (d*i+j)) vn-    where d = reflectDim (Proxy :: Proxy n)+  basicUnsafeWrite (MV_VN _ v0) i0 (V vn0) = let d0 = V.length vn0 in go v0 vn0 d0 (d0*i0) i0+   where+    go v vn d o i+      | i >= d = return ()+      | otherwise = do+        a <- G.basicUnsafeIndexM vn i+        M.basicUnsafeWrite v o a+        go v vn d (o+1) (i-1) #if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_VN _ v) = M.basicInitialize v   {-# INLINE basicInitialize #-}