7 #ifndef BALL_MATHS_NUMERICALINTEGRATOR_H
8 #define BALL_MATHS_NUMERICALINTEGRATOR_H
10 #ifndef BALL_MATHS_FUNCTION_H
19 template <
typename Function,
typename DataType =
float>
82 DataType
getValue(
const DataType& x)
const;
89 DataType
integrate(
const DataType& from,
const DataType& to)
const;
102 template<
typename Function,
typename DataType>
110 template<
typename Function,
typename DataType>
113 : function_(nint.function_)
118 template<
typename Function,
typename DataType>
125 template<
typename Function,
typename DataType>
136 template<
typename Function,
typename DataType>
140 function_ =
function;
144 template<
typename Function,
typename DataType>
149 return (function_ == nint.function_);
153 template<
typename Function,
typename DataType>
161 template<
typename Function,
typename DataType>
164 const DataType& from,
const DataType& to)
const
172 DataType step = (to - from) / n;
177 area += (function_(x) + function_(x + step)) / 2.0 * step;
186 #endif // BALL_MATHS_NUMERICALINTEGRATOR_H
NumericalIntegrator()
Default constructor.
#define BALL_CREATE(name)
virtual ~NumericalIntegrator()
Destructor.
DataType getValue(const DataType &x) const
DataType integrate(const DataType &from, const DataType &to) const
bool operator==(const NumericalIntegrator &nint) const
Equality operator.
NumericalIntegrator & operator=(const NumericalIntegrator &nint)
Assignment operator.
const Function & getFunction() const
void setFunction(const Function &function)