summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/Util/Convolution.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Util/Convolution.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/Util/Convolution.hs18
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
14module Numeric.LinearAlgebra.Util.Convolution( 14module 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
23import Numeric.LinearAlgebra 19import 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])
36fromList [14.0,20.0,26.0,32.0,38.0,44.0,50.0,56.0]@ 32fromList [14.0,20.0,26.0,32.0,38.0,44.0,50.0,56.0]
37 33
38-} 34-}
39corr ker v | dim ker <= dim v = vectSS (dim ker) v <> ker 35corr 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
43conv :: (Product t, Num t) => Vector t -> Vector t -> Vector t 39conv :: (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])
47fromList [-1.0,0.0,1.0]@ 43fromList [-1.0,0.0,1.0]
48 44
49-} 45-}
50conv ker v = corr ker' v' 46conv ker v = corr ker' v'
@@ -113,6 +109,6 @@ conv2 k m = corr2 (fliprl . flipud $ k) pm
113 109
114 110
115separable :: Element t => (Vector t -> Vector t) -> Matrix t -> Matrix t 111separable :: 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.
117separable f = fromColumns . map f . toColumns . fromRows . map f . toRows 113separable f = fromColumns . map f . toColumns . fromRows . map f . toRows
118 114