diff options
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 10 |
1 files changed, 3 insertions, 7 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 |
182 | infixl 9 @@> | 182 | infixl 9 @@> |
183 | --m@M {rows = r, cols = c} @@> (i,j) | 183 | m@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 | |||
187 | m@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 |
207 | createMatrix :: (Storable a) => MatrixOrder -> Int -> Int -> IO (Matrix a) | 203 | createMatrix :: (Storable a) => MatrixOrder -> Int -> Int -> IO (Matrix a) |
208 | createMatrix order r c = do | 204 | createMatrix 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@ |
213 | where r is the desired number of rows.) | 209 | where r is the desired number of rows.) |