From 482b533c3fbfcd75d6c5c1d3ce32585bf9fc2ad7 Mon Sep 17 00:00:00 2001 From: Vivian McPhail Date: Mon, 20 Sep 2010 03:48:46 +0000 Subject: remove Fractional from Element --- lib/Data/Packed/Internal/Matrix.hs | 3 ++- lib/Data/Packed/Matrix.hs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/Data/Packed') diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 090826d..c0824a3 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs @@ -246,7 +246,8 @@ compat m1 m2 = rows m1 == rows m2 && cols m1 == cols m2 ------------------------------------------------------------------ -- | Supported element types for basic matrix operations. -class (Storable a, Floating a) => Element a where +--class (Storable a, Floating a) => Element a where +class (Storable a) => Element a where subMatrixD :: (Int,Int) -- ^ (r0,c0) starting position -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix -> Matrix a -> Matrix a diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index 0fc7876..b8c309c 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs @@ -170,7 +170,7 @@ fliprl m = fromColumns . reverse . toColumns $ m ------------------------------------------------------------ -- | Creates a square matrix with a given diagonal. -diag :: Element a => Vector a -> Matrix a +diag :: (Num a, Element a) => Vector a -> Matrix a diag v = ST.runSTMatrix $ do let d = dim v m <- ST.newMatrix 0 d d @@ -199,7 +199,7 @@ takeDiag :: (Element t) => Matrix t -> Vector t takeDiag m = fromList [flatten m `at` (k*cols m+k) | k <- [0 .. min (rows m) (cols m) -1]] -- | creates the identity matrix of given dimension -ident :: Element a => Int -> Matrix a +ident :: (Num a, Element a) => Int -> Matrix a ident n = diag (constantD 1 n) ------------------------------------------------------------ -- cgit v1.2.3