diff options
Diffstat (limited to 'lib/Data')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 9 |
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 | ||
47 | import Data.List(transpose,intersperse) | 47 | import Data.List(transpose,intersperse) |
48 | import Foreign.Storable(Storable) | 48 | import Foreign.Storable(Storable) |
49 | import 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 | ||
355 | mk c g = \k v -> g ((fromIntegral *** fromIntegral) (divMod k c)) v | 354 | mk c g = \k v -> g (divMod k c) v |
356 | 355 | ||
357 | {- | | 356 | {- | |
358 | 357 | ||
@@ -367,7 +366,7 @@ m[1,2] = 6@ | |||
367 | mapMatrixWithIndexM_ | 366 | mapMatrixWithIndexM_ |
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 () |
371 | mapMatrixWithIndexM_ g m = mapVectorWithIndexM_ (mk c g) . flatten $ m | 370 | mapMatrixWithIndexM_ 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) |
388 | mapMatrixWithIndexM g m = fmap (reshape c) . mapVectorWithIndexM (mk c g) . flatten $ m | 387 | mapMatrixWithIndexM 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 | -} |
399 | mapMatrixWithIndex :: (Foreign.Storable.Storable t, | 398 | mapMatrixWithIndex :: (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 |
402 | mapMatrixWithIndex g = head . mapMatrixWithIndexM (\a b -> [g a b]) | 401 | mapMatrixWithIndex g = head . mapMatrixWithIndexM (\a b -> [g a b]) |
403 | 402 | ||
404 | mapMatrix :: (Storable a, Storable b) => (a -> b) -> Matrix a -> Matrix b | 403 | mapMatrix :: (Storable a, Storable b) => (a -> b) -> Matrix a -> Matrix b |