module Test where
import Data
.Array
.Repa
hiding (map) import qualified Data
.Array
.Repa
as R
(map)
type DIM1
_U
_D
= Array U DIM1
Double type DIM1
_D
_D
= Array D DIM1
Double
calc :: DIM1_U_D -> DIM1_U_D -> DIM1_D_D
calc k b = let sizeB = size (extent b)
sizeK = size (extent k)
(\i -> kp (Z:.i) * bp (Z:.ic+i))
[0..sizeK-1]
in traverse2 k b (\_ _ -> Z:.sizeB-sizeK+1) p
-- example
base, kernel :: DIM1_U_D
base = fromListUnboxed (Z:.5) [3, 5, 2, 9, 4]
kernel = fromListUnboxed (Z:.3) [6, 3, 5]
result = toList (calc kernel base) -- [43, 81, 59]
bW9kdWxlIFRlc3Qgd2hlcmUKCmltcG9ydCBEYXRhLkFycmF5LlJlcGEgaGlkaW5nIChtYXApCmltcG9ydCBxdWFsaWZpZWQgRGF0YS5BcnJheS5SZXBhIGFzIFIgKG1hcCkKCgp0eXBlIERJTTFfVV9EID0gQXJyYXkgVSBESU0xIERvdWJsZQp0eXBlIERJTTFfRF9EID0gQXJyYXkgRCBESU0xIERvdWJsZQoKCmNhbGMgOjogRElNMV9VX0QgLT4gRElNMV9VX0QgLT4gRElNMV9EX0QKY2FsYyBrIGIgPSBsZXQgc2l6ZUIgPSBzaXplIChleHRlbnQgYikKICAgICAgICAgICAgICAgc2l6ZUsgPSBzaXplIChleHRlbnQgaykKICAgICAgICAgICAgICAgcCBrcCBicCAoWjouaWMpID0gc3VtICQgbWFwCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChcaSAtPiBrcCAoWjouaSkgKiBicCAoWjouaWMraSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFswLi5zaXplSy0xXQogICAgICAgICAgIGluIHRyYXZlcnNlMiBrIGIgKFxfIF8gLT4gWjouc2l6ZUItc2l6ZUsrMSkgcAoKCi0tIGV4YW1wbGUKCmJhc2UsIGtlcm5lbCA6OiBESU0xX1VfRApiYXNlICAgPSBmcm9tTGlzdFVuYm94ZWQgKFo6LjUpIFszLCA1LCAyLCA5LCA0XQprZXJuZWwgPSBmcm9tTGlzdFVuYm94ZWQgKFo6LjMpIFs2LCAzLCA1XQoKcmVzdWx0ID0gdG9MaXN0IChjYWxjIGtlcm5lbCBiYXNlKSAtLSBbNDMsIDgxLCA1OV0=