]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
more types improved
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 5 May 1999 12:50:05 +0000 (12:50 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 5 May 1999 12:50:05 +0000 (12:50 +0000)
git-svn-id: https://svn.dealii.org/trunk@1276 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/mg_base.h
deal.II/deal.II/source/multigrid/mg_base.cc
deal.II/lac/include/lac/mgbase.h
deal.II/lac/include/lac/solver.h
deal.II/lac/include/lac/solver_cg.h
deal.II/lac/include/lac/sparse_matrix.h
deal.II/lac/include/lac/sparse_matrix.templates.h
deal.II/lac/source/mgbase.cc
deal.II/lac/source/sparse_matrix.double.cc
deal.II/lac/source/sparse_matrix.float.cc
deal.II/lac/source/sparse_matrix.long_double.cc

index 2a45a3a82662f9f4958fa1c78aa0e32f27f8403b..5f16cbf0e9d82346c0057f58213c478d8d6814ed 100644 (file)
@@ -12,9 +12,6 @@
 #include <vector>
 #include <base/smartpointer.h>
 
-#define FLOAT float
-
-
 /**
  * Abstract base class for coarse grid solvers.
  * The interface of a function call operator is defined to execute coarse
@@ -41,8 +38,8 @@ class MGCoarseGridSolver
                                      * about the matrix is removed to
                                      * that class.
                                      */
-    virtual void operator() (unsigned int level, Vector<FLOAT>& dst,
-                            const Vector<FLOAT>& src) const = 0;
+    virtual void operator() (unsigned int level, Vector<float>& dst,
+                            const Vector<float>& src) const = 0;
 };
 
 
@@ -75,8 +72,8 @@ class MGSmootherBase
                                      * things.
                                      */
     virtual void smooth (const unsigned int   level,
-                        Vector<FLOAT>       &u,
-                        const Vector<FLOAT> &rhs) const = 0;
+                        Vector<float>       &u,
+                        const Vector<float> &rhs) const = 0;
 
 };
 
@@ -94,8 +91,8 @@ class MGSmootherIdentity
                                      * This function does nothing.
                                      */
     virtual void smooth (const unsigned int   level,
-                        Vector<FLOAT>       &u,
-                        const Vector<FLOAT> &rhs) const;
+                        Vector<float>       &u,
+                        const Vector<float> &rhs) const;
 };
 
 /**
@@ -130,8 +127,8 @@ class MGTransferBase
                                      * level.
                                      */
     virtual void prolongate (const unsigned int   to_level,
-                            Vector<FLOAT>       &dst,
-                            const Vector<FLOAT> &src) const = 0;
+                            Vector<float>       &dst,
+                            const Vector<float> &src) const = 0;
 
                                     /**
                                      * Restrict a vector from level
@@ -147,8 +144,8 @@ class MGTransferBase
                                      * level.
                                      */
     virtual void restrict (const unsigned int   from_level,
-                          Vector<FLOAT>       &dst,
-                          const Vector<FLOAT> &src) const = 0;
+                          Vector<float>       &dst,
+                          const Vector<float> &src) const = 0;
 };
 
 /**
@@ -246,8 +243,8 @@ class MGCoarseGridLACIteration
                                      * matrix, vectors and
                                      * preconditioner.
                                      */
-    virtual void operator() (unsigned int level, Vector<FLOAT>& dst,
-                            const Vector<FLOAT>& src) const;
+    virtual void operator() (unsigned int level, Vector<float>& dst,
+                            const Vector<float>& src) const;
   private:
                                     /**
                                      * Reference to the solver.
@@ -304,18 +301,18 @@ class MGBase
                                     /**
                                      * Auxiliary vector, defect.
                                      */
-    MGVector<Vector<FLOAT> > d;
+    MGVector<Vector<float> > d;
 
                                     /**
                                      * Auxiliary vector, solution.
                                      */
-    MGVector<Vector<FLOAT> > s;
+    MGVector<Vector<float> > s;
 
   private:
                                     /**
                                      * Auxiliary vector.
                                      */
-    Vector<FLOAT> t;
+    Vector<float> t;
     
                                     /**
                                      * Prolongation and restriction object.
@@ -345,9 +342,9 @@ class MGBase
                                      * derived class.
                                      */
     virtual void level_residual(unsigned int level,
-                            Vector<FLOAT>& dst,
-                            const Vector<FLOAT>& src,
-                            const Vector<FLOAT>& rhs) = 0;  
+                            Vector<float>& dst,
+                            const Vector<float>& src,
+                            const Vector<float>& rhs) = 0;  
 
   
   public:
@@ -443,7 +440,7 @@ MGCoarseGridLACIteration<SOLVER, MATRIX, PRECOND>
 template<class SOLVER, class MATRIX, class PRECOND>
 void
 MGCoarseGridLACIteration<SOLVER, MATRIX, PRECOND>::operator()
-(unsigned int, Vector<FLOAT>& dst, const Vector<FLOAT>& src) const
+(unsigned int, Vector<float>& dst, const Vector<float>& src) const
 {
   solver.solve(matrix, dst, src, precondition);
 }
index b7e475a798afa5ad3edd5443342b43ddb55ee9df..b08359efb40eba1252c8022d3f9dab6e10d1fdea 100644 (file)
@@ -13,7 +13,7 @@ void print_vector(ostream& s, const VECTOR& v)
   for (unsigned int i=0;i<n;++i)
     {
       for (unsigned int j=0;j<n;++j)
-//     s << ((FLOAT)i)/n << '\t' << ((FLOAT)j)/n << '\t' << v(k++) << endl;
+//     s << ((float)i)/n << '\t' << ((float)j)/n << '\t' << v(k++) << endl;
        s << '\t' << v(k++);
       s << endl;
     }
@@ -99,8 +99,8 @@ MGSmootherBase::~MGSmootherBase()
 
 void
 MGSmootherIdentity::smooth (const unsigned int,
-                           Vector<FLOAT>       &,
-                           const Vector<FLOAT> &) const
+                           Vector<float>       &,
+                           const Vector<float> &) const
 {}
 
 
index 4192a16bd61863cb0fa4ec2ca7fa6eef5a369365..3e9396f8f0ee5e467308e41d379dbf032d293346 100644 (file)
@@ -12,9 +12,6 @@
 #include <vector>
 #include <base/smartpointer.h>
 
-#define FLOAT float
-
-
 /**
  * Abstract base class for coarse grid solvers.
  * The interface of a function call operator is defined to execute coarse
@@ -41,8 +38,8 @@ class MGCoarseGridSolver
                                      * about the matrix is removed to
                                      * that class.
                                      */
-    virtual void operator() (unsigned int level, Vector<FLOAT>& dst,
-                            const Vector<FLOAT>& src) const = 0;
+    virtual void operator() (unsigned int level, Vector<float>& dst,
+                            const Vector<float>& src) const = 0;
 };
 
 
@@ -75,8 +72,8 @@ class MGSmootherBase
                                      * things.
                                      */
     virtual void smooth (const unsigned int   level,
-                        Vector<FLOAT>       &u,
-                        const Vector<FLOAT> &rhs) const = 0;
+                        Vector<float>       &u,
+                        const Vector<float> &rhs) const = 0;
 
 };
 
@@ -94,8 +91,8 @@ class MGSmootherIdentity
                                      * This function does nothing.
                                      */
     virtual void smooth (const unsigned int   level,
-                        Vector<FLOAT>       &u,
-                        const Vector<FLOAT> &rhs) const;
+                        Vector<float>       &u,
+                        const Vector<float> &rhs) const;
 };
 
 /**
@@ -130,8 +127,8 @@ class MGTransferBase
                                      * level.
                                      */
     virtual void prolongate (const unsigned int   to_level,
-                            Vector<FLOAT>       &dst,
-                            const Vector<FLOAT> &src) const = 0;
+                            Vector<float>       &dst,
+                            const Vector<float> &src) const = 0;
 
                                     /**
                                      * Restrict a vector from level
@@ -147,8 +144,8 @@ class MGTransferBase
                                      * level.
                                      */
     virtual void restrict (const unsigned int   from_level,
-                          Vector<FLOAT>       &dst,
-                          const Vector<FLOAT> &src) const = 0;
+                          Vector<float>       &dst,
+                          const Vector<float> &src) const = 0;
 };
 
 /**
@@ -246,8 +243,8 @@ class MGCoarseGridLACIteration
                                      * matrix, vectors and
                                      * preconditioner.
                                      */
-    virtual void operator() (unsigned int level, Vector<FLOAT>& dst,
-                            const Vector<FLOAT>& src) const;
+    virtual void operator() (unsigned int level, Vector<float>& dst,
+                            const Vector<float>& src) const;
   private:
                                     /**
                                      * Reference to the solver.
@@ -304,18 +301,18 @@ class MGBase
                                     /**
                                      * Auxiliary vector, defect.
                                      */
-    MGVector<Vector<FLOAT> > d;
+    MGVector<Vector<float> > d;
 
                                     /**
                                      * Auxiliary vector, solution.
                                      */
-    MGVector<Vector<FLOAT> > s;
+    MGVector<Vector<float> > s;
 
   private:
                                     /**
                                      * Auxiliary vector.
                                      */
-    Vector<FLOAT> t;
+    Vector<float> t;
     
                                     /**
                                      * Prolongation and restriction object.
@@ -345,9 +342,9 @@ class MGBase
                                      * derived class.
                                      */
     virtual void level_residual(unsigned int level,
-                            Vector<FLOAT>& dst,
-                            const Vector<FLOAT>& src,
-                            const Vector<FLOAT>& rhs) = 0;  
+                            Vector<float>& dst,
+                            const Vector<float>& src,
+                            const Vector<float>& rhs) = 0;  
 
   
   public:
@@ -443,7 +440,7 @@ MGCoarseGridLACIteration<SOLVER, MATRIX, PRECOND>
 template<class SOLVER, class MATRIX, class PRECOND>
 void
 MGCoarseGridLACIteration<SOLVER, MATRIX, PRECOND>::operator()
-(unsigned int, Vector<FLOAT>& dst, const Vector<FLOAT>& src) const
+(unsigned int, Vector<float>& dst, const Vector<float>& src) const
 {
   solver.solve(matrix, dst, src, precondition);
 }
index 7a3a6028ec4bcfec627adbf679f874329bcc71ad..a7494f17a0147d9a77044cf97e5142356a839789 100644 (file)
@@ -143,47 +143,12 @@ class Solver
                                      */
     Solver (SolverControl &, VectorMemory<Vector> &);
 
-                                    /**
-                                     * Solver procedure.  This is in
-                                     * fact only a template for the
-                                     * solve-function to be
-                                     * implemented in derived classes
-                                     */
-    template<class Preconditioner>
-    ReturnState solve (const Matrix &A,
-                      Vector &x,
-                      const Vector &b,
-                      const Preconditioner& precondition) const;
-    
                                     /**
                                      * Access to control object.
                                      */
     SolverControl& control() const;
     
   protected:
-                                    /**
-                                     * Calculation of convergence
-                                     * criterion. To allow further
-                                     * flexibility in solvers, the
-                                     * convergence criterion can be
-                                     * implemented by the user. Each
-                                     * method has it's standard
-                                     * criterion (usually some kind of
-                                     * residual) already implemented.
-                                     */
-    virtual double criterion() = 0;
-    
-                                    /**
-                                     * Additional entry point for
-                                     * examination.  Allows access to
-                                     * internal variables of a solver
-                                     * at a given point dependent of
-                                     * the actual solver method. Does
-                                     * nothing by default and should
-                                     * only be implemented to test
-                                     * iterative methods.
-                                     */
-    virtual void expert() {};
 
                                     /**
                                      * Control structure.
@@ -217,7 +182,7 @@ class SolverDual : public Solver<Matrix, Vector>
                                      * Solve the original problem
                                      * $Ax=b$.
                                      */
-    virtual ReturnState solve (const Matrix &A,
+    ReturnState solve (const Matrix &A,
                               Vector       &x,
                               const Vector &b) = 0;
 
@@ -225,7 +190,7 @@ class SolverDual : public Solver<Matrix, Vector>
                                      * Solve the two problems
                                      * $Ax=b1$ and $A^Tz=b2$ simultanously.
                                      */
-    virtual ReturnState solve (const Matrix &A,
+    ReturnState solve (const Matrix &A,
                               Vector       &x,
                               const Vector &b1,
                               Vector       &z,
@@ -241,7 +206,8 @@ class SolverDual : public Solver<Matrix, Vector>
 
 template <class Matrix, class Vector>
 inline
-SolverControl & Solver<Matrix,Vector>::control() const {
+SolverControl & Solver<Matrix,Vector>::control() const
+{
   return cntrl;
 };
 
@@ -255,9 +221,6 @@ Solver<Matrix, Vector>::Solver(SolverControl &cn, VectorMemory<Vector> &mem)
 {};
 
 
-
-
-
 /*----------------------------   solver.h     ---------------------------*/
 /* end of #ifndef __solver_H */
 #endif
index a0000885a65a6759f058c793318a52915d043eb9..94a3a3398b84524ea18fc52cc28f7e3d3a8220d4 100644 (file)
@@ -52,7 +52,7 @@ class SolverCG : public Solver<Matrix,Vector>
                                      * Implementation of the computation of
                                      * the norm of the residual.
                                      */
-    virtual double criterion();
+    virtual long double criterion();
     
                                     /**
                                      * Temporary vectors, allocated through
@@ -72,7 +72,7 @@ class SolverCG : public Solver<Matrix,Vector>
                                      * norm of the residual vector and thus
                                      * the square root of the #res2# value.
                                      */
-    double res2;
+    long double res2;
 };
 
 
@@ -89,7 +89,8 @@ SolverCG<Matrix,Vector>::SolverCG(SolverControl &cn,
 
 
 template<class Matrix, class Vector>
-double SolverCG<Matrix,Vector>::criterion()
+long double
+SolverCG<Matrix,Vector>::criterion()
 {
   return sqrt(res2);
 };
@@ -128,7 +129,7 @@ SolverCG<Matrix,Vector>::solve (const Matrix &A,
                                   // Implementation taken from the DEAL
                                   // library
   int  it=0;
-  double res,gh,alpha,beta;
+  long double res,gh,alpha,beta;
  
   res = A.residual(g,x,b);
   conv = control().check(0,res);
index 23507bc94c0d9bd4ef737d1d51cb9bd66e97fb56..8c7da6c9846e097bd56be51b540b51d0fe10f034 100644 (file)
@@ -763,7 +763,7 @@ class SparseMatrix : public Subscriptor
                                      * for this operation.
                                      */
     template <typename somenumber>
-    double matrix_norm (const Vector<somenumber> &v) const;
+    somenumber matrix_norm (const Vector<somenumber> &v) const;
 
                                     /**
                                      * Return the l1-norm of the matrix, i.e.
@@ -801,7 +801,7 @@ class SparseMatrix : public Subscriptor
                                      * #dst#.
                                      */
     template <typename somenumber>
-    double residual (Vector<somenumber>& dst, const Vector<somenumber>& x,
+    somenumber residual (Vector<somenumber>& dst, const Vector<somenumber>& x,
                     const Vector<somenumber>& b) const;
                                     //
     template <typename somenumber>
index a9bb565977ec420cf826c68f89ba17f10be321d1..c20d302938ee06936b47e95c869e3e06263a2b83 100644 (file)
@@ -225,7 +225,7 @@ SparseMatrix<number>::Tvmult (Vector<somenumber>& dst, const Vector<somenumber>&
 
 template <typename number>
 template <typename somenumber>
-double
+somenumber
 SparseMatrix<number>::matrix_norm (const Vector<somenumber>& v) const
 {
   Assert (cols != 0, ExcMatrixNotInitialized());
@@ -292,7 +292,7 @@ number SparseMatrix<number>::linfty_norm () const
 
 template <typename number>
 template <typename somenumber>
-double
+somenumber
 SparseMatrix<number>::residual (Vector<somenumber>& dst,
                                const Vector<somenumber>& u,
                                const Vector<somenumber>& b) const
index b7e475a798afa5ad3edd5443342b43ddb55ee9df..b08359efb40eba1252c8022d3f9dab6e10d1fdea 100644 (file)
@@ -13,7 +13,7 @@ void print_vector(ostream& s, const VECTOR& v)
   for (unsigned int i=0;i<n;++i)
     {
       for (unsigned int j=0;j<n;++j)
-//     s << ((FLOAT)i)/n << '\t' << ((FLOAT)j)/n << '\t' << v(k++) << endl;
+//     s << ((float)i)/n << '\t' << ((float)j)/n << '\t' << v(k++) << endl;
        s << '\t' << v(k++);
       s << endl;
     }
@@ -99,8 +99,8 @@ MGSmootherBase::~MGSmootherBase()
 
 void
 MGSmootherIdentity::smooth (const unsigned int,
-                           Vector<FLOAT>       &,
-                           const Vector<FLOAT> &) const
+                           Vector<float>       &,
+                           const Vector<float> &) const
 {}
 
 
index d3adea7812ce078158ec6f8c765304632afc3f80..3ad663c0520f6d22addf298f06bc3f989ce20087 100644 (file)
@@ -29,10 +29,10 @@ template void SparseMatrix<TYPEMAT>::vmult (Vector<TYPE2> &,
 template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
                                             const Vector<TYPE2> &) const;
 
-template double
+template TYPE2
 SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
 
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
                                               const Vector<TYPE2> &,
                                               const Vector<TYPE2> &) const;
 
@@ -65,10 +65,10 @@ template void SparseMatrix<TYPEMAT>::vmult (Vector<TYPE2> &,
 template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
                                             const Vector<TYPE2> &) const;
 
-template double
+template TYPE2
 SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
 
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
                                               const Vector<TYPE2> &,
                                               const Vector<TYPE2> &) const;
 
index 5be1b54c19860ddba197d9b1c759e6b5c1972d57..88c4460cf05a6aec6061df0f3e3925868feb90d4 100644 (file)
@@ -29,12 +29,12 @@ template void SparseMatrix<TYPEMAT>::vmult (Vector<TYPE2> &,
 template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
                                             const Vector<TYPE2> &) const;
 
-template double
+template TYPE2
 SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
 
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
-                                              const Vector<TYPE2> &,
-                                              const Vector<TYPE2> &) const;
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+                                               const Vector<TYPE2> &,
+                                               const Vector<TYPE2> &) const;
 
 template void SparseMatrix<TYPEMAT>::precondition_SSOR (Vector<TYPE2> &,
                                                      const Vector<TYPE2> &,
index 6678c95d2f4c216ebf0b8b14ae6e59962f9148dd..7334d98ccec88599c98167af94d8ad65924160c6 100644 (file)
@@ -29,10 +29,10 @@ template void SparseMatrix<TYPEMAT>::vmult (Vector<TYPE2> &,
 template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
                                             const Vector<TYPE2> &) const;
 
-template double
+template TYPE2
 SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
 
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
                                               const Vector<TYPE2> &,
                                               const Vector<TYPE2> &) const;
 
@@ -65,10 +65,10 @@ template void SparseMatrix<TYPEMAT>::vmult (Vector<TYPE2> &,
 template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
                                             const Vector<TYPE2> &) const;
 
-template double
+template TYPE2
 SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
 
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
                                               const Vector<TYPE2> &,
                                               const Vector<TYPE2> &) const;
 
@@ -101,10 +101,10 @@ template void SparseMatrix<TYPEMAT>::vmult (Vector<TYPE2> &,
 template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
                                             const Vector<TYPE2> &) const;
 
-template double
+template TYPE2
 SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
 
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
                                               const Vector<TYPE2> &,
                                               const Vector<TYPE2> &) const;
 
@@ -137,10 +137,10 @@ template void SparseMatrix<TYPEMAT>::vmult (Vector<TYPE2> &,
 template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
                                             const Vector<TYPE2> &) const;
 
-template double
+template TYPE2
 SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
 
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
                                               const Vector<TYPE2> &,
                                               const Vector<TYPE2> &) const;
 
@@ -173,10 +173,10 @@ template void SparseMatrix<TYPEMAT>::vmult (Vector<TYPE2> &,
 template void SparseMatrix<TYPEMAT>::Tvmult (Vector<TYPE2> &,
                                             const Vector<TYPE2> &) const;
 
-template double
+template TYPE2
 SparseMatrix<TYPEMAT>::matrix_norm (const Vector<TYPE2> &) const;
 
-template double SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
+template TYPE2 SparseMatrix<TYPEMAT>::residual (Vector<TYPE2> &,
                                               const Vector<TYPE2> &,
                                               const Vector<TYPE2> &) const;
 

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.