28template<
class T1,
class T2,
unsigned D>
34 T0 dot = lhs[0]*rhs[0];
35 for (
unsigned d=1; d<D; ++d)
41template<
class T1,
class T2>
51template<
class T1,
class T2>
57 return lhs[0]*rhs[0] + lhs[1]*rhs[1];
61template<
class T1,
class T2>
67 return lhs[0]*rhs[0] + lhs[1]*rhs[1] + lhs[2]*rhs[2];
77template<
class T1,
class T2,
unsigned D>
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);
95template<
class T1,
class T2>
105template<
class T1,
class T2>
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));
118template<
class T1,
class T2>
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) );
143template<
class T1,
class T2,
unsigned D>
150 for (
unsigned int i=0; i<D; ++i)
151 for (
unsigned int j=i; j<D; ++j) {
155 sum += lhs.
HL(i,k) * rhs.
HL(j,k);
157 sum += lhs.
HL(k,i) * rhs.
HL(j,k);
159 sum += lhs.
HL(k,i) * rhs.
HL(k,j);
166template<
class T1,
class T2>
176template<
class T1,
class T2>
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));
189template<
class T1,
class T2>
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));
215template<
class T1,
class T2,
unsigned D>
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];
233template<
class T1,
class T2>
243template<
class T1,
class T2>
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] );
254template<
class T1,
class T2>
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] );
272template<
class T1,
class T2,
unsigned D>
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);
290template<
class T1,
class T2>
300template<
class T1,
class T2>
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) );
311template<
class T1,
class T2>
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) );
329template<
class T1,
class T2,
unsigned D>
336 for (
unsigned int i=0; i<D; ++i) {
340 sum += lhs.
HL(i,j)*rhs[j];
342 sum += lhs.
HL(j,i)*rhs[j];
350template<
class T1,
class T2>
360template<
class T1,
class T2>
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] );
371template<
class T1,
class T2>
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] );
389template<
class T1,
class T2,
unsigned D>
396 for (
unsigned int i=0; i<D; ++i) {
397 T0 sum = lhs[0]*rhs[i*(i+1)/2];
400 sum += lhs[j]*rhs[i*(i+1)/2+j];
402 sum += lhs[j]*rhs[j*(j+1)/2+i];
410template<
class T1,
class T2>
420template<
class T1,
class T2>
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) );
431template<
class T1,
class T2>
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) );
449template<
class T1,
class T2,
unsigned D>
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);
461 sum += lhs.
HL(i,k) * rhs(k,j);
463 sum += lhs.
HL(k,i) * rhs(k,j);
470template<
class T1,
class T2>
480template<
class T1,
class T2>
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));
493template<
class T1,
class T2>
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));
518template<
class T1,
class T2,
unsigned D>
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);
530 sum += lhs(i,k) * rhs.
HL(j,k);
532 sum += lhs(i,k) * rhs.
HL(k,j);
539template<
class T1,
class T2>
549template<
class T1,
class T2>
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));
562template<
class T1,
class T2>
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));
587template<
class T1,
class T2,
unsigned D>
594 for (
unsigned int j=0; j<D; ++j) {
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];
606template<
class T1,
class T2>
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) );
617template<
class T1,
class T2>
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) );
635template<
class T1,
class T2,
unsigned D>
642 for (
unsigned int i=0; i<D; ++i) {
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];
655template<
class T1,
class T2>
665template<
class T1,
class T2>
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] );
676template<
class T1,
class T2>
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] );
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
Element_t HL(unsigned int hi, unsigned int lo) const
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static T0 apply(const Vektor< T1, D > &lhs, const Vektor< T2, D > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static T0 apply(const Vektor< T1, 1 > &lhs, const Vektor< T2, 1 > &rhs)
static T0 apply(const Vektor< T1, 2 > &lhs, const Vektor< T2, 2 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static T0 apply(const Vektor< T1, 3 > &lhs, const Vektor< T2, 3 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Tenzor< T0, D > apply(const Tenzor< T1, D > &lhs, const Tenzor< T2, D > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Tenzor< T0, 1 > apply(const Tenzor< T1, 1 > &lhs, const Tenzor< T2, 1 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Tenzor< T0, 2 > apply(const Tenzor< T1, 2 > &lhs, const Tenzor< T2, 2 > &rhs)
static Tenzor< T0, 3 > apply(const Tenzor< T1, 3 > &lhs, const Tenzor< T2, 3 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Tenzor< T0, D > apply(const SymTenzor< T1, D > &lhs, const SymTenzor< T2, D > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Tenzor< T0, 1 > apply(const SymTenzor< T1, 1 > &lhs, const SymTenzor< T2, 1 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Tenzor< T0, 2 > apply(const SymTenzor< T1, 2 > &lhs, const SymTenzor< T2, 2 > &rhs)
static Tenzor< T0, 3 > apply(const SymTenzor< T1, 3 > &lhs, const SymTenzor< T2, 3 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, D > apply(const Tenzor< T1, D > &lhs, const Vektor< T2, D > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, 1 > apply(const Tenzor< T1, 1 > &lhs, const Vektor< T2, 1 > &rhs)
static Vektor< T0, 2 > apply(const Tenzor< T1, 2 > &lhs, const Vektor< T2, 2 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, 3 > apply(const Tenzor< T1, 3 > &lhs, const Vektor< T2, 3 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, D > apply(const Vektor< T2, D > &lhs, const Tenzor< T1, D > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, 1 > apply(const Vektor< T1, 1 > &lhs, const Tenzor< T2, 1 > &rhs)
static Vektor< T0, 2 > apply(const Vektor< T1, 2 > &lhs, const Tenzor< T2, 2 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, 3 > apply(const Vektor< T1, 3 > &lhs, const Tenzor< T2, 3 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, D > apply(const SymTenzor< T1, D > &lhs, const Vektor< T2, D > &rhs)
static Vektor< T0, 1 > apply(const SymTenzor< T1, 1 > &lhs, const Vektor< T2, 1 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, 2 > apply(const SymTenzor< T1, 2 > &lhs, const Vektor< T2, 2 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, 3 > apply(const SymTenzor< T1, 3 > &lhs, const Vektor< T2, 3 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, D > apply(const Vektor< T2, D > &lhs, const SymTenzor< T1, D > &rhs)
static Vektor< T0, 1 > apply(const Vektor< T1, 1 > &lhs, const SymTenzor< T2, 1 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, 2 > apply(const Vektor< T1, 2 > &lhs, const SymTenzor< T2, 2 > &rhs)
static Vektor< T0, 3 > apply(const Vektor< T1, 3 > &lhs, const SymTenzor< T2, 3 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Tenzor< T0, D > apply(const SymTenzor< T1, D > &lhs, const Tenzor< T2, D > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Tenzor< T0, 1 > apply(const SymTenzor< T1, 1 > &lhs, const Tenzor< T2, 1 > &rhs)
static Tenzor< T0, 2 > apply(const SymTenzor< T1, 2 > &lhs, const Tenzor< T2, 2 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Tenzor< T0, 3 > apply(const SymTenzor< T1, 3 > &lhs, const Tenzor< T2, 3 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Tenzor< T0, D > apply(const Tenzor< T1, D > &lhs, const SymTenzor< T2, D > &rhs)
static Tenzor< T0, 1 > apply(const Tenzor< T1, 1 > &lhs, const SymTenzor< T2, 1 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Tenzor< T0, 2 > apply(const Tenzor< T1, 2 > &lhs, const SymTenzor< T2, 2 > &rhs)
static Tenzor< T0, 3 > apply(const Tenzor< T1, 3 > &lhs, const SymTenzor< T2, 3 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, D > apply(const Vektor< T2, D > &lhs, const AntiSymTenzor< T1, D > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, 2 > apply(const Vektor< T1, 2 > &lhs, const AntiSymTenzor< T2, 2 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, 3 > apply(const Vektor< T1, 3 > &lhs, const AntiSymTenzor< T2, 3 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, D > apply(const AntiSymTenzor< T1, D > &lhs, const Vektor< T2, D > &rhs)
static Vektor< T0, 1 > apply(const AntiSymTenzor< T1, 1 > &lhs, const Vektor< T2, 1 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, 2 > apply(const AntiSymTenzor< T1, 2 > &lhs, const Vektor< T2, 2 > &rhs)
PETEBinaryReturn< T1, T2, OpMultipply >::type T0
static Vektor< T0, 3 > apply(const AntiSymTenzor< T1, 3 > &lhs, const Vektor< T2, 3 > &rhs)
PETE_ComputeBinaryType< T1, T2, Op, Op::tag >::type type