diff options
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index 2033dc7..2e8cb3d 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -134,3 +134,18 @@ asRow v = reshape (dim v) v | |||
134 | 134 | ||
135 | asColumn :: Field a => Vector a -> Matrix a | 135 | asColumn :: Field a => Vector a -> Matrix a |
136 | asColumn v = reshape 1 v | 136 | asColumn v = reshape 1 v |
137 | |||
138 | ------------------------------------------------ | ||
139 | |||
140 | {- | Outer product of two vectors. | ||
141 | |||
142 | @\> 'fromList' [1,2,3] \`outer\` 'fromList' [5,2,3] | ||
143 | (3><3) | ||
144 | [ 5.0, 2.0, 3.0 | ||
145 | , 10.0, 4.0, 6.0 | ||
146 | , 15.0, 6.0, 9.0 ]@ | ||
147 | -} | ||
148 | outer :: (Num t, Field t) => Vector t -> Vector t -> Matrix t | ||
149 | outer u v = multiply RowMajor r c | ||
150 | where r = matrixFromVector RowMajor 1 u | ||
151 | c = matrixFromVector RowMajor (dim v) v | ||