]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New tests
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 24 Apr 2006 23:06:30 +0000 (23:06 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 24 Apr 2006 23:06:30 +0000 (23:06 +0000)
git-svn-id: https://svn.dealii.org/trunk@12869 0785d39b-7218-0410-832d-ea1e28bc413d

16 files changed:
tests/lac/Makefile
tests/lac/identity_matrix_01.cc [new file with mode: 0644]
tests/lac/identity_matrix_01/.cvsignore [new file with mode: 0644]
tests/lac/identity_matrix_01/cmp/generic [new file with mode: 0644]
tests/lac/identity_matrix_02.cc [new file with mode: 0644]
tests/lac/identity_matrix_02/.cvsignore [new file with mode: 0644]
tests/lac/identity_matrix_02/cmp/generic [new file with mode: 0644]
tests/lac/identity_matrix_03.cc [new file with mode: 0644]
tests/lac/identity_matrix_03/.cvsignore [new file with mode: 0644]
tests/lac/identity_matrix_03/cmp/generic [new file with mode: 0644]
tests/lac/identity_matrix_04.cc [new file with mode: 0644]
tests/lac/identity_matrix_04/.cvsignore [new file with mode: 0644]
tests/lac/identity_matrix_04/cmp/generic [new file with mode: 0644]
tests/lac/identity_matrix_05.cc [new file with mode: 0644]
tests/lac/identity_matrix_05/.cvsignore [new file with mode: 0644]
tests/lac/identity_matrix_05/cmp/generic [new file with mode: 0644]

index f432114908135cf57836d6ff76ae000d0f5b7f8b..6018121e6370eb7828e1ae8fb2579e622ef31e57 100644 (file)
@@ -27,7 +27,8 @@ tests_x = vector-vector \
        block_vector block_vector_* block_matrices \
        matrix_lib matrix_out \
        solver eigen \
-       sparse_ilu sparse_ilu_t lapack lapack_fill block_minres
+       sparse_ilu sparse_ilu_t lapack lapack_fill block_minres \
+       identity_matrix*
 
 
 # from above list of regular expressions, generate the real set of
diff --git a/tests/lac/identity_matrix_01.cc b/tests/lac/identity_matrix_01.cc
new file mode 100644 (file)
index 0000000..f7a5bad
--- /dev/null
@@ -0,0 +1,76 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005, 2006 by the deal.II authors
+//
+//    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.
+//
+//---------------------------------------------------------------------------
+
+// check IdentityMatrix::vmult and friends
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/identity_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <cmath>
+
+template<typename number>
+void
+check_vmult()
+{
+  IdentityMatrix M(4);
+  Vector<number> u(4);
+  Vector<number> v(4);
+
+  for (unsigned int i=0;i<4;++i)
+    u(i) = i+1;
+  
+  M.vmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.vmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+}
+
+
+int main()
+{
+  std::ofstream logfile("identity_matrix_01/output");
+  logfile.setf(std::ios::fixed);
+  logfile.precision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+  
+  check_vmult<double>();
+  check_vmult<float>();
+}
diff --git a/tests/lac/identity_matrix_01/.cvsignore b/tests/lac/identity_matrix_01/.cvsignore
new file mode 100644 (file)
index 0000000..d196dfb
--- /dev/null
@@ -0,0 +1 @@
+obj.* exe OK output
diff --git a/tests/lac/identity_matrix_01/cmp/generic b/tests/lac/identity_matrix_01/cmp/generic
new file mode 100644 (file)
index 0000000..29bcfce
--- /dev/null
@@ -0,0 +1,9 @@
+
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
diff --git a/tests/lac/identity_matrix_02.cc b/tests/lac/identity_matrix_02.cc
new file mode 100644 (file)
index 0000000..46d825e
--- /dev/null
@@ -0,0 +1,77 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005, 2006 by the deal.II authors
+//
+//    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.
+//
+//---------------------------------------------------------------------------
+
+// check conversion constructor from IdentityMatrix to FullMatrix
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/identity_matrix.h>
+#include <lac/full_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <cmath>
+
+template<typename number>
+void
+check_vmult()
+{
+  FullMatrix<number> M(IdentityMatrix(4));
+  Vector<number> u(4);
+  Vector<number> v(4);
+
+  for (unsigned int i=0;i<4;++i)
+    u(i) = i+1;
+  
+  M.vmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.vmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+}
+
+
+int main()
+{
+  std::ofstream logfile("identity_matrix_02/output");
+  logfile.setf(std::ios::fixed);
+  logfile.precision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+  
+  check_vmult<double>();
+  check_vmult<float>();
+}
diff --git a/tests/lac/identity_matrix_02/.cvsignore b/tests/lac/identity_matrix_02/.cvsignore
new file mode 100644 (file)
index 0000000..d196dfb
--- /dev/null
@@ -0,0 +1 @@
+obj.* exe OK output
diff --git a/tests/lac/identity_matrix_02/cmp/generic b/tests/lac/identity_matrix_02/cmp/generic
new file mode 100644 (file)
index 0000000..29bcfce
--- /dev/null
@@ -0,0 +1,9 @@
+
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
diff --git a/tests/lac/identity_matrix_03.cc b/tests/lac/identity_matrix_03.cc
new file mode 100644 (file)
index 0000000..09ca305
--- /dev/null
@@ -0,0 +1,78 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005, 2006 by the deal.II authors
+//
+//    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.
+//
+//---------------------------------------------------------------------------
+
+// check assignment from IdentityMatrix to FullMatrix
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/identity_matrix.h>
+#include <lac/full_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <cmath>
+
+template<typename number>
+void
+check_vmult()
+{
+  FullMatrix<number> M;
+  M = IdentityMatrix(4);
+  Vector<number> u(4);
+  Vector<number> v(4);
+
+  for (unsigned int i=0;i<4;++i)
+    u(i) = i+1;
+  
+  M.vmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.vmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+}
+
+
+int main()
+{
+  std::ofstream logfile("identity_matrix_03/output");
+  logfile.setf(std::ios::fixed);
+  logfile.precision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+  
+  check_vmult<double>();
+  check_vmult<float>();
+}
diff --git a/tests/lac/identity_matrix_03/.cvsignore b/tests/lac/identity_matrix_03/.cvsignore
new file mode 100644 (file)
index 0000000..d196dfb
--- /dev/null
@@ -0,0 +1 @@
+obj.* exe OK output
diff --git a/tests/lac/identity_matrix_03/cmp/generic b/tests/lac/identity_matrix_03/cmp/generic
new file mode 100644 (file)
index 0000000..29bcfce
--- /dev/null
@@ -0,0 +1,9 @@
+
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
diff --git a/tests/lac/identity_matrix_04.cc b/tests/lac/identity_matrix_04.cc
new file mode 100644 (file)
index 0000000..46ef4d8
--- /dev/null
@@ -0,0 +1,82 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005, 2006 by the deal.II authors
+//
+//    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.
+//
+//---------------------------------------------------------------------------
+
+// check conversion constructor from IdentityMatrix to SparseMatrix
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/identity_matrix.h>
+#include <lac/sparse_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <cmath>
+
+template<typename number>
+void
+check_vmult()
+{
+  SparsityPattern sp(4,4,1);
+  for (unsigned int i=0; i<4; ++i)
+    sp.add (i,i);
+  sp.compress ();
+  
+  SparseMatrix<number> M(sp, IdentityMatrix(4));
+  Vector<number> u(4);
+  Vector<number> v(4);
+
+  for (unsigned int i=0;i<4;++i)
+    u(i) = i+1;
+  
+  M.vmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.vmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+}
+
+
+int main()
+{
+  std::ofstream logfile("identity_matrix_04/output");
+  logfile.setf(std::ios::fixed);
+  logfile.precision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+  
+  check_vmult<double>();
+  check_vmult<float>();
+}
diff --git a/tests/lac/identity_matrix_04/.cvsignore b/tests/lac/identity_matrix_04/.cvsignore
new file mode 100644 (file)
index 0000000..d196dfb
--- /dev/null
@@ -0,0 +1 @@
+obj.* exe OK output
diff --git a/tests/lac/identity_matrix_04/cmp/generic b/tests/lac/identity_matrix_04/cmp/generic
new file mode 100644 (file)
index 0000000..29bcfce
--- /dev/null
@@ -0,0 +1,9 @@
+
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
diff --git a/tests/lac/identity_matrix_05.cc b/tests/lac/identity_matrix_05.cc
new file mode 100644 (file)
index 0000000..ce38d30
--- /dev/null
@@ -0,0 +1,83 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005, 2006 by the deal.II authors
+//
+//    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.
+//
+//---------------------------------------------------------------------------
+
+// check assignment from IdentityMatrix to SparseMatrix
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/identity_matrix.h>
+#include <lac/sparse_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <cmath>
+
+template<typename number>
+void
+check_vmult()
+{
+  SparsityPattern sp(4,4,1);
+  for (unsigned int i=0; i<4; ++i)
+    sp.add (i,i);
+  sp.compress ();
+  
+  SparseMatrix<number> M(sp);
+  M = IdentityMatrix(4);
+  Vector<number> u(4);
+  Vector<number> v(4);
+
+  for (unsigned int i=0;i<4;++i)
+    u(i) = i+1;
+  
+  M.vmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.vmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+}
+
+
+int main()
+{
+  std::ofstream logfile("identity_matrix_05/output");
+  logfile.setf(std::ios::fixed);
+  logfile.precision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+  
+  check_vmult<double>();
+  check_vmult<float>();
+}
diff --git a/tests/lac/identity_matrix_05/.cvsignore b/tests/lac/identity_matrix_05/.cvsignore
new file mode 100644 (file)
index 0000000..d196dfb
--- /dev/null
@@ -0,0 +1 @@
+obj.* exe OK output
diff --git a/tests/lac/identity_matrix_05/cmp/generic b/tests/lac/identity_matrix_05/cmp/generic
new file mode 100644 (file)
index 0000000..29bcfce
--- /dev/null
@@ -0,0 +1,9 @@
+
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.

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.