]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
TensorProductPolynomials keep their own copy of Polynomials.
authorhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 7 Mar 2001 11:05:23 +0000 (11:05 +0000)
committerhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 7 Mar 2001 11:05:23 +0000 (11:05 +0000)
git-svn-id: https://svn.dealii.org/trunk@4139 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/tensor_product_polynomials.h
deal.II/base/source/tensor_product_polynomials.cc

index 2f7283f8e98da43dd3172a62f068f4b40fd2d809..3f091d88077cb371e209d70043e423d6dacc8ce0 100644 (file)
@@ -43,7 +43,8 @@ class TensorProductPolynomials
                                      * and will be copied into the
                                      * member variable @p{polynomials}.
                                      */
-    TensorProductPolynomials(const std::vector<SmartPointer<Polynomial<double> > > &pols);
+    template<class Pol>
+    TensorProductPolynomials(const std::vector<Pol> &pols);
 
                                     /**
                                      * Calculates the polynomials
@@ -78,10 +79,11 @@ class TensorProductPolynomials
            
   private:
                                     /**
-                                     * Pointer to the @p{polynomials}
-                                     * given to the constructor.
+                                     * Copy of the vector @p{pols} of
+                                     * polynomials given to the
+                                     * constructor.
                                      */
-    std::vector<SmartPointer<Polynomial<double> > > polynomials;
+    std::vector<Polynomial<double> > polynomials;
 
                                     /**
                                      * Number of tensor product
@@ -89,10 +91,23 @@ class TensorProductPolynomials
                                      * polynomials this is $n^dim$.
                                      */
     const unsigned int n_tensor_pols;
+
+
+    static unsigned int power(const unsigned int x, const unsigned int y);
 };
 
 
 
 
 
+template <int dim>
+template <class Pol>
+TensorProductPolynomials<dim>::TensorProductPolynomials(
+  const std::vector<Pol> &pols):
+               polynomials (pols.begin(), pols.end()),
+               n_tensor_pols(power(pols.size(), dim))
+{}
+
+
+
 #endif
index 4bb827db8e4e060d80bd11e919ce8164ba6708c0..67443cb4dcb956ec71d022fc5062cbe14ff7bbd0 100644 (file)
 
 
 
-template<typename number> static
-number power(number x, unsigned int y)
+template <int dim>
+unsigned int TensorProductPolynomials<dim>::power(const unsigned int x,
+                                                 const unsigned int y)
 {
-  number value=1;
+  unsigned int value=1;
   for (unsigned int i=0; i<y; ++i)
     value*=x;
   return value;
 }
 
 
-
-template <int dim>
-TensorProductPolynomials<dim>::TensorProductPolynomials(
-  const std::vector<SmartPointer<Polynomial<double> > > &pols):
-               polynomials(pols),
-               n_tensor_pols(power(polynomials.size(), dim))
-{}
-
-
 template <int dim>
 void TensorProductPolynomials<dim>::compute(
   const Point<dim>                     &p,
@@ -83,7 +75,7 @@ void TensorProductPolynomials<dim>::compute(
       std::vector<std::vector<double> > &v_d=v[d];
       Assert(v_d.size()==n_pols, ExcInternalError());
       for (unsigned int i=0; i<n_pols; ++i)
-       polynomials[i]->value(p(d), v_d[i]);
+       polynomials[i].value(p(d), v_d[i]);
     }
   
   if (update_values)

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.