]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test to check that the vector can be print in a format readable by numpy
authorBruno Turcksin <bruno.turcksin@gmail.com>
Sun, 2 Jun 2019 22:51:26 +0000 (18:51 -0400)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 12 Jun 2019 13:01:30 +0000 (09:01 -0400)
tests/lac/la_vector_print.cc [new file with mode: 0644]
tests/lac/la_vector_print.output [new file with mode: 0644]

diff --git a/tests/lac/la_vector_print.cc b/tests/lac/la_vector_print.cc
new file mode 100644 (file)
index 0000000..c7f2317
--- /dev/null
@@ -0,0 +1,44 @@
+// ---------------------------------------------------------------------
+//
+// 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// Check that print_numpy_array works
+
+#include <deal.II/lac/la_vector.h>
+
+#include "../tests.h"
+
+
+template <typename number>
+void
+print_vector()
+{
+  const unsigned int            size = 20;
+  LinearAlgebra::Vector<number> vec(size);
+  for (unsigned int i = 0; i < size; ++i)
+    vec(i) = static_cast<number>(i);
+
+  vec.print_numpy_array(deallog.get_file_stream());
+}
+
+
+int
+main()
+{
+  initlog();
+
+  print_vector<float>();
+  print_vector<double>();
+}
diff --git a/tests/lac/la_vector_print.output b/tests/lac/la_vector_print.output
new file mode 100644 (file)
index 0000000..8468fc4
--- /dev/null
@@ -0,0 +1,3 @@
+
+0.00000000 1.00000000 2.00000000 3.00000000 4.00000000 5.00000000 6.00000000 7.00000000 8.00000000 9.00000000 10.0000000 11.0000000 12.0000000 13.0000000 14.0000000 15.0000000 16.0000000 17.0000000 18.0000000 19.0000000
+0.00000000 1.00000000 2.00000000 3.00000000 4.00000000 5.00000000 6.00000000 7.00000000 8.00000000 9.00000000 10.0000000 11.0000000 12.0000000 13.0000000 14.0000000 15.0000000 16.0000000 17.0000000 18.0000000 19.0000000

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.