diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2013-03-17 23:12:05 -0400 |
---|---|---|
committer | Ben Gamari <bgamari.foss@gmail.com> | 2013-03-17 23:12:05 -0400 |
commit | 167ee54f28248d55da72bcb22c3335f8448efcfa (patch) | |
tree | c1bc4545d7e68e1be5deda703b3d45f948daa9e5 | |
parent | a1b41bc023c0ac44b130c6092e886525d6411b86 (diff) |
Matrix: Whitespace cleanup
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 16 |
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 |
161 | flipud :: Element t => Matrix t -> Matrix t | 161 | flipud :: Element t => Matrix t -> Matrix t |
162 | flipud m = fromRows . reverse . toRows $ m | 162 | flipud m = fromRows . reverse . toRows $ m |
163 | 163 | ||
@@ -272,7 +272,7 @@ Hilbert matrix of order N: | |||
272 | buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a | 272 | buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a |
273 | buildMatrix rc cc f = | 273 | buildMatrix 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. |
287 | extractRows :: Element t => [Int] -> Matrix t -> Matrix t | 287 | extractRows :: Element t => [Int] -> Matrix t -> Matrix t |
288 | extractRows l m = fromRows $ extract (toRows m) l | 288 | extractRows 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 | ||
354 | mk c g = \k v -> g (divMod k c) v | 354 | mk 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 ..]) |
359 | m[0,0] = 1 | 359 | m[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 () |
370 | mapMatrixWithIndexM_ g m = mapVectorWithIndexM_ (mk c g) . flatten $ m | 370 | mapMatrixWithIndexM_ 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 | -} |
382 | mapMatrixWithIndexM | 382 | mapMatrixWithIndexM |
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) |
387 | 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 |
388 | where | 388 | where |
389 | c = cols m | 389 | c = cols m |
390 | 390 | ||