Parma Polyhedra Library requirements
C++ finite scalar selection and numerical utility predicates

C++ finite scalar selection and numerical utility predicates

UID:
VERSION:
CLASSIFICATION:
PREFIX:
Type
Level
MID
UID
REFS
Title
Statement
Rationale
Comment
BIBLIOGRAPHY
STATUS
COMPONENT
APPLICABILITY
VERIFICATION_METHODS
VERIFICATION_CRITERIA
SOURCE
LANGUAGE
VISIBILITY
INTERFACE
SW_SPEC
1
PPL-SPEC-000913
PPL-SPEC-000913
Finite same-type minimum and maximum assignment

For two live same-type finite ordered numerical values x and y, min_assign(x, y) shall assign the lesser mathematical value and max_assign(x, y) the greater. The admitted types shall be the standard native integer types, native floating types, mpz_class, canonical mpq_class and supported Checked_Number<T, Policy> forms. A strictly selected source shall be copied with independent owned storage. If the two entry values are equal, the destination's entry representation shall remain unchanged, including a native floating zero's sign.

Both functions shall return void. The source may be the destination; every comparison shall use entry values, and a distinct source shall remain unchanged. Checked calls shall require no rounding defaults, implicit conversion capability or result handler, and shall make no result-policy callback. Same-type checked assignment shall retain 🔗 1. Finite checked scalar storage and copying. Mathematical ordering shall retain 🔗 1. Exact scalar sign and ordering and 🔗 2. Mixed finite floating and exact scalar ordering.

Native floating values shall exclude infinities and NaNs. Raw native comparison/assignment shall remain available independently of configured PPL rounded floating kernels; checked floating forms shall require the corresponding configured scalar support. Rational operands shall be finite and canonical. Live objects, synchronized overlapping mutation and sufficient copy-allocation resources shall be required. No library initialization, coefficient-constant stage, FPU direction or policy default shall be required. Hardware direction shall remain unchanged.

Mathematical selection does not require numerical rounding or result-policy dispatch. Retaining the receiver on a tie preserves representation details such as signed zero.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

Check less/equal/greater operands, self-aliases, either source order, native endpoints and large GMP values with independent literal comparisons. Require void return, preserved distinct source, independent selected copies and unchanged tie representation including both zero signs. Use checked policies without handlers/defaults, all standard hardware modes and a raw floating no- rounded-kernel configuration.

src/math_utilities_defs.hh; src/math_utilities_inlines.hh; tests/scalarutilitiesspec1.cc.

CPP
Public

Public header: <ppl.hh>; function templates in Parma_Polyhedra_Library:

template <typename N>
void min_assign(N& x, const N& y);

template <typename N>
void max_assign(N& x, const N& y);
SW_SPEC
2
PPL-SPEC-000914
PPL-SPEC-000914
Finite parity and additive-inverse predicates

For finite admitted scalar values, is_even(x) shall return true exactly when the mathematical value of x belongs to 2ℤ. A nonintegral rational or native floating value shall therefore return false. is_additive_inverse(x, y) shall return true exactly when x + y = 0 as a mathematical equality, without evaluating an overflowing native sum or requiring a representable stored negation. Both signs of native floating zero shall denote mathematical zero for these predicates.

The admitted same-type forms shall be raw standard native integers, mpz_class, finite canonical mpq_class, configured supported native floating formats and their supported Checked_Number<T, Policy> forms. Policy-reserved special payloads shall not be finite operands. Every finite endpoint shall be admitted, including a bounded minimum whose mathematical negative is outside the storage range. Checked predicates shall require no rounding default, result handler or implicit conversion capability and shall invoke no policy handler. Each result shall have type bool.

Sources may be the same object and shall remain unchanged. Rational scratch storage and synchronization shall follow 🔗 6. Exact rational operations with powers of two; other live-object, finite/canonical and resource prerequisites shall follow the corresponding scalar family. Floating parity shall satisfy the native nonnegative dyadic residue backend/hardware prerequisites in 🔗 4. Rounded nonnegative native residue modulo a power of two. Additive-inverse comparison shall use exact negation and ordering meanings. No coefficient-constant initialization shall be required. Neither predicate shall change hardware direction.

Parity and inverse relations are predicates on represented mathematical values; unrepresentable auxiliary arithmetic must not turn a valid finite query into overflow or a false equality.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

Use independent unbounded-integer/rational parity and zero-sum oracles, signed and unsigned endpoints, all eight-bit values, equal/distinct objects, fractional native/rational inputs, large GMP values and signed zero. Check exact Boolean results, source representation preservation and no handler/default dependency. Cover overflow-checking and unchecked policies under admitted hardware/resource conditions.

src/math_utilities_defs.hh; src/math_utilities_inlines.hh; tests/scalarutilitiesspec1.cc.

CPP
Public

Public header: <ppl.hh>; function templates in Parma_Polyhedra_Library for admitted T:

template <Native_Or_Checked_Number T>
bool
is_even(const T& x);

template <Native_Or_Checked_Number T>
bool
is_additive_inverse(const T& x, const T& y);
SW_SPEC
3
PPL-SPEC-000915
PPL-SPEC-000915
Native low-bit mask construction

For an admitted native integral type T with specialized binary std::numeric_limits<T>, let d be its number of value bits, std::numeric_limits<T>::digits. For an unsigned int exponent 0 ≤ n < d, low_bits_mask<T>(n) shall return a T whose mathematical value is 2n − 1. In particular, zero shall produce zero, and exactly the lowest n value bits shall be set.

The admitted types shall include all eleven standard native integer types. Where INT128_AVAILABLE holds, the same template instantiations shall admit the compiler's signed and unsigned native 128-bit types. That capability shall not imply a general PPL public 128-bit scalar arithmetic instantiation. No signed representation bit outside the nonnegative representable range shall be set. The result type shall be exactly T.

The call shall require no source object, policy, initialization stage, allocation, FPU setup or mutable numerical state. Hardware direction shall remain unchanged. Requests outside n < d shall not be admitted.

An explicit value-bit bound keeps mask construction within both the native shift domain and the nonnegative range of signed types.

APPROVED
NUMERICS
IF_CPP
Test, Analysis, Inspection

For every admitted exponent in each standard signed/unsigned type, compare set bits and value against an independent unbounded integer built by repeated doubling and subtraction. Check zero, the largest admitted exponent, actual char signedness, exact return types and optional signed/unsigned128 capability without assuming its presence. Require unchanged hardware direction.

src/math_utilities_defs.hh; src/math_utilities_inlines.hh; tests/scalarutilitiesspec1.cc.

CPP
Public

Public header: <ppl.hh>; function template in Parma_Polyhedra_Library:

template <typename T>
T low_bits_mask(unsigned n);