]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Run a test on previous commit.
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 13 Feb 2014 09:51:43 +0000 (09:51 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 13 Feb 2014 09:51:43 +0000 (09:51 +0000)
git-svn-id: https://svn.dealii.org/trunk@32476 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/tensor_26.cc [new file with mode: 0644]
tests/base/tensor_26.output [new file with mode: 0644]

diff --git a/tests/base/tensor_26.cc b/tests/base/tensor_26.cc
new file mode 100644 (file)
index 0000000..3d8661b
--- /dev/null
@@ -0,0 +1,74 @@
+// ---------------------------------------------------------------------
+// $Id: tensor_26.cc $
+//
+// Copyright (C) 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// check   Tensor<rank,dim,std::complex<double> > operator * (const Tensor<rank,dim>     &t,
+//                                                            const std::complex<double>  factor)
+// and
+// check   Tensor<rank,dim,std::complex<double> > operator * (const std::complex<double>  factor,
+//                                                            const Tensor<rank,dim>     &t)
+// by multiplying on the left and on the right.
+
+#include "../tests.h"
+#include <deal.II/base/tensor.h>
+#include <deal.II/base/logstream.h>
+#include <fstream>
+#include <iomanip>
+
+
+template <int dim>
+void test_tensor ()
+{
+  // a real tensor
+  Tensor<1,dim,double> t (false);
+
+  for (unsigned int i=0; i<dim; ++i)
+    {
+      t[i] = 2*i+dim+1;
+    }
+
+  // multiply on the right by a complex<double>
+  const Tensor<1,dim,std::complex<double> > right = 
+    t * std::complex<double> (1,2);
+
+  // multiply on the left by a complex<double>
+  const Tensor<1,dim,std::complex<double> > left  = 
+    std::complex<double> (1,2) * t;
+
+  // they should yield the same result
+  Assert (left == right, ExcInternalError ());
+
+  deallog << "dim = " << dim   << std::endl
+         << left << " : "     << right << std::endl;
+}
+
+
+int main ()
+{
+  std::ofstream logfile("output");
+  deallog << std::setprecision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test_tensor<1>();
+  test_tensor<2>();
+  test_tensor<3>();
+  test_tensor<4>();
+
+  deallog << "OK" << std::endl;
+}
+
diff --git a/tests/base/tensor_26.output b/tests/base/tensor_26.output
new file mode 100644 (file)
index 0000000..d7617dd
--- /dev/null
@@ -0,0 +1,10 @@
+
+DEAL::dim = 1
+DEAL::(2.00,4.00) : (2.00,4.00)
+DEAL::dim = 2
+DEAL::(3.00,6.00) (5.00,10.0) : (3.00,6.00) (5.00,10.0)
+DEAL::dim = 3
+DEAL::(4.00,8.00) (6.00,12.0) (8.00,16.0) : (4.00,8.00) (6.00,12.0) (8.00,16.0)
+DEAL::dim = 4
+DEAL::(5.00,10.0) (7.00,14.0) (9.00,18.0) (11.0,22.0) : (5.00,10.0) (7.00,14.0) (9.00,18.0) (11.0,22.0)
+DEAL::OK

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.