diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index 48b2279..68971ff 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -395,11 +395,12 @@ mapMatrixWithIndexM g m = fmap (reshape c) . mapVectorWithIndexM (mk c g) . flat | |||
395 | , 10.0, 111.0, 12.0 | 395 | , 10.0, 111.0, 12.0 |
396 | , 20.0, 21.0, 122.0 ]@ | 396 | , 20.0, 21.0, 122.0 ]@ |
397 | -} | 397 | -} |
398 | mapMatrixWithIndex :: (Foreign.Storable.Storable t, | 398 | mapMatrixWithIndex :: (Foreign.Storable.Storable t, |
399 | Element a, Num a) => | 399 | Element a, Num a) => |
400 | ((Int, Int) -> a -> t) -> Matrix a -> Matrix t | 400 | ((Int, Int) -> a -> t) -> Matrix a -> Matrix t |
401 | mapMatrixWithIndex g = head . mapMatrixWithIndexM (\a b -> [g a b]) | 401 | mapMatrixWithIndex g m = reshape c $ mapVectorWithIndex (mk c g) $ flatten m |
402 | where | ||
403 | c = cols m | ||
402 | 404 | ||
403 | mapMatrix :: (Storable a, Storable b) => (a -> b) -> Matrix a -> Matrix b | 405 | mapMatrix :: (Storable a, Storable b) => (a -> b) -> Matrix a -> Matrix b |
404 | mapMatrix f = liftMatrix (mapVector f) | 406 | mapMatrix f = liftMatrix (mapVector f) |
405 | |||