]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 May 2000 17:13:21 +0000 (17:13 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 5 May 2000 17:13:21 +0000 (17:13 +0000)
git-svn-id: https://svn.dealii.org/trunk@2817 0785d39b-7218-0410-832d-ea1e28bc413d

tests/lac/block_matrices.cc
tests/lac/block_matrices.checked

index 971cc45f997d49eb820ac5c80ca2f91287529070..d442bf71e6beb844c925fbd883715eb40a5c8cda 100644 (file)
 
 #include <base/logstream.h>
 #include <lac/block_sparsity_pattern.h>
+#include <lac/block_sparse_matrix.h>
 #include <fstream>
 #include <algorithm>
 
 
 
 
-int main () 
+void test () 
 {
   ofstream logfile("block_matrices.output");
   logfile.setf(ios::fixed);
@@ -71,6 +72,7 @@ int main ()
                                   // their places are checked later
                                   // with the matrix-vector
                                   // operations.
+  unsigned int total_nonzero_elements = 0;
   for (unsigned int row=0; row<19; ++row)
     {
                                       // first count the number of
@@ -91,7 +93,7 @@ int main ()
       deallog << endl;
       
       const unsigned int c=count(t.begin(), t.end(), true);
-
+      
                                       // now see how many elements
                                       // there really are:
       unsigned int ac=0;
@@ -107,6 +109,72 @@ int main ()
              << ": expected length=" << c
              << ", actual length=" << ac
              << endl;
-      Assert (c==ac, ExcInternalError());
+      total_nonzero_elements += ac;
+      AssertThrow (c==ac, ExcInternalError());
+    };
+  deallog << total_nonzero_elements << "=="
+         << bsp.n_nonzero_elements()
+         << endl;
+  AssertThrow (total_nonzero_elements == bsp.n_nonzero_elements(),
+              ExcInternalError());
+
+
+
+  
+                                  // now make a matrix with this
+                                  // sparsity pattern
+  BlockSparseMatrix<double,3,2> bsm (bsp);
+  deallog << total_nonzero_elements << "=="
+         << bsm.n_nonzero_elements()
+         << endl;
+  AssertThrow (total_nonzero_elements == bsm.n_nonzero_elements(),
+              ExcInternalError());
+  
+                                  // try to write something into it,
+                                  // set entry (i,j) to i*j
+  for (unsigned int row=0; row<19; ++row)
+    for (unsigned int i=0; i<10; ++i)
+      bsm.set (row, (row*5+i*9)%29, row*((row*5+i*9)%29));
+                                  // and add .5 to each value
+  for (unsigned int row=0; row<19; ++row)
+    for (unsigned int i=0; i<10; ++i)
+      bsm.add (row, (row*5+i*9)%29, 0.5);
+};
+
+
+
+
+int main ()
+{
+  try
+    {
+      test ();
+    }
+  catch (exception &e)
+    {
+      cerr << endl << endl
+          << "----------------------------------------------------"
+          << endl;
+      cerr << "Exception on processing: " << e.what() << endl
+          << "Aborting!" << endl
+          << "----------------------------------------------------"
+          << endl;
+                                      // abort
+      return 2;
+    }
+  catch (...) 
+    {
+      cerr << endl << endl
+          << "----------------------------------------------------"
+          << endl;
+      cerr << "Unknown exception!" << endl
+          << "Aborting!" << endl
+          << "----------------------------------------------------"
+          << endl;
+                                      // abort
+      return 3;
     };
+  
+  
+  return 0;
 };
index a5fa48ce4fae3bc9c9c9b0f7cf801f6b9e8ce8b2..3172c91cda720828ecaaaa65729a2b7b06b3cc99 100644 (file)
@@ -37,3 +37,5 @@ DEAL::Row 17 sparsity:  00010101100010101000010101010
 DEAL::Row=17: expected length=11, actual length=11
 DEAL::Row 18 sparsity:  01010000111010000101010000101
 DEAL::Row=18: expected length=11, actual length=11
+DEAL::196==196
+DEAL::196==196

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.