]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fold the implementations of testmatrix.cc into the header file. This way we can also...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 25 Feb 2004 19:46:34 +0000 (19:46 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 25 Feb 2004 19:46:34 +0000 (19:46 +0000)
git-svn-id: https://svn.dealii.org/trunk@8545 0785d39b-7218-0410-832d-ea1e28bc413d

tests/lac/Makefile
tests/lac/testmatrix.cc [deleted file]
tests/lac/testmatrix.h

index 75fb41e693c0b9e95f32f1aaab3c1c6cd5aa9aa6..96235c7e501ff6153100043c2c9153c1cb3d78b6 100644 (file)
@@ -1,6 +1,6 @@
 ############################################################
 # $Id$
-# Copyright (C) 2000, 2001, 2002, 2003 by the deal.II authors
+# Copyright (C) 2000, 2001, 2002, 2003, 2004 by the deal.II authors
 ############################################################
 
 ############################################################
@@ -25,15 +25,15 @@ block_vector.exe          : block_vector.g.$(OBJEXT)                    $(librar
 block_vector_iterator.exe : block_vector_iterator.g.$(OBJEXT)           $(libraries)
 full_matrix.exe           : full_matrix.g.$(OBJEXT)                     $(libraries)
 matrix_out.exe            : matrix_out.g.$(OBJEXT)                      $(libraries)
-solver.exe                : solver.g.$(OBJEXT)   testmatrix.g.$(OBJEXT) $(libraries)
-eigen.exe                 : eigen.g.$(OBJEXT)   testmatrix.g.$(OBJEXT) $(libraries)
-sparse_matrices.exe       : sparse_matrices.g.$(OBJEXT) testmatrix.g.$(OBJEXT) $(libraries)
-sparse_matrices.opt.exe   : sparse_matrices.$(OBJEXT) testmatrix.$(OBJEXT) $(libraries_o)
-sparsity_pattern.exe      : sparsity_pattern.g.$(OBJEXT) testmatrix.g.$(OBJEXT) $(libraries)
-sparse_ilu.exe            : sparse_ilu.g.$(OBJEXT) testmatrix.g.$(OBJEXT) $(libraries)
+solver.exe                : solver.g.$(OBJEXT)                          $(libraries)
+eigen.exe                 : eigen.g.$(OBJEXT)                           $(libraries)
+sparse_matrices.exe       : sparse_matrices.g.$(OBJEXT)                 $(libraries)
+sparse_matrices.opt.exe   : sparse_matrices.$(OBJEXT)                   $(libraries_o)
+sparsity_pattern.exe      : sparsity_pattern.g.$(OBJEXT)                $(libraries)
+sparse_ilu.exe            : sparse_ilu.g.$(OBJEXT)                      $(libraries)
 vector-vector.exe         : vector-vector.g.$(OBJEXT)                   $(libraries)
 #mgbase.exe               : mgbase.g.$(OBJEXT)                          $(libraries)
-#mg.exe                   : mg.g.$(OBJEXT) testmatrix.g.$(OBJEXT)       $(libraries)
+#mg.exe                   : mg.g.$(OBJEXT)                              $(libraries)
 
 
 tests = $(sort \
diff --git a/tests/lac/testmatrix.cc b/tests/lac/testmatrix.cc
deleted file mode 100644 (file)
index a4ee0ce..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-//----------------------------  testmatrix.cc  ---------------------------
-//    testmatrix.cc,v 1.22 2003/09/09 16:09:15 wolf Exp
-//    Version: 
-//
-//    Copyright (C) 1998, 1999, 2000, 2002, 2003 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.
-//
-//----------------------------  testmatrix.cc  ---------------------------
-
-
-#include "../tests.h"
-#include "testmatrix.h"
-#include <lac/sparse_matrix.h>
-#include <lac/block_sparse_matrix.h>
-#include <lac/sparse_matrix_ez.h>
-#include <lac/vector.h>
-
-FDMatrix::FDMatrix(unsigned int nx, unsigned int ny)
-               :
-               nx(nx), ny(ny)
-{}
-
-void
-FDMatrix::five_point_structure(SparsityPattern& structure) const
-{
-  for(unsigned int i=0;i<=ny-2;i++)
-    {
-      for(unsigned int j=0;j<=nx-2; j++)
-       {
-                                          // Number of the row to be entered
-         unsigned int row = j+(nx-1)*i;
-         structure.add(row, row);
-         if (j>0)
-           {
-             structure.add(row-1, row);
-             structure.add(row, row-1);
-           }
-         if (j<nx-2)
-           {
-             structure.add(row+1, row);
-             structure.add(row, row+1);
-           }
-         if (i>0)
-           {
-             structure.add(row-(nx-1), row);
-             structure.add(row, row-(nx-1));
-           }
-         if (i<ny-2)
-           {
-             structure.add(row+(nx-1), row);
-             structure.add(row, row+(nx-1));
-           }
-       }
-    }
-}
-
-void
-FDMatrix::nine_point_structure(SparsityPattern& structure) const
-{
-  for(unsigned int i=0;i<=ny-2;i++)
-    {
-      for(unsigned int j=0;j<=nx-2; j++)
-       {
-                                          // Number of the row to be entered
-         unsigned int row = j+(nx-1)*i;
-         structure.add(row, row);
-         if (j>0)
-           {
-             structure.add(row-1, row);
-             structure.add(row, row-1);
-             if (i>0)
-               {
-                 structure.add(row-1, row-(nx-1));
-                 structure.add(row-(nx-1), row-1);
-               }
-             if (i<ny-2)
-               {
-                 structure.add(row-1, row+(nx-1));
-                 structure.add(row+(nx-1), row-1);
-               }
-           }
-         if (j<nx-2)
-           {
-             structure.add(row+1, row);
-             structure.add(row, row+1);
-             if (i>0)
-               {
-                 structure.add(row+1, row-(nx-1));
-                 structure.add(row-(nx-1), row+1);
-               }
-             if (i<ny-2)
-               {
-                 structure.add(row+1, row+(nx-1));
-                 structure.add(row+(nx-1), row+1);
-               }
-           }
-         if (i>0)
-           {
-             structure.add(row-(nx-1), row);
-             structure.add(row, row-(nx-1));
-           }
-         if (i<ny-2)
-           {
-             structure.add(row+(nx-1), row);
-             structure.add(row, row+(nx-1));
-           }
-       }
-    }
-}
-
-template<typename MATRIX>
-void
-FDMatrix::nine_point(MATRIX& A, bool) const
-{
-   for(unsigned int i=0;i<=ny-2;i++)
-    {
-      for(unsigned int j=0;j<=nx-2; j++)
-       {
-                                          // Number of the row to be entered
-         unsigned int row = j+(nx-1)*i;
-         
-         A.set(row, row, 20.);
-         if (j>0)
-           {
-             A.set(row-1, row, -4.);
-             A.set(row, row-1, -4.);
-             if (i>0)
-               {
-                 A.set(row-1, row-(nx-1), -1.);
-                 A.set(row-(nx-1), row-1, -1.);
-               }
-             if (i<ny-2)
-               {
-                 A.set(row-1, row+(nx-1), -1.);
-                 A.set(row+(nx-1), row-1, -1.);
-               }
-           }
-         if (j<nx-2)
-           {
-             A.set(row+1, row, -4.);
-             A.set(row, row+1, -4.);
-             if (i>0)
-               {
-                 A.set(row+1, row-(nx-1), -1.);
-                 A.set(row-(nx-1), row+1, -1.);
-               }
-             if (i<ny-2)
-               {
-                 A.set(row+1, row+(nx-1), -1.);
-                 A.set(row+(nx-1), row+1, -1.);
-               }
-           }
-         if (i>0)
-           {
-             A.set(row-(nx-1), row, -4.);
-             A.set(row, row-(nx-1), -4.);
-           }
-         if (i<ny-2)
-           {
-             A.set(row+(nx-1), row, -4.);
-             A.set(row, row+(nx-1), -4.);
-           }
-       }
-    } 
-}
-
-template<typename MATRIX>
-void
-FDMatrix::five_point(MATRIX& A, bool nonsymmetric) const
-{
-   for(unsigned int i=0;i<=ny-2;i++)
-    {
-      for(unsigned int j=0;j<=nx-2; j++)
-       {
-                                          // Number of the row to be entered
-         unsigned int row = j+(nx-1)*i;
-         if (nonsymmetric)
-           A.set(row, row, 5.);
-         else
-           A.set(row, row, 4.);
-         if (j>0)
-           {
-             if (nonsymmetric)
-               A.set(row-1, row, -2.);
-             else
-               A.set(row-1, row, -1.);
-             A.set(row, row-1, -1.);
-           }
-         if (j<nx-2)
-           {
-             A.set(row+1, row, -1.);
-             A.set(row, row+1, -1.);
-           }
-         if (i>0)
-           {
-             A.set(row-(nx-1), row, -1.);
-             A.set(row, row-(nx-1), -1.);
-           }
-         if (i<ny-2)
-           {
-             A.set(row+(nx-1), row, -1.);
-             A.set(row, row+(nx-1), -1.);
-           }
-       }
-    } 
-}
-
-template<typename MATRIX>
-void
-FDMatrix::upwind(MATRIX& A, bool back) const
-{
-   for(unsigned int i=0;i<=ny-2;i++)
-    {
-      for(unsigned int j=0;j<=nx-2; j++)
-       {
-                                          // Number of the row to be entered
-         unsigned int row = j+(nx-1)*i;
-         A.set(row, row, 3.);
-
-         if (j>0 && !back)
-           A.set(row, row-1, -1.);
-
-         if (j<nx-2 && back)
-             A.set(row, row+1, -1.);
-       }
-    } 
-}
-
-template<typename number>
-void
-FDMatrix::gnuplot_print(std::ostream& s, const Vector<number>& V) const
-{
-   for(unsigned int i=0;i<=ny-2;i++)
-    {
-      for(unsigned int j=0;j<=nx-2; j++)
-       {
-                                          // Number of the row to be entered
-         unsigned int row = j+(nx-1)*i;
-         s << (j+1)/(float)nx << '\t' << (i+1)/(float)ny << '\t' << V(row) << std::endl;
-       }
-      s << std::endl;
-    } 
-   s << std::endl;
-}
-
-
-
-template void FDMatrix::five_point(SparseMatrix<long double>&, bool) const;
-template void FDMatrix::five_point(SparseMatrix<double>&, bool) const;
-template void FDMatrix::five_point(BlockSparseMatrix<long double>&, bool) const;
-template void FDMatrix::five_point(BlockSparseMatrix<double>&, bool) const;
-template void FDMatrix::five_point(SparseMatrixEZ<double>&, bool) const;
-template void FDMatrix::five_point(SparseMatrix<float>&, bool) const;
-template void FDMatrix::nine_point(SparseMatrix<long double>&, bool) const;
-template void FDMatrix::nine_point(SparseMatrix<double>&, bool) const;
-template void FDMatrix::nine_point(SparseMatrixEZ<double>&, bool) const;
-template void FDMatrix::nine_point(SparseMatrix<float>&, bool) const;
-template void FDMatrix::upwind(SparseMatrix<long double>&, bool) const;
-template void FDMatrix::upwind(SparseMatrix<double>&, bool) const;
-template void FDMatrix::upwind(SparseMatrixEZ<double>&, bool) const;
-template void FDMatrix::upwind(SparseMatrix<float>&, bool) const;
-template void FDMatrix::gnuplot_print(std::ostream& s, const Vector<long double>& V) const;
-template void FDMatrix::gnuplot_print(std::ostream& s, const Vector<double>& V) const;
-template void FDMatrix::gnuplot_print(std::ostream& s, const Vector<float>& V) const;
-
index 04ab4a5fd848238e5325556304373de862ea2587..f7579d296940295646c17cf025fe4d329161ee79 100644 (file)
@@ -3,9 +3,11 @@
 #include "../tests.h"
 #include <base/exceptions.h>
 #include <iostream>
+#include <lac/sparse_matrix.h>
+#include <lac/block_sparse_matrix.h>
+#include <lac/sparse_matrix_ez.h>
+#include <lac/vector.h>
 
-template <typename number> class Vector;
-class SparsityPattern;
 
 /**
  * Finite difference matrix on uniform grid.
@@ -62,3 +64,248 @@ class FDMatrix
                                      */
     unsigned int ny;
 };
+
+
+// --------------- inline and template functions -----------------
+
+inline
+FDMatrix::FDMatrix(unsigned int nx, unsigned int ny)
+               :
+               nx(nx), ny(ny)
+{}
+
+
+
+inline
+void
+FDMatrix::five_point_structure(SparsityPattern& structure) const
+{
+  for(unsigned int i=0;i<=ny-2;i++)
+    {
+      for(unsigned int j=0;j<=nx-2; j++)
+       {
+                                          // Number of the row to be entered
+         unsigned int row = j+(nx-1)*i;
+         structure.add(row, row);
+         if (j>0)
+           {
+             structure.add(row-1, row);
+             structure.add(row, row-1);
+           }
+         if (j<nx-2)
+           {
+             structure.add(row+1, row);
+             structure.add(row, row+1);
+           }
+         if (i>0)
+           {
+             structure.add(row-(nx-1), row);
+             structure.add(row, row-(nx-1));
+           }
+         if (i<ny-2)
+           {
+             structure.add(row+(nx-1), row);
+             structure.add(row, row+(nx-1));
+           }
+       }
+    }
+}
+
+
+
+inline
+void
+FDMatrix::nine_point_structure(SparsityPattern& structure) const
+{
+  for(unsigned int i=0;i<=ny-2;i++)
+    {
+      for(unsigned int j=0;j<=nx-2; j++)
+       {
+                                          // Number of the row to be entered
+         unsigned int row = j+(nx-1)*i;
+         structure.add(row, row);
+         if (j>0)
+           {
+             structure.add(row-1, row);
+             structure.add(row, row-1);
+             if (i>0)
+               {
+                 structure.add(row-1, row-(nx-1));
+                 structure.add(row-(nx-1), row-1);
+               }
+             if (i<ny-2)
+               {
+                 structure.add(row-1, row+(nx-1));
+                 structure.add(row+(nx-1), row-1);
+               }
+           }
+         if (j<nx-2)
+           {
+             structure.add(row+1, row);
+             structure.add(row, row+1);
+             if (i>0)
+               {
+                 structure.add(row+1, row-(nx-1));
+                 structure.add(row-(nx-1), row+1);
+               }
+             if (i<ny-2)
+               {
+                 structure.add(row+1, row+(nx-1));
+                 structure.add(row+(nx-1), row+1);
+               }
+           }
+         if (i>0)
+           {
+             structure.add(row-(nx-1), row);
+             structure.add(row, row-(nx-1));
+           }
+         if (i<ny-2)
+           {
+             structure.add(row+(nx-1), row);
+             structure.add(row, row+(nx-1));
+           }
+       }
+    }
+}
+
+
+
+template<typename MATRIX>
+void
+FDMatrix::nine_point(MATRIX& A, bool) const
+{
+   for(unsigned int i=0;i<=ny-2;i++)
+    {
+      for(unsigned int j=0;j<=nx-2; j++)
+       {
+                                          // Number of the row to be entered
+         unsigned int row = j+(nx-1)*i;
+         
+         A.set(row, row, 20.);
+         if (j>0)
+           {
+             A.set(row-1, row, -4.);
+             A.set(row, row-1, -4.);
+             if (i>0)
+               {
+                 A.set(row-1, row-(nx-1), -1.);
+                 A.set(row-(nx-1), row-1, -1.);
+               }
+             if (i<ny-2)
+               {
+                 A.set(row-1, row+(nx-1), -1.);
+                 A.set(row+(nx-1), row-1, -1.);
+               }
+           }
+         if (j<nx-2)
+           {
+             A.set(row+1, row, -4.);
+             A.set(row, row+1, -4.);
+             if (i>0)
+               {
+                 A.set(row+1, row-(nx-1), -1.);
+                 A.set(row-(nx-1), row+1, -1.);
+               }
+             if (i<ny-2)
+               {
+                 A.set(row+1, row+(nx-1), -1.);
+                 A.set(row+(nx-1), row+1, -1.);
+               }
+           }
+         if (i>0)
+           {
+             A.set(row-(nx-1), row, -4.);
+             A.set(row, row-(nx-1), -4.);
+           }
+         if (i<ny-2)
+           {
+             A.set(row+(nx-1), row, -4.);
+             A.set(row, row+(nx-1), -4.);
+           }
+       }
+    } 
+}
+
+template<typename MATRIX>
+inline
+void
+FDMatrix::five_point(MATRIX& A, bool nonsymmetric) const
+{
+   for(unsigned int i=0;i<=ny-2;i++)
+    {
+      for(unsigned int j=0;j<=nx-2; j++)
+       {
+                                          // Number of the row to be entered
+         unsigned int row = j+(nx-1)*i;
+         if (nonsymmetric)
+           A.set(row, row, 5.);
+         else
+           A.set(row, row, 4.);
+         if (j>0)
+           {
+             if (nonsymmetric)
+               A.set(row-1, row, -2.);
+             else
+               A.set(row-1, row, -1.);
+             A.set(row, row-1, -1.);
+           }
+         if (j<nx-2)
+           {
+             A.set(row+1, row, -1.);
+             A.set(row, row+1, -1.);
+           }
+         if (i>0)
+           {
+             A.set(row-(nx-1), row, -1.);
+             A.set(row, row-(nx-1), -1.);
+           }
+         if (i<ny-2)
+           {
+             A.set(row+(nx-1), row, -1.);
+             A.set(row, row+(nx-1), -1.);
+           }
+       }
+    } 
+}
+
+
+
+template<typename MATRIX>
+inline
+void
+FDMatrix::upwind(MATRIX& A, bool back) const
+{
+   for(unsigned int i=0;i<=ny-2;i++)
+    {
+      for(unsigned int j=0;j<=nx-2; j++)
+       {
+                                          // Number of the row to be entered
+         unsigned int row = j+(nx-1)*i;
+         A.set(row, row, 3.);
+
+         if (j>0 && !back)
+           A.set(row, row-1, -1.);
+
+         if (j<nx-2 && back)
+             A.set(row, row+1, -1.);
+       }
+    } 
+}
+
+template<typename number>
+inline
+void
+FDMatrix::gnuplot_print(std::ostream& s, const Vector<number>& V) const
+{
+   for(unsigned int i=0;i<=ny-2;i++)
+    {
+      for(unsigned int j=0;j<=nx-2; j++)
+       {
+                                          // Number of the row to be entered
+         unsigned int row = j+(nx-1)*i;
+         s << (j+1)/(float)nx << '\t' << (i+1)/(float)ny << '\t' << V(row) << std::endl;
+       }
+      s << std::endl;
+    } 
+   s << 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.