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.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to