Created
June 5, 2011 15:37
-
-
Save nneitzke/1009061 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
slice :: (Slice sh, Shape sh, Elt a) => Int -> Int -> Array (sh :. Int) a -> Array (sh :. Int) a | |
slice from to array = | |
fromFunction (z :. (to - from + 1)) (\(z :. ix) -> array ! (z :. (ix + from))) | |
where (z :. _) = extent array | |
cumsum :: | |
(FullShape uf ~ uf, | |
Slice uf, | |
Slice (SliceShape uf), | |
Shape uf, | |
Shape (SliceShape uf), | |
Elt a, | |
Num a) => | |
Array (uf :. Int) a -> Array (uf :. Int) a | |
cumsum array = traverse array id $ cumsum' array | |
where | |
cumsum' array f (sh :. outer) = | |
Repa.sumAll $ | |
Surf.slice 0 outer $ | |
Repa.slice array (sh :. All) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment