summaryrefslogtreecommitdiff
path: root/lib/Data
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data')
-rw-r--r--lib/Data/Packed.hs4
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs26
-rw-r--r--lib/Data/Packed/Matrix.hs7
-rw-r--r--lib/Data/Packed/Vector.hs2
4 files changed, 23 insertions, 16 deletions
diff --git a/lib/Data/Packed.hs b/lib/Data/Packed.hs
index bfc2d8b..b8bec8a 100644
--- a/lib/Data/Packed.hs
+++ b/lib/Data/Packed.hs
@@ -1,14 +1,14 @@
1----------------------------------------------------------------------------- 1-----------------------------------------------------------------------------
2{- | 2{- |
3Module : Data.Packed 3Module : Data.Packed
4Copyright : (c) Alberto Ruiz 2006-7 4Copyright : (c) Alberto Ruiz 2006-2010
5License : GPL-style 5License : GPL-style
6 6
7Maintainer : Alberto Ruiz (aruiz at um dot es) 7Maintainer : Alberto Ruiz (aruiz at um dot es)
8Stability : provisional 8Stability : provisional
9Portability : uses ffi 9Portability : uses ffi
10 10
11The Vector and Matrix types and some utilities. 11Types for dense 'Vector' and 'Matrix' of 'Storable' elements.
12 12
13-} 13-}
14----------------------------------------------------------------------------- 14-----------------------------------------------------------------------------
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index 7b823de..b616442 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -75,7 +75,11 @@ import Foreign.C.String
75 75
76data MatrixOrder = RowMajor | ColumnMajor deriving (Show,Eq) 76data MatrixOrder = RowMajor | ColumnMajor deriving (Show,Eq)
77 77
78-- | Matrix representation suitable for GSL and LAPACK computations. 78{- | Matrix representation suitable for GSL and LAPACK computations.
79
80The elements are stored in a continuous memory array.
81
82-}
79data Matrix t = MC { irows :: {-# UNPACK #-} !Int 83data Matrix t = MC { irows :: {-# UNPACK #-} !Int
80 , icols :: {-# UNPACK #-} !Int 84 , icols :: {-# UNPACK #-} !Int
81 , cdat :: {-# UNPACK #-} !(Vector t) } 85 , cdat :: {-# UNPACK #-} !(Vector t) }
@@ -245,9 +249,14 @@ compat m1 m2 = rows m1 == rows m2 && cols m1 == cols m2
245 249
246------------------------------------------------------------------ 250------------------------------------------------------------------
247 251
248-- | Supported element types for basic matrix operations. 252{- | Supported matrix elements.
249-- provides unoptimised defaults for all (Storable a) instances 253
250-- @instance Element Foo where@ 254 This class provides optimized internal
255 operations for selected element types.
256 It provides unoptimised defaults for any 'Storable' type,
257 so you can create instances simply as:
258 @instance Element Foo@.
259-}
251class (Storable a) => Element a where 260class (Storable a) => Element a where
252 subMatrixD :: (Int,Int) -- ^ (r0,c0) starting position 261 subMatrixD :: (Int,Int) -- ^ (r0,c0) starting position
253 -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix 262 -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix
@@ -257,30 +266,23 @@ class (Storable a) => Element a where
257 transdata = transdataP -- transdata' 266 transdata = transdataP -- transdata'
258 constantD :: a -> Int -> Vector a 267 constantD :: a -> Int -> Vector a
259 constantD = constantP -- constant' 268 constantD = constantP -- constant'
260{- 269
261 conjugateD :: Vector a -> Vector a
262 conjugateD = id
263-}
264 270
265instance Element Float where 271instance Element Float where
266 transdata = transdataAux ctransF 272 transdata = transdataAux ctransF
267 constantD = constantAux cconstantF 273 constantD = constantAux cconstantF
268-- conjugateD = id
269 274
270instance Element Double where 275instance Element Double where
271 transdata = transdataAux ctransR 276 transdata = transdataAux ctransR
272 constantD = constantAux cconstantR 277 constantD = constantAux cconstantR
273-- conjugateD = id
274 278
275instance Element (Complex Float) where 279instance Element (Complex Float) where
276 transdata = transdataAux ctransQ 280 transdata = transdataAux ctransQ
277 constantD = constantAux cconstantQ 281 constantD = constantAux cconstantQ
278-- conjugateD = conjugateQ
279 282
280instance Element (Complex Double) where 283instance Element (Complex Double) where
281 transdata = transdataAux ctransC 284 transdata = transdataAux ctransC
282 constantD = constantAux cconstantC 285 constantD = constantAux cconstantC
283-- conjugateD = conjugateC
284 286
285------------------------------------------------------------------- 287-------------------------------------------------------------------
286 288
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs
index 1fa8903..50a321d 100644
--- a/lib/Data/Packed/Matrix.hs
+++ b/lib/Data/Packed/Matrix.hs
@@ -7,7 +7,7 @@
7----------------------------------------------------------------------------- 7-----------------------------------------------------------------------------
8-- | 8-- |
9-- Module : Data.Packed.Matrix 9-- Module : Data.Packed.Matrix
10-- Copyright : (c) Alberto Ruiz 2007 10-- Copyright : (c) Alberto Ruiz 2007-10
11-- License : GPL-style 11-- License : GPL-style
12-- 12--
13-- Maintainer : Alberto Ruiz <aruiz@um.es> 13-- Maintainer : Alberto Ruiz <aruiz@um.es>
@@ -16,11 +16,14 @@
16-- 16--
17-- A Matrix representation suitable for numerical computations using LAPACK and GSL. 17-- A Matrix representation suitable for numerical computations using LAPACK and GSL.
18-- 18--
19-- This module provides basic functions for manipulation of structure.
20
19----------------------------------------------------------------------------- 21-----------------------------------------------------------------------------
20 22
21module Data.Packed.Matrix ( 23module Data.Packed.Matrix (
24 Matrix,
22 Element, 25 Element,
23 Matrix,rows,cols, 26 rows,cols,
24 (><), 27 (><),
25 trans, 28 trans,
26 reshape, flatten, 29 reshape, flatten,
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs
index 2e0a9f5..eaf4b9c 100644
--- a/lib/Data/Packed/Vector.hs
+++ b/lib/Data/Packed/Vector.hs
@@ -11,6 +11,8 @@
11-- 11--
12-- 1D arrays suitable for numeric computations using external libraries. 12-- 1D arrays suitable for numeric computations using external libraries.
13-- 13--
14-- This module provides basic functions for manipulation of structure.
15--
14----------------------------------------------------------------------------- 16-----------------------------------------------------------------------------
15 17
16module Data.Packed.Vector ( 18module Data.Packed.Vector (