]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
test for Legendre polynomials
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 28 May 2001 11:26:07 +0000 (11:26 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 28 May 2001 11:26:07 +0000 (11:26 +0000)
git-svn-id: https://svn.dealii.org/trunk@4732 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/Makefile.in
tests/base/polynomial1d.cc [new file with mode: 0644]
tests/base/polynomial1d.checked [new file with mode: 0644]

index f60060d7540ead2fb63b34da0fb473fb9e2f1117..869df7427888148963f3d2c6c99ef647b7cf9250 100644 (file)
@@ -19,8 +19,9 @@ default: run-tests
 
 ############################################################
 
-logtest.exe        : logtest.go            $(libraries)
-polynomial_test.exe: polynomial_test.go    $(libraries)
+logtest.exe        : logtest.go            $(lib-base.g)
+polynomial_test.exe: polynomial_test.go    $(lib-base.g)
+polynomial1d.exe   : polynomial1d.go       $(lib-base.g)
 quadrature_test.exe: quadrature_test.go    $(libraries)
 reference.exe      : reference.go abort.go $(libraries)
 tensor.exe         : tensor.go             $(libraries)
@@ -28,7 +29,7 @@ timer.exe          : timer.go              $(libraries)
 auto_derivative_function.exe        : auto_derivative_function.go            $(libraries)
 
 
-tests = logtest quadrature_test reference tensor timer polynomial_test auto_derivative_function
+tests = logtest reference quadrature_test tensor timer polynomial1d polynomial_test auto_derivative_function
 
 ############################################################
 
diff --git a/tests/base/polynomial1d.cc b/tests/base/polynomial1d.cc
new file mode 100644 (file)
index 0000000..98f7a5e
--- /dev/null
@@ -0,0 +1,55 @@
+//-----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2000, 2001 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 <iostream>
+#include <fstream>
+#include <cmath>
+
+#include <base/logstream.h>
+#include <base/polynomial.h>
+#include <base/quadrature_lib.h>
+
+
+double scalar_product (const Polynomial<double>& p1,
+                      const Polynomial<double>& p2)
+{
+  unsigned int degree = (p1.degree() + p2.degree())/2 + 1;
+  QGauss<1> gauss(degree);
+
+  double sum = 0.;
+  for (unsigned int i=0;i<gauss.n_quadrature_points;++i)
+    {
+      double x = 2.*gauss.point(i)(0)-1.;
+      double P1 = p1.value(x);
+      double P2 = p2.value(x);
+      sum += 2.*gauss.weight(i) * P1 * P2;
+    }
+  return sum;
+}
+
+int main ()
+{
+  std::ofstream logfile("polynomial1d.output");
+  logfile.precision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  vector<Polynomial<double> > p (15);
+  for (unsigned int i=0;i<p.size();++i)
+    p[i] = Legendre<double>(i);
+  
+  for (unsigned int i=0;i<p.size();++i)
+    for (unsigned int j=0;j<=i;++j)
+      deallog << 'P' << i << " * P" << j
+             << " =" << scalar_product(p[i], p[j]) << endl;
+}
diff --git a/tests/base/polynomial1d.checked b/tests/base/polynomial1d.checked
new file mode 100644 (file)
index 0000000..9704110
--- /dev/null
@@ -0,0 +1,121 @@
+
+DEAL::P0 * P0 =2.00
+DEAL::P1 * P0 =0.00
+DEAL::P1 * P1 =0.667
+DEAL::P2 * P0 =0.00
+DEAL::P2 * P1 =0.00
+DEAL::P2 * P2 =0.400
+DEAL::P3 * P0 =0.00
+DEAL::P3 * P1 =0.00
+DEAL::P3 * P2 =0.00
+DEAL::P3 * P3 =0.286
+DEAL::P4 * P0 =0.00
+DEAL::P4 * P1 =0.00
+DEAL::P4 * P2 =0.00
+DEAL::P4 * P3 =0.00
+DEAL::P4 * P4 =0.222
+DEAL::P5 * P0 =0.00
+DEAL::P5 * P1 =0.00
+DEAL::P5 * P2 =0.00
+DEAL::P5 * P3 =0.00
+DEAL::P5 * P4 =0.00
+DEAL::P5 * P5 =0.182
+DEAL::P6 * P0 =0.00
+DEAL::P6 * P1 =0.00
+DEAL::P6 * P2 =0.00
+DEAL::P6 * P3 =0.00
+DEAL::P6 * P4 =0.00
+DEAL::P6 * P5 =0.00
+DEAL::P6 * P6 =0.154
+DEAL::P7 * P0 =0.00
+DEAL::P7 * P1 =0.00
+DEAL::P7 * P2 =0.00
+DEAL::P7 * P3 =0.00
+DEAL::P7 * P4 =0.00
+DEAL::P7 * P5 =0.00
+DEAL::P7 * P6 =0.00
+DEAL::P7 * P7 =0.133
+DEAL::P8 * P0 =0.00
+DEAL::P8 * P1 =0.00
+DEAL::P8 * P2 =0.00
+DEAL::P8 * P3 =0.00
+DEAL::P8 * P4 =0.00
+DEAL::P8 * P5 =0.00
+DEAL::P8 * P6 =0.00
+DEAL::P8 * P7 =0.00
+DEAL::P8 * P8 =0.118
+DEAL::P9 * P0 =0.00
+DEAL::P9 * P1 =0.00
+DEAL::P9 * P2 =0.00
+DEAL::P9 * P3 =0.00
+DEAL::P9 * P4 =0.00
+DEAL::P9 * P5 =0.00
+DEAL::P9 * P6 =0.00
+DEAL::P9 * P7 =0.00
+DEAL::P9 * P8 =0.00
+DEAL::P9 * P9 =0.105
+DEAL::P10 * P0 =0.00
+DEAL::P10 * P1 =0.00
+DEAL::P10 * P2 =0.00
+DEAL::P10 * P3 =0.00
+DEAL::P10 * P4 =0.00
+DEAL::P10 * P5 =0.00
+DEAL::P10 * P6 =0.00
+DEAL::P10 * P7 =0.00
+DEAL::P10 * P8 =0.00
+DEAL::P10 * P9 =0.00
+DEAL::P10 * P10 =0.0952
+DEAL::P11 * P0 =0.00
+DEAL::P11 * P1 =0.00
+DEAL::P11 * P2 =0.00
+DEAL::P11 * P3 =0.00
+DEAL::P11 * P4 =0.00
+DEAL::P11 * P5 =0.00
+DEAL::P11 * P6 =0.00
+DEAL::P11 * P7 =0.00
+DEAL::P11 * P8 =0.00
+DEAL::P11 * P9 =0.00
+DEAL::P11 * P10 =0.00
+DEAL::P11 * P11 =0.0870
+DEAL::P12 * P0 =0.00
+DEAL::P12 * P1 =0.00
+DEAL::P12 * P2 =0.00
+DEAL::P12 * P3 =0.00
+DEAL::P12 * P4 =0.00
+DEAL::P12 * P5 =0.00
+DEAL::P12 * P6 =0.00
+DEAL::P12 * P7 =0.00
+DEAL::P12 * P8 =0.00
+DEAL::P12 * P9 =0.00
+DEAL::P12 * P10 =0.00
+DEAL::P12 * P11 =0.00
+DEAL::P12 * P12 =0.0800
+DEAL::P13 * P0 =0.00
+DEAL::P13 * P1 =0.00
+DEAL::P13 * P2 =0.00
+DEAL::P13 * P3 =0.00
+DEAL::P13 * P4 =0.00
+DEAL::P13 * P5 =0.00
+DEAL::P13 * P6 =0.00
+DEAL::P13 * P7 =0.00
+DEAL::P13 * P8 =0.00
+DEAL::P13 * P9 =0.00
+DEAL::P13 * P10 =0.00
+DEAL::P13 * P11 =0.00
+DEAL::P13 * P12 =0.00
+DEAL::P13 * P13 =0.0741
+DEAL::P14 * P0 =0.00
+DEAL::P14 * P1 =0.00
+DEAL::P14 * P2 =0.00
+DEAL::P14 * P3 =0.00
+DEAL::P14 * P4 =0.00
+DEAL::P14 * P5 =0.00
+DEAL::P14 * P6 =0.00
+DEAL::P14 * P7 =0.00
+DEAL::P14 * P8 =0.00
+DEAL::P14 * P9 =0.00
+DEAL::P14 * P10 =0.00
+DEAL::P14 * P11 =0.00
+DEAL::P14 * P12 =0.00
+DEAL::P14 * P13 =0.00
+DEAL::P14 * P14 =0.0690

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.