philsupertramp/game-math
Loading...
Searching...
No Matches
numerics/analysis/TestIntegration.cpp

This is an example on how to use the quadrature method.

#include "../../Test.h"
class IntegrationTestCase : public Test
{
bool TestQuadAdaptive() {
auto res = quadrature(sin, 0, M_PI, .1, 1.e-50);
AssertLessThenEqual(fabs(res.first - 2.0), 9.32e-5);
return true;
}
public:
virtual void run() { TestQuadAdaptive(); }
};
int main() {
IntegrationTestCase().run();
return 0;
}
std::pair< double, std::vector< double > > quadrature(const std::function< double(double)> &fun, const double &lower, const double &upper, const double &tol, const double &hMin)
Definition: Integration.h:117