]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add another test. 6081/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 21 Mar 2018 20:09:26 +0000 (14:09 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 21 Mar 2018 20:09:26 +0000 (14:09 -0600)
tests/sparsity/sparsity_pattern_full_matrix_02.cc [new file with mode: 0644]
tests/sparsity/sparsity_pattern_full_matrix_02.output [new file with mode: 0644]

diff --git a/tests/sparsity/sparsity_pattern_full_matrix_02.cc b/tests/sparsity/sparsity_pattern_full_matrix_02.cc
new file mode 100644 (file)
index 0000000..9d1f173
--- /dev/null
@@ -0,0 +1,53 @@
+
+// ---------------------------------------------------------------------
+//
+// 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 at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// Check SparsityPattern::copy_from(FullMatrix). The peer review of
+// the original patch uncovered a case where we would segfault with
+// empty matrices. Cover this in a testcase as well.
+
+#include "../tests.h"
+#include <deal.II/lac/sparsity_pattern.h>
+#include <deal.II/lac/full_matrix.h>
+
+
+void test (const unsigned int M,
+           const unsigned int N)
+{
+  SparsityPattern sp (M,N);
+
+  // fill a full matrix completely
+  FullMatrix<double> mat(M,N);
+  for (unsigned int m=0; m<M; ++m)
+    for (unsigned int n=0; n<N; ++n)
+      mat(m,n) = 1;
+
+  // then copy the nonzero entries of 'mat' (i.e., all entries) to the
+  // sparsity pattern
+  sp.copy_from (mat);
+
+  deallog << sp.n_nonzero_elements() << std::endl;
+}
+
+
+
+int main ()
+{
+  initlog();
+
+  test (0, 0);
+}
diff --git a/tests/sparsity/sparsity_pattern_full_matrix_02.output b/tests/sparsity/sparsity_pattern_full_matrix_02.output
new file mode 100644 (file)
index 0000000..199228a
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::0

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.