diff options
-rw-r--r-- | hmatrix.cabal | 11 | ||||
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 16 | ||||
-rw-r--r-- | lib/Data/Packed/Vector.hs | 15 |
3 files changed, 27 insertions, 15 deletions
diff --git a/hmatrix.cabal b/hmatrix.cabal index 0cd4c03..6d29d2e 100644 --- a/hmatrix.cabal +++ b/hmatrix.cabal | |||
@@ -78,13 +78,16 @@ flag vector | |||
78 | description: Use Data.Vector.Storable type from "vector" package. | 78 | description: Use Data.Vector.Storable type from "vector" package. |
79 | default: False | 79 | default: False |
80 | 80 | ||
81 | flag binary | ||
82 | description: Define Binary instances | ||
83 | default: True | ||
84 | |||
81 | library | 85 | library |
82 | 86 | ||
83 | Build-Depends: base >= 4 && < 5, | 87 | Build-Depends: base >= 4 && < 5, |
84 | array, | 88 | array, |
85 | storable-complex, | 89 | storable-complex, |
86 | process, | 90 | process |
87 | binary | ||
88 | 91 | ||
89 | Extensions: ForeignFunctionInterface, | 92 | Extensions: ForeignFunctionInterface, |
90 | CPP | 93 | CPP |
@@ -131,6 +134,10 @@ library | |||
131 | Build-Depends: vector >= 0.7 | 134 | Build-Depends: vector >= 0.7 |
132 | cpp-options: -DVECTOR | 135 | cpp-options: -DVECTOR |
133 | 136 | ||
137 | if flag(binary) | ||
138 | Build-Depends: binary | ||
139 | cpp-options: -DBINARY | ||
140 | |||
134 | if flag(tests) | 141 | if flag(tests) |
135 | Build-Depends: QuickCheck, HUnit, random | 142 | Build-Depends: QuickCheck, HUnit, random |
136 | exposed-modules: Numeric.LinearAlgebra.Tests | 143 | exposed-modules: Numeric.LinearAlgebra.Tests |
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index de2300a..2922cbe 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -2,16 +2,16 @@ | |||
2 | {-# LANGUAGE FlexibleContexts #-} | 2 | {-# LANGUAGE FlexibleContexts #-} |
3 | {-# LANGUAGE FlexibleInstances #-} | 3 | {-# LANGUAGE FlexibleInstances #-} |
4 | {-# LANGUAGE MultiParamTypeClasses #-} | 4 | {-# LANGUAGE MultiParamTypeClasses #-} |
5 | {-# LANGUAGE CPP #-} | ||
5 | 6 | ||
6 | ----------------------------------------------------------------------------- | 7 | ----------------------------------------------------------------------------- |
7 | -- | | 8 | -- | |
8 | -- Module : Data.Packed.Matrix | 9 | -- Module : Data.Packed.Matrix |
9 | -- Copyright : (c) Alberto Ruiz 2007-10 | 10 | -- Copyright : (c) Alberto Ruiz 2007-10 |
10 | -- License : GPL-style | 11 | -- License : GPL |
11 | -- | 12 | -- |
12 | -- Maintainer : Alberto Ruiz <aruiz@um.es> | 13 | -- Maintainer : Alberto Ruiz <aruiz@um.es> |
13 | -- Stability : provisional | 14 | -- Stability : provisional |
14 | -- Portability : portable | ||
15 | -- | 15 | -- |
16 | -- A Matrix representation suitable for numerical computations using LAPACK and GSL. | 16 | -- A Matrix representation suitable for numerical computations using LAPACK and GSL. |
17 | -- | 17 | -- |
@@ -43,16 +43,14 @@ import Data.Packed.Internal | |||
43 | import qualified Data.Packed.ST as ST | 43 | import qualified Data.Packed.ST as ST |
44 | import Data.List(transpose,intersperse) | 44 | import Data.List(transpose,intersperse) |
45 | import Data.Array | 45 | import Data.Array |
46 | import Foreign.Storable | ||
47 | |||
48 | ------------------------------------------------------------------- | ||
46 | 49 | ||
50 | #ifdef BINARY | ||
47 | 51 | ||
48 | import Data.Binary | 52 | import Data.Binary |
49 | import Foreign.Storable | ||
50 | import Control.Monad(replicateM) | 53 | import Control.Monad(replicateM) |
51 | --import Control.Arrow((***)) | ||
52 | --import GHC.Float(double2Float,float2Double) | ||
53 | |||
54 | |||
55 | ------------------------------------------------------------------- | ||
56 | 54 | ||
57 | instance (Binary a, Element a, Storable a) => Binary (Matrix a) where | 55 | instance (Binary a, Element a, Storable a) => Binary (Matrix a) where |
58 | put m = do | 56 | put m = do |
@@ -67,6 +65,8 @@ instance (Binary a, Element a, Storable a) => Binary (Matrix a) where | |||
67 | xs <- replicateM r $ replicateM c get | 65 | xs <- replicateM r $ replicateM c get |
68 | return $ fromLists xs | 66 | return $ fromLists xs |
69 | 67 | ||
68 | #endif | ||
69 | |||
70 | ------------------------------------------------------------------- | 70 | ------------------------------------------------------------------- |
71 | 71 | ||
72 | instance (Show a, Element a) => (Show (Matrix a)) where | 72 | instance (Show a, Element a) => (Show (Matrix a)) where |
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs index 8b1e813..f90f8e4 100644 --- a/lib/Data/Packed/Vector.hs +++ b/lib/Data/Packed/Vector.hs | |||
@@ -1,13 +1,13 @@ | |||
1 | {-# LANGUAGE FlexibleContexts #-} | 1 | {-# LANGUAGE FlexibleContexts #-} |
2 | {-# LANGUAGE CPP #-} | ||
2 | ----------------------------------------------------------------------------- | 3 | ----------------------------------------------------------------------------- |
3 | -- | | 4 | -- | |
4 | -- Module : Data.Packed.Vector | 5 | -- Module : Data.Packed.Vector |
5 | -- Copyright : (c) Alberto Ruiz 2007 | 6 | -- Copyright : (c) Alberto Ruiz 2007-10 |
6 | -- License : GPL-style | 7 | -- License : GPL |
7 | -- | 8 | -- |
8 | -- Maintainer : Alberto Ruiz <aruiz@um.es> | 9 | -- Maintainer : Alberto Ruiz <aruiz@um.es> |
9 | -- Stability : provisional | 10 | -- Stability : provisional |
10 | -- Portability : portable | ||
11 | -- | 11 | -- |
12 | -- 1D arrays suitable for numeric computations using external libraries. | 12 | -- 1D arrays suitable for numeric computations using external libraries. |
13 | -- | 13 | -- |
@@ -26,12 +26,15 @@ module Data.Packed.Vector ( | |||
26 | ) where | 26 | ) where |
27 | 27 | ||
28 | import Data.Packed.Internal.Vector | 28 | import Data.Packed.Internal.Vector |
29 | import Data.Binary | ||
30 | import Foreign.Storable | 29 | import Foreign.Storable |
31 | import Control.Monad(replicateM) | ||
32 | 30 | ||
33 | ------------------------------------------------------------------- | 31 | ------------------------------------------------------------------- |
34 | 32 | ||
33 | #ifdef BINARY | ||
34 | |||
35 | import Data.Binary | ||
36 | import Control.Monad(replicateM) | ||
37 | |||
35 | -- a 64K cache, with a Double taking 13 bytes in Bytestring, | 38 | -- a 64K cache, with a Double taking 13 bytes in Bytestring, |
36 | -- implies a chunk size of 5041 | 39 | -- implies a chunk size of 5041 |
37 | chunk :: Int | 40 | chunk :: Int |
@@ -60,6 +63,8 @@ instance (Binary a, Storable a) => Binary (Vector a) where | |||
60 | vs <- mapM getVector $ chunks d | 63 | vs <- mapM getVector $ chunks d |
61 | return $! join vs | 64 | return $! join vs |
62 | 65 | ||
66 | #endif | ||
67 | |||
63 | ------------------------------------------------------------------- | 68 | ------------------------------------------------------------------- |
64 | 69 | ||
65 | {- | creates a Vector of the specified length using the supplied function to | 70 | {- | creates a Vector of the specified length using the supplied function to |