summaryrefslogtreecommitdiff
path: root/packages/base/src/Data
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/Data
parent302a220b636d510ccf654e3671e8a93391c13523 (diff)
improved loadMatrix
Diffstat (limited to 'packages/base/src/Data')
-rw-r--r--packages/base/src/Data/Packed/IO.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/packages/base/src/Data/Packed/IO.hs b/packages/base/src/Data/Packed/IO.hs
index f7afa80..85f1b37 100644
--- a/packages/base/src/Data/Packed/IO.hs
+++ b/packages/base/src/Data/Packed/IO.hs
@@ -14,7 +14,7 @@
14 14
15module Data.Packed.IO ( 15module Data.Packed.IO (
16 dispf, disps, dispcf, vecdisp, latexFormat, format, 16 dispf, disps, dispcf, vecdisp, latexFormat, format,
17 readMatrix, fromArray2D, loadMatrix, saveMatrix 17 readMatrix, fromArray2D, loadMatrix, loadMatrix', saveMatrix
18) where 18) where
19 19
20import Data.Packed 20import Data.Packed
@@ -155,5 +155,13 @@ loadMatrix :: FilePath -> IO (Matrix Double)
155loadMatrix f = do 155loadMatrix f = do
156 v <- vectorScan f 156 v <- vectorScan f
157 c <- apparentCols f 157 c <- apparentCols f
158 return (reshape c v) 158 if (dim v `mod` c /= 0)
159 then
160 error $ printf "loadMatrix: %d elements and %d columns in file %s"
161 (dim v) c f
162 else
163 return (reshape c v)
164
165
166loadMatrix' name = mbCatch (loadMatrix name)
159 167