]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add a test 7206/head
authorMatthias Maier <tamiko@43-1.org>
Wed, 19 Sep 2018 17:52:51 +0000 (12:52 -0500)
committerMatthias Maier <tamiko@43-1.org>
Wed, 19 Sep 2018 17:52:51 +0000 (12:52 -0500)
tests/petsc/sparse_matrix_03.cc [new file with mode: 0644]
tests/petsc/sparse_matrix_03.output [new file with mode: 0644]

diff --git a/tests/petsc/sparse_matrix_03.cc b/tests/petsc/sparse_matrix_03.cc
new file mode 100644 (file)
index 0000000..d04b25b
--- /dev/null
@@ -0,0 +1,74 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check SparseMatrix::transpose
+
+#include <deal.II/lac/petsc_sparse_matrix.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+  const unsigned int          s = 3;
+  PETScWrappers::SparseMatrix m(s, s, s);
+
+  const auto print = [&]() {
+    for (unsigned int i = 0; i < m.m(); ++i)
+      {
+        for (unsigned int j = 0; j < m.n(); ++j)
+          deallog << m(i, j) << " ";
+        deallog << std::endl;
+      }
+  };
+
+  for (unsigned int i = 0; i < m.m(); ++i)
+    for (unsigned int j = 0; j < m.n(); ++j)
+      m.set(i, j, i + m.m() * j);
+
+  m.compress(VectorOperation::insert);
+
+  deallog << "before: " << std::endl;
+  print();
+
+  m.transpose();
+
+  deallog << "after: " << std::endl;
+  print();
+
+  m.transpose();
+
+  deallog << "back to original: " << std::endl;
+  print();
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+  initlog();
+
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  test();
+}
diff --git a/tests/petsc/sparse_matrix_03.output b/tests/petsc/sparse_matrix_03.output
new file mode 100644 (file)
index 0000000..a61e2a5
--- /dev/null
@@ -0,0 +1,14 @@
+
+DEAL::before: 
+DEAL::0.00000 3.00000 6.00000 
+DEAL::1.00000 4.00000 7.00000 
+DEAL::2.00000 5.00000 8.00000 
+DEAL::after: 
+DEAL::0.00000 1.00000 2.00000 
+DEAL::3.00000 4.00000 5.00000 
+DEAL::6.00000 7.00000 8.00000 
+DEAL::back to original: 
+DEAL::0.00000 3.00000 6.00000 
+DEAL::1.00000 4.00000 7.00000 
+DEAL::2.00000 5.00000 8.00000 
+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.