How make method monte carlo in algorithm parallel in c++? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

How make method monte carlo in algorithm parallel in c++?

i need you help pls.

27th Sep 2017, 6:15 PM
Anderson colcas
Anderson colcas - avatar
1 Resposta
+ 1
e.g. you want to calculate integral[0,1]dx sin(x). monte carlo now gives integral[0,1]dx sin(x) ~SUM[i=0,i<N] (1-0)/N sin(x_i), with N where you can split the right hand side into e.g. 2 sums which you can calculate separately (via MPI, etc...) and add afterwards (1-0)/N (SUM[i=0,i<m] sin(x_i) + SUM[i=m,i<N] sin(x_i)) working cpp example (not sure why not working here at playground, maybe missing pthread flag etc.) https://code.sololearn.com/cjQ8hA94GwpL/#cpp
6th Oct 2017, 11:33 PM
---
--- - avatar