C++ distances between Box endpoint descriptions
- PPL-LLR-000003 Conservative directed numerical bounds (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000431 Mathematical query capabilities and logical outcomes (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
- PPL-LLR-000133 Failure and resource safety (Specifies)
For the endpoint differences dj of 🔗 4. Box endpoint-distance domain, workspaces and dispatch, rectilinear_distance_assign shall compute the requested directed bound on
This shall be a distance of endpoint descriptions, not the minimum distance between a point of each box. Openness shall not affect it. With exact rational temporary arithmetic and an exactly representable output, the finite sum shall be returned exactly.
The source interpretation, exceptional dimensional/empty/infinite cases, false-output preservation, numerical directions, workspace choices and lifetime conditions of 🔗 4. Box endpoint-distance domain, workspaces and dispatch shall apply to every overload. With supported arithmetic and representable intermediates, a completed upward result shall be at least the exact distance and a completed downward result at most the exact distance. A numerical or resource failure shall not establish a successful directed-bound result. Both sources shall retain their values and dimensions.
Endpoint descriptions give a deterministic numerical comparison of boxes; its meaning differs from geometric point-to-set separation.
Public header: <ppl.hh>; PPL free functions:
template <typename To, typename ITV> bool rectilinear_distance_assign( Checked_Number<To,Extended_Number_Policy>& result, const Box<ITV>& x, const Box<ITV>& y, Rounding_Dir dir); template <typename Temp, typename To, typename ITV> bool rectilinear_distance_assign( Checked_Number<To,Extended_Number_Policy>& result, const Box<ITV>& x, const Box<ITV>& y, Rounding_Dir dir); template <typename Work, typename To, typename ITV> bool rectilinear_distance_assign( Checked_Number<To,Extended_Number_Policy>& result, const Box<ITV>& x, const Box<ITV>& y, Rounding_Dir dir, Work& tmp0, Work& tmp1, Work& tmp2);
Independently flatten rational product descriptions and sum their absolute finite endpoint differences. Check exact sums, both source orders, all three overload forms, supplied scratch/result overlaps, identical owners, open/closed descriptions with equal endpoints, unbounded positions, empty and zero-dimensional conventions, mismatch sentinels and directed native output bounds.
src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/distances_defs.hh; src/distances_inlines.hh; tests/boxdistancesspec1.cc; tests/boxdistanceoracle.hh; tests/boxdistancespublic1.cc; tests/Box/intervalcontracts1.cc; tests/boxrationalmetrictemporaries1.cc.
- PPL-LLR-000003 Conservative directed numerical bounds (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000431 Mathematical query capabilities and logical outcomes (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
- PPL-LLR-000133 Failure and resource safety (Specifies)
For the endpoint differences dj of 🔗 4. Box endpoint-distance domain, workspaces and dispatch, euclidean_distance_assign shall compute the requested directed bound on
Each squared contribution shall preserve the requested bound on this nonnegative endpoint distance, including when conversions into a temporary format are inexact. This endpoint-tuple norm shall not be identified with the minimum set distance or general Euclidean Hausdorff distance between the represented boxes. Openness shall not affect it. A rational temporary square root shall retain the enclosure and precision conditions of 🔗 2. Finite rational square root at the selected irrational precision and 🔗 3. Selection and ownership of irrational rational precision; no universal exactness of a rational perfect-square input or universal fixed error width shall be inferred beyond those contracts.
The source interpretation, exceptional dimensional/empty/infinite cases, false-output preservation, numerical directions, workspace choices and lifetime conditions of 🔗 4. Box endpoint-distance domain, workspaces and dispatch shall apply to every overload. With supported arithmetic and representable intermediates, a completed upward result shall be at least the exact distance and a completed downward result at most the exact distance. A numerical or resource failure shall not establish a successful directed-bound result. Both sources shall retain their values and dimensions.
A directed bound on a sum of squares requires bounds on nonnegative contributions; squaring a negative lower approximation does not preserve that ordering.
Public header: <ppl.hh>; PPL free functions:
template <typename To, typename ITV> bool euclidean_distance_assign( Checked_Number<To,Extended_Number_Policy>& result, const Box<ITV>& x, const Box<ITV>& y, Rounding_Dir dir); template <typename Temp, typename To, typename ITV> bool euclidean_distance_assign( Checked_Number<To,Extended_Number_Policy>& result, const Box<ITV>& x, const Box<ITV>& y, Rounding_Dir dir); template <typename Work, typename To, typename ITV> bool euclidean_distance_assign( Checked_Number<To,Extended_Number_Policy>& result, const Box<ITV>& x, const Box<ITV>& y, Rounding_Dir dir, Work& tmp0, Work& tmp1, Work& tmp2);
Compute the exact rational sum of squared endpoint differences independently. Check directed results by exact squaring with the appropriate sign condition; include zero, Pythagorean and irrational norms, rational precision choices, inexact temporary conversions, matching/mismatching unbounded endpoints, all overloads and result/scratch overlaps, dimension mismatch and scalar range/resource prerequisites.
src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/distances_defs.hh; src/distances_inlines.hh; tests/boxdistancesspec1.cc; tests/boxdistanceoracle.hh; tests/boxdistancespublic1.cc; tests/Box/intervalcontracts1.cc; tests/boxrationalmetrictemporaries1.cc.
- PPL-LLR-000003 Conservative directed numerical bounds (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000431 Mathematical query capabilities and logical outcomes (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
- PPL-LLR-000133 Failure and resource safety (Specifies)
For the endpoint differences dj of 🔗 4. Box endpoint-distance domain, workspaces and dispatch, l_infinity_distance_assign shall compute the requested directed bound on
with value zero for an empty finite endpoint tuple. Openness shall not affect this endpoint comparison. With exact rational temporary arithmetic and an exactly representable output, the finite maximum shall be returned exactly.
The source interpretation, exceptional dimensional/empty/infinite cases, false-output preservation, numerical directions, workspace choices and lifetime conditions of 🔗 4. Box endpoint-distance domain, workspaces and dispatch shall apply to every overload. With supported arithmetic and representable intermediates, a completed upward result shall be at least the exact distance and a completed downward result at most the exact distance. A numerical or resource failure shall not establish a successful directed-bound result. Both sources shall retain their values and dimensions.
The largest endpoint displacement is a separate norm from the sum and sum-of-squares comparisons and needs its own infinity and zero conventions.
Public header: <ppl.hh>; PPL free functions:
template <typename To, typename ITV> bool l_infinity_distance_assign( Checked_Number<To,Extended_Number_Policy>& result, const Box<ITV>& x, const Box<ITV>& y, Rounding_Dir dir); template <typename Temp, typename To, typename ITV> bool l_infinity_distance_assign( Checked_Number<To,Extended_Number_Policy>& result, const Box<ITV>& x, const Box<ITV>& y, Rounding_Dir dir); template <typename Work, typename To, typename ITV> bool l_infinity_distance_assign( Checked_Number<To,Extended_Number_Policy>& result, const Box<ITV>& x, const Box<ITV>& y, Rounding_Dir dir, Work& tmp0, Work& tmp1, Work& tmp2);
Independently compute the maximum endpoint difference. Check exact rational and directed native results, ties, zero-contribution coordinates, every coordinate as unique maximum, source symmetry, all overloads and admitted scratch/result overlaps, equal endpoints with different openness, unbounded positions and dimension/empty conventions.
src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/distances_defs.hh; src/distances_inlines.hh; tests/boxdistancesspec1.cc; tests/boxdistanceoracle.hh; tests/boxdistancespublic1.cc; tests/Box/intervalcontracts1.cc; tests/boxrationalmetrictemporaries1.cc.
- PPL-LLR-000133 Failure and resource safety (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000431 Mathematical query capabilities and logical outcomes (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
For equally dimensioned nonempty ordinary-real boxes, each finite lower or upper endpoint shall occupy its corresponding position in a tuple of 2n endpoints. A position finite in both boxes shall contribute dj = |ej(X) − ej(Y)|. A matching unbounded lower position or matching unbounded upper position shall contribute zero; a position unbounded in exactly one source shall make each supported distance positive infinity. Endpoint openness shall be ignored, so boxes differing only in endpoint inclusion may have distance zero.
Two empty boxes of equal ambient dimension shall have distance zero; exactly one empty box shall have positive-infinite distance. These conventions shall apply also in dimension zero, distinguishing zero-dimensional empty from universe. Unequal ambient dimensions shall return false before modifying the result or caller-supplied scratch objects. Equal dimensions shall return true on successful numerical completion, with the assigned distance specified by 🔗 1. Rectilinear distance between Box endpoint tuples, 🔗 2. Euclidean distance between Box endpoint tuples or 🔗 3. Maximum-coordinate distance between Box endpoint tuples. A Boolean success shall not imply exactness of a rounded value.
The default overload shall allocate three Checked_Number<To,Extended_Number_Policy> workspaces. The overload with an explicit scalar temporary type Temp shall instead allocate three Checked_Number<Temp,Extended_Number_Policy> workspaces. The supplied workspace overload shall use the actual Work type of its three references, which may be an admitted raw or checked numerical type. Each scalar conversion, subtraction, accumulation, square, square root and final assignment shall satisfy its backend's representability, numerical failure, resource, shared-temporary, nontrapping and caller-owned FPU conditions. Native floating conversions or computations shall retain their configured availability and hardware prerequisites. Rational square-root precision shall remain stable throughout a dependent call.
Calls evaluating a finite endpoint difference shall use ROUND_UP or ROUND_DOWN, optionally with ROUND_STRICT_RELATION. They shall not require endpoint conversions to be exact solely to establish a directed bound. Paths assigning only the exact zero or positive-infinite exceptional value shall admit any otherwise valid direction request for that scalar assignment. Sources shall satisfy 🔗 1. Cartesian box values, coordinate identity and valid use; no NaN or included-infinity element shall be introduced into their ordinary-real carrier. An output profile shall support positive infinity whenever that outcome is reachable. Otherwise valid calls shall require no additional library initialization beyond the selected numerical/thread prerequisites.
The three supplied scratch objects shall be pairwise distinct and have storage disjoint from both source boxes. Their entry numerical values need not be initialized when the call overwrites them before reading. The result shall have live assignable storage disjoint from the source boxes; it may coincide with any one scratch object or its compatible raw storage. Result and scratch aliases shall use source values on entry. The same box may be supplied for both sources. Source factor views shall retain their read-only contract 🔗 7. Empty-aware borrowed coordinate interval access. Callers shall synchronize access, including cached emptiness updates, and preserve object/borrowed-storage lifetimes. Failures other than ordinary dimension mismatch shall retain the selected scalar policy's permitted partial output/scratch state, with no aggregate rollback guarantee.
The generic l_m_distance_assign helper shall apply these rules when instantiated with the library's rectilinear, Euclidean or maximum-coordinate specialization for that same workspace type. The sum, sum-of-squares/square-root and maximum accumulation shall use the shared numerical specializations of 🔗 17. Rectilinear distance between bound-entry arrays, 🔗 18. Euclidean distance between bound-entry arrays and 🔗 19. Maximum-coordinate distance between bound-entry arrays, respectively. The source tuple here shall consist of Box endpoints, with the Box admission and overlap conditions stated above.
Source tuples, aliases and numeric setup define when a directed endpoint-distance result is meaningful; endpoint norms do not distinguish all topological differences between boxes.
Public header: <ppl.hh>; PPL free functions:
template <typename Specialization, typename Work, typename To, typename ITV> bool l_m_distance_assign( Checked_Number<To,Extended_Number_Policy>& result, const Box<ITV>& x, const Box<ITV>& y, Rounding_Dir dir, Work& tmp0, Work& tmp1, Work& tmp2);
Check the three named specialization dispatches against independent endpoint norms, including shared and mismatching infinite positions, classified/lazy emptiness, every zero-dimensional pair and unequal dimensions. Instantiate default, explicit scalar and raw/checked supplied workspaces; exercise result aliases to each scratch object and identical input owners. Preserve result and all scratch sentinels on dimension mismatch. Compare directed bounds under inexact conversions without imposing exact-source-conversion admission; check pure valid calls without additional Init and native availability guards.
src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/distances_defs.hh; src/distances_inlines.hh; tests/boxdistancesspec1.cc; tests/boxdistanceoracle.hh; tests/boxdistancespublic1.cc; tests/Box/intervalcontracts1.cc; tests/boxrationalmetrictemporaries1.cc.