diff options
Diffstat (limited to 'packages/hmatrix/src/Numeric/GSL/LinearAlgebra.hs')
-rw-r--r-- | packages/hmatrix/src/Numeric/GSL/LinearAlgebra.hs | 61 |
1 files changed, 4 insertions, 57 deletions
diff --git a/packages/hmatrix/src/Numeric/GSL/LinearAlgebra.hs b/packages/hmatrix/src/Numeric/GSL/LinearAlgebra.hs index 43e46c5..8bd0cc2 100644 --- a/packages/hmatrix/src/Numeric/GSL/LinearAlgebra.hs +++ b/packages/hmatrix/src/Numeric/GSL/LinearAlgebra.hs | |||
@@ -9,15 +9,15 @@ | |||
9 | ----------------------------------------------------------------------------- | 9 | ----------------------------------------------------------------------------- |
10 | 10 | ||
11 | module Numeric.GSL.LinearAlgebra ( | 11 | module Numeric.GSL.LinearAlgebra ( |
12 | RandDist(..), randomVector, | 12 | randomVector, |
13 | saveMatrix, | 13 | saveMatrix, |
14 | fwriteVector, freadVector, fprintfVector, fscanfVector | 14 | fwriteVector, freadVector, fprintfVector, fscanfVector |
15 | ) where | 15 | ) where |
16 | 16 | ||
17 | import Data.Packed | 17 | import Data.Packed |
18 | import Numeric.LinearAlgebra.Base(RandDist(..)) | ||
18 | import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM) | 19 | import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM) |
19 | 20 | ||
20 | import Data.Complex | ||
21 | import Foreign.Marshal.Alloc(free) | 21 | import Foreign.Marshal.Alloc(free) |
22 | import Foreign.Ptr(Ptr) | 22 | import Foreign.Ptr(Ptr) |
23 | import Foreign.C.Types | 23 | import Foreign.C.Types |
@@ -28,10 +28,6 @@ fromei x = fromIntegral (fromEnum x) :: CInt | |||
28 | 28 | ||
29 | ----------------------------------------------------------------------- | 29 | ----------------------------------------------------------------------- |
30 | 30 | ||
31 | data RandDist = Uniform -- ^ uniform distribution in [0,1) | ||
32 | | Gaussian -- ^ normal distribution with mean zero and standard deviation one | ||
33 | deriving Enum | ||
34 | |||
35 | -- | Obtains a vector of pseudorandom elements from the the mt19937 generator in GSL, with a given seed. Use randomIO to get a random seed. | 31 | -- | Obtains a vector of pseudorandom elements from the the mt19937 generator in GSL, with a given seed. Use randomIO to get a random seed. |
36 | randomVector :: Int -- ^ seed | 32 | randomVector :: Int -- ^ seed |
37 | -> RandDist -- ^ distribution | 33 | -> RandDist -- ^ distribution |
@@ -39,10 +35,10 @@ randomVector :: Int -- ^ seed | |||
39 | -> Vector Double | 35 | -> Vector Double |
40 | randomVector seed dist n = unsafePerformIO $ do | 36 | randomVector seed dist n = unsafePerformIO $ do |
41 | r <- createVector n | 37 | r <- createVector n |
42 | app1 (c_random_vector (fi seed) ((fi.fromEnum) dist)) vec r "randomVector" | 38 | app1 (c_random_vector_GSL (fi seed) ((fi.fromEnum) dist)) vec r "randomVectorGSL" |
43 | return r | 39 | return r |
44 | 40 | ||
45 | foreign import ccall unsafe "random_vector" c_random_vector :: CInt -> CInt -> TV | 41 | foreign import ccall unsafe "random_vector_GSL" c_random_vector_GSL :: CInt -> CInt -> TV |
46 | 42 | ||
47 | -------------------------------------------------------------------------------- | 43 | -------------------------------------------------------------------------------- |
48 | 44 | ||
@@ -105,56 +101,7 @@ fwriteVector filename v = do | |||
105 | 101 | ||
106 | foreign import ccall unsafe "vector_fwrite" gsl_vector_fwrite :: Ptr CChar -> TV | 102 | foreign import ccall unsafe "vector_fwrite" gsl_vector_fwrite :: Ptr CChar -> TV |
107 | 103 | ||
108 | type PF = Ptr Float -- | ||
109 | type PD = Ptr Double -- | 104 | type PD = Ptr Double -- |
110 | type PQ = Ptr (Complex Float) -- | ||
111 | type PC = Ptr (Complex Double) -- | ||
112 | type TF = CInt -> PF -> IO CInt -- | ||
113 | type TFF = CInt -> PF -> TF -- | ||
114 | type TFV = CInt -> PF -> TV -- | ||
115 | type TVF = CInt -> PD -> TF -- | ||
116 | type TFFF = CInt -> PF -> TFF -- | ||
117 | type TV = CInt -> PD -> IO CInt -- | 105 | type TV = CInt -> PD -> IO CInt -- |
118 | type TVV = CInt -> PD -> TV -- | ||
119 | type TVVV = CInt -> PD -> TVV -- | ||
120 | type TFM = CInt -> CInt -> PF -> IO CInt -- | ||
121 | type TFMFM = CInt -> CInt -> PF -> TFM -- | ||
122 | type TFMFMFM = CInt -> CInt -> PF -> TFMFM -- | ||
123 | type TM = CInt -> CInt -> PD -> IO CInt -- | 106 | type TM = CInt -> CInt -> PD -> IO CInt -- |
124 | type TMM = CInt -> CInt -> PD -> TM -- | ||
125 | type TVMM = CInt -> PD -> TMM -- | ||
126 | type TMVMM = CInt -> CInt -> PD -> TVMM -- | ||
127 | type TMMM = CInt -> CInt -> PD -> TMM -- | ||
128 | type TVM = CInt -> PD -> TM -- | ||
129 | type TVVM = CInt -> PD -> TVM -- | ||
130 | type TMV = CInt -> CInt -> PD -> TV -- | ||
131 | type TMMV = CInt -> CInt -> PD -> TMV -- | ||
132 | type TMVM = CInt -> CInt -> PD -> TVM -- | ||
133 | type TMMVM = CInt -> CInt -> PD -> TMVM -- | ||
134 | type TCM = CInt -> CInt -> PC -> IO CInt -- | ||
135 | type TCVCM = CInt -> PC -> TCM -- | ||
136 | type TCMCVCM = CInt -> CInt -> PC -> TCVCM -- | ||
137 | type TMCMCVCM = CInt -> CInt -> PD -> TCMCVCM -- | ||
138 | type TCMCMCVCM = CInt -> CInt -> PC -> TCMCVCM -- | ||
139 | type TCMCM = CInt -> CInt -> PC -> TCM -- | ||
140 | type TVCM = CInt -> PD -> TCM -- | ||
141 | type TCMVCM = CInt -> CInt -> PC -> TVCM -- | ||
142 | type TCMCMVCM = CInt -> CInt -> PC -> TCMVCM -- | ||
143 | type TCMCMCM = CInt -> CInt -> PC -> TCMCM -- | ||
144 | type TCV = CInt -> PC -> IO CInt -- | ||
145 | type TCVCV = CInt -> PC -> TCV -- | ||
146 | type TCVCVCV = CInt -> PC -> TCVCV -- | ||
147 | type TCVV = CInt -> PC -> TV -- | ||
148 | type TQV = CInt -> PQ -> IO CInt -- | ||
149 | type TQVQV = CInt -> PQ -> TQV -- | ||
150 | type TQVQVQV = CInt -> PQ -> TQVQV -- | ||
151 | type TQVF = CInt -> PQ -> TF -- | ||
152 | type TQM = CInt -> CInt -> PQ -> IO CInt -- | ||
153 | type TQMQM = CInt -> CInt -> PQ -> TQM -- | ||
154 | type TQMQMQM = CInt -> CInt -> PQ -> TQMQM -- | ||
155 | type TCMCV = CInt -> CInt -> PC -> TCV -- | ||
156 | type TVCV = CInt -> PD -> TCV -- | ||
157 | type TCVM = CInt -> PC -> TM -- | ||
158 | type TMCVM = CInt -> CInt -> PD -> TCVM -- | ||
159 | type TMMCVM = CInt -> CInt -> PD -> TMCVM -- | ||
160 | 107 | ||