16#ifndef B2INTEGRATION1D_H_ 
   17#define B2INTEGRATION1D_H_ 
   21typedef double(quadpack_function_t)(
const double*);
 
   23extern "C" void FC_GLOBAL(dqagse, DQAGSE)(
 
   24      quadpack_function_t f, 
double* a, 
double* b, 
double* epsabs, 
double* epsrel, 
int* limit,
 
   25      double* result, 
double* abserr, 
int* neval, 
int* ier, 
double* alist, 
double* blist,
 
   26      double* rlist, 
double* elist, 
int* iord, 
int* last);
 
   28namespace b2000 { 
namespace quadpack {
 
   31double simpson_integration(
const F& f, 
double a, 
double b, 
int n) {
 
   32    if (n % 2 != 0) { n += 1; }
 
   33    double r = (f(a) + f(b)) / 2;
 
   34    const double h = (b - a) / n;
 
   36    for (
int i = 1; i != n; ++i, a += h) { r += (1 + i % 2) * f(a); }
 
   43    static void set(
const F* f) { f_static = f; }
 
   44    static double f(
const double* x) { 
return (*f_static)(*x); }
 
   48    static const F* f_static;
 
   52const F* FOToF<F>::f_static;
 
   59                set_msg(
"Maximum number of subdivisions allowed has been achieved");
 
   63                      "The occurrence of roundoff error is detected, " 
   64                      "which prevents the requested tolerance from being achieved.");
 
   68                      "Extremely bad integrand behaviour occurs at some " 
   69                      "points of the integration interval.");
 
   72                set_msg(
"The algorithm does not converge.");
 
   75                set_msg(
"The integral is probably divergent, or slowly convergent.");
 
   78                set_msg(
"The input is invali.");
 
   81                set_msg(
"The integral is probably divergent, or slowly convergent.");
 
   89      const F& f, 
double a, 
double b, 
double epsabs, 
double epsrel, 
int subintevals_limit,
 
   90      double& abserr, 
int& nb_subinterval) {
 
   94    double* work = 
new double[subintevals_limit * 4];
 
   95    int* iwork = 
new int[subintevals_limit];
 
   97    FC_GLOBAL(dqagse, DQAGSE)
 
   98    (FOToF<F>::f, &a, &b, &epsabs, &epsrel, &subintevals_limit, &res, &abserr, &neval, &ier, work,
 
   99     work + subintevals_limit, work + 2 * subintevals_limit, work + 3 * subintevals_limit, iwork,
 
  101    nb_subinterval = neval;
 
  104    if (ier > 1) { Exception(ier) << 
THROW; }
 
#define THROW
Definition b2exception.H:198
 
Definition b2exception.H:131
 
Exception(const std::string &msg_=std::string(), const char *file_=nullptr, int line_=-1)
Definition b2exception.H:143
 
Contains the base classes for implementing Finite Elements.
Definition b2boundary_condition.H:32