]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Test multiplication of a complex tensor by a complex number.
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 12 Feb 2014 09:52:13 +0000 (09:52 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 12 Feb 2014 09:52:13 +0000 (09:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@32460 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/base/tensor_complex_06.cc b/tests/base/tensor_complex_06.cc
new file mode 100644 (file)
index 0000000..435793d
--- /dev/null
@@ -0,0 +1,77 @@
+// ---------------------------------------------------------------------
+// $Id: tensor_complex_06.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<1,dim,std::complex<double>>::operator*(Tensor<1,dim,std::complex<double> >)
+// These tests are simple enough to do by hand.
+
+#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_01 ()
+{
+  Tensor<1,dim,std::complex<double> > t (false);
+  for (unsigned int i=0; i<dim; ++i)
+    {
+      t[i] = std::complex<double> (i,1);
+    }
+  const Tensor<1,dim,std::complex<double> > res = 
+    t * std::complex<double> (1,2);
+
+  deallog << "dim = " << dim << ": " << res << std::endl;
+}
+
+
+template <int dim>
+void test_tensor_02 ()
+{
+  Tensor<1,dim,std::complex<double> > t (false);
+  for (unsigned int i=0; i<dim; ++i)
+    {
+      t[i] = std::complex<double> (1,i);
+    }
+  const Tensor<1,dim,std::complex<double> > res = 
+    t * std::complex<double> (1,2);
+
+  deallog << "dim = " << dim << ": " << res << 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);
+
+  deallog << "First test" << std::endl;
+
+  test_tensor_01<1>();
+  test_tensor_01<2>();
+  test_tensor_01<3>();
+
+  deallog << "Second test" << std::endl;
+
+  test_tensor_02<1>();
+  test_tensor_02<2>();
+  test_tensor_02<3>();
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/base/tensor_complex_06.output b/tests/base/tensor_complex_06.output
new file mode 100644 (file)
index 0000000..a856b76
--- /dev/null
@@ -0,0 +1,10 @@
+
+DEAL::First test
+DEAL::dim = 1: (-2.00,1.00)
+DEAL::dim = 2: (-2.00,1.00) (-1.00,3.00)
+DEAL::dim = 3: (-2.00,1.00) (-1.00,3.00) (0.00,5.00)
+DEAL::Second test
+DEAL::dim = 1: (1.00,2.00)
+DEAL::dim = 2: (1.00,2.00) (-1.00,3.00)
+DEAL::dim = 3: (1.00,2.00) (-1.00,3.00) (-3.00,4.00)
+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.