Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
PowerFunctor.h
Go to the documentation of this file.
1 #pragma once
2 
9 #include "AQ_Util.h"
10 #include <cmath>
11 #include <functional>
12 
13 namespace UA_CoMP {
14 namespace Num {
15 
19 class PowerFunctor : public std::unary_function<double, double>
20 {
21 public:
24  class Integral : public std::binary_function<argument_type, argument_type, result_type>
25  {
26  public:
28  Integral(int n) : fN(n) {}
29 
31  result_type operator()(first_argument_type a, first_argument_type b) const
32  {
33  return (std::pow(b, fN + 1) - std::pow(a, fN + 1)) / static_cast<result_type>(fN + 1);
34  }
35 
36  private:
37  int fN;
38  };
39 
41  PowerFunctor(int n) : fN(n), fIntegral(n) {}
42 
44  result_type operator()(argument_type x) const { return std::pow(x, fN); }
45 
47  Integral getIntegral() const { return fIntegral; }
48 
49 private:
50  int fN;
52 };
53 
54 } // namespace Num
55 } // namespace UA_CoMP
PowerFunctor(int n)
Straightforward constructor.
Definition: PowerFunctor.h:41
Integral(int n)
Non-default constructor.
Definition: PowerFunctor.h:28
Nested class contains the analytic integral of the functor for testing purposes.
Definition: PowerFunctor.h:24
result_type operator()(first_argument_type a, first_argument_type b) const
The definite integral from a to b.
Definition: PowerFunctor.h:31
Utilities for the implementation of the Adaptive Quadrature.
Integral getIntegral() const
Return the analytic integral object.
Definition: PowerFunctor.h:47
result_type operator()(argument_type x) const
Evaluation operator.
Definition: PowerFunctor.h:44