summaryrefslogtreecommitdiff
path: root/lib/Data/Packed
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed')
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs10
-rw-r--r--lib/Data/Packed/ST.hs2
2 files changed, 4 insertions, 8 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index 28bebbc..257e4fc 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -180,11 +180,7 @@ toColumns m = toRows . trans $ m
180-- | Reads a matrix position. 180-- | Reads a matrix position.
181(@@>) :: Storable t => Matrix t -> (Int,Int) -> t 181(@@>) :: Storable t => Matrix t -> (Int,Int) -> t
182infixl 9 @@> 182infixl 9 @@>
183--m@M {rows = r, cols = c} @@> (i,j) 183m@Matrix {irows = r, icols = c} @@> (i,j)
184-- | i<0 || i>=r || j<0 || j>=c = error "matrix indexing out of range"
185-- | otherwise = cdat m `at` (i*c+j)
186
187m@Matrix {irows = r, icols = c, xdat = v, order = o} @@> (i,j)
188 | safe = if i<0 || i>=r || j<0 || j>=c 184 | safe = if i<0 || i>=r || j<0 || j>=c
189 then error "matrix indexing out of range" 185 then error "matrix indexing out of range"
190 else atM' m i j 186 else atM' m i j
@@ -205,9 +201,9 @@ matrixFromVector o c v = Matrix { irows = r, icols = c, xdat = v, order = o }
205 201
206-- allocates memory for a new matrix 202-- allocates memory for a new matrix
207createMatrix :: (Storable a) => MatrixOrder -> Int -> Int -> IO (Matrix a) 203createMatrix :: (Storable a) => MatrixOrder -> Int -> Int -> IO (Matrix a)
208createMatrix order r c = do 204createMatrix ord r c = do
209 p <- createVector (r*c) 205 p <- createVector (r*c)
210 return (matrixFromVector order c p) 206 return (matrixFromVector ord c p)
211 207
212{- | Creates a matrix from a vector by grouping the elements in rows with the desired number of columns. (GNU-Octave groups by columns. To do it you can define @reshapeF r = trans . reshape r@ 208{- | Creates a matrix from a vector by grouping the elements in rows with the desired number of columns. (GNU-Octave groups by columns. To do it you can define @reshapeF r = trans . reshape r@
213where r is the desired number of rows.) 209where r is the desired number of rows.)
diff --git a/lib/Data/Packed/ST.hs b/lib/Data/Packed/ST.hs
index c96a209..c1e7aef 100644
--- a/lib/Data/Packed/ST.hs
+++ b/lib/Data/Packed/ST.hs
@@ -171,7 +171,7 @@ writeMatrix :: Storable t => STMatrix s t -> Int -> Int -> t -> ST s ()
171writeMatrix = safeIndexM unsafeWriteMatrix 171writeMatrix = safeIndexM unsafeWriteMatrix
172 172
173newUndefinedMatrix :: Storable t => MatrixOrder -> Int -> Int -> ST s (STMatrix s t) 173newUndefinedMatrix :: Storable t => MatrixOrder -> Int -> Int -> ST s (STMatrix s t)
174newUndefinedMatrix order r c = unsafeIOToST $ fmap STMatrix $ createMatrix order r c 174newUndefinedMatrix ord r c = unsafeIOToST $ fmap STMatrix $ createMatrix ord r c
175 175
176{-# NOINLINE newMatrix #-} 176{-# NOINLINE newMatrix #-}
177newMatrix :: Storable t => t -> Int -> Int -> ST s (STMatrix s t) 177newMatrix :: Storable t => t -> Int -> Int -> ST s (STMatrix s t)