packages feed

linear 1.20 → 1.20.1

raw patch · 8 files changed

+65/−13 lines, 8 files

Files

CHANGELOG.markdown view
@@ -1,3 +1,8 @@+1.20.1+------+* Fixed doctests broken by the previous change.+* Unboxed vector instances for various linear data types now use unpacked integers even on older GHCs.+ 1.20 ---- * `inv22`, `inv33` and `inv44` no longer attempt an epsilon check. They no longer return a `Maybe` result as a consequence.
linear.cabal view
@@ -1,6 +1,6 @@ name:          linear category:      Math, Algebra-version:       1.20+version:       1.20.1 license:       BSD3 cabal-version: >= 1.8 license-file:  LICENSE
src/Linear/Matrix.hs view
@@ -43,7 +43,6 @@ import Data.Distributive import Data.Foldable as Foldable import Data.Functor.Rep-import Linear.Epsilon import Linear.Quaternion import Linear.V2 import Linear.V3@@ -337,8 +336,8 @@ -- |2x2 matrix inverse. -- -- >>> inv22 $ V2 (V2 1 2) (V2 3 4)--- Just (V2 (V2 (-2.0) 1.0) (V2 1.5 (-0.5)))-inv22 :: (Epsilon a, Floating a) => M22 a -> M22 a+-- V2 (V2 (-2.0) 1.0) (V2 1.5 (-0.5))+inv22 :: Floating a => M22 a -> M22 a inv22 m@(V2 (V2 a b) (V2 c d)) = (1 / det) *!! V2 (V2 d (-b)) (V2 (-c) a)   where det = det22 m {-# INLINE inv22 #-}@@ -346,8 +345,8 @@ -- |3x3 matrix inverse. -- -- >>> inv33 $ V3 (V3 1 2 4) (V3 4 2 2) (V3 1 1 1)--- Just (V3 (V3 0.0 0.5 (-1.0)) (V3 (-0.5) (-0.75) 3.5) (V3 0.5 0.25 (-1.5)))-inv33 :: (Epsilon a, Floating a) => M33 a -> M33 a+-- V3 (V3 0.0 0.5 (-1.0)) (V3 (-0.5) (-0.75) 3.5) (V3 0.5 0.25 (-1.5))+inv33 :: Floating a => M33 a -> M33 a inv33 m@(V3 (V3 a b c)             (V3 d e f)             (V3 g h i))@@ -377,7 +376,7 @@ {-# INLINE transpose #-}  -- |4x4 matrix inverse.-inv44 :: (Epsilon a, Fractional a) => M44 a -> M44 a+inv44 :: Fractional a => M44 a -> M44 a inv44 (V4 (V4 i00 i01 i02 i03)           (V4 i10 i11 i12 i13)           (V4 i20 i21 i22 i23)
src/Linear/V0.hs view
@@ -269,6 +269,12 @@ instance U.Unbox (V0 a)  instance M.MVector U.MVector (V0 a) where+  {-# INLINE basicLength #-}+  {-# INLINE basicUnsafeSlice #-}+  {-# INLINE basicOverlaps #-}+  {-# INLINE basicUnsafeNew #-}+  {-# INLINE basicUnsafeRead #-}+  {-# INLINE basicUnsafeWrite #-}   basicLength (MV_V0 n) = n   basicUnsafeSlice _ n _ = MV_V0 n   basicOverlaps _ _ = False@@ -277,9 +283,15 @@   basicUnsafeWrite _ _ _ = return () #if MIN_VERSION_vector(0,11,0)   basicInitialize _ = return ()+  {-# INLINE basicInitialize #-} #endif  instance G.Vector U.Vector (V0 a) where+  {-# INLINE basicUnsafeFreeze #-}+  {-# INLINE basicUnsafeThaw   #-}+  {-# INLINE basicLength       #-}+  {-# INLINE basicUnsafeSlice  #-}+  {-# INLINE basicUnsafeIndexM #-}   basicUnsafeFreeze (MV_V0 n) = return (V_V0 n)   basicUnsafeThaw (V_V0 n) = return (MV_V0 n)   basicLength (V_V0 n) = n
src/Linear/V1.hs view
@@ -289,6 +289,12 @@ instance U.Unbox a => U.Unbox (V1 a)  instance U.Unbox a => M.MVector U.MVector (V1 a) where+  {-# INLINE basicLength #-}+  {-# INLINE basicUnsafeSlice #-}+  {-# INLINE basicOverlaps #-}+  {-# INLINE basicUnsafeNew #-}+  {-# INLINE basicUnsafeRead #-}+  {-# INLINE basicUnsafeWrite #-}   basicLength (MV_V1 v) = M.basicLength v   basicUnsafeSlice m n (MV_V1 v) = MV_V1 (M.basicUnsafeSlice m n v)   basicOverlaps (MV_V1 v) (MV_V1 u) = M.basicOverlaps v u@@ -297,9 +303,15 @@   basicUnsafeWrite (MV_V1 v) i (V1 x) = M.basicUnsafeWrite v i x #if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_V1 v) = M.basicInitialize v+  {-# INLINE basicInitialize #-} #endif  instance U.Unbox a => G.Vector U.Vector (V1 a) where+  {-# INLINE basicUnsafeFreeze #-}+  {-# INLINE basicUnsafeThaw   #-}+  {-# INLINE basicLength       #-}+  {-# INLINE basicUnsafeSlice  #-}+  {-# INLINE basicUnsafeIndexM #-}   basicUnsafeFreeze (MV_V1 v) = liftM V_V1 (G.basicUnsafeFreeze v)   basicUnsafeThaw (V_V1 v) = liftM MV_V1 (G.basicUnsafeThaw v)   basicLength (V_V1 v) = G.basicLength v
src/Linear/V2.hs view
@@ -330,11 +330,17 @@   each = traverse   {-# INLINE each #-} -data instance U.Vector    (V2 a) =  V_V2 !Int (U.Vector    a)-data instance U.MVector s (V2 a) = MV_V2 !Int (U.MVector s a)+data instance U.Vector    (V2 a) =  V_V2 {-# UNPACK #-} !Int !(U.Vector    a)+data instance U.MVector s (V2 a) = MV_V2 {-# UNPACK #-} !Int !(U.MVector s a) instance U.Unbox a => U.Unbox (V2 a)  instance U.Unbox a => M.MVector U.MVector (V2 a) where+  {-# INLINE basicLength #-}+  {-# INLINE basicUnsafeSlice #-}+  {-# INLINE basicOverlaps #-}+  {-# INLINE basicUnsafeNew #-}+  {-# INLINE basicUnsafeRead #-}+  {-# INLINE basicUnsafeWrite #-}   basicLength (MV_V2 n _) = n   basicUnsafeSlice m n (MV_V2 _ v) = MV_V2 n (M.basicUnsafeSlice (2*m) (2*n) v)   basicOverlaps (MV_V2 _ v) (MV_V2 _ u) = M.basicOverlaps v u@@ -350,9 +356,15 @@        M.basicUnsafeWrite v (o+1) y #if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_V2 _ v) = M.basicInitialize v+  {-# INLINE basicInitialize #-} #endif  instance U.Unbox a => G.Vector U.Vector (V2 a) where+  {-# INLINE basicUnsafeFreeze #-}+  {-# INLINE basicUnsafeThaw   #-}+  {-# INLINE basicLength       #-}+  {-# INLINE basicUnsafeSlice  #-}+  {-# INLINE basicUnsafeIndexM #-}   basicUnsafeFreeze (MV_V2 n v) = liftM ( V_V2 n) (G.basicUnsafeFreeze v)   basicUnsafeThaw   ( V_V2 n v) = liftM (MV_V2 n) (G.basicUnsafeThaw   v)   basicLength       ( V_V2 n _) = n
src/Linear/V3.hs view
@@ -353,11 +353,17 @@   each = traverse   {-# INLINE each #-} -data instance U.Vector    (V3 a) =  V_V3 !Int (U.Vector    a)-data instance U.MVector s (V3 a) = MV_V3 !Int (U.MVector s a)+data instance U.Vector    (V3 a) =  V_V3 {-# UNPACK #-} !Int !(U.Vector    a)+data instance U.MVector s (V3 a) = MV_V3 {-# UNPACK #-} !Int !(U.MVector s a) instance U.Unbox a => U.Unbox (V3 a)  instance U.Unbox a => M.MVector U.MVector (V3 a) where+  {-# INLINE basicLength #-}+  {-# INLINE basicUnsafeSlice #-}+  {-# INLINE basicOverlaps #-}+  {-# INLINE basicUnsafeNew #-}+  {-# INLINE basicUnsafeRead #-}+  {-# INLINE basicUnsafeWrite #-}   basicLength (MV_V3 n _) = n   basicUnsafeSlice m n (MV_V3 _ v) = MV_V3 n (M.basicUnsafeSlice (3*m) (3*n) v)   basicOverlaps (MV_V3 _ v) (MV_V3 _ u) = M.basicOverlaps v u@@ -375,9 +381,15 @@        M.basicUnsafeWrite v (o+2) z #if MIN_VERSION_vector(0,11,0)   basicInitialize (MV_V3 _ v) = M.basicInitialize v+  {-# INLINE basicInitialize #-} #endif  instance U.Unbox a => G.Vector U.Vector (V3 a) where+  {-# INLINE basicUnsafeFreeze #-}+  {-# INLINE basicUnsafeThaw   #-}+  {-# INLINE basicLength       #-}+  {-# INLINE basicUnsafeSlice  #-}+  {-# INLINE basicUnsafeIndexM #-}   basicUnsafeFreeze (MV_V3 n v) = liftM ( V_V3 n) (G.basicUnsafeFreeze v)   basicUnsafeThaw   ( V_V3 n v) = liftM (MV_V3 n) (G.basicUnsafeThaw   v)   basicLength       ( V_V3 n _) = n
src/Linear/V4.hs view
@@ -495,8 +495,8 @@ instance Each (V4 a) (V4 b) a b where   each = traverse -data instance U.Vector    (V4 a) =  V_V4 !Int (U.Vector    a)-data instance U.MVector s (V4 a) = MV_V4 !Int (U.MVector s a)+data instance U.Vector    (V4 a) =  V_V4 {-# UNPACK #-} !Int !(U.Vector    a)+data instance U.MVector s (V4 a) = MV_V4 {-# UNPACK #-} !Int !(U.MVector s a) instance U.Unbox a => U.Unbox (V4 a)  instance U.Unbox a => M.MVector U.MVector (V4 a) where