OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
TSVMetaDot.h
Go to the documentation of this file.
1// -*- C++ -*-
2/***************************************************************************
3 *
4 * The IPPL Framework
5 *
6 *
7 * Visit http://people.web.psi.ch/adelmann/ for more details
8 *
9 ***************************************************************************/
10
11#ifndef TSV_META_DOT_H
12#define TSV_META_DOT_H
13
15//
16// Definition of the struct TSV_MetaDot.
17//
19
20template<class T1, class T2> struct TSV_MetaDot {};
21
23//
24// Specializations for Vektor dot Vektor
25//
27
28template<class T1, class T2, unsigned D>
29struct TSV_MetaDot< Vektor<T1,D> , Vektor<T2,D> >
30{
32 inline static T0
33 apply(const Vektor<T1,D>& lhs, const Vektor<T2,D>& rhs) {
34 T0 dot = lhs[0]*rhs[0];
35 for (unsigned d=1; d<D; ++d)
36 dot += lhs[d]*rhs[d];
37 return dot;
38 }
39};
40
41template<class T1, class T2>
42struct TSV_MetaDot< Vektor<T1,1> , Vektor<T2,1> >
43{
45 inline static T0
46 apply(const Vektor<T1,1>& lhs, const Vektor<T2,1>& rhs) {
47 return lhs[0]*rhs[0];
48 }
49};
50
51template<class T1, class T2>
52struct TSV_MetaDot< Vektor<T1,2> , Vektor<T2,2> >
53{
55 inline static T0
56 apply(const Vektor<T1,2>& lhs, const Vektor<T2,2>& rhs) {
57 return lhs[0]*rhs[0] + lhs[1]*rhs[1];
58 }
59};
60
61template<class T1, class T2>
62struct TSV_MetaDot< Vektor<T1,3> , Vektor<T2,3> >
63{
65 inline static T0
66 apply(const Vektor<T1,3>& lhs, const Vektor<T2,3>& rhs) {
67 return lhs[0]*rhs[0] + lhs[1]*rhs[1] + lhs[2]*rhs[2];
68 }
69};
70
72//
73// Specializations for Tenzor dot Tenzor
74//
76
77template<class T1, class T2, unsigned D>
78struct TSV_MetaDot< Tenzor<T1,D> , Tenzor<T2,D> >
79{
81 inline static Tenzor<T0,D>
82 apply(const Tenzor<T1,D>& lhs, const Tenzor<T2,D>& rhs) {
84 for (unsigned int i=0; i<D; ++i)
85 for (unsigned int j=0; j<D; ++j) {
86 T0 sum = lhs(i,0) * rhs(0,j);
87 for (unsigned int k=1; k<D; ++k)
88 sum += lhs(i,k) * rhs(k,j);
89 dot(i,j) = sum;
90 }
91 return dot;
92 }
93};
94
95template<class T1, class T2>
96struct TSV_MetaDot< Tenzor<T1,1> , Tenzor<T2,1> >
97{
99 inline static Tenzor<T0,1>
100 apply(const Tenzor<T1,1>& lhs, const Tenzor<T2,1>& rhs) {
101 return Tenzor<T0,1>(lhs[0]*rhs[0]);
102 }
103};
104
105template<class T1, class T2>
106struct TSV_MetaDot< Tenzor<T1,2> , Tenzor<T2,2> >
107{
109 inline static Tenzor<T0,2>
110 apply(const Tenzor<T1,2>& lhs, const Tenzor<T2,2>& rhs) {
111 return Tenzor<T0,2>(lhs(0,0)*rhs(0,0) + lhs(0,1)*rhs(1,0),
112 lhs(0,0)*rhs(0,1) + lhs(0,1)*rhs(1,1),
113 lhs(1,0)*rhs(0,0) + lhs(1,1)*rhs(1,0),
114 lhs(1,0)*rhs(0,1) + lhs(1,1)*rhs(1,1));
115 }
116};
117
118template<class T1, class T2>
119struct TSV_MetaDot< Tenzor<T1,3> , Tenzor<T2,3> >
120{
122 inline static Tenzor<T0,3>
123 apply(const Tenzor<T1,3>& lhs, const Tenzor<T2,3>& rhs) {
124 return Tenzor<T0,3>( lhs(0,0)*rhs(0,0) + lhs(0,1)*rhs(1,0) + lhs(0,2)*rhs(2,0) ,
125 lhs(0,0)*rhs(0,1) + lhs(0,1)*rhs(1,1) + lhs(0,2)*rhs(2,1) ,
126 lhs(0,0)*rhs(0,2) + lhs(0,1)*rhs(1,2) + lhs(0,2)*rhs(2,2) ,
127 lhs(1,0)*rhs(0,0) + lhs(1,1)*rhs(1,0) + lhs(1,2)*rhs(2,0) ,
128 lhs(1,0)*rhs(0,1) + lhs(1,1)*rhs(1,1) + lhs(1,2)*rhs(2,1) ,
129 lhs(1,0)*rhs(0,2) + lhs(1,1)*rhs(1,2) + lhs(1,2)*rhs(2,2) ,
130 lhs(2,0)*rhs(0,0) + lhs(2,1)*rhs(1,0) + lhs(2,2)*rhs(2,0) ,
131 lhs(2,0)*rhs(0,1) + lhs(2,1)*rhs(1,1) + lhs(2,2)*rhs(2,1) ,
132 lhs(2,0)*rhs(0,2) + lhs(2,1)*rhs(1,2) + lhs(2,2)*rhs(2,2) );
133
134 }
135};
136
138//
139// Specializations for SymTenzor dot SymTenzor
140//
142
143template<class T1, class T2, unsigned D>
144struct TSV_MetaDot< SymTenzor<T1,D> , SymTenzor<T2,D> >
145{
147 inline static Tenzor<T0,D>
148 apply(const SymTenzor<T1,D>& lhs, const SymTenzor<T2,D>& rhs) {
150 for (unsigned int i=0; i<D; ++i)
151 for (unsigned int j=i; j<D; ++j) {
152 T0 sum = lhs.HL(i,0) * rhs.HL(j,0);
153 unsigned int k=1;
154 for ( ; k<i; ++k )
155 sum += lhs.HL(i,k) * rhs.HL(j,k);
156 for ( ; k<j; ++k )
157 sum += lhs.HL(k,i) * rhs.HL(j,k);
158 for ( ; k<D; ++k )
159 sum += lhs.HL(k,i) * rhs.HL(k,j);
160 dot(i,j) = sum;
161 }
162 return dot;
163 }
164};
165
166template<class T1, class T2>
167struct TSV_MetaDot< SymTenzor<T1,1> , SymTenzor<T2,1> >
168{
170 inline static Tenzor<T0,1>
171 apply(const SymTenzor<T1,1>& lhs, const SymTenzor<T2,1>& rhs) {
172 return Tenzor<T0,1>(lhs[0]*rhs[0]);
173 }
174};
175
176template<class T1, class T2>
177struct TSV_MetaDot< SymTenzor<T1,2> , SymTenzor<T2,2> >
178{
180 inline static Tenzor<T0,2>
181 apply(const SymTenzor<T1,2>& lhs, const SymTenzor<T2,2>& rhs) {
182 return Tenzor<T0,2>(lhs(0,0)*rhs(0,0) + lhs(0,1)*rhs(1,0),
183 lhs(0,0)*rhs(0,1) + lhs(0,1)*rhs(1,1),
184 lhs(1,0)*rhs(0,0) + lhs(1,1)*rhs(1,0),
185 lhs(1,0)*rhs(0,1) + lhs(1,1)*rhs(1,1));
186 }
187};
188
189template<class T1, class T2>
190struct TSV_MetaDot< SymTenzor<T1,3> , SymTenzor<T2,3> >
191{
193 inline static Tenzor<T0,3>
194 apply(const SymTenzor<T1,3>& lhs, const SymTenzor<T2,3>& rhs) {
195 return
196 Tenzor<T0,3>(lhs(0,0)*rhs(0,0) + lhs(0,1)*rhs(1,0) + lhs(0,2)*rhs(2,0) ,
197 lhs(0,0)*rhs(0,1) + lhs(0,1)*rhs(1,1) + lhs(0,2)*rhs(2,1) ,
198 lhs(0,0)*rhs(0,2) + lhs(0,1)*rhs(1,2) + lhs(0,2)*rhs(2,2) ,
199 lhs(1,0)*rhs(0,0) + lhs(1,1)*rhs(1,0) + lhs(1,2)*rhs(2,0) ,
200 lhs(1,0)*rhs(0,1) + lhs(1,1)*rhs(1,1) + lhs(1,2)*rhs(2,1) ,
201 lhs(1,0)*rhs(0,2) + lhs(1,1)*rhs(1,2) + lhs(1,2)*rhs(2,2) ,
202 lhs(2,0)*rhs(0,0) + lhs(2,1)*rhs(1,0) + lhs(2,2)*rhs(2,0) ,
203 lhs(2,0)*rhs(0,1) + lhs(2,1)*rhs(1,1) + lhs(2,2)*rhs(2,1) ,
204 lhs(2,0)*rhs(0,2) + lhs(2,1)*rhs(1,2) + lhs(2,2)*rhs(2,2));
205
206 }
207};
208
210//
211// Specializations for Tenzor dot Vektor
212//
214
215template<class T1, class T2, unsigned D>
216struct TSV_MetaDot< Tenzor<T1,D> , Vektor<T2,D> >
217{
219 inline static Vektor<T0,D>
220 apply(const Tenzor<T1,D>& lhs, const Vektor<T2,D>& rhs) {
222 for (unsigned int i=0; i<D; ++i) {
223 T0 sum = lhs(i,0)*rhs[0];
224 for (unsigned int j=1; j<D; ++j)
225 sum += lhs(i,j)*rhs[j];
226 ret[i] = sum;
227 }
228 return ret;
229 }
230};
231
232
233template<class T1, class T2>
234struct TSV_MetaDot< Tenzor<T1,1> , Vektor<T2,1> >
235{
237 inline static Vektor<T0,1>
238 apply(const Tenzor<T1,1>& lhs, const Vektor<T2,1>& rhs) {
239 return Vektor<T0,1>( lhs[0]*rhs[0] );
240 }
241};
242
243template<class T1, class T2>
244struct TSV_MetaDot< Tenzor<T1,2> , Vektor<T2,2> >
245{
247 inline static Vektor<T0,2>
248 apply(const Tenzor<T1,2>& lhs, const Vektor<T2,2>& rhs) {
249 return Vektor<T0,2>( lhs(0,0)*rhs[0] + lhs(0,1)*rhs[1] ,
250 lhs(1,0)*rhs[0] + lhs(1,1)*rhs[1] );
251 }
252};
253
254template<class T1, class T2>
255struct TSV_MetaDot< Tenzor<T1,3> , Vektor<T2,3> >
256{
258 inline static Vektor<T0,3>
259 apply(const Tenzor<T1,3>& lhs, const Vektor<T2,3>& rhs) {
260 return Vektor<T0,3>( lhs(0,0)*rhs[0] + lhs(0,1)*rhs[1] + lhs(0,2)*rhs[2],
261 lhs(1,0)*rhs[0] + lhs(1,1)*rhs[1] + lhs(1,2)*rhs[2],
262 lhs(2,0)*rhs[0] + lhs(2,1)*rhs[1] + lhs(2,2)*rhs[2] );
263 }
264};
265
267//
268// Specializations for Vektor dot Tenzor
269//
271
272template<class T1, class T2, unsigned D>
273struct TSV_MetaDot< Vektor<T1,D> , Tenzor<T2,D> >
274{
276 inline static Vektor<T0,D>
277 apply(const Vektor<T2,D>& lhs, const Tenzor<T1,D>& rhs) {
279 for (unsigned int i=0; i<D; ++i) {
280 T0 sum = lhs[0]*rhs(0,i);
281 for (unsigned int j=1; j<D; ++j)
282 sum += lhs[j]*rhs(j,i);
283 ret[i] = sum;
284 }
285 return ret;
286 }
287};
288
289
290template<class T1, class T2>
291struct TSV_MetaDot< Vektor<T1,1> , Tenzor<T2,1> >
292{
294 inline static Vektor<T0,1>
295 apply(const Vektor<T1,1>& lhs, const Tenzor<T2,1>& rhs) {
296 return Vektor<T0,1>( lhs[0]*rhs[0] );
297 }
298};
299
300template<class T1, class T2>
301struct TSV_MetaDot< Vektor<T1,2> , Tenzor<T2,2> >
302{
304 inline static Vektor<T0,2>
305 apply(const Vektor<T1,2>& lhs, const Tenzor<T2,2>& rhs) {
306 return Vektor<T0,2>( lhs[0]*rhs(0,0) + lhs[1]*rhs(1,0) ,
307 lhs[0]*rhs(0,1) + lhs[1]*rhs(1,1) );
308 }
309};
310
311template<class T1, class T2>
312struct TSV_MetaDot< Vektor<T1,3> , Tenzor<T2,3> >
313{
315 inline static Vektor<T0,3>
316 apply(const Vektor<T1,3>& lhs, const Tenzor<T2,3>& rhs) {
317 return Vektor<T0,3>( lhs[0]*rhs(0,0) + lhs[1]*rhs(1,0) + lhs[2]*rhs(2,0),
318 lhs[0]*rhs(0,1) + lhs[1]*rhs(1,1) + lhs[2]*rhs(2,1),
319 lhs[0]*rhs(0,2) + lhs[1]*rhs(1,2) + lhs[2]*rhs(2,2) );
320 }
321};
322
324//
325// Specializations for SymTenzor dot Vektor
326//
328
329template<class T1, class T2, unsigned D>
330struct TSV_MetaDot< SymTenzor<T1,D> , Vektor<T2,D> >
331{
333 inline static Vektor<T0,D>
334 apply(const SymTenzor<T1,D>& lhs, const Vektor<T2,D>& rhs) {
336 for (unsigned int i=0; i<D; ++i) {
337 T0 sum = lhs.HL(i,0)*rhs[0];
338 unsigned int j=1;
339 for ( ; j<i; ++j)
340 sum += lhs.HL(i,j)*rhs[j];
341 for ( ; j<D; ++j)
342 sum += lhs.HL(j,i)*rhs[j];
343 ret[i] = sum;
344 }
345 return ret;
346 }
347};
348
349
350template<class T1, class T2>
351struct TSV_MetaDot< SymTenzor<T1,1> , Vektor<T2,1> >
352{
354 inline static Vektor<T0,1>
355 apply(const SymTenzor<T1,1>& lhs, const Vektor<T2,1>& rhs) {
356 return Vektor<T0,1>( lhs[0]*rhs[0] );
357 }
358};
359
360template<class T1, class T2>
361struct TSV_MetaDot< SymTenzor<T1,2> , Vektor<T2,2> >
362{
364 inline static Vektor<T0,2>
365 apply(const SymTenzor<T1,2>& lhs, const Vektor<T2,2>& rhs) {
366 return Vektor<T0,2>( lhs(0,0)*rhs[0] + lhs(0,1)*rhs[1] ,
367 lhs(1,0)*rhs[0] + lhs(1,1)*rhs[1] );
368 }
369};
370
371template<class T1, class T2>
372struct TSV_MetaDot< SymTenzor<T1,3> , Vektor<T2,3> >
373{
375 inline static Vektor<T0,3>
376 apply(const SymTenzor<T1,3>& lhs, const Vektor<T2,3>& rhs) {
377 return Vektor<T0,3>( lhs(0,0)*rhs[0] + lhs(0,1)*rhs[1] + lhs(0,2)*rhs[2],
378 lhs(1,0)*rhs[0] + lhs(1,1)*rhs[1] + lhs(1,2)*rhs[2],
379 lhs(2,0)*rhs[0] + lhs(2,1)*rhs[1] + lhs(2,2)*rhs[2] );
380 }
381};
382
384//
385// Specializations for Vektor dot SymTenzor
386//
388
389template<class T1, class T2, unsigned D>
390struct TSV_MetaDot< Vektor<T1,D> , SymTenzor<T2,D> >
391{
393 inline static Vektor<T0,D>
394 apply(const Vektor<T2,D>& lhs, const SymTenzor<T1,D>& rhs) {
396 for (unsigned int i=0; i<D; ++i) {
397 T0 sum = lhs[0]*rhs[i*(i+1)/2];
398 unsigned int j=1;
399 for ( ; j<i; ++j)
400 sum += lhs[j]*rhs[i*(i+1)/2+j];
401 for ( ; j<D; ++j)
402 sum += lhs[j]*rhs[j*(j+1)/2+i];
403 ret[i] = sum;
404 }
405 return ret;
406 }
407};
408
409
410template<class T1, class T2>
411struct TSV_MetaDot< Vektor<T1,1> , SymTenzor<T2,1> >
412{
414 inline static Vektor<T0,1>
415 apply(const Vektor<T1,1>& lhs, const SymTenzor<T2,1>& rhs) {
416 return Vektor<T0,1>( lhs[0]*rhs[0] );
417 }
418};
419
420template<class T1, class T2>
421struct TSV_MetaDot< Vektor<T1,2> , SymTenzor<T2,2> >
422{
424 inline static Vektor<T0,2>
425 apply(const Vektor<T1,2>& lhs, const SymTenzor<T2,2>& rhs) {
426 return Vektor<T0,2>( lhs[0]*rhs(0,0) + lhs[1]*rhs(1,0) ,
427 lhs[0]*rhs(0,1) + lhs[1]*rhs(1,1) );
428 }
429};
430
431template<class T1, class T2>
432struct TSV_MetaDot< Vektor<T1,3> , SymTenzor<T2,3> >
433{
435 inline static Vektor<T0,3>
436 apply(const Vektor<T1,3>& lhs, const SymTenzor<T2,3>& rhs) {
437 return Vektor<T0,3>( lhs[0]*rhs(0,0) + lhs[1]*rhs(1,0) + lhs[2]*rhs(2,0),
438 lhs[0]*rhs(0,1) + lhs[1]*rhs(1,1) + lhs[2]*rhs(2,1),
439 lhs[0]*rhs(0,2) + lhs[1]*rhs(1,2) + lhs[2]*rhs(2,2) );
440 }
441};
442
444//
445// Specializations for SymTenzor dot Tenzor
446//
448
449template<class T1, class T2, unsigned D>
450struct TSV_MetaDot< SymTenzor<T1,D> , Tenzor<T2,D> >
451{
453 inline static Tenzor<T0,D>
454 apply(const SymTenzor<T1,D>& lhs, const Tenzor<T2,D>& rhs) {
456 for (unsigned int i=0; i<D; ++i)
457 for (unsigned int j=0; j<D; ++j) {
458 T0 sum = lhs.HL(i,0) * rhs(0,j);
459 unsigned int k = 1;
460 for (; k<i; ++k)
461 sum += lhs.HL(i,k) * rhs(k,j);
462 for (; k<D; ++k)
463 sum += lhs.HL(k,i) * rhs(k,j);
464 dot(i,j) = sum;
465 }
466 return dot;
467 }
468};
469
470template<class T1, class T2>
471struct TSV_MetaDot< SymTenzor<T1,1> , Tenzor<T2,1> >
472{
474 inline static Tenzor<T0,1>
475 apply(const SymTenzor<T1,1>& lhs, const Tenzor<T2,1>& rhs) {
476 return Tenzor<T0,1>(lhs[0]*rhs[0]);
477 }
478};
479
480template<class T1, class T2>
481struct TSV_MetaDot< SymTenzor<T1,2> , Tenzor<T2,2> >
482{
484 inline static Tenzor<T0,2>
485 apply(const SymTenzor<T1,2>& lhs, const Tenzor<T2,2>& rhs) {
486 return Tenzor<T0,2>(lhs(0,0)*rhs(0,0) + lhs(0,1)*rhs(1,0),
487 lhs(0,0)*rhs(0,1) + lhs(0,1)*rhs(1,1),
488 lhs(1,0)*rhs(0,0) + lhs(1,1)*rhs(1,0),
489 lhs(1,0)*rhs(0,1) + lhs(1,1)*rhs(1,1));
490 }
491};
492
493template<class T1, class T2>
494struct TSV_MetaDot< SymTenzor<T1,3> , Tenzor<T2,3> >
495{
497 inline static Tenzor<T0,3>
498 apply(const SymTenzor<T1,3>& lhs, const Tenzor<T2,3>& rhs) {
499 return
500 Tenzor<T0,3>(lhs(0,0)*rhs(0,0) + lhs(0,1)*rhs(1,0) + lhs(0,2)*rhs(2,0) ,
501 lhs(0,0)*rhs(0,1) + lhs(0,1)*rhs(1,1) + lhs(0,2)*rhs(2,1) ,
502 lhs(0,0)*rhs(0,2) + lhs(0,1)*rhs(1,2) + lhs(0,2)*rhs(2,2) ,
503 lhs(1,0)*rhs(0,0) + lhs(1,1)*rhs(1,0) + lhs(1,2)*rhs(2,0) ,
504 lhs(1,0)*rhs(0,1) + lhs(1,1)*rhs(1,1) + lhs(1,2)*rhs(2,1) ,
505 lhs(1,0)*rhs(0,2) + lhs(1,1)*rhs(1,2) + lhs(1,2)*rhs(2,2) ,
506 lhs(2,0)*rhs(0,0) + lhs(2,1)*rhs(1,0) + lhs(2,2)*rhs(2,0) ,
507 lhs(2,0)*rhs(0,1) + lhs(2,1)*rhs(1,1) + lhs(2,2)*rhs(2,1) ,
508 lhs(2,0)*rhs(0,2) + lhs(2,1)*rhs(1,2) + lhs(2,2)*rhs(2,2));
509 }
510};
511
513//
514// Specializations for Tenzor dot SymTenzor
515//
517
518template<class T1, class T2, unsigned D>
519struct TSV_MetaDot< Tenzor<T1,D> , SymTenzor<T2,D> >
520{
522 inline static Tenzor<T0,D>
523 apply(const Tenzor<T1,D>& lhs, const SymTenzor<T2,D>& rhs) {
525 for (unsigned int i=0; i<D; ++i)
526 for (unsigned int j=0; j<D; ++j) {
527 T0 sum = lhs(i,0) * rhs.HL(j,0);
528 unsigned int k=1;
529 for (; k<j; ++k)
530 sum += lhs(i,k) * rhs.HL(j,k);
531 for (; k<D; ++k)
532 sum += lhs(i,k) * rhs.HL(k,j);
533 dot[i*D+j] = sum;
534 }
535 return dot;
536 }
537};
538
539template<class T1, class T2>
540struct TSV_MetaDot< Tenzor<T1,1> , SymTenzor<T2,1> >
541{
543 inline static Tenzor<T0,1>
544 apply(const Tenzor<T1,1>& lhs, const SymTenzor<T2,1>& rhs) {
545 return Tenzor<T0,1>(lhs[0]*rhs[0]);
546 }
547};
548
549template<class T1, class T2>
550struct TSV_MetaDot< Tenzor<T1,2> , SymTenzor<T2,2> >
551{
553 inline static Tenzor<T0,2>
554 apply(const Tenzor<T1,2>& lhs, const SymTenzor<T2,2>& rhs) {
555 return Tenzor<T0,2>(lhs(0,0)*rhs(0,0) + lhs(0,1)*rhs(1,0),
556 lhs(0,0)*rhs(0,1) + lhs(0,1)*rhs(1,1),
557 lhs(1,0)*rhs(0,0) + lhs(1,1)*rhs(1,0),
558 lhs(1,0)*rhs(0,1) + lhs(1,1)*rhs(1,1));
559 }
560};
561
562template<class T1, class T2>
563struct TSV_MetaDot< Tenzor<T1,3> , SymTenzor<T2,3> >
564{
566 inline static Tenzor<T0,3>
567 apply(const Tenzor<T1,3>& lhs, const SymTenzor<T2,3>& rhs) {
568 return
569 Tenzor<T0,3>(lhs(0,0)*rhs(0,0) + lhs(0,1)*rhs(1,0) + lhs(0,2)*rhs(2,0) ,
570 lhs(0,0)*rhs(0,1) + lhs(0,1)*rhs(1,1) + lhs(0,2)*rhs(2,1) ,
571 lhs(0,0)*rhs(0,2) + lhs(0,1)*rhs(1,2) + lhs(0,2)*rhs(2,2) ,
572 lhs(1,0)*rhs(0,0) + lhs(1,1)*rhs(1,0) + lhs(1,2)*rhs(2,0) ,
573 lhs(1,0)*rhs(0,1) + lhs(1,1)*rhs(1,1) + lhs(1,2)*rhs(2,1) ,
574 lhs(1,0)*rhs(0,2) + lhs(1,1)*rhs(1,2) + lhs(1,2)*rhs(2,2) ,
575 lhs(2,0)*rhs(0,0) + lhs(2,1)*rhs(1,0) + lhs(2,2)*rhs(2,0) ,
576 lhs(2,0)*rhs(0,1) + lhs(2,1)*rhs(1,1) + lhs(2,2)*rhs(2,1) ,
577 lhs(2,0)*rhs(0,2) + lhs(2,1)*rhs(1,2) + lhs(2,2)*rhs(2,2));
578 }
579};
580
582//
583// Specializations for Vektor dot AntiSymTenzor
584//
586
587template<class T1, class T2, unsigned D>
588struct TSV_MetaDot< Vektor<T1,D> , AntiSymTenzor<T2,D> >
589{
591 inline static Vektor<T0,D>
592 apply(const Vektor<T2,D>& lhs, const AntiSymTenzor<T1,D>& rhs) {
594 for (unsigned int j=0; j<D; ++j) {
595 double sum = 0;
596 for (unsigned int i=0; i<j; i++)
597 sum -= lhs[i]*rhs[((j-1)*j/2)+i];
598 for (unsigned int i=j+1; i<D; ++i)
599 sum += lhs[i]*rhs[((i-1)*i/2)+j];
600 ret[j] = sum;
601 }
602 return ret;
603 }
604};
605
606template<class T1, class T2>
607struct TSV_MetaDot< Vektor<T1,2> , AntiSymTenzor<T2,2> >
608{
610 inline static Vektor<T0,2>
611 apply(const Vektor<T1,2>& lhs, const AntiSymTenzor<T2,2>& rhs) {
612 return Vektor<T0,2>( lhs[0]*rhs(0,0) + lhs[1]*rhs(1,0) ,
613 lhs[0]*rhs(0,1) + lhs[1]*rhs(1,1) );
614 }
615};
616
617template<class T1, class T2>
618struct TSV_MetaDot< Vektor<T1,3> , AntiSymTenzor<T2,3> >
619{
621 inline static Vektor<T0,3>
622 apply(const Vektor<T1,3>& lhs, const AntiSymTenzor<T2,3>& rhs) {
623 return Vektor<T0,3>( lhs[0]*rhs(0,0) + lhs[1]*rhs(1,0) + lhs[2]*rhs(2,0),
624 lhs[0]*rhs(0,1) + lhs[1]*rhs(1,1) + lhs[2]*rhs(2,1),
625 lhs[0]*rhs(0,2) + lhs[1]*rhs(1,2) + lhs[2]*rhs(2,2) );
626 }
627};
628
630//
631// Specializations for AntiSymTenzor dot Vektor
632//
634
635template<class T1, class T2, unsigned D>
636struct TSV_MetaDot< AntiSymTenzor<T1,D> , Vektor<T2,D> >
637{
639 inline static Vektor<T0,D>
640 apply(const AntiSymTenzor<T1,D>& lhs, const Vektor<T2,D>& rhs) {
642 for (unsigned int i=0; i<D; ++i) {
643 T0 sum = 0;
644 for (unsigned int j=0; j<i; ++j)
645 sum += lhs[((i-1)*i/2)+j]*rhs[j];
646 for (unsigned int j=i+1; j<D; ++j)
647 sum -= lhs[((j-1)*j/2)+i]*rhs[j];
648 ret[i] = sum;
649 }
650 return ret;
651 }
652};
653
654
655template<class T1, class T2>
656struct TSV_MetaDot< AntiSymTenzor<T1,1> , Vektor<T2,1> >
657{
659 inline static Vektor<T0,1>
660 apply(const AntiSymTenzor<T1,1>& lhs, const Vektor<T2,1>& rhs) {
661 return Vektor<T0,1>( lhs[0]*rhs[0] );
662 }
663};
664
665template<class T1, class T2>
666struct TSV_MetaDot< AntiSymTenzor<T1,2> , Vektor<T2,2> >
667{
669 inline static Vektor<T0,2>
670 apply(const AntiSymTenzor<T1,2>& lhs, const Vektor<T2,2>& rhs) {
671 return Vektor<T0,2>( lhs(0,0)*rhs[0] + lhs(0,1)*rhs[1] ,
672 lhs(1,0)*rhs[0] + lhs(1,1)*rhs[1] );
673 }
674};
675
676template<class T1, class T2>
677struct TSV_MetaDot< AntiSymTenzor<T1,3> , Vektor<T2,3> >
678{
680 inline static Vektor<T0,3>
681 apply(const AntiSymTenzor<T1,3>& lhs, const Vektor<T2,3>& rhs) {
682 return Vektor<T0,3>( lhs(0,0)*rhs[0] + lhs(0,1)*rhs[1] + lhs(0,2)*rhs[2],
683 lhs(1,0)*rhs[0] + lhs(1,1)*rhs[1] + lhs(1,2)*rhs[2],
684 lhs(2,0)*rhs[0] + lhs(2,1)*rhs[1] + lhs(2,2)*rhs[2] );
685 }
686};
687
689
690#endif // TSV_META_DOT_H
691
692/***************************************************************************
693 * $RCSfile: TSVMetaDot.h,v $ $Author: adelmann $
694 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:24 $
695 * IPPL_VERSION_ID: $Id: TSVMetaDot.h,v 1.1.1.1 2003/01/23 07:40:24 adelmann Exp $
696 ***************************************************************************/
697
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Definition: Vector3D.cpp:118
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
Definition: PETE.h:1111
Definition: Tenzor.h:35
Element_t HL(unsigned int hi, unsigned int lo) const
Definition: SymTenzor.h:215
Definition: Vektor.h:32
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:31
static T0 apply(const Vektor< T1, D > &lhs, const Vektor< T2, D > &rhs)
Definition: TSVMetaDot.h:33
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:44
static T0 apply(const Vektor< T1, 1 > &lhs, const Vektor< T2, 1 > &rhs)
Definition: TSVMetaDot.h:46
static T0 apply(const Vektor< T1, 2 > &lhs, const Vektor< T2, 2 > &rhs)
Definition: TSVMetaDot.h:56
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:54
static T0 apply(const Vektor< T1, 3 > &lhs, const Vektor< T2, 3 > &rhs)
Definition: TSVMetaDot.h:66
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:64
static Tenzor< T0, D > apply(const Tenzor< T1, D > &lhs, const Tenzor< T2, D > &rhs)
Definition: TSVMetaDot.h:82
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:80
static Tenzor< T0, 1 > apply(const Tenzor< T1, 1 > &lhs, const Tenzor< T2, 1 > &rhs)
Definition: TSVMetaDot.h:100
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:98
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:108
static Tenzor< T0, 2 > apply(const Tenzor< T1, 2 > &lhs, const Tenzor< T2, 2 > &rhs)
Definition: TSVMetaDot.h:110
static Tenzor< T0, 3 > apply(const Tenzor< T1, 3 > &lhs, const Tenzor< T2, 3 > &rhs)
Definition: TSVMetaDot.h:123
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:121
static Tenzor< T0, D > apply(const SymTenzor< T1, D > &lhs, const SymTenzor< T2, D > &rhs)
Definition: TSVMetaDot.h:148
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:146
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:169
static Tenzor< T0, 1 > apply(const SymTenzor< T1, 1 > &lhs, const SymTenzor< T2, 1 > &rhs)
Definition: TSVMetaDot.h:171
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:179
static Tenzor< T0, 2 > apply(const SymTenzor< T1, 2 > &lhs, const SymTenzor< T2, 2 > &rhs)
Definition: TSVMetaDot.h:181
static Tenzor< T0, 3 > apply(const SymTenzor< T1, 3 > &lhs, const SymTenzor< T2, 3 > &rhs)
Definition: TSVMetaDot.h:194
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:192
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:218
static Vektor< T0, D > apply(const Tenzor< T1, D > &lhs, const Vektor< T2, D > &rhs)
Definition: TSVMetaDot.h:220
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:236
static Vektor< T0, 1 > apply(const Tenzor< T1, 1 > &lhs, const Vektor< T2, 1 > &rhs)
Definition: TSVMetaDot.h:238
static Vektor< T0, 2 > apply(const Tenzor< T1, 2 > &lhs, const Vektor< T2, 2 > &rhs)
Definition: TSVMetaDot.h:248
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:246
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:257
static Vektor< T0, 3 > apply(const Tenzor< T1, 3 > &lhs, const Vektor< T2, 3 > &rhs)
Definition: TSVMetaDot.h:259
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:275
static Vektor< T0, D > apply(const Vektor< T2, D > &lhs, const Tenzor< T1, D > &rhs)
Definition: TSVMetaDot.h:277
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:293
static Vektor< T0, 1 > apply(const Vektor< T1, 1 > &lhs, const Tenzor< T2, 1 > &rhs)
Definition: TSVMetaDot.h:295
static Vektor< T0, 2 > apply(const Vektor< T1, 2 > &lhs, const Tenzor< T2, 2 > &rhs)
Definition: TSVMetaDot.h:305
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:303
static Vektor< T0, 3 > apply(const Vektor< T1, 3 > &lhs, const Tenzor< T2, 3 > &rhs)
Definition: TSVMetaDot.h:316
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:314
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:332
static Vektor< T0, D > apply(const SymTenzor< T1, D > &lhs, const Vektor< T2, D > &rhs)
Definition: TSVMetaDot.h:334
static Vektor< T0, 1 > apply(const SymTenzor< T1, 1 > &lhs, const Vektor< T2, 1 > &rhs)
Definition: TSVMetaDot.h:355
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:353
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:363
static Vektor< T0, 2 > apply(const SymTenzor< T1, 2 > &lhs, const Vektor< T2, 2 > &rhs)
Definition: TSVMetaDot.h:365
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:374
static Vektor< T0, 3 > apply(const SymTenzor< T1, 3 > &lhs, const Vektor< T2, 3 > &rhs)
Definition: TSVMetaDot.h:376
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:392
static Vektor< T0, D > apply(const Vektor< T2, D > &lhs, const SymTenzor< T1, D > &rhs)
Definition: TSVMetaDot.h:394
static Vektor< T0, 1 > apply(const Vektor< T1, 1 > &lhs, const SymTenzor< T2, 1 > &rhs)
Definition: TSVMetaDot.h:415
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:413
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:423
static Vektor< T0, 2 > apply(const Vektor< T1, 2 > &lhs, const SymTenzor< T2, 2 > &rhs)
Definition: TSVMetaDot.h:425
static Vektor< T0, 3 > apply(const Vektor< T1, 3 > &lhs, const SymTenzor< T2, 3 > &rhs)
Definition: TSVMetaDot.h:436
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:434
static Tenzor< T0, D > apply(const SymTenzor< T1, D > &lhs, const Tenzor< T2, D > &rhs)
Definition: TSVMetaDot.h:454
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:452
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:473
static Tenzor< T0, 1 > apply(const SymTenzor< T1, 1 > &lhs, const Tenzor< T2, 1 > &rhs)
Definition: TSVMetaDot.h:475
static Tenzor< T0, 2 > apply(const SymTenzor< T1, 2 > &lhs, const Tenzor< T2, 2 > &rhs)
Definition: TSVMetaDot.h:485
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:483
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:496
static Tenzor< T0, 3 > apply(const SymTenzor< T1, 3 > &lhs, const Tenzor< T2, 3 > &rhs)
Definition: TSVMetaDot.h:498
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:521
static Tenzor< T0, D > apply(const Tenzor< T1, D > &lhs, const SymTenzor< T2, D > &rhs)
Definition: TSVMetaDot.h:523
static Tenzor< T0, 1 > apply(const Tenzor< T1, 1 > &lhs, const SymTenzor< T2, 1 > &rhs)
Definition: TSVMetaDot.h:544
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:542
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:552
static Tenzor< T0, 2 > apply(const Tenzor< T1, 2 > &lhs, const SymTenzor< T2, 2 > &rhs)
Definition: TSVMetaDot.h:554
static Tenzor< T0, 3 > apply(const Tenzor< T1, 3 > &lhs, const SymTenzor< T2, 3 > &rhs)
Definition: TSVMetaDot.h:567
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:565
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:590
static Vektor< T0, D > apply(const Vektor< T2, D > &lhs, const AntiSymTenzor< T1, D > &rhs)
Definition: TSVMetaDot.h:592
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:609
static Vektor< T0, 2 > apply(const Vektor< T1, 2 > &lhs, const AntiSymTenzor< T2, 2 > &rhs)
Definition: TSVMetaDot.h:611
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:620
static Vektor< T0, 3 > apply(const Vektor< T1, 3 > &lhs, const AntiSymTenzor< T2, 3 > &rhs)
Definition: TSVMetaDot.h:622
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:638
static Vektor< T0, D > apply(const AntiSymTenzor< T1, D > &lhs, const Vektor< T2, D > &rhs)
Definition: TSVMetaDot.h:640
static Vektor< T0, 1 > apply(const AntiSymTenzor< T1, 1 > &lhs, const Vektor< T2, 1 > &rhs)
Definition: TSVMetaDot.h:660
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:658
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:668
static Vektor< T0, 2 > apply(const AntiSymTenzor< T1, 2 > &lhs, const Vektor< T2, 2 > &rhs)
Definition: TSVMetaDot.h:670
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
Definition: TSVMetaDot.h:679
static Vektor< T0, 3 > apply(const AntiSymTenzor< T1, 3 > &lhs, const Vektor< T2, 3 > &rhs)
Definition: TSVMetaDot.h:681
PETE_ComputeBinaryType< T1, T2, Op, Op::tag >::type type