diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-09-04 09:34:13 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-09-04 09:34:13 +0000 |
commit | 7aa4500e6c71964094374d553faad1b1754cbc65 (patch) | |
tree | e3de3c60d1eecd12236afd635abf7625528cd6df /lib/Numeric/LinearAlgebra/Interface.hs | |
parent | 4486e93da02c7ef9e1fdf785c88f78986048c332 (diff) |
vector norms moved to Vectors
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Interface.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Interface.hs | 55 |
1 files changed, 1 insertions, 54 deletions
diff --git a/lib/Numeric/LinearAlgebra/Interface.hs b/lib/Numeric/LinearAlgebra/Interface.hs index ec08694..13d175b 100644 --- a/lib/Numeric/LinearAlgebra/Interface.hs +++ b/lib/Numeric/LinearAlgebra/Interface.hs | |||
@@ -19,7 +19,7 @@ In the context of the standard numeric operators, one-component vectors and matr | |||
19 | ----------------------------------------------------------------------------- | 19 | ----------------------------------------------------------------------------- |
20 | 20 | ||
21 | module Numeric.LinearAlgebra.Interface( | 21 | module Numeric.LinearAlgebra.Interface( |
22 | (<>),(<.>),mulG, Adapt, adaptElements, | 22 | (<>),(<.>), |
23 | (<\>), | 23 | (<\>), |
24 | (.*),(*/), | 24 | (.*),(*/), |
25 | (<|>),(<->), | 25 | (<|>),(<->), |
@@ -29,28 +29,20 @@ import Data.Packed.Vector | |||
29 | import Data.Packed.Matrix | 29 | import Data.Packed.Matrix |
30 | import Numeric.LinearAlgebra.Algorithms | 30 | import Numeric.LinearAlgebra.Algorithms |
31 | import Numeric.LinearAlgebra.Linear | 31 | import Numeric.LinearAlgebra.Linear |
32 | import Data.Complex | ||
33 | import Control.Arrow((***)) | ||
34 | |||
35 | --import Numeric.GSL.Vector | ||
36 | 32 | ||
37 | class Mul a b c | a b -> c where | 33 | class Mul a b c | a b -> c where |
38 | infixl 7 <> | 34 | infixl 7 <> |
39 | -- | Matrix-matrix, matrix-vector, and vector-matrix products. | 35 | -- | Matrix-matrix, matrix-vector, and vector-matrix products. |
40 | (<>) :: Product t => a t -> b t -> c t | 36 | (<>) :: Product t => a t -> b t -> c t |
41 | mulG :: (Element r, Element s, Adapt r s t t, Product t) => a r -> b s -> c t | ||
42 | 37 | ||
43 | instance Mul Matrix Matrix Matrix where | 38 | instance Mul Matrix Matrix Matrix where |
44 | (<>) = mXm | 39 | (<>) = mXm |
45 | mulG a b = uncurry mXm (curry adapt a b) | ||
46 | 40 | ||
47 | instance Mul Matrix Vector Vector where | 41 | instance Mul Matrix Vector Vector where |
48 | (<>) m v = flatten $ m <> (asColumn v) | 42 | (<>) m v = flatten $ m <> (asColumn v) |
49 | mulG m v = flatten $ m `mulG` (asColumn v) | ||
50 | 43 | ||
51 | instance Mul Vector Matrix Vector where | 44 | instance Mul Vector Matrix Vector where |
52 | (<>) v m = flatten $ (asRow v) <> m | 45 | (<>) v m = flatten $ (asRow v) <> m |
53 | mulG v m = flatten $ (asRow v) `mulG` m | ||
54 | 46 | ||
55 | --------------------------------------------------- | 47 | --------------------------------------------------- |
56 | 48 | ||
@@ -124,48 +116,3 @@ a <|> b = joinH a b | |||
124 | -- -- | Vertical concatenation of matrices and vectors. | 116 | -- -- | Vertical concatenation of matrices and vectors. |
125 | -- (<->) :: (Element t, Joinable a b) => a t -> b t -> Matrix t | 117 | -- (<->) :: (Element t, Joinable a b) => a t -> b t -> Matrix t |
126 | a <-> b = joinV a b | 118 | a <-> b = joinV a b |
127 | |||
128 | ---------------------------------------------------- | ||
129 | |||
130 | class Adapt a b c d | a b -> c, a b -> d where | ||
131 | adapt :: Container k => (k a, k b) -> (k c, k d) | ||
132 | |||
133 | --instance Adapt a a a a where | ||
134 | -- adapt = id *** id | ||
135 | |||
136 | instance Adapt Float Float Float Float where | ||
137 | adapt = id *** id | ||
138 | |||
139 | instance Adapt Double Double Double Double where | ||
140 | adapt = id *** id | ||
141 | |||
142 | instance Adapt (Complex Float) (Complex Float) (Complex Float) (Complex Float) where | ||
143 | adapt = id *** id | ||
144 | |||
145 | instance Adapt Float Double Double Double where | ||
146 | adapt = double *** id | ||
147 | |||
148 | instance Adapt Double Float Double Double where | ||
149 | adapt = id *** double | ||
150 | |||
151 | instance Adapt Float (Complex Float) (Complex Float) (Complex Float) where | ||
152 | adapt = complex *** id | ||
153 | |||
154 | instance Adapt (Complex Float) Float (Complex Float) (Complex Float) where | ||
155 | adapt = id *** complex | ||
156 | |||
157 | instance (Convert a, Convert (DoubleOf a), ComplexOf (DoubleOf a) ~ Complex Double) => Adapt a (Complex Double) (Complex Double) (Complex Double) where | ||
158 | adapt = complex.double *** id | ||
159 | |||
160 | instance (Convert a, Convert (DoubleOf a), ComplexOf (DoubleOf a) ~ Complex Double) => Adapt (Complex Double) a (Complex Double) (Complex Double) where | ||
161 | adapt = id *** complex.double | ||
162 | |||
163 | instance Adapt Double (Complex Float) (Complex Double) (Complex Double) where | ||
164 | adapt = complex *** double | ||
165 | |||
166 | instance Adapt (Complex Float) Double (Complex Double) (Complex Double) where | ||
167 | adapt = double *** complex | ||
168 | |||
169 | adaptElements:: (Adapt a b c d, Container k) => (k a, k b) -> (k c, k d) | ||
170 | adaptElements p = adapt p | ||
171 | |||