From 49df400d892d4f51cbe724f5677aec70753b0408 Mon Sep 17 00:00:00 2001 From: Khudyakov Alexey Date: Wed, 29 Sep 2010 12:35:11 +0000 Subject: [hlint] Remove redundant brackets and $'s --- lib/Data/Packed/Internal/Matrix.hs | 2 +- lib/Data/Packed/Matrix.hs | 4 ++-- lib/Data/Packed/Random.hs | 2 +- lib/Graphics/Plot.hs | 10 +++++----- lib/Numeric/Chain.hs | 14 +++++++------- lib/Numeric/Container.hs | 4 ++-- lib/Numeric/LinearAlgebra/Algorithms.hs | 5 ++--- lib/Numeric/LinearAlgebra/Tests/Instances.hs | 2 +- 8 files changed, 21 insertions(+), 22 deletions(-) (limited to 'lib') diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index c4491fb..29aba51 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs @@ -160,7 +160,7 @@ fromRows vs = case compatdim (map dim vs) of -- | extracts the rows of a matrix as a list of vectors toRows :: Element t => Matrix t -> [Vector t] toRows m = toRows' 0 where - v = flatten $ m + v = flatten m r = rows m c = cols m toRows' k | k == r*c = [] diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index 2efb08d..de2300a 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs @@ -269,7 +269,7 @@ Hilbert matrix of order N: -} buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a buildMatrix rc cc f = - fromLists $ map (\x -> map f x) + fromLists $ map (map f) $ map (\ ri -> map (\ ci -> (ri, ci)) [0 .. (cc - 1)]) [0 .. (rc - 1)] ----------------------------------------------------- @@ -283,7 +283,7 @@ fromArray2D m = (r> [Int] -> Matrix t -> Matrix t -extractRows l m = fromRows $ extract (toRows $ m) l +extractRows l m = fromRows $ extract (toRows m) l where extract l' is = [l'!!i |i<-is] {- | creates matrix by repetition of a matrix a given number of rows and columns diff --git a/lib/Data/Packed/Random.hs b/lib/Data/Packed/Random.hs index 14d91ea..4b229f0 100644 --- a/lib/Data/Packed/Random.hs +++ b/lib/Data/Packed/Random.hs @@ -63,4 +63,4 @@ meanCov x = (med,cov) where med = konst k r `vXm` x meds = konst 1 r `outer` med xc = x `sub` meds - cov = flip scale (trans xc `mXm` xc) (recip (fromIntegral (r-1))) + cov = scale (recip (fromIntegral (r-1))) (trans xc `mXm` xc) diff --git a/lib/Graphics/Plot.hs b/lib/Graphics/Plot.hs index 32106df..74a2695 100644 --- a/lib/Graphics/Plot.hs +++ b/lib/Graphics/Plot.hs @@ -45,7 +45,7 @@ In certain versions you can interactively rotate the graphic using the mouse. mesh :: Matrix Double -> IO () mesh m = gnuplotX (command++dat) where command = "splot "++datafollows++" matrix with lines\n" - dat = prep $ toLists $ m + dat = prep $ toLists m {- | Draws the surface represented by the function f in the desired ranges and number of points, internally using 'mesh'. @@ -104,7 +104,7 @@ matrixToPGM m = header ++ unlines (map unwords ll) where maxgray = 255.0 maxval = maxElement m minval = minElement m - scale' = if (maxval == minval) + scale' = if maxval == minval then 0.0 else maxgray / (maxval - minval) f x = show ( round ( scale' *(x - minval) ) :: Int ) @@ -124,7 +124,7 @@ gnuplotX command = do { _ <- system cmdstr; return()} where datafollows = "\\\"-\\\"" -prep = (++"e\n\n") . unlines . map (unwords . (map show)) +prep = (++"e\n\n") . unlines . map (unwords . map show) gnuplotpdf :: String -> String -> [([[Double]], String)] -> IO () @@ -158,7 +158,7 @@ gnuplotpdf title command ds = gnuplot (prelude ++ command ++" "++ draw) >> postp "\\end{document}" - pr = (++"e\n") . unlines . map (unwords . (map show)) + pr = (++"e\n") . unlines . map (unwords . map show) gnuplot cmd = do writeFile "gnuplotcommand" cmd @@ -172,7 +172,7 @@ gnuplotWin title command ds = gnuplot (prelude ++ command ++" "++ draw) where draw = concat (intersperse ", " (map ("\"-\" "++) defs)) ++ "\n" ++ concatMap pr dats - pr = (++"e\n") . unlines . map (unwords . (map show)) + pr = (++"e\n") . unlines . map (unwords . map show) prelude = "set title \""++title++"\";" diff --git a/lib/Numeric/Chain.hs b/lib/Numeric/Chain.hs index 03ca88d..e1ab7da 100644 --- a/lib/Numeric/Chain.hs +++ b/lib/Numeric/Chain.hs @@ -98,11 +98,11 @@ minimum_cost :: (Sizes,Cost,Indexes) -> (Int,Int) -> (Sizes,Cost,Indexes) minimum_cost sci fu = foldl (smaller_cost fu) sci (fulcrum_order fu) smaller_cost :: (Int,Int) -> (Sizes,Cost,Indexes) -> ((Int,Int),(Int,Int)) -> (Sizes,Cost,Indexes) -smaller_cost (r,c) (mz,cost,ixes) ix@((lr,lc),(rr,rc)) = let op_cost = (fromJust ((cost A.! lr) A.! lc)) - + (fromJust ((cost A.! rr) A.! rc)) - + ((fst $ mz A.! (lr-lc+1)) - *(snd $ mz A.! lc) - *(snd $ mz A.! rr)) +smaller_cost (r,c) (mz,cost,ixes) ix@((lr,lc),(rr,rc)) = let op_cost = fromJust ((cost A.! lr) A.! lc) + + fromJust ((cost A.! rr) A.! rc) + + fst (mz A.! (lr-lc+1)) + * snd (mz A.! lc) + * snd (mz A.! rr) cost' = (cost A.! r) A.! c in case cost' of Nothing -> let cost'' = update cost (r,c) (Just op_cost) @@ -118,10 +118,10 @@ smaller_cost (r,c) (mz,cost,ixes) ix@((lr,lc),(rr,rc)) = let op_cost = (fromJust fulcrum_order (r,c) = let fs' = zip (repeat r) [1..(c-1)] in map (partner (r,c)) fs' -partner (r,c) (a,b) = (((r-b),(c-b)),(a,b)) +partner (r,c) (a,b) = ((r-b, c-b), (a,b)) order 0 = [] -order n = (order (n-1)) ++ (zip (repeat n) [1..n]) +order n = order (n-1) ++ zip (repeat n) [1..n] chain_paren :: Product a => (Int,Int) -> Indexes -> Matrices a -> Matrix a chain_paren (r,c) ixes ma = let ((lr,lc),(rr,rc)) = fromJust $ (ixes A.! r) A.! c diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs index 45b33e0..621574e 100644 --- a/lib/Numeric/Container.hs +++ b/lib/Numeric/Container.hs @@ -117,10 +117,10 @@ instance Mul Matrix Matrix Matrix where (<>) = mXm instance Mul Matrix Vector Vector where - (<>) m v = flatten $ m <> (asColumn v) + (<>) m v = flatten $ m <> asColumn v instance Mul Vector Matrix Vector where - (<>) v m = flatten $ (asRow v) <> m + (<>) v m = flatten $ asRow v <> m -------------------------------------------------------- diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs index f4f8bca..dd93db2 100644 --- a/lib/Numeric/LinearAlgebra/Algorithms.hs +++ b/lib/Numeric/LinearAlgebra/Algorithms.hs @@ -392,7 +392,7 @@ eps = 2.22044604925031e-16 -- | 1 + 0.5*peps == 1, 1 + 0.6*peps /= 1 peps :: RealFloat x => x -peps = x where x = 2.0**(fromIntegral $ 1-floatDigits x) +peps = x where x = 2.0 ** fromIntegral (1 - floatDigits x) -- | The imaginary unit: @i = 0.0 :+ 1.0@ @@ -553,8 +553,7 @@ epslist = [ (fromIntegral k, golubeps k k) | k <- [1..]] geps delta = head [ k | (k,g) <- epslist, g Arbitrary (Matrix a) where #if MIN_VERSION_QuickCheck(2,0,0) -- shrink any one of the components - shrink a = map ((rows a) >< (cols a)) + shrink a = map (rows a >< cols a) . shrinkListElementwise . concat . toLists $ a -- cgit v1.2.3