diff options
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra')
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Data.hs | 4 | ||||
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/HMatrix.hs | 2 | ||||
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Util.hs | 44 |
3 files changed, 39 insertions, 11 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Data.hs b/packages/base/src/Numeric/LinearAlgebra/Data.hs index b1a31fc..6dea407 100644 --- a/packages/base/src/Numeric/LinearAlgebra/Data.hs +++ b/packages/base/src/Numeric/LinearAlgebra/Data.hs | |||
@@ -40,7 +40,7 @@ module Numeric.LinearAlgebra.Data( | |||
40 | takeRows, dropRows, takeColumns, dropColumns, subMatrix, (?), (¿), fliprl, flipud, | 40 | takeRows, dropRows, takeColumns, dropColumns, subMatrix, (?), (¿), fliprl, flipud, |
41 | 41 | ||
42 | -- * Block matrix | 42 | -- * Block matrix |
43 | fromBlocks, (¦), (——), diagBlock, repmat, toBlocks, toBlocksEvery, | 43 | fromBlocks, (|||), (===), diagBlock, repmat, toBlocks, toBlocksEvery, |
44 | 44 | ||
45 | -- * Mapping functions | 45 | -- * Mapping functions |
46 | conj, cmap, step, cond, | 46 | conj, cmap, step, cond, |
@@ -66,7 +66,7 @@ module Numeric.LinearAlgebra.Data( | |||
66 | arctan2, | 66 | arctan2, |
67 | rows, cols, | 67 | rows, cols, |
68 | separable, | 68 | separable, |
69 | 69 | (¦),(——), | |
70 | module Data.Complex, | 70 | module Data.Complex, |
71 | 71 | ||
72 | Vector, Matrix, GMatrix, nRows, nCols | 72 | Vector, Matrix, GMatrix, nRows, nCols |
diff --git a/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs b/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs index c0cc622..677f9ee 100644 --- a/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs +++ b/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs | |||
@@ -134,7 +134,7 @@ module Numeric.LinearAlgebra.HMatrix ( | |||
134 | Seed, RandDist(..), randomVector, rand, randn, gaussianSample, uniformSample, | 134 | Seed, RandDist(..), randomVector, rand, randn, gaussianSample, uniformSample, |
135 | 135 | ||
136 | -- * Misc | 136 | -- * Misc |
137 | meanCov, peps, relativeError, haussholder, optimiseMult, udot, nullspaceSVD, orthSVD, ranksv, | 137 | meanCov, rowOuters, peps, relativeError, haussholder, optimiseMult, udot, nullspaceSVD, orthSVD, ranksv, |
138 | ℝ,ℂ,iC, | 138 | ℝ,ℂ,iC, |
139 | -- * Auxiliary classes | 139 | -- * Auxiliary classes |
140 | Element, Container, Product, Numeric, LSDiv, | 140 | Element, Container, Product, Numeric, LSDiv, |
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 |