oomph::Legendre_functions_helper Namespace Reference

Helper namespace for functions required for Helmholtz computations. More...

Functions

double factorial (const unsigned &l)
 Factorial. More...
 
double plgndr1 (const unsigned &n, const double &x)
 Legendre polynomials depending on one parameter. More...
 
double plgndr2 (const unsigned &l, const unsigned &m, const double &x)
 Legendre polynomials depending on two parameters. More...
 

Detailed Description

Helper namespace for functions required for Helmholtz computations.

Function Documentation

◆ factorial()

double oomph::Legendre_functions_helper::factorial ( const unsigned l)

Factorial.

41  {
42  if (l == 0) return 1.0;
43  return double(l * factorial(l - 1));
44  }
double factorial(const unsigned &l)
Factorial.
Definition: fourier_decomposed_helmholtz_elements.cc:40

Referenced by oomph::FourierDecomposedHelmholtzDtNMesh< ELEMENT >::setup_gamma().

◆ plgndr1()

double oomph::Legendre_functions_helper::plgndr1 ( const unsigned n,
const double x 
)

Legendre polynomials depending on one parameter.

51  {
52  unsigned i;
53  double pmm, pmm1;
54  double pmm2 = 0;
55 
56 #ifdef PARANOID
57  // Shout if things went wrong
58  if (std::fabs(x) > 1.0)
59  {
60  std::ostringstream error_stream;
61  error_stream << "Bad arguments in routine plgndr1: x=" << x
62  << " but should be less than 1 in absolute value.\n";
63  throw OomphLibError(
65  }
66 #endif
67 
68  // Compute pmm : if l=m it's finished
69  pmm = 1.0;
70  if (n == 0)
71  {
72  return pmm;
73  }
74 
75  pmm1 = x * 1.0;
76  if (n == 1)
77  {
78  return pmm1;
79  }
80  else
81  {
82  for (i = 2; i <= n; i++)
83  {
84  pmm2 = (x * (2 * i - 1) * pmm1 - (i - 1) * pmm) / i;
85  pmm = pmm1;
86  pmm1 = pmm2;
87  }
88  return pmm2;
89  }
90 
91  } // end of plgndr1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:117
list x
Definition: plotDoE.py:28
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References boost::multiprecision::fabs(), i, n, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, and plotDoE::x.

◆ plgndr2()

double oomph::Legendre_functions_helper::plgndr2 ( const unsigned l,
const unsigned m,
const double x 
)

Legendre polynomials depending on two parameters.

98  {
99  unsigned i, ll;
100  double fact, pmm, pmmp1, somx2;
101  double pll = 0.0;
102 
103 #ifdef PARANOID
104  // Shout if things went wrong
105  if (std::fabs(x) > 1.0)
106  {
107  std::ostringstream error_stream;
108  error_stream << "Bad arguments in routine plgndr2: x=" << x
109  << " but should be less than 1 in absolute value.\n";
110  throw OomphLibError(
111  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
112  }
113 #endif
114 
115  // This one is easy...
116  if (m > l)
117  {
118  return 0.0;
119  }
120 
121  // Compute pmm : if l=m it's finished
122  pmm = 1.0;
123  if (m > 0)
124  {
125  somx2 = sqrt((1.0 - x) * (1.0 + x));
126  fact = 1.0;
127  for (i = 1; i <= m; i++)
128  {
129  pmm *= -fact * somx2;
130  fact += 2.0;
131  }
132  }
133  if (l == m) return pmm;
134 
135  // Compute pmmp1 : if l=m+1 it's finished
136  else
137  {
138  pmmp1 = x * (2 * m + 1) * pmm;
139  if (l == (m + 1))
140  {
141  return pmmp1;
142  }
143  // Compute pll : if l>m+1 it's finished
144  else
145  {
146  for (ll = m + 2; ll <= l; ll++)
147  {
148  pll = (x * (2 * ll - 1) * pmmp1 - (ll + m - 1) * pmm) / (ll - m);
149  pmm = pmmp1;
150  pmmp1 = pll;
151  }
152  return pll;
153  }
154  }
155  } // end of plgndr2
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int * m
Definition: level2_cplx_impl.h:294

References boost::multiprecision::fabs(), i, m, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, sqrt(), and plotDoE::x.

Referenced by oomph::FourierDecomposedHelmholtzDtNBoundaryElement< ELEMENT >::compute_gamma_contribution(), ProblemParameters::exact_minus_dudr(), PlanarWave::get_exact_u(), ProblemParameters::get_exact_u(), and main().