module Data.Array.Repa.Operators.Traversal
( traverse, unsafeTraverse
, traverse2, unsafeTraverse2
, traverse3, unsafeTraverse3
, traverse4, unsafeTraverse4)
where
import Data.Array.Repa.Base
import Data.Array.Repa.Shape
import Data.Array.Repa.Repr.Delayed
traverse, unsafeTraverse
:: forall r sh sh' a b
. ( Source r a
, Shape sh, Shape sh')
=> Array r sh a
-> (sh -> sh')
-> ((sh -> a) -> sh' -> b)
-> Array D sh' b
traverse arr transExtent newElem
= fromFunction (transExtent (extent arr)) (newElem (index arr))
unsafeTraverse arr transExtent newElem
= fromFunction (transExtent (extent arr)) (newElem (unsafeIndex arr))
traverse2, unsafeTraverse2
:: forall r1 r2 sh sh' sh'' a b c
. ( Source r1 a, Source r2 b
, Shape sh, Shape sh', Shape sh'')
=> Array r1 sh a
-> Array r2 sh' b
-> (sh -> sh' -> sh'')
-> ((sh -> a) -> (sh' -> b)
-> (sh'' -> c))
-> Array D sh'' c
traverse2 arrA arrB transExtent newElem
= fromFunction (transExtent (extent arrA) (extent arrB))
(newElem (index arrA) (index arrB))
unsafeTraverse2 arrA arrB transExtent newElem
= fromFunction (transExtent (extent arrA) (extent arrB))
(newElem (unsafeIndex arrA) (unsafeIndex arrB))
traverse3, unsafeTraverse3
:: forall r1 r2 r3
sh1 sh2 sh3 sh4
a b c d
. ( Source r1 a, Source r2 b, Source r3 c
, Shape sh1, Shape sh2, Shape sh3, Shape sh4)
=> Array r1 sh1 a
-> Array r2 sh2 b
-> Array r3 sh3 c
-> (sh1 -> sh2 -> sh3 -> sh4)
-> ( (sh1 -> a) -> (sh2 -> b)
-> (sh3 -> c)
-> sh4 -> d )
-> Array D sh4 d
traverse3 arrA arrB arrC transExtent newElem
= fromFunction (transExtent (extent arrA) (extent arrB) (extent arrC))
(newElem (index arrA) (index arrB) (index arrC))
unsafeTraverse3 arrA arrB arrC transExtent newElem
= fromFunction (transExtent (extent arrA) (extent arrB) (extent arrC))
(newElem (unsafeIndex arrA) (unsafeIndex arrB) (unsafeIndex arrC))
traverse4, unsafeTraverse4
:: forall r1 r2 r3 r4
sh1 sh2 sh3 sh4 sh5
a b c d e
. ( Source r1 a, Source r2 b, Source r3 c, Source r4 d
, Shape sh1, Shape sh2, Shape sh3, Shape sh4, Shape sh5)
=> Array r1 sh1 a
-> Array r2 sh2 b
-> Array r3 sh3 c
-> Array r4 sh4 d
-> (sh1 -> sh2 -> sh3 -> sh4 -> sh5 )
-> ( (sh1 -> a) -> (sh2 -> b)
-> (sh3 -> c) -> (sh4 -> d)
-> sh5 -> e )
-> Array D sh5 e
traverse4 arrA arrB arrC arrD transExtent newElem
= fromFunction (transExtent (extent arrA) (extent arrB) (extent arrC) (extent arrD))
(newElem (index arrA) (index arrB) (index arrC) (index arrD))
unsafeTraverse4 arrA arrB arrC arrD transExtent newElem
= fromFunction (transExtent (extent arrA) (extent arrB) (extent arrC) (extent arrD))
(newElem (unsafeIndex arrA) (unsafeIndex arrB) (unsafeIndex arrC) (unsafeIndex arrD))