4545// hydra
4646#include < hydra/host/System.h>
4747#include < hydra/device/System.h>
48- #include < hydra/Lambda.h>
4948#include < hydra/Parameter.h>
5049#include < hydra/RandomFill.h>
50+ #include < hydra/detail/Copy.inl>
51+
5152
5253// hydra functions
5354#include < hydra/functions/Gaussian.h>
@@ -100,7 +101,7 @@ int main(int argv, char** argc)
100101 }
101102
102103
103- auto data = hydra::device::vector<double >(nentries);
104+ auto data_d = hydra::device::vector<double >(nentries);
104105
105106
106107
@@ -161,10 +162,11 @@ int main(int argv, char** argc)
161162
162163
163164
164- hydra::fill_random (data , gauss);
165-
166- for (size_t i=0 ; i<10 ; ++i) std::cout << data[i] << std::endl;
165+ hydra::fill_random (data_d , gauss);
167166
167+ std::cout << std::endl<< " Generated data:" << std::endl;
168+ for (size_t i=0 ; i<10 ; ++i)
169+ std::cout << " [" << i << " ] :" << data_d[i] << std::endl;
168170
169171
170172#ifdef _ROOT_AVAILABLE_
@@ -182,36 +184,56 @@ int main(int argv, char** argc)
182184 hist_uniform.SetMinimum (0.0 );
183185
184186
185- for (auto x : data) hist_gauss.Fill ( x );
187+ // copying the values in the host and fill the ROOT histogram
188+
189+ auto data_h = hydra::host::vector<double >(nentries);
190+
191+ hydra::copy (data_d , data_h);
192+
193+ for (auto x : data_h) hist_gauss.Fill ( x );
194+
195+
196+
197+ // filling the container in the device
198+ // and copy back to the host also for the
199+ // other functors
200+
201+ hydra::fill_random (data_d , lognormal);
202+ hydra::copy (data_d , data_h);
203+ for (auto x : data_h) hist_lognormal.Fill ( x );
186204
187- /*
188- hydra::fill_random(data , lognormal );
189- for(auto x : data) hist_lognormal .Fill( x );
205+ hydra::fill_random (data_d , bigauss);
206+ hydra::copy (data_d , data_h );
207+ for (auto x : data_h) hist_bigauss .Fill ( x );
190208
191- hydra::fill_random(data , bigauss);
192- for(auto x : data) hist_bigauss.Fill( x );
209+ hydra::fill_random (data_d , exp);
210+ hydra::copy (data_d , data_h);
211+ for (auto x : data_h) hist_exp.Fill ( x );
193212
194- hydra::fill_random(data , exp);
195- for(auto x : data) hist_exp.Fill( x );
213+ hydra::fill_random (data_d , bw);
214+ hydra::copy (data_d , data_h);
215+ for (auto x : data_h) hist_bw.Fill ( x );
196216
197- hydra::fill_random(data , bw);
198- for(auto x : data) hist_bw.Fill( x );
217+ hydra::fill_random (data_d , chi2);
218+ hydra::copy (data_d , data_h);
219+ for (auto x : data_h) hist_chi.Fill ( x );
199220
200- hydra::fill_random(data , chi2);
201- for(auto x : data) hist_chi.Fill( x );
221+ hydra::fill_random (data_d , johnson_su);
222+ hydra::copy (data_d , data_h);
223+ for (auto x : data_h) hist_johnson_su.Fill ( x );
202224
203- hydra::fill_random(data , johnson_su);
204- for(auto x : data) hist_johnson_su.Fill( x );
225+ hydra::fill_random (data_d , uniform);
226+ hydra::copy (data_d , data_h);
227+ for (auto x : data_h) hist_uniform.Fill ( x );
205228
206- hydra::fill_random(data , uniform);
207- for(auto x : data) hist_uniform.Fill( x );
229+ hydra::fill_random (data_d , triangle);
230+ hydra::copy (data_d , data_h);
231+ for (auto x : data_h) hist_triangle.Fill ( x );
208232
209- hydra::fill_random(data , triangle);
210- for(auto x : data) hist_triangle.Fill( x );
233+ hydra::fill_random (data_d , trapezoid);
234+ hydra::copy (data_d , data_h);
235+ for (auto x : data_h) hist_trapezoid.Fill ( x );
211236
212- hydra::fill_random(data , trapezoid);
213- for(auto x : data) hist_trapezoid.Fill( x );
214- */
215237
216238
217239 TApplication *myapp=new TApplication (" myapp" ,0 ,0 );
0 commit comments