diff options
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra/Util')
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Util/CG.hs | 2 | ||||
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs | 18 |
2 files changed, 11 insertions, 9 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs b/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs index d21602d..5e2ea84 100644 --- a/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs +++ b/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs | |||
@@ -6,7 +6,7 @@ module Numeric.LinearAlgebra.Util.CG( | |||
6 | CGMat, CGState(..), R, V | 6 | CGMat, CGState(..), R, V |
7 | ) where | 7 | ) where |
8 | 8 | ||
9 | import Numeric.Container | 9 | import Data.Packed.Numeric |
10 | import Numeric.Vector() | 10 | import Numeric.Vector() |
11 | 11 | ||
12 | {- | 12 | {- |
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs b/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs index e4cba8f..c8c7536 100644 --- a/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs +++ b/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs | |||
@@ -16,16 +16,18 @@ module Numeric.LinearAlgebra.Util.Convolution( | |||
16 | corr2, conv2, separable | 16 | corr2, conv2, separable |
17 | ) where | 17 | ) where |
18 | 18 | ||
19 | import Numeric.Container | 19 | import Data.Packed.Numeric |
20 | 20 | ||
21 | 21 | ||
22 | vectSS :: Element t => Int -> Vector t -> Matrix t | 22 | vectSS :: Element t => Int -> Vector t -> Matrix t |
23 | vectSS n v = fromRows [ subVector k n v | k <- [0 .. dim v - n] ] | 23 | vectSS n v = fromRows [ subVector k n v | k <- [0 .. dim v - n] ] |
24 | 24 | ||
25 | 25 | ||
26 | corr :: Product t => Vector t -- ^ kernel | 26 | corr |
27 | -> Vector t -- ^ source | 27 | :: (Container Vector t, Product t) |
28 | -> Vector t | 28 | => Vector t -- ^ kernel |
29 | -> Vector t -- ^ source | ||
30 | -> Vector t | ||
29 | {- ^ correlation | 31 | {- ^ correlation |
30 | 32 | ||
31 | >>> corr (fromList[1,2,3]) (fromList [1..10]) | 33 | >>> corr (fromList[1,2,3]) (fromList [1..10]) |
@@ -33,12 +35,12 @@ fromList [14.0,20.0,26.0,32.0,38.0,44.0,50.0,56.0] | |||
33 | 35 | ||
34 | -} | 36 | -} |
35 | corr ker v | 37 | corr ker v |
36 | | dim ker == 0 = constant 0 (dim v) | 38 | | dim ker == 0 = konst 0 (dim v) |
37 | | dim ker <= dim v = vectSS (dim ker) v <> ker | 39 | | dim ker <= dim v = vectSS (dim ker) v <> ker |
38 | | otherwise = error $ "corr: dim kernel ("++show (dim ker)++") > dim vector ("++show (dim v)++")" | 40 | | otherwise = error $ "corr: dim kernel ("++show (dim ker)++") > dim vector ("++show (dim v)++")" |
39 | 41 | ||
40 | 42 | ||
41 | conv :: (Product t, Num t) => Vector t -> Vector t -> Vector t | 43 | conv :: (Container Vector t, Product t, Num t) => Vector t -> Vector t -> Vector t |
42 | {- ^ convolution ('corr' with reversed kernel and padded input, equivalent to polynomial product) | 44 | {- ^ convolution ('corr' with reversed kernel and padded input, equivalent to polynomial product) |
43 | 45 | ||
44 | >>> conv (fromList[1,1]) (fromList [-1,1]) | 46 | >>> conv (fromList[1,1]) (fromList [-1,1]) |
@@ -46,12 +48,12 @@ fromList [-1.0,0.0,1.0] | |||
46 | 48 | ||
47 | -} | 49 | -} |
48 | conv ker v | 50 | conv ker v |
49 | | dim ker == 0 = constant 0 (dim v) | 51 | | dim ker == 0 = konst 0 (dim v) |
50 | | otherwise = corr ker' v' | 52 | | otherwise = corr ker' v' |
51 | where | 53 | where |
52 | ker' = (flatten.fliprl.asRow) ker | 54 | ker' = (flatten.fliprl.asRow) ker |
53 | v' = vjoin [z,v,z] | 55 | v' = vjoin [z,v,z] |
54 | z = constant 0 (dim ker -1) | 56 | z = konst 0 (dim ker -1) |
55 | 57 | ||
56 | corrMin :: (Container Vector t, RealElement t, Product t) | 58 | corrMin :: (Container Vector t, RealElement t, Product t) |
57 | => Vector t | 59 | => Vector t |