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: |
603 |
|
* @return the cross product (vector product) of t1 and t2 |
604 |
|
*/ |
605 |
|
template<typename Real, unsigned int Row, unsigned int Col> |
606 |
< |
inline Vector<Real, Row> cross( const RectMatrix<Real, Row, Col>& t1, |
606 |
> |
inline Vector<Real, Row> mCross( const RectMatrix<Real, Row, Col>& t1, |
607 |
|
const RectMatrix<Real, Row, Col>& t2 ) { |
608 |
|
Vector<Real, Row> result; |
609 |
|
unsigned int i1; |
615 |
|
for (unsigned int j = 0; j < Col; j++) { |
616 |
|
result[i] += t1(i1,j) * t2(i2,j) - t1(i2,j) * t2(i1,j); |
617 |
|
} |
618 |
< |
} |
618 |
> |
} |
619 |
|
return result; |
620 |
|
} |
621 |
|
|