ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/math/RectMatrix.hpp
(Generate patch)

Comparing trunk/src/math/RectMatrix.hpp (file contents):
Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC vs.
Revision 1924 by gezelter, Mon Aug 5 21:46:11 2013 UTC

# Line 555 | Line 555 | namespace OpenMD {
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:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines