diff options
author | Peter Dobsan <pdobsan@gmail.com> | 2018-04-27 00:09:35 +0200 |
---|---|---|
committer | Peter Dobsan <pdobsan@gmail.com> | 2018-04-27 00:09:35 +0200 |
commit | 1286ae831088236213ea0ea94b0b288a2e0ce4bb (patch) | |
tree | 1e7117c4929a93af00e37ec7650c24613038492b /packages/base/src/Internal/Container.hs | |
parent | dd96a98207dbafbf81b4a5f02613963cf5bd4b4c (diff) | |
parent | 3ffea9114b573eb11e2e41ddfc6a8b69fdd6baed (diff) |
Merge branch 'fix-vector-show-instance'
The show instance was changed in vector 0.11. The merged modifications
adjust hmatrix/base to that change. That fixes issues #277 and #177.
Diffstat (limited to 'packages/base/src/Internal/Container.hs')
-rw-r--r-- | packages/base/src/Internal/Container.hs | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/packages/base/src/Internal/Container.hs b/packages/base/src/Internal/Container.hs index 282163e..46e9cf3 100644 --- a/packages/base/src/Internal/Container.hs +++ b/packages/base/src/Internal/Container.hs | |||
@@ -40,9 +40,14 @@ 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+i) :: Vector (Complex Double) |
47 | |||
48 | <interactive>:6:17: ERROR: | ||
49 | Variable not in scope: i :: Complex Double | ||
50 | |||
46 | fromList [8.0 :+ 0.0,6.5 :+ 0.25,5.0 :+ 0.5,3.5 :+ 0.75,2.0 :+ 1.0] | 51 | fromList [8.0 :+ 0.0,6.5 :+ 0.25,5.0 :+ 0.5,3.5 :+ 0.75,2.0 :+ 1.0] |
47 | 52 | ||
48 | Logarithmic spacing can be defined as follows: | 53 | Logarithmic spacing can be defined as follows: |
@@ -87,7 +92,8 @@ infixr 8 <.> | |||
87 | >>> let v = vector [10,20,30] | 92 | >>> let v = vector [10,20,30] |
88 | 93 | ||
89 | >>> m #> v | 94 | >>> m #> v |
90 | fromList [140.0,320.0] | 95 | [140.0,320.0] |
96 | it :: Vector Numeric.LinearAlgebra.Data.R | ||
91 | 97 | ||
92 | -} | 98 | -} |
93 | infixr 8 #> | 99 | infixr 8 #> |
@@ -136,10 +142,12 @@ v = vector [13.0,27.0,1.0] | |||
136 | 142 | ||
137 | >>> let x = a <\> v | 143 | >>> let x = a <\> v |
138 | >>> x | 144 | >>> x |
139 | fromList [3.0799999999999996,5.159999999999999] | 145 | [3.0799999999999996,5.159999999999999] |
146 | it :: Vector Numeric.LinearAlgebra.Data.R | ||
140 | 147 | ||
141 | >>> a #> x | 148 | >>> a #> x |
142 | fromList [13.399999999999999,26.799999999999997,1.0] | 149 | [13.399999999999999,26.799999999999997,0.9999999999999991] |
150 | it :: Vector Numeric.LinearAlgebra.Data.R | ||
143 | 151 | ||
144 | It also admits multiple right-hand sides stored as columns in a matrix. | 152 | It also admits multiple right-hand sides stored as columns in a matrix. |
145 | 153 | ||
@@ -167,7 +175,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 | 175 | where |
168 | -- | | 176 | -- | |
169 | -- >>> build 5 (**2) :: Vector Double | 177 | -- >>> build 5 (**2) :: Vector Double |
170 | -- fromList [0.0,1.0,4.0,9.0,16.0] | 178 | -- [0.0,1.0,4.0,9.0,16.0] |
179 | -- it :: Vector Double | ||
171 | -- | 180 | -- |
172 | -- Hilbert matrix of order N: | 181 | -- Hilbert matrix of order N: |
173 | -- | 182 | -- |
@@ -205,6 +214,17 @@ optimiseMult = mconcat | |||
205 | {- | Compute mean vector and covariance matrix of the rows of a matrix. | 214 | {- | Compute mean vector and covariance matrix of the rows of a matrix. |
206 | 215 | ||
207 | >>> meanCov $ gaussianSample 666 1000 (fromList[4,5]) (diagl[2,3]) | 216 | >>> meanCov $ gaussianSample 666 1000 (fromList[4,5]) (diagl[2,3]) |
217 | |||
218 | <interactive>:4:52: ERROR: | ||
219 | • Couldn't match expected type ‘Herm Double’ | ||
220 | with actual type ‘Matrix Double’ | ||
221 | • In the fourth argument of ‘gaussianSample’, namely | ||
222 | ‘(diagl [2, 3])’ | ||
223 | In the second argument of ‘($)’, namely | ||
224 | ‘gaussianSample 666 1000 (fromList [4, 5]) (diagl [2, 3])’ | ||
225 | In the expression: | ||
226 | meanCov $ gaussianSample 666 1000 (fromList [4, 5]) (diagl [2, 3]) | ||
227 | |||
208 | (fromList [4.010341078059521,5.0197204699640405], | 228 | (fromList [4.010341078059521,5.0197204699640405], |
209 | (2><2) | 229 | (2><2) |
210 | [ 1.9862461923890056, -1.0127225830525157e-2 | 230 | [ 1.9862461923890056, -1.0127225830525157e-2 |