]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix Utilities::fixed_power for VectorizedArray. 4696/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 4 Aug 2017 16:27:56 +0000 (18:27 +0200)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 4 Aug 2017 16:27:56 +0000 (18:27 +0200)
include/deal.II/base/utilities.h
tests/base/utilities_12.cc [new file with mode: 0644]
tests/base/utilities_12.output [new file with mode: 0644]

index e46c586d66476da3736f99c4a2aeb3fc0229aaa2..788ddaaff2a1a1bcc5cc64d18213093c507c92c7 100644 (file)
@@ -601,7 +601,7 @@ namespace Utilities
     switch (N)
       {
       case 0:
-        return 1;
+        return dealii::internal::NumberType<T>::value(1);
       case 1:
         return n;
       case 2:
diff --git a/tests/base/utilities_12.cc b/tests/base/utilities_12.cc
new file mode 100644 (file)
index 0000000..d39ee2c
--- /dev/null
@@ -0,0 +1,60 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 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.
+//
+// ---------------------------------------------------------------------
+
+
+// test Utilities::fixed_power on VectorizedArray, similar to utilities_02
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+
+#include <deal.II/base/vectorization.h>
+#include <deal.II/base/utilities.h>
+
+
+template <int dim>
+void test ()
+{
+  VectorizedArray<double> v1 = make_vectorized_array(2.);
+  v1 = Utilities::fixed_power<dim>(v1);
+  deallog << v1[0] << std::endl;
+  v1 = -2;
+  v1 = Utilities::fixed_power<dim>(v1);
+  deallog << v1[0] << std::endl;
+  v1 = 2.5;
+  v1 = Utilities::fixed_power<dim>(v1);
+  deallog << v1[0] << std::endl;
+  VectorizedArray<float> v2 = make_vectorized_array<float>(-2.5);
+  v2 = Utilities::fixed_power<dim>(v2);
+  deallog << (double)v2[0] << std::endl;
+  deallog << std::endl;
+}
+
+
+
+
+int main()
+{
+  initlog();
+  deallog.threshold_double(1.e-10);
+
+  test<0> ();
+  test<1> ();
+  test<2> ();
+  test<3> ();
+  test<4> ();
+}
diff --git a/tests/base/utilities_12.output b/tests/base/utilities_12.output
new file mode 100644 (file)
index 0000000..829812b
--- /dev/null
@@ -0,0 +1,26 @@
+
+DEAL::1.00000
+DEAL::1.00000
+DEAL::1.00000
+DEAL::1.00000
+DEAL::
+DEAL::2.00000
+DEAL::-2.00000
+DEAL::2.50000
+DEAL::-2.50000
+DEAL::
+DEAL::4.00000
+DEAL::4.00000
+DEAL::6.25000
+DEAL::6.25000
+DEAL::
+DEAL::8.00000
+DEAL::-8.00000
+DEAL::15.6250
+DEAL::-15.6250
+DEAL::
+DEAL::16.0000
+DEAL::16.0000
+DEAL::39.0625
+DEAL::39.0625
+DEAL::

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.