diff options
Diffstat (limited to 'packages/base/src/Internal/Container.hs')
-rw-r--r-- | packages/base/src/Internal/Container.hs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/packages/base/src/Internal/Container.hs b/packages/base/src/Internal/Container.hs index 282163e..a498069 100644 --- a/packages/base/src/Internal/Container.hs +++ b/packages/base/src/Internal/Container.hs | |||
@@ -40,10 +40,12 @@ import Prelude hiding ((<>)) | |||
40 | {- | Creates a real vector containing a range of values: | 40 | {- | Creates a real vector containing a range of values: |
41 | 41 | ||
42 | >>> linspace 5 (-3,7::Double) | 42 | >>> linspace 5 (-3,7::Double) |
43 | fromList [-3.0,-0.5,2.0,4.5,7.0]@ | 43 | [-3.0,-0.5,2.0,4.5,7.0] |
44 | it :: Vector Double | ||
44 | 45 | ||
45 | >>> linspace 5 (8,2+i) :: Vector (Complex Double) | 46 | >>> linspace 5 (8,2:+1) :: Vector (Complex Double) |
46 | fromList [8.0 :+ 0.0,6.5 :+ 0.25,5.0 :+ 0.5,3.5 :+ 0.75,2.0 :+ 1.0] | 47 | [8.0 :+ 0.0,6.5 :+ 0.25,5.0 :+ 0.5,3.5 :+ 0.75,2.0 :+ 1.0] |
48 | it :: Vector (Complex Double) | ||
47 | 49 | ||
48 | Logarithmic spacing can be defined as follows: | 50 | Logarithmic spacing can be defined as follows: |
49 | 51 | ||
@@ -87,7 +89,8 @@ infixr 8 <.> | |||
87 | >>> let v = vector [10,20,30] | 89 | >>> let v = vector [10,20,30] |
88 | 90 | ||
89 | >>> m #> v | 91 | >>> m #> v |
90 | fromList [140.0,320.0] | 92 | [140.0,320.0] |
93 | it :: Vector Numeric.LinearAlgebra.Data.R | ||
91 | 94 | ||
92 | -} | 95 | -} |
93 | infixr 8 #> | 96 | infixr 8 #> |
@@ -136,10 +139,12 @@ v = vector [13.0,27.0,1.0] | |||
136 | 139 | ||
137 | >>> let x = a <\> v | 140 | >>> let x = a <\> v |
138 | >>> x | 141 | >>> x |
139 | fromList [3.0799999999999996,5.159999999999999] | 142 | [3.0799999999999996,5.159999999999999] |
143 | it :: Vector Numeric.LinearAlgebra.Data.R | ||
140 | 144 | ||
141 | >>> a #> x | 145 | >>> a #> x |
142 | fromList [13.399999999999999,26.799999999999997,1.0] | 146 | [13.399999999999999,26.799999999999997,0.9999999999999991] |
147 | it :: Vector Numeric.LinearAlgebra.Data.R | ||
143 | 148 | ||
144 | It also admits multiple right-hand sides stored as columns in a matrix. | 149 | It also admits multiple right-hand sides stored as columns in a matrix. |
145 | 150 | ||
@@ -167,7 +172,8 @@ class Build d f c e | d -> c, c -> d, f -> e, f -> d, f -> c, c e -> f, d e -> f | |||
167 | where | 172 | where |
168 | -- | | 173 | -- | |
169 | -- >>> build 5 (**2) :: Vector Double | 174 | -- >>> build 5 (**2) :: Vector Double |
170 | -- fromList [0.0,1.0,4.0,9.0,16.0] | 175 | -- [0.0,1.0,4.0,9.0,16.0] |
176 | -- it :: Vector Double | ||
171 | -- | 177 | -- |
172 | -- Hilbert matrix of order N: | 178 | -- Hilbert matrix of order N: |
173 | -- | 179 | -- |
@@ -204,12 +210,11 @@ optimiseMult = mconcat | |||
204 | 210 | ||
205 | {- | Compute mean vector and covariance matrix of the rows of a matrix. | 211 | {- | Compute mean vector and covariance matrix of the rows of a matrix. |
206 | 212 | ||
207 | >>> meanCov $ gaussianSample 666 1000 (fromList[4,5]) (diagl[2,3]) | 213 | >>> meanCov $ gaussianSample 666 1000 (fromList[4,5]) (trustSym $ diagl [2,3]) |
208 | (fromList [4.010341078059521,5.0197204699640405], | 214 | ([3.9933155655086696,5.061409102770331],Herm (2><2) |
209 | (2><2) | 215 | [ 1.9963242906624408, -4.227815571404954e-2 |
210 | [ 1.9862461923890056, -1.0127225830525157e-2 | 216 | , -4.227815571404954e-2, 3.2003833097832857 ]) |
211 | , -1.0127225830525157e-2, 3.0373954915729318 ]) | 217 | it :: (Vector Double, Herm Double) |
212 | |||
213 | -} | 218 | -} |
214 | meanCov :: Matrix Double -> (Vector Double, Herm Double) | 219 | meanCov :: Matrix Double -> (Vector Double, Herm Double) |
215 | meanCov x = (med,cov) where | 220 | meanCov x = (med,cov) where |