]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Extend block matrix test.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 May 2000 11:28:20 +0000 (11:28 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 May 2000 11:28:20 +0000 (11:28 +0000)
git-svn-id: https://svn.dealii.org/trunk@2823 0785d39b-7218-0410-832d-ea1e28bc413d

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

index d442bf71e6beb844c925fbd883715eb40a5c8cda..9d8af4ef881fdaf9d0c1d10cf1f1d6d9bb12a32c 100644 (file)
@@ -15,6 +15,7 @@
 #include <base/logstream.h>
 #include <lac/block_sparsity_pattern.h>
 #include <lac/block_sparse_matrix.h>
+#include <lac/block_vector.h>
 #include <fstream>
 #include <algorithm>
 
@@ -139,6 +140,55 @@ void test ()
   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);
+
+                                  // now allocate two block vectors
+                                  // and see what we can get after
+                                  // vmults:
+  BlockVector<2,double> src;
+  vector<unsigned int> src_sizes (2);
+  src_sizes[0] = 10;
+  src_sizes[1] = 19;
+  src.reinit (src_sizes);
+
+  BlockVector<3,double> dst;
+  vector<unsigned int> dst_sizes (3);
+  dst_sizes[0] = 2;
+  dst_sizes[1] = 7;
+  dst_sizes[2] = 10;
+  dst.reinit (dst_sizes);
+
+  for (unsigned int i=0; i<29; ++i)
+    src(i) = i;
+
+  bsm.vmult (dst, src);
+                                  // now check what came out
+  for (unsigned int row=0; row<19; ++row)
+    {
+      vector<double> t(29, 0);
+                                      // first check which elements
+                                      // in this row exist
+      for (unsigned int i=0; i<10; ++i)
+       t[(row*5+i*9)%29] = row*((row*5+i*9)%29);
+      
+      for (unsigned int i=0; i<10; ++i)
+       t[(row*5+i*9)%29] += 0.5;
+
+                                      // compute the exact result
+      double row_sum = 0;
+      for (unsigned int i=0; i<29; ++i)
+       row_sum += t[i]*i;
+
+                                      // compare to vmult result
+      Assert (row_sum == dst(row), ExcInternalError());
+      deallog << "vmult " << row << ' ' << row_sum << ' ' << dst(row) << endl;
+    };
+
+
+                                  // test matrix_scalar_product. note that dst=M*src
+  const double msp1 = dst.norm_sqr ();
+  const double msp2 = bsm.matrix_scalar_product (dst, src);
+  Assert (msp1 == msp2, ExcInternalError());
+  deallog << "matrix_scalar_product " << msp1 << ' ' << msp2 << endl;
 };
 
 
index 3172c91cda720828ecaaaa65729a2b7b06b3cc99..cdf08f7c9ab56277fda36e8ae77cbdec9b147a8b 100644 (file)
@@ -39,3 +39,23 @@ DEAL::Row 18 sparsity:  01010000111010000101010000101
 DEAL::Row=18: expected length=11, actual length=11
 DEAL::196==196
 DEAL::196==196
+DEAL::vmult 0 72.000 72.000
+DEAL::vmult 1 2658.000 2658.000
+DEAL::vmult 2 6332.500 6332.500
+DEAL::vmult 3 6288.000 6288.000
+DEAL::vmult 4 10810.500 10810.500
+DEAL::vmult 5 12221.500 12221.500
+DEAL::vmult 6 18749.000 18749.000
+DEAL::vmult 7 14275.500 14275.500
+DEAL::vmult 8 20949.000 20949.000
+DEAL::vmult 9 20999.000 20999.000
+DEAL::vmult 10 29845.500 29845.500
+DEAL::vmult 11 29848.500 29848.500
+DEAL::vmult 12 31135.500 31135.500
+DEAL::vmult 13 29638.500 29638.500
+DEAL::vmult 14 40618.000 40618.000
+DEAL::vmult 15 39010.000 39010.000
+DEAL::vmult 16 39234.000 39234.000
+DEAL::vmult 17 51127.500 51127.500
+DEAL::vmult 18 51714.500 51714.500
+DEAL::matrix_scalar_product 15416941535.500 15416941535.500

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.