DUNE-FEM (unstable)

legendrepolynomials.hh
1#ifndef DUNE_FEM_SPACE_SHAPEFUNCTIONSET_LEGENDREPOLYNOMIALS_HH
2#define DUNE_FEM_SPACE_SHAPEFUNCTIONSET_LEGENDREPOLYNOMIALS_HH
3
4// C++ inlcudes
5#include <cassert>
6#include <iostream>
7
8
9namespace Dune
10{
11
12 namespace Fem
13 {
14
15 class LegendrePolynomials
16 {
17 public:
18 static const int maxOrder = 11;
19
20 static const double factor[ maxOrder ][ maxOrder ];
21 static const double weight[ maxOrder ];
22
23 public:
24 static double evaluate ( const int num, const double x )
25 {
26 assert( 0 <= num && num < maxOrder );
27
28 double phi = factor[ num ][ num ];
29 for( int i = num-1; i >= 0; --i )
30 phi = phi * x + factor[ num ][ i ];
31 return weight[ num ] * phi;
32 }
33
34 static double jacobian ( const int num, const double x )
35 {
36 assert( 0 <= num && num < maxOrder );
37
38 double phi = 0.;
39 if( num >= 1 )
40 {
41 phi = factor[ num ][ num ] * num;
42 for( int i = num-1; i >= 1; --i )
43 phi = phi * x + factor[ num ][ i ] * i;
44 }
45 return weight[ num ] * phi;
46 }
47
48 static double hessian ( const int num, const double x )
49 {
50 assert( 0 <= num && num < maxOrder );
51
52 double phi=0.;
53 if( num >= 2 )
54 {
55 phi = factor[ num ][ num ] * num * ( num-1 );
56 for( int i = num-1; i >= 2; --i )
57 phi = phi * x + factor[ num ][ i ] * i * (i-1);
58 }
59 return weight[ num ] * phi;
60 }
61 };
62
63 } // namespace Fem
64
65} // namespace Dune
66
67#endif // #ifndef DUNE_FEM_SPACE_SHAPEFUNCTIONSET_LEGENDREPOLYNOMIALS_HH
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)