diff options
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Util/Convolution.hs')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Util/Convolution.hs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/Numeric/LinearAlgebra/Util/Convolution.hs b/lib/Numeric/LinearAlgebra/Util/Convolution.hs index b64b169..32cb188 100644 --- a/lib/Numeric/LinearAlgebra/Util/Convolution.hs +++ b/lib/Numeric/LinearAlgebra/Util/Convolution.hs | |||
@@ -12,12 +12,8 @@ Stability : provisional | |||
12 | ----------------------------------------------------------------------------- | 12 | ----------------------------------------------------------------------------- |
13 | 13 | ||
14 | module Numeric.LinearAlgebra.Util.Convolution( | 14 | module Numeric.LinearAlgebra.Util.Convolution( |
15 | -- * 1D | 15 | corr, conv, corrMin, |
16 | corr, conv, | 16 | corr2, conv2, separable |
17 | -- * 2D | ||
18 | corr2, conv2, | ||
19 | -- * Misc | ||
20 | separable, corrMin | ||
21 | ) where | 17 | ) where |
22 | 18 | ||
23 | import Numeric.LinearAlgebra | 19 | import Numeric.LinearAlgebra |
@@ -32,8 +28,8 @@ corr :: Product t => Vector t -- ^ kernel | |||
32 | -> Vector t | 28 | -> Vector t |
33 | {- ^ correlation | 29 | {- ^ correlation |
34 | 30 | ||
35 | @\> (fromList[1,2,3]) (fromList [1..10]) | 31 | >>> corr (fromList[1,2,3]) (fromList [1..10]) |
36 | fromList [14.0,20.0,26.0,32.0,38.0,44.0,50.0,56.0]@ | 32 | fromList [14.0,20.0,26.0,32.0,38.0,44.0,50.0,56.0] |
37 | 33 | ||
38 | -} | 34 | -} |
39 | corr ker v | dim ker <= dim v = vectSS (dim ker) v <> ker | 35 | corr ker v | dim ker <= dim v = vectSS (dim ker) v <> ker |
@@ -43,8 +39,8 @@ corr ker v | dim ker <= dim v = vectSS (dim ker) v <> ker | |||
43 | conv :: (Product t, Num t) => Vector t -> Vector t -> Vector t | 39 | conv :: (Product t, Num t) => Vector t -> Vector t -> Vector t |
44 | {- ^ convolution ('corr' with reversed kernel and padded input, equivalent to polynomial product) | 40 | {- ^ convolution ('corr' with reversed kernel and padded input, equivalent to polynomial product) |
45 | 41 | ||
46 | @\> conv (fromList[1,1]) (fromList [-1,1]) | 42 | >>> conv (fromList[1,1]) (fromList [-1,1]) |
47 | fromList [-1.0,0.0,1.0]@ | 43 | fromList [-1.0,0.0,1.0] |
48 | 44 | ||
49 | -} | 45 | -} |
50 | conv ker v = corr ker' v' | 46 | conv ker v = corr ker' v' |
@@ -113,6 +109,6 @@ conv2 k m = corr2 (fliprl . flipud $ k) pm | |||
113 | 109 | ||
114 | 110 | ||
115 | separable :: Element t => (Vector t -> Vector t) -> Matrix t -> Matrix t | 111 | separable :: Element t => (Vector t -> Vector t) -> Matrix t -> Matrix t |
116 | -- ^ 2D process implemented as separated 1D processes by rows and columns. | 112 | -- ^ matrix computation implemented as separated vector operations by rows and columns. |
117 | separable f = fromColumns . map f . toColumns . fromRows . map f . toRows | 113 | separable f = fromColumns . map f . toColumns . fromRows . map f . toRows |
118 | 114 | ||