summaryrefslogtreecommitdiff
path: root/lib/Data
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2013-03-17 21:38:13 -0400
committerBen Gamari <bgamari.foss@gmail.com>2013-03-17 21:38:13 -0400
commit1c920c8bed07646272d859c8d5ad1a77cbf98cd9 (patch)
tree97073e78063aaebe505847806ffac395ce0856fa /lib/Data
parent55edd1062e41e58c702e8049849e44333c8c83d7 (diff)
Data.Packed.Matrix: mapMatrix* should pass indices as Ints
Diffstat (limited to 'lib/Data')
-rw-r--r--lib/Data/Packed/Matrix.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs
index ca96c50..48b2279 100644
--- a/lib/Data/Packed/Matrix.hs
+++ b/lib/Data/Packed/Matrix.hs
@@ -46,7 +46,6 @@ import Data.Array
46 46
47import Data.List(transpose,intersperse) 47import Data.List(transpose,intersperse)
48import Foreign.Storable(Storable) 48import Foreign.Storable(Storable)
49import Control.Arrow((***))
50 49
51------------------------------------------------------------------- 50-------------------------------------------------------------------
52 51
@@ -352,7 +351,7 @@ toBlocksEvery r c m = toBlocks rs cs m where
352 351
353------------------------------------------------------------------- 352-------------------------------------------------------------------
354 353
355mk c g = \k v -> g ((fromIntegral *** fromIntegral) (divMod k c)) v 354mk c g = \k v -> g (divMod k c) v
356 355
357{- | 356{- |
358 357
@@ -367,7 +366,7 @@ m[1,2] = 6@
367mapMatrixWithIndexM_ 366mapMatrixWithIndexM_
368 :: (Element a, Num a, 367 :: (Element a, Num a,
369 Functor f, Monad f) => 368 Functor f, Monad f) =>
370 ((a, a) -> a -> f ()) -> Matrix a -> f () 369 ((Int, Int) -> a -> f ()) -> Matrix a -> f ()
371mapMatrixWithIndexM_ g m = mapVectorWithIndexM_ (mk c g) . flatten $ m 370mapMatrixWithIndexM_ g m = mapVectorWithIndexM_ (mk c g) . flatten $ m
372 where 371 where
373 c = cols m 372 c = cols m
@@ -384,7 +383,7 @@ mapMatrixWithIndexM
384 :: (Foreign.Storable.Storable t, 383 :: (Foreign.Storable.Storable t,
385 Element a, Num a, 384 Element a, Num a,
386 Functor f, Monad f) => 385 Functor f, Monad f) =>
387 ((a, a) -> a -> f t) -> Matrix a -> f (Matrix t) 386 ((Int, Int) -> a -> f t) -> Matrix a -> f (Matrix t)
388mapMatrixWithIndexM g m = fmap (reshape c) . mapVectorWithIndexM (mk c g) . flatten $ m 387mapMatrixWithIndexM g m = fmap (reshape c) . mapVectorWithIndexM (mk c g) . flatten $ m
389 where 388 where
390 c = cols m 389 c = cols m
@@ -398,7 +397,7 @@ mapMatrixWithIndexM g m = fmap (reshape c) . mapVectorWithIndexM (mk c g) . flat
398 -} 397 -}
399mapMatrixWithIndex :: (Foreign.Storable.Storable t, 398mapMatrixWithIndex :: (Foreign.Storable.Storable t,
400 Element a, Num a) => 399 Element a, Num a) =>
401 ((a, a) -> a -> t) -> Matrix a -> Matrix t 400 ((Int, Int) -> a -> t) -> Matrix a -> Matrix t
402mapMatrixWithIndex g = head . mapMatrixWithIndexM (\a b -> [g a b]) 401mapMatrixWithIndex g = head . mapMatrixWithIndexM (\a b -> [g a b])
403 402
404mapMatrix :: (Storable a, Storable b) => (a -> b) -> Matrix a -> Matrix b 403mapMatrix :: (Storable a, Storable b) => (a -> b) -> Matrix a -> Matrix b