24 #ifndef PPL_OR_Matrix_inlines_hh
25 #define PPL_OR_Matrix_inlines_hh 1
31 #include "assertions.hh"
40 return ((k + 1)*(k + 1))/2;
49 #if PPL_OR_MATRIX_EXTRA_DEBUG
58 #endif // PPL_OR_MATRIX_EXTRA_DEBUG
80 #if PPL_OR_MATRIX_EXTRA_DEBUG
103 #if PPL_OR_MATRIX_EXTRA_DEBUG
109 template <
typename T>
110 template <
typename U>
115 template <
typename T>
116 template <
typename U>
119 #if PPL_OR_MATRIX_EXTRA_DEBUG
120 PPL_ASSERT(k < size_);
125 template <
typename T>
126 template <
typename U>
134 #if PPL_OR_MATRIX_EXTRA_DEBUG
140 template <
typename T>
141 template <
typename U>
153 template <
typename T>
154 template <
typename U>
155 template <
typename V>
164 template <
typename T>
165 template <
typename U>
166 template <
typename V>
175 template <
typename T>
176 template <
typename U>
182 template <
typename T>
183 template <
typename U>
189 template <
typename T>
190 template <
typename U>
198 #if PPL_OR_MATRIX_EXTRA_DEBUG
204 value.first += increment;
208 template <
typename T>
209 template <
typename U>
217 template <
typename T>
218 template <
typename U>
225 #if PPL_OR_MATRIX_EXTRA_DEBUG
230 value.first -= decrement;
234 template <
typename T>
235 template <
typename U>
243 template <
typename T>
244 template <
typename U>
250 if (e_dt % 2 == 0 && m % 2 != 0) {
257 value.first += increment;
258 #if PPL_OR_MATRIX_EXTRA_DEBUG
260 value_size_dt += (m - m % 2);
266 template <
typename T>
267 template <
typename U>
268 template <
typename Un
signed>
275 if (e % 2 == 0 && n % 2 != 0) {
280 value.first += increment;
281 #if PPL_OR_MATRIX_EXTRA_DEBUG
287 template <
typename T>
288 template <
typename U>
294 template <
typename T>
295 template <
typename U>
301 template <
typename T>
302 template <
typename U>
310 template <
typename T>
311 template <
typename U>
312 template <
typename Un
signed>
322 template <
typename T>
323 template <
typename U>
331 template <
typename T>
332 template <
typename U>
339 template <
typename T>
340 template <
typename U>
347 template <
typename T>
348 template <
typename U>
354 template <
typename T>
355 template <
typename U>
362 template <
typename T>
363 template <
typename U>
369 template <
typename T>
370 template <
typename U>
377 template <
typename T>
378 template <
typename U>
384 template <
typename T>
385 template <
typename U>
391 template <
typename T>
397 template <
typename T>
403 template <
typename T>
409 template <
typename T>
415 template <
typename T>
421 template <
typename T>
427 template <
typename T>
433 template <
typename T>
439 template <
typename T>
448 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
449 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
466 template <
typename T>
472 return (k - 1) - (k - 1) % 2;
475 template <
typename T>
481 template <
typename T>
484 :
vec(2*num_dimensions*(num_dimensions + 1)),
489 template <
typename T>
494 template <
typename T>
504 template <
typename T>
514 template <
typename T>
520 template <
typename T>
523 return 2*space_dimension();
526 template <
typename T>
532 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
534 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
535 template <
typename T>
541 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
543 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
544 template <
typename T>
550 template <
typename T>
554 space_dim(y.space_dim),
559 template <
typename T>
560 template <
typename U>
564 space_dim(y.space_dim),
571 template <
typename T>
580 template <
typename T>
583 PPL_ASSERT(new_dim >= space_dim);
584 if (new_dim > space_dim) {
586 if (new_size <= vec_capacity) {
588 vec.expand_within_capacity(new_size);
596 mend = element_end(); i != mend; ++i, ++j) {
604 template <
typename T>
607 PPL_ASSERT(new_dim <= space_dim);
609 vec.shrink(new_size);
613 template <
typename T>
616 if (new_dim > space_dim) {
618 if (new_size <= vec_capacity) {
620 vec.expand_within_capacity(new_size);
629 else if (new_dim < space_dim) {
634 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
636 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
637 template <
typename Specialization,
typename Temp,
typename To,
typename T>
652 mat_end = x.
element_end(); i != mat_end; ++i, ++j) {
678 sub_assign_r(tmp1, *tmp1p, *tmp2p, dir);
679 PPL_ASSERT(
sgn(tmp1) >= 0);
689 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
691 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
692 template <
typename Temp,
typename To,
typename T>
702 l_m_distance_assign<Rectilinear_Distance_Specialization<Temp> >(r, x, y,
709 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
711 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
712 template <
typename Temp,
typename To,
typename T>
722 l_m_distance_assign<Euclidean_Distance_Specialization<Temp> >(r, x, y,
729 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
731 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
732 template <
typename Temp,
typename To,
typename T>
742 l_m_distance_assign<L_Infinity_Distance_Specialization<Temp> >(r, x, y,
750 template <
typename T>
758 #endif // !defined(PPL_OR_Matrix_inlines_hh)
void swap(OR_Matrix< T > &x, OR_Matrix< T > &y)
Swaps x with y.
friend bool operator==(const OR_Matrix< T > &x, const OR_Matrix< T > &y)
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Enable_If< Is_Singleton< T >::value, Interval< B, Info > >::type operator*(const Interval< B, Info > &x, const T &y)
Enable_If< Is_Native_Or_Checked< To >::value &&Is_Special< From >::value, Result >::type assign_r(To &to, const From &, Rounding_Dir dir)
bool operator!=(const OR_Matrix< T > &x, const OR_Matrix< T > &y)
Returns true if and only if x and y are different.
bool l_m_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const OR_Matrix< T > &x, const OR_Matrix< T > &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
dimension_type num_rows() const
Returns the number of rows in the matrix.
bool operator>(const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
row_iterator row_end()
Returns the past-the-end const_iterator.
void swap(CO_Tree &x, CO_Tree &y)
void shrink(dimension_type new_dim)
Makes the matrix shrink by removing the last space dimensions.
bool rectilinear_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const OR_Matrix< T > &x, const OR_Matrix< T > &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
bool euclidean_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const OR_Matrix< T > &x, const OR_Matrix< T > &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)
size_t dimension_type
An unsigned integral type for representing space dimensions.
OR_Matrix()
Private and not implemented: default construction is not allowed.
A class to define STL const and non-const iterators from pointer types.
any_row_iterator< T > row_iterator
A (non const) row iterator.
Rounding_Dir
Rounding directions for arithmetic computations.
bool operator>=(const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
Enable_If< Has_Assign_Or_Swap< T >::value, void >::type assign_or_swap(T &to, T &from)
dimension_type isqrt(dimension_type x)
Returns the integer square root of x.
A template class to derive both OR_Matrix::iterator and OR_Matrix::const_iterator.
bool operator==(const OR_Matrix< T > &x, const OR_Matrix< T > &y)
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
dimension_type space_dimension() const
Returns the space-dimension of the matrix.
void resize_no_copy(dimension_type new_dim)
Resizes the matrix without worrying about the old contents.
bool OK() const
Checks if all the invariants are satisfied.
void m_swap(OR_Matrix &y)
Swaps *this with y.
An object that behaves like a matrix's row with respect to the subscript operators.
dimension_type i
Internal index: i = (e+1)*(e+1)/2.
U * first
Holds a reference to the beginning of this row.
Rounding_Dir inverse(Rounding_Dir dir)
dimension_type compute_capacity(dimension_type requested_size, dimension_type maximum_size)
Speculative allocation function.
The base class for the single rows of matrices.
A wrapper for numeric types implementing a given policy.
element_iterator element_begin()
Returns an iterator pointing to the first element, if *this is not empty; otherwise, returns the past-the-end const_iterator.
#define PPL_OR_MATRIX_EXTRA_DEBUG
static dimension_type row_first_element_index(dimension_type k)
Returns the index into vec of the first element of the row of index k.
void finalize()
Finalizes the library.
dimension_type e
External index.
any_row_iterator< const T > const_row_iterator
A const row iterator.
bool operator<(const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
static dimension_type row_size(dimension_type k)
Returns the size of the row of index k.
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_plus_infinity(const T &x)
void grow(dimension_type new_dim)
Makes the matrix grow by adding more space dimensions.
OR_Matrix & operator=(const OR_Matrix &y)
Assignment operator.
Pseudo_Row< U > value
Represents the beginning of a row.
DB_Row< T > vec
Contains the rows of the matrix.
dimension_type space_dim
Contains the dimension of the space of the matrix.
Plus_Infinity PLUS_INFINITY
The entire library is confined to this namespace.
Enable_If< Is_Singleton< T >::value, Interval< B, Info > >::type operator+(const Interval< B, Info > &x, const T &y)
row_reference_type operator[](dimension_type k)
Returns a reference to the k-th row of the matrix.
static dimension_type max_num_rows()
Returns the maximum number of rows of a OR_Matrix.
dimension_type vec_capacity
Contains the capacity of vec.
bool operator<=(const Ptr_Iterator< P > &x, const Ptr_Iterator< Q > &y)
I_Result combine(Result l, Result u)
int sgn(Boundary_Type type, const T &x, const Info &info)
A matrix representing octagonal constraints.
static dimension_type max_size()
Returns the size() of the largest possible DB_Row.
Enable_If< Is_Singleton< T >::value, Interval< B, Info > >::type operator-(const Interval< B, Info > &x, const T &y)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void clear()
Clears the matrix deallocating all its rows.
A class that provides a type member called type equivalent to T if and only if b is true...
row_iterator row_begin()
Returns an iterator pointing to the first row, if *this is not empty; otherwise, returns the past-the...
Result maybe_assign(const To *&top, To &tmp, const From &from, Rounding_Dir dir)
Assigns to top a pointer to a location that holds the conversion, according to dir, of from to type To. When necessary, and only when necessary, the variable tmp is used to hold the result of conversion.
element_iterator element_end()
Returns the past-the-end const_iterator.
bool l_infinity_distance_assign(Checked_Number< To, Extended_Number_Policy > &r, const OR_Matrix< T > &x, const OR_Matrix< T > &y, const Rounding_Dir dir, Temp &tmp0, Temp &tmp1, Temp &tmp2)