OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
vector_algebra_ofp.hpp
1//
2// Created by Abhinav Singh on 18.02.21.
3//
4
5#ifndef OPENFPM_PDATA_VECTOR_ALGEBRA_OFP_HPP
6#define OPENFPM_PDATA_VECTOR_ALGEBRA_OFP_HPP
7
8namespace boost {
9 namespace numeric {
10 namespace odeint {
11 /* It copy one element of the chunk for each property
12 *
13 */
14 template<typename vector_type,typename index_type,typename op_type>
16 {
17
18 vector_type &v;
19 index_type &p;
20 op_type &op;
28 __device__ __host__ inline for_each_prop1(vector_type &v,index_type &p,op_type &op)
29 :v(v),p(p),op(op)
30 {};
32 template<typename T>
33 __device__ __host__ inline void operator()(T& t) const
34 {
35
36 op(v.data.template get<T::value>().getVector().template get<0>(p));
37 }
38 };
39 template<typename S1,typename S2,typename index_type,typename op_type>
41 {
42
43 S1 &v1;
44 S2 &v2;
45 index_type &p;
46 op_type &op;
54 __device__ __host__ inline for_each_prop2(S1 &v1,S2 &v2,index_type &p,op_type &op)
55 :v1(v1),v2(v2),p(p),op(op)
56 {};
58 template<typename T>
59 __device__ __host__ inline void operator()(T& t) const
60 {
61 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p));
62 }
63 };
64
65 template<typename S1,typename S2,typename S3,typename index_type,typename op_type>
67 {
68
69 S1 &v1;
70 S2 &v2;
71 S3 &v3;
72 index_type &p;
73 op_type &op;
81 __device__ __host__ inline for_each_prop3(S1 &v1,S2 &v2,S3 &v3,index_type &p,op_type &op)
82 :v1(v1),v2(v2),v3(v3),p(p),op(op)
83 {};
85 template<typename T>
86 __device__ __host__ inline void operator()(T& t) const
87 {
88 //std::cout<<v1.data.template get<T::value>().getVector().size()<<":"<<v2.data.template get<T::value>().getVector().size()<<":"<<v3.data.template get<T::value>().getVector().size()<<std::endl;
89 //printf("v2:%f,v3:%f \n",v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p));
90 //printf("2\n");
91 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p));
92 //printf("v1:%f, v2:%f,v3:%f \n",v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p));
93
94 }
95 };
96 template<typename S1,typename S2,typename S3,typename S4,typename index_type,typename op_type>
98 {
99
100 S1 &v1;
101 S2 &v2;
102 S3 &v3;
103 S4 &v4;
104
105 index_type &p;
106 op_type &op;
114 __device__ __host__ inline for_each_prop4(S1 &v1,S2 &v2,S3 &v3,S4 &v4,index_type &p,op_type &op)
115 :v1(v1),v2(v2),v3(v3),v4(v4),p(p),op(op)
116 {};
118 template<typename T>
119 __device__ __host__ inline void operator()(T& t) const
120 {
121 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p));
122 }
123 };
124 template<typename S1,typename S2,typename S3,typename S4,typename S5,typename index_type,typename op_type>
126 {
127
128 S1 &v1;
129 S2 &v2;
130 S3 &v3;
131 S4 &v4;
132 S5 &v5;
133
134 index_type &p;
135 op_type &op;
143 __device__ __host__ inline for_each_prop5(S1 &v1,S2 &v2,S3 &v3,S4 &v4,S5 &v5,index_type &p,op_type &op)
144 :v1(v1),v2(v2),v3(v3),v4(v4),v5(v5),p(p),op(op)
145 {};
147 template<typename T>
148 __device__ __host__ inline void operator()(T& t) const
149 {
150 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p),v5.data.template get<T::value>().getVector().template get<0>(p));
151 }
152 };
153
154 template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename index_type,typename op_type>
156 {
157
158 S1 &v1;
159 S2 &v2;
160 S3 &v3;
161 S4 &v4;
162 S5 &v5;
163 S6 &v6;
164
165
166 index_type &p;
167 op_type &op;
175 __device__ __host__ inline for_each_prop6(S1 &v1,S2 &v2,S3 &v3,S4 &v4,S5 &v5,S6 &v6,index_type &p,op_type &op)
176 :v1(v1),v2(v2),v3(v3),v4(v4),v5(v5),v6(v6),p(p),op(op)
177 {};
179 template<typename T>
180 __device__ __host__ inline void operator()(T& t) const
181 {
182 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p),v5.data.template get<T::value>().getVector().template get<0>(p),v6.data.template get<T::value>().getVector().template get<0>(p));
183 }
184 };
185
186
187 template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename index_type,typename op_type>
189 {
190
191 S1 &v1;
192 S2 &v2;
193 S3 &v3;
194 S4 &v4;
195 S5 &v5;
196 S6 &v6;
197 S7 &v7;
198
199
200 index_type &p;
201 op_type &op;
209 __device__ __host__ inline for_each_prop7(S1 &v1,S2 &v2,S3 &v3,S4 &v4,S5 &v5,S6 &v6,S7 &v7,index_type &p,op_type &op)
210 :v1(v1),v2(v2),v3(v3),v4(v4),v5(v5),v6(v6),v7(v7),p(p),op(op)
211 {};
213 template<typename T>
214 __device__ __host__ inline void operator()(T& t) const
215 {
216 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p),v5.data.template get<T::value>().getVector().template get<0>(p),v6.data.template get<T::value>().getVector().template get<0>(p),v7.data.template get<T::value>().getVector().template get<0>(p));
217 }
218 };
219
220 template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8,typename index_type,typename op_type>
222 {
223
224 S1 &v1;
225 S2 &v2;
226 S3 &v3;
227 S4 &v4;
228 S5 &v5;
229 S6 &v6;
230 S7 &v7;
231 S8 &v8;
232
233
234 index_type &p;
235 op_type &op;
243 __device__ __host__ inline for_each_prop8(S1 &v1,S2 &v2,S3 &v3,S4 &v4,S5 &v5,S6 &v6,S7 &v7,S8 &v8,index_type &p,op_type &op)
244 :v1(v1),v2(v2),v3(v3),v4(v4),v5(v5),v6(v6),v7(v7),v8(v8),p(p),op(op)
245 {};
247 template<typename T>
248 __device__ __host__ inline void operator()(T& t) const
249 {
250 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p),v5.data.template get<T::value>().getVector().template get<0>(p),v6.data.template get<T::value>().getVector().template get<0>(p),v7.data.template get<T::value>().getVector().template get<0>(p),v8.data.template get<T::value>().getVector().template get<0>(p));
251 }
252 };
253
254 template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8, typename S9,typename index_type,typename op_type>
256 {
257
258 S1 &v1;
259 S2 &v2;
260 S3 &v3;
261 S4 &v4;
262 S5 &v5;
263 S6 &v6;
264 S7 &v7;
265 S8 &v8;
266 S9 &v9;
267
268
269 index_type &p;
270 op_type &op;
278 __device__ __host__ inline for_each_prop9(S1 &v1,S2 &v2,S3 &v3,S4 &v4,S5 &v5,S6 &v6,S7 &v7,S8 &v8,S9 &v9,index_type &p,op_type &op)
279 :v1(v1),v2(v2),v3(v3),v4(v4),v5(v5),v6(v6),v7(v7),v8(v8),v9(v9),p(p),op(op)
280 {};
282 template<typename T>
283 __device__ __host__ inline void operator()(T& t) const
284 {
285 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p),v5.data.template get<T::value>().getVector().template get<0>(p),v6.data.template get<T::value>().getVector().template get<0>(p),v7.data.template get<T::value>().getVector().template get<0>(p),v8.data.template get<T::value>().getVector().template get<0>(p),v9.data.template get<T::value>().getVector().template get<0>(p));
286 }
287 };
288
289 template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8, typename S9, typename S10,typename index_type,typename op_type>
291 {
292
293 S1 &v1;
294 S2 &v2;
295 S3 &v3;
296 S4 &v4;
297 S5 &v5;
298 S6 &v6;
299 S7 &v7;
300 S8 &v8;
301 S9 &v9;
302 S10 &v10;
303
304
305 index_type &p;
306 op_type &op;
314 __device__ __host__ inline for_each_prop10(S1 &v1,S2 &v2,S3 &v3,S4 &v4,S5 &v5,S6 &v6,S7 &v7,S8 &v8,S9 &v9,S10 &v10,index_type &p,op_type &op)
315 :v1(v1),v2(v2),v3(v3),v4(v4),v5(v5),v6(v6),v7(v7),v8(v8),v9(v9),v10(v10),p(p),op(op)
316 {};
318 template<typename T>
319 __device__ __host__ inline void operator()(T& t) const
320 {
321 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p),v5.data.template get<T::value>().getVector().template get<0>(p),v6.data.template get<T::value>().getVector().template get<0>(p),v7.data.template get<T::value>().getVector().template get<0>(p),v8.data.template get<T::value>().getVector().template get<0>(p),v9.data.template get<T::value>().getVector().template get<0>(p),v10.data.template get<T::value>().getVector().template get<0>(p));
322 }
323 };
324
325 template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8, typename S9, typename S10, typename S11,typename index_type,typename op_type>
327 {
328
329 S1 &v1;
330 S2 &v2;
331 S3 &v3;
332 S4 &v4;
333 S5 &v5;
334 S6 &v6;
335 S7 &v7;
336 S8 &v8;
337 S9 &v9;
338 S10 &v10;
339 S11 &v11;
340
341
342 index_type &p;
343 op_type &op;
351 __device__ __host__ inline for_each_prop11(S1 &v1,S2 &v2,S3 &v3,S4 &v4,S5 &v5,S6 &v6,S7 &v7,S8 &v8,S9 &v9,S10 &v10, S11 &v11,index_type &p,op_type &op)
352 :v1(v1),v2(v2),v3(v3),v4(v4),v5(v5),v6(v6),v7(v7),v8(v8),v9(v9),v10(v10),v11(v11),p(p),op(op)
353 {};
355 template<typename T>
356 __device__ __host__ inline void operator()(T& t) const
357 {
358 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p),v5.data.template get<T::value>().getVector().template get<0>(p),v6.data.template get<T::value>().getVector().template get<0>(p),v7.data.template get<T::value>().getVector().template get<0>(p),v8.data.template get<T::value>().getVector().template get<0>(p),v9.data.template get<T::value>().getVector().template get<0>(p),v10.data.template get<T::value>().getVector().template get<0>(p),v11.data.template get<T::value>().getVector().template get<0>(p));
359 }
360 };
361
362
363 template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8, typename S9, typename S10, typename S11, typename S12,typename index_type,typename op_type>
365 {
366
367 S1 &v1;
368 S2 &v2;
369 S3 &v3;
370 S4 &v4;
371 S5 &v5;
372 S6 &v6;
373 S7 &v7;
374 S8 &v8;
375 S9 &v9;
376 S10 &v10;
377 S11 &v11;
378 S12 &v12;
379
380
381 index_type &p;
382 op_type &op;
390 __device__ __host__ inline for_each_prop12(S1 &v1,S2 &v2,S3 &v3,S4 &v4,S5 &v5,S6 &v6,S7 &v7,S8 &v8,S9 &v9,S10 &v10, S11 &v11,S12 &v12,index_type &p,op_type &op)
391 :v1(v1),v2(v2),v3(v3),v4(v4),v5(v5),v6(v6),v7(v7),v8(v8),v9(v9),v10(v10),v11(v11), v12(v12),p(p),op(op)
392 {};
394 template<typename T>
395 __device__ __host__ inline void operator()(T& t) const
396 {
397 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p),v5.data.template get<T::value>().getVector().template get<0>(p),v6.data.template get<T::value>().getVector().template get<0>(p),v7.data.template get<T::value>().getVector().template get<0>(p),v8.data.template get<T::value>().getVector().template get<0>(p),v9.data.template get<T::value>().getVector().template get<0>(p),v10.data.template get<T::value>().getVector().template get<0>(p),v11.data.template get<T::value>().getVector().template get<0>(p),v12.data.template get<T::value>().getVector().template get<0>(p));
398 }
399 };
400
401
402 template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8, typename S9, typename S10, typename S11, typename S12, typename S13,typename index_type,typename op_type>
404 {
405
406 S1 &v1;
407 S2 &v2;
408 S3 &v3;
409 S4 &v4;
410 S5 &v5;
411 S6 &v6;
412 S7 &v7;
413 S8 &v8;
414 S9 &v9;
415 S10 &v10;
416 S11 &v11;
417 S12 &v12;
418 S13 &v13;
419
420
421 index_type &p;
422 op_type &op;
430 __device__ __host__ inline for_each_prop13(S1 &v1,S2 &v2,S3 &v3,S4 &v4,S5 &v5,S6 &v6,S7 &v7,S8 &v8,S9 &v9,S10 &v10, S11 &v11,S12 &v12,S13 &v13,index_type &p,op_type &op)
431 :v1(v1),v2(v2),v3(v3),v4(v4),v5(v5),v6(v6),v7(v7),v8(v8),v9(v9),v10(v10),v11(v11), v12(v12),v13(v13),p(p),op(op)
432 {};
434 template<typename T>
435 __device__ __host__ inline void operator()(T& t) const
436 {
437 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p),v5.data.template get<T::value>().getVector().template get<0>(p),v6.data.template get<T::value>().getVector().template get<0>(p),v7.data.template get<T::value>().getVector().template get<0>(p),v8.data.template get<T::value>().getVector().template get<0>(p),v9.data.template get<T::value>().getVector().template get<0>(p),v10.data.template get<T::value>().getVector().template get<0>(p),v11.data.template get<T::value>().getVector().template get<0>(p),v12.data.template get<T::value>().getVector().template get<0>(p),v13.data.template get<T::value>().getVector().template get<0>(p));
438 }
439 };
440
441
442 template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8, typename S9, typename S10, typename S11, typename S12, typename S13, typename S14,typename index_type,typename op_type>
444 {
445
446 S1 &v1;
447 S2 &v2;
448 S3 &v3;
449 S4 &v4;
450 S5 &v5;
451 S6 &v6;
452 S7 &v7;
453 S8 &v8;
454 S9 &v9;
455 S10 &v10;
456 S11 &v11;
457 S12 &v12;
458 S13 &v13;
459 S14 &v14;
460
461
462 index_type &p;
463 op_type &op;
471 __device__ __host__ inline for_each_prop14(S1 &v1,S2 &v2,S3 &v3,S4 &v4,S5 &v5,S6 &v6,S7 &v7,S8 &v8,S9 &v9,S10 &v10, S11 &v11,S12 &v12,S13 &v13,S14 &v14,index_type &p,op_type &op)
472 :v1(v1),v2(v2),v3(v3),v4(v4),v5(v5),v6(v6),v7(v7),v8(v8),v9(v9),v10(v10),v11(v11), v12(v12),v13(v13),v14(v14),p(p),op(op)
473 {};
475 template<typename T>
476 __device__ __host__ inline void operator()(T& t) const
477 {
478 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p),v5.data.template get<T::value>().getVector().template get<0>(p),v6.data.template get<T::value>().getVector().template get<0>(p),v7.data.template get<T::value>().getVector().template get<0>(p),v8.data.template get<T::value>().getVector().template get<0>(p),v9.data.template get<T::value>().getVector().template get<0>(p),v10.data.template get<T::value>().getVector().template get<0>(p),v11.data.template get<T::value>().getVector().template get<0>(p),v12.data.template get<T::value>().getVector().template get<0>(p),v13.data.template get<T::value>().getVector().template get<0>(p),v14.data.template get<T::value>().getVector().template get<0>(p));
479 }
480 };
481
482
483 template<typename S1,typename S2,typename S3,typename S4,typename S5,typename S6,typename S7,typename S8, typename S9, typename S10, typename S11, typename S12, typename S13, typename S14, typename S15,typename index_type,typename op_type>
485 {
486
487 S1 &v1;
488 S2 &v2;
489 S3 &v3;
490 S4 &v4;
491 S5 &v5;
492 S6 &v6;
493 S7 &v7;
494 S8 &v8;
495 S9 &v9;
496 S10 &v10;
497 S11 &v11;
498 S12 &v12;
499 S13 &v13;
500 S14 &v14;
501 S15 &v15;
502
503
504 index_type &p;
505 op_type &op;
513 __device__ __host__ inline for_each_prop15(S1 &v1,S2 &v2,S3 &v3,S4 &v4,S5 &v5,S6 &v6,S7 &v7,S8 &v8,S9 &v9,S10 &v10, S11 &v11,S12 &v12,S13 &v13,S14 &v14,S15 &v15,index_type &p,op_type &op)
514 :v1(v1),v2(v2),v3(v3),v4(v4),v5(v5),v6(v6),v7(v7),v8(v8),v9(v9),v10(v10),v11(v11), v12(v12),v13(v13),v14(v14),v15(v15),p(p),op(op)
515 {};
517 template<typename T>
518 __device__ __host__ inline void operator()(T& t) const
519 {
520 op(v1.data.template get<T::value>().getVector().template get<0>(p),v2.data.template get<T::value>().getVector().template get<0>(p),v3.data.template get<T::value>().getVector().template get<0>(p),v4.data.template get<T::value>().getVector().template get<0>(p),v5.data.template get<T::value>().getVector().template get<0>(p),v6.data.template get<T::value>().getVector().template get<0>(p),v7.data.template get<T::value>().getVector().template get<0>(p),v8.data.template get<T::value>().getVector().template get<0>(p),v9.data.template get<T::value>().getVector().template get<0>(p),v10.data.template get<T::value>().getVector().template get<0>(p),v11.data.template get<T::value>().getVector().template get<0>(p),v12.data.template get<T::value>().getVector().template get<0>(p),v13.data.template get<T::value>().getVector().template get<0>(p),v14.data.template get<T::value>().getVector().template get<0>(p),v15.data.template get<T::value>().getVector().template get<0>(p));
521 }
522 };
523
524/*
525 * This class template has to be overload in order to call vector_space_algebra::norm_inf
526 */
527 // template< class State, class Enabler = void > struct vector_space_norm_inf;
528
529/*
530 * Example: instantiation for sole doubles and complex
531 */
532/* template<>
533 struct vector_space_norm_inf< double >
534 {
535 typedef double result_type;
536 double operator()( double x ) const
537 {
538 using std::abs;
539 return abs(x);
540 }
541 };
542
543 template<>
544 struct vector_space_norm_inf< float >
545 {
546 typedef float result_type;
547 result_type operator()( float x ) const
548 {
549 using std::abs;
550 return abs(x);
551 }
552 };
553
554 template< typename T >
555 struct vector_space_norm_inf< std::complex<T> >
556 {
557 typedef T result_type;
558 result_type operator()( std::complex<T> x ) const
559 {
560 using std::abs;
561 return abs( x );
562 }
563 };*/
564
565 template<typename S1,typename S2>
567 S1 &v1;
568 S2 &v2;
576 inline for_each_prop_resize(S1 &v1,S2 &v2)
577 :v1(v1),v2(v2)
578 {};
580 template<typename T>
581 inline void operator()(T& t) const
582 {
583 v1.data.template get<T::value>().getVector().resize(v2.data.template get<T::value>().getVector().size());
584 }
585 };
586
587
588
590 {
591 template< class S1 , class Op >
592 static void for_each1( S1 &s1 , Op op )
593 {
594
595 // ToDo : build checks, that the +-*/ operators are well defined
596 auto it=s1.data.template get<0>().getVector().getIterator();
597 while(it.isNext()){
598 auto p=it.get();
599 //converting to boost vector ids.
601 //creating an iterator on v_ids[0] [1] [2]
602 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
603
604 ++it;
605 }
606 }
607
608
609
610 template< class S1 , class S2 , class Op >
611 static void for_each2( S1 &s1 , S2 &s2 , Op op )
612 {
613 for_each_prop_resize<S1,S2> the_resize(s1,s2);
614 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
615 //s1.data.template get<0>().getVector().resize(s2.data.template get<0>().getVector().size());
616 // ToDo : build checks, that the +-*/ operators are well defined
617 auto it=s1.data.template get<0>().getVector().getIterator();
618 while(it.isNext()){
619 auto p=it.get();
620 //converting to boost vector ids.
622 //creating an iterator on v_ids[0] [1] [2]
623 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
624
625 ++it;
626 }
627 }
628
629
630 template< class S1 , class S2 , class S3 , class Op >
631 static void for_each3( S1 &s1 , S2 &s2 , S3 &s3 , Op op )
632 {
633
634//
635 for_each_prop_resize<S1,S2> the_resize(s1,s2);
636 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(the_resize);
637 // ToDo : build checks, that the +-*/ operators are well defined
638 auto it=s1.data.template get<0>().getVector().getIterator();
639
640 while(it.isNext()){
641 auto p=it.get();
642 //converting to boost vector ids.
644 //creating an iterator on v_ids[0] [1] [2]
645 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
646
647 ++it;
648 }
649 }
650
651
652
653
654 template< class S1 , class S2 , class S3 , class S4 , class Op >
655 static void for_each4( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , Op op )
656 {
657 for_each_prop_resize<S1,S2> the_resize(s1,s2);
658 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
659 // ToDo : build checks, that the +-*/ operators are well defined
660 auto it=s1.data.template get<0>().getVector().getIterator();
661 while(it.isNext()){
662 auto p=it.get();
663 //converting to boost vector ids.
665 //creating an iterator on v_ids[0] [1] [2]
666 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
667
668 ++it;
669 }
670 }
671
672
673
674
675 template< class S1 , class S2 , class S3 , class S4,class S5 , class Op >
676 static void for_each5( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5 , Op op )
677 {
678 for_each_prop_resize<S1,S2> the_resize(s1,s2);
679 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
680 // ToDo : build checks, that the +-*/ operators are well defined
681 auto it=s1.data.template get<0>().getVector().getIterator();
682 while(it.isNext()){
683 auto p=it.get();
684 //converting to boost vector ids.
686 //creating an iterator on v_ids[0] [1] [2]
687 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
688
689 ++it;
690 }
691 }
692
693 template< class S1 , class S2 , class S3 , class S4,class S5,class S6 , class Op >
694 static void for_each6( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6 , Op op )
695 {
696 for_each_prop_resize<S1,S2> the_resize(s1,s2);
697 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
698 // ToDo : build checks, that the +-*/ operators are well defined
699 auto it=s1.data.template get<0>().getVector().getIterator();
700 while(it.isNext()){
701 auto p=it.get();
702 //converting to boost vector ids.
704 //creating an iterator on v_ids[0] [1] [2]
705 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
706
707 ++it;
708 }
709 }
710
711 template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7, class Op >
712 static void for_each7( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7 , Op op )
713 {
714 for_each_prop_resize<S1,S2> the_resize(s1,s2);
715 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
716 // ToDo : build checks, that the +-*/ operators are well defined
717 auto it=s1.data.template get<0>().getVector().getIterator();
718 while(it.isNext()){
719 auto p=it.get();
720 //converting to boost vector ids.
722 //creating an iterator on v_ids[0] [1] [2]
723 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
724
725 ++it;
726 }
727 }
728
729 template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class Op >
730 static void for_each8( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8 , Op op )
731 {
732 for_each_prop_resize<S1,S2> the_resize(s1,s2);
733 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
734 // ToDo : build checks, that the +-*/ operators are well defined
735 auto it=s1.data.template get<0>().getVector().getIterator();
736 while(it.isNext()){
737 auto p=it.get();
738 //converting to boost vector ids.
740 //creating an iterator on v_ids[0] [1] [2]
741 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
742
743 ++it;
744 }
745 }
746
747 template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class Op >
748 static void for_each9( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9 , Op op )
749 {
750 for_each_prop_resize<S1,S2> the_resize(s1,s2);
751 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
752 // ToDo : build checks, that the +-*/ operators are well defined
753 auto it=s1.data.template get<0>().getVector().getIterator();
754 while(it.isNext()){
755 auto p=it.get();
756 //converting to boost vector ids.
758 //creating an iterator on v_ids[0] [1] [2]
759 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
760
761 ++it;
762 }
763 }
764
765 template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class Op >
766 static void for_each10( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9 , S10 &s10, Op op )
767 {
768 for_each_prop_resize<S1,S2> the_resize(s1,s2);
769 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
770 // ToDo : build checks, that the +-*/ operators are well defined
771 auto it=s1.data.template get<0>().getVector().getIterator();
772 while(it.isNext()){
773 auto p=it.get();
774 //converting to boost vector ids.
776 //creating an iterator on v_ids[0] [1] [2]
777 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
778
779 ++it;
780 }
781 }
782
783
784 template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class S11, class Op >
785 static void for_each11( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9 , S10 &s10,S11 &s11, Op op )
786 {
787 for_each_prop_resize<S1,S2> the_resize(s1,s2);
788 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
789 // ToDo : build checks, that the +-*/ operators are well defined
790 auto it=s1.data.template get<0>().getVector().getIterator();
791 while(it.isNext()){
792 auto p=it.get();
793 //converting to boost vector ids.
795 //creating an iterator on v_ids[0] [1] [2]
796 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
797
798 ++it;
799 }
800 }
801
802 template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class S11, class S12, class Op >
803 static void for_each12( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9 , S10 &s10,S11 &s11,S12 &s12, Op op )
804 {
805 for_each_prop_resize<S1,S2> the_resize(s1,s2);
806 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
807 // ToDo : build checks, that the +-*/ operators are well defined
808 auto it=s1.data.template get<0>().getVector().getIterator();
809 while(it.isNext()){
810 auto p=it.get();
811 //converting to boost vector ids.
813 //creating an iterator on v_ids[0] [1] [2]
814 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
815
816 ++it;
817 }
818 }
819
820 template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class S11, class S12, class S13, class Op >
821 static void for_each13( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9 , S10 &s10,S11 &s11,S12 &s12,S13 &s13, Op op )
822 {
823 for_each_prop_resize<S1,S2> the_resize(s1,s2);
824 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
825 // ToDo : build checks, that the +-*/ operators are well defined
826 auto it=s1.data.template get<0>().getVector().getIterator();
827 while(it.isNext()){
828 auto p=it.get();
829 //converting to boost vector ids.
830 for_each_prop13<S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,typename S1::index_type,Op> cp(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,p,op);
831 //creating an iterator on v_ids[0] [1] [2]
832 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
833
834 ++it;
835 }
836 }
837
838
839 template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class S11, class S12, class S13, class S14, class Op >
840 static void for_each14( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9, S10 &s10,S11 &s11,S12 &s12,S13 &s13,S14 &s14, Op op )
841 {
842 for_each_prop_resize<S1,S2> the_resize(s1,s2);
843 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
844 // ToDo : build checks, that the +-*/ operators are well defined
845 auto it=s1.data.template get<0>().getVector().getIterator();
846 while(it.isNext()){
847 auto p=it.get();
848 //converting to boost vector ids.
849 for_each_prop14<S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,typename S1::index_type,Op> cp(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,p,op);
850 //creating an iterator on v_ids[0] [1] [2]
851 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
852
853 ++it;
854 }
855 }
856
857 template< class S1 , class S2 , class S3 , class S4,class S5,class S6 ,class S7,class S8, class S9, class S10, class S11, class S12, class S13, class S14, class S15, class Op >
858 static void for_each15( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4,S5 &s5,S6 &s6,S7 &s7,S8 &s8, S9 &s9, S10 &s10,S11 &s11,S12 &s12,S13 &s13,S14 &s14,S15 &s15, Op op )
859 {
860 for_each_prop_resize<S1,S2> the_resize(s1,s2);
861 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s1.data)::max_prop>>(the_resize);
862 // ToDo : build checks, that the +-*/ operators are well defined
863 auto it=s1.data.template get<0>().getVector().getIterator();
864 while(it.isNext()){
865 auto p=it.get();
866 //converting to boost vector ids.
867 for_each_prop15<S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,S15,typename S1::index_type,Op> cp(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,p,op);
868 //creating an iterator on v_ids[0] [1] [2]
869 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype( s1.data)::max_prop>>(cp);
870
871 ++it;
872 }
873 }
874
875
876
877
878
879
880 template<typename vector_type,typename index_type,typename norm_result_type>
882 {
883 const vector_type &v;
884 index_type &p;
885 norm_result_type &n;
893 inline for_each_norm(const vector_type &v,index_type &p,norm_result_type &n)
894 :v(v),p(p),n(n)
895 {};
897 template<typename T>
898 inline void operator()(T& t) const
899 {
900 if(fabs(v.data.template get<T::value>().getVector().template get<0>(p)) > n)
901 {
902 n=fabs(v.data.template get<T::value>().getVector().template get<0>(p));
903 }
904
905 }
906 };
907
908 template< class S >
909 static typename boost::numeric::odeint::vector_space_norm_inf< S >::result_type norm_inf( const S &s )
910 {
911 typename boost::numeric::odeint::vector_space_norm_inf< S >::result_type n=0;
912 auto it=s.data.template get<0>().getVector().getIterator();
913 while(it.isNext()){
914 auto p=it.get();
915 //converting to boost vector ids.
916 for_each_norm<S,typename S::index_type,typename boost::numeric::odeint::vector_space_norm_inf< S >::result_type> cp(s,p,n);
917 //creating an iterator on v_ids[0] [1] [2]
918 boost::mpl::for_each_ref<boost::mpl::range_c<int,0,decltype(s.data)::max_prop>>(cp);
919
920 ++it;
921 }
922 auto &v_cl = create_vcluster();
923 v_cl.max(n);
924 v_cl.execute();
925 //std::max();
926 //std::cout<<n<<std::endl;
927 return n;
928 }
929 };
930
931
932
933 } // odeint
934} // numeric
935} // boost
936
937
938
939
940
941
942
943
944#endif //OPENFPM_PDATA_VECTOR_ALGEBRA_OFP_HPP
Distributed vector.
__device__ __host__ for_each_prop10(S1 &v1, S2 &v2, S3 &v3, S4 &v4, S5 &v5, S6 &v6, S7 &v7, S8 &v8, S9 &v9, S10 &v10, index_type &p, op_type &op)
constructor
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ for_each_prop11(S1 &v1, S2 &v2, S3 &v3, S4 &v4, S5 &v5, S6 &v6, S7 &v7, S8 &v8, S9 &v9, S10 &v10, S11 &v11, index_type &p, op_type &op)
constructor
__device__ __host__ for_each_prop12(S1 &v1, S2 &v2, S3 &v3, S4 &v4, S5 &v5, S6 &v6, S7 &v7, S8 &v8, S9 &v9, S10 &v10, S11 &v11, S12 &v12, index_type &p, op_type &op)
constructor
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ for_each_prop13(S1 &v1, S2 &v2, S3 &v3, S4 &v4, S5 &v5, S6 &v6, S7 &v7, S8 &v8, S9 &v9, S10 &v10, S11 &v11, S12 &v12, S13 &v13, index_type &p, op_type &op)
constructor
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ for_each_prop14(S1 &v1, S2 &v2, S3 &v3, S4 &v4, S5 &v5, S6 &v6, S7 &v7, S8 &v8, S9 &v9, S10 &v10, S11 &v11, S12 &v12, S13 &v13, S14 &v14, index_type &p, op_type &op)
constructor
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ for_each_prop15(S1 &v1, S2 &v2, S3 &v3, S4 &v4, S5 &v5, S6 &v6, S7 &v7, S8 &v8, S9 &v9, S10 &v10, S11 &v11, S12 &v12, S13 &v13, S14 &v14, S15 &v15, index_type &p, op_type &op)
constructor
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ for_each_prop1(vector_type &v, index_type &p, op_type &op)
constructor
__device__ __host__ for_each_prop2(S1 &v1, S2 &v2, index_type &p, op_type &op)
constructor
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ for_each_prop3(S1 &v1, S2 &v2, S3 &v3, index_type &p, op_type &op)
constructor
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ for_each_prop4(S1 &v1, S2 &v2, S3 &v3, S4 &v4, index_type &p, op_type &op)
constructor
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ for_each_prop5(S1 &v1, S2 &v2, S3 &v3, S4 &v4, S5 &v5, index_type &p, op_type &op)
constructor
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ for_each_prop6(S1 &v1, S2 &v2, S3 &v3, S4 &v4, S5 &v5, S6 &v6, index_type &p, op_type &op)
constructor
__device__ __host__ for_each_prop7(S1 &v1, S2 &v2, S3 &v3, S4 &v4, S5 &v5, S6 &v6, S7 &v7, index_type &p, op_type &op)
constructor
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
__device__ __host__ for_each_prop8(S1 &v1, S2 &v2, S3 &v3, S4 &v4, S5 &v5, S6 &v6, S7 &v7, S8 &v8, index_type &p, op_type &op)
constructor
__device__ __host__ for_each_prop9(S1 &v1, S2 &v2, S3 &v3, S4 &v4, S5 &v5, S6 &v6, S7 &v7, S8 &v8, S9 &v9, index_type &p, op_type &op)
constructor
__device__ __host__ void operator()(T &t) const
It call the copy function for each property.
void operator()(T &t) const
It call the copy function for each property.
void operator()(T &t) const
It call the copy function for each property.
for_each_norm(const vector_type &v, index_type &p, norm_result_type &n)
constructor