]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Lexicographical order of support points.
authorhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 15 Dec 2000 10:33:36 +0000 (10:33 +0000)
committerhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 15 Dec 2000 10:33:36 +0000 (10:33 +0000)
git-svn-id: https://svn.dealii.org/trunk@3540 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/polynomial.h
deal.II/base/source/polynomial.cc
tests/base/polynomial_test.cc
tests/base/polynomial_test.checked

index 923f59db4cee0f2b0c9031d75a85d3b7006ee18e..ca599d3debd0b48950939603433434bf4956d2a7 100644 (file)
@@ -36,7 +36,7 @@ class Polynomial
                                      * Returns the values and the
                                      * derivatives of the @p{Polynomial}
                                      * at point @p{x}. @p{values[i],
-                                     * i=0,...,values.size()}
+                                     * i=0,...,values.size()-1}
                                      * includes the @p{i}th
                                      * derivative.
                                      *
@@ -61,11 +61,11 @@ class Polynomial
 /**
  * Class of Lagrange polynomials with equidistant interpolation
  * points. The polynomial of order @p{n} has got @p{n+1} interpolation
- * points. The interpolation points are x=0, x=1 and x=intermediate
- * points in ]0,1[ in ascending order. This order gives an index to
- * each interpolation point.  A Lagrangian polynomial equals 1 at one
- * interpolation point that is called `support point', and 0 at all other
- * interpolation points.
+ * points. The interpolation points are sorted in ascending
+ * order. This order gives an index to each interpolation point.  A
+ * Lagrangian polynomial equals 1 at one interpolation point that is
+ * then called `support point', and 0 at all other interpolation
+ * points.
  *
  * @author Ralf Hartmann, 2000
  */
index cacbecff7587d63d7864c36f75e7dc9390c9779c..80ad3e57632e5e1d5c459ce4d7138d9574ea95f4 100644 (file)
@@ -88,13 +88,13 @@ vector<double> LagrangeEquidistant::compute_coefficients(unsigned int n, unsigne
                      break;
                case 1:
                      a[0]=0.;
-                     a[1]=-1.;               
-                     a[2]=2.;
+                     a[1]=4.;                
+                     a[2]=-4.;
                      break;
                case 2:
                      a[0]=0.;
-                     a[1]=4.;                
-                     a[2]=-4.;
+                     a[1]=-1.;               
+                     a[2]=2.;
                      break;
                default:
                      Assert(false, ExcInternalError());
@@ -110,23 +110,23 @@ vector<double> LagrangeEquidistant::compute_coefficients(unsigned int n, unsigne
                      a[3]=-9.0/2.0;
                      break;
                case 1:
-                     a[0]=0.;
-                     a[1]=1.;                
-                     a[2]=-9.0/2.0;
-                     a[3]=9.0/2.0;
-                     break;
-               case 2:
                      a[0]=0.;
                      a[1]=9.0;               
                      a[2]=-45.0/2.0;
                      a[3]=27.0/2.0;
                      break;
-               case 3:
+               case 2:
                      a[0]=0.;
                      a[1]=-9.0/2.0;                  
                      a[2]=18.0;
                      a[3]=-27.0/2.0;
                      break;
+               case 3:
+                     a[0]=0.;
+                     a[1]=1.;                
+                     a[2]=-9.0/2.0;
+                     a[3]=9.0/2.0;
+                     break;
                default:
                      Assert(false, ExcInternalError());
              }
@@ -142,33 +142,33 @@ vector<double> LagrangeEquidistant::compute_coefficients(unsigned int n, unsigne
                      a[4]=32.0/3.0;
                      break;
                case 1:
-                     a[0]=0.;
-                     a[1]=-1.;
-                     a[2]=22.0/3.0;
-                     a[3]=-16.0;
-                     a[4]=32.0/3.0;
-                     break;
-               case 2:
                      a[0]=0.;
                      a[1]=16.0;
                      a[2]=-208.0/3.0;
                      a[3]=96.0;
                      a[4]=-128.0/3.0;
                      break;
-               case 3:
+               case 2:
                      a[0]=0.;
                      a[1]=-12.0;
                      a[2]=76.0;
                      a[3]=-128.0;
                      a[4]=64.0;
                      break;
-               case 4:
+               case 3:
                      a[0]=0.;
                      a[1]=16.0/3.0;
                      a[2]=-112.0/3.0;
                      a[3]=224.0/3.0;
                      a[4]=-128.0/3.0;
                      break;
+               case 4:
+                     a[0]=0.;
+                     a[1]=-1.;
+                     a[2]=22.0/3.0;
+                     a[3]=-16.0;
+                     a[4]=32.0/3.0;
+                     break;
                default:
                      Assert(false, ExcInternalError());
              }
index 1a7af8f700b2d7056cc0a6b96f5cd4556adcd406..bdc4267e748f107f9f59d855d2e189e76cc2af06 100644 (file)
@@ -47,39 +47,23 @@ int main(int, char)
          LagrangeEquidistant polynom(order, s_point);
 
                                           // support points in vertices
-         if (order>0)
-           for (unsigned int i=0; i<=1; ++i)
-             {
-               double x=i;
-               polynom.value(x, values);
-               deallog << " p_" << s_point << "(" << x << ")";
-//             deallog << "=" << values[0];
-               if (equals_delta_ij(values[0], s_point, i))
-                 deallog << "   ok";
-               else
-                 deallog << "   false";
-               deallog << endl;
-             }
-                                          // support points on line
-         if (order>1)
-           for (unsigned int i=1; i<order; ++i)
-             {
-               double x=static_cast<double>(i)/order;
-               polynom.value(x, values);
-               deallog << " p_" << s_point << "(" << x << ")";
-//             deallog << "=" << values[0];
-               if (equals_delta_ij(values[0], s_point, i+1))
-                 deallog << "   ok";
-               else
-                 deallog << "   false";
-               deallog << endl;
-             }
-         deallog << endl;
+         for (unsigned int i=0; i<=order; ++i)
+           {
+             double x=static_cast<double>(i)/order;
+             polynom.value(x, values);
+             deallog << " p_" << s_point << "(" << x << ")";
+//           deallog << "=" << values[0];
+             if (equals_delta_ij(values[0], s_point, i))
+               deallog << "   ok";
+             else
+               deallog << "   false";
+             deallog << endl;
+           }
        }
     }
 
   deallog << endl << "Test derivatives computed by the Horner scheme:" << endl;
-  LagrangeEquidistant pol(4, 3);
+  LagrangeEquidistant pol(4, 2);
   vector<double> v_horner(6);
   for (unsigned int i=0; i<=10; ++i)
     {
@@ -87,8 +71,8 @@ int main(int, char)
       deallog << "x=" << xi << ",    all derivatives: ";
       vector<double> v_exact(6);
       
-      v_exact[0]=64.0*xi*xi*xi*xi-128.0*xi*xi*xi+76.0*xi*xi-12.0*xi;
       v_exact[1]=256.0*xi*xi*xi-384.0*xi*xi+152.0*xi-12.0;
+      v_exact[0]=64.0*xi*xi*xi*xi-128.0*xi*xi*xi+76.0*xi*xi-12.0*xi;
       v_exact[2]=768.0*xi*xi-768.0*xi+152.0;
       v_exact[3]=1536*xi-768;
       v_exact[4]=1536;
index 06dbd848bb65d7266081ca02e7c25b4d7a6f5242..71d338087526efee02cb8bb20ef251064a5af623 100644 (file)
@@ -3,75 +3,61 @@ DEAL::LagrangeEquidistant polynoms:
 DEAL::Polynomial p of order 1
 DEAL:: p_0(0.00000)   ok
 DEAL:: p_0(1.00000)   ok
-
 DEAL:: p_1(0.00000)   ok
 DEAL:: p_1(1.00000)   ok
-
 DEAL::Polynomial p of order 2
 DEAL:: p_0(0.00000)   ok
-DEAL:: p_0(1.00000)   ok
 DEAL:: p_0(0.500000)   ok
-
+DEAL:: p_0(1.00000)   ok
 DEAL:: p_1(0.00000)   ok
-DEAL:: p_1(1.00000)   ok
 DEAL:: p_1(0.500000)   ok
-
+DEAL:: p_1(1.00000)   ok
 DEAL:: p_2(0.00000)   ok
-DEAL:: p_2(1.00000)   ok
 DEAL:: p_2(0.500000)   ok
-
+DEAL:: p_2(1.00000)   ok
 DEAL::Polynomial p of order 3
 DEAL:: p_0(0.00000)   ok
-DEAL:: p_0(1.00000)   ok
 DEAL:: p_0(0.333333)   ok
 DEAL:: p_0(0.666667)   ok
-
+DEAL:: p_0(1.00000)   ok
 DEAL:: p_1(0.00000)   ok
-DEAL:: p_1(1.00000)   ok
 DEAL:: p_1(0.333333)   ok
 DEAL:: p_1(0.666667)   ok
-
+DEAL:: p_1(1.00000)   ok
 DEAL:: p_2(0.00000)   ok
-DEAL:: p_2(1.00000)   ok
 DEAL:: p_2(0.333333)   ok
 DEAL:: p_2(0.666667)   ok
-
+DEAL:: p_2(1.00000)   ok
 DEAL:: p_3(0.00000)   ok
-DEAL:: p_3(1.00000)   ok
 DEAL:: p_3(0.333333)   ok
 DEAL:: p_3(0.666667)   ok
-
+DEAL:: p_3(1.00000)   ok
 DEAL::Polynomial p of order 4
 DEAL:: p_0(0.00000)   ok
-DEAL:: p_0(1.00000)   ok
 DEAL:: p_0(0.250000)   ok
 DEAL:: p_0(0.500000)   ok
 DEAL:: p_0(0.750000)   ok
-
+DEAL:: p_0(1.00000)   ok
 DEAL:: p_1(0.00000)   ok
-DEAL:: p_1(1.00000)   ok
 DEAL:: p_1(0.250000)   ok
 DEAL:: p_1(0.500000)   ok
 DEAL:: p_1(0.750000)   ok
-
+DEAL:: p_1(1.00000)   ok
 DEAL:: p_2(0.00000)   ok
-DEAL:: p_2(1.00000)   ok
 DEAL:: p_2(0.250000)   ok
 DEAL:: p_2(0.500000)   ok
 DEAL:: p_2(0.750000)   ok
-
+DEAL:: p_2(1.00000)   ok
 DEAL:: p_3(0.00000)   ok
-DEAL:: p_3(1.00000)   ok
 DEAL:: p_3(0.250000)   ok
 DEAL:: p_3(0.500000)   ok
 DEAL:: p_3(0.750000)   ok
-
+DEAL:: p_3(1.00000)   ok
 DEAL:: p_4(0.00000)   ok
-DEAL:: p_4(1.00000)   ok
 DEAL:: p_4(0.250000)   ok
 DEAL:: p_4(0.500000)   ok
 DEAL:: p_4(0.750000)   ok
-
+DEAL:: p_4(1.00000)   ok
 
 DEAL::Test derivatives computed by the Horner scheme:
 DEAL::x=0.00000,    all derivatives: ok

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.