diff options
Diffstat (limited to 'packages/base/src/Data/Packed')
-rw-r--r-- | packages/base/src/Data/Packed/IO.hs | 12 |
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 | ||
15 | module Data.Packed.IO ( | 15 | module 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 | ||
20 | import Data.Packed | 20 | import Data.Packed |
@@ -155,5 +155,13 @@ loadMatrix :: FilePath -> IO (Matrix Double) | |||
155 | loadMatrix f = do | 155 | loadMatrix 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 | |||
166 | loadMatrix' name = mbCatch (loadMatrix name) | ||
159 | 167 | ||