Permalink
Browse files

Normal error messages

  • Loading branch information...
1 parent 3280129 commit 06773d4d9fd81cbfdf122f2914d8dfeb6044c8e6 @Shimuuar committed Aug 31, 2012
Showing with 27 additions and 25 deletions.
  1. +4 −4 Data/Matrix/Dense.hs
  2. +2 −2 Data/Matrix/Generic.hs
  3. +4 −2 Numeric/BLAS/Expression.hs
  4. +17 −17 Numeric/BLAS/Mutable.hs
@@ -92,14 +92,14 @@ instance (Storable a, Show a) => Show (Matrix a) where
getRow :: Storable a => Matrix a -> Int -> V.Vector a
{-# INLINE getRow #-}
getRow m i
- | i < 0 || i >= rows m = error "A"
+ | i < 0 || i >= rows m = error "Data.Matrix.Dense.getRow: row index out of range"
| otherwise = unsafeGetRow m i
-- | Get n'th column of matrix as vector.
getCol :: Storable a => Matrix a -> Int -> V.Vector a
{-# INLINE getCol #-}
getCol m i
- | i < 0 || i >= cols m = error "A"
+ | i < 0 || i >= cols m = error "Data.Matrix.Dense.getRow: column index out of range"
| otherwise = unsafeGetColumn m i
-- | Get n'th row of matrix as vector. No range checks performed.
@@ -123,7 +123,7 @@ unsafeGetColumn (Matrix nr _ lda fp) i
-- | Create matrix from list of columns. All columns must have same
-- length.
fromCols :: Storable a => [[a]] -> Matrix a
-fromCols [] = error "AAA"
+fromCols [] = error "Data.Matrix.Dense.fromCols: empty list"
fromCols columns = runST $ do
m <- M.new (nRows,nCols)
forM_ ([0..] `zip` columns) $ \(nc,col) ->
@@ -134,7 +134,7 @@ fromCols columns = runST $ do
nCols = length columns
nRows = case group $ map length columns of
[(n:_)] -> n :: Int
- _ -> error "MUST BE SAME"
+ _ -> error "Data.Matrix.Dense.fromCols: all columns must have same length"
-- | Create matrix from list of rows. All rows must have same length.
fromRows :: Storable a => [[a]] -> Matrix a
@@ -102,8 +102,8 @@ unsafeIndex = basicUnsafeIndex
-> a
{-# INLINE (@!) #-}
m @! a@(i,j)
- | i < 0 || i >= rows m = error "ROW"
- | j > 0 || j >= cols m = error "COL"
+ | i < 0 || i >= rows m = error "Data.Matrix.Generic.@!: row index out of range"
+ | j > 0 || j >= cols m = error "Data.Matrix.Generic.@!: column index out of range"
| otherwise = unsafeIndex m a
@@ -619,7 +619,8 @@ instance BLAS1 a => LinSpaceM MMatrix a where
scaleVector α $ MMatD.unsafeGetCol m i
{-# INLINE scaleM #-}
addScaleM α x y
- | MMat.shape x /= MMat.shape y = error "QWE"
+ | MMat.shape x /= MMat.shape y =
+ error "Numeric.BLAS.Expression[MMatrix].addScaleM: dimensions of matrices don't match"
| otherwise =
forM_ [0 .. MMat.cols x - 1] $ \i ->
addVecScaled α (MMatD.unsafeGetCol x i) (MMatD.unsafeGetCol y i)
@@ -630,7 +631,8 @@ instance (BLAS1 a, MMat.IsMMatrix (MSymmetricRaw tag) a) => LinSpaceM (MSymmetri
scaleVector α $ symColumn m i
{-# INLINE scaleM #-}
addScaleM α x y
- | MMat.shape x /= MMat.shape y = error "QWE"
+ | MMat.shape x /= MMat.shape y =
+ error "Numeric.BLAS.Expression[MSymmetric].addScaleM: dimensions of matrices don't match"
| otherwise =
forM_ [0 .. MMat.cols x - 1] $ \i ->
addVecScaled α (symColumn x i) (symColumn y i)
@@ -141,8 +141,8 @@ multMV ::(PrimMonad m, MultMV mat a, MVectorBLAS v, BLAS2 a)
-> m ()
{-# INLINE multMV #-}
multMV a m x b y
- | blasLength x /= M.cols m = error "@@@ 1"
- | blasLength y /= M.rows m = error "@@@ 2"
+ | blasLength x /= M.cols m = error "Numeric.BLAS.Mutable.multMV: dimensions don't match"
+ | blasLength y /= M.rows m = error "Numeric.BLAS.Mutable.multMV: dimensions don't match"
| otherwise = unsafeMultMV a m x b y
-- | Matrix vector multiplication which dows range checking
@@ -158,8 +158,8 @@ multTMV ::(PrimMonad m, MultTMV mat a, MVectorBLAS v, BLAS2 a)
-> m ()
{-# INLINE multTMV #-}
multTMV a t m x b y
- | blasLength x /= colsT t m = error "multTMV: 1"
- | blasLength y /= rowsT t m = error "multTMV: 2"
+ | blasLength x /= colsT t m = error "Numeric.BLAS.Mutable.multTMV: dimensions don't match"
+ | blasLength y /= rowsT t m = error "Numeric.BLAS.Mutable.multTMV: dimensions don't match"
| otherwise = unsafeMultTMV a t m x b y
@@ -174,8 +174,8 @@ crossVV
=> a -> v (PrimState m) a -> v (PrimState m) a -> MD.MMatrix (PrimState m) a -> m ()
{-# INLINE crossVV #-}
crossVV a v u m
- | blasLength v /= M.cols m = error "!"
- | blasLength u /= M.rows m = error "!"
+ | blasLength v /= M.cols m = error "Numeric.BLAS.Mutable.crossVV: dimensions don't match"
+ | blasLength u /= M.rows m = error "Numeric.BLAS.Mutable.crossVV: dimensions don't match"
| otherwise = unsafeCrossVV a v u m
@@ -187,8 +187,8 @@ crossHVV
=> a -> v (PrimState m) a -> v (PrimState m) a -> MD.MMatrix (PrimState m) a -> m ()
{-# INLINE crossHVV #-}
crossHVV a v u m
- | blasLength v /= M.cols m = error "!"
- | blasLength u /= M.rows m = error "!"
+ | blasLength v /= M.cols m = error "Numeric.BLAS.Mutable.crossHVV: dimension sized don't match"
+ | blasLength u /= M.rows m = error "Numeric.BLAS.Mutable.crossHVV: dimension sized don't match"
| otherwise = unsafeCrossVV a v u m
@@ -212,9 +212,9 @@ multMM :: (PrimMonad m, BLAS3 a)
-> m ()
{-# INLINE multMM #-}
multMM a ta ma tb mb b mc
- | rowA /= rowC = error "MM 1"
- | colB /= colC = error "MM 2"
- | colA /= rowB = error "MM 3"
+ | rowA /= rowC = error "Numeric.BLAS.Mutable.multMM: dimensions of matrices don't match"
+ | colB /= colC = error "Numeric.BLAS.Mutable.multMM: dimensions of matrices don't match"
+ | colA /= rowB = error "Numeric.BLAS.Mutable.multMM: dimensions of matrices don't match"
| otherwise = unsafeMultMM a ta ma tb mb b mc
where
rowA = rowsT ta ma ; colA = colsT ta ma
@@ -237,9 +237,9 @@ multSymMM :: (PrimMonad m, BLAS3 a)
-> m ()
{-# INLINE multSymMM #-}
multSymMM side α ma mb β mc
- | M.rows ma /= M.rows mc = error "!"
- | M.cols ma /= M.cols mc = error "!"
- | not okB = error "!"
+ | M.rows ma /= M.rows mc = error "Numeric.BLAS.Mutable.multSymMM: dimensions of matrices don't match"
+ | M.cols ma /= M.cols mc = error "Numeric.BLAS.Mutable.multSymMM: dimensions of matrices don't match"
+ | not okB = error "Numeric.BLAS.Mutable.multSymMM: dimensions of matrices don't match"
| otherwise = unsafeMultSymMM side α ma mb β mc
where
ordB = M.cols mb
@@ -262,9 +262,9 @@ multHerMM :: (PrimMonad m, BLAS3 a, Conjugate a)
-> m ()
{-# INLINE multHerMM #-}
multHerMM side α ma mb β mc
- | M.rows ma /= M.rows mc = error "!"
- | M.cols ma /= M.cols mc = error "!"
- | not okB = error "!"
+ | M.rows ma /= M.rows mc = error "Numeric.BLAS.Mutable.multSymMM: dimensions of matrices don't match"
+ | M.cols ma /= M.cols mc = error "Numeric.BLAS.Mutable.multSymMM: dimensions of matrices don't match"
+ | not okB = error "Numeric.BLAS.Mutable.multSymMM: dimensions of matrices don't match"
| otherwise = unsafeMultHerMM side α ma mb β mc
where
ordB = M.cols mb

0 comments on commit 06773d4

Please sign in to comment.