Internal dense and sparse coefficient-row storage
Dense_Row and Sparse_Row shall represent a finite coefficient vector (a0, …, an − 1) with independently declared logical size n. Size zero shall be valid. A row shall impose no mandatory constant or hidden coordinate. The affine expression interpretation shall instead belong to 🔗 1. Affine value, numerical prerequisites and shared zero. Dense storage shall retain every logical position; sparse storage shall permit implicit and explicitly stored zeroes with the same coefficient value, while exposing the stored-position distinction.
Operations shall require live valid rows, admitted sizes and indices, active library initialization where coefficient constants or scratch storage are used, and synchronization under 🔗 3. Thread initialization, default state and finalization. Successful arithmetic shall require all evaluated coefficient steps/results to be representable in the selected profile. Allocation/numerical exceptions may propagate. Failed construction shall release resources owned by the incomplete row; unchanged sources shall survive failure. A modified target shall remain destructible, without a universal rollback guarantee.
Raw coefficient storage must preserve vector indices without importing geometric descriptor conventions.
Internal source headers: Dense_Row_defs.hh and Sparse_Row_defs.hh. Names belong to Parma_Polyhedra_Library.
class Dense_Row; class Sparse_Row;
Check literal vectors, zero-sized rows, stored/implicit zeroes and profile-dependent arithmetic prerequisites. Inspect ownership, initialization and mutation contexts.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/denserow1.cc.
Default construction shall create a zero-sized row. Sized construction shall create exactly the requested number of zero coefficients. Construction with explicit capacity shall require size <= capacity <= max_size() and reserve that capacity without making additional logical coefficients. The size-only form shall initially reserve its requested size. max_size() shall return numeric_limits<size_t>::max() / sizeof(Coefficient); resource availability shall remain a separate condition from this reported limit.
Reserved capacity is storage for later growth, rather than additional vector entries.
Dense_Row(); Dense_Row(dimension_type size); Dense_Row(dimension_type size, dimension_type capacity); static dimension_type Dense_Row::max_size(); dimension_type Dense_Row::size() const;
Check default, zero-sized reserved and nonzero rows; infer specified capacity through memory accounting and growth within capacity without infeasible allocations.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/denserow1.cc.
Sparse construction shall retain the requested logical size, initially with no stored entries. The compatibility capacity argument shall be ignored. size() shall report logical size and num_stored_elements() shall count stored positions, including explicitly stored zeroes. max_size() shall return CO_Tree::max_size(), the supported number of stored elements; logical extent and admissible dimension keys shall remain distinct from that storage count. The type shall opt out of the C++20 sized-range customization so that standard range distances count iterated entries, including explicitly stored zeroes, rather than the logical extent.
Sparse vectors can carry a large zero extent while storing no coefficients.
explicit Sparse_Row(dimension_type size = 0); Sparse_Row(dimension_type size, dimension_type capacity); dimension_type Sparse_Row::size() const; dimension_type Sparse_Row::num_stored_elements() const; static dimension_type Sparse_Row::max_size();
Check logical-size independence from stored counts, standard range distances with explicit zeroes and empty support, ignored capacity, empty iteration and safe large logical zero extents.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc.
- PPL-LLR-000144 Ordered coefficient-map semantics (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000303 Preservation by representation-only changes (Specifies)
- PPL-LLR-000133 Failure and resource safety (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
Ordinary row copies shall preserve size and every coefficient, own independent storage and survive source mutation/destruction. Dense copies shall retain source capacity unless supplied another admitted capacity. A copy with specified size/capacity shall retain the common source prefix, discard removed positions and zero-extend added positions. Explicit dense capacity shall be at least result size; sparse compatibility capacity shall be ignored. Cross-storage construction shall preserve that same complete coefficient vector. Dense-to-sparse construction may omit zero entries; sparse-to-dense construction shall materialize implicit zeroes. Const-rvalue forms selecting copy constructors shall retain the source value.
Copying and representation changes must preserve values independently of the source owner.
Dense_Row(const Dense_Row& y); Dense_Row(const Dense_Row& y, dimension_type capacity); Dense_Row(const Dense_Row& y, dimension_type size, dimension_type capacity); explicit Dense_Row(const Sparse_Row& y); Dense_Row(const Sparse_Row& y, dimension_type size, dimension_type capacity); Sparse_Row(const Sparse_Row& y); // Explicitly defaulted. Sparse_Row(const Sparse_Row& y, dimension_type capacity); Sparse_Row(const Sparse_Row& y, dimension_type size, dimension_type capacity); explicit Sparse_Row(const Dense_Row& y); Sparse_Row(const Dense_Row& y, dimension_type size, dimension_type capacity);
Check all copy forms with shorter/equal/longer sizes, explicit stored zeroes, source destruction, source mutation and both storage directions; inject recoverable backing-allocation failure.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/denserow1.cc.
- PPL-LLR-000144 Ordered coefficient-map semantics (Specifies)
- PPL-LLR-000301 Meaning of successful exact and approximate results (Specifies)
- PPL-LLR-000303 Preservation by representation-only changes (Specifies)
- PPL-LLR-000133 Failure and resource safety (Specifies)
- PPL-LLR-000442 Explicit numerical operation contracts (Specifies)
Successful copy assignment shall replace the complete vector, return the target, preserve its distinct source and admit self-assignment. Cross-storage assignment shall preserve values while retaining the target's row type. Copies shall remain independently mutable. Whole-row swaps shall exchange full vectors, including their sizes and owned storage; mixed dense/sparse swaps shall convert storage while exchanging vector values. Self-swaps shall retain value. iter_swap for two vector positions shall swap the owning dense rows. Destruction shall release owned coefficient and backing storage.
Replacement allocation failure shall preserve the source; target-state guarantees shall follow 🔗 1. Internal coefficient-row values and valid use.
For trivially destructible coefficient types, Dense_Row transfer construction from a non-const rvalue shall acquire the complete owned storage without allocating or throwing and leave its source empty and reusable. References to dense elements shall follow their storage; distinct-owner transfers shall invalidate element iterators.
For other coefficient types, dense construction from rvalues shall retain independent, source-preserving copy behavior. Dense assignment from rvalues shall retain independent, source-preserving copy behavior for every coefficient type; self-assignment shall preserve the value.
Sparse_Row construction and assignment from rvalues shall retain independent, source-preserving copy behavior, including logical extent and explicit stored zeroes. Its copy declarations shall prevent new backing-tree transfer operations from implicitly changing the row-level interface.
Replacing or exchanging vector owners must not make coefficient values depend on another row lifetime.
Dense_Row& Dense_Row::operator=(const Dense_Row& y); Dense_Row& Dense_Row::operator=(const Sparse_Row& y); Sparse_Row& Sparse_Row::operator=(const Sparse_Row& y); // Explicitly defaulted. Sparse_Row& Sparse_Row::operator=(const Dense_Row& y); void Dense_Row::m_swap(Dense_Row& y); void Sparse_Row::m_swap(Sparse_Row& y); void swap(Dense_Row& x, Dense_Row& y); void swap(Sparse_Row& x, Sparse_Row& y); void swap(Dense_Row& x, Sparse_Row& y); void swap(Sparse_Row& x, Dense_Row& y); void iter_swap(std::vector<Dense_Row>::iterator x, std::vector<Dense_Row>::iterator y); Dense_Row::~Dense_Row(); Sparse_Row::~Sparse_Row(); // Implicitly declared. // This transfer overload requires trivially destructible coefficients. Dense_Row(Dense_Row&& y) noexcept;
Check dense nonthrowing construction traits, zero C++/GMP allocation during construction transfers, exact values and storage ownership, empty and reserved-empty inputs, const-rvalue copies and source reuse. Check independently mutable source-preserving rvalue assignments and self-assignment. Check that sparse rvalue construction and assignment preserve their sources and create independently mutable copies. Verify the same source-preserving dense construction behavior for nontrivial coefficient types. Check chained/self/rvalue assignments, empty and different-sized sources, swaps in every storage pairing, vector iter_swap and destruction independence. Exercise allocation-failure paths.
tests/rowmovespec1.cc; src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/denserow1.cc.
Resizing shall retain the common prefix, discard removed coefficients and initialize newly introduced coefficients to zero. Removed values shall not reappear after regrowth. resize(n) shall retain current capacity when sufficient. Otherwise, with prior capacity c and maximum capacity M, it shall grow capacity to max(n, min(M, c + floor(c/2))), evaluating the sum without overflow. Thus construction from zero capacity and large one-shot expansions shall allocate the requested extent; repeated small growth shall reserve fewer than half as many spare slots as the requested extent at each reallocation. Retaining capacity after shrinking or an explicit reservation shall remain permitted. resize(n,c) shall require admitted n <= c and set capacity exactly c; zero capacity shall release backing storage. shrink(n) shall require n <= size() and retain capacity. expand_within_capacity(n) shall require size() <= n <= capacity and add zeroes without replacing backing storage. Position changes/reallocation shall invalidate affected borrowed references and iterators.
Logical growth, logical removal and backing-capacity changes have different effects on storage ownership. Geometric growth amortizes repeated small expansions while bounding spare coefficient storage; explicit-capacity requests retain exact control.
void Dense_Row::resize(dimension_type n); void Dense_Row::resize(dimension_type n, dimension_type capacity); void Dense_Row::shrink(dimension_type n); void Dense_Row::expand_within_capacity(dimension_type n);
Check all size/capacity relations, empty reserved rows, prefix preservation, removal/regrowth zeroes and reference stability when no storage replacement or relocation occurs. Check that repeated unit growth uses logarithmically many backing replacements, capacity stays within the stated spare-storage bound, and one-shot/explicit-capacity requests remain exact. Analyze saturation of capacity arithmetic at the maximum admitted extent; exercise allocation failure before replacement.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/denserow1.cc.
Sparse resizing shall retain the common coefficient prefix, erase stored entries outside a shortened extent and zero-extend an enlarged extent without materializing the new zeroes. shrink(n) shall require n <= size(); expand_within_capacity(n) shall require size() <= n and need no reserved-capacity argument. Size zero shall erase all stored entries. Changing logical extent shall not change values at retained coordinates.
Sparse extent changes must not retain unreachable coefficients or turn zero extent into a stored-entry count.
void Sparse_Row::resize(dimension_type n); void Sparse_Row::shrink(dimension_type n); void Sparse_Row::expand_within_capacity(dimension_type n);
Check shrink to interior, exact stored-key boundaries and zero; grow again and confirm removed coefficients do not reappear, including explicitly stored zeroes.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc.
Indexed access and get(i) shall require i < size() and return the coefficient at that position. Const access shall not materialize missing sparse entries. Mutable dense access shall borrow the owned coefficient; mutable sparse access shall retain an existing stored coefficient or insert a stored zero and return its mutable reference. Mutating that reference shall update only its indexed value. A reference to an absent sparse value shall borrow the library zero constant and require its lifetime.
Borrowed references shall not outlive their owners or the documented storage invalidation of an operation. Sparse insertion/removal or reorganization may invalidate previously borrowed entries and iterators. Values must be copied before an operation that can invalidate their reference, except where entry argument capture is explicitly specified.
Member overloads that return references, iterators or nonowning views into the owner shall require an lvalue owner. Matching rvalue calls that would produce such borrows shall be rejected during overload resolution. Temporary iterator and row-view values shall remain usable while their backing owner remains alive. Const coefficient queries whose declared result type is an independent value shall also remain admitted for temporary owners.
Logical zero access can be allocation-free even though mutable access needs an addressable coefficient owner.
Coefficient& Dense_Row::operator[](dimension_type i) &; Coefficient_traits::const_reference Dense_Row::operator[](dimension_type i) const &; Coefficient_traits::const_reference Dense_Row::get(dimension_type i) const &; Coefficient& Sparse_Row::operator[](dimension_type i) &; Coefficient_traits::const_reference Sparse_Row::operator[](dimension_type i) const &; Coefficient_traits::const_reference Sparse_Row::get(dimension_type i) const &;
Compare const reads and mutable updates with independent vectors; check stored counts and owner-address identity, plus copied values across later mutation. Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc.
Dense iterators shall enumerate every index in increasing order, including zero-valued positions; end() shall have index size(). Valid dereference shall borrow the corresponding coefficient; mutable dereference shall permit updating it. Increment/decrement shall require valid next/previous positions. Prefix shall return the advanced iterator by reference; postfix shall return the entry-position copy. Const conversion and copied/assigned iterator positions shall preserve owner and index. Equality shall compare owner and index. Defaults shall admit copying, assignment, destruction and OK() before assignment to a live position. Iterators shall not outlive their row.
Member overloads that return references, iterators or nonowning views into the owner shall require an lvalue owner. Matching rvalue calls that would produce such borrows shall be rejected during overload resolution. Temporary iterator and row-view values shall remain usable while their backing owner remains alive. Direct const-iterator construction shall also reject a temporary row owner.
Dense traversal represents positions rather than nonzero support.
class Dense_Row::iterator; class Dense_Row::const_iterator; Dense_Row::iterator Dense_Row::begin() &; Dense_Row::iterator Dense_Row::end() &; Dense_Row::const_iterator Dense_Row::begin() const &; Dense_Row::const_iterator Dense_Row::end() const &; Dense_Row::iterator::iterator(); Dense_Row::iterator::iterator(Dense_Row& row, dimension_type i); dimension_type Dense_Row::iterator::index() const; Coefficient_traits::const_reference Dense_Row::iterator::operator*() const; Dense_Row::iterator& Dense_Row::iterator::operator++(); Dense_Row::iterator Dense_Row::iterator::operator++(int); Dense_Row::iterator& Dense_Row::iterator::operator--(); Dense_Row::iterator Dense_Row::iterator::operator--(int); bool Dense_Row::iterator::operator==(const iterator& y) const; bool Dense_Row::iterator::operator!=(const iterator& y) const; bool Dense_Row::iterator::OK() const; Dense_Row::const_iterator::const_iterator(); Dense_Row::const_iterator::const_iterator(const Dense_Row& row, dimension_type i); dimension_type Dense_Row::const_iterator::index() const; Coefficient_traits::const_reference Dense_Row::const_iterator::operator*() const; Dense_Row::const_iterator& Dense_Row::const_iterator::operator++(); Dense_Row::const_iterator Dense_Row::const_iterator::operator++(int); Dense_Row::const_iterator& Dense_Row::const_iterator::operator--(); Dense_Row::const_iterator Dense_Row::const_iterator::operator--(int); bool Dense_Row::const_iterator::operator==(const const_iterator& y) const; bool Dense_Row::const_iterator::operator!=(const const_iterator& y) const; bool Dense_Row::const_iterator::OK() const; Coefficient& Dense_Row::iterator::operator*(); Dense_Row::iterator::operator const_iterator() const;
Check zero-sized and mixed rows, forward/reverse standard traversal, index/value associations, mutable/const copies and conversions, defaults and prefix/postfix return identity. Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/rowstoragebranches1.cc.
stored_entries() shall return a borrowed view bound to a live lvalue row. The view shall visit exactly the stored positions, including explicit zeroes, and expose their count through constant-time size() and empty() independently of logical width. Mutable and read-only views shall be sized bidirectional ranges; mutable cursors shall permit value updates without changing stored keys or count. A const view object shall retain its bound row's mutability. Temporary row owners shall be rejected.
The view shall store the row binding without allocating or owning storage. Copies and queries shall follow the current row object through valid mutations and swaps; iterators already obtained retain the row's existing invalidation conditions. Iterators shall not depend on the view object's lifetime. The view need not have an unbound default state.
Sparse iterators shall enumerate exactly stored entries in increasing index order, including explicitly stored zeroes. Implicit zeroes shall not appear. Dereference and index() shall report the stored coefficient and its key; mutable dereference shall permit replacement without changing the key. Bidirectional traversal and const conversion shall follow CO_Tree iterator contracts. A referenced end()/cend() sentinel shall belong to its live row and remain updated by mutations, while copied iterator values shall obey operation-specific invalidation. Swapping rows shall not transfer ownership of a cached reference to an end sentinel. Cached end references shall be available only from lvalue rows; mutable and const temporary owners shall be rejected. No sentinel shall be dereferenced.
Member overloads that return references, iterators or nonowning views into the owner shall require an lvalue owner. Matching rvalue calls that would produce such borrows shall be rejected during overload resolution. Temporary iterator and row-view values shall remain usable while their backing owner remains alive.
Stored support differs from the logical vector and can change while a row-owned end sentinel remains observable.
The Sparse_Row stored-entry factories have the following signatures:
Stored_Entries_View<false> stored_entries() &; Stored_Entries_View<true> stored_entries() const &; Stored_Entries_View<true> stored_entries() const && = delete;
typedef CO_Tree::iterator Sparse_Row::iterator; typedef CO_Tree::const_iterator Sparse_Row::const_iterator; Sparse_Row::iterator Sparse_Row::begin() &; const Sparse_Row::iterator& Sparse_Row::end() &; const Sparse_Row::iterator& Sparse_Row::end() && = delete; Sparse_Row::const_iterator Sparse_Row::begin() const &; const Sparse_Row::const_iterator& Sparse_Row::end() const &; const Sparse_Row::const_iterator& Sparse_Row::end() const && = delete; Sparse_Row::const_iterator Sparse_Row::cbegin() const &; const Sparse_Row::const_iterator& Sparse_Row::cend() const &; const Sparse_Row::const_iterator& Sparse_Row::cend() const && = delete;
Check sized, bidirectional and borrowed range concepts; reject temporary row owners. Exercise stored zeroes, constant-cursor updates, reverse traversal, view copies, logical resizing and swaps; verify counts without conflating logical width or filtering stored zeroes.
Check implicit/explicit zero distinction, increasing keys, copied positions, reverse traversal and cached end references after insertion, reset, clear and row swaps. Reject cached end-reference access from mutable and const temporary rows. Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.
tests/rowmovespec1.cc; src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/sparserow1.cc.
find(i) shall require an in-size index. Dense rows shall return its position even when zero; sparse rows shall return the stored entry if present and end() otherwise. lower_bound(i) shall admit i <= size() and return the first dense/stored sparse position with index at least i, or end() if none. A hint shall be a valid position or end sentinel for the same unchanged row and shall not affect the result. Const and mutable forms shall agree; searches shall not materialize sparse zeroes.
Member overloads that return references, iterators or nonowning views into the owner shall require an lvalue owner. Matching rvalue calls that would produce such borrows shall be rejected during overload resolution. Temporary iterator and row-view values shall remain usable while their backing owner remains alive.
Hints may improve search cost but cannot change the selected index or materialize a coefficient.
Dense_Row::iterator Dense_Row::find(dimension_type i) &; Dense_Row::const_iterator Dense_Row::find(dimension_type i) const &; Dense_Row::iterator Dense_Row::find(iterator hint, dimension_type i) &; Dense_Row::const_iterator Dense_Row::find(const_iterator hint, dimension_type i) const &; Dense_Row::iterator Dense_Row::lower_bound(dimension_type i) &; Dense_Row::const_iterator Dense_Row::lower_bound(dimension_type i) const &; Dense_Row::iterator Dense_Row::lower_bound(iterator hint, dimension_type i) &; Dense_Row::const_iterator Dense_Row::lower_bound(const_iterator hint, dimension_type i) const &; Sparse_Row::iterator Sparse_Row::find(dimension_type i) &; Sparse_Row::const_iterator Sparse_Row::find(dimension_type i) const &; Sparse_Row::iterator Sparse_Row::find(iterator hint, dimension_type i) &; Sparse_Row::const_iterator Sparse_Row::find(const_iterator hint, dimension_type i) const &; Sparse_Row::iterator Sparse_Row::lower_bound(dimension_type i) &; Sparse_Row::const_iterator Sparse_Row::lower_bound(dimension_type i) const &; Sparse_Row::iterator Sparse_Row::lower_bound(iterator hint, dimension_type i) &; Sparse_Row::const_iterator Sparse_Row::lower_bound(const_iterator hint, dimension_type i) const &;
Compare every valid target index and every live hint with an independent stored-key list; include holes, explicit zeroes, empty rows and lower_bound(size()). Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/sparserow1.cc.
Insertion shall require i < size() and return the indexed position. An explicit value shall replace that coefficient using its entry value, including when borrowed from another entry of the same row. No duplicate key shall be created. A value-free insertion shall retain an existing value, or create a stored zero in a missing sparse position. Dense value-free insertion shall return the existing logical slot unchanged. Hints shall have the validity and result-independence specified by 🔗 11. Indexed row search, lower bounds and hint independence. Sparse insertions may reorganize storage and invalidate earlier borrowed positions.
Member overloads that return references, iterators or nonowning views into the owner shall require an lvalue owner. Matching rvalue calls that would produce such borrows shall be rejected during overload resolution. Temporary iterator and row-view values shall remain usable while their backing owner remains alive.
Inserting from a borrowed coefficient must preserve its value through storage growth or replacement.
Dense_Row::iterator Dense_Row::insert(dimension_type i, Coefficient_traits::const_reference x) &; Dense_Row::iterator Dense_Row::insert(iterator hint, dimension_type i, Coefficient_traits::const_reference x) &; Dense_Row::iterator Dense_Row::insert(dimension_type i) &; Dense_Row::iterator Dense_Row::insert(iterator hint, dimension_type i) &; Sparse_Row::iterator Sparse_Row::insert(dimension_type i, Coefficient_traits::const_reference x) &; Sparse_Row::iterator Sparse_Row::insert(iterator hint, dimension_type i, Coefficient_traits::const_reference x) &; Sparse_Row::iterator Sparse_Row::insert(dimension_type i) &; Sparse_Row::iterator Sparse_Row::insert(iterator hint, dimension_type i) &;
Check new/existing keys, zero/nonzero replacement, all hints, self-entry and other-entry arguments, including sparse growth and storage reorganization. Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc.
clear() shall set every logical coefficient to zero while retaining size; sparse clear shall remove every stored entry. Indexed reset shall zero the chosen in-size coefficient, removing its sparse entry if any. Dense range reset shall require first <= last <= size() and change exactly that half-open range. Dense iterator reset shall zero its live slot and return the following logical slot. Sparse iterator reset shall erase its stored slot and return the following stored slot; an iterator range shall erase exactly its stored half-open interval and return the first retained successor. Sparse_Row::reset_after(i) shall require i < size() and remove every stored position at or after i. Empty ranges shall be admitted.
Member overloads that return references, iterators or nonowning views into the owner shall require an lvalue owner. Matching rvalue calls that would produce such borrows shall be rejected during overload resolution. Temporary iterator and row-view values shall remain usable while their backing owner remains alive.
Resetting a coefficient changes value and support, while retaining the row extent.
void Dense_Row::clear(); void Sparse_Row::clear(); void Dense_Row::reset(dimension_type i); void Sparse_Row::reset(dimension_type i); void Dense_Row::reset(dimension_type first, dimension_type last); Dense_Row::iterator Dense_Row::reset(iterator i) &; Sparse_Row::iterator Sparse_Row::reset(iterator i) &; Sparse_Row::iterator Sparse_Row::reset(iterator first, iterator last) &; void Sparse_Row::reset_after(dimension_type i);
Compare every dense reset window and sparse stored-iterator window with independent vector/key models, checking returned successors, prefix/suffix preservation and unchanged logical size. Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc.
add_zeroes_and_shift(n,i) shall require i <= size() and admitted nonoverflowing result size/keys. It shall insert n zero positions before i and shift every old position at or after i upward by n. Zero insertion shall preserve the vector. delete_element_and_shift(i) shall require i < size(), remove just that coefficient and shift all later indices down by one. Dense deletion shall retain capacity. Implicit sparse zeroes shall stay implicit unless already explicitly represented. Dense shifts/deletions and sparse deletions shall invalidate prior iterators. Sparse insertion of zero positions shall preserve stored-entry iterator values and update affected indices, retaining their coefficient association.
For erase_and_reindex(index_map,new_size), index_map shall contain size() entries. Selected coordinates shall be marked not_a_dimension(); the remaining images shall enumerate [0,new_size) in order. The result shall be the stable subsequence of retained coefficients with the specified size. Dense rows shall retain capacity. Sparse rows shall retain surviving explicit stored zeroes without materializing implicit zeroes. The operation shall invalidate ordinary iterators and coefficient references. If a sparse erasure allocation fails, the row shall remain valid at its old size and numbering, with possibly some selected stored entries already erased.
Coordinate renumbering must move the coefficient associated with each surviving position.
void Dense_Row::add_zeroes_and_shift(dimension_type n, dimension_type i); void Sparse_Row::add_zeroes_and_shift(dimension_type n, dimension_type i); void Dense_Row::delete_element_and_shift(dimension_type i); void Sparse_Row::delete_element_and_shift(dimension_type i); void Dense_Row::erase_and_reindex( const std::vector<dimension_type>& index_map, dimension_type new_size); void Sparse_Row::erase_and_reindex( const std::vector<dimension_type>& index_map, dimension_type new_size);
Enumerate front/interior/end insertion and all deletion indices against literal vector insertion/erase, including empty rows, holes, stored zeroes, spare dense capacity and sparse iterator index updates.
Compare all removal subsets of small vectors, including empty/identity/all removed maps, signed coefficient boundaries, explicit sparse zeroes and spare dense capacity. Check retained stored entries and growth after compaction.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/sparserow1.cc.
Indexed swaps shall require two in-size indices and exchange exactly their coefficient values, including implicit sparse zeroes. Iterator swaps shall require two live dereferenceable positions of the same row and exchange their values without exchanging their keys. Self-swaps shall retain value. Sparse fast_swap(i,pos) shall require an in-size index and lower_bound(i) == pos != end(); it shall move that stored entry to i, leaving its previous position implicitly zero. Its iterator shall remain valid and report the new index, and unrelated entries shall be retained.
Exchanging coefficient values differs from relocating a stored sparse key into an empty preceding interval.
void Dense_Row::swap_coefficients(dimension_type i, dimension_type j); void Sparse_Row::swap_coefficients(dimension_type i, dimension_type j); void Dense_Row::swap_coefficients(iterator i, iterator j); void Sparse_Row::swap_coefficients(iterator i, iterator j); void Sparse_Row::fast_swap(dimension_type i, iterator pos);
Check all indexed swaps across holes and stored zeroes, iterator swaps, self-swaps and valid fast relocations with unchanged intervening keys and live iterator association.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/sparserow1.cc.
For a nonzero row, normalize() shall divide every coefficient by the positive greatest common divisor of all coefficient magnitudes. All-zero rows, including empty rows, shall be unchanged. Size and coefficient signs shall be retained. A common sign shall not be reversed. This operation shall change vector value when the common divisor exceeds one; it shall not be a representation-only operation. Numerical prerequisites shall follow 🔗 1. Internal coefficient-row values and valid use.
Removing a positive common factor preserves proportional relations but does not preserve a raw affine vector value.
void Dense_Row::normalize(); void Sparse_Row::normalize();
Use independent integer GCD division with leading/trailing zeroes, mixed signs, common factors, relatively prime entries, negative-only entries, explicit sparse zeroes and size zero.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/denserow1.cc.
For equal-sized rows and pointwise callback functions obeying the following identities, combination shall produce the vector obtained by applying g(x[i],y[i]) to each entry. Callbacks shall modify only their first coefficient argument; they shall not change another row position, row structure or external state on which another callback result depends. They shall admit aliased first/source arguments for self-operand calls. Invocation count/order shall not be promised. For combine_needs_first, g(0,b) shall leave zero unchanged and f(a) shall equal g(a,0). For combine_needs_second, g(a,0) shall leave a unchanged and h(0,b) shall equal g(0,b). For general combine, g(0,0) shall leave zero unchanged, with both f/h identities. Exact final values shall be independent of stored zeroes and storage type. Self-operand calls shall use each position's entry value as both operands. Sparse result zeroes may remain stored or be removed.
Sparse evaluation can omit zero cases only when the callback algebra makes those omissions equivalent.
template <typename F, typename G> void Dense_Row::combine_needs_first(const Dense_Row& y, const F& f, const G& g); template <typename G, typename H> void Dense_Row::combine_needs_second(const Dense_Row& y, const G& g, const H& h); template <typename F, typename G, typename H> void Dense_Row::combine(const Dense_Row& y, const F& f, const G& g, const H& h); template <typename F, typename G> void Sparse_Row::combine_needs_first(const Sparse_Row& y, const F& f, const G& g); template <typename G, typename H> void Sparse_Row::combine_needs_second(const Sparse_Row& y, const G& g, const H& h); template <typename F, typename G, typename H> void Sparse_Row::combine(const Sparse_Row& y, const F& f, const G& g, const H& h);
Compare product, sum and signed difference callbacks with independent entry-value vectors; include disjoint/matching supports, zero cancellation, self operands and explicit stored zeroes.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/sparserow1.cc; tests/rowstoragebranches1.cc.
With nonzero scalar coefficients c1 and c2, whole-row combination shall assign xi :  = c1xi + c2yi from entry values. Dense/dense member or free forms shall require equal logical sizes. Sparse/sparse forms shall require distinct rows of equal size. The dense-destination/sparse-source whole-row free form shall require equal logical sizes. The sparse-destination/dense-source whole-row free form shall require x.size() >= y.size() and treat absent trailing source coordinates as zero. Target size shall be retained and distinct source values preserved. Dense self-operand calls shall use each position's entry value for both operands. Scalars shall remain live and independent of coefficients modified by the operation. Numerical/failure prerequisites shall follow 🔗 1. Internal coefficient-row values and valid use.
A storage-specific optimization must compute the same exact coefficient combination over the declared vector extent.
void Dense_Row::linear_combine(const Dense_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2); void Sparse_Row::linear_combine(const Sparse_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2); void linear_combine(Dense_Row& x, const Dense_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2); void linear_combine(Dense_Row& x, const Sparse_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2); void linear_combine(Sparse_Row& x, const Dense_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2); void linear_combine(Sparse_Row& x, const Sparse_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2);
Compare every storage pairing and scalar optimization case with independent integer vectors, including cancellation, sparse tails, empty rows, mixed unequal extents and dense self operands. Check equal-extent dense/sparse whole-row combinations, including empty rows and scalar fast paths. Independently check public mixed-storage linear-expression combinations across shorter/equal/longer dimensions; public maximum-dimension and zero-extension behavior shall remain unchanged.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/linearexpressionpublic1.cc; tests/rowstoragebranches1.cc.
Range combination shall require start <= end within both logical sizes, nonzero scalars and the operand/scalar independence conditions of 🔗 18. Whole-row linear combinations across row storage. It shall assign xi :  = c1xi + c2yi from entry values exactly for start ≤ i < end, leaving every other target coordinate unchanged. Empty windows shall preserve the complete vector. Storage pairing and optimized scalar cases shall not change that result.
Range updates are reusable storage operations whose prefix and suffix are independently meaningful.
void Dense_Row::linear_combine(const Dense_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2, dimension_type start, dimension_type end); void Sparse_Row::linear_combine(const Sparse_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2, dimension_type start, dimension_type end); void linear_combine(Dense_Row& x, const Dense_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2, dimension_type start, dimension_type end); void linear_combine(Dense_Row& x, const Sparse_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2, dimension_type start, dimension_type end); void linear_combine(Sparse_Row& x, const Dense_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2, dimension_type start, dimension_type end); void linear_combine(Sparse_Row& x, const Sparse_Row& y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2, dimension_type start, dimension_type end);
Compare all windows of small literal vectors for all four storage pairings and scalar cases; include empty windows, cancellation, boundary stored entries and distinct outer tails.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc.
Equality shall return true exactly when logical sizes and all corresponding coefficient values agree. Dense/sparse pairing, allocation capacity and explicit versus implicit sparse zeroes shall not affect equality. Inequality shall be its Boolean negation. Equality shall preserve both operands and shall not equate rows merely because one has additional trailing zeroes.
Raw vector equality includes its extent while excluding representation details.
bool operator==(const Dense_Row& x, const Dense_Row& y); // Inequality uses C++20 rewriting of operator==. bool operator==(const Dense_Row& x, const Sparse_Row& y); bool operator!=(const Dense_Row& x, const Sparse_Row& y); bool operator==(const Sparse_Row& x, const Dense_Row& y); bool operator!=(const Sparse_Row& x, const Dense_Row& y); bool operator==(const Sparse_Row& x, const Sparse_Row& y); bool operator!=(const Sparse_Row& x, const Sparse_Row& y);
Check Boolean inequality expressions in both operand orders through C++20 equality rewriting, retaining the stated equality and mismatch behavior. Check all storage pairings, explicit zeroes, changed entries, extra zero extent, differing dense capacities, self comparison and empty rows.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc.
ascii_dump(s) shall emit the logical size followed by all coefficients in index order, using size n a0 ... syntax and a terminating newline. ascii_load(s) shall accept a complete compatible representation with an admitted size and representable coefficients, replace size/values and return true. Size zero shall be admitted. A malformed keyword, missing size or missing/malformed coefficient shall return false; trailing input shall be left for subsequent parsing. No rollback shall be promised after failure; owned resources and surviving target destruction shall follow 🔗 1. Internal coefficient-row values and valid use. The zero-argument dump and print forms shall write this representation to the designated diagnostic stream.
Raw-row reload must restore every logical coefficient, including explicit dense zeroes and extent.
void Dense_Row::ascii_dump(std::ostream& s) const; void Dense_Row::ascii_dump() const; bool Dense_Row::ascii_load(std::istream& s); void Dense_Row::print() const;
Round-trip independent vectors and size zero through replacement targets; check exact format, malformed/truncated tokens, retry after failure and preserved trailing input.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/denserow1.cc.
Sparse ASCII export shall report logical size, stored-element count and ascending indexed coefficients, including explicitly stored zeroes, in size n elements k [ i ]= a ... syntax with a terminating newline. Loading a complete compatible representation shall replace logical extent and stored entries and return true. Size zero with zero stored entries shall be valid. Malformed or missing keywords, counts, indices and coefficients, counts greater than the logical extent, and repeated, out-of-order or out-of-extent indices shall report false rather than successful construction of an invalid row. Trailing input shall remain available. No rollback shall be promised on failure; target ownership shall follow 🔗 1. Internal coefficient-row values and valid use. Diagnostic dump/print forms shall use this reloadable representation.
A sparse loader must preserve both extent and indexed coefficient associations without admitting keys outside the vector.
void Sparse_Row::ascii_dump(std::ostream& s) const; void Sparse_Row::ascii_dump() const; bool Sparse_Row::ascii_load(std::istream& s); void Sparse_Row::print() const;
Check round-trip stored zeroes, holes, count/size zero, exact syntax, malformed and truncated fields, out-of-extent keys, failure retry and trailing input.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/sparserow1.cc; tests/rowstoragebranches1.cc.
OK() shall report satisfaction of row structural invariants without changing values. Dense invariants shall include size <= capacity <= max_size() and backing-storage consistency; OK(n) shall additionally compare logical size with n. Sparse invariants shall require every stored index below logical size; its compatibility OK(capacity) shall ignore that argument.
Memory queries shall return nonnegative accounting estimates without changing values. For both row types, total shall equal sizeof(row) + external. Dense external accounting shall include actual reserved coefficient slots and external storage owned by live coefficients. Sparse external accounting shall follow its coefficient tree. Compatibility capacity arguments shall not change the reported current storage; neither query shall promise exact allocator bookkeeping or available memory.
Current storage accounting and structural validity are observable checks rather than estimates of future allocation success.
bool Dense_Row::OK() const; bool Dense_Row::OK(dimension_type n) const; memory_size_type Dense_Row::external_memory_in_bytes() const; memory_size_type Dense_Row::external_memory_in_bytes(dimension_type capacity) const; memory_size_type Dense_Row::total_memory_in_bytes() const; memory_size_type Dense_Row::total_memory_in_bytes(dimension_type capacity) const; bool Sparse_Row::OK() const; bool Sparse_Row::OK(dimension_type n) const; memory_size_type Sparse_Row::external_memory_in_bytes() const; memory_size_type Sparse_Row::external_memory_in_bytes(dimension_type capacity) const; memory_size_type Sparse_Row::total_memory_in_bytes() const; memory_size_type Sparse_Row::total_memory_in_bytes(dimension_type capacity) const;
Check accounting identities for empty/reserved/populated rows and coefficient limbs, ignored compatibility capacity, matching dense size checks and unchanged values through const queries.
src/Dense_Row_defs.hh; src/Dense_Row_inlines.hh; src/Dense_Row_templates.hh; src/Dense_Row.cc; src/Sparse_Row_defs.hh; src/Sparse_Row_inlines.hh; src/Sparse_Row_templates.hh; src/Sparse_Row.cc; tests/rowstoragespec1.cc; tests/denserow1.cc.