]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a double_contract function.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 29 Mar 2005 21:50:41 +0000 (21:50 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 29 Mar 2005 21:50:41 +0000 (21:50 +0000)
git-svn-id: https://svn.dealii.org/trunk@10305 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/tensor.h
deal.II/doc/news/changes.html

index 742d0fc7a6084b7e493453b3c1cd2e1406d24eb7..c8eb3592255a020e5ca7f1022d17dde28bd38b3c 100644 (file)
@@ -724,6 +724,29 @@ void contract (Tensor<4,dim>       &dest,
 }
 
 
+/**
+ * Contract the last two indices of <tt>src1</tt> with the two indices
+ * <tt>src2</tt>, creating a rank-2 tensor. This is the matrix-vector
+ * product analog operation between tensors of rank 4 and rank 2.
+ *
+ * @relates Tensor
+ * @author Wolfgang Bangerth, 2005
+ */
+template <int dim>
+inline
+void double_contract (Tensor<2,dim>       &dest,
+                     const Tensor<4,dim> &src1,
+                     const Tensor<2,dim> &src2)
+{
+  dest.clear ();
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=0; j<dim; ++j)
+      for (unsigned int k=0; k<dim; ++k)
+       for (unsigned int l=0; l<dim; ++l)
+         dest[i][j] += src1[i][j][k][l] * src2[k][l];
+}
+
+
 
 /**
  * Contract three tensors, corresponding to the matrix vector product
index 182038e7ff79fae8aebe0eaca5b30c015a7a2cef..4b772d8b93581ea1ba1bcd62acb47e6fbc816ca6 100644 (file)
@@ -151,6 +151,15 @@ inconvenience this causes.
 <h3>base</h3>
 
 <ol>  
+  <li> <p>
+       New: The new function <code
+       class="member">double_contract</code> contracts two tensors of
+       rank 4 and 2 into a tensor of rank 2, by contracting over two
+       indices at the same time.
+       <br> 
+       (WB, 2005/03/29)
+       </p>
+
   <li> <p>
        New: The new function <code
        class="member">TableIndicesBase::sort</code> allows to sort the indices

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.