]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add Frobenius inner product of two Tensor of rank 2
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 1 Aug 2012 16:58:57 +0000 (16:58 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 1 Aug 2012 16:58:57 +0000 (16:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@25746 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/tensor.h

index d32dbe917a69a2489d674752d8f3a98b37bccf3d..c5a5bf12166e28cf62882ddb8c2330e855c51461 100644 (file)
@@ -219,7 +219,7 @@ class Tensor
                                      /**
                                       * Return the square of the
                                       * Frobenius-norm of a tensor,
-                                      * i.e. the square root of the
+                                      * i.e. the
                                       * sum of squares of all entries.
                                       *
                                       * This function mainly exists
@@ -691,6 +691,26 @@ operator * (const Tensor<1,dim,Number> &src1,
 }
 
 
+/**
+ * Double contract two tensors of rank 2, thus computing the Frobenius
+ * inner product <tt> sum<sub>i,j</sub> src1[i][j]*src2[i][j]</tt>.
+ *
+ * @relates Tensor
+ * @author Guido Kanschat, 2000 
+ */
+template <int dim, typename Number>
+inline
+Number double_contract (const Tensor<2, dim, Number> &src1,
+                       const Tensor<2, dim, Number> &src2)
+{
+  Number res = 0.;
+  for (unsigned int i=0; i<dim; ++i)
+    res += contract(src1[i],src2[i]);
+  
+  return res;
+}
+
+
 /**
  * Contract a tensor of rank 2 with a tensor of rank 1. The result is
  * <tt>dest[i] = sum_j src1[i][j] src2[j]</tt>.

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.