From: Matthias Maier Date: Sat, 12 Sep 2015 05:15:24 +0000 (-0500) Subject: Add a test X-Git-Tag: v8.4.0-rc2~433^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ca9f0a9dba00387e3a76e2a4727e87a9e282fbd;p=dealii.git Add a test --- diff --git a/tests/base/tensor_mixing_types_01.cc b/tests/base/tensor_mixing_types_01.cc index ba51874a79..4a33a0e60e 100644 --- a/tests/base/tensor_mixing_types_01.cc +++ b/tests/base/tensor_mixing_types_01.cc @@ -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 index 0000000000..afee1dbbce --- /dev/null +++ b/tests/base/tensor_mixing_types_02.cc @@ -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 + +#include + + +int main () +{ + initlog(); + + float f_scalar = 10.; + double d_scalar = 10.; + std::complex c_scalar = 10.; + + Tensor<1,2,float> f1 = { {1., 2.} }; + Tensor<1,2,double> d1 = { {4., 8.} }; + Tensor<1,2,std::complex > 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 > 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 > 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 index 0000000000..5845ca66de --- /dev/null +++ b/tests/base/tensor_mixing_types_02.output @@ -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!