summaryrefslogtreecommitdiff
path: root/lib/LinearAlgebra/Linear.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-09-12 19:09:47 +0000
committerAlberto Ruiz <aruiz@um.es>2007-09-12 19:09:47 +0000
commit0ff13d993b880739295de343bca62f06fac5ca0c (patch)
tree252a51b4314c19c04a9eda87973eeaae63167a41 /lib/LinearAlgebra/Linear.hs
parentcd937c2be2900b8f13506d9ae7c731ad43d74e05 (diff)
documentation
Diffstat (limited to 'lib/LinearAlgebra/Linear.hs')
-rw-r--r--lib/LinearAlgebra/Linear.hs29
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/LinearAlgebra/Linear.hs b/lib/LinearAlgebra/Linear.hs
index 5c5bf0d..51b32f5 100644
--- a/lib/LinearAlgebra/Linear.hs
+++ b/lib/LinearAlgebra/Linear.hs
@@ -14,11 +14,15 @@ Portability : uses ffi
14----------------------------------------------------------------------------- 14-----------------------------------------------------------------------------
15 15
16module LinearAlgebra.Linear ( 16module LinearAlgebra.Linear (
17 Linear(..) 17 Linear(..),
18 toComplex, comp,
19 conj,
20 multiply, dot, outer
18) where 21) where
19 22
20 23
21import Data.Packed.Internal 24import Data.Packed.Internal
25import Data.Packed.Matrix
22import GSL.Vector 26import GSL.Vector
23import Complex 27import Complex
24 28
@@ -43,3 +47,26 @@ instance Linear Vector (Complex Double) where
43 add = vectorZipC Add 47 add = vectorZipC Add
44 sub = vectorZipC Sub 48 sub = vectorZipC Sub
45 mul = vectorZipC Mul 49 mul = vectorZipC Mul
50
51--------------------------------------------------
52
53
54-- | euclidean inner product
55dot :: (Field t) => Vector t -> Vector t -> t
56dot u v = dat (multiply r c) `at` 0
57 where r = asRow u
58 c = asColumn v
59
60
61
62
63{- | Outer product of two vectors.
64
65@\> 'fromList' [1,2,3] \`outer\` 'fromList' [5,2,3]
66(3><3)
67 [ 5.0, 2.0, 3.0
68 , 10.0, 4.0, 6.0
69 , 15.0, 6.0, 9.0 ]@
70-}
71outer :: (Num t, Field t) => Vector t -> Vector t -> Matrix t
72outer u v = asColumn u `multiply` asRow v