summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Matrix.hs
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2013-03-17 23:12:05 -0400
committerBen Gamari <bgamari.foss@gmail.com>2013-03-17 23:12:05 -0400
commit167ee54f28248d55da72bcb22c3335f8448efcfa (patch)
treec1bc4545d7e68e1be5deda703b3d45f948daa9e5 /lib/Data/Packed/Matrix.hs
parenta1b41bc023c0ac44b130c6092e886525d6411b86 (diff)
Matrix: Whitespace cleanup
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r--lib/Data/Packed/Matrix.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs
index 68971ff..c1a9b24 100644
--- a/lib/Data/Packed/Matrix.hs
+++ b/lib/Data/Packed/Matrix.hs
@@ -157,7 +157,7 @@ adaptBlocks ms = ms' where
157 157
158----------------------------------------------------------- 158-----------------------------------------------------------
159 159
160-- | Reverse rows 160-- | Reverse rows
161flipud :: Element t => Matrix t -> Matrix t 161flipud :: Element t => Matrix t -> Matrix t
162flipud m = fromRows . reverse . toRows $ m 162flipud m = fromRows . reverse . toRows $ m
163 163
@@ -272,7 +272,7 @@ Hilbert matrix of order N:
272buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a 272buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a
273buildMatrix rc cc f = 273buildMatrix rc cc f =
274 fromLists $ map (map f) 274 fromLists $ map (map f)
275 $ map (\ ri -> map (\ ci -> (ri, ci)) [0 .. (cc - 1)]) [0 .. (rc - 1)] 275 $ map (\ ri -> map (\ ci -> (ri, ci)) [0 .. (cc - 1)]) [0 .. (rc - 1)]
276 276
277----------------------------------------------------- 277-----------------------------------------------------
278 278
@@ -283,7 +283,7 @@ fromArray2D m = (r><c) (elems m)
283 c = c1-c0+1 283 c = c1-c0+1
284 284
285 285
286-- | rearranges the rows of a matrix according to the order given in a list of integers. 286-- | rearranges the rows of a matrix according to the order given in a list of integers.
287extractRows :: Element t => [Int] -> Matrix t -> Matrix t 287extractRows :: Element t => [Int] -> Matrix t -> Matrix t
288extractRows l m = fromRows $ extract (toRows m) l 288extractRows l m = fromRows $ extract (toRows m) l
289 where extract l' is = [l'!!i |i<-is] 289 where extract l' is = [l'!!i |i<-is]
@@ -351,9 +351,9 @@ toBlocksEvery r c m = toBlocks rs cs m where
351 351
352------------------------------------------------------------------- 352-------------------------------------------------------------------
353 353
354mk c g = \k v -> g (divMod k c) v 354mk c g = \k v -> g (divMod k c) v
355 355
356{- | 356{- |
357 357
358@ghci> mapMatrixWithIndexM_ (\\(i,j) v -> printf \"m[%.0f,%.0f] = %.f\\n\" i j v :: IO()) ((2><3)[1 :: Double ..]) 358@ghci> mapMatrixWithIndexM_ (\\(i,j) v -> printf \"m[%.0f,%.0f] = %.f\\n\" i j v :: IO()) ((2><3)[1 :: Double ..])
359m[0,0] = 1 359m[0,0] = 1
@@ -367,7 +367,7 @@ mapMatrixWithIndexM_
367 :: (Element a, Num a, 367 :: (Element a, Num a,
368 Functor f, Monad f) => 368 Functor f, Monad f) =>
369 ((Int, Int) -> a -> f ()) -> Matrix a -> f () 369 ((Int, Int) -> a -> f ()) -> Matrix a -> f ()
370mapMatrixWithIndexM_ g m = mapVectorWithIndexM_ (mk c g) . flatten $ m 370mapMatrixWithIndexM_ g m = mapVectorWithIndexM_ (mk c g) . flatten $ m
371 where 371 where
372 c = cols m 372 c = cols m
373 373
@@ -380,11 +380,11 @@ Just (3><3)
380 , 20.0, 21.0, 122.0 ]@ 380 , 20.0, 21.0, 122.0 ]@
381-} 381-}
382mapMatrixWithIndexM 382mapMatrixWithIndexM
383 :: (Foreign.Storable.Storable t, 383 :: (Foreign.Storable.Storable t,
384 Element a, Num a, 384 Element a, Num a,
385 Functor f, Monad f) => 385 Functor f, Monad f) =>
386 ((Int, Int) -> a -> f t) -> Matrix a -> f (Matrix t) 386 ((Int, Int) -> a -> f t) -> Matrix a -> f (Matrix t)
387mapMatrixWithIndexM g m = fmap (reshape c) . mapVectorWithIndexM (mk c g) . flatten $ m 387mapMatrixWithIndexM g m = fmap (reshape c) . mapVectorWithIndexM (mk c g) . flatten $ m
388 where 388 where
389 c = cols m 389 c = cols m
390 390