From: wolf Date: Fri, 5 May 2000 17:13:21 +0000 (+0000) Subject: . X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c406a3b22d114998923917a4b481922cb8849b9a;p=dealii-svn.git . git-svn-id: https://svn.dealii.org/trunk@2817 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/lac/block_matrices.cc b/tests/lac/block_matrices.cc index 971cc45f99..d442bf71e6 100644 --- a/tests/lac/block_matrices.cc +++ b/tests/lac/block_matrices.cc @@ -14,13 +14,14 @@ #include #include +#include #include #include -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 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; }; diff --git a/tests/lac/block_matrices.checked b/tests/lac/block_matrices.checked index a5fa48ce4f..3172c91cda 100644 --- a/tests/lac/block_matrices.checked +++ b/tests/lac/block_matrices.checked @@ -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