]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Filter away small numbers to avoid roundoff errors for floats.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Sun, 5 Nov 2017 17:33:40 +0000 (18:33 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Sun, 5 Nov 2017 17:33:40 +0000 (18:33 +0100)
tests/full_matrix/full_matrix_09.cc
tests/full_matrix/full_matrix_10.cc

index eff8fb1b12cbfd49c8bbf0e5eaf1ed99208ed350..77ececa4f145111515bff3092d0db406280a15be 100644 (file)
@@ -41,7 +41,8 @@ void test()
 
   C.add(-1., E);
 
-  deallog << "Difference 1: " << (double)C.l1_norm() << std::endl;
+  const double tolerance = 100*std::numeric_limits<Number>::epsilon();
+  deallog << "Difference 1: " << filter_out_small_numbers(C.l1_norm(),tolerance) << std::endl;
 
   C = 0;
   for (unsigned int i=0; i<A.m(); ++i)
@@ -50,7 +51,7 @@ void test()
         C(i,j) += A(i,k) * B(k,j);
   C.add(-1., E);
 
-  deallog << "Difference 2: " << (double)C.l1_norm() << std::endl;
+  deallog << "Difference 2: " << filter_out_small_numbers(C.l1_norm(),tolerance) << std::endl;
 }
 
 int main()
index a737ba768783a3124ea089c907930d9230c470e6..8860f2a3f3c83812f76d01173bb8460844b2a511 100644 (file)
@@ -41,7 +41,7 @@ void test()
         D(i,j) += A(i,k) * B(j,k);
   C.add(-1., D);
 
-  deallog << "Difference: " << (double)C.l1_norm() << std::endl;
+  deallog << "Difference: " << filter_out_small_numbers(C.l1_norm(), std::numeric_limits<Number>::epsilon()*50.) << std::endl;
 }
 
 int main()

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.