summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Matrix.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r--lib/Data/Packed/Matrix.hs15
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
135asColumn :: Field a => Vector a -> Matrix a 135asColumn :: Field a => Vector a -> Matrix a
136asColumn v = reshape 1 v 136asColumn 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-}
148outer :: (Num t, Field t) => Vector t -> Vector t -> Matrix t
149outer u v = multiply RowMajor r c
150 where r = matrixFromVector RowMajor 1 u
151 c = matrixFromVector RowMajor (dim v) v