]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
test Hermite interpolation polynomials
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 12 Sep 2012 08:59:34 +0000 (08:59 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 12 Sep 2012 08:59:34 +0000 (08:59 +0000)
git-svn-id: https://svn.dealii.org/trunk@26300 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/polynomial_hermite_interpolation.cc [new file with mode: 0644]
tests/base/polynomial_hermite_interpolation/cmp/generic [new file with mode: 0644]

diff --git a/tests/base/polynomial_hermite_interpolation.cc b/tests/base/polynomial_hermite_interpolation.cc
new file mode 100644 (file)
index 0000000..495638a
--- /dev/null
@@ -0,0 +1,60 @@
+//-----------------------------------------------------------------------------
+//    $Id: polynomial_lagrange_product.cc 23959 2011-07-26 12:58:28Z kronbichler $
+//
+//    Copyright (C) 2012 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.
+//
+//-----------------------------------------------------------------------------
+
+#include "../tests.h"
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/polynomial.h>
+
+using namespace Polynomials;
+
+void plot(const std::vector<Polynomial<double> >& polynomials)
+{
+  LogStream::Prefix("plot");
+  const unsigned int n=8;
+  for (unsigned int i=0;i<=n;++i)
+    {
+      const double x = 1.*i/n;
+      deallog << x;
+      for (unsigned int p=0;p<polynomials.size();++p)
+       deallog << '\t' << polynomials[p].value(x);
+      deallog << std::endl;
+    }
+}
+
+void interpolation_conditions(const std::vector<Polynomial<double> >& polynomials)
+{
+  std::vector<double> values(2);
+  for (unsigned int i=0;i<polynomials.size();++i)
+    {
+      polynomials[i].value(0., values);
+      deallog << i << "\t 0:\t" << values[0] << '\t' << values[1] << std::endl;
+      polynomials[i].value(1., values);
+      deallog << i << "\t 1:\t" << values[0] << '\t' << values[1] << std::endl;
+    }
+}
+
+
+int main()
+{
+  std::string logname = JobIdentifier::base_name(__FILE__) + std::string("/output");
+  std::ofstream logfile(logname.c_str());
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-12);
+  
+  interpolation_conditions(HermiteInterpolation::generate_complete_basis(6));
+  plot(HermiteInterpolation::generate_complete_basis(6));
+}
diff --git a/tests/base/polynomial_hermite_interpolation/cmp/generic b/tests/base/polynomial_hermite_interpolation/cmp/generic
new file mode 100644 (file)
index 0000000..bf33d9e
--- /dev/null
@@ -0,0 +1,24 @@
+
+DEAL::0         0:     1.00000 0
+DEAL::0         1:     0       0
+DEAL::1         0:     0       0
+DEAL::1         1:     1.00000 0
+DEAL::2         0:     0       1.00000
+DEAL::2         1:     0       0
+DEAL::3         0:     0       0
+DEAL::3         1:     0       1.00000
+DEAL::4         0:     0       0
+DEAL::4         1:     0       0
+DEAL::5         0:     0       0
+DEAL::5         1:     0       0
+DEAL::6         0:     0       0
+DEAL::6         1:     0       0
+DEAL::0        1.00000 0       0       0       0       0       0
+DEAL::0.125000 0.957031        0.0429688       0.0957031       -0.0136719      0.191406        -0.248644       0.147124
+DEAL::0.250000 0.843750        0.156250        0.140625        -0.0468750      0.562500        -0.487139       -0.157224
+DEAL::0.375000 0.683594        0.316406        0.146484        -0.0878906      0.878906        -0.380578       -0.798401
+DEAL::0.500000 0.500000        0.500000        0.125000        -0.125000       1.00000 0       -1.11803
+DEAL::0.625000 0.316406        0.683594        0.0878906       -0.146484       0.878906        0.380578        -0.798401
+DEAL::0.750000 0.156250        0.843750        0.0468750       -0.140625       0.562500        0.487139        -0.157224
+DEAL::0.875000 0.0429688       0.957031        0.0136719       -0.0957031      0.191406        0.248644        0.147124
+DEAL::1.00000  0       1.00000 0       0       0       0       0

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.