]> AND Private Git Repository - book_gpu.git/blob - BookGPU/Chapters/chapter5/code/ex3.cu
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
new
[book_gpu.git] / BookGPU / Chapters / chapter5 / code / ex3.cu
1 struct forward_euler\r
2 {\r
3         template <typename F, typename T, typename V>\r
4         void operator()(F fun, V& x, T t, T tend, T dt)\r
5         {\r
6                 V rhs(x);             // Initialize RHS vector\r
7                 while(t < tend)\r
8                 {\r
9                         if(tend-t < dt)\r
10                                 dt = tend-t;      // Adjust dt for last time step\r
11 \r
12                         (*fun)(t, x, rhs);  // Apply rhs function\r
13                         x.axpy(dt,rhs);     // Update stage\r
14                         t += dt;            // Next time step\r
15                 }\r
16         }\r
17 }