From 09e51d85570bb01e8df81cfdb579bee7cd445329 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 3 Feb 2013 15:01:19 -0500 Subject: [PATCH] Fix compiler warnings in Matrix.hs. --- src/Matrix.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Matrix.hs b/src/Matrix.hs index a79619e..349b71a 100644 --- a/src/Matrix.hs +++ b/src/Matrix.hs @@ -85,11 +85,12 @@ rowsminus rs1 rs2 = -- | Matrix multiplication. mtimes :: Num a => (Matrix a) -> (Matrix a) -> (Matrix a) -mtimes m1@(Matrix rows1) m2@(Matrix rows2) = +mtimes m1 m2 = Matrix (V.fromList rows) where - row i = V.fromList [ sum [ (m1 ! (i,k)) * (m2 ! (k,j)) | k <- [0..(ncols m1)-1] ] - | j <- [0..(ncols m2)-1] ] + row i = + V.fromList [ sum [ (m1 ! (i,k)) * (m2 ! (k,j)) | k <- [0..(ncols m1)-1] ] + | j <- [0..(ncols m2)-1] ] rows = [row i | i <- [0..(nrows m1)-1]] -- | Is @m@ symmetric? @@ -108,7 +109,7 @@ construct :: Int -> Int -> (Int -> Int -> a) -> (Matrix a) construct imax jmax lambda = Matrix rows where - row i = V.fromList [ lambda i j | j <- [0..jmax] ] + row i = V.fromList [ lambda i j | j <- [0..jmax] ] rows = V.fromList [ row i | i <- [0..imax] ] -- | Given a positive-definite matrix @m@, computes the @@ -119,9 +120,10 @@ cholesky m = construct (nrows m - 1) (ncols m - 1) r where r :: Int -> Int -> a - r i j | i > j = 0 - | i == j = sqrt(m ! (i,j) - sum [(r k i)**2 | k <- [0..i-1]]) - | i < j = (((m ! (i,j)) - sum [(r k i)*(r k j) | k <- [0..i-1]]))/(r i i) + r i j | i == j = sqrt(m ! (i,j) - sum [(r k i)**2 | k <- [0..i-1]]) + | i < j = + (((m ! (i,j)) - sum [(r k i)*(r k j) | k <- [0..i-1]]))/(r i i) + | otherwise = 0 -- | It's not correct to use Num here, but I really don't want to have -- to define my own addition and subtraction. @@ -139,4 +141,4 @@ instance Num a => Num (Matrix a) where signum _ = error "signum of matrices is undefined" - fromInteger x = error "fromInteger of matrices is undefined" + fromInteger _ = error "fromInteger of matrices is undefined" -- 2.43.2