summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Internal/Matrix.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs21
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)
47import Foreign.C.Types 47import Foreign.C.Types
48import Foreign.C.String(newCString) 48import Foreign.C.String(newCString)
49import System.IO.Unsafe(unsafePerformIO) 49import System.IO.Unsafe(unsafePerformIO)
50import 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]@
1389 |> [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]@
139-}
140flatten :: Element t => Matrix t -> Vector t 139flatten :: Element t => Matrix t -> Vector t
141flatten = xdat . cmat 140flatten = xdat . cmat
142 141
@@ -459,3 +458,13 @@ size m = (rows m, cols m)
459 458
460shSize m = "(" ++ show (rows m) ++"><"++ show (cols m)++")" 459shSize m = "(" ++ show (rows m) ++"><"++ show (cols m)++")"
461 460
461----------------------------------------------------------------------
462
463instance (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