diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-09-12 19:09:47 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-09-12 19:09:47 +0000 |
commit | 0ff13d993b880739295de343bca62f06fac5ca0c (patch) | |
tree | 252a51b4314c19c04a9eda87973eeaae63167a41 /lib/LinearAlgebra/Linear.hs | |
parent | cd937c2be2900b8f13506d9ae7c731ad43d74e05 (diff) |
documentation
Diffstat (limited to 'lib/LinearAlgebra/Linear.hs')
-rw-r--r-- | lib/LinearAlgebra/Linear.hs | 29 |
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 | ||
16 | module LinearAlgebra.Linear ( | 16 | module LinearAlgebra.Linear ( |
17 | Linear(..) | 17 | Linear(..), |
18 | toComplex, comp, | ||
19 | conj, | ||
20 | multiply, dot, outer | ||
18 | ) where | 21 | ) where |
19 | 22 | ||
20 | 23 | ||
21 | import Data.Packed.Internal | 24 | import Data.Packed.Internal |
25 | import Data.Packed.Matrix | ||
22 | import GSL.Vector | 26 | import GSL.Vector |
23 | import Complex | 27 | import 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 | ||
55 | dot :: (Field t) => Vector t -> Vector t -> t | ||
56 | dot 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 | -} | ||
71 | outer :: (Num t, Field t) => Vector t -> Vector t -> Matrix t | ||
72 | outer u v = asColumn u `multiply` asRow v | ||