summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Data/Packed.hs2
-rw-r--r--lib/Data/Packed/Random.hs11
-rw-r--r--lib/Numeric/LinearAlgebra.hs4
-rw-r--r--lib/Numeric/LinearAlgebra/Interface.hs1
4 files changed, 7 insertions, 11 deletions
diff --git a/lib/Data/Packed.hs b/lib/Data/Packed.hs
index 87695ee..50a5eb6 100644
--- a/lib/Data/Packed.hs
+++ b/lib/Data/Packed.hs
@@ -24,4 +24,4 @@ import Data.Packed.Vector
24import Data.Packed.Matrix 24import Data.Packed.Matrix
25import Data.Packed.Random 25import Data.Packed.Random
26import Data.Complex 26import Data.Complex
27 27import Numeric.LinearAlgebra.Instances()
diff --git a/lib/Data/Packed/Random.hs b/lib/Data/Packed/Random.hs
index 3b02225..33a11d7 100644
--- a/lib/Data/Packed/Random.hs
+++ b/lib/Data/Packed/Random.hs
@@ -23,7 +23,6 @@ import Numeric.GSL.Vector
23import Data.Packed.Matrix 23import Data.Packed.Matrix
24import Data.Packed.Vector 24import Data.Packed.Vector
25import Numeric.LinearAlgebra.Algorithms 25import Numeric.LinearAlgebra.Algorithms
26import Numeric.LinearAlgebra.Interface
27import Numeric.LinearAlgebra.Linear 26import Numeric.LinearAlgebra.Linear
28 27
29-- | Obtains a matrix whose rows are pseudorandom samples from a multivariate 28-- | Obtains a matrix whose rows are pseudorandom samples from a multivariate
@@ -37,7 +36,7 @@ gaussianSample seed n med cov = m where
37 c = dim med 36 c = dim med
38 meds = constant 1 n `outer` med 37 meds = constant 1 n `outer` med
39 rs = reshape c $ randomVector seed Gaussian (c * n) 38 rs = reshape c $ randomVector seed Gaussian (c * n)
40 m = rs <> cholSH cov + meds 39 m = rs `mXm` cholSH cov `add` meds
41 40
42-- | Obtains a matrix whose rows are pseudorandom samples from a multivariate 41-- | Obtains a matrix whose rows are pseudorandom samples from a multivariate
43-- uniform distribution. 42-- uniform distribution.
@@ -52,7 +51,7 @@ uniformSample seed n rgs = m where
52 d = dim a 51 d = dim a
53 dat = toRows $ reshape n $ randomVector seed Uniform (n*d) 52 dat = toRows $ reshape n $ randomVector seed Uniform (n*d)
54 am = constant 1 n `outer` a 53 am = constant 1 n `outer` a
55 m = fromColumns (zipWith scale cs dat) + am 54 m = fromColumns (zipWith scale cs dat) `add` am
56 55
57------------ utilities ------------------------------- 56------------ utilities -------------------------------
58 57
@@ -61,7 +60,7 @@ meanCov :: Matrix Double -> (Vector Double, Matrix Double)
61meanCov x = (med,cov) where 60meanCov x = (med,cov) where
62 r = rows x 61 r = rows x
63 k = 1 / fromIntegral r 62 k = 1 / fromIntegral r
64 med = constant k r <> x 63 med = constant k r `vXm` x
65 meds = constant 1 r `outer` med 64 meds = constant 1 r `outer` med
66 xc = x - meds 65 xc = x `sub` meds
67 cov = (trans xc <> xc) / fromIntegral (r-1) 66 cov = flip scale (trans xc `mXm` xc) (recip (fromIntegral (r-1)))
diff --git a/lib/Numeric/LinearAlgebra.hs b/lib/Numeric/LinearAlgebra.hs
index f3a4104..e8a14d6 100644
--- a/lib/Numeric/LinearAlgebra.hs
+++ b/lib/Numeric/LinearAlgebra.hs
@@ -16,12 +16,10 @@ module Numeric.LinearAlgebra (
16 module Data.Packed, 16 module Data.Packed,
17 module Numeric.LinearAlgebra.Algorithms, 17 module Numeric.LinearAlgebra.Algorithms,
18 module Numeric.LinearAlgebra.Interface, 18 module Numeric.LinearAlgebra.Interface,
19 module Numeric.LinearAlgebra.Linear, 19 module Numeric.LinearAlgebra.Linear
20 module Numeric.LinearAlgebra.Instances
21) where 20) where
22 21
23import Data.Packed 22import Data.Packed
24import Numeric.LinearAlgebra.Algorithms 23import Numeric.LinearAlgebra.Algorithms
25import Numeric.LinearAlgebra.Interface 24import Numeric.LinearAlgebra.Interface
26import Numeric.LinearAlgebra.Linear 25import Numeric.LinearAlgebra.Linear
27import Numeric.LinearAlgebra.Instances
diff --git a/lib/Numeric/LinearAlgebra/Interface.hs b/lib/Numeric/LinearAlgebra/Interface.hs
index 6df782f..542d76e 100644
--- a/lib/Numeric/LinearAlgebra/Interface.hs
+++ b/lib/Numeric/LinearAlgebra/Interface.hs
@@ -24,7 +24,6 @@ module Numeric.LinearAlgebra.Interface(
24 (<|>),(<->), 24 (<|>),(<->),
25) where 25) where
26 26
27import Numeric.LinearAlgebra.Instances()
28import Data.Packed.Vector 27import Data.Packed.Vector
29import Data.Packed.Matrix 28import Data.Packed.Matrix
30import Numeric.LinearAlgebra.Algorithms 29import Numeric.LinearAlgebra.Algorithms