Page MenuHomeHEPForge

test_rectangleQuadrature.cc
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

test_rectangleQuadrature.cc

#include <cmath>
#include "UnitTest++.h"
#include "test_utils.hh"
#include "npstat/nm/rectangleQuadrature.hh"
using namespace npstat;
using namespace std;
namespace {
class TestFunctor1D : public AbsMultivariateFunctor
{
inline unsigned minDim() const {return 1U;}
double operator()(const double* point, unsigned dim) const
{
assert(dim == minDim());
const double x = point[0];
return 3*x*x + 4*x - 7;
}
};
class TestFunctor2D : public AbsMultivariateFunctor
{
inline unsigned minDim() const {return 2U;}
double operator()(const double* point, unsigned dim) const
{
assert(dim == minDim());
const double x = point[0];
const double y = point[1];
return 2*x*x + 3*y*y - 4*x*y + 5*x + 6*y - 10;
}
};
TEST(rectangleQuadrature)
{
const double rectangleCenter[2] = {2.5, 4.5};
const double rectangleSize[2] = {3.0, 5.0};
const double integ1 = rectangleIntegralCenterAndSize(
TestFunctor1D(), rectangleCenter, rectangleSize, 1, 4);
CHECK_CLOSE(72.0, integ1, 1.0e-12);
const double integ2 = rectangleIntegralCenterAndSize(
TestFunctor2D(), rectangleCenter, rectangleSize, 2, 4);
CHECK_CLOSE(1965/2.0, integ2, 1.0e-12);
}
}

File Metadata

Mime Type
text/x-c
Expires
Tue, Sep 30, 4:45 AM (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6540640
Default Alt Text
test_rectangleQuadrature.cc (1 KB)

Event Timeline