]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Remove template arg from Polynomials::Legendre and Polynomials::Hierarchical
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 May 2003 21:37:35 +0000 (21:37 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 May 2003 21:37:35 +0000 (21:37 +0000)
git-svn-id: https://svn.dealii.org/trunk@7639 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/polynomial.h
deal.II/base/source/polynomial.cc
deal.II/doc/news/2002/c-3-4.html

index ee6f29dd397fedce158c7104909d888dbba65b35..fb9e31e0166de3ec1f2ada9c2782623f0ef4c068 100644 (file)
@@ -282,8 +282,7 @@ namespace Polynomials
  *
  * @author Guido Kanschat, 2000
  */
-  template <typename number>
-  class Legendre : public Polynomial<number>
+  class Legendre : public Polynomial<double>
   {
     public:
                                        /**
@@ -305,14 +304,14 @@ namespace Polynomials
                                         * classes.
                                         */
       static
-      std::vector<Polynomial<number> >
+      std::vector<Polynomial<double> >
       generate_complete_basis (const unsigned int degree);
     
     private:
                                        /**
                                         * Coefficients for the interval $[0,1]$.
                                         */
-      static std::vector<const std::vector<number> *> shifted_coefficients;
+      static std::vector<const std::vector<double> *> shifted_coefficients;
     
                                        /**
                                         * Vector with already computed
@@ -324,7 +323,7 @@ namespace Polynomials
                                         * vectors in order to simplify
                                         * programming multithread-safe.
                                         */
-      static std::vector<const std::vector<number> *> recursive_coefficients;
+      static std::vector<const std::vector<double> *> recursive_coefficients;
     
                                        /**
                                         * Compute coefficients recursively.
@@ -338,7 +337,7 @@ namespace Polynomials
                                         * constructor of
                                         * @ref{Polynomial}.
                                         */
-      static const std::vector<number> &
+      static const std::vector<double> &
       get_coefficients (const unsigned int k);
   };
 
@@ -384,8 +383,7 @@ namespace Polynomials
  *
  * @author Brian Carnes, 2002
  */
-  template <typename number>
-  class Hierarchical : public Polynomial<number>
+  class Hierarchical : public Polynomial<double>
   {
     public:
                                      /**
@@ -416,7 +414,7 @@ namespace Polynomials
                                      * classes.
                                      */
       static
-      std::vector<Polynomial<number> >
+      std::vector<Polynomial<double> >
       generate_complete_basis (const unsigned int degree);
     
     private:
@@ -432,10 +430,10 @@ namespace Polynomials
                                      * constructor of
                                      * @ref{Polynomial}.
                                      */
-     static const std::vector<number> &
+     static const std::vector<double> &
      get_coefficients (const unsigned int k);
  
-     static std::vector<const std::vector<number> *> recursive_coefficients;
+     static std::vector<const std::vector<double> *> recursive_coefficients;
    };  
 }
 
index 373485c3c9697bd036f995fe40bce336b87ab2b2..1792e49d270d839d9b443a468076db7f1c27a049 100644 (file)
@@ -252,7 +252,8 @@ namespace Polynomials
 // ------------------ class LagrangeEquidistant --------------- //
 
   LagrangeEquidistant::LagrangeEquidistant (const unsigned int n,
-                                            const unsigned int support_point):
+                                            const unsigned int support_point)
+                 :
                   Polynomial<double>(compute_coefficients(n,support_point))
   {}
 
@@ -514,20 +515,23 @@ namespace Polynomials
 
 // Reserve space for polynomials up to degree 19. Should be sufficient
 // for the start.
-  template <typename number>
-  std::vector<const std::vector<number> *>
-  Legendre<number>::recursive_coefficients(
-    20, static_cast<const std::vector<number>*>(0));
-  template <typename number>
-  std::vector<const std::vector<number> *>
-  Legendre<number>::shifted_coefficients(
-    20, static_cast<const std::vector<number>*>(0));
+  std::vector<const std::vector<double> *>
+  Legendre::recursive_coefficients(20,
+                                  static_cast<const std::vector<double>*>(0));
+  std::vector<const std::vector<double> *>
+  Legendre::shifted_coefficients(20,
+                                static_cast<const std::vector<double>*>(0));
 
 
+  Legendre::Legendre (const unsigned int k)
+                  :
+                  Polynomial<double> (get_coefficients(k))
+  {}
 
-  template <typename number>
+
+  
   void
-  Legendre<number>::compute_coefficients (const unsigned int k_)
+  Legendre::compute_coefficients (const unsigned int k_)
   {
                                      // make sure we call the
                                      // Polynomial::shift function
@@ -572,10 +576,10 @@ namespace Polynomials
                                              // later assign it to the
                                              // coefficients array to
                                              // make it const
-            std::vector<number> *c0 = new std::vector<number>(1);
+            std::vector<double> *c0 = new std::vector<double>(1);
             (*c0)[0] = 1.;
 
-            std::vector<number> *c1 = new std::vector<number>(2);
+            std::vector<double> *c1 = new std::vector<double>(2);
             (*c1)[0] = 0.;
             (*c1)[1] = 1.;
 
@@ -585,14 +589,14 @@ namespace Polynomials
             recursive_coefficients[1] = c1;
                                              // Compute polynomials
                                              // orthogonal on [0,1]
-            c0 = new std::vector<number>(*c0);
-            c1 = new std::vector<number>(*c1);
+            c0 = new std::vector<double>(*c0);
+            c1 = new std::vector<double>(*c1);
          
-            Polynomial<number>::template shift<SHIFT_TYPE> (*c0, -1.);
-            Polynomial<number>::scale(*c0, 2.);
-            Polynomial<number>::template shift<SHIFT_TYPE> (*c1, -1.);
-            Polynomial<number>::scale(*c1, 2.);
-            Polynomial<number>::multiply(*c1, std::sqrt(3.));
+            Polynomial<double>::shift<SHIFT_TYPE> (*c0, -1.);
+            Polynomial<double>::scale(*c0, 2.);
+            Polynomial<double>::shift<SHIFT_TYPE> (*c1, -1.);
+            Polynomial<double>::scale(*c1, 2.);
+            Polynomial<double>::multiply(*c1, std::sqrt(3.));
             shifted_coefficients[0]=c0;
             shifted_coefficients[1]=c1;
           }
@@ -610,11 +614,11 @@ namespace Polynomials
             compute_coefficients(k-1);
             coefficients_lock.acquire ();
 
-            std::vector<number> *ck = new std::vector<number>(k+1);
+            std::vector<double> *ck = new std::vector<double>(k+1);
          
-            const number a = 1./(k);
-            const number b = a*(2*k-1);
-            const number c = a*(k-1);
+            const double a = 1./(k);
+            const double b = a*(2*k-1);
+            const double c = a*(k-1);
          
             (*ck)[k]   = b*(*recursive_coefficients[k-1])[k-1];
             (*ck)[k-1] = b*(*recursive_coefficients[k-1])[k-2];
@@ -631,10 +635,10 @@ namespace Polynomials
             recursive_coefficients[k] = ck;
                                              // and compute the
                                              // coefficients for [0,1]
-            ck = new std::vector<number>(*ck);
-            Polynomial<number>::template shift<SHIFT_TYPE> (*ck, -1.);
-            Polynomial<number>::scale(*ck, 2.);
-            Polynomial<number>::multiply(*ck, std::sqrt(2.*k+1.));
+            ck = new std::vector<double>(*ck);
+            Polynomial<double>::shift<SHIFT_TYPE> (*ck, -1.);
+            Polynomial<double>::scale(*ck, 2.);
+            Polynomial<double>::multiply(*ck, std::sqrt(2.*k+1.));
             shifted_coefficients[k] = ck;
           };
       };
@@ -642,9 +646,8 @@ namespace Polynomials
 
 
 
-  template <typename number>
-  const std::vector<number> &
-  Legendre<number>::get_coefficients (const unsigned int k)
+  const std::vector<double> &
+  Legendre::get_coefficients (const unsigned int k)
   {
                                      // first make sure the coefficients
                                      // get computed if so necessary
@@ -659,22 +662,13 @@ namespace Polynomials
 
 
 
-  template <typename number>
-  Legendre<number>::Legendre (const unsigned int k)
-                  :
-                  Polynomial<number> (get_coefficients(k))
-  {}
-
-
-
-  template <typename number>
-  std::vector<Polynomial<number> >
-  Legendre<number>::generate_complete_basis (const unsigned int degree)
+  std::vector<Polynomial<double> >
+  Legendre::generate_complete_basis (const unsigned int degree)
   {
     std::vector<Polynomial<double> > v;
     v.reserve(degree+1);
     for (unsigned int i=0; i<=degree; ++i)
-      v.push_back (Legendre<double>(i));
+      v.push_back (Legendre(i));
     return v;
   }
 
@@ -686,16 +680,21 @@ namespace Polynomials
 
 // Reserve space for polynomials up to degree 19. Should be sufficient
 // for the start.
-  template <typename number>
-  std::vector<const std::vector<number> *>
-  Hierarchical<number>::recursive_coefficients(
-     20, static_cast<const std::vector<number>*>(0));
+  std::vector<const std::vector<double> *>
+  Hierarchical::recursive_coefficients(
+     20, static_cast<const std::vector<double>*>(0));
+
+
+
+  Hierarchical::Hierarchical (const unsigned int k)
+                      :
+                      Polynomial<double> (get_coefficients(k))
+  {}
 
 
 
-  template <typename number>
   void
-  Hierarchical<number>::compute_coefficients (const unsigned int k_)
+  Hierarchical::compute_coefficients (const unsigned int k_)
   {
     unsigned int k = k_;
 
@@ -730,11 +729,11 @@ namespace Polynomials
                                              // later assign it to the
                                              // coefficients array to
                                              // make it const
-           std::vector<number> *c0 = new std::vector<number>(2);
+           std::vector<double> *c0 = new std::vector<double>(2);
            (*c0)[0] =  1.;
            (*c0)[1] = -1.;
 
-           std::vector<number> *c1 = new std::vector<number>(2);
+           std::vector<double> *c1 = new std::vector<double>(2);
            (*c1)[0] = 0.;
            (*c1)[1] = 1.;
 
@@ -749,9 +748,9 @@ namespace Polynomials
            compute_coefficients(1);
            coefficients_lock.acquire ();
 
-           std::vector<number> *c2 = new std::vector<number>(3);
+           std::vector<double> *c2 = new std::vector<double>(3);
 
-           const number a = 1.; //1./8.;
+           const double a = 1.; //1./8.;
 
            (*c2)[0] =   0.*a;
            (*c2)[1] =  -4.*a;
@@ -773,9 +772,9 @@ namespace Polynomials
            compute_coefficients(k-1);
            coefficients_lock.acquire ();
 
-           std::vector<number> *ck = new std::vector<number>(k+1);
+           std::vector<double> *ck = new std::vector<double>(k+1);
           
-           const number a = 1.; //1./(2.*k);
+           const double a = 1.; //1./(2.*k);
 
            (*ck)[0] = - a*(*recursive_coefficients[k-1])[0];
          
@@ -789,7 +788,7 @@ namespace Polynomials
                                          // basis fcn phi_2
            if ( (k%2) == 0 )
              {
-               number b = 1.; //8.;
+               double b = 1.; //8.;
                //for (unsigned int i=1; i<=k; i++)
                //  b /= 2.*i;
 
@@ -807,9 +806,8 @@ namespace Polynomials
 
 
 
-  template <typename number>
-  const typename std::vector<number> &
-  Hierarchical<number>::get_coefficients (const unsigned int k)
+  const std::vector<double> &
+  Hierarchical::get_coefficients (const unsigned int k)
   {
                                   // first make sure the coefficients
                                   // get computed if so necessary
@@ -819,7 +817,7 @@ namespace Polynomials
                                   // of coefficients. do that in a MT
                                      // safe way
     coefficients_lock.acquire ();
-    const std::vector<number> *p = recursive_coefficients[k];
+    const std::vector<double> *p = recursive_coefficients[k];
     coefficients_lock.release ();
 
                                   // return the object pointed
@@ -831,17 +829,8 @@ namespace Polynomials
 
 
 
-  template <typename number>
-  Hierarchical<number>::Hierarchical (const unsigned int k)
-                      :
-                      Polynomial<number> (get_coefficients(k))
-  {}
-
-
-
-  template <typename number>
-  std::vector<Polynomial<number> >
-  Hierarchical<number>::generate_complete_basis (const unsigned int degree)
+  std::vector<Polynomial<double> >
+  Hierarchical::generate_complete_basis (const unsigned int degree)
   {
     if (degree==0)
                                        // create constant
@@ -860,7 +849,7 @@ namespace Polynomials
         std::vector<Polynomial<double> > v;
         v.reserve(degree+1);
         for (unsigned int i=0; i<=degree; ++i)
-          v.push_back (Hierarchical<double>(i));
+          v.push_back (Hierarchical(i));
         return v;
       }
   }
@@ -882,7 +871,4 @@ namespace Polynomials
   template void Polynomial<long double>::shift(const long double offset);
   template void Polynomial<float>::shift(const long double offset);
   template void Polynomial<double>::shift(const long double offset);
-
-  template class Legendre<double>;
-  template class Hierarchical<double>;
 }
index a986b9ed1c813e4460a40bf4c8f936142766e020..fbf918d5983c2db53f7d65bd91a399ccecd87acf 100644 (file)
@@ -327,6 +327,15 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>base</h3>
 
 <ol>
+  <li> <p>
+       Changed: The <code class="class">Polynomials::Legendre</code>
+       class lost its template argument and is now just a regular
+       class. There was no real good reason for the template argument,
+       it had just crept in.
+       <br>
+       (WB 2003/05/12)
+       </p>
+
   <li> <p>
        New: There is now a class <code
        class="class">AnisotropicPolynomials</code> that constructs a higher

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.