A type that visits SPnodes to check if they meet a 'Reimann Difference' tolerance requirement. More...
Public Member Functions | |
ReimannDiffToleranceCheck (const MappedFobj &f, cxsc::real tol) | |
Constructor. | |
void | visit (const SPnode *const spn) const |
The visit operation. | |
bool | getResult () const |
Get the result of the visit operation. |
A type that visits SPnodes to check if they meet a 'Reimann Difference' tolerance requirement.
The 'Reimann Difference' tolerance requirement is that the difference in the Reimann Integral taken to the top of the interval image of the box associated with the node against the Reimann Integral taken to the bottom of the interval image of the box associated should be less than or equal to the tolerance given by the constructor argument tol.
ie the Reimann Difference can also be seen as the 'area' represented by the interval image of the box associated with the node, or the volume of the box associated with the node multiplied by the diameter of the interval enclosure of the box associated with the node.
A node may not meet the requirement but not be splittable: in this case the result of the visit should be true (ie the node is deemed to meet the requirement because it is as close as it can be to meeting it).
The visit operation should return true if either the the node visited meets the Reimann Difference tolerance requirement or the node does not meet the requirement but is not splittable. Return false otherwise.
subpavings::ReimannDiffToleranceCheck::ReimannDiffToleranceCheck | ( | const MappedFobj & | f, |
cxsc::real | tol | ||
) |
Constructor.
f | describes a function against which to check the interval image tolerance requirement. |
tol | describes the tolerance to be used in the check. |
: fobj(f), tolerance(tol) { if (tolerance < cxsc::MinReal) throw std::invalid_argument( "ReimannDiffToleranceCheck::ReimannDiffToleranceCheck(MappedFobj&, cxsc::real) : tol < cxsc::MinReal"); }
void subpavings::ReimannDiffToleranceCheck::visit | ( | const SPnode *const | spn | ) | const [virtual] |
The visit operation.
Checks the node pointed to by spn and stores the result true if the Reimann Difference tolerance requirement is met.
spn | a pointer to an SPnode to be visited. |
Implements subpavings::SPCheckVisitor.
{ #ifdef MYDEBUG std::cout << "in ReimannDiffToleranceCheck::visit, for " << spn->getNodeName() << std::endl; #endif result = true; if (spn->isSplittableNode()) { ivector box = spn->getBox(); #ifdef MYDEBUG std::cout << "this box is " << box << std::endl; #endif interval thisRange = fobj(box); #ifdef MYDEBUG std::cout << "this range is " << thisRange << std::endl; #endif #ifdef MYDEBUG std::cout << "this tolerance is " << tolerance << std::endl; #endif if ((realVolume(box) * cxsc::diam(thisRange)) > tolerance) { result = false; } } #ifdef MYDEBUG_MIN std::cout << "conclusion " << result << std::endl; #endif }