diff options
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Interface.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Interface.hs | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/Numeric/LinearAlgebra/Interface.hs b/lib/Numeric/LinearAlgebra/Interface.hs index b74180f..750670b 100644 --- a/lib/Numeric/LinearAlgebra/Interface.hs +++ b/lib/Numeric/LinearAlgebra/Interface.hs | |||
@@ -9,7 +9,12 @@ Maintainer : Alberto Ruiz (aruiz at um dot es) | |||
9 | Stability : provisional | 9 | Stability : provisional |
10 | Portability : portable | 10 | Portability : portable |
11 | 11 | ||
12 | (Very provisional) operators for frequent operations. | 12 | Operators for frequent operations. |
13 | |||
14 | This module exports Show, Read, Eq, Num, Fractional, and Floating instances for Vector and Matrix. | ||
15 | |||
16 | In the context of the standard numeric operators, one-component vectors and matrices automatically expand to match the dimensions of the other operand. | ||
17 | |||
13 | 18 | ||
14 | -} | 19 | -} |
15 | ----------------------------------------------------------------------------- | 20 | ----------------------------------------------------------------------------- |
@@ -21,14 +26,14 @@ module Numeric.LinearAlgebra.Interface( | |||
21 | (<|>),(<->), | 26 | (<|>),(<->), |
22 | ) where | 27 | ) where |
23 | 28 | ||
24 | import Numeric.LinearAlgebra.Linear | 29 | import Numeric.LinearAlgebra.Instances() |
25 | import Data.Packed.Vector | 30 | import Data.Packed.Vector |
26 | import Data.Packed.Matrix | 31 | import Data.Packed.Matrix |
27 | import Numeric.LinearAlgebra.Algorithms | 32 | import Numeric.LinearAlgebra.Algorithms |
28 | 33 | ||
29 | class Mul a b c | a b -> c where | 34 | class Mul a b c | a b -> c where |
30 | infixl 7 <> | 35 | infixl 7 <> |
31 | -- | matrix product | 36 | -- | Matrix-matrix, matrix-vector, and vector-matrix products. |
32 | (<>) :: Field t => a t -> b t -> c t | 37 | (<>) :: Field t => a t -> b t -> c t |
33 | 38 | ||
34 | instance Mul Matrix Matrix Matrix where | 39 | instance Mul Matrix Matrix Matrix where |
@@ -42,7 +47,7 @@ instance Mul Vector Matrix Vector where | |||
42 | 47 | ||
43 | --------------------------------------------------- | 48 | --------------------------------------------------- |
44 | 49 | ||
45 | -- | @u \<.\> v = dot u v@ | 50 | -- | Dot product: @u \<.\> v = dot u v@ |
46 | (<.>) :: (Field t) => Vector t -> Vector t -> t | 51 | (<.>) :: (Field t) => Vector t -> Vector t -> t |
47 | infixl 7 <.> | 52 | infixl 7 <.> |
48 | (<.>) = dot | 53 | (<.>) = dot |
@@ -51,8 +56,8 @@ infixl 7 <.> | |||
51 | 56 | ||
52 | {-# DEPRECATED (.*) "use scale a x or scalar a * x" #-} | 57 | {-# DEPRECATED (.*) "use scale a x or scalar a * x" #-} |
53 | 58 | ||
54 | -- | @x .* a = scale x a@ | 59 | -- -- | @x .* a = scale x a@ |
55 | (.*) :: (Linear c a) => a -> c a -> c a | 60 | -- (.*) :: (Linear c a) => a -> c a -> c a |
56 | infixl 7 .* | 61 | infixl 7 .* |
57 | a .* x = scale a x | 62 | a .* x = scale a x |
58 | 63 | ||
@@ -60,8 +65,8 @@ a .* x = scale a x | |||
60 | 65 | ||
61 | {-# DEPRECATED (*/) "use scale (recip a) x or x / scalar a" #-} | 66 | {-# DEPRECATED (*/) "use scale (recip a) x or x / scalar a" #-} |
62 | 67 | ||
63 | -- | @a *\/ x = scale (recip x) a@ | 68 | -- -- | @a *\/ x = scale (recip x) a@ |
64 | (*/) :: (Linear c a) => c a -> a -> c a | 69 | -- (*/) :: (Linear c a) => c a -> a -> c a |
65 | infixl 7 */ | 70 | infixl 7 */ |
66 | v */ x = scale (recip x) v | 71 | v */ x = scale (recip x) v |
67 | 72 | ||
@@ -94,7 +99,7 @@ instance Joinable Vector Matrix where | |||
94 | infixl 4 <|> | 99 | infixl 4 <|> |
95 | infixl 3 <-> | 100 | infixl 3 <-> |
96 | 101 | ||
97 | {- | Horizontal concatenation of matrices and vectors: | 102 | {-- - | Horizontal concatenation of matrices and vectors: |
98 | 103 | ||
99 | @> (ident 3 \<-\> 3 * ident 3) \<|\> fromList [1..6.0] | 104 | @> (ident 3 \<-\> 3 * ident 3) \<|\> fromList [1..6.0] |
100 | (6><4) | 105 | (6><4) |
@@ -105,10 +110,10 @@ infixl 3 <-> | |||
105 | , 0.0, 3.0, 0.0, 5.0 | 110 | , 0.0, 3.0, 0.0, 5.0 |
106 | , 0.0, 0.0, 3.0, 6.0 ]@ | 111 | , 0.0, 0.0, 3.0, 6.0 ]@ |
107 | -} | 112 | -} |
108 | (<|>) :: (Element t, Joinable a b) => a t -> b t -> Matrix t | 113 | -- (<|>) :: (Element t, Joinable a b) => a t -> b t -> Matrix t |
109 | a <|> b = joinH a b | 114 | a <|> b = joinH a b |
110 | 115 | ||
111 | -- | Vertical concatenation of matrices and vectors. | 116 | -- -- | Vertical concatenation of matrices and vectors. |
112 | (<->) :: (Element t, Joinable a b) => a t -> b t -> Matrix t | 117 | -- (<->) :: (Element t, Joinable a b) => a t -> b t -> Matrix t |
113 | a <-> b = joinV a b | 118 | a <-> b = joinV a b |
114 | 119 | ||