24#include <ql/errors.hpp>
25#include <ql/utilities/null.hpp>
26#include <ql/math/array.hpp>
27#include <ql/math/functional.hpp>
28#include <ql/math/integrals/filonintegral.hpp>
37 intervals_(intervals),
39 QL_REQUIRE( !(
intervals_ & 1),
"number of intervals must be even");
44 const Real h = (b-a)/(2*
n_);
48 const Real theta2 = theta*theta;
49 const Real theta3 = theta2*theta;
51 const Real alpha = 1/theta + std::sin(2*theta)/(2*theta2)
52 - 2*
squared(std::sin(theta))/theta3;
53 const Real beta = 2*( (1+
squared(std::cos(theta)))/theta2
54 - std::sin(2*theta)/theta3);
55 const Real gamma = 4*(std::sin(theta)/theta3 - std::cos(theta)/theta2);
58 std::transform(x.
begin(), x.
end(), v.begin(), f);
63 f1 = [](
Real x) ->
Real {
return std::sin(x); };
64 f2 = [](
Real x) ->
Real {
return std::cos(x); };
67 f1 = [](
Real x) ->
Real {
return std::cos(x); };
68 f2 = [](
Real x) ->
Real {
return std::sin(x); };
71 QL_FAIL(
"unknown integration type");
76 - 0.5*(v[2*
n_]*f2(
t_*b) + v[0]*f2(
t_*a));
78 for (
Size i=1; i <=
n_; ++i) {
79 c_2n += v[2*i] *f2(
t_*x[2*i]);
80 c_2n_1 += v[2*i-1]*f2(
t_*x[2*i-1]);
83 return h*(alpha*(v[2*
n_]*f1(
t_*x[2*
n_]) - v[0]*f1(
t_*x[0]))
85 + beta*c_2n + gamma*c_2n_1);
1-D array used in linear algebra.
const_iterator end() const
Size size() const
dimension of the array
const_iterator begin() const
FilonIntegral(Type type, Real t, Size intervals)
Real integrate(const ext::function< Real(Real)> &f, Real a, Real b) const override
template class providing a null value for a given type.
std::size_t Size
size of a container