]> https://gitweb.dealii.org/ - dealii.git/commitdiff
new contract for Tensors of order 1 and 2
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 18 Jan 2001 13:02:16 +0000 (13:02 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 18 Jan 2001 13:02:16 +0000 (13:02 +0000)
git-svn-id: https://svn.dealii.org/trunk@3721 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 760b360aaacbcebf5b81006a7997ee6c64c337b5..af950a21c13480da8ca1c358ac168422c4873fb7 100644 (file)
@@ -436,6 +436,26 @@ void contract (Tensor<1,dim>       &dest,
 
 
 
+/**
+ * Contract a tensor of rank 1 with a tensor of rank 2. The result is
+ * @p{dest[i] = sum_j src1[j] src2[j][i]}.
+ *
+ * @author Guido Kanschat, 2001
+ */
+template <int dim>
+inline
+void contract (Tensor<1,dim>       &dest,
+              const Tensor<1,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)
+      dest[i] += src1[j] * src2[j][i];
+};
+
+
+
 /**
  * Contract a tensor of rank 2 with a tensor of rank 2. The result is
  * @p{dest[i][k] = sum_j src1[i][j] src2[j][k]}.

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.