]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a test
authorMatthias Maier <tamiko@43-1.org>
Sat, 12 Sep 2015 05:15:24 +0000 (00:15 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sat, 12 Sep 2015 21:42:12 +0000 (16:42 -0500)
tests/base/tensor_mixing_types_01.cc
tests/base/tensor_mixing_types_02.cc [new file with mode: 0644]
tests/base/tensor_mixing_types_02.output [new file with mode: 0644]

index ba51874a79cbd1201aa77d66fbafc636b632f028..4a33a0e60eec56ca2dc12ddec9017d6a1eb171f9 100644 (file)
@@ -59,11 +59,11 @@ int main ()
 
     deallog << f + d << std::endl;
     deallog << f - d << std::endl;
-    deallog << f *d << std::endl;
+    deallog << f * d << std::endl;
 
     deallog << d + c << std::endl;
     deallog << d - c << std::endl;
-    deallog << d *c << std::endl;
+    deallog << d * c << std::endl;
 
     float f_scalar = 10.;
     deallog << (d * f_scalar) << std::endl;
@@ -87,11 +87,11 @@ int main ()
 
     deallog << f + d << std::endl;
     deallog << f - d << std::endl;
-    deallog << f *d << std::endl;
+    deallog << f * d << std::endl;
 
     deallog << d + c << std::endl;
     deallog << d - c << std::endl;
-    deallog << d *c << std::endl;
+    deallog << d * c << std::endl;
 
     float f_scalar = 10.;
     deallog << (d * f_scalar) << std::endl;
diff --git a/tests/base/tensor_mixing_types_02.cc b/tests/base/tensor_mixing_types_02.cc
new file mode 100644 (file)
index 0000000..afee1db
--- /dev/null
@@ -0,0 +1,120 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 1998 - 2015 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.
+//
+// ---------------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <deal.II/base/tensor.h>
+
+#include<complex>
+
+
+int main ()
+{
+  initlog();
+
+  float f_scalar = 10.;
+  double d_scalar = 10.;
+  std::complex<double> c_scalar = 10.;
+
+  Tensor<1,2,float>                 f1 = { {1., 2.} };
+  Tensor<1,2,double>                d1 = { {4., 8.} };
+  Tensor<1,2,std::complex<double> > c1 = { {16., 32.} };
+
+  deallog << f1 + d1 << std::endl;
+  deallog << f1 - d1 << std::endl;
+  deallog << f1 * d1 << std::endl;
+
+  deallog << d1 + c1 << std::endl;
+  deallog << d1 - c1 << std::endl;
+  deallog << d1 * c1 << std::endl;
+
+  deallog << (d1 * f_scalar) << std::endl;
+  deallog << (d1 / f_scalar) << std::endl;
+  deallog << (f_scalar * d1) << std::endl;
+  deallog << (d1 *= f_scalar) << std::endl;
+  deallog << (d1 /= f_scalar) << std::endl;
+
+  deallog << (c1 * d_scalar) << std::endl;
+  deallog << (c1 / d_scalar) << std::endl;
+  deallog << (d_scalar * c1) << std::endl;
+  deallog << (c1 *= d_scalar) << std::endl;
+  deallog << (c1 /= d_scalar) << std::endl;
+
+  Tensor<2,2,float> f2;
+  f2[0] = f1;
+  f2[1] = 2. * f1;
+
+  Tensor<2,2,double> d2;
+  d2[0] = d1;
+  d2[1] = 2. * d1;
+
+  Tensor<2,2,std::complex<double> > c2;
+  c2[0] = c1;
+  c2[1] = 2. * c1;
+
+  deallog << f2 + d2 << std::endl;
+  deallog << f2 - d2 << std::endl;
+  deallog << f2 * d2 << std::endl;
+
+  deallog << d2 + c2 << std::endl;
+  deallog << d2 - c2 << std::endl;
+  deallog << d2 * c2 << std::endl;
+
+  deallog << (d2 * f_scalar) << std::endl;
+  deallog << (d2 / f_scalar) << std::endl;
+  deallog << (f_scalar * d2) << std::endl;
+  deallog << (d2 *= f_scalar) << std::endl;
+  deallog << (d2 /= f_scalar) << std::endl;
+
+  deallog << (c2 * d_scalar) << std::endl;
+  deallog << (c2 / d_scalar) << std::endl;
+  deallog << (d_scalar * c2) << std::endl;
+  deallog << (c2 *= d_scalar) << std::endl;
+  deallog << (c2 /= d_scalar) << std::endl;
+
+  Tensor<3,2,float> f3;
+  f3[0] = f2;
+  f3[1] = 2. * f2;
+
+  Tensor<3,2,double> d3;
+  d3[0] = d2;
+  d3[1] = 2. * d2;
+
+  Tensor<3,2,std::complex<double> > c3;
+  c3[0] = c2;
+  c3[1] = 2. * c2;
+
+  deallog << f3 + d3 << std::endl;
+  deallog << f3 - d3 << std::endl;
+  deallog << f3 * d3 << std::endl;
+
+  deallog << d3 + c3 << std::endl;
+  deallog << d3 - c3 << std::endl;
+  deallog << d3 * c3 << std::endl;
+
+  deallog << (d3 * f_scalar) << std::endl;
+  deallog << (d3 / f_scalar) << std::endl;
+  deallog << (f_scalar * d3) << std::endl;
+  deallog << (d3 *= f_scalar) << std::endl;
+  deallog << (d3 /= f_scalar) << std::endl;
+
+  deallog << (c3 * d_scalar) << std::endl;
+  deallog << (c3 / d_scalar) << std::endl;
+  deallog << (d_scalar * c3) << std::endl;
+  deallog << (c3 *= d_scalar) << std::endl;
+  deallog << (c3 /= d_scalar) << std::endl;
+
+  deallog << "OK!" << std::endl;
+}
diff --git a/tests/base/tensor_mixing_types_02.output b/tests/base/tensor_mixing_types_02.output
new file mode 100644 (file)
index 0000000..5845ca6
--- /dev/null
@@ -0,0 +1,50 @@
+
+DEAL::5.00000 10.0000
+DEAL::-3.00000 -6.00000
+DEAL::20.0000
+DEAL::(20.0000,0.00000) (40.0000,0.00000)
+DEAL::(-12.0000,0.00000) (-24.0000,0.00000)
+DEAL::(320.000,0.00000)
+DEAL::40.0000 80.0000
+DEAL::0.400000 0.800000
+DEAL::40.0000 80.0000
+DEAL::40.0000 80.0000
+DEAL::4.00000 8.00000
+DEAL::(160.000,0.00000) (320.000,0.00000)
+DEAL::(1.60000,0.00000) (3.20000,0.00000)
+DEAL::(160.000,0.00000) (320.000,0.00000)
+DEAL::(160.000,0.00000) (320.000,0.00000)
+DEAL::(16.0000,0.00000) (32.0000,0.00000)
+DEAL::5.00000 10.0000 10.0000 20.0000
+DEAL::-3.00000 -6.00000 -6.00000 -12.0000
+DEAL::20.0000 40.0000 40.0000 80.0000
+DEAL::(20.0000,0.00000) (40.0000,0.00000) (40.0000,0.00000) (80.0000,0.00000)
+DEAL::(-12.0000,0.00000) (-24.0000,0.00000) (-24.0000,0.00000) (-48.0000,0.00000)
+DEAL::(320.000,0.00000) (640.000,0.00000) (640.000,0.00000) (1280.00,0.00000)
+DEAL::40.0000 80.0000 80.0000 160.000
+DEAL::0.400000 0.800000 0.800000 1.60000
+DEAL::40.0000 80.0000 80.0000 160.000
+DEAL::40.0000 80.0000 80.0000 160.000
+DEAL::4.00000 8.00000 8.00000 16.0000
+DEAL::(160.000,0.00000) (320.000,0.00000) (320.000,0.00000) (640.000,0.00000)
+DEAL::(1.60000,0.00000) (3.20000,0.00000) (3.20000,0.00000) (6.40000,0.00000)
+DEAL::(160.000,0.00000) (320.000,0.00000) (320.000,0.00000) (640.000,0.00000)
+DEAL::(160.000,0.00000) (320.000,0.00000) (320.000,0.00000) (640.000,0.00000)
+DEAL::(16.0000,0.00000) (32.0000,0.00000) (32.0000,0.00000) (64.0000,0.00000)
+DEAL::5.00000 10.0000 10.0000 20.0000 10.0000 20.0000 20.0000 40.0000
+DEAL::-3.00000 -6.00000 -6.00000 -12.0000 -6.00000 -12.0000 -12.0000 -24.0000
+DEAL::20.0000 40.0000 40.0000 80.0000 40.0000 80.0000 80.0000 160.000 40.0000 80.0000 80.0000 160.000 80.0000 160.000 160.000 320.000
+DEAL::(20.0000,0.00000) (40.0000,0.00000) (40.0000,0.00000) (80.0000,0.00000) (40.0000,0.00000) (80.0000,0.00000) (80.0000,0.00000) (160.000,0.00000)
+DEAL::(-12.0000,0.00000) (-24.0000,0.00000) (-24.0000,0.00000) (-48.0000,0.00000) (-24.0000,0.00000) (-48.0000,0.00000) (-48.0000,0.00000) (-96.0000,0.00000)
+DEAL::(320.000,0.00000) (640.000,0.00000) (640.000,0.00000) (1280.00,0.00000) (640.000,0.00000) (1280.00,0.00000) (1280.00,0.00000) (2560.00,0.00000) (640.000,0.00000) (1280.00,0.00000) (1280.00,0.00000) (2560.00,0.00000) (1280.00,0.00000) (2560.00,0.00000) (2560.00,0.00000) (5120.00,0.00000)
+DEAL::40.0000 80.0000 80.0000 160.000 80.0000 160.000 160.000 320.000
+DEAL::0.400000 0.800000 0.800000 1.60000 0.800000 1.60000 1.60000 3.20000
+DEAL::40.0000 80.0000 80.0000 160.000 80.0000 160.000 160.000 320.000
+DEAL::40.0000 80.0000 80.0000 160.000 80.0000 160.000 160.000 320.000
+DEAL::4.00000 8.00000 8.00000 16.0000 8.00000 16.0000 16.0000 32.0000
+DEAL::(160.000,0.00000) (320.000,0.00000) (320.000,0.00000) (640.000,0.00000) (320.000,0.00000) (640.000,0.00000) (640.000,0.00000) (1280.00,0.00000)
+DEAL::(1.60000,0.00000) (3.20000,0.00000) (3.20000,0.00000) (6.40000,0.00000) (3.20000,0.00000) (6.40000,0.00000) (6.40000,0.00000) (12.8000,0.00000)
+DEAL::(160.000,0.00000) (320.000,0.00000) (320.000,0.00000) (640.000,0.00000) (320.000,0.00000) (640.000,0.00000) (640.000,0.00000) (1280.00,0.00000)
+DEAL::(160.000,0.00000) (320.000,0.00000) (320.000,0.00000) (640.000,0.00000) (320.000,0.00000) (640.000,0.00000) (640.000,0.00000) (1280.00,0.00000)
+DEAL::(16.0000,0.00000) (32.0000,0.00000) (32.0000,0.00000) (64.0000,0.00000) (32.0000,0.00000) (64.0000,0.00000) (64.0000,0.00000) (128.000,0.00000)
+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.