summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/LinearAlgebra
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
parent302a220b636d510ccf654e3671e8a93391c13523 (diff)
improved loadMatrix
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Data.hs2
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util.hs5
2 files changed, 4 insertions, 3 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Data.hs b/packages/base/src/Numeric/LinearAlgebra/Data.hs
index d5ce32f..b1a31fc 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Data.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Data.hs
@@ -55,7 +55,7 @@ module Numeric.LinearAlgebra.Data(
55 55
56 -- * IO 56 -- * IO
57 disp, 57 disp,
58 loadMatrix, saveMatrix, 58 loadMatrix, loadMatrix', saveMatrix,
59 latexFormat, 59 latexFormat,
60 dispf, disps, dispcf, format, 60 dispf, disps, dispcf, format,
61 dispDots, dispBlanks, dispShort, 61 dispDots, dispBlanks, dispShort,
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