hmatrix 0.10.0.1 → 0.10.0.2
raw patch · 2 files changed
+24/−15 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- hmatrix.cabal +2/−2
- lib/Data/Packed/Matrix.hs +22/−13
hmatrix.cabal view
@@ -1,5 +1,5 @@ Name: hmatrix-Version: 0.10.0.1+Version: 0.10.0.2 License: GPL License-file: LICENSE Author: Alberto Ruiz@@ -21,7 +21,7 @@ . - "Numeric.LinearAlgebra": everything + instances of standard Haskell numeric classes Category: Math-tested-with: GHC ==6.10.4, GHC ==6.12.1+tested-with: GHC ==6.10.4, GHC ==6.12.1, GHC ==6.12.3 cabal-version: >=1.6
lib/Data/Packed/Matrix.hs view
@@ -300,17 +300,25 @@ repmat m r c = fromBlocks $ splitEvery c $ replicate (r*c) m -- | A version of 'liftMatrix2' which automatically adapt matrices with a single row or column to match the dimensions of the other matrix.-liftMatrix2Auto :: (Element t, Element a, Element b)- => (Vector a -> Vector b -> Vector t) -> Matrix a -> Matrix b -> Matrix t-liftMatrix2Auto f m1 m2 | compat' m1 m2 = lM f m1 m2- | rows m1 == rows m2 && cols m2 == 1 = lM f m1 (repCols (cols m1) m2)- | rows m1 == rows m2 && cols m1 == 1 = lM f (repCols (cols m2) m1) m2- | cols m1 == cols m2 && rows m2 == 1 = lM f m1 (repRows (rows m1) m2)- | cols m1 == cols m2 && cols m1 == 1 = lM f (repRows (rows m2) m1) m2- | rows m1 == 1 && cols m2 == 1 = lM f (repRows (rows m2) m1) (repCols (cols m1) m2)- | cols m1 == 1 && rows m2 == 1 = lM f (repCols (cols m2) m1) (repRows (rows m1) m2)- | otherwise = error $ "nonconformable matrices in liftMatrix2Auto: " ++ show (size m1) ++ ", " ++ show (size m2)+liftMatrix2Auto :: (Element t, Element a, Element b) => (Vector a -> Vector b -> Vector t) -> Matrix a -> Matrix b -> Matrix t+liftMatrix2Auto f m1 m2+ | compat' m1 m2 = lM f m1 m2 + | r1 == 1 && c2 == 1 = lM f (repRows r2 m1) (repCols c1 m2)+ | c1 == 1 && r2 == 1 = lM f (repCols c2 m1) (repRows r1 m2)+ + | r1 == r2 && c2 == 1 = lM f m1 (repCols c1 m2)+ | r1 == r2 && c1 == 1 = lM f (repCols c2 m1) m2++ | c1 == c2 && r2 == 1 = lM f m1 (repRows r1 m2)+ | c1 == c2 && r1 == 1 = lM f (repRows r2 m1) m2++ | otherwise = error $ "nonconformable matrices in liftMatrix2Auto: "+ ++ show (size m1) ++ ", " ++ show (size m2)+ where+ (r1,c1) = size m1+ (r2,c2) = size m2+ size m = (rows m, cols m) lM f m1 m2 = reshape (max (cols m1) (cols m2)) (f (flatten m1) (flatten m2))@@ -319,9 +327,10 @@ repCols n x = fromColumns (replicate n (flatten x)) compat' :: Matrix a -> Matrix b -> Bool-compat' m1 m2 = rows m1 == 1 && cols m1 == 1- || rows m2 == 1 && cols m2 == 1- || rows m1 == rows m2 && cols m1 == cols m2+compat' m1 m2 = s1 == (1,1) || s2 == (1,1) || s1 == s2+ where+ s1 = size m1+ s2 = size m2 ------------------------------------------------------------