2
0
mirror of https://github.com/boostorg/ublas.git synced 2026-02-26 17:12:10 +00:00

uBLAS CHANGE row_major/column_major functor so they have a consistent element access abstraction and naming

svn path=/trunk/boost/boost/numeric/ublas/; revision=34007
This commit is contained in:
Michael Stevens
2006-05-18 16:44:57 +00:00
parent e1574c973f
commit 5cc19b0a13
4 changed files with 563 additions and 561 deletions

View File

@@ -1370,8 +1370,8 @@ namespace boost { namespace numeric { namespace ublas {
}
};
// This functor computes the address translation
// matrix [i] [j] -> storage [i * size2 + j]
// This functor defines storage layout and it's properties
// matrix (i,j) -> storage [i * size_i + j]
template <class Z, class D>
struct basic_row_major {
typedef Z size_type;
@@ -1380,90 +1380,133 @@ namespace boost { namespace numeric { namespace ublas {
static
BOOST_UBLAS_INLINE
size_type storage_size (size_type size1, size_type size2) {
size_type storage_size (size_type size_i, size_type size_j) {
// Guard against size_type overflow
BOOST_UBLAS_CHECK (size2 == 0 || size1 <= (std::numeric_limits<size_type>::max) () / size2, bad_size ());
return size1 * size2;
BOOST_UBLAS_CHECK (size_j == 0 || size_i <= (std::numeric_limits<size_type>::max) () / size_j, bad_size ());
return size_i * size_j;
}
// Indexing
// Indexing conversion to storage element
static
BOOST_UBLAS_INLINE
size_type element (size_type i, size_type size1, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (i < size1, bad_index ());
BOOST_UBLAS_CHECK (j < size2, bad_index ());
detail::ignore_unused_variable_warning(size1);
size_type element (size_type i, size_type size_i, size_type j, size_type size_j) {
BOOST_UBLAS_CHECK (i < size_i, bad_index ());
BOOST_UBLAS_CHECK (j < size_j, bad_index ());
detail::ignore_unused_variable_warning(size_i);
// Guard against size_type overflow
BOOST_UBLAS_CHECK (i <= ((std::numeric_limits<size_type>::max) () - j) / size2, bad_index ());
return i * size2 + j;
BOOST_UBLAS_CHECK (i <= ((std::numeric_limits<size_type>::max) () - j) / size_j, bad_index ());
return i * size_j + j;
}
static
BOOST_UBLAS_INLINE
size_type address (size_type i, size_type size1, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (i <= size1, bad_index ());
BOOST_UBLAS_CHECK (j <= size2, bad_index ());
// Guard against size_type overflow - address may be size2 past end of storage
BOOST_UBLAS_CHECK (size2 == 0 || i <= ((std::numeric_limits<size_type>::max) () - j) / size2, bad_index ());
detail::ignore_unused_variable_warning(size1);
return i * size2 + j;
size_type address (size_type i, size_type size_i, size_type j, size_type size_j) {
BOOST_UBLAS_CHECK (i <= size_i, bad_index ());
BOOST_UBLAS_CHECK (j <= size_j, bad_index ());
// Guard against size_type overflow - address may be size_j past end of storage
BOOST_UBLAS_CHECK (size_j == 0 || i <= ((std::numeric_limits<size_type>::max) () - j) / size_j, bad_index ());
detail::ignore_unused_variable_warning(size_i);
return i * size_j + j;
}
// Storage element to index conversion
static
BOOST_UBLAS_INLINE
difference_type distance_i (difference_type k, size_type /* size_i */, size_type size_j) {
return size_j != 0 ? k / size_j : 0;
}
static
BOOST_UBLAS_INLINE
difference_type distance1 (difference_type k, size_type /* size1 */, size_type size2) {
return size2 != 0 ? k / size2 : 0;
}
static
BOOST_UBLAS_INLINE
difference_type distance2 (difference_type k, size_type /* size1 */, size_type /* size2 */) {
difference_type distance_j (difference_type k, size_type /* size_i */, size_type /* size_j */) {
return k;
}
static
BOOST_UBLAS_INLINE
size_type index1 (difference_type k, size_type /* size1 */, size_type size2) {
return size2 != 0 ? k / size2 : 0;
size_type index_i (difference_type k, size_type /* size_i */, size_type size_j) {
return size_j != 0 ? k / size_j : 0;
}
static
BOOST_UBLAS_INLINE
size_type index2 (difference_type k, size_type /* size1 */, size_type size2) {
return size2 != 0 ? k % size2 : 0;
size_type index_j (difference_type k, size_type /* size_i */, size_type size_j) {
return size_j != 0 ? k % size_j : 0;
}
static
BOOST_UBLAS_INLINE
bool fast1 () {
bool fast_i () {
return false;
}
static
BOOST_UBLAS_INLINE
size_type one1 (size_type /* size1 */, size_type size2) {
return size2;
}
static
BOOST_UBLAS_INLINE
bool fast2 () {
bool fast_j () {
return true;
}
// Iterating storage elements
template<class I>
static
BOOST_UBLAS_INLINE
size_type one2 (size_type /* size1 */, size_type /* size2 */) {
return 1;
void increment_i (I &it, size_type /* size_i */, size_type size_j) {
it += size_j;
}
template<class I>
static
BOOST_UBLAS_INLINE
void increment_i (I &it, difference_type n, size_type /* size_i */, size_type size_j) {
it += n * size_j;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement_i (I &it, size_type /* size_i */, size_type size_j) {
it -= size_j;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement_i (I &it, difference_type n, size_type /* size_i */, size_type size_j) {
it -= n * size_j;
}
template<class I>
static
BOOST_UBLAS_INLINE
void increment_j (I &it, size_type /* size_i */, size_type /* size_j */) {
++ it;
}
template<class I>
static
BOOST_UBLAS_INLINE
void increment_j (I &it, difference_type n, size_type /* size_i */, size_type /* size_j */) {
it += n;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement_j (I &it, size_type /* size_i */, size_type /* size_j */) {
-- it;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement_j (I &it, difference_type n, size_type /* size_i */, size_type /* size_j */) {
it -= n;
}
// Triangular access
static
BOOST_UBLAS_INLINE
size_type triangular_size (size_type size1, size_type size2) {
size_type size = (std::max) (size1, size2);
size_type triangular_size (size_type size_i, size_type size_j) {
size_type size = (std::max) (size_i, size_j);
// Guard against size_type overflow - simplified
BOOST_UBLAS_CHECK (size == 0 || size / 2 < (std::numeric_limits<size_type>::max) () / size /* +1/2 */, bad_size ());
return ((size + 1) * size) / 2;
}
static
BOOST_UBLAS_INLINE
size_type lower_element (size_type i, size_type size1, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (i < size1, bad_index ());
BOOST_UBLAS_CHECK (j < size2, bad_index ());
size_type lower_element (size_type i, size_type size_i, size_type j, size_type size_j) {
BOOST_UBLAS_CHECK (i < size_i, bad_index ());
BOOST_UBLAS_CHECK (j < size_j, bad_index ());
BOOST_UBLAS_CHECK (i >= j, bad_index ());
detail::ignore_unused_variable_warning(size1);
detail::ignore_unused_variable_warning(size2);
detail::ignore_unused_variable_warning(size_i);
detail::ignore_unused_variable_warning(size_j);
// FIXME size_type overflow
// sigma_i (i + 1) = (i + 1) * i / 2
// i = 0 1 2 3, sigma = 0 1 3 6
@@ -1471,94 +1514,41 @@ namespace boost { namespace numeric { namespace ublas {
}
static
BOOST_UBLAS_INLINE
size_type upper_element (size_type i, size_type size1, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (i < size1, bad_index ());
BOOST_UBLAS_CHECK (j < size2, bad_index ());
size_type upper_element (size_type i, size_type size_i, size_type j, size_type size_j) {
BOOST_UBLAS_CHECK (i < size_i, bad_index ());
BOOST_UBLAS_CHECK (j < size_j, bad_index ());
BOOST_UBLAS_CHECK (i <= j, bad_index ());
// FIXME size_type overflow
// sigma_i (size - i) = size * i - i * (i - 1) / 2
// i = 0 1 2 3, sigma = 0 4 7 9
return (i * (2 * (std::max) (size1, size2) - i + 1)) / 2 + j - i;
return (i * (2 * (std::max) (size_i, size_j) - i + 1)) / 2 + j - i;
}
// Major and minor indices
static
BOOST_UBLAS_INLINE
size_type element1 (size_type i, size_type size1, size_type /* j */, size_type /* size2 */) {
BOOST_UBLAS_CHECK (i < size1, bad_index ());
detail::ignore_unused_variable_warning(size1);
return i;
}
static
BOOST_UBLAS_INLINE
size_type element2 (size_type /* i */, size_type /* size1 */, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (j < size2, bad_index ());
detail::ignore_unused_variable_warning(size2);
return j;
}
static
BOOST_UBLAS_INLINE
size_type address1 (size_type i, size_type size1, size_type /* j */, size_type /* size2 */) {
BOOST_UBLAS_CHECK (i <= size1, bad_index ());
detail::ignore_unused_variable_warning(size1);
return i;
}
static
BOOST_UBLAS_INLINE
size_type address2 (size_type /* i */, size_type /* size1 */, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (j <= size2, bad_index ());
detail::ignore_unused_variable_warning(size2);
return j;
}
static
BOOST_UBLAS_INLINE
size_type index1 (size_type index1, size_type /* index2 */) {
size_type index_M (size_type index1, size_type /* index2 */) {
return index1;
}
static
BOOST_UBLAS_INLINE
size_type index2 (size_type /* index1 */, size_type index2) {
size_type index_m (size_type /* index1 */, size_type index2) {
return index2;
}
static
BOOST_UBLAS_INLINE
size_type size1 (size_type size1, size_type /* size2 */) {
return size1;
size_type size_M (size_type size_i, size_type /* size_j */) {
return size_i;
}
static
BOOST_UBLAS_INLINE
size_type size2 (size_type /* size1 */, size_type size2) {
return size2;
}
// Iterating
template<class I>
static
BOOST_UBLAS_INLINE
void increment1 (I &it, size_type /* size1 */, size_type size2) {
it += size2;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement1 (I &it, size_type /* size1 */, size_type size2) {
it -= size2;
}
template<class I>
static
BOOST_UBLAS_INLINE
void increment2 (I &it, size_type /* size1 */, size_type /* size2 */) {
++ it;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement2 (I &it, size_type /* size1 */, size_type /* size2 */) {
-- it;
size_type size_m (size_type /* size_i */, size_type size_j) {
return size_j;
}
};
// This functor computes the address translation
// matrix [i] [j] -> storage [i + j * size1]
// This functor defines storage layout and it's properties
// matrix (i,j) -> storage [i + j * size_i]
template <class Z, class D>
struct basic_column_major {
typedef Z size_type;
@@ -1567,98 +1557,141 @@ namespace boost { namespace numeric { namespace ublas {
static
BOOST_UBLAS_INLINE
size_type storage_size (size_type size1, size_type size2) {
size_type storage_size (size_type size_i, size_type size_j) {
// Guard against size_type overflow
BOOST_UBLAS_CHECK (size1 == 0 || size2 <= (std::numeric_limits<size_type>::max) () / size1, bad_size ());
return size1 * size2;
BOOST_UBLAS_CHECK (size_i == 0 || size_j <= (std::numeric_limits<size_type>::max) () / size_i, bad_size ());
return size_i * size_j;
}
// Indexing
// Indexing conversion to storage element
static
BOOST_UBLAS_INLINE
size_type element (size_type i, size_type size1, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (i < size1, bad_index ());
BOOST_UBLAS_CHECK (j < size2, bad_index ());
detail::ignore_unused_variable_warning(size2);
size_type element (size_type i, size_type size_i, size_type j, size_type size_j) {
BOOST_UBLAS_CHECK (i < size_i, bad_index ());
BOOST_UBLAS_CHECK (j < size_j, bad_index ());
detail::ignore_unused_variable_warning(size_j);
// Guard against size_type overflow
BOOST_UBLAS_CHECK (j <= ((std::numeric_limits<size_type>::max) () - i) / size1, bad_index ());
return i + j * size1;
BOOST_UBLAS_CHECK (j <= ((std::numeric_limits<size_type>::max) () - i) / size_i, bad_index ());
return i + j * size_i;
}
static
BOOST_UBLAS_INLINE
size_type address (size_type i, size_type size1, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (i <= size1, bad_index ());
BOOST_UBLAS_CHECK (j <= size2, bad_index ());
detail::ignore_unused_variable_warning(size2);
// Guard against size_type overflow - address may be size1 past end of storage
BOOST_UBLAS_CHECK (size1 == 0 || j <= ((std::numeric_limits<size_type>::max) () - i) / size1, bad_index ());
return i + j * size1;
size_type address (size_type i, size_type size_i, size_type j, size_type size_j) {
BOOST_UBLAS_CHECK (i <= size_i, bad_index ());
BOOST_UBLAS_CHECK (j <= size_j, bad_index ());
detail::ignore_unused_variable_warning(size_j);
// Guard against size_type overflow - address may be size_i past end of storage
BOOST_UBLAS_CHECK (size_i == 0 || j <= ((std::numeric_limits<size_type>::max) () - i) / size_i, bad_index ());
return i + j * size_i;
}
// Storage element to index conversion
static
BOOST_UBLAS_INLINE
difference_type distance1 (difference_type k, size_type /* size1 */, size_type /* size2 */) {
difference_type distance_i (difference_type k, size_type /* size_i */, size_type /* size_j */) {
return k;
}
static
BOOST_UBLAS_INLINE
difference_type distance2 (difference_type k, size_type size1, size_type /* size2 */) {
return size1 != 0 ? k / size1 : 0;
difference_type distance_j (difference_type k, size_type size_i, size_type /* size_j */) {
return size_i != 0 ? k / size_i : 0;
}
static
BOOST_UBLAS_INLINE
size_type index1 (difference_type k, size_type size1, size_type /* size2 */) {
return size1 != 0 ? k % size1 : 0;
size_type index_i (difference_type k, size_type size_i, size_type /* size_j */) {
return size_i != 0 ? k % size_i : 0;
}
static
BOOST_UBLAS_INLINE
size_type index2 (difference_type k, size_type size1, size_type /* size2 */) {
return size1 != 0 ? k / size1 : 0;
size_type index_j (difference_type k, size_type size_i, size_type /* size_j */) {
return size_i != 0 ? k / size_i : 0;
}
static
BOOST_UBLAS_INLINE
bool fast1 () {
bool fast_i () {
return true;
}
static
BOOST_UBLAS_INLINE
size_type one1 (size_type /* size1 */, size_type /* size2 */) {
return 1;
}
static
BOOST_UBLAS_INLINE
bool fast2 () {
bool fast_j () {
return false;
}
// Iterating
template<class I>
static
BOOST_UBLAS_INLINE
size_type one2 (size_type size1, size_type /* size2 */) {
return size1;
void increment_i (I &it, size_type /* size_i */, size_type /* size_j */) {
++ it;
}
template<class I>
static
BOOST_UBLAS_INLINE
void increment_i (I &it, difference_type n, size_type /* size_i */, size_type /* size_j */) {
it += n;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement_i (I &it, size_type /* size_i */, size_type /* size_j */) {
-- it;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement_i (I &it, difference_type n, size_type /* size_i */, size_type /* size_j */) {
it -= n;
}
template<class I>
static
BOOST_UBLAS_INLINE
void increment_j (I &it, size_type size_i, size_type /* size_j */) {
it += size_i;
}
template<class I>
static
BOOST_UBLAS_INLINE
void increment_j (I &it, difference_type n, size_type size_i, size_type /* size_j */) {
it += n * size_i;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement_j (I &it, size_type size_i, size_type /* size_j */) {
it -= size_i;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement_j (I &it, difference_type n, size_type size_i, size_type /* size_j */) {
it -= n* size_i;
}
// Triangular access
static
BOOST_UBLAS_INLINE
size_type triangular_size (size_type size1, size_type size2) {
size_type size = (std::max) (size1, size2);
size_type triangular_size (size_type size_i, size_type size_j) {
size_type size = (std::max) (size_i, size_j);
// Guard against size_type overflow - simplified
BOOST_UBLAS_CHECK (size == 0 || size / 2 < (std::numeric_limits<size_type>::max) () / size /* +1/2 */, bad_size ());
return ((size + 1) * size) / 2;
}
static
BOOST_UBLAS_INLINE
size_type lower_element (size_type i, size_type size1, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (i < size1, bad_index ());
BOOST_UBLAS_CHECK (j < size2, bad_index ());
size_type lower_element (size_type i, size_type size_i, size_type j, size_type size_j) {
BOOST_UBLAS_CHECK (i < size_i, bad_index ());
BOOST_UBLAS_CHECK (j < size_j, bad_index ());
BOOST_UBLAS_CHECK (i >= j, bad_index ());
// FIXME size_type overflow
// sigma_j (size - j) = size * j - j * (j - 1) / 2
// j = 0 1 2 3, sigma = 0 4 7 9
return i - j + (j * (2 * (std::max) (size1, size2) - j + 1)) / 2;
return i - j + (j * (2 * (std::max) (size_i, size_j) - j + 1)) / 2;
}
static
BOOST_UBLAS_INLINE
size_type upper_element (size_type i, size_type size1, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (i < size1, bad_index ());
BOOST_UBLAS_CHECK (j < size2, bad_index ());
size_type upper_element (size_type i, size_type size_i, size_type j, size_type size_j) {
BOOST_UBLAS_CHECK (i < size_i, bad_index ());
BOOST_UBLAS_CHECK (j < size_j, bad_index ());
BOOST_UBLAS_CHECK (i <= j, bad_index ());
// FIXME size_type overflow
// sigma_j (j + 1) = (j + 1) * j / 2
@@ -1666,79 +1699,26 @@ namespace boost { namespace numeric { namespace ublas {
return i + ((j + 1) * j) / 2;
}
// Major and minor indices
static
BOOST_UBLAS_INLINE
size_type element1 (size_type /* i */, size_type /* size1 */, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (j < size2, bad_index ());
detail::ignore_unused_variable_warning(size2);
return j;
}
static
BOOST_UBLAS_INLINE
size_type element2 (size_type i, size_type size1, size_type /* j */, size_type /* size2 */) {
BOOST_UBLAS_CHECK (i < size1, bad_index ());
detail::ignore_unused_variable_warning(size1);
return i;
}
static
BOOST_UBLAS_INLINE
size_type address1 (size_type /* i */, size_type /* size1 */, size_type j, size_type size2) {
BOOST_UBLAS_CHECK (j <= size2, bad_index ());
detail::ignore_unused_variable_warning(size2);
return j;
}
static
BOOST_UBLAS_INLINE
size_type address2 (size_type i, size_type size1, size_type /* j */, size_type /* size2 */) {
BOOST_UBLAS_CHECK (i <= size1, bad_index ());
detail::ignore_unused_variable_warning(size1);
return i;
}
static
BOOST_UBLAS_INLINE
size_type index1 (size_type /* index1 */, size_type index2) {
size_type index_M (size_type /* index1 */, size_type index2) {
return index2;
}
static
BOOST_UBLAS_INLINE
size_type index2 (size_type index1, size_type /* index2 */) {
size_type index_m (size_type index1, size_type /* index2 */) {
return index1;
}
static
BOOST_UBLAS_INLINE
size_type size1 (size_type /* size1 */, size_type size2) {
return size2;
size_type size_M (size_type /* size_i */, size_type size_j) {
return size_j;
}
static
BOOST_UBLAS_INLINE
size_type size2 (size_type size1, size_type /* size2 */) {
return size1;
}
// Iterating
template<class I>
static
BOOST_UBLAS_INLINE
void increment1 (I &it, size_type /* size1 */, size_type /* size2 */) {
++ it;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement1 (I &it, size_type /* size1 */, size_type /* size2 */) {
-- it;
}
template<class I>
static
BOOST_UBLAS_INLINE
void increment2 (I &it, size_type size1, size_type /* size2 */) {
it += size1;
}
template<class I>
static
BOOST_UBLAS_INLINE
void decrement2 (I &it, size_type size1, size_type /* size2 */) {
it -= size1;
size_type size_m (size_type size_i, size_type /* size_j */) {
return size_i;
}
};
@@ -1750,8 +1730,8 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type packed_size (L, size_type size1, size_type size2) {
return L::storage_size (size1, size2);
size_type packed_size (L, size_type size_i, size_type size_j) {
return L::storage_size (size_i, size_j);
}
static
@@ -1769,6 +1749,26 @@ namespace boost { namespace numeric { namespace ublas {
bool other (size_type /* i */, size_type /* j */) {
return true;
}
static
BOOST_UBLAS_INLINE
size_type restrict1 (size_type i, size_type j) {
return i;
}
static
BOOST_UBLAS_INLINE
size_type restrict2 (size_type i, size_type j) {
return j;
}
static
BOOST_UBLAS_INLINE
size_type mutable_restrict1 (size_type i, size_type j) {
return i;
}
static
BOOST_UBLAS_INLINE
size_type mutable_restrict2 (size_type i, size_type j) {
return j;
}
};
template <class Z>
@@ -1778,8 +1778,8 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type packed_size (L, size_type size1, size_type size2) {
return L::triangular_size (size1, size2);
size_type packed_size (L, size_type size_i, size_type size_j) {
return L::triangular_size (size_i, size_j);
}
static
@@ -1800,8 +1800,8 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type element (L, size_type i, size_type size1, size_type j, size_type size2) {
return L::lower_element (i, size1, j, size2);
size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) {
return L::lower_element (i, size_i, j, size_j);
}
static
@@ -1832,8 +1832,8 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type packed_size (L, size_type size1, size_type size2) {
return L::triangular_size (size1, size2);
size_type packed_size (L, size_type size_i, size_type size_j) {
return L::triangular_size (size_i, size_j);
}
static
@@ -1854,8 +1854,8 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type element (L, size_type i, size_type size1, size_type j, size_type size2) {
return L::upper_element (i, size1, j, size2);
size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) {
return L::upper_element (i, size_i, j, size_j);
}
static
@@ -1886,10 +1886,10 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type packed_size (L, size_type size1, size_type size2) {
size_type packed_size (L, size_type size_i, size_type size_j) {
// Zero size strict triangles are bad at this point
BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ());
return L::triangular_size (size1 - 1, size2 - 1);
BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ());
return L::triangular_size (size_i - 1, size_j - 1);
}
static
@@ -1905,10 +1905,10 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type element (L, size_type i, size_type size1, size_type j, size_type size2) {
size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) {
// Zero size strict triangles are bad at this point
BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ());
return L::lower_element (i, size1 - 1, j, size2 - 1);
BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ());
return L::lower_element (i, size_i - 1, j, size_j - 1);
}
static
@@ -1929,10 +1929,10 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type packed_size (L, size_type size1, size_type size2) {
size_type packed_size (L, size_type size_i, size_type size_j) {
// Zero size strict triangles are bad at this point
BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ());
return L::triangular_size (size1 - 1, size2 - 1);
BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ());
return L::triangular_size (size_i - 1, size_j - 1);
}
static
@@ -1948,10 +1948,10 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type element (L, size_type i, size_type size1, size_type j, size_type size2) {
size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) {
// Zero size strict triangles are bad at this point
BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ());
return L::upper_element (i, size1 - 1, j, size2 - 1);
BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ());
return L::upper_element (i, size_i - 1, j, size_j - 1);
}
static
@@ -1972,10 +1972,10 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type packed_size (L, size_type size1, size_type size2) {
size_type packed_size (L, size_type size_i, size_type size_j) {
// Zero size strict triangles are bad at this point
BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ());
return L::triangular_size (size1 - 1, size2 - 1);
BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ());
return L::triangular_size (size_i - 1, size_j - 1);
}
static
@@ -1996,10 +1996,10 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type element (L, size_type i, size_type size1, size_type j, size_type size2) {
size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) {
// Zero size strict triangles are bad at this point
BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ());
return L::lower_element (i, size1 - 1, j, size2 - 1);
BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ());
return L::lower_element (i, size_i - 1, j, size_j - 1);
}
static
@@ -2030,10 +2030,10 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type packed_size (L, size_type size1, size_type size2) {
size_type packed_size (L, size_type size_i, size_type size_j) {
// Zero size strict triangles are bad at this point
BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ());
return L::triangular_size (size1 - 1, size2 - 1);
BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ());
return L::triangular_size (size_i - 1, size_j - 1);
}
static
@@ -2054,10 +2054,10 @@ namespace boost { namespace numeric { namespace ublas {
template<class L>
static
BOOST_UBLAS_INLINE
size_type element (L, size_type i, size_type size1, size_type j, size_type size2) {
size_type element (L, size_type i, size_type size_i, size_type j, size_type size_j) {
// Zero size strict triangles are bad at this point
BOOST_UBLAS_CHECK (size1 != 0 && size2 != 0, bad_index ());
return L::upper_element (i, size1 - 1, j, size2 - 1);
BOOST_UBLAS_CHECK (size_i != 0 && size_j != 0, bad_index ());
return L::upper_element (i, size_i - 1, j, size_j - 1);
}
static

View File

@@ -41,15 +41,17 @@ namespace boost { namespace numeric { namespace ublas {
// Common elements to preserve
const size_type size1_min = (std::min) (size1, msize1);
const size_type size2_min = (std::min) (size2, msize2);
// Order loop for i-major and j-minor sizes
const size_type i_size = layout_type::size1 (size1_min, size2_min);
const size_type j_size = layout_type::size2 (size1_min, size2_min);
for (size_type i = 0; i != i_size; ++i) { // indexing copy over major
for (size_type j = 0; j != j_size; ++j) {
const size_type element1 = layout_type::element1(i,i_size, j,j_size);
const size_type element2 = layout_type::element2(i,i_size, j,j_size);
temporary.data () [layout_type::element (element1, size1, element2, size2)] =
m.data() [layout_type::element (element1, msize1, element2, msize2)];
// Order for major and minor sizes
const size_type major_size = layout_type::size_M (size1_min, size2_min);
const size_type minor_size = layout_type::size_m (size1_min, size2_min);
// Indexing copy over major
for (size_type major = 0; major != major_size; ++major) {
for (size_type minor = 0; minor != minor_size; ++minor) {
// find indexes - use invertability of element_ functions
const size_type i1 = layout_type::index_M(major, minor);
const size_type i2 = layout_type::index_m(major, minor);
temporary.data () [layout_type::element (i1, size1, i2, size2)] =
m.data() [layout_type::element (i1, msize1, i2, msize2)];
}
}
m.assign_temporary (temporary);
@@ -355,28 +357,28 @@ namespace boost { namespace numeric { namespace ublas {
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator1 &operator ++ () {
layout_type::increment1 (it_, (*this) ().size1 (), (*this) ().size2 ());
layout_type::increment_i (it_, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
const_iterator1 &operator -- () {
layout_type::decrement1 (it_, (*this) ().size1 (), (*this) ().size2 ());
layout_type::decrement_i (it_, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
const_iterator1 &operator += (difference_type n) {
it_ += n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ());
layout_type::increment_i (it_, n, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
const_iterator1 &operator -= (difference_type n) {
it_ -= n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ());
layout_type::decrement_i (it_, n, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
difference_type operator - (const const_iterator1 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
return layout_type::distance1 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
return layout_type::distance_i (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
}
// Dereference
@@ -428,12 +430,12 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_INLINE
size_type index1 () const {
const self_type &m = (*this) ();
return layout_type::index1 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
return layout_type::index_i (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
}
BOOST_UBLAS_INLINE
size_type index2 () const {
const self_type &m = (*this) ();
return layout_type::index2 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
return layout_type::index_j (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
}
// Assignment
@@ -497,28 +499,28 @@ namespace boost { namespace numeric { namespace ublas {
// Arithmetic
BOOST_UBLAS_INLINE
iterator1 &operator ++ () {
layout_type::increment1 (it_, (*this) ().size1 (), (*this) ().size2 ());
layout_type::increment_i (it_, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
iterator1 &operator -- () {
layout_type::decrement1 (it_, (*this) ().size1 (), (*this) ().size2 ());
layout_type::decrement_i (it_, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
iterator1 &operator += (difference_type n) {
it_ += n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ());
layout_type::increment_i (it_, n, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
iterator1 &operator -= (difference_type n) {
it_ -= n * layout_type::one1 ((*this) ().size1 (), (*this) ().size2 ());
layout_type::decrement_i (it_, n, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
difference_type operator - (const iterator1 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
return layout_type::distance1 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
return layout_type::distance_i (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
}
// Dereference
@@ -570,12 +572,12 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_INLINE
size_type index1 () const {
self_type &m = (*this) ();
return layout_type::index1 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
return layout_type::index_i (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
}
BOOST_UBLAS_INLINE
size_type index2 () const {
self_type &m = (*this) ();
return layout_type::index2 (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
return layout_type::index_j (it_ - m.begin1 ().it_, m.size1 (), m.size2 ());
}
// Assignment
@@ -642,28 +644,28 @@ namespace boost { namespace numeric { namespace ublas {
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator2 &operator ++ () {
layout_type::increment2 (it_, (*this) ().size1 (), (*this) ().size2 ());
layout_type::increment_j (it_, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
const_iterator2 &operator -- () {
layout_type::decrement2 (it_, (*this) ().size1 (), (*this) ().size2 ());
layout_type::decrement_j (it_, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
const_iterator2 &operator += (difference_type n) {
it_ += n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ());
layout_type::increment_j (it_, n, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
const_iterator2 &operator -= (difference_type n) {
it_ -= n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ());
layout_type::decrement_j (it_, n, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
difference_type operator - (const const_iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
return layout_type::distance2 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
return layout_type::distance_j (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
}
// Dereference
@@ -715,12 +717,12 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_INLINE
size_type index1 () const {
const self_type &m = (*this) ();
return layout_type::index1 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
return layout_type::index_i (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
}
BOOST_UBLAS_INLINE
size_type index2 () const {
const self_type &m = (*this) ();
return layout_type::index2 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
return layout_type::index_j (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
}
// Assignment
@@ -784,28 +786,28 @@ namespace boost { namespace numeric { namespace ublas {
// Arithmetic
BOOST_UBLAS_INLINE
iterator2 &operator ++ () {
layout_type::increment2 (it_, (*this) ().size1 (), (*this) ().size2 ());
layout_type::increment_j (it_, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
iterator2 &operator -- () {
layout_type::decrement2 (it_, (*this) ().size1 (), (*this) ().size2 ());
layout_type::decrement_j (it_, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
iterator2 &operator += (difference_type n) {
it_ += n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ());
layout_type::increment_j (it_, n, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
iterator2 &operator -= (difference_type n) {
it_ -= n * layout_type::one2 ((*this) ().size1 (), (*this) ().size2 ());
layout_type::decrement_j (it_, n, (*this) ().size1 (), (*this) ().size2 ());
return *this;
}
BOOST_UBLAS_INLINE
difference_type operator - (const iterator2 &it) const {
BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());
return layout_type::distance2 (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
return layout_type::distance_j (it_ - it.it_, (*this) ().size1 (), (*this) ().size2 ());
}
// Dereference
@@ -857,12 +859,12 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_INLINE
size_type index1 () const {
self_type &m = (*this) ();
return layout_type::index1 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
return layout_type::index_i (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
}
BOOST_UBLAS_INLINE
size_type index2 () const {
self_type &m = (*this) ();
return layout_type::index2 (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
return layout_type::index_j (it_ - m.begin2 ().it_, m.size1 (), m.size2 ());
}
// Assignment
@@ -1249,7 +1251,7 @@ namespace boost { namespace numeric { namespace ublas {
#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
return const_iterator1 (*this, i, j);
#else
return const_iterator1 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin () + layout_type::address2 (i, size1_, j, size2_));
return const_iterator1 (*this, i, j, data () [layout_type::index_M (i, j)].begin () + layout_type::index_m (i, j));
#endif
}
BOOST_UBLAS_INLINE
@@ -1257,7 +1259,7 @@ namespace boost { namespace numeric { namespace ublas {
#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
return iterator1 (*this, i, j);
#else
return iterator1 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin () + layout_type::address2 (i, size1_, j, size2_));
return iterator1 (*this, i, j, data () [layout_type::index_M (i, j)].begin () + layout_type::index_m (i, j));
#endif
}
BOOST_UBLAS_INLINE
@@ -1265,7 +1267,7 @@ namespace boost { namespace numeric { namespace ublas {
#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
return const_iterator2 (*this, i, j);
#else
return const_iterator2 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin () + layout_type::address2 (i, size1_, j, size2_));
return const_iterator2 (*this, i, j, data () [layout_type::index_M (i, j)].begin () + layout_type::index_m (i, j));
#endif
}
BOOST_UBLAS_INLINE
@@ -1273,7 +1275,7 @@ namespace boost { namespace numeric { namespace ublas {
#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR
return iterator2 (*this, i, j);
#else
return iterator2 (*this, i, j, data () [layout_type::address1 (i, size1_, j, size2_)].begin () + layout_type::address2 (i, size1_, j, size2_));
return iterator2 (*this, i, j, data () [layout_type::index_M (i, j)].begin () + layout_type::index_m (i, j));
#endif
}
@@ -1308,7 +1310,7 @@ namespace boost { namespace numeric { namespace ublas {
const_iterator1 &operator ++ () {
++ i_;
const self_type &m = (*this) ();
if (layout_type::fast1 ())
if (layout_type::fast_i ())
++ it_;
else
it_ = m.find1 (1, i_, j_).it_;
@@ -1318,7 +1320,7 @@ namespace boost { namespace numeric { namespace ublas {
const_iterator1 &operator -- () {
-- i_;
const self_type &m = (*this) ();
if (layout_type::fast1 ())
if (layout_type::fast_i ())
-- it_;
else
it_ = m.find1 (1, i_, j_).it_;
@@ -1467,7 +1469,7 @@ namespace boost { namespace numeric { namespace ublas {
iterator1 &operator ++ () {
++ i_;
self_type &m = (*this) ();
if (layout_type::fast1 ())
if (layout_type::fast_i ())
++ it_;
else
it_ = m.find1 (1, i_, j_).it_;
@@ -1477,7 +1479,7 @@ namespace boost { namespace numeric { namespace ublas {
iterator1 &operator -- () {
-- i_;
self_type &m = (*this) ();
if (layout_type::fast1 ())
if (layout_type::fast_i ())
-- it_;
else
it_ = m.find1 (1, i_, j_).it_;
@@ -1629,7 +1631,7 @@ namespace boost { namespace numeric { namespace ublas {
const_iterator2 &operator ++ () {
++ j_;
const self_type &m = (*this) ();
if (layout_type::fast2 ())
if (layout_type::fast_j ())
++ it_;
else
it_ = m.find2 (1, i_, j_).it_;
@@ -1639,7 +1641,7 @@ namespace boost { namespace numeric { namespace ublas {
const_iterator2 &operator -- () {
-- j_;
const self_type &m = (*this) ();
if (layout_type::fast2 ())
if (layout_type::fast_j ())
-- it_;
else
it_ = m.find2 (1, i_, j_).it_;
@@ -1788,7 +1790,7 @@ namespace boost { namespace numeric { namespace ublas {
iterator2 &operator ++ () {
++ j_;
self_type &m = (*this) ();
if (layout_type::fast2 ())
if (layout_type::fast_j ())
++ it_;
else
it_ = m.find2 (1, i_, j_).it_;
@@ -1798,7 +1800,7 @@ namespace boost { namespace numeric { namespace ublas {
iterator2 &operator -- () {
-- j_;
self_type &m = (*this) ();
if (layout_type::fast2 ())
if (layout_type::fast_j ())
-- it_;
else
it_ = m.find2 (1, i_, j_).it_;

File diff suppressed because it is too large Load Diff

View File

@@ -64,7 +64,7 @@ namespace boost { namespace numeric { namespace ublas {
generalized_vector_of_vector ():
matrix_container<self_type> (),
size1_ (0), size2_ (0), data_ (1) {
const size_type sizeM = layout_type::size1 (size1_, size2_);
const size_type sizeM = layout_type::size_M (size1_, size2_);
// create size1+1 empty vector elements
data_.insert_element (sizeM, vector_data_value_type ());
storage_invariants ();
@@ -72,9 +72,9 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_INLINE
generalized_vector_of_vector (size_type size1, size_type size2, size_type non_zeros = 0):
matrix_container<self_type> (),
size1_ (size1), size2_ (size2), data_ (layout_type::size1 (size1_, size2_) + 1) {
const size_type sizeM = layout_type::size1 (size1_, size2_);
const size_type sizem = layout_type::size2 (size1_, size2_);
size1_ (size1), size2_ (size2), data_ (layout_type::size_M (size1_, size2_) + 1) {
const size_type sizeM = layout_type::size_M (size1_, size2_);
const size_type sizem = layout_type::size_m (size1_, size2_);
for (size_type i = 0; i < sizeM; ++ i) // create size1 vector elements
data_.insert_element (i, vector_data_value_type ()) .resize (sizem, false);
data_.insert_element (sizeM, vector_data_value_type ());
@@ -90,9 +90,9 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_INLINE
generalized_vector_of_vector (const matrix_expression<AE> &ae, size_type non_zeros = 0):
matrix_container<self_type> (),
size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (layout_type::size1 (size1_, size2_) + 1) {
const size_type sizeM = layout_type::size1 (size1_, size2_);
const size_type sizem = layout_type::size2 (size1_, size2_);
size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (layout_type::size_M (size1_, size2_) + 1) {
const size_type sizeM = layout_type::size_M (size1_, size2_);
const size_type sizem = layout_type::size_m (size1_, size2_);
for (size_type i = 0; i < sizeM; ++ i) // create size1 vector elements
data_.insert_element (i, vector_data_value_type ()) .resize (sizem, false);
data_.insert_element (sizeM, vector_data_value_type ());
@@ -130,11 +130,11 @@ namespace boost { namespace numeric { namespace ublas {
// Resizing
BOOST_UBLAS_INLINE
void resize (size_type size1, size_type size2, bool preserve = true) {
const size_type oldM = layout_type::size1 (size1_, size2_);
const size_type oldM = layout_type::size_M (size1_, size2_);
size1_ = size1;
size2_ = size2;
const size_type sizeM = layout_type::size1 (size1_, size2_);
const size_type sizem = layout_type::size2 (size1_, size2_);
const size_type sizeM = layout_type::size_M (size1_, size2_);
const size_type sizem = layout_type::size_m (size1_, size2_);
data ().resize (sizeM + 1, preserve);
if (preserve) {
for (size_type i = 0; (i <= oldM) && (i < sizeM); ++ i)
@@ -161,8 +161,8 @@ namespace boost { namespace numeric { namespace ublas {
}
BOOST_UBLAS_INLINE
const_pointer find_element (size_type i, size_type j) const {
const size_type elementM = layout_type::element1 (i, size1_, j, size2_);
const size_type elementm = layout_type::element2 (i, size1_, j, size2_);
const size_type elementM = layout_type::index_M (i, j);
const size_type elementm = layout_type::index_m (i, j);
// optimise: check the storage_type and index directly if element always exists
if (boost::is_convertible<typename array_type::storage_category, packed_tag>::value) {
return & (data () [elementM] [elementm]);
@@ -293,31 +293,31 @@ namespace boost { namespace numeric { namespace ublas {
// Element insertion and erasure
BOOST_UBLAS_INLINE
true_reference insert_element (size_type i, size_type j, const_reference t) {
const size_type elementM = layout_type::element1 (i, size1_, j, size2_);
const size_type elementm = layout_type::element2 (i, size1_, j, size2_);
const size_type elementM = layout_type::index_M (i, j);
const size_type elementm = layout_type::index_m (i, j);
vector_data_value_type& vd (ref (data () [elementM]));
storage_invariants ();
return vd.insert_element (elementm, t);
}
BOOST_UBLAS_INLINE
void append_element (size_type i, size_type j, const_reference t) {
const size_type elementM = layout_type::element1 (i, size1_, j, size2_);
const size_type elementm = layout_type::element2 (i, size1_, j, size2_);
const size_type elementM = layout_type::index_M (i, j);
const size_type elementm = layout_type::index_m (i, j);
vector_data_value_type& vd (ref (data () [elementM]));
storage_invariants ();
return vd.append_element (elementm, t);
}
BOOST_UBLAS_INLINE
void erase_element (size_type i, size_type j) {
vectoriterator_type itv (data ().find (layout_type::element1 (i, size1_, j, size2_)));
vectoriterator_type itv (data ().find (layout_type::index_M (i, j)));
if (itv == data ().end ())
return;
(*itv).erase_element (layout_type::element2 (i, size1_, j, size2_));
(*itv).erase_element (layout_type::index_m (i, j));
storage_invariants ();
}
BOOST_UBLAS_INLINE
void clear () {
const size_type sizeM = layout_type::size1 (size1_, size2_);
const size_type sizeM = layout_type::size_M (size1_, size2_);
// FIXME should clear data () if this is done via value_type/*zero*/() then it is not size preserving
for (size_type i = 0; i < sizeM; ++ i)
ref (data () [i]).clear ();
@@ -334,7 +334,7 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_INLINE
true_reference at_element (size_type i, size_type j) {
return ref (ref (data () [layout_type::element1 (i, size1_, j, size2_)]) [layout_type::element2 (i, size1_, j, size2_)]);
return ref (ref (data () [layout_type::index_M (i, j)]) [layout_type::index_m (i, j)]);
}
public:
@@ -351,19 +351,19 @@ namespace boost { namespace numeric { namespace ublas {
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const {
for (;;) {
const_vectoriterator_type itv (data ().find (layout_type::address1 (i, size1_, j, size2_)));
const_vectoriterator_type itv (data ().find (layout_type::index_M (i, j)));
const_vectoriterator_type itv_end (data ().end ());
if (itv == itv_end)
return const_iterator1 (*this, rank, i, j, itv_end, (*(-- itv)).end ());
const_subiterator_type it ((*itv).find (layout_type::address2 (i, size1_, j, size2_)));
const_subiterator_type it ((*itv).find (layout_type::index_m (i, j)));
const_subiterator_type it_end ((*itv).end ());
if (rank == 0)
return const_iterator1 (*this, rank, i, j, itv, it);
if (it != it_end && it.index () == layout_type::address2 (i, size1_, j, size2_))
if (it != it_end && it.index () == layout_type::index_m (i, j))
return const_iterator1 (*this, rank, i, j, itv, it);
if (direction > 0) {
if (layout_type::fast1 ()) {
if (layout_type::fast_i ()) {
if (it == it_end)
return const_iterator1 (*this, rank, i, j, itv, it);
i = it.index ();
@@ -373,7 +373,7 @@ namespace boost { namespace numeric { namespace ublas {
++ i;
}
} else /* if (direction < 0) */ {
if (layout_type::fast1 ()) {
if (layout_type::fast_i ()) {
if (it == (*itv).begin ())
return const_iterator1 (*this, rank, i, j, itv, it);
--it;
@@ -389,19 +389,19 @@ namespace boost { namespace numeric { namespace ublas {
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) {
for (;;) {
vectoriterator_type itv (data ().find (layout_type::address1 (i, size1_, j, size2_)));
vectoriterator_type itv (data ().find (layout_type::index_M (i, j)));
vectoriterator_type itv_end (data ().end ());
if (itv == itv_end)
return iterator1 (*this, rank, i, j, itv_end, (*(-- itv)).end ());
subiterator_type it ((*itv).find (layout_type::address2 (i, size1_, j, size2_)));
subiterator_type it ((*itv).find (layout_type::index_m (i, j)));
subiterator_type it_end ((*itv).end ());
if (rank == 0)
return iterator1 (*this, rank, i, j, itv, it);
if (it != it_end && it.index () == layout_type::address2 (i, size1_, j, size2_))
if (it != it_end && it.index () == layout_type::index_m (i, j))
return iterator1 (*this, rank, i, j, itv, it);
if (direction > 0) {
if (layout_type::fast1 ()) {
if (layout_type::fast_i ()) {
if (it == it_end)
return iterator1 (*this, rank, i, j, itv, it);
i = it.index ();
@@ -411,7 +411,7 @@ namespace boost { namespace numeric { namespace ublas {
++ i;
}
} else /* if (direction < 0) */ {
if (layout_type::fast1 ()) {
if (layout_type::fast_i ()) {
if (it == (*itv).begin ())
return iterator1 (*this, rank, i, j, itv, it);
--it;
@@ -427,19 +427,19 @@ namespace boost { namespace numeric { namespace ublas {
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const {
for (;;) {
const_vectoriterator_type itv (data ().find (layout_type::address1 (i, size1_, j, size2_)));
const_vectoriterator_type itv (data ().find (layout_type::index_M (i, j)));
const_vectoriterator_type itv_end (data ().end ());
if (itv == itv_end)
return const_iterator2 (*this, rank, i, j, itv_end, (*(-- itv)).end ());
const_subiterator_type it ((*itv).find (layout_type::address2 (i, size1_, j, size2_)));
const_subiterator_type it ((*itv).find (layout_type::index_m (i, j)));
const_subiterator_type it_end ((*itv).end ());
if (rank == 0)
return const_iterator2 (*this, rank, i, j, itv, it);
if (it != it_end && it.index () == layout_type::address2 (i, size1_, j, size2_))
if (it != it_end && it.index () == layout_type::index_m (i, j))
return const_iterator2 (*this, rank, i, j, itv, it);
if (direction > 0) {
if (layout_type::fast2 ()) {
if (layout_type::fast_j ()) {
if (it == it_end)
return const_iterator2 (*this, rank, i, j, itv, it);
j = it.index ();
@@ -449,7 +449,7 @@ namespace boost { namespace numeric { namespace ublas {
++ j;
}
} else /* if (direction < 0) */ {
if (layout_type::fast2 ()) {
if (layout_type::fast_j ()) {
if (it == (*itv).begin ())
return const_iterator2 (*this, rank, i, j, itv, it);
--it;
@@ -465,19 +465,19 @@ namespace boost { namespace numeric { namespace ublas {
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let the compiler inline it.
iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) {
for (;;) {
vectoriterator_type itv (data ().find (layout_type::address1 (i, size1_, j, size2_)));
vectoriterator_type itv (data ().find (layout_type::index_M (i, j)));
vectoriterator_type itv_end (data ().end ());
if (itv == itv_end)
return iterator2 (*this, rank, i, j, itv_end, (*(-- itv)).end ());
subiterator_type it ((*itv).find (layout_type::address2 (i, size1_, j, size2_)));
subiterator_type it ((*itv).find (layout_type::index_m (i, j)));
subiterator_type it_end ((*itv).end ());
if (rank == 0)
return iterator2 (*this, rank, i, j, itv, it);
if (it != it_end && it.index () == layout_type::address2 (i, size1_, j, size2_))
if (it != it_end && it.index () == layout_type::index_m (i, j))
return iterator2 (*this, rank, i, j, itv, it);
if (direction > 0) {
if (layout_type::fast2 ()) {
if (layout_type::fast_j ()) {
if (it == it_end)
return iterator2 (*this, rank, i, j, itv, it);
j = it.index ();
@@ -487,7 +487,7 @@ namespace boost { namespace numeric { namespace ublas {
++ j;
}
} else /* if (direction < 0) */ {
if (layout_type::fast2 ()) {
if (layout_type::fast_j ()) {
if (it == (*itv).begin ())
return iterator2 (*this, rank, i, j, itv, it);
--it;
@@ -529,7 +529,7 @@ namespace boost { namespace numeric { namespace ublas {
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator1 &operator ++ () {
if (rank_ == 1 && layout_type::fast1 ())
if (rank_ == 1 && layout_type::fast_i ())
++ it_;
else {
const self_type &m = (*this) ();
@@ -546,7 +546,7 @@ namespace boost { namespace numeric { namespace ublas {
}
BOOST_UBLAS_INLINE
const_iterator1 &operator -- () {
if (rank_ == 1 && layout_type::fast1 ())
if (rank_ == 1 && layout_type::fast_i ())
-- it_;
else {
const self_type &m = (*this) ();
@@ -612,8 +612,8 @@ namespace boost { namespace numeric { namespace ublas {
size_type index1 () const {
BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ());
if (rank_ == 1) {
BOOST_UBLAS_CHECK (layout_type::index1 (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ());
return layout_type::index1 (itv_.index (), it_.index ());
BOOST_UBLAS_CHECK (layout_type::index_M (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ());
return layout_type::index_M (itv_.index (), it_.index ());
} else {
return i_;
}
@@ -622,8 +622,8 @@ namespace boost { namespace numeric { namespace ublas {
size_type index2 () const {
BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ());
if (rank_ == 1) {
BOOST_UBLAS_CHECK (layout_type::index2 (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ());
return layout_type::index2 (itv_.index (), it_.index ());
BOOST_UBLAS_CHECK (layout_type::index_m (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ());
return layout_type::index_m (itv_.index (), it_.index ());
} else {
return j_;
}
@@ -694,7 +694,7 @@ namespace boost { namespace numeric { namespace ublas {
// Arithmetic
BOOST_UBLAS_INLINE
iterator1 &operator ++ () {
if (rank_ == 1 && layout_type::fast1 ())
if (rank_ == 1 && layout_type::fast_i ())
++ it_;
else {
self_type &m = (*this) ();
@@ -711,7 +711,7 @@ namespace boost { namespace numeric { namespace ublas {
}
BOOST_UBLAS_INLINE
iterator1 &operator -- () {
if (rank_ == 1 && layout_type::fast1 ())
if (rank_ == 1 && layout_type::fast_i ())
-- it_;
else {
self_type &m = (*this) ();
@@ -777,8 +777,8 @@ namespace boost { namespace numeric { namespace ublas {
size_type index1 () const {
BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ());
if (rank_ == 1) {
BOOST_UBLAS_CHECK (layout_type::index1 (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ());
return layout_type::index1 (itv_.index (), it_.index ());
BOOST_UBLAS_CHECK (layout_type::index_M (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ());
return layout_type::index_M (itv_.index (), it_.index ());
} else {
return i_;
}
@@ -787,8 +787,8 @@ namespace boost { namespace numeric { namespace ublas {
size_type index2 () const {
BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ());
if (rank_ == 1) {
BOOST_UBLAS_CHECK (layout_type::index2 (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ());
return layout_type::index2 (itv_.index (), it_.index ());
BOOST_UBLAS_CHECK (layout_type::index_m (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ());
return layout_type::index_m (itv_.index (), it_.index ());
} else {
return j_;
}
@@ -864,7 +864,7 @@ namespace boost { namespace numeric { namespace ublas {
// Arithmetic
BOOST_UBLAS_INLINE
const_iterator2 &operator ++ () {
if (rank_ == 1 && layout_type::fast2 ())
if (rank_ == 1 && layout_type::fast_j ())
++ it_;
else {
const self_type &m = (*this) ();
@@ -881,7 +881,7 @@ namespace boost { namespace numeric { namespace ublas {
}
BOOST_UBLAS_INLINE
const_iterator2 &operator -- () {
if (rank_ == 1 && layout_type::fast2 ())
if (rank_ == 1 && layout_type::fast_j ())
-- it_;
else {
const self_type &m = (*this) ();
@@ -947,8 +947,8 @@ namespace boost { namespace numeric { namespace ublas {
size_type index1 () const {
BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ());
if (rank_ == 1) {
BOOST_UBLAS_CHECK (layout_type::index1 (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ());
return layout_type::index1 (itv_.index (), it_.index ());
BOOST_UBLAS_CHECK (layout_type::index_M (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ());
return layout_type::index_M (itv_.index (), it_.index ());
} else {
return i_;
}
@@ -957,8 +957,8 @@ namespace boost { namespace numeric { namespace ublas {
size_type index2 () const {
BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ());
if (rank_ == 1) {
BOOST_UBLAS_CHECK (layout_type::index2 (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ());
return layout_type::index2 (itv_.index (), it_.index ());
BOOST_UBLAS_CHECK (layout_type::index_m (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ());
return layout_type::index_m (itv_.index (), it_.index ());
} else {
return j_;
}
@@ -1029,7 +1029,7 @@ namespace boost { namespace numeric { namespace ublas {
// Arithmetic
BOOST_UBLAS_INLINE
iterator2 &operator ++ () {
if (rank_ == 1 && layout_type::fast2 ())
if (rank_ == 1 && layout_type::fast_j ())
++ it_;
else {
self_type &m = (*this) ();
@@ -1046,7 +1046,7 @@ namespace boost { namespace numeric { namespace ublas {
}
BOOST_UBLAS_INLINE
iterator2 &operator -- () {
if (rank_ == 1 && layout_type::fast2 ())
if (rank_ == 1 && layout_type::fast_j ())
-- it_;
else {
self_type &m = (*this) ();
@@ -1112,8 +1112,8 @@ namespace boost { namespace numeric { namespace ublas {
size_type index1 () const {
BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ());
if (rank_ == 1) {
BOOST_UBLAS_CHECK (layout_type::index1 (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ());
return layout_type::index1 (itv_.index (), it_.index ());
BOOST_UBLAS_CHECK (layout_type::index_M (itv_.index (), it_.index ()) < (*this) ().size1 (), bad_index ());
return layout_type::index_M (itv_.index (), it_.index ());
} else {
return i_;
}
@@ -1122,8 +1122,8 @@ namespace boost { namespace numeric { namespace ublas {
size_type index2 () const {
BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ());
if (rank_ == 1) {
BOOST_UBLAS_CHECK (layout_type::index2 (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ());
return layout_type::index2 (itv_.index (), it_.index ());
BOOST_UBLAS_CHECK (layout_type::index_m (itv_.index (), it_.index ()) < (*this) ().size2 (), bad_index ());
return layout_type::index_m (itv_.index (), it_.index ());
} else {
return j_;
}
@@ -1213,7 +1213,7 @@ namespace boost { namespace numeric { namespace ublas {
private:
void storage_invariants () const
{
BOOST_UBLAS_CHECK (layout_type::size1 (size1_, size2_) + 1 == data_.size (), internal_logic ());
BOOST_UBLAS_CHECK (layout_type::size_M (size1_, size2_) + 1 == data_.size (), internal_logic ());
BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ());
}