555 |
|
return result; |
556 |
|
} |
557 |
|
|
558 |
+ |
|
559 |
+ |
/** |
560 |
+ |
* Returns the tensor contraction (double dot product) of two rank 2 |
561 |
+ |
* tensors (or Matrices) |
562 |
+ |
* |
563 |
+ |
* \f[ \mathbf{A} \colon \! \mathbf{B} = \sum_\alpha \sum_\beta \mathbf{A}_{\alpha \beta} B_{\alpha \beta} \f] |
564 |
+ |
* |
565 |
+ |
* @param t1 first tensor |
566 |
+ |
* @param t2 second tensor |
567 |
+ |
* @return the tensor contraction (double dot product) of t1 and t2 |
568 |
+ |
*/ |
569 |
+ |
template<typename Real, unsigned int Row, unsigned int Col> |
570 |
+ |
inline Real doubleDot( const RectMatrix<Real, Row, Col>& t1, |
571 |
+ |
const RectMatrix<Real, Row, Col>& t2 ) { |
572 |
+ |
Real tmp; |
573 |
+ |
tmp = 0; |
574 |
+ |
|
575 |
+ |
for (unsigned int i = 0; i < Row; i++) |
576 |
+ |
for (unsigned int j =0; j < Col; j++) |
577 |
+ |
tmp += t1(i,j) * t2(i,j); |
578 |
+ |
|
579 |
+ |
return tmp; |
580 |
+ |
} |
581 |
|
|
582 |
+ |
|
583 |
+ |
|
584 |
|
/** |
585 |
|
* Returns the vector (cross) product of two matrices. This |
586 |
|
* operation is defined in: |