]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New tests.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 23 Feb 2004 21:39:23 +0000 (21:39 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 23 Feb 2004 21:39:23 +0000 (21:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@8496 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/Makefile
tests/bits/full_matrix_vector_01.cc [new file with mode: 0644]
tests/bits/full_matrix_vector_02.cc [new file with mode: 0644]
tests/bits/full_matrix_vector_05.cc [new file with mode: 0644]
tests/bits/full_matrix_vector_06.cc [new file with mode: 0644]
tests/bits/full_matrix_vector_07.cc [new file with mode: 0644]
tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_01.output [new file with mode: 0644]
tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_02.output [new file with mode: 0644]
tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_05.output [new file with mode: 0644]
tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_06.output [new file with mode: 0644]
tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_07.output [new file with mode: 0644]

index e44d116e2bf7d5d82ae3559f4d62e8948a0bc48e..f57862e88bfba77f3097c0809a8b2bc204d22d5a 100644 (file)
@@ -46,7 +46,8 @@ tests_x = anna_? \
          mapping_q4_3d \
          q_points \
           find_cell_* \
-          sparse_matrix_*
+          sparse_matrix_* \
+         full_matrix_vector_*
 
 ifeq ($(USE_CONTRIB_PETSC),yes)
   tests_x += petsc_*
diff --git a/tests/bits/full_matrix_vector_01.cc b/tests/bits/full_matrix_vector_01.cc
new file mode 100644 (file)
index 0000000..cad3631
--- /dev/null
@@ -0,0 +1,94 @@
+//----------------------------  full_matrix_vector_01.cc  ---------------------------
+//    $Id$
+//    Version: 
+//
+//    Copyright (C) 2004 by the deal.II authors and Anna Schneebeli
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  full_matrix_vector_01.cc  ---------------------------
+
+
+// check FullMatrix::vmult
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <lac/full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+           Vector<double> &w)
+{
+  FullMatrix<double> m(v.size(), v.size());
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+        m(i,j) = ( i+2*j);
+
+  for (unsigned int i=0; i<v.size(); ++i)
+    v(i) = i;
+  
+  v.compress ();
+  w.compress ();
+
+                                   // w:=Mv
+  m.vmult (w,v);
+
+                                   // make sure we get the expected result
+  for (unsigned int i=0; i<v.size(); ++i)
+    {
+      Assert (v(i) == i, ExcInternalError());
+
+      double result = 0;
+      for (unsigned int j=0; j<m.m(); ++j)
+        result += (i+2*j)*j;
+      Assert (w(i) == result, ExcInternalError());
+    }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("full_matrix_vector_01.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      Vector<double> v (100);
+      Vector<double> w (100);
+      test (v,w);
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+               << exc.what() << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      
+      return 1;
+    }
+  catch (...) 
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/bits/full_matrix_vector_02.cc b/tests/bits/full_matrix_vector_02.cc
new file mode 100644 (file)
index 0000000..722757b
--- /dev/null
@@ -0,0 +1,94 @@
+//----------------------------  full_matrix_vector_02.cc  ---------------------------
+//    $Id$
+//    Version: 
+//
+//    Copyright (C) 2004 by the deal.II authors and Anna Schneebeli
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  full_matrix_vector_02.cc  ---------------------------
+
+
+// check FullMatrix::Tvmult
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <lac/full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+           Vector<double> &w)
+{
+  FullMatrix<double> m(v.size(), v.size());
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+        m(i,j) = ( i+2*j);
+
+  for (unsigned int i=0; i<v.size(); ++i)
+    v(i) = i;
+  
+  v.compress ();
+  w.compress ();
+
+                                   // w:=Mv
+  m.Tvmult (w,v);
+
+                                   // make sure we get the expected result
+  for (unsigned int i=0; i<v.size(); ++i)
+    {
+      Assert (v(i) == i, ExcInternalError());
+
+      double result = 0;
+      for (unsigned int j=0; j<m.m(); ++j)
+        result += (j+2*i)*j;
+      Assert (w(i) == result, ExcInternalError());
+    }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("full_matrix_vector_02.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      Vector<double> v (100);
+      Vector<double> w (100);
+      test (v,w);
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+               << exc.what() << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      
+      return 1;
+    }
+  catch (...) 
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/bits/full_matrix_vector_05.cc b/tests/bits/full_matrix_vector_05.cc
new file mode 100644 (file)
index 0000000..b7d5300
--- /dev/null
@@ -0,0 +1,100 @@
+//----------------------------  full_matrix_vector_05.cc  ---------------------------
+//    $Id$
+//    Version: 
+//
+//    Copyright (C) 2004 by the deal.II authors and Anna Schneebeli
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  full_matrix_vector_05.cc  ---------------------------
+
+
+// check FullMatrix::matrix_scalar_product
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <lac/full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+           Vector<double> &w)
+{
+  FullMatrix<double> m(v.size(), v.size());
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+        m(i,j) = ( i+2*j);
+
+  for (unsigned int i=0; i<v.size(); ++i)
+    {
+      v(i) = i;
+      w(i) = i+1;
+    }
+  
+  v.compress ();
+  w.compress ();
+
+                                   // <w,Mv>
+  const double s = m.matrix_scalar_product (w,v);
+
+                                   // make sure we get the expected result
+  for (unsigned int i=0; i<v.size(); ++i)
+    {
+      Assert (v(i) == i, ExcInternalError());
+      Assert (w(i) == i+1, ExcInternalError());
+    }
+
+  double result = 0;
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      result += (i+2*j)*j*(i+1);
+
+  Assert (s == result, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("full_matrix_vector_05.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      Vector<double> v (100);
+      Vector<double> w (100);
+      test (v,w);
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+               << exc.what() << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      
+      return 1;
+    }
+  catch (...) 
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/bits/full_matrix_vector_06.cc b/tests/bits/full_matrix_vector_06.cc
new file mode 100644 (file)
index 0000000..887cf32
--- /dev/null
@@ -0,0 +1,91 @@
+//----------------------------  full_matrix_vector_06.cc  ---------------------------
+//    $Id$
+//    Version: 
+//
+//    Copyright (C) 2004 by the deal.II authors and Anna Schneebeli
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  full_matrix_vector_06.cc  ---------------------------
+
+
+// check FullMatrix::matrix_norm_square
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <lac/full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+  FullMatrix<double> m(v.size(), v.size());
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+        m(i,j) = ( i+2*j);
+
+  for (unsigned int i=0; i<v.size(); ++i)
+    v(i) = i;
+  
+  v.compress ();
+
+                                   // <w,Mv>
+  const double s = m.matrix_norm_square (v);
+
+                                   // make sure we get the expected result
+  for (unsigned int i=0; i<v.size(); ++i)
+    Assert (v(i) == i, ExcInternalError());
+
+  double result = 0;
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      result += (i+2*j)*j*i;
+
+  Assert (s == result, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("full_matrix_vector_06.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      Vector<double> v (100);
+      test (v);
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+               << exc.what() << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      
+      return 1;
+    }
+  catch (...) 
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/bits/full_matrix_vector_07.cc b/tests/bits/full_matrix_vector_07.cc
new file mode 100644 (file)
index 0000000..36ae540
--- /dev/null
@@ -0,0 +1,103 @@
+//----------------------------  full_matrix_vector_07.cc  ---------------------------
+//    $Id$
+//    Version: 
+//
+//    Copyright (C) 2004 by the deal.II authors and Anna Schneebeli
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  full_matrix_vector_07.cc  ---------------------------
+
+
+// check FullMatrix::matrix_norm_square
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <lac/full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+           Vector<double> &w,
+           Vector<double> &x)
+{
+  FullMatrix<double> m(v.size(), v.size());
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+        m(i,j) = ( i+2*j);
+
+  for (unsigned int i=0; i<v.size(); ++i)
+    {
+      v(i) = i;
+      w(i) = i+1;
+    }
+      
+  v.compress ();
+  w.compress ();
+
+                                   // x=w-Mv
+  const double s = m.residual (x, v, w);
+
+                                   // make sure we get the expected result
+  for (unsigned int i=0; i<v.size(); ++i)
+    {
+      Assert (v(i) == i, ExcInternalError());
+      Assert (w(i) == i+1, ExcInternalError());
+
+      double result = i+1;
+      for (unsigned int j=0; j<m.m(); ++j)
+        result -= (i+2*j)*j;
+
+      Assert (x(i) == result, ExcInternalError());
+    }
+
+  Assert (s == x.l2_norm(), ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("full_matrix_vector_07.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      Vector<double> v (100);
+      Vector<double> w (100);
+      Vector<double> x (100);
+      test (v,w,x);
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+               << exc.what() << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      
+      return 1;
+    }
+  catch (...) 
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_01.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_01.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_02.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_02.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_05.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_05.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_06.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_06.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_07.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/full_matrix_vector_07.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK

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.