Parma Polyhedra Library requirements
Internal octagonal matrix ownership and row interfaces
1. Pseudo-triangular matrix values and physical coordinates PPL-SPEC-000771

OR_Matrix<T> shall own a pseudo-triangular array with a nonnegative space dimension n, exactly 2n physical rows, and row width w(k) = 2(⌊k ⁄ 2⌋ + 1) for 0 ≤ k < 2n. Its stored entries shall be exactly the pairs (k, j) with 0 ≤ j < w(k); their total count shall be 2n(n + 1). Coordinate identity and value shall be independent of spare capacity. Physical access shall require these coordinates; entries outside this pseudo-triangle shall not be supplied by the raw storage interface.

The selected T shall satisfy 🔗 1. Extended-number row meaning and construction states for the element operations actually used, including its arithmetic, initialization, resource and synchronization prerequisites. Admitted dimensions and cursor displacements shall fit the advertised row bound and all selected size, offset, capacity and signed-displacement calculations. Borrowed objects shall require their coefficients to remain alive and unmoved. Only successful operations on valid objects shall reestablish the full matrix value; reported failures shall retain 🔗 20. Incomplete-owner cleanup and mutation failure states.

PPL-SPEC-000772
2. Sized construction, destruction and the supported row bound PPL-SPEC-000772

Construction with admitted space dimension n shall create the shape of 🔗 1. Pseudo-triangular matrix values and physical coordinates and initialize every stored entry to positive infinity, including every stored diagonal entry. Zero dimension shall create an empty owning matrix with no rows or logical entries. No public default constructor shall be supplied. Destruction shall release the owned storage and each physically live coefficient exactly once. Failed construction shall retain 🔗 20. Incomplete-owner cleanup and mutation failure states.

max_num_rows() shall report an even supported physical row-count bound. For admitted dimensions, twice the dimension shall not exceed that bound, and the corresponding stored count shall fit the supported DB_Row<T> size. The bound shall not guarantee available resources for constructing an object of that size.

PPL-SPEC-000773
3. Independent ordinary and rvalue copy construction PPL-SPEC-000773

Ordinary copy construction shall create the same space dimension and stored entry values in independently owned coefficients. It shall preserve its source. Mutation or destruction of either completed owner shall not change the other owner. Physical spare capacity need not be copied exactly. An rvalue source shall retain this ordinary copying contract; no distinct move constructor shall be required. Empty matrices shall copy as empty matrices. Failure shall preserve the source and release the incomplete target under 🔗 20. Incomplete-owner cleanup and mutation failure states.

PPL-SPEC-000774
4. Pointwise upward representation conversion PPL-SPEC-000774

Cross-element-type construction shall create an independently owned matrix of the source space dimension. Each physical coordinate shall follow the upward conversion of 🔗 7. Pointwise upward conversion of extended-number rows: finite results shall bound the exact source upward, exactly representable values shall remain exact, and supported extended values shall retain their meanings. The source shall remain unchanged. Empty sources shall produce empty targets. Selected source/target profiles shall admit the conversions and all required intermediates. Failure shall retain 🔗 20. Incomplete-owner cleanup and mutation failure states.

5. Value assignment and assignment failure preservation PPL-SPEC-000775

Successful assignment shall replace the target by the source space dimension and independently owned physical entry values, preserve its source, and return the target wrapper. Self-assignment shall preserve its dimension and values; it need not preserve allocation addresses or spare capacity. Rvalue assignment shall retain the ordinary copying contract. A supported recoverable allocation or coefficient-copy failure while preparing the replacement shall preserve the completed target and source values, release the incomplete replacement, and permit retry. Successful replacement shall invalidate borrows to the replaced storage.

PPL-SPEC-000776
6. Whole-owner swap and borrowed coefficient identity PPL-SPEC-000776

Member and free swap shall exchange the entire owning storage, space dimension and capacity metadata. They shall preserve every entry value and coordinate within its transferred owner without copying, allocating or destroying coefficients. Existing coefficient references and copied row views shall keep referring to the same live coefficients now owned by the other matrix. Self-swap shall preserve the owner. Callers shall associate any retained cursor with the transferred shape and storage rather than reuse it with the other allocation.

PPL-SPEC-000777
7. Dimension queries, row-width formula and exact array equality PPL-SPEC-000777

space_dimension() shall return the current characteristic parameter n; num_rows() shall return 2n. row_size(k) shall return 2(⌊k ⁄ 2⌋ + 1) whenever its index and result arithmetic are representable. The formula may also be queried for a count-only endpoint without dereferencing it.

Equality shall hold exactly when both matrices have the same space dimension and equal values at every stored coordinate. Inequality shall be its negation. Different dimensions shall compare unequal regardless of their common-prefix entries. Equality shall not modify either input.

8. Borrowing row-view construction, conversion and lifetime PPL-SPEC-000778

A row_reference_type shall be a value view borrowing one physical row of mutable T coefficients. const_row_reference_type shall borrow const coefficients. Copy construction and ordinary assignment shall copy the binding without copying coefficients or allocating. The declared compatible converting constructor shall permit mutable-to- const view construction and its use for compatible assignment. View destruction shall leave the coefficients unchanged.

A default-constructed view shall be unbound and shall require assignment of a valid view before coefficient access. A bound copied view shall remain independent of the cursor cache from which it was obtained, while the borrowed coefficients remain alive and unmoved. Constness of the view wrapper alone shall preserve its selected coefficient type.

PPL-SPEC-000779
9. Coordinate subscripting through borrowing row values PPL-SPEC-000779

Matrix subscripting at live physical row k shall return a borrowing value view of that row. Subscript j on a bound view shall return the actual coefficient reference at (k, j) and require 0 ≤ j < w(k). Mutable coefficient views shall permit updates through const view wrappers; const coefficient views shall provide read-only references. The operations shall not copy or allocate coefficients, and views shall retain 🔗 8. Borrowing row-view construction, conversion and lifetime.

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.

PPL-SPEC-000780
10. Row-cursor binding, copying and compatible const conversion PPL-SPEC-000780

A storage-backed row cursor constructed from the first coefficient of a live nonempty matrix shall denote row zero. Count-only construction shall record the supplied row count for comparisons and index/width queries without binding matrix storage; such a cursor shall not be navigated or dereferenced. A count-only matrix endpoint shall have the matrix's current physical row count.

Copy construction and assignment shall reproduce the position and a separate cached row view without coefficient copying or allocation. Compatible mutable-to-const construction and assignment shall be supported. All storage-backed cursors shall retain the single-allocation lifetime and valid-position conditions of 🔗 1. Pseudo-triangular matrix values and physical coordinates.

Borrowing iterator constructors shall reject temporary backing owners. Copying temporary iterator values shall remain admitted when their backing storage remains alive.

PPL-SPEC-000781
11. Row-cursor aliases, cached views and position queries PPL-SPEC-000781

Row-cursor aliases shall retain the declared types below. The category shall support the library's member-operation dispatch; these declarations shall not promise the complete standard-library iterator requirements. In particular, std::reverse_iterator shall not be an admitted adapter for this cached-reference cursor.

At a live position, dereference and arrow shall borrow the cached row view inside that cursor. The returned reference/pointer shall require that cursor to remain alive and unchanged. Copying the view by value shall create an independent borrowing value under 🔗 8. Borrowing row-view construction, conversion and lifetime, including a copy made within the full expression of a temporary cursor. Cursor index() shall return its row index; row_size() shall return the width formula for that index. Endpoints shall support these queries without coefficient access.

PPL-SPEC-000782
12. Row-cursor prefix and postfix traversal PPL-SPEC-000782

For storage-backed cursors, increment and decrement shall change the row index by exactly one and bind the corresponding physical row or past-the-end position. Navigation shall stay in the same matrix's closed begin/end position interval. Prefix shall return the updated cursor by reference; postfix shall return an independent copy of the old cursor. Returned old live positions shall remain usable while their coefficients remain live and unmoved. Past-the-end shall not be dereferenced. Both even/odd row-width transitions shall retain exact coordinate associations.

PPL-SPEC-000783
13. Signed and unsigned row offsets and indexed view values PPL-SPEC-000783

For a storage-backed cursor at row index k, admitted offset m shall produce index k + m in the same matrix's closed begin/end interval. Signed addition/subtraction and the declared unsigned addition overloads shall agree on common nonnegative offsets. Compound updates shall return the modified cursor; value-returning operations shall preserve their source. Selected signed displacement calculations, including negation, shall be representable.

Indexed cursor access shall require the offset position to be a live row and return that row's borrowing view by value. This value shall remain independent of the source cursor's cached view and lifetime, subject to the coefficient lifetime conditions.

PPL-SPEC-000784
14. Row-position comparison and signed differences PPL-SPEC-000784

Comparison and difference shall require positions of the same live matrix, using compatible const conversion where required by the declared member signatures. The six comparisons shall have exactly the ordering of the row indices. Cursor difference shall return the mathematical signed difference of the two indices when representable in difference_type. Empty count-only begin/end positions may be compared and subtracted without navigating or dereferencing them. No coefficient value shall affect these results.

PPL-SPEC-000785
15. Mutable and const row-range endpoints PPL-SPEC-000785

For a nonempty matrix, row begin/end shall return storage-backed cursors at indices zero and num_rows(). They shall delimit exactly the live physical rows and permit supported forward/backward member navigation. For an empty matrix, both shall return equal count-only endpoints of index zero; they shall not be navigated or dereferenced. Const overloads shall return read-only coefficient cursors. Shape changes shall require obtaining new endpoints before traversing the new shape; coefficient borrows shall retain their own lifetime rules.

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.

PPL-SPEC-000786
16. Flattened element ranges and physical row-major order PPL-SPEC-000786

Element begin/end shall delimit exactly the live stored coefficients in increasing physical row order and increasing column order within each row. Mutable and const overloads shall retain the corresponding DB_Row<T> pointer-iterator contracts of 🔗 5. Row sizes, supported limits, coefficient ranges and equality and 🔗 1. Pointer-adapter types and borrowed storage. A zero-dimensional matrix shall have an empty valid element range. For every live coordinate, the flat coefficient reference shall be identical to matrix/row-view subscripting at that coordinate. Shape/owner changes shall retain the actual coefficient lifetime and invalidation rules.

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.

PPL-SPEC-000787
17. Value-preserving dimension growth PPL-SPEC-000787

grow(new_dim) shall require an admitted dimension no smaller than the current dimension. On success it shall produce the new shape, preserve every old stored coordinate exactly and initialize every newly introduced coordinate to positive infinity. Growth to the current dimension shall preserve the values and existing coefficient objects. Successful growth may replace storage; retained views shall be usable only while their actual coefficients remain alive and unmoved. Reported failure shall retain 🔗 20. Incomplete-owner cleanup and mutation failure states.

PPL-SPEC-000788
18. Dimension shrinkage and complete clearing PPL-SPEC-000788

shrink(new_dim) shall require an admitted dimension no greater than the current dimension. It shall preserve exactly the physical prefix of rows belonging to the new shape, destroy removed logical coefficients, and set the new dimension. Removed values shall not reappear after later successful growth. Equal-dimension shrinkage shall preserve the existing values and coefficient objects.

clear() shall release the old owned storage and replace the matrix by a valid zero-dimensional owning matrix. It shall be safe on an already empty matrix and permit subsequent construction by growth or assignment. Clearing shall invalidate old coefficient borrows.

PPL-SPEC-000789
19. Discarding resize and valid rebuilt shape PPL-SPEC-000789

resize_no_copy(new_dim) shall accept every admitted dimension. On success it shall establish the corresponding valid shape. Shrinking shall retain the prefix behavior of 🔗 18. Dimension shrinkage and complete clearing. Equal- dimension calls shall preserve the existing coefficient objects and values. Growing shall initialize all newly introduced coordinates to positive infinity; no old-prefix value preservation shall be required by this interface. A client needing that preservation shall use 🔗 17. Value-preserving dimension growth. Failure shall retain 🔗 20. Incomplete-owner cleanup and mutation failure states.

20. Incomplete-owner cleanup and mutation failure states PPL-SPEC-000790

Failed sized/copy/upward construction shall release storage and destroy every completed coefficient of the incomplete matrix, preserving any source owner. Assignment preparation failure shall retain the stronger value-preserving guarantee of 🔗 5. Value assignment and assignment failure preservation.

A reported recoverable failure during growth or discarding resize may leave a partially extended or partially transferred target without a coherent full matrix shape. Its completed coefficients and owned storage shall remain safely destructible and replaceable by a complete successful assignment or clearing operation. No ordinary matrix access or traversal shall be required before such replacement. A failure before mutation, including failure to allocate replacement backing storage, shall preserve the old completed value. Resources owned by a discarded incomplete replacement shall be released.

These guarantees shall require selected element operations to retain their own documented exceptional states and nonthrowing destruction. They shall not require recovery from fatal GMP allocation failure or caller-precondition violations, or classify reported failure as a successful numerical value.