|
33 | 33 | * |
34 | 34 | */ |
35 | 35 |
|
36 | | -/* |
37 | | -#include <iostream> |
38 | | -#include <assert.h> |
39 | | -#include <time.h> |
40 | | -#include <chrono> |
41 | | -
|
42 | | -//command line |
43 | | -#include <tclap/CmdLine.h> |
44 | | -
|
45 | | -//this lib |
46 | | -#include <hydra/device/System.h> |
47 | | -#include <hydra/host/System.h> |
48 | | -#include <hydra/Function.h> |
49 | | -#include <hydra/Lambda.h> |
50 | | -#include <hydra/Random.h> |
51 | | -#include <hydra/Algorithm.h> |
52 | | -*/ |
53 | | -/*------------------------------------- |
54 | | - * Include classes from ROOT to fill |
55 | | - * and draw histograms and plots. |
56 | | - *------------------------------------- |
57 | | - */ |
58 | | -/* |
59 | | -#ifdef _ROOT_AVAILABLE_ |
60 | | -
|
61 | | -#include <TROOT.h> |
62 | | -#include <TH1D.h> |
63 | | -#include <TApplication.h> |
64 | | -#include <TCanvas.h> |
65 | | -
|
66 | | -#endif //_ROOT_AVAILABLE_ |
67 | | -
|
68 | | -
|
69 | | -
|
70 | | -int main(int argv, char** argc) |
71 | | -{ |
72 | | - size_t nentries = 0; |
73 | | -
|
74 | | - try { |
75 | | -
|
76 | | - TCLAP::CmdLine cmd("Command line arguments for ", '='); |
77 | | -
|
78 | | - TCLAP::ValueArg<size_t> EArg("n", "number-of-events","Number of events", true, 10e6, "size_t"); |
79 | | - cmd.add(EArg); |
80 | | -
|
81 | | - // Parse the argv array. |
82 | | - cmd.parse(argv, argc); |
83 | | -
|
84 | | - // Get the value parsed by each arg. |
85 | | - nentries = EArg.getValue(); |
86 | | -
|
87 | | - } |
88 | | - catch (TCLAP::ArgException &e) { |
89 | | - std::cerr << "error: " << e.error() << " for arg " << e.argId() |
90 | | - << std::endl; |
91 | | - } |
92 | | -
|
93 | | -
|
94 | | - //generator |
95 | | - hydra::Random<> |
96 | | - Generator( std::chrono::system_clock::now().time_since_epoch().count() ); |
97 | | -
|
98 | | -
|
99 | | - //device |
100 | | - //------------------------ |
101 | | -#ifdef _ROOT_AVAILABLE_ |
102 | | -
|
103 | | - TH1D hist_uniform_d("uniform_d", "Uniform", 100, -6.0, 6.0); |
104 | | - TH1D hist_gaussian_d("gaussian_d", "Gaussian", 100, -6.0, 6.0); |
105 | | - TH1D hist_exp_d("exponential_d", "Exponential", 100, 0.0, 5.0); |
106 | | - TH1D hist_bw_d("breit_wigner_d", "Breit-Wigner",100, 0.0, 5.0); |
107 | | -
|
108 | | -#endif //_ROOT_AVAILABLE_ |
109 | | -
|
110 | | - { |
111 | | - //1D device buffer |
112 | | - hydra::device::vector<double> data_d(nentries); |
113 | | - hydra::host::vector<double> data_h(nentries); |
114 | | -
|
115 | | - //------------------------------------------------------- |
116 | | - //uniform |
117 | | - Generator.Uniform(-5.0, 5.0, data_d.begin(), data_d.end()); |
118 | | - hydra::copy(data_d, data_h); |
119 | | -
|
120 | | - for(size_t i=0; i<10; i++) |
121 | | - std::cout << "< Random::Uniform > [" << i << "] :" << data_d[i] << std::endl; |
122 | | -
|
123 | | -#ifdef _ROOT_AVAILABLE_ |
124 | | - for(auto value : data_h) |
125 | | - hist_uniform_d.Fill( value); |
126 | | -#endif //_ROOT_AVAILABLE_ |
127 | | -
|
128 | | - //------------------------------------------------------- |
129 | | - //gaussian |
130 | | - Generator.Gauss(0.0, 1.0, data_d.begin(), data_d.end()); |
131 | | - hydra::copy(data_d, data_h); |
132 | | -
|
133 | | - for(size_t i=0; i<10; i++) |
134 | | - std::cout << "< Random::Gauss > [" << i << "] :" << data_d[i] << std::endl; |
135 | | -
|
136 | | -#ifdef _ROOT_AVAILABLE_ |
137 | | - for(auto value : data_d) |
138 | | - hist_gaussian_d.Fill( value); |
139 | | -#endif //_ROOT_AVAILABLE_ |
140 | | -
|
141 | | - //------------------------------------------------------- |
142 | | - //exponential |
143 | | - Generator.Exp(1.0, data_d); |
144 | | - hydra::copy(data_d, data_h); |
145 | | -
|
146 | | - for(size_t i=0; i<10; i++) |
147 | | - std::cout << "< Random::Exp > [" << i << "] :" << data_d[i] << std::endl; |
148 | | -
|
149 | | -#ifdef _ROOT_AVAILABLE_ |
150 | | - for(auto value : data_h) |
151 | | - hist_exp_d.Fill( value); |
152 | | -#endif //_ROOT_AVAILABLE_ |
153 | | -
|
154 | | - //------------------------------------------------------- |
155 | | - //breit-wigner |
156 | | - Generator.BreitWigner(2.0, 0.2, data_d.begin(), data_d.end()); |
157 | | - hydra::copy(data_d, data_h); |
158 | | -
|
159 | | - for(size_t i=0; i<10; i++) |
160 | | - std::cout << "< Random::BreitWigner > [" << i << "] :" << data_d[i] << std::endl; |
161 | | -
|
162 | | -#ifdef _ROOT_AVAILABLE_ |
163 | | - for(auto value : data_h) |
164 | | - hist_bw_d.Fill( value); |
165 | | -#endif //_ROOT_AVAILABLE_ |
166 | | - } |
167 | | -
|
168 | | -
|
169 | | -
|
170 | | -
|
171 | | -#ifdef _ROOT_AVAILABLE_ |
172 | | - TApplication *myapp=new TApplication("myapp",0,0); |
173 | | -
|
174 | | - //draw histograms |
175 | | - TCanvas canvas_d("canvas_d" ,"Distributions - Device", 1000, 1000); |
176 | | - canvas_d.Divide(2,2); |
177 | | - canvas_d.cd(1); hist_uniform_d.Draw("hist"); |
178 | | - canvas_d.cd(2); hist_gaussian_d.Draw("hist"); |
179 | | - canvas_d.cd(3); hist_exp_d.Draw("hist"); |
180 | | - canvas_d.cd(4); hist_bw_d.Draw("hist"); |
181 | | -
|
182 | | -
|
183 | | -
|
184 | | - myapp->Run(); |
185 | | -
|
186 | | -#endif //_ROOT_AVAILABLE_ |
187 | | -
|
188 | | - return 0; |
189 | | -
|
190 | | -
|
191 | | -
|
192 | | -} |
193 | | -
|
194 | | -*/ |
195 | 36 | #include <iostream> |
196 | 37 | #include <assert.h> |
197 | 38 | #include <time.h> |
@@ -262,17 +103,9 @@ auto data = hydra::device::vector< double>(10, .0); |
262 | 103 | //Parameters |
263 | 104 | auto mean = hydra::Parameter::Create("mean" ).Value(0.0); |
264 | 105 | auto sigma = hydra::Parameter::Create("sigma").Value(0.25); |
| 106 | + auto gauss = hydra::Gaussian<xvar>(mean, sigma); |
265 | 107 |
|
266 | | - auto gauss = hydra::Gaussian<xvar>(mean, sigma); |
267 | | - |
268 | | - for(auto x: data) |
269 | | - std::cout << ">>>>>>>>>"<<hydra::detail::is_valid_type_pack<hydra_thrust::tuple<xvar> , decltype(x) >::value << std::endl; |
270 | | - //x.dummy; |
271 | | - //std::cout << gauss(x) << std::endl; |
272 | | - |
273 | | - |
274 | | - |
275 | | - //LogNormal distribution |
| 108 | + //LogNormal distribution |
276 | 109 | auto lognormal = hydra::LogNormal<xvar>(mean, sigma); |
277 | 110 |
|
278 | 111 |
|
|
0 commit comments