Haskell集成函数中的并行性

时间:2019-04-24 14:24:05

标签: haskell parallel-processing

如何在辛普森函数上正确引入并行性?

simpsonIntegrate f a b n =
   parMap rseq( (s + s4 + s2) * h / 6)
    where
        s  = f a + f b
        s4 = 4 * (sum . map f $ [a + h/2, a + h/2 + h .. b - h/2])
        s2 = 2 * (sum . map f $ [a + h,   a + 2*h     .. b - h])
        h  = (b - a) / n

0 个答案:

没有答案