C++ affine linear expressions
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000438 Thread entry and shared-facility use (Specifies)
- PPL-LLR-000133 Failure and resource safety (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
A live Linear_Expression of space dimension d, with homogeneous coefficients ai and inhomogeneous term b, shall denote the function E(x) = b + ∑d − 1i = 0aixi on rational valuations. The constant term shall not occupy a coordinate. Trailing zero coefficients shall remain part of the declared ambient dimension.
Use shall satisfy 🔗 3. Thread initialization, default state and finalization. The caller shall synchronize access to an object while another operation modifies it. The valid representations shall be DENSE and SPARSE; default_representation shall be SPARSE. zero() shall return a borrowed, constant expression of dimension zero and value zero. The returned object shall remain alive until its owning initialized thread is finalized.
The computed arithmetic guarantees of 🔗 7. Affine addition, subtraction and negation, 🔗 8. Integral scalar multiplication and coefficient-wise division, 🔗 9. Explicit scaled accumulation, combination and elimination and 🔗 10. Coefficient normalization and sign normalization shall require every evaluated coefficient arithmetic step and result to be representable in the selected coefficient profile. Checked arithmetic may report overflow; unchecked completion shall not prove that this precondition held. Allocation failures may propagate. Failed construction shall release resources owned by the incomplete expression. Distinct, unchanged operands shall remain valid after a reported failure. Other modified objects shall be destructible; no universal rollback is promised.
An expression has an affine value independently of its storage or any constraint later formed from it. Shared numerical prerequisites delimit arithmetic guarantees without weakening that value meaning.
Public header: <ppl.hh>; names belong to Parma_Polyhedra_Library.
class Linear_Expression; enum Representation { DENSE, SPARSE }; static constexpr Representation Linear_Expression::default_representation = SPARSE; static const Linear_Expression& Linear_Expression::zero();
Evaluate explicit coefficient vectors independently over rational valuations, including dimension zero and trailing zeros. Check the shared zero during a balanced initialized lifetime and verify both supported representations. Inspect construction cleanup and failure paths without inferring unpromised rollback.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc; tests/linearexpressionfailure1.cc.
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000133 Failure and resource safety (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
Expression_Adapter_Source<T> shall have the truth value of std::is_convertible_v<const T&, const Expression_Adapter_Base&>. The four adapter-copy constructors shall use this predicate as their type constraint, including implicit base-reference conversions and excluding inaccessible or ambiguous base conversions. Their optional trailing void* parameter shall retain its default null value and shall be ignored.
Construction with only an optional representation shall produce dimension zero and value zero. Construction from a coefficient shall produce dimension zero and that constant value. Construction from Variable v shall produce dimension v.space_dimension(), coefficient one at v.id(), and zero elsewhere, including the constant term.
A variable whose dimension exceeds max_space_dimension() shall cause std::length_error. A requested representation shall be used. The ordinary copy constructor shall copy all coefficients and the declared dimension and retain the source representation. The overload accepting a representation shall use that representation. The overloads accepting space_dim shall copy the retained coefficients, discard coefficients of removed trailing coordinates when shrinking, and insert zero coefficients when extending. Their caller shall supply space_dim <= max_space_dimension(). All copies shall own independent values.
The four corresponding copy forms shall also accept a supported, live expression adapter, including the borrowed expression views exposed by constraints and congruences. They shall copy the adapter's visible coefficients, constant and declared dimension. Copying a view shall not introduce a descriptor's hidden representation columns. Omitting the representation shall retain the adapter's representation; an explicit representation shall select that representation. Dimensioned copies shall apply the same truncation and zero-extension rules as ordinary copies.
Constructor dimensions are observable and must not be inferred from the last nonzero term. Explicit dimensioned copying is a semantic truncation when removed coefficients are nonzero. Named constraints expose source admission while the implementation argument alias preserves the established constructor linkage.
template <typename T> concept Expression_Adapter_Source = std::is_convertible_v<const T&, const Expression_Adapter_Base&>; explicit Linear_Expression(Representation r = default_representation); explicit Linear_Expression(Coefficient_traits::const_reference n, Representation r = default_representation); Linear_Expression(Variable v, Representation r = default_representation); Linear_Expression(const Linear_Expression& e); Linear_Expression(const Linear_Expression& e, Representation r); Linear_Expression(const Linear_Expression& e, dimension_type space_dim); Linear_Expression(const Linear_Expression& e, dimension_type space_dim, Representation r);
For a supported expression adapter v, representation r and valid space dimension d, these effective constructor calls shall be admitted:
Linear_Expression a(v); Linear_Expression b(v, r); Linear_Expression c(v, d); Linear_Expression e(v, d, r);
Check both representations, constants of each sign, variables including a nonleading coordinate, zero-sized and trailing-zero copies, shrink/extend operations, independent later mutations and variable-limit rejection. Evaluate copies over rational points against a separately transformed coefficient vector. Check all four adapter-copy forms with constraint and congruence expression views, including hidden strictness, shrinking, extending and later independent mutations.
src/Expression_Adapter_defs.hh; tests/commonhelpersspec1.cc; src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc; tests/linearexpressionfailure1.cc; tests/linearexpressionbranches1.cc.
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000133 Failure and resource safety (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
Copy assignment shall replace the target coefficients, dimension and representation with those of the source at entry, return a reference to the target, and preserve a distinct source. Self-assignment shall preserve the value, dimension and representation. Construction or assignment from an rvalue shall admit the copy forms and retain the source value; no distinct move operation is required. A separately owned copy shall remain usable after mutation or destruction of the original.
m_swap and the PPL swap overload shall exchange complete values, dimensions and representations; swapping an object with itself shall preserve it. Destruction shall release the object's owned representation. Assignment shall leave the target unchanged if creating its replacement copy fails.
Owning value semantics separate expression lifetime from borrowed coefficient references. Swapping the owned representation must also exchange its representation choice.
Linear_Expression& Linear_Expression::operator=(const Linear_Expression& e); Linear_Expression::~Linear_Expression(); void Linear_Expression::m_swap(Linear_Expression& y); void swap(Linear_Expression& x, Linear_Expression& y);
Check return identity, self-assignment, rvalue copy behavior, cross-representation assignment and both swap forms. Destroy originals while retaining copies. Inject failure while copying a replacement and check unchanged target and source.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc; tests/linearexpressionfailure1.cc.
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000303 Preservation by representation-only changes (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000133 Failure and resource safety (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
representation() shall report the expression's current storage choice. For r equal to DENSE or SPARSE, successful set_representation(r) shall select r while preserving every coefficient, the constant term and declared space dimension. Repeating the current choice shall preserve the expression. Explicit-representation copy construction shall make the same coefficient-preservation guarantee for a distinct result. If creating a converted representation fails, set_representation shall leave the original unchanged.
Dense and sparse storage encode the same affine function; changing storage is not coefficient normalization.
Representation Linear_Expression::representation() const; void Linear_Expression::set_representation(Representation r); Linear_Expression(const Linear_Expression& e, Representation r);
Convert both directions and repeat the existing representation, including zero, constants, sparse gaps and unused trailing coordinates. Compare coefficient vectors and independent rational evaluations. Inject conversion allocation failures and check unchanged state.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc; tests/linearexpressionfailure1.cc.
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
max_space_dimension() shall return the common maximum supported expression dimension. space_dimension() shall return the declared ambient dimension, including unused trailing coordinates. For n <= max_space_dimension(), successful set_space_dimension(n) shall retain the constant term and coefficients with indices below the lesser of the old and new dimensions. Extension shall give all new coordinates zero coefficients. Shrinking shall discard removed coefficients. Resizing to the current dimension shall preserve all coefficients. These operations shall retain the representation.
Expression resizing erases coefficient slots rather than performing existential projection of a pointset.
static dimension_type Linear_Expression::max_space_dimension(); dimension_type Linear_Expression::space_dimension() const; void Linear_Expression::set_space_dimension(dimension_type n);
Check zero-dimensional extension, unchanged size, nonzero trailing-coordinate truncation, all-coordinate removal and subsequent extension. Compare coefficients and evaluations with an independent vector resize, for dense and sparse storage.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc.
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
Coefficient accessors shall require an lvalue receiver, with the corresponding const && overloads deleted in every coefficient profile. References shall not outlive their owning expression.
coefficient(v) shall return the stored homogeneous coefficient when v.id() is within the declared dimension, and zero otherwise. inhomogeneous_term() shall return the constant term. Returned references, where the configured trait returns references, shall be borrowed until the expression is modified or destroyed.
For a variable within the declared dimension, set_coefficient(v,n) shall replace only that coefficient. set_inhomogeneous_term(n) shall replace only the constant term. Both shall preserve dimension and representation. Scalar inputs may be borrowed from the expression being modified; their entry values shall be used.
is_zero() shall hold exactly when every homogeneous coefficient and the constant term are zero. all_homogeneous_terms_are_zero() shall disregard the constant term. For a Variables_Set whose indices are within the expression dimension, all_zeroes(vars) shall hold exactly when every selected homogeneous coefficient is zero. An empty selection shall satisfy that predicate. is_equal_to(other) shall hold exactly when the declared space dimensions, constant terms and all homogeneous coefficients are equal, independently of representation. It shall not test equality of zero sets; expressions differing by a nonunit scale shall generally compare unequal.
A missing homogeneous coefficient is zero, while overwriting a term must not silently extend the ambient dimension. Constant and homogeneous zero tests answer different questions.
Coefficient_traits::const_reference Linear_Expression::coefficient(Variable v) const &; Coefficient_traits::const_reference Linear_Expression::inhomogeneous_term() const &; void Linear_Expression::set_coefficient(Variable v, Coefficient_traits::const_reference n); void Linear_Expression::set_inhomogeneous_term( Coefficient_traits::const_reference n); bool Linear_Expression::is_zero() const; bool Linear_Expression::all_homogeneous_terms_are_zero() const; bool Linear_Expression::all_zeroes(const Variables_Set& vars) const; bool Linear_Expression::is_equal_to(const Linear_Expression& other) const;
Check sparse absent terms and out-of-dimension reads, replacement by zero and nonzero values, untouched coefficients and dimensions, constant-only and total zero, empty and mixed selected zero sets. Copy borrowed values before mutation.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc; tests/linearexpressionbranches1.cc.
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
For operands denoting E and F, expression addition and subtraction shall produce E + F and E − F, using zero coefficients for missing trailing coordinates and the maximum input dimension. Mixed variable forms shall treat a variable as its coordinate function. Mixed coefficient forms shall treat a coefficient as a dimension-zero constant. Unary plus shall return an independent copy; unary minus and neg_assign shall negate every coefficient, including the constant, without changing dimension.
Compound addition and subtraction shall update the target from entry values, return a reference to it, retain its representation, and permit the target as the expression source. Distinct sources shall remain unchanged. Zero cancellation shall retain the computed maximum dimension. An operation adding or subtracting a variable beyond the supported expression dimension shall throw std::length_error before modifying the target. The numerical prerequisites of 🔗 1. Affine value, numerical prerequisites and shared zero shall apply.
Affine equality is stronger than equality of the zero sets of expressions. Independent evaluation detects unintended scaling or sign changes.
For Linear_Expression operands e and f, Variable operands v and w, and Coefficient operand n, these forms shall be available in a C++ function using PPL names:
Linear_Expression sum(e + f), difference(e - f); Linear_Expression vv_sum(v + w), vv_difference(v - w); Linear_Expression ev_sum(e + v), ve_sum(v + e); Linear_Expression ev_difference(e - v), ve_difference(v - e); Linear_Expression en_sum(e + n), ne_sum(n + e); Linear_Expression en_difference(e - n), ne_difference(n - e); Linear_Expression positive(+e), negative(-e); Linear_Expression& expression_sum = (e += f); Linear_Expression& expression_difference = (e -= f); Linear_Expression& variable_sum = (e += v); Linear_Expression& variable_difference = (e -= v); Linear_Expression& constant_sum = (e += n); Linear_Expression& constant_difference = (e -= n); neg_assign(e);
Compare all overloads against independent affine sums and differences over rational valuations. Include unequal dimensions in both orders, dense/sparse combinations, self-addition/subtraction, constant changes, zero cancellation, return identity, source preservation and oversized variable rejection.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc.
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
Multiplication by a coefficient c shall multiply every stored coefficient and the constant term by c, producing the affine function cE. Multiplication by zero shall retain the expression's dimension. operator*= shall update and return the target and retain its representation. Both scalar operand orders shall be available for a new result.
For nonzero divisor c, operator/= shall replace each homogeneous coefficient and the constant term separately by its integral quotient rounded towards zero. It shall retain dimension and representation and return the target. This shall denote affine division E ⁄ c when all coefficients are divisible by c; otherwise it shall denote the expression formed from those truncated coefficients. No rational-coefficient result is implied. The scalar passed to a mutating operation shall not reference a coefficient owned by that target. The numerical prerequisites of 🔗 1. Affine value, numerical prerequisites and shared zero shall apply.
Integer-coefficient division can change an affine function by truncating its coefficients. Exact scalar division is a special case that must not be confused with the general operation.
Linear_Expression operator*(const Linear_Expression& e, Coefficient_traits::const_reference n); Linear_Expression operator*(Coefficient_traits::const_reference n, const Linear_Expression& e); Linear_Expression& operator*=(Linear_Expression& e, Coefficient_traits::const_reference n); Linear_Expression& operator/=(Linear_Expression& e, Coefficient_traits::const_reference n);
Check both signs and zero multipliers, exact and inexact division with positive and negative divisors, constant terms and trailing dimensions. Compare quotient coefficients with an independent GMP truncating-division oracle and evaluate the resulting affine functions at rational points.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc; tests/linearexpressionbranches1.cc.
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
Variable accumulation shall add or subtract cxv to the target, extending its dimension when needed. Expression accumulation shall add or subtract cF and use the maximum input dimension. linear_combine(y,c1,c2) shall assign c1E + c2F and require both multipliers nonzero. linear_combine_lax shall have that same meaning while admitting zero multipliers. Both shall retain the maximum input dimension, even when its coefficient cancels, and retain the target representation.
For equal-dimension distinct expressions with nonzero coefficients a and b at v, linear_combine(y,v) shall assign (b ⁄ g)E − (a ⁄ g)F, where g = gcd(|a|, |b|). The chosen coordinate coefficient shall therefore be zero. The variable shall lie in that dimension.
Expression sources shall be distinct from the target. Scalar multipliers shall not reference a coefficient owned by the target. Distinct sources shall be preserved. Numerical prerequisites in 🔗 1. Affine value, numerical prerequisites and shared zero shall apply.
Eliminating a coefficient requires a specified scaled combination, not merely an expression that happens to have zero in that slot.
Linear_Expression& add_mul_assign(Linear_Expression& e, Coefficient_traits::const_reference n, Variable v); Linear_Expression& sub_mul_assign(Linear_Expression& e, Coefficient_traits::const_reference n, Variable v); void add_mul_assign(Linear_Expression& e, Coefficient_traits::const_reference n, const Linear_Expression& y); void sub_mul_assign(Linear_Expression& e, Coefficient_traits::const_reference n, const Linear_Expression& y); void Linear_Expression::linear_combine(const Linear_Expression& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2); void Linear_Expression::linear_combine_lax(const Linear_Expression& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2); void Linear_Expression::linear_combine(const Linear_Expression& y, Variable v);
Use dense/sparse cross products and unequal dimensions, positive and negative factors, zero factors for lax combinations, variable extension and accumulation return identity. Independently compute all coefficient vectors and rational evaluations. For elimination include shared factors and all coefficient-sign pairs.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc; tests/linearexpressionbranches1.cc.
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
normalize() shall divide all homogeneous coefficients and the constant term by their common nonnegative greatest common divisor when it is nonzero. The all-zero expression shall remain zero. sign_normalize() shall negate all coefficients and the constant term exactly when the first nonzero homogeneous coefficient, in increasing variable order, is negative. An expression having no nonzero homogeneous coefficient shall be unchanged by sign normalization, including a negative constant.
Both operations shall retain dimension and representation and be idempotent. Normalization can scale the affine value; sign normalization can negate it. Neither operation shall promise affine-value preservation merely because its result has the same zero set. The numerical prerequisites of 🔗 1. Affine value, numerical prerequisites and shared zero shall apply.
Primitive coefficients and a chosen leading sign are useful descriptor conventions, but they change affine values unless the chosen scale is one.
void Linear_Expression::normalize(); void Linear_Expression::sign_normalize();
Check all-zero, positive and negative constants, coprime coefficients, a shared divisor, leading zero gaps, each sign of the first nonzero coefficient and unused trailing coordinates. Compare exact expected coefficients and rational evaluation scaling, and repeat each operation to establish idempotence.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc; tests/linearexpressionbranches1.cc.
The owning expression's iterator-position accessors shall require an lvalue receiver, with the corresponding const && overloads deleted. Iterators shall not extend the owning expression's lifetime.
begin() and end() shall delimit homogeneous nonzero coefficients in increasing coordinate order; the constant term and zero coefficients shall not occur. end() shall be the past-the-end position. lower_bound(v) shall return the first such coefficient whose variable identifier is at least v.id(), or end() when none exists; callers shall supply v.id() <= space_dimension(), including the past-the-end coordinate.
Dereferencing a valid non-end iterator shall return its coefficient; variable() shall return its coordinate and index() shall return that coordinate's identifier plus one. Prefix increment/decrement shall navigate the sequence and return the changed iterator. Decrement shall require a preceding element; decrementing a nonempty sequence's end shall yield its last element. Iterator copies and assignment shall own independent positions, while borrowing the same expression. Iterators shall be compared only within the same unchanged expression. Mutating or destroying the expression shall invalidate them. A default iterator shall admit destruction or replacement; copying, dereferencing or navigating it is not required.
visit_nonzero_coefficients(visitor) const & shall invoke the callback exactly once with a concrete borrowed, bidirectional range of the same ordered nonzero homogeneous terms. The callback shall accept dense and sparse ranges and return the same type for both. Representation shall be selected once; constructing, traversing and copying range iterators shall not allocate. Range begin and end access shall take constant time; locating their positions may be performed when constructing the view. The callback result and exceptions shall propagate unchanged. Owner rvalues shall be rejected. A range or iterator returned by the callback shall borrow the expression and shall obey the same invalidation rules. Adapter visitors shall honor the visible dimension and omit hidden descriptor coordinates.
Logical nonzero iteration hides storage differences. The public iterator index also includes the constant-slot offset, unlike a Variable identifier.
template <typename Visitor> decltype(auto) Linear_Expression::visit_nonzero_coefficients(Visitor&&) const &; class Linear_Expression::const_iterator; Linear_Expression::const_iterator Linear_Expression::begin() const &; Linear_Expression::const_iterator Linear_Expression::end() const &; Linear_Expression::const_iterator Linear_Expression::lower_bound(Variable v) const &; explicit Linear_Expression::const_iterator::const_iterator(); Linear_Expression::const_iterator::const_iterator(const const_iterator& i); Linear_Expression::const_iterator::~const_iterator(); Linear_Expression::const_iterator& Linear_Expression::const_iterator::operator=(const const_iterator& i); Linear_Expression::const_iterator& Linear_Expression::const_iterator::operator++(); Linear_Expression::const_iterator& Linear_Expression::const_iterator::operator--(); Linear_Expression::const_iterator::reference Linear_Expression::const_iterator::operator*() const; Variable Linear_Expression::const_iterator::variable() const; dimension_type Linear_Expression::const_iterator::index() const; bool Linear_Expression::const_iterator::operator==(const const_iterator& i) const; bool Linear_Expression::const_iterator::operator!=(const const_iterator& i) const; void Linear_Expression::const_iterator::m_swap(const_iterator& i);
Compare forward and reverse sequences with independently listed indices and coefficients for empty, constant, gapped and trailing-zero expressions in both representations. Check lower bounds at and between supported positions, copied/assigned iterator independence, return identity, member swap and replacement of a default iterator. Check the concrete visitor against independent coefficient lists, prefix visibility, exception propagation, rvalue rejection and an armed allocation failure.
src/Linear_Expression_Coefficients.hh; src/Linear_Expression_templates.hh; src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc.
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
For variables within the expression dimension, swap_space_dimensions shall exchange exactly their coefficients and retain the constant term. permute_space_dimensions(cycle) shall require distinct, in-dimension variables. It shall move each listed coordinate coefficient to the following listed coordinate, and the last to the first. Empty and singleton cycles shall preserve the expression.
remove_space_dimensions(vars) shall require in-dimension indices, discard their coefficients, and compact retained coordinates in their original order. Removing none shall preserve the expression; removing all shall retain only the constant term. shift_space_dimensions(v,n) shall require v.id() <= space_dimension() and a resulting dimension not exceeding max_space_dimension(). It shall insert n zero coefficients immediately before v, shift subsequent coefficients by n, and increase the dimension accordingly. Insertion at the old dimension shall append zeros. A zero shift shall preserve the expression.
These transformations shall preserve the inhomogeneous term and representation. They shall implement the stated coefficient rearrangement, with no claim that discarding a nonzero coefficient preserves the original affine value.
Descriptor coefficient transformation is distinct from existential pointset projection. Explicit placement makes the resulting affine meaning unambiguous.
void Linear_Expression::swap_space_dimensions(Variable v1, Variable v2); void Linear_Expression::permute_space_dimensions( const std::vector<Variable>& cycle); void Linear_Expression::remove_space_dimensions(const Variables_Set& vars); void Linear_Expression::shift_space_dimensions(Variable v, dimension_type n);
Use independently permuted, filtered and shifted coefficient vectors. Check self-swaps, empty/singleton and longer cycles, zero and nonzero moved coefficients, removal of no/all/interior coordinates, zero shifts, insertion at front/interior/end and preserved constant terms in both representations.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc.
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000311 Public C++ access to supported facilities (Specifies)
- PPL-LLR-000133 Failure and resource safety (Specifies)
- PPL-LLR-000446 Reloadable textual representations (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
ascii_dump(s) shall write a reloadable representation consisting of the word size, the number of coefficient slots d + 1, and then the constant term followed by all homogeneous coefficients in increasing variable order. Whitespace shall separate tokens. ascii_dump() shall write the same representation to std::cerr. Export shall preserve the expression.
Given a compatible complete representation with representable coefficient values and a positive slot count not exceeding the supported storage limit, ascii_load(s) shall return true and replace the expression with the encoded coefficients and dimension, retaining its destination representation. The slot count shall include the constant slot, so zero shall be rejected with false before resizing, preserving the destination expression. A missing or incorrect size token, missing count, malformed coefficient or truncated coefficient sequence shall yield false. Trailing input after the indicated coefficient count shall remain available to the caller. The contract shall not promise a stable cross-version wire format.
Other reported load failures may change the destination. It shall remain destructible and may be replaced by a subsequent complete valid load; no rollback is promised. Allocation and configured numerical failures may propagate through their documented exception channels.
A reloadable expression carries its ambient dimension and constant term, while storage choice belongs to the destination. An empty coefficient sequence cannot encode an affine expression.
void Linear_Expression::ascii_dump(std::ostream& s) const; void Linear_Expression::ascii_dump() const; bool Linear_Expression::ascii_load(std::istream& s);
Round-trip constants, gaps, trailing zeros and modified expressions through all dense/sparse producer and consumer pairs. Compare literal coefficient vectors and rational evaluations. Check exact token order, trailing-input preservation, malformed headers/counts/coefficients and truncation. Verify that zero-slot rejection preserves coefficients, dimension and representation. After other failures exercise destruction and complete replacement, without assuming unchanged state.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc; tests/linearexpressionbranches1.cc.
The output operator shall display the nonzero homogeneous terms in increasing variable order, followed by a nonzero constant term. It shall use the active Variable formatter specified by 🔗 7. Active Variable formatter and initialized thread state. For coefficient magnitudes other than one it shall put * between the coefficient and variable; a magnitude of one shall be omitted. Later positive and negative terms shall be separated by " + " and " - " respectively, with a minus sign also preceding a negative first term. A zero expression shall display 0. No newline shall be added. The supplied stream shall be returned. print() shall use the same display on std::cerr.
Output shall preserve coefficients, dimension and representation. Its formatting arithmetic shall satisfy the selected coefficient profile's preconditions, including representability of any negated coefficient. The human-readable display shall not substitute for the reloadable representation in 🔗 13. Reloadable ASCII export and replacement loading.
Readable output uses coordinate naming supplied by the client, whereas machine reload requires explicit coefficient slots and dimensions.
namespace IO_Operators { std::ostream& operator<<(std::ostream& s, const Linear_Expression& e); } void Linear_Expression::print() const;
Check literal output for zero, constants, both leading signs, unit magnitudes, gaps and mixed signs. Install an indexed variable formatter and verify dispatch and stream identity. Redirect std::cerr to check print without a newline and verify the expression remains unchanged.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc.
OK() shall report whether the expression's owned representation satisfies its checked storage invariants. Expressions produced by successful operations under their stated preconditions shall satisfy those invariants. external_memory_in_bytes() shall report the memory accounted for by its owned representation, including that representation object. total_memory_in_bytes() shall equal sizeof(Linear_Expression) plus external_memory_in_bytes(). These queries shall preserve the expression's coefficients, dimension and representation. Memory counts shall not promise allocator overhead, a fixed dense-to-sparse ordering or exact process memory consumption.
An owning interface object accounts separately for itself and its dynamically selected representation. Storage diagnostics do not measure process resident memory.
bool Linear_Expression::OK() const; memory_size_type Linear_Expression::external_memory_in_bytes() const; memory_size_type Linear_Expression::total_memory_in_bytes() const;
Check valid empty, constant, dense and sparse expressions, resized copies and representation conversions. Verify the total/external identity and preservation of every observable value without imposing architecture-specific byte totals.
src/Linear_Expression_defs.hh; src/Linear_Expression_inlines.hh; src/Linear_Expression.cc; src/Linear_Expression_Impl_inlines.hh; src/Linear_Expression_Impl_templates.hh; tests/linearexpressionspec1.cc.