]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Filter out small float number in FullMatrix test.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 6 Nov 2017 10:03:48 +0000 (11:03 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 6 Nov 2017 10:03:48 +0000 (11:03 +0100)
tests/full_matrix/full_matrix_53.output
tests/full_matrix/full_matrix_common.h

index 72779c8a0c88d67799e57dc855c9bb43cee15e94..dca760fd5f36f978e0643d2661946cda99d67998 100644 (file)
@@ -31,7 +31,7 @@ DEAL::-0.11 0.11
 DEAL::0.72 -0.22 
 DEAL::Identity = A*A_r_inv
 DEAL::2x2 matrix
-DEAL::1.0 -2.2e-16 
+DEAL::1.0 0.0 
 DEAL::0.0 1.0 
 DEAL::
 DEAL::B matrix
@@ -45,8 +45,8 @@ DEAL::-1.3 -0.33 0.67
 DEAL::1.1 0.33 -0.42 
 DEAL::Identity = B_l_inv*B
 DEAL::2x2 matrix
-DEAL::1.0 -1.7e-14 
-DEAL::1.8e-15 1.0 
+DEAL::1.0 0.0 
+DEAL::0.0 1.0 
 DEAL::A matrix
 DEAL::1x2 matrix
 DEAL::1.0 2.0 
@@ -79,8 +79,8 @@ DEAL::-0.11 0.11
 DEAL::0.72 -0.22 
 DEAL::Identity = A*A_r_inv
 DEAL::2x2 matrix
-DEAL::1.0 -1.2e-07 
-DEAL::-9.5e-07 1.0 
+DEAL::1.0 0.0 
+DEAL::0.0 1.0 
 DEAL::
 DEAL::B matrix
 DEAL::3x2 matrix
@@ -93,5 +93,5 @@ DEAL::-1.3 -0.33 0.67
 DEAL::1.1 0.33 -0.42 
 DEAL::Identity = B_l_inv*B
 DEAL::2x2 matrix
-DEAL::1.0 9.1e-06 
-DEAL::-9.5e-07 1.0 
+DEAL::1.0 0.0 
+DEAL::0.0 1.0 
index e2c71f874fffaaf3fb0a05605c041f6171d7496d..c4b71a4fb55cde39258300df1643682f4ff40413 100644 (file)
@@ -80,10 +80,10 @@ template <typename number>
 void
 print_matrix (const FullMatrix<number> &m)
 {
+  const number tolerance = 100.*std::numeric_limits<number>::epsilon();
   for (unsigned int i=0; i<m.m(); ++i)
     for (unsigned int j=0; j<m.n(); ++j)
-      // make sure we also respect output thresholds on floats
-      deallog << i << ' ' << j << ' ' << (double)m(i,j)
+      deallog << i << ' ' << j << ' ' << filter_out_small_numbers(m(i,j),tolerance)
               << std::endl;
 }
 
@@ -93,9 +93,10 @@ template <typename number>
 void
 print_matrix (const FullMatrix<std::complex<number> > &m)
 {
+  const number tolerance = 100.*std::numeric_limits<number>::epsilon();
   for (unsigned int i=0; i<m.m(); ++i)
     for (unsigned int j=0; j<m.n(); ++j)
-      deallog << i << ' ' << j << ' ' << m(i,j)
+      deallog << i << ' ' << j << ' ' << filter_out_small_numbers(m(i,j),tolerance)
               << std::endl;
 }
 
@@ -105,8 +106,10 @@ template <typename number>
 void
 print_vector (const Vector<number> &v)
 {
+  const typename numbers::NumberTraits<number>::real_type tolerance
+    = 100.*std::numeric_limits<typename numbers::NumberTraits<number>::real_type>::epsilon();
   for (unsigned int i=0; i<v.size(); ++i)
-    deallog << i << ' ' << v(i)
+    deallog << i << ' ' << filter_out_small_numbers(v(i),tolerance)
             << std::endl;
 }
 
@@ -114,13 +117,13 @@ template <typename number>
 void
 display_matrix(FullMatrix<number> M)
 {
+  const number tolerance = 100.*std::numeric_limits<number>::epsilon();
   deallog<<M.m()<<"x"<<M.n()<<" matrix"<<std::endl;
   for (unsigned int i=0; i<M.m(); i++)
     {
-      // make sure we also respect output thresholds on floats
       for (unsigned int j=0; j<M.n(); j++)
-        deallog<<(double)M(i,j)<<" ";
-      deallog<<std::endl;
+        deallog << filter_out_small_numbers(M(i,j),tolerance) << " ";
+      deallog << std::endl;
     }
 }
 
@@ -128,11 +131,12 @@ template <typename number>
 void
 display_matrix(FullMatrix<std::complex<number> > M)
 {
+  const number tolerance = 100.*std::numeric_limits<number>::epsilon();
   deallog<<M.m()<<"x"<<M.n()<<" matrix"<<std::endl;
   for (unsigned int i=0; i<M.m(); i++)
     {
       for (unsigned int j=0; j<M.n(); j++)
-        deallog<<M(i,j)<<" ";
+        deallog << filter_out_small_numbers(M(i,j),tolerance) << " ";
       deallog<<std::endl;
     }
 }

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.