[Haskell-cafe] poor perfomance of indexU in uvector package
Felipe Lessa
felipe.lessa at gmail.com
Sun Nov 15 09:50:48 EST 2009
On Sun, Nov 15, 2009 at 03:00:34PM +0300, Alexey Khudyakov wrote:
> Naive implementation using lists and index lookup.
> 2.15 second for 200*200 array
> > sliceXlist :: Int -> UArr Double -> [UArr Double]
> > sliceXlist n a = map mkSlice [0 .. n-1]
> > where
> > mkSlice x = toU $ map (\y -> indexU a (x + y*n)) [0 .. n-1]
Have you tried something like
mkSlice x = mapU (\y -> indexU a (x + y*n)) $ enumFromToU 0 (n-1)
I guess it should be a lot faster :). Also, I would recomend
using criterion. Another implementation you may try is
a' = mapU (\(i :*: x) -> (i `mod` n) :*: x) (indexedU a)
mkSlice j = fstU $ filterU (\(i :*: x) -> i == j) a'
HTH,
--
Felipe.
More information about the Haskell-Cafe
mailing list