diff options
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index b8ed18d..255009c 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -47,6 +47,7 @@ import Data.Complex(Complex) | |||
47 | import Foreign.C.Types | 47 | import Foreign.C.Types |
48 | import Foreign.C.String(newCString) | 48 | import Foreign.C.String(newCString) |
49 | import System.IO.Unsafe(unsafePerformIO) | 49 | import System.IO.Unsafe(unsafePerformIO) |
50 | import Control.DeepSeq | ||
50 | 51 | ||
51 | ----------------------------------------------------------------- | 52 | ----------------------------------------------------------------- |
52 | 53 | ||
@@ -131,12 +132,10 @@ mat a f = | |||
131 | let m g = do | 132 | let m g = do |
132 | g (fi (rows a)) (fi (cols a)) p | 133 | g (fi (rows a)) (fi (cols a)) p |
133 | f m | 134 | f m |
134 | 135 | -- | Creates a vector by concatenation of rows. If the matrix is ColumnMajor, this operation requires a transpose. | |
135 | {- | Creates a vector by concatenation of rows | 136 | -- |
136 | 137 | -- @\> flatten ('ident' 3) | |
137 | @\> flatten ('ident' 3) | 138 | -- 9 |> [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]@ |
138 | 9 |> [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]@ | ||
139 | -} | ||
140 | flatten :: Element t => Matrix t -> Vector t | 139 | flatten :: Element t => Matrix t -> Vector t |
141 | flatten = xdat . cmat | 140 | flatten = xdat . cmat |
142 | 141 | ||
@@ -459,3 +458,13 @@ size m = (rows m, cols m) | |||
459 | 458 | ||
460 | shSize m = "(" ++ show (rows m) ++"><"++ show (cols m)++")" | 459 | shSize m = "(" ++ show (rows m) ++"><"++ show (cols m)++")" |
461 | 460 | ||
461 | ---------------------------------------------------------------------- | ||
462 | |||
463 | instance (Storable t, NFData t) => NFData (Matrix t) | ||
464 | where | ||
465 | rnf m | d > 0 = rnf (v @> 0) | ||
466 | | otherwise = () | ||
467 | where | ||
468 | d = dim v | ||
469 | v = xdat m | ||
470 | |||