--- /dev/null
+//-----------------------------------------------------------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2010 by the deal.II authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//-----------------------------------------------------------------------------
+
+// test IndexSet::subtract_set
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <stdlib.h>
+
+#include <base/index_set.h>
+
+
+void test ()
+{
+ IndexSet is1 (100);
+ IndexSet is2 (100);
+
+ // randomly add 90 elements to each
+ // set, some of which may be
+ // repetitions of previous ones
+ for (unsigned int i=0; i<9*is1.size()/10; ++i)
+ {
+ is1.add_index (rand() % is1.size());
+ is2.add_index (rand() % is2.size());
+ }
+
+ IndexSet is3 = is1;
+ is3.subtract_set(is2);
+
+ deallog << "Set sizes: "
+ << is1.n_elements() << ' '
+ << is2.n_elements() << ' '
+ << is3.n_elements() << std::endl;
+
+ is1.print(deallog);
+ is2.print(deallog);
+ is3.print(deallog);
+
+
+
+ for (unsigned int i=0; i<is3.size(); ++i)
+ {
+ Assert ((is1.is_element(i) && !is2.is_element(i))
+ ==
+ is3.is_element(i),
+ ExcInternalError());
+ }
+
+ IndexSet empty(100);
+ is3 = is1;
+ is3.subtract_set(empty);
+
+ Assert (is3 == is1, ExcInternalError());
+
+ is3.subtract_set(is1);
+ Assert (is3 == empty, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+
+int main()
+{
+ std::ofstream logfile("index_set_15/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ test ();
+}
--- /dev/null
+
+DEAL::Set sizes: 61 56 31
+DEAL::{1, 3, [5,6], [8,9], 11, [13,15], [17,19], [21,22], 24, [26,29], [31,32], 34, 36, [39,41], [43,44], 46, 49, 52, 54, 56, 59, [62,65], 67, [69,70], 72, [76,77], 79, [81,84], [86,88], [90,91], [93,98]}
+DEAL::{[0,2], 5, 8, 12, [14,15], 17, 19, 21, [23,30], [35,37], 39, [41,42], 45, [49,51], 53, [55,60], [64,65], [67,68], [70,71], 73, 75, 78, [80,81], [83,84], 86, [88,89], [91,92], 95, 99}
+DEAL::{3, 6, 9, 11, 13, 18, 22, [31,32], 34, 40, [43,44], 46, 52, 54, [62,63], 69, 72, [76,77], 79, 82, 87, 90, [93,94], [96,98]}
+DEAL::OK
--- /dev/null
+
+//-----------------------------------------------------------------------------
+// $Id: index_set_15.cc 20519 2010-02-08 10:23:05Z heister $
+// Version: $Name$
+//
+// Copyright (C) 2010 by the deal.II authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//-----------------------------------------------------------------------------
+
+// test IndexSet::subtract_set further
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <stdlib.h>
+
+#include <base/index_set.h>
+
+
+void test ()
+{
+ IndexSet is1 (100);
+ IndexSet is2 (100);
+
+ is1.add_range(0,10);
+ is1.add_range(20,100);
+
+ is2.add_range(0,50);
+// is2.add_range(10,15);
+
+ IndexSet is3 = is1;
+ is3.subtract_set(is2);
+
+ is1.print(deallog);
+ is2.print(deallog);
+ is3.print(deallog);
+
+ for (unsigned int i=0; i<is3.size(); ++i)
+ {
+ Assert ((is1.is_element(i) && !is2.is_element(i))
+ ==
+ is3.is_element(i),
+ ExcInternalError());
+ }
+
+ deallog << is3.index_within_set(51) << std::endl;
+ Assert(is3.index_within_set(51)==1, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+
+int main()
+{
+ std::ofstream logfile("index_set_16/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ test ();
+}
--- /dev/null
+
+DEAL::{[0,9], [20,99]}
+DEAL::{[0,49]}
+DEAL::{[50,99]}
+DEAL::1
+DEAL::OK