summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Matrix.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-10-19 09:39:06 +0000
committerAlberto Ruiz <aruiz@um.es>2007-10-19 09:39:06 +0000
commit1a9c07dd1fffdbd7eb939fa6a781793419947c08 (patch)
tree849f7206f3179b60b19a6e986809b108381c9414 /lib/Data/Packed/Internal/Matrix.hs
parentf71bcb5b4fbc68f514acc05005cc96932ced32dc (diff)
some refactoring
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs16
1 files changed, 1 insertions, 15 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index bf7f0ec..77906dc 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -22,10 +22,10 @@ import Data.Packed.Internal.Vector
22import Foreign hiding (xor) 22import Foreign hiding (xor)
23import Complex 23import Complex
24import Control.Monad(when) 24import Control.Monad(when)
25import Data.List(transpose,intersperse)
26import Data.Maybe(fromJust) 25import Data.Maybe(fromJust)
27import Foreign.C.String 26import Foreign.C.String
28import Foreign.C.Types 27import Foreign.C.Types
28import Data.List(transpose)
29 29
30----------------------------------------------------------------- 30-----------------------------------------------------------------
31 31
@@ -199,20 +199,6 @@ instance Field (Complex Double) where
199 199
200------------------------------------------------------------------ 200------------------------------------------------------------------
201 201
202instance (Show a, Field a) => (Show (Matrix a)) where
203 show m = (sizes++) . dsp . map (map show) . toLists $ m
204 where sizes = "("++show (rows m)++"><"++show (cols m)++")\n"
205
206dsp as = (++" ]") . (" ["++) . init . drop 2 . unlines . map (" , "++) . map unwords' $ transpose mtp
207 where
208 mt = transpose as
209 longs = map (maximum . map length) mt
210 mtp = zipWith (\a b -> map (pad a) b) longs mt
211 pad n str = replicate (n - length str) ' ' ++ str
212 unwords' = concat . intersperse ", "
213
214------------------------------------------------------------------
215
216(>|<) :: (Field a) => Int -> Int -> [a] -> Matrix a 202(>|<) :: (Field a) => Int -> Int -> [a] -> Matrix a
217r >|< c = f where 203r >|< c = f where
218 f l | dim v == r*c = matrixFromVector ColumnMajor c v 204 f l | dim v == r*c = matrixFromVector ColumnMajor c v