~ubuntu-branches/ubuntu/vivid/haskell-hmatrix/vivid

« back to all changes in this revision

Viewing changes to lib/Data/Packed/Internal/Matrix.hs

  • Committer: Package Import Robot
  • Author(s): Denis Laxalde
  • Date: 2013-07-06 15:37:50 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130706153750-wxxplc788jedqvv5
Tags: 0.15.0.0-1
* New upstream release.
* Make it clear in copyright that the license is GPL-3 (as stated by the
  author in <https://github.com/albertoruiz/hmatrix/issues/45>) although
  there is no proper license file yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
import Foreign.C.Types
48
48
import Foreign.C.String(newCString)
49
49
import System.IO.Unsafe(unsafePerformIO)
 
50
import Control.DeepSeq
50
51
 
51
52
-----------------------------------------------------------------
52
53
 
131
132
        let m g = do
132
133
            g (fi (rows a)) (fi (cols a)) p
133
134
        f m
134
 
 
135
 
{- | Creates a vector by concatenation of rows
136
 
 
137
 
@\> flatten ('ident' 3)
138
 
9 |> [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]@
139
 
-}
 
135
-- | Creates a vector by concatenation of rows. If the matrix is ColumnMajor, this operation requires a transpose.
 
136
--
 
137
-- @\> flatten ('ident' 3)
 
138
-- 9 |> [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]@
140
139
flatten :: Element t => Matrix t -> Vector t
141
140
flatten = xdat . cmat
142
141
 
459
458
 
460
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