Hello Bulat, Bulat Ziganshin wrote:
> the fastest way to calculate dot product is: > > dot :: STUArray s Int Double -> STUArray s Int Double -> ST s Double > dot x y = do > let (l,r) = bounds x > cycle sum i | sum `seq` i>r = return sum > cycle sum i = do xi <- readArray x i > yi <- readArray y i > cycle (sum+xi*yi) (i+1) > cycle 0 l That is a nice implementation. In fact, creating uninitialized arrays with newArray_ and then setting all its elements to some value using a function similar to this one is dramatically faster than creating initialized arrays with newArray. Gunnar. _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users