diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-09-20 08:39:33 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-09-20 08:39:33 +0000 |
commit | 9593058746aaf1f5afd9ce78c1dd5d64ef7b05a6 (patch) | |
tree | c109e502df2160cef7c95272478a78dc3c8bcc75 | |
parent | 0fc87fd99db80b81521a51c8abf4b8b151efb9da (diff) |
move deprecated funcs to Numeric.Container
-rw-r--r-- | lib/Data/Packed/Vector.hs | 40 | ||||
-rw-r--r-- | lib/Numeric/Container.hs | 91 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Algorithms.hs | 2 | ||||
-rw-r--r-- | lib/Numeric/Matrix.hs | 75 |
4 files changed, 93 insertions, 115 deletions
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs index 253f2fa..49448b2 100644 --- a/lib/Data/Packed/Vector.hs +++ b/lib/Data/Packed/Vector.hs | |||
@@ -18,14 +18,6 @@ module Data.Packed.Vector ( | |||
18 | fromList, (|>), toList, buildVector, | 18 | fromList, (|>), toList, buildVector, |
19 | dim, (@>), | 19 | dim, (@>), |
20 | subVector, takesV, join, | 20 | subVector, takesV, join, |
21 | -- moved to Numeric.LinearAlgebra.Linear | ||
22 | -- constant, linspace, | ||
23 | -- moved to Data.Packed.Matrix | ||
24 | -- vecdisp, | ||
25 | -- moved to Numeric.LinearAlgebra.Linear typeclass | ||
26 | -- vectorFMax, vectorFMin, vectorFMaxIndex, vectorFMinIndex, | ||
27 | -- vectorMax, vectorMin, | ||
28 | vectorMaxIndex, vectorMinIndex, | ||
29 | mapVector, zipVector, zipVectorWith, unzipVector, unzipVectorWith, | 21 | mapVector, zipVector, zipVectorWith, unzipVector, unzipVectorWith, |
30 | mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, | 22 | mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, |
31 | fscanfVector, fprintfVector, freadVector, fwriteVector, | 23 | fscanfVector, fprintfVector, freadVector, fwriteVector, |
@@ -33,9 +25,6 @@ module Data.Packed.Vector ( | |||
33 | ) where | 25 | ) where |
34 | 26 | ||
35 | import Data.Packed.Internal.Vector | 27 | import Data.Packed.Internal.Vector |
36 | import Numeric.GSL.Vector | ||
37 | -- import Data.Packed.ST | ||
38 | |||
39 | import Data.Binary | 28 | import Data.Binary |
40 | import Foreign.Storable | 29 | import Foreign.Storable |
41 | import Control.Monad(replicateM) | 30 | import Control.Monad(replicateM) |
@@ -72,35 +61,6 @@ instance (Binary a, Storable a) => Binary (Vector a) where | |||
72 | 61 | ||
73 | ------------------------------------------------------------------- | 62 | ------------------------------------------------------------------- |
74 | 63 | ||
75 | {- | ||
76 | vectorFMax :: Vector Float -> Float | ||
77 | vectorFMax = toScalarF Max | ||
78 | |||
79 | vectorFMin :: Vector Float -> Float | ||
80 | vectorFMin = toScalarF Min | ||
81 | |||
82 | vectorFMaxIndex :: Vector Float -> Int | ||
83 | vectorFMaxIndex = round . toScalarF MaxIdx | ||
84 | |||
85 | vectorFMinIndex :: Vector Float -> Int | ||
86 | vectorFMinIndex = round . toScalarF MinIdx | ||
87 | |||
88 | vectorMax :: Vector Double -> Double | ||
89 | vectorMax = toScalarR Max | ||
90 | |||
91 | vectorMin :: Vector Double -> Double | ||
92 | vectorMin = toScalarR Min | ||
93 | -} | ||
94 | |||
95 | {-# DEPRECATED vectorMaxIndex "use minIdx" #-} | ||
96 | vectorMaxIndex :: Vector Double -> Int | ||
97 | vectorMaxIndex = round . toScalarR MaxIdx | ||
98 | |||
99 | {-# DEPRECATED vectorMinIndex "use maxIdx" #-} | ||
100 | vectorMinIndex :: Vector Double -> Int | ||
101 | vectorMinIndex = round . toScalarR MinIdx | ||
102 | |||
103 | |||
104 | {- | creates a Vector of the specified length using the supplied function to | 64 | {- | creates a Vector of the specified length using the supplied function to |
105 | to map the index to the value at that index. | 65 | to map the index to the value at that index. |
106 | 66 | ||
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs index 0fecf86..8cf3e07 100644 --- a/lib/Numeric/Container.hs +++ b/lib/Numeric/Container.hs | |||
@@ -20,11 +20,14 @@ | |||
20 | ----------------------------------------------------------------------------- | 20 | ----------------------------------------------------------------------------- |
21 | 21 | ||
22 | module Numeric.Container ( | 22 | module Numeric.Container ( |
23 | -- * Generic operations | ||
23 | Container(..), | 24 | Container(..), |
25 | -- * Matrix product and related functions | ||
24 | Product(..), | 26 | Product(..), |
25 | mXm,mXv,vXm, | 27 | mXm,mXv,vXm, |
26 | outer, kronecker, | 28 | outer, kronecker, |
27 | 29 | ||
30 | -- * Element conversion | ||
28 | Convert(..), | 31 | Convert(..), |
29 | Complexable(), | 32 | Complexable(), |
30 | RealElement(), | 33 | RealElement(), |
@@ -32,7 +35,11 @@ module Numeric.Container ( | |||
32 | RealOf, ComplexOf, SingleOf, DoubleOf, | 35 | RealOf, ComplexOf, SingleOf, DoubleOf, |
33 | 36 | ||
34 | IndexOf, | 37 | IndexOf, |
35 | module Data.Complex | 38 | module Data.Complex, |
39 | -- * Deprecated | ||
40 | (.*),(*/),(<|>),(<->), | ||
41 | vectorMax,vectorMin, | ||
42 | vectorMaxIndex, vectorMinIndex | ||
36 | ) where | 43 | ) where |
37 | 44 | ||
38 | import Data.Packed | 45 | import Data.Packed |
@@ -397,3 +404,85 @@ type family ElementOf c | |||
397 | type instance ElementOf (Vector a) = a | 404 | type instance ElementOf (Vector a) = a |
398 | type instance ElementOf (Matrix a) = a | 405 | type instance ElementOf (Matrix a) = a |
399 | 406 | ||
407 | ------------------------------------------------------------ | ||
408 | |||
409 | ---------------------------------------------------- | ||
410 | |||
411 | {-# DEPRECATED (.*) "use scale a x or scalar a * x" #-} | ||
412 | |||
413 | -- -- | @x .* a = scale x a@ | ||
414 | -- (.*) :: (Linear c a) => a -> c a -> c a | ||
415 | infixl 7 .* | ||
416 | a .* x = scale a x | ||
417 | |||
418 | ---------------------------------------------------- | ||
419 | |||
420 | {-# DEPRECATED (*/) "use scale (recip a) x or x / scalar a" #-} | ||
421 | |||
422 | -- -- | @a *\/ x = scale (recip x) a@ | ||
423 | -- (*/) :: (Linear c a) => c a -> a -> c a | ||
424 | infixl 7 */ | ||
425 | v */ x = scale (recip x) v | ||
426 | |||
427 | |||
428 | ------------------------------------------------ | ||
429 | |||
430 | {-# DEPRECATED (<|>) "define operator a & b = fromBlocks[[a,b]] and use asRow/asColumn to join vectors" #-} | ||
431 | {-# DEPRECATED (<->) "define operator a // b = fromBlocks[[a],[b]] and use asRow/asColumn to join vectors" #-} | ||
432 | |||
433 | class Joinable a b where | ||
434 | joinH :: Element t => a t -> b t -> Matrix t | ||
435 | joinV :: Element t => a t -> b t -> Matrix t | ||
436 | |||
437 | instance Joinable Matrix Matrix where | ||
438 | joinH m1 m2 = fromBlocks [[m1,m2]] | ||
439 | joinV m1 m2 = fromBlocks [[m1],[m2]] | ||
440 | |||
441 | instance Joinable Matrix Vector where | ||
442 | joinH m v = joinH m (asColumn v) | ||
443 | joinV m v = joinV m (asRow v) | ||
444 | |||
445 | instance Joinable Vector Matrix where | ||
446 | joinH v m = joinH (asColumn v) m | ||
447 | joinV v m = joinV (asRow v) m | ||
448 | |||
449 | infixl 4 <|> | ||
450 | infixl 3 <-> | ||
451 | |||
452 | {-- - | Horizontal concatenation of matrices and vectors: | ||
453 | |||
454 | @> (ident 3 \<-\> 3 * ident 3) \<|\> fromList [1..6.0] | ||
455 | (6><4) | ||
456 | [ 1.0, 0.0, 0.0, 1.0 | ||
457 | , 0.0, 1.0, 0.0, 2.0 | ||
458 | , 0.0, 0.0, 1.0, 3.0 | ||
459 | , 3.0, 0.0, 0.0, 4.0 | ||
460 | , 0.0, 3.0, 0.0, 5.0 | ||
461 | , 0.0, 0.0, 3.0, 6.0 ]@ | ||
462 | -} | ||
463 | -- (<|>) :: (Element t, Joinable a b) => a t -> b t -> Matrix t | ||
464 | a <|> b = joinH a b | ||
465 | |||
466 | -- -- | Vertical concatenation of matrices and vectors. | ||
467 | -- (<->) :: (Element t, Joinable a b) => a t -> b t -> Matrix t | ||
468 | a <-> b = joinV a b | ||
469 | |||
470 | ------------------------------------------------------------------- | ||
471 | |||
472 | {-# DEPRECATED vectorMin "use minElement" #-} | ||
473 | vectorMin :: (Container Vector t, Element t) => Vector t -> t | ||
474 | vectorMin = minElement | ||
475 | |||
476 | {-# DEPRECATED vectorMax "use maxElement" #-} | ||
477 | vectorMax :: (Container Vector t, Element t) => Vector t -> t | ||
478 | vectorMax = maxElement | ||
479 | |||
480 | |||
481 | {-# DEPRECATED vectorMaxIndex "use minIndex" #-} | ||
482 | vectorMaxIndex :: Vector Double -> Int | ||
483 | vectorMaxIndex = round . toScalarR MaxIdx | ||
484 | |||
485 | {-# DEPRECATED vectorMinIndex "use maxIndex" #-} | ||
486 | vectorMinIndex :: Vector Double -> Int | ||
487 | vectorMinIndex = round . toScalarR MinIdx | ||
488 | |||
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs index 28cf88f..4f6f54d 100644 --- a/lib/Numeric/LinearAlgebra/Algorithms.hs +++ b/lib/Numeric/LinearAlgebra/Algorithms.hs | |||
@@ -79,7 +79,7 @@ import Data.Packed.Matrix | |||
79 | import Numeric.LinearAlgebra.LAPACK as LAPACK | 79 | import Numeric.LinearAlgebra.LAPACK as LAPACK |
80 | import Data.List(foldl1') | 80 | import Data.List(foldl1') |
81 | import Data.Array | 81 | import Data.Array |
82 | import Numeric.Container | 82 | import Numeric.Container hiding ((.*),(*/)) |
83 | 83 | ||
84 | -- | Auxiliary typeclass used to define generic computations for both real and complex matrices. | 84 | -- | Auxiliary typeclass used to define generic computations for both real and complex matrices. |
85 | class (Product t, | 85 | class (Product t, |
diff --git a/lib/Numeric/Matrix.hs b/lib/Numeric/Matrix.hs index 3d1ac94..f78e0c2 100644 --- a/lib/Numeric/Matrix.hs +++ b/lib/Numeric/Matrix.hs | |||
@@ -31,10 +31,7 @@ module Numeric.Matrix ( | |||
31 | --module Numeric.Container, | 31 | --module Numeric.Container, |
32 | optimiseMult, | 32 | optimiseMult, |
33 | -- * Operators | 33 | -- * Operators |
34 | (<>), (<\>), | 34 | (<>), (<\>) |
35 | -- * Deprecated | ||
36 | (.*),(*/),(<|>),(<->), | ||
37 | vectorMax,vectorMin | ||
38 | ) where | 35 | ) where |
39 | 36 | ||
40 | ------------------------------------------------------------------- | 37 | ------------------------------------------------------------------- |
@@ -101,77 +98,9 @@ instance Mul Matrix Vector Vector where | |||
101 | instance Mul Vector Matrix Vector where | 98 | instance Mul Vector Matrix Vector where |
102 | (<>) v m = flatten $ (asRow v) <> m | 99 | (<>) v m = flatten $ (asRow v) <> m |
103 | 100 | ||
104 | ---------------------------------------------------- | 101 | -------------------------------------------------------- |
105 | |||
106 | {-# DEPRECATED (.*) "use scale a x or scalar a * x" #-} | ||
107 | |||
108 | -- -- | @x .* a = scale x a@ | ||
109 | -- (.*) :: (Linear c a) => a -> c a -> c a | ||
110 | infixl 7 .* | ||
111 | a .* x = scale a x | ||
112 | |||
113 | ---------------------------------------------------- | ||
114 | |||
115 | {-# DEPRECATED (*/) "use scale (recip a) x or x / scalar a" #-} | ||
116 | |||
117 | -- -- | @a *\/ x = scale (recip x) a@ | ||
118 | -- (*/) :: (Linear c a) => c a -> a -> c a | ||
119 | infixl 7 */ | ||
120 | v */ x = scale (recip x) v | ||
121 | 102 | ||
122 | -- | least squares solution of a linear system, similar to the \\ operator of Matlab\/Octave (based on linearSolveSVD). | 103 | -- | least squares solution of a linear system, similar to the \\ operator of Matlab\/Octave (based on linearSolveSVD). |
123 | (<\>) :: (Field a) => Matrix a -> Vector a -> Vector a | 104 | (<\>) :: (Field a) => Matrix a -> Vector a -> Vector a |
124 | infixl 7 <\> | 105 | infixl 7 <\> |
125 | m <\> v = flatten (linearSolveSVD m (reshape 1 v)) | 106 | m <\> v = flatten (linearSolveSVD m (reshape 1 v)) |
126 | |||
127 | ------------------------------------------------ | ||
128 | |||
129 | {-# DEPRECATED (<|>) "define operator a & b = fromBlocks[[a,b]] and use asRow/asColumn to join vectors" #-} | ||
130 | {-# DEPRECATED (<->) "define operator a // b = fromBlocks[[a],[b]] and use asRow/asColumn to join vectors" #-} | ||
131 | |||
132 | class Joinable a b where | ||
133 | joinH :: Element t => a t -> b t -> Matrix t | ||
134 | joinV :: Element t => a t -> b t -> Matrix t | ||
135 | |||
136 | instance Joinable Matrix Matrix where | ||
137 | joinH m1 m2 = fromBlocks [[m1,m2]] | ||
138 | joinV m1 m2 = fromBlocks [[m1],[m2]] | ||
139 | |||
140 | instance Joinable Matrix Vector where | ||
141 | joinH m v = joinH m (asColumn v) | ||
142 | joinV m v = joinV m (asRow v) | ||
143 | |||
144 | instance Joinable Vector Matrix where | ||
145 | joinH v m = joinH (asColumn v) m | ||
146 | joinV v m = joinV (asRow v) m | ||
147 | |||
148 | infixl 4 <|> | ||
149 | infixl 3 <-> | ||
150 | |||
151 | {-- - | Horizontal concatenation of matrices and vectors: | ||
152 | |||
153 | @> (ident 3 \<-\> 3 * ident 3) \<|\> fromList [1..6.0] | ||
154 | (6><4) | ||
155 | [ 1.0, 0.0, 0.0, 1.0 | ||
156 | , 0.0, 1.0, 0.0, 2.0 | ||
157 | , 0.0, 0.0, 1.0, 3.0 | ||
158 | , 3.0, 0.0, 0.0, 4.0 | ||
159 | , 0.0, 3.0, 0.0, 5.0 | ||
160 | , 0.0, 0.0, 3.0, 6.0 ]@ | ||
161 | -} | ||
162 | -- (<|>) :: (Element t, Joinable a b) => a t -> b t -> Matrix t | ||
163 | a <|> b = joinH a b | ||
164 | |||
165 | -- -- | Vertical concatenation of matrices and vectors. | ||
166 | -- (<->) :: (Element t, Joinable a b) => a t -> b t -> Matrix t | ||
167 | a <-> b = joinV a b | ||
168 | |||
169 | ------------------------------------------------------------------- | ||
170 | |||
171 | {-# DEPRECATED vectorMin "use minElement" #-} | ||
172 | vectorMin :: (Container Vector t, Element t) => Vector t -> t | ||
173 | vectorMin = minElement | ||
174 | |||
175 | {-# DEPRECATED vectorMax "use maxElement" #-} | ||
176 | vectorMax :: (Container Vector t, Element t) => Vector t -> t | ||
177 | vectorMax = maxElement | ||