diff options
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra/Util.hs')
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Util.hs | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util.hs b/packages/base/src/Numeric/LinearAlgebra/Util.hs index 6bb9d15..043aa21 100644 --- a/packages/base/src/Numeric/LinearAlgebra/Util.hs +++ b/packages/base/src/Numeric/LinearAlgebra/Util.hs | |||
@@ -33,7 +33,7 @@ module Numeric.LinearAlgebra.Util( | |||
33 | diagl, | 33 | diagl, |
34 | row, | 34 | row, |
35 | col, | 35 | col, |
36 | (&), (¦), (——), (#), | 36 | (&), (¦), (|||), (——), (===), (#), |
37 | (?), (¿), | 37 | (?), (¿), |
38 | Indexable(..), size, | 38 | Indexable(..), size, |
39 | Numeric, | 39 | Numeric, |
@@ -157,25 +157,34 @@ a & b = vjoin [a,b] | |||
157 | 157 | ||
158 | {- | horizontal concatenation of real matrices | 158 | {- | horizontal concatenation of real matrices |
159 | 159 | ||
160 | (unicode 0x00a6, broken bar) | 160 | >>> ident 3 ||| konst 7 (3,4) |
161 | |||
162 | >>> ident 3 ¦ konst 7 (3,4) | ||
163 | (3><7) | 161 | (3><7) |
164 | [ 1.0, 0.0, 0.0, 7.0, 7.0, 7.0, 7.0 | 162 | [ 1.0, 0.0, 0.0, 7.0, 7.0, 7.0, 7.0 |
165 | , 0.0, 1.0, 0.0, 7.0, 7.0, 7.0, 7.0 | 163 | , 0.0, 1.0, 0.0, 7.0, 7.0, 7.0, 7.0 |
166 | , 0.0, 0.0, 1.0, 7.0, 7.0, 7.0, 7.0 ] | 164 | , 0.0, 0.0, 1.0, 7.0, 7.0, 7.0, 7.0 ] |
167 | 165 | ||
168 | -} | 166 | -} |
167 | infixl 3 ||| | ||
168 | (|||) :: Matrix Double -> Matrix Double -> Matrix Double | ||
169 | a ||| b = fromBlocks [[a,b]] | ||
170 | |||
171 | -- | a synonym for ('|||') (unicode 0x00a6, broken bar) | ||
169 | infixl 3 ¦ | 172 | infixl 3 ¦ |
170 | (¦) :: Matrix Double -> Matrix Double -> Matrix Double | 173 | (¦) :: Matrix Double -> Matrix Double -> Matrix Double |
171 | a ¦ b = fromBlocks [[a,b]] | 174 | (¦) = (|||) |
175 | |||
172 | 176 | ||
173 | -- | vertical concatenation of real matrices | 177 | -- | vertical concatenation of real matrices |
174 | -- | 178 | -- |
175 | -- (unicode 0x2014, em dash) | 179 | (===) :: Matrix Double -> Matrix Double -> Matrix Double |
180 | infixl 2 === | ||
181 | a === b = fromBlocks [[a],[b]] | ||
182 | |||
183 | -- | a synonym for ('===') (unicode 0x2014, em dash) | ||
176 | (——) :: Matrix Double -> Matrix Double -> Matrix Double | 184 | (——) :: Matrix Double -> Matrix Double -> Matrix Double |
177 | infixl 2 —— | 185 | infixl 2 —— |
178 | a —— b = fromBlocks [[a],[b]] | 186 | (——) = (===) |
187 | |||
179 | 188 | ||
180 | (#) :: Matrix Double -> Matrix Double -> Matrix Double | 189 | (#) :: Matrix Double -> Matrix Double -> Matrix Double |
181 | infixl 2 # | 190 | infixl 2 # |
@@ -356,7 +365,26 @@ pairwiseD2 x y | ok = x2 `outer` oy + ox `outer` y2 - 2* x <> trans y | |||
356 | 365 | ||
357 | -------------------------------------------------------------------------------- | 366 | -------------------------------------------------------------------------------- |
358 | 367 | ||
359 | -- | outer products of rows | 368 | {- | outer products of rows |
369 | |||
370 | >>> a | ||
371 | (3><2) | ||
372 | [ 1.0, 2.0 | ||
373 | , 10.0, 20.0 | ||
374 | , 100.0, 200.0 ] | ||
375 | >>> b | ||
376 | (3><3) | ||
377 | [ 1.0, 2.0, 3.0 | ||
378 | , 4.0, 5.0, 6.0 | ||
379 | , 7.0, 8.0, 9.0 ] | ||
380 | |||
381 | >>> rowOuters a (b ||| 1) | ||
382 | (3><8) | ||
383 | [ 1.0, 2.0, 3.0, 1.0, 2.0, 4.0, 6.0, 2.0 | ||
384 | , 40.0, 50.0, 60.0, 10.0, 80.0, 100.0, 120.0, 20.0 | ||
385 | , 700.0, 800.0, 900.0, 100.0, 1400.0, 1600.0, 1800.0, 200.0 ] | ||
386 | |||
387 | -} | ||
360 | rowOuters :: Matrix Double -> Matrix Double -> Matrix Double | 388 | rowOuters :: Matrix Double -> Matrix Double -> Matrix Double |
361 | rowOuters a b = a' * b' | 389 | rowOuters a b = a' * b' |
362 | where | 390 | where |