// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
+/**
+ * Compute the scalar product $a:b=\sum_{i,j} a_{ij}b_{ij}$ between two
+ * tensors $a,b$ of rank 2. We don't use <code>operator*</code> for this
+ * operation since the product between two tensors is usually assumed to be
+ * the contraction over the last index of the first tensor and the first index
+ * of the second tensor, for example $(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$.
+ *
+ * @relates Tensor
+ * @author Wolfgang Bangerth, 2008
+ */
+template <int dim>
+inline
+double
+scalar_product (const Tensor<2,dim> &t1,
+ const Tensor<2,dim> &t2)
+{
+ double s = 0;
+ for (unsigned int i=0; i<dim; ++i)
+ for (unsigned int j=0; j<dim; ++j)
+ s += t1[i][j] * t2[i][j];
+ return s;
+}
+
+
+
/**
* Compute the determinant of a tensor of arbitrary rank and dimension
* one. Since this is a number, the return value is, of course, the
<h3>base</h3>
<ol>
+ <li>
+ <p>
+ New: There is a new function scalar_product(const Tensor<2,dim> &,
+ const Tensor<2,dim> &) that computes the scalar product
+ $a:b=\sum_{i,j} a_{ij}b_{ij}$ between two tensors of rank 2.
+ <br>
+ (WB 2008/08/15)
+ </p>
+
<li>
<p>
New: If the compiler allows to do <code>\#include @<mpi.h@></code>, then
- the flag <code>DEAL_II_COMPILER_SUPPORTS_MPI</code> is now set in
+ the preprocessor flag <code>DEAL_II_COMPILER_SUPPORTS_MPI</code> is now set in
<code>base/include/base/config.h</code>. This also fixes a problem in
<code>base/include/base/utilities.h</code> if a compiler capable of
including <code>mpi.h</code> was used but not PETSc.