1
// Copyright (C) 2003-2006 Anders Logg.
2
// Licensed under the GNU LGPL Version 2.1.
4
// First added: 2003-06-03
5
// Last changed: 2006-10-23
9
#include <dolfin/dolfin_log.h>
10
#include <dolfin/Legendre.h>
11
#include <dolfin/GaussQuadrature.h>
13
using namespace dolfin;
15
//-----------------------------------------------------------------------------
16
GaussQuadrature::GaussQuadrature(unsigned int n) : GaussianQuadrature(n)
21
error("Gauss quadrature not ok, check failed.");
23
//message("Gauss quadrature computed for n = %d, check passed.", n);
25
//-----------------------------------------------------------------------------
26
void GaussQuadrature::disp() const
28
cout << "Gauss quadrature points and weights on [-1,1] for n = "
31
cout << " i points weights" << endl;
32
cout << "-----------------------------------------------------" << endl;
34
for (unsigned int i = 0; i < n; i++)
35
message("%2d %.16e %.16e", i, points[i], weights[i]);
37
//-----------------------------------------------------------------------------
38
void GaussQuadrature::computePoints()
40
// Compute Gauss quadrature points on [-1,1] as the
41
// as the zeroes of the Legendre polynomials using Newton's method
53
// Compute the points by Newton's method
54
for (unsigned int i = 0; i <= ((n-1)/2); i++) {
57
x = cos(DOLFIN_PI*(real(i+1)-0.25)/(real(n)+0.5));
61
dx = - p(x) / p.ddx(x);
63
} while ( fabs(dx) > DOLFIN_EPS );
65
// Save the value using the symmetry of the points
75
//-----------------------------------------------------------------------------