summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/LinearAlgebra/Util.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-06-12 14:15:05 +0200
committerAlberto Ruiz <aruiz@um.es>2014-06-12 14:15:05 +0200
commit01832377377142696645a2ea800af2db3d0fac15 (patch)
tree4988111123ac1e8ad4cc377bb713f8fff6ee3274 /packages/base/src/Numeric/LinearAlgebra/Util.hs
parent302a220b636d510ccf654e3671e8a93391c13523 (diff)
improved loadMatrix
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra/Util.hs')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util.hs b/packages/base/src/Numeric/LinearAlgebra/Util.hs
index b6f8966..6bb9d15 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Util.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Util.hs
@@ -416,7 +416,7 @@ c ~!~ msg = when c (error msg)
416 416
417formatSparse :: String -> String -> String -> Int -> Matrix Double -> String 417formatSparse :: String -> String -> String -> Int -> Matrix Double -> String
418 418
419formatSparse zeroI zeroF sep _ (approxInt -> Just m) = format sep f m 419formatSparse zeroI _zeroF sep _ (approxInt -> Just m) = format sep f m
420 where 420 where
421 f 0 = zeroI 421 f 0 = zeroI
422 f x = printf "%.0f" x 422 f x = printf "%.0f" x
@@ -424,7 +424,8 @@ formatSparse zeroI zeroF sep _ (approxInt -> Just m) = format sep f m
424formatSparse zeroI zeroF sep n m = format sep f m 424formatSparse zeroI zeroF sep n m = format sep f m
425 where 425 where
426 f x | abs (x::Double) < 2*peps = zeroI++zeroF 426 f x | abs (x::Double) < 2*peps = zeroI++zeroF
427 | abs (fromIntegral (round x) - x) / abs x < 2*peps = printf ("%.0f."++replicate n ' ') x 427 | abs (fromIntegral (round x::Int) - x) / abs x < 2*peps
428 = printf ("%.0f."++replicate n ' ') x
428 | otherwise = printf ("%."++show n++"f") x 429 | otherwise = printf ("%."++show n++"f") x
429 430
430approxInt m 431approxInt m