]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
A patch by Denis Davydov: Multiply a real tensor by a complex number.
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 13 Feb 2014 09:51:05 +0000 (09:51 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 13 Feb 2014 09:51:05 +0000 (09:51 +0000)
git-svn-id: https://svn.dealii.org/trunk@32475 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 5ddc7dc75230a0a170e558d4511c2a20f8d7a3de..c3c6dab70271e9780bbd6f8a786ea6750948d963 100644 (file)
@@ -2093,6 +2093,48 @@ operator / (const Tensor<rank,dim> &t,
   return tt;
 }
 
+
+
+/**
+ * Multiplication of a tensor of general rank by a scalar
+ * complex<double> from the left.
+ *
+ * @relates Tensor
+ */
+template <int rank, int dim>
+  inline
+  Tensor<rank,dim,std::complex<double> >
+  operator * (const std::complex<double>  factor,
+             const Tensor<rank,dim>     &t)
+{
+  Tensor<rank,dim,std::complex<double> > tt;
+  for (unsigned int d=0; d<dim; ++d)
+    tt[d] = factor * t[d];
+  return tt;
+}
+
+
+
+/**
+ * Multiplication of a tensor of general rank by a scalar
+ * complex<double> from the right.
+ *
+ * @relates Tensor
+ */
+template <int rank, int dim>
+  inline
+  Tensor<rank,dim,std::complex<double> >
+  operator * (const Tensor<rank,dim>     &t,
+             const std::complex<double>  factor)
+{
+  Tensor<rank,dim,std::complex<double> > tt;
+  for (unsigned int d=0; d<dim; ++d)
+    tt[d] = t[d] * factor;
+  return tt;
+}
+
+
+
 DEAL_II_NAMESPACE_CLOSE
 
 #endif
index 94c8e1b3e990af3df0ea4c11230fedef7a7de1e6..1b3c58fe60162ca0deb7e65fffc4988271eb8e6d 100644 (file)
@@ -1463,6 +1463,47 @@ operator / (const Tensor<1,dim> &t,
 }
 
 
+
+/**
+ * Multiplication of a tensor of rank 1 by a scalar complex<double>
+ * from the right.
+ *
+ * @relates Tensor<1,dim,Number>
+ */
+template <int dim>
+inline
+Tensor<1,dim,std::complex<double> >
+  operator * (const Tensor<1,dim>        &t,
+             const std::complex<double>  factor)
+{                                  
+  Tensor<1,dim,std::complex<double> > tt (false);
+  for (unsigned int d=0; d<dim; ++d)
+    tt[d] = t[d] * factor;
+  return tt;
+}
+
+
+
+/**
+ * Multiplication of a tensor of rank 1 by a scalar complex<double>
+ * from the left.
+ *
+ * @relates Tensor<1,dim,Number>
+ */
+template <int dim>
+inline
+Tensor<1,dim,std::complex<double> >
+  operator * (const std::complex<double>  factor,
+             const Tensor<1,dim>        &t)
+{                                  
+  Tensor<1,dim,std::complex<double> > tt (false);
+  for (unsigned int d=0; d<dim; ++d)
+    tt[d] = t[d] * factor;
+  return tt;
+}
+
+
+
 DEAL_II_NAMESPACE_CLOSE
 
 #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.