]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix up a number of tests.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 6 Feb 2004 20:07:14 +0000 (20:07 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 6 Feb 2004 20:07:14 +0000 (20:07 +0000)
git-svn-id: https://svn.dealii.org/trunk@8414 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/Makefile
tests/bits/sparse_matrix_01.cc
tests/bits/sparse_matrix_02.cc
tests/bits/sparse_matrix_03.cc
tests/bits/sparse_matrix_05.cc
tests/bits/sparse_matrix_05a.cc [new file with mode: 0644]
tests/bits/sparse_matrix_09.cc
tests/bits/sparse_matrix_10.cc

index 371dd940576f9b5ff0b03b8652e5d8a4320c1be1..f049c910b9bca98897010da0ba970b5e4444f47d 100644 (file)
@@ -142,6 +142,7 @@ sparse_matrix_02.exe    : sparse_matrix_02.g.$(OBJEXT)     $(libraries)
 sparse_matrix_03.exe    : sparse_matrix_03.g.$(OBJEXT)     $(libraries)
 sparse_matrix_04.exe    : sparse_matrix_04.g.$(OBJEXT)     $(libraries)
 sparse_matrix_05.exe    : sparse_matrix_05.g.$(OBJEXT)     $(libraries)
+sparse_matrix_05a.exe   : sparse_matrix_05a.g.$(OBJEXT)    $(libraries)
 sparse_matrix_06.exe    : sparse_matrix_06.g.$(OBJEXT)     $(libraries)
 sparse_matrix_07.exe    : sparse_matrix_07.g.$(OBJEXT)     $(libraries)
 sparse_matrix_08.exe    : sparse_matrix_08.g.$(OBJEXT)     $(libraries)
@@ -201,7 +202,8 @@ tests = anna_1 anna_2 anna_3 anna_4 anna_5 anna_6 \
        mapping_q4_3d \
        q_points find_cell_1 find_cell_2 find_cell_3 \
         sparse_matrix_01 sparse_matrix_02 sparse_matrix_03 \
-        sparse_matrix_04 sparse_matrix_05 sparse_matrix_06 \
+        sparse_matrix_04 sparse_matrix_05 sparse_matrix_05a \
+       sparse_matrix_06 \
         sparse_matrix_07 sparse_matrix_08 sparse_matrix_09 \
         sparse_matrix_10 sparse_matrix_11 sparse_matrix_12
 
index 37f3443c01bd199c8ac1d60946ae2b2f30649649..f39ea3f7ecd1c7f36ffbfe1e31ac7759e9391a77 100644 (file)
@@ -48,7 +48,6 @@ void test ()
         }
       else
         {
-          Assert (m(i,j) == 0, ExcInternalError());
           Assert (m.el(i,j) == 0, ExcInternalError());
         }
 
index 011fca11cc434a2a4060f8ce5e1e52a7568f35bd..5dcf7947bed3e122f74612122c069d20e536bc1a 100644 (file)
@@ -47,7 +47,6 @@ void test ()
         }
       else
         {
-          Assert (m(i,j) == 0, ExcInternalError());
           Assert (m.el(i,j) == 0, ExcInternalError());
         }
 
index c193db18ddede163b5d7581ce153febbb15571b7..ce542d7d247d8060b64d0ea634110e427c3b1f8b 100644 (file)
@@ -54,7 +54,6 @@ void test ()
         }
       else
         {
-          Assert (m(i,j) == 0, ExcInternalError());
           Assert (m.el(i,j) == 0, ExcInternalError());
         }
 
index 45a6cc202dfe46047cdb6963ed38858b0ae58e1e..0f2f3f152ed53851a44a36b7aedf3179dc267565 100644 (file)
@@ -32,15 +32,23 @@ void test ()
   SparseMatrix<double> m(sp);
   
                                    // first set a few entries. count how many
-                                   // entries we have
+                                   // entries we have. note that for square
+                                   // matrices we also always store the
+                                   // diagonal element, so add one per row,
+                                   // but don't count it when traversing the
+                                   // row
   unsigned int counter = 0;
   for (unsigned int i=0; i<m.m(); ++i)
-    for (unsigned int j=0; j<m.m(); ++j)
-      if ((i+2*j+1) % 3 == 0)
-        {
-          m.set (i,j, i*j*.5+.5);
-          ++counter;
-        }
+    {
+      for (unsigned int j=0; j<m.m(); ++j)
+        if ((i+2*j+1) % 3 == 0)
+          {
+            m.set (i,j, i*j*.5+.5);
+            if (i!=j)
+              ++counter;
+          }
+      ++counter;
+    }
 
   deallog << m.n_nonzero_elements() << std::endl;
   Assert (m.n_nonzero_elements() == counter,
diff --git a/tests/bits/sparse_matrix_05a.cc b/tests/bits/sparse_matrix_05a.cc
new file mode 100644 (file)
index 0000000..944c439
--- /dev/null
@@ -0,0 +1,92 @@
+//----------------------------  sparse_matrix_05a.cc  ---------------------------
+//    sparse_matrix_05.cc,v 1.4 2003/07/03 10:31:46 guido Exp
+//    Version: 
+//
+//    Copyright (C) 2004 by the deal.II authors and Anna Schneebeli
+//
+//    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.
+//
+//----------------------------  sparse_matrix_05a.cc  ---------------------------
+
+
+// check querying the number of nonzero elements in
+// SparseMatrix when we don't store the diagonal elements explicitly
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>    
+#include <fstream>
+
+
+void test ()
+{
+  SparsityPattern sp (5,5,3,false);
+  for (unsigned int i=0; i<5; ++i)
+    for (unsigned int j=0; j<5; ++j)
+      if ((i+2*j+1) % 3 == 0)
+        sp.add (i,j);
+  sp.compress ();
+
+  SparseMatrix<double> m(sp);
+  
+                                   // first set a few entries. count how many
+                                   // entries we have. note that for square
+                                   // matrices we also always store the
+                                   // diagonal element, except when as above
+                                   // we set the special flag for the matrix
+                                   // sparsity pattern
+  unsigned int counter = 0;
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        {
+          m.set (i,j, i*j*.5+.5);
+          ++counter;
+        }
+
+  deallog << m.n_nonzero_elements() << std::endl;
+  Assert (m.n_nonzero_elements() == counter,
+          ExcInternalError());
+  
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+  std::ofstream logfile("sparse_matrix_05a.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      test ();
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+               << exc.what() << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      
+      return 1;
+    }
+  catch (...) 
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 1;
+    };
+}
index aa2f00457f3dac4cd7c54cbeff7a1fdc103bd959..cf6664361384594fbf0d157905804bc8d97e871f 100644 (file)
@@ -50,7 +50,6 @@ void test ()
         }
       else
         {
-          Assert (m(i,j) == 0, ExcInternalError());
           Assert (m.el(i,j) == 0, ExcInternalError());
         }
 
index 739b8756613893c986372c80bb4c49a80bd6e412..a7969d9d76550ad8af9be012e772618c0207f745 100644 (file)
@@ -50,7 +50,6 @@ void test ()
         }
       else
         {
-          Assert (m(i,j) == 0, ExcInternalError());
           Assert (m.el(i,j) == 0, ExcInternalError());
         }
 

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.