Skip to content

Instantly share code, notes, and snippets.

@apriori
Created July 31, 2013 20:08
Show Gist options
  • Save apriori/6125681 to your computer and use it in GitHub Desktop.
Save apriori/6125681 to your computer and use it in GitHub Desktop.
sfold :: (Shape ix, Elt a) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Array ix a) -> Exp a
sfold f i a = let
iteratefunc :: (Elt a, Shape ix) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Array ix a) -> Exp Int -> Exp a
iteratefunc f i ar idx = let new = f i (ar A.!! idx) in
(idx <* (size ar) - 1) ? ((f new (iteratefunc f new ar (idx+1))), new)
-- new
in
iteratefunc f i a $ constant 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment