Skip to content

Instantly share code, notes, and snippets.

@jtobin
Created October 10, 2012 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtobin/3865601 to your computer and use it in GitHub Desktop.
Save jtobin/3865601 to your computer and use it in GitHub Desktop.
Incorporating parallelism
import Control.Monad.Par
-- Using the Par monad
logRosenbrockDensity :: [Double] -> Double
logRosenbrockDensity [x0, x1] = runPar $ do
[a, b] <- sequence [new, new]
fork $ put a (-100*(x1 - (x0^2))^2 / 20)
fork $ put b (-0.05*(1-x0)^2)
[a', b'] <- sequence [get a, get b]
return $ a' + b'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment