]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test 3040/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 31 Aug 2016 16:37:25 +0000 (18:37 +0200)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 31 Aug 2016 16:37:25 +0000 (18:37 +0200)
tests/sparsity/sparsity_pattern_copy_from_01.cc [moved from tests/sparsity/sparsity_pattern_copy_from.cc with 100% similarity]
tests/sparsity/sparsity_pattern_copy_from_01.output [moved from tests/sparsity/sparsity_pattern_copy_from.output with 100% similarity]
tests/sparsity/sparsity_pattern_copy_from_02.cc [new file with mode: 0644]
tests/sparsity/sparsity_pattern_copy_from_02.output [new file with mode: 0644]

diff --git a/tests/sparsity/sparsity_pattern_copy_from_02.cc b/tests/sparsity/sparsity_pattern_copy_from_02.cc
new file mode 100644 (file)
index 0000000..ca99f09
--- /dev/null
@@ -0,0 +1,50 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// SparsityPattern::copy_from used to be of quadratic complexity for
+// DynamicSparsityPattern arguments with many empty rows. Create a big
+// sparsity pattern of 10m elements and only put an entry into the last
+// row. The old code would time out.
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/sparsity_pattern.h>
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
+#include <fstream>
+#include <iomanip>
+#include <list>
+#include <set>
+#include <cstdio>
+
+
+int
+main ()
+{
+  std::ofstream logfile("output");
+  logfile.setf(std::ios::fixed);
+  deallog << std::setprecision(3);
+  deallog.attach(logfile);
+  deallog.threshold_double(1.e-10);
+
+  DynamicSparsityPattern csp (10000000, 100);
+  csp.add(9999999, 1);
+
+  SparsityPattern sp;
+  sp.copy_from (csp);
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/sparsity/sparsity_pattern_copy_from_02.output b/tests/sparsity/sparsity_pattern_copy_from_02.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+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.