]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Test for FullMatrix move operations 3819/head
authordanshapero <shapero.daniel@gmail.com>
Tue, 17 Jan 2017 07:11:35 +0000 (23:11 -0800)
committerdanshapero <shapero.daniel@gmail.com>
Tue, 17 Jan 2017 23:27:48 +0000 (15:27 -0800)
tests/full_matrix/full_matrix_move.cc [new file with mode: 0644]
tests/full_matrix/full_matrix_move.with_cxx11=on.output [new file with mode: 0644]

diff --git a/tests/full_matrix/full_matrix_move.cc b/tests/full_matrix/full_matrix_move.cc
new file mode 100644 (file)
index 0000000..b1b3dda
--- /dev/null
@@ -0,0 +1,52 @@
+// ---------------------------------------------------------------------
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+
+// Check that FullMatrix objects can be move constructed and assigned
+
+#include "../tests.h"
+
+#include <deal.II/lac/full_matrix.h>
+
+int main()
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.threshold_double(1.0e-10);
+
+  size_t m = 2, n = 3;
+  FullMatrix<double> A(m, n);
+  for (size_t i = 0; i < m; ++i)
+    for (size_t j = 0; j < n; ++j)
+      A(i, j) = n * i + j;
+
+  deallog << "Size of A:" << std::endl
+          << A.m() << " " << A.n() << std::endl;
+
+  FullMatrix<double> B = std::move(A);
+
+  deallog << "Size of B:" << std::endl
+          << B.m() << " " << B.n() << std::endl;
+  deallog << "Size of A:" << std::endl
+          << A.m() << " " << A.n() << std::endl;
+
+  A = std::move(B);
+  deallog << "Size of B:" << std::endl
+          << B.m() << " " << B.n() << std::endl;
+  deallog << "Size of A:" << std::endl
+          << A.m() << " " << A.n() << std::endl;
+
+  return 0;
+}
diff --git a/tests/full_matrix/full_matrix_move.with_cxx11=on.output b/tests/full_matrix/full_matrix_move.with_cxx11=on.output
new file mode 100644 (file)
index 0000000..973682b
--- /dev/null
@@ -0,0 +1,11 @@
+
+DEAL::Size of A:
+DEAL::2 3
+DEAL::Size of B:
+DEAL::2 3
+DEAL::Size of A:
+DEAL::0 0
+DEAL::Size of B:
+DEAL::0 0
+DEAL::Size of A:
+DEAL::2 3

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.