]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a test to check std::copy and std::swap with vector of Expressions
authorJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 18 Apr 2019 13:49:59 +0000 (15:49 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Mon, 22 Apr 2019 08:14:28 +0000 (10:14 +0200)
tests/symengine/symengine_number_type_03.cc [new file with mode: 0644]
tests/symengine/symengine_number_type_03.output [new file with mode: 0644]

diff --git a/tests/symengine/symengine_number_type_03.cc b/tests/symengine/symengine_number_type_03.cc
new file mode 100644 (file)
index 0000000..743745d
--- /dev/null
@@ -0,0 +1,56 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 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 that the wrapper for symengine expressions can be use with some
+// of the algorithms defined in the standard namespace
+
+#include <deal.II/differentiation/sd.h>
+
+#include <algorithm>
+
+#include "../tests.h"
+
+using namespace dealii;
+namespace SD = Differentiation::SD;
+
+int
+main()
+{
+  initlog();
+
+  const SD::types::symbol_vector copy_from{SD::Expression(1),
+                                           SD::Expression(true),
+                                           SD::Expression(2.5),
+                                           SD::Expression("a")};
+  SD::types::symbol_vector       copy_to(copy_from.size());
+
+  // Mimics Tensor operator=
+  std::copy(copy_from.begin(), copy_from.end(), copy_to.begin());
+
+  deallog << "Copy" << std::endl;
+  for (unsigned int i = 0; i < copy_from.size(); ++i)
+    deallog << i << ": " << copy_from[i] << " -> " << copy_to[i] << std::endl;
+
+
+  SD::types::symbol_vector swap_to;
+  std::swap(copy_to, swap_to);
+
+  deallog << "Swap" << std::endl;
+  for (unsigned int i = 0; i < swap_to.size(); ++i)
+    deallog << i << ": " << swap_to[i] << std::endl;
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/symengine/symengine_number_type_03.output b/tests/symengine/symengine_number_type_03.output
new file mode 100644 (file)
index 0000000..acf7106
--- /dev/null
@@ -0,0 +1,12 @@
+
+DEAL::Copy
+DEAL::0: 1 -> 1
+DEAL::1: True -> True
+DEAL::2: 2.5 -> 2.5
+DEAL::3: a -> a
+DEAL::Swap
+DEAL::0: 1
+DEAL::1: True
+DEAL::2: 2.5
+DEAL::3: a
+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.