]> https://gitweb.dealii.org/ - dealii.git/commitdiff
more complex contraction
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 18 May 2004 07:51:20 +0000 (07:51 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Tue, 18 May 2004 07:51:20 +0000 (07:51 +0000)
git-svn-id: https://svn.dealii.org/trunk@9250 0785d39b-7218-0410-832d-ea1e28bc413d

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

index be4266a21b13c9baeaf96baf04c1e5cad47a9984..8317d89ceb869d1c6223a2f1cff0b3b6610d6e9a 100644 (file)
@@ -721,6 +721,28 @@ void contract (Tensor<4,dim>       &dest,
 
 
 
+/**
+ * Contract three tensors, corresponding to the matrix vector product
+ * <i>u<sup>T</sup> A v</i>.
+ *
+ * @relates Tensor
+ * @author Guido Kanschat, 2004
+ */
+template <int dim>
+inline
+double contract3 (const Tensor<1,dim>& u,
+                 const Tensor<2,dim>& A,
+                 const Tensor<1,dim>& v)
+{
+  double result = 0.;
+
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=0; j<dim; ++j)
+      result += u[i] * A[i][j] * v[j];
+  return result;
+}
+
+
 /**
  * Form the outer product of two tensors of rank 1 and 1, i.e.
  * <tt>dst[i][j] = src1[i] * src2[j]</tt>.
@@ -1069,7 +1091,7 @@ transpose (const Tensor<2,dim> &t)
   return tt;
 }
 
-
+/// @if NoDoc
 
 /**
  * Return the transpose of the given tensor. This is the
@@ -1123,7 +1145,7 @@ transpose (const Tensor<2,3> &t)
   return Tensor<2,3>(x);
 }
 
-
+/// @endif
 
 
 /**

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.