From 5cc19b0a13068eb555e94034cd3c43c4a3bbb5d2 Mon Sep 17 00:00:00 2001 From: Michael Stevens Date: Thu, 18 May 2006 16:44:57 +0000 Subject: [PATCH] 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 --- include/boost/numeric/ublas/functional.hpp | 494 +++++++++--------- include/boost/numeric/ublas/matrix.hpp | 100 ++-- include/boost/numeric/ublas/matrix_sparse.hpp | 400 +++++++------- .../boost/numeric/ublas/vector_of_vector.hpp | 130 ++--- 4 files changed, 563 insertions(+), 561 deletions(-) diff --git a/include/boost/numeric/ublas/functional.hpp b/include/boost/numeric/ublas/functional.hpp index f321b41e..f3beaf4c 100644 --- a/include/boost/numeric/ublas/functional.hpp +++ b/include/boost/numeric/ublas/functional.hpp @@ -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 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::max) () / size2, bad_size ()); - return size1 * size2; + BOOST_UBLAS_CHECK (size_j == 0 || size_i <= (std::numeric_limits::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::max) () - j) / size2, bad_index ()); - return i * size2 + j; + BOOST_UBLAS_CHECK (i <= ((std::numeric_limits::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::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::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 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 + 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 + static + BOOST_UBLAS_INLINE + void decrement_i (I &it, size_type /* size_i */, size_type size_j) { + it -= size_j; + } + template + 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 + static + BOOST_UBLAS_INLINE + void increment_j (I &it, size_type /* size_i */, size_type /* size_j */) { + ++ it; + } + template + static + BOOST_UBLAS_INLINE + void increment_j (I &it, difference_type n, size_type /* size_i */, size_type /* size_j */) { + it += n; + } + template + static + BOOST_UBLAS_INLINE + void decrement_j (I &it, size_type /* size_i */, size_type /* size_j */) { + -- it; + } + template + 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::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 - static - BOOST_UBLAS_INLINE - void increment1 (I &it, size_type /* size1 */, size_type size2) { - it += size2; - } - template - static - BOOST_UBLAS_INLINE - void decrement1 (I &it, size_type /* size1 */, size_type size2) { - it -= size2; - } - template - static - BOOST_UBLAS_INLINE - void increment2 (I &it, size_type /* size1 */, size_type /* size2 */) { - ++ it; - } - template - 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 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::max) () / size1, bad_size ()); - return size1 * size2; + BOOST_UBLAS_CHECK (size_i == 0 || size_j <= (std::numeric_limits::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::max) () - i) / size1, bad_index ()); - return i + j * size1; + BOOST_UBLAS_CHECK (j <= ((std::numeric_limits::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::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::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 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 + static + BOOST_UBLAS_INLINE + void increment_i (I &it, difference_type n, size_type /* size_i */, size_type /* size_j */) { + it += n; + } + template + static + BOOST_UBLAS_INLINE + void decrement_i (I &it, size_type /* size_i */, size_type /* size_j */) { + -- it; + } + template + static + BOOST_UBLAS_INLINE + void decrement_i (I &it, difference_type n, size_type /* size_i */, size_type /* size_j */) { + it -= n; + } + template + static + BOOST_UBLAS_INLINE + void increment_j (I &it, size_type size_i, size_type /* size_j */) { + it += size_i; + } + template + 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 + static + BOOST_UBLAS_INLINE + void decrement_j (I &it, size_type size_i, size_type /* size_j */) { + it -= size_i; + } + template + 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::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 - static - BOOST_UBLAS_INLINE - void increment1 (I &it, size_type /* size1 */, size_type /* size2 */) { - ++ it; - } - template - static - BOOST_UBLAS_INLINE - void decrement1 (I &it, size_type /* size1 */, size_type /* size2 */) { - -- it; - } - template - static - BOOST_UBLAS_INLINE - void increment2 (I &it, size_type size1, size_type /* size2 */) { - it += size1; - } - template - 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 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 @@ -1778,8 +1778,8 @@ namespace boost { namespace numeric { namespace ublas { template 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 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 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 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 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 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 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 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 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 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 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 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 diff --git a/include/boost/numeric/ublas/matrix.hpp b/include/boost/numeric/ublas/matrix.hpp index a05e31ef..68a9d3f8 100644 --- a/include/boost/numeric/ublas/matrix.hpp +++ b/include/boost/numeric/ublas/matrix.hpp @@ -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_; diff --git a/include/boost/numeric/ublas/matrix_sparse.hpp b/include/boost/numeric/ublas/matrix_sparse.hpp index 3bb02f95..3b5fb893 100644 --- a/include/boost/numeric/ublas/matrix_sparse.hpp +++ b/include/boost/numeric/ublas/matrix_sparse.hpp @@ -552,8 +552,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 = size_type (-1); size_type index2 = size_type (-1); while (rank == 1 && it != it_end) { - index1 = layout_type::index1 ((*it).first, size1_, size2_); - index2 = layout_type::index2 ((*it).first, size1_, size2_); + index1 = layout_type::index_i ((*it).first, size1_, size2_); + index2 = layout_type::index_j ((*it).first, size1_, size2_); if (direction > 0) { if ((index1 >= i && index2 == j) || (i >= size1_)) break; @@ -581,8 +581,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 = size_type (-1); size_type index2 = size_type (-1); while (rank == 1 && it != it_end) { - index1 = layout_type::index1 ((*it).first, size1_, size2_); - index2 = layout_type::index2 ((*it).first, size1_, size2_); + index1 = layout_type::index_i ((*it).first, size1_, size2_); + index2 = layout_type::index_j ((*it).first, size1_, size2_); if (direction > 0) { if ((index1 >= i && index2 == j) || (i >= size1_)) break; @@ -610,8 +610,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 = size_type (-1); size_type index2 = size_type (-1); while (rank == 1 && it != it_end) { - index1 = layout_type::index1 ((*it).first, size1_, size2_); - index2 = layout_type::index2 ((*it).first, size1_, size2_); + index1 = layout_type::index_i ((*it).first, size1_, size2_); + index2 = layout_type::index_j ((*it).first, size1_, size2_); if (direction > 0) { if ((index2 >= j && index1 == i) || (j >= size2_)) break; @@ -639,8 +639,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 = size_type (-1); size_type index2 = size_type (-1); while (rank == 1 && it != it_end) { - index1 = layout_type::index1 ((*it).first, size1_, size2_); - index2 = layout_type::index2 ((*it).first, size1_, size2_); + index1 = layout_type::index_i ((*it).first, size1_, size2_); + index2 = layout_type::index_j ((*it).first, size1_, size2_); if (direction > 0) { if ((index2 >= j && index1 == i) || (j >= size2_)) break; @@ -690,7 +690,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 *this = (*this) ().find1 (rank_, index1 () + 1, j_, 1); @@ -698,7 +698,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 *this = (*this) ().find1 (rank_, index1 () - 1, j_, -1); @@ -756,8 +756,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()); } else { return i_; } @@ -766,8 +766,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()); } else { return j_; } @@ -836,7 +836,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 *this = (*this) ().find1 (rank_, index1 () + 1, j_, 1); @@ -844,7 +844,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 *this = (*this) ().find1 (rank_, index1 () - 1, j_, -1); @@ -902,8 +902,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (*this != (*this) ().find1 (0, (*this) ().size1 (), j_), bad_index ()); if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()); } else { return i_; } @@ -912,8 +912,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index2 () const { if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()); } else { return j_; } @@ -987,7 +987,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 *this = (*this) ().find2 (rank_, i_, index2 () + 1, 1); @@ -995,7 +995,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 *this = (*this) ().find2 (rank_, i_, index2 () - 1, -1); @@ -1052,8 +1052,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()); } else { return i_; } @@ -1063,8 +1063,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()); } else { return j_; } @@ -1133,7 +1133,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 *this = (*this) ().find2 (rank_, i_, index2 () + 1, 1); @@ -1141,7 +1141,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 *this = (*this) ().find2 (rank_, i_, index2 () - 1, -1); @@ -1198,8 +1198,8 @@ namespace boost { namespace numeric { namespace ublas { size_type index1 () const { if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size1 (), bad_index ()); + return layout_type::index_i ((*it_).first, m.size1 (), m.size2 ()); } else { return i_; } @@ -1209,8 +1209,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_CHECK (*this != (*this) ().find2 (0, i_, (*this) ().size2 ()), bad_index ()); if (rank_ == 1) { const self_type &m = (*this) (); - BOOST_UBLAS_CHECK (layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*it_).first, m.size1 (), m.size2 ()); + BOOST_UBLAS_CHECK (layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()) < (*this) ().size2 (), bad_index ()); + return layout_type::index_j ((*it_).first, m.size1 (), m.size2 ()); } else { return j_; } @@ -1344,13 +1344,13 @@ namespace boost { namespace numeric { namespace ublas { mapped_vector_of_mapped_vector (): matrix_container (), size1_ (0), size2_ (0), data_ () { - data_ [layout_type::size1 (size1_, size2_)] = vector_data_value_type (); + data_ [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); } BOOST_UBLAS_INLINE mapped_vector_of_mapped_vector (size_type size1, size_type size2, size_type non_zeros = 0): matrix_container (), size1_ (size1), size2_ (size2), data_ () { - data_ [layout_type::size1 (size1_, size2_)] = vector_data_value_type (); + data_ [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); } BOOST_UBLAS_INLINE mapped_vector_of_mapped_vector (const mapped_vector_of_mapped_vector &m): @@ -1361,7 +1361,7 @@ namespace boost { namespace numeric { namespace ublas { mapped_vector_of_mapped_vector (const matrix_expression &ae, size_type non_zeros = 0): matrix_container (), size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ () { - data_ [layout_type::size1 (size1_, size2_)] = vector_data_value_type (); + data_ [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); matrix_assign (*this, ae); } @@ -1407,7 +1407,7 @@ namespace boost { namespace numeric { namespace ublas { size1_ = size1; size2_ = size2; data ().clear (); - data () [layout_type::size1 (size1_, size2_)] = vector_data_value_type (); + data () [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); } // Element support @@ -1417,8 +1417,8 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_pointer find_element (size_type i, size_type j) const { - const size_type element1 = layout_type::element1 (i, size1_, j, size2_); - const size_type element2 = layout_type::element2 (i, size1_, j, size2_); + const size_type element1 = layout_type::index_M (i, j); + const size_type element2 = layout_type::index_m (i, j); vector_const_subiterator_type itv (data ().find (element1)); if (itv == data ().end ()) return 0; @@ -1433,8 +1433,8 @@ namespace boost { namespace numeric { namespace ublas { // Element access BOOST_UBLAS_INLINE const_reference operator () (size_type i, size_type j) const { - const size_type element1 = layout_type::element1 (i, size1_, j, size2_); - const size_type element2 = layout_type::element2 (i, size1_, j, size2_); + const size_type element1 = layout_type::index_M (i, j); + const size_type element2 = layout_type::index_m (i, j); vector_const_subiterator_type itv (data ().find (element1)); if (itv == data ().end ()) return zero_; @@ -1448,8 +1448,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) { #ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE - const size_type element1 = layout_type::element1 (i, size1_, j, size2_); - const size_type element2 = layout_type::element2 (i, size1_, j, size2_); + const size_type element1 = layout_type::index_M (i, j); + const size_type element2 = layout_type::index_m (i, j); vector_data_value_type& vd (data () [element1]); std::pair ii (vd.insert (typename array_type::value_type::second_type::value_type (element2, value_type/*zero*/()))); BOOST_UBLAS_CHECK ((ii.first)->first == element2, internal_logic ()); // broken map @@ -1463,8 +1463,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE true_reference insert_element (size_type i, size_type j, const_reference t) { BOOST_UBLAS_CHECK (!find_element (i, j), bad_index ()); // duplicate element - const size_type element1 = layout_type::element1 (i, size1_, j, size2_); - const size_type element2 = layout_type::element2 (i, size1_, j, size2_); + const size_type element1 = layout_type::index_M (i, j); + const size_type element2 = layout_type::index_m (i, j); vector_data_value_type& vd (data () [element1]); std::pair ii (vd.insert (typename vector_data_value_type::value_type (element2, t))); @@ -1475,10 +1475,10 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE void erase_element (size_type i, size_type j) { - vector_subiterator_type itv (data ().find (layout_type::element1 (i, size1_, j, size2_))); + vector_subiterator_type itv (data ().find (layout_type::index_M (i, j))); if (itv == data ().end ()) return; - subiterator_type it ((*itv).second.find (layout_type::element2 (i, size1_, j, size2_))); + subiterator_type it ((*itv).second.find (layout_type::index_m (i, j))); if (it == (*itv).second.end ()) return; (*itv).second.erase (it); @@ -1488,7 +1488,7 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE void clear () { data ().clear (); - data_ [layout_type::size1 (size1_, size2_)] = vector_data_value_type (); + data_ [layout_type::size_M (size1_, size2_)] = vector_data_value_type (); } // Assignment @@ -1598,8 +1598,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE true_reference at_element (size_type i, size_type j) { - const size_type element1 = layout_type::element1 (i, size1_, j, size2_); - const size_type element2 = layout_type::element2 (i, size1_, j, size2_); + const size_type element1 = layout_type::index_M (i, j); + const size_type element2 = layout_type::index_m (i, j); vector_subiterator_type itv (data ().find (element1)); BOOST_UBLAS_CHECK (itv != data ().end(), bad_index ()); BOOST_UBLAS_CHECK ((*itv).first == element1, internal_logic ()); // broken map @@ -1625,19 +1625,19 @@ namespace boost { namespace numeric { namespace ublas { const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { - vector_const_subiterator_type itv (data ().lower_bound (layout_type::address1 (i, size1_, j, size2_))); + vector_const_subiterator_type itv (data ().lower_bound (layout_type::index_M (i, j))); vector_const_subiterator_type itv_end (data ().end ()); if (itv == itv_end) return const_iterator1 (*this, rank, i, j, itv_end, (*(-- itv)).second.end ()); - const_subiterator_type it ((*itv).second.lower_bound (layout_type::address2 (i, size1_, j, size2_))); + const_subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); const_subiterator_type it_end ((*itv).second.end ()); if (rank == 0) return const_iterator1 (*this, rank, i, j, itv, it); - if (it != it_end && (*it).first == layout_type::address2 (i, size1_, j, size2_)) + if (it != it_end && (*it).first == 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).first; @@ -1647,7 +1647,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == (*itv).second.begin ()) return const_iterator1 (*this, rank, i, j, itv, it); -- it; @@ -1664,19 +1664,19 @@ namespace boost { namespace numeric { namespace ublas { iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { - vector_subiterator_type itv (data ().lower_bound (layout_type::address1 (i, size1_, j, size2_))); + vector_subiterator_type itv (data ().lower_bound (layout_type::index_M (i, j))); vector_subiterator_type itv_end (data ().end ()); if (itv == itv_end) return iterator1 (*this, rank, i, j, itv_end, (*(-- itv)).second.end ()); - subiterator_type it ((*itv).second.lower_bound (layout_type::address2 (i, size1_, j, size2_))); + subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); subiterator_type it_end ((*itv).second.end ()); if (rank == 0) return iterator1 (*this, rank, i, j, itv, it); - if (it != it_end && (*it).first == layout_type::address2 (i, size1_, j, size2_)) + if (it != it_end && (*it).first == 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).first; @@ -1686,7 +1686,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == (*itv).second.begin ()) return iterator1 (*this, rank, i, j, itv, it); -- it; @@ -1703,19 +1703,19 @@ namespace boost { namespace numeric { namespace ublas { const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { - vector_const_subiterator_type itv (data ().lower_bound (layout_type::address1 (i, size1_, j, size2_))); + vector_const_subiterator_type itv (data ().lower_bound (layout_type::index_M (i, j))); vector_const_subiterator_type itv_end (data ().end ()); if (itv == itv_end) return const_iterator2 (*this, rank, i, j, itv_end, (*(-- itv)).second.end ()); - const_subiterator_type it ((*itv).second.lower_bound (layout_type::address2 (i, size1_, j, size2_))); + const_subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); const_subiterator_type it_end ((*itv).second.end ()); if (rank == 0) return const_iterator2 (*this, rank, i, j, itv, it); - if (it != it_end && (*it).first == layout_type::address2 (i, size1_, j, size2_)) + if (it != it_end && (*it).first == 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).first; @@ -1725,7 +1725,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == (*itv).second.begin ()) return const_iterator2 (*this, rank, i, j, itv, it); -- it; @@ -1742,19 +1742,19 @@ namespace boost { namespace numeric { namespace ublas { iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) { BOOST_UBLAS_CHECK (data ().begin () != data ().end (), internal_logic ()); for (;;) { - vector_subiterator_type itv (data ().lower_bound (layout_type::address1 (i, size1_, j, size2_))); + vector_subiterator_type itv (data ().lower_bound (layout_type::index_M (i, j))); vector_subiterator_type itv_end (data ().end ()); if (itv == itv_end) return iterator2 (*this, rank, i, j, itv_end, (*(-- itv)).second.end ()); - subiterator_type it ((*itv).second.lower_bound (layout_type::address2 (i, size1_, j, size2_))); + subiterator_type it ((*itv).second.lower_bound (layout_type::index_m (i, j))); subiterator_type it_end ((*itv).second.end ()); if (rank == 0) return iterator2 (*this, rank, i, j, itv, it); - if (it != it_end && (*it).first == layout_type::address2 (i, size1_, j, size2_)) + if (it != it_end && (*it).first == 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).first; @@ -1764,7 +1764,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == (*itv).second.begin ()) return iterator2 (*this, rank, i, j, itv, it); -- it; @@ -1805,7 +1805,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) (); @@ -1822,7 +1822,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) (); @@ -1888,8 +1888,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_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_M ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*itv_).first, (*it_).first); } else { return i_; } @@ -1897,8 +1897,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_m ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*itv_).first, (*it_).first); } else { return j_; } @@ -1969,7 +1969,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) (); @@ -1986,7 +1986,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) (); @@ -2052,8 +2052,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_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_M ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*itv_).first, (*it_).first); } else { return i_; } @@ -2061,8 +2061,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_m ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*itv_).first, (*it_).first); } else { return j_; } @@ -2138,7 +2138,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) (); @@ -2155,7 +2155,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) (); @@ -2220,8 +2220,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_M ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*itv_).first, (*it_).first); } else { return i_; } @@ -2230,8 +2230,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_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_m ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*itv_).first, (*it_).first); } else { return j_; } @@ -2302,7 +2302,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) (); @@ -2319,7 +2319,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) (); @@ -2384,8 +2384,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_M ((*itv_).first, (*it_).first) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*itv_).first, (*it_).first); } else { return i_; } @@ -2394,8 +2394,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_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*itv_).first, (*it_).first); + BOOST_UBLAS_CHECK (layout_type::index_m ((*itv_).first, (*it_).first) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*itv_).first, (*it_).first); } else { return j_; } @@ -2537,7 +2537,7 @@ namespace boost { namespace numeric { namespace ublas { matrix_container (), size1_ (0), size2_ (0), capacity_ (restrict_capacity (0)), filled1_ (1), filled2_ (0), - index1_data_ (layout_type::size1 (size1_, size2_) + 1), index2_data_ (capacity_), value_data_ (capacity_) { + index1_data_ (layout_type::size_M (size1_, size2_) + 1), index2_data_ (capacity_), value_data_ (capacity_) { index1_data_ [filled1_ - 1] = k_based (filled2_); storage_invariants (); } @@ -2546,7 +2546,7 @@ namespace boost { namespace numeric { namespace ublas { matrix_container (), size1_ (size1), size2_ (size2), capacity_ (restrict_capacity (non_zeros)), filled1_ (1), filled2_ (0), - index1_data_ (layout_type::size1 (size1_, size2_) + 1), index2_data_ (capacity_), value_data_ (capacity_) { + index1_data_ (layout_type::size_M (size1_, size2_) + 1), index2_data_ (capacity_), value_data_ (capacity_) { index1_data_ [filled1_ - 1] = k_based (filled2_); storage_invariants (); } @@ -2563,7 +2563,7 @@ namespace boost { namespace numeric { namespace ublas { compressed_matrix (const coordinate_matrix &m): matrix_container (), size1_ (m.size1()), size2_ (m.size2()), - index1_data_ (layout_type::size1 (size1_, size2_) + 1) + index1_data_ (layout_type::size_M (size1_, size2_) + 1) { m.sort(); reserve(m.nnz(), false); @@ -2572,7 +2572,7 @@ namespace boost { namespace numeric { namespace ublas { const_subiterator_type i_end = (i_start + filled2_); const_subiterator_type i = i_start; size_type r = 1; - for (; (r < layout_type::size1 (size1_, size2_)) && (i != i_end); ++r) { + for (; (r < layout_type::size_M (size1_, size2_)) && (i != i_end); ++r) { i = std::lower_bound(i, i_end, r); index1_data_[r] = k_based( i - i_start ); } @@ -2589,7 +2589,7 @@ namespace boost { namespace numeric { namespace ublas { matrix_container (), size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), capacity_ (restrict_capacity (non_zeros)), filled1_ (1), filled2_ (0), - index1_data_ (layout_type::size1 (ae ().size1 (), ae ().size2 ()) + 1), + index1_data_ (layout_type::size_M (ae ().size1 (), ae ().size2 ()) + 1), index2_data_ (capacity_), value_data_ (capacity_) { index1_data_ [filled1_ - 1] = k_based (filled2_); storage_invariants (); @@ -2659,7 +2659,7 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE void complete_index1_data () { - while (filled1_ <= layout_type::size1 (size1_, size2_)) { + while (filled1_ <= layout_type::size_M (size1_, size2_)) { this->index1_data_ [filled1_] = k_based (filled2_); ++ this->filled1_; } @@ -2686,7 +2686,7 @@ namespace boost { namespace numeric { namespace ublas { capacity_ = restrict_capacity (capacity_); filled1_ = 1; filled2_ = 0; - index1_data_.resize (layout_type::size1 (size1_, size2_) + 1); + index1_data_.resize (layout_type::size_M (size1_, size2_) + 1); index2_data_.resize (capacity_); value_data_.resize (capacity_); index1_data_ [filled1_ - 1] = k_based (filled2_); @@ -2719,8 +2719,8 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE const_pointer find_element (size_type i, size_type j) const { - size_type element1 (layout_type::element1 (i, size1_, j, size2_)); - size_type element2 (layout_type::element2 (i, size1_, j, size2_)); + size_type element1 (layout_type::index_M (i, j)); + size_type element2 (layout_type::index_m (i, j)); if (filled1_ <= element1 + 1) return 0; vector_const_subiterator_type itv (index1_data_.begin () + element1); @@ -2744,8 +2744,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE reference operator () (size_type i, size_type j) { #ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE - size_type element1 (layout_type::element1 (i, size1_, j, size2_)); - size_type element2 (layout_type::element2 (i, size1_, j, size2_)); + size_type element1 (layout_type::index_M (i, j)); + size_type element2 (layout_type::index_m (i, j)); if (filled1_ <= element1 + 1) return insert_element (i, j, value_type/*zero*/()); pointer p = find_element (i, j); @@ -2765,8 +2765,8 @@ namespace boost { namespace numeric { namespace ublas { if (filled2_ >= capacity_) reserve (2 * filled2_, true); BOOST_UBLAS_CHECK (filled2_ < capacity_, internal_logic ()); - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); while (filled1_ <= element1 + 1) { index1_data_ [filled1_] = k_based (filled2_); ++ filled1_; @@ -2793,8 +2793,8 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE void erase_element (size_type i, size_type j) { - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); if (element1 + 1 > filled1_) return; vector_subiterator_type itv (index1_data_.begin () + element1); @@ -2943,8 +2943,8 @@ namespace boost { namespace numeric { namespace ublas { if (filled2_ >= capacity_) reserve (2 * filled2_, true); BOOST_UBLAS_CHECK (filled2_ < capacity_, internal_logic ()); - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); while (filled1_ < element1 + 2) { index1_data_ [filled1_] = k_based (filled2_); ++ filled1_; @@ -3000,8 +3000,8 @@ 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 (;;) { - array_size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - array_size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + array_size_type address1 (layout_type::index_M (i, j)); + array_size_type address2 (layout_type::index_m (i, j)); vector_const_subiterator_type itv (index1_data_.begin () + (std::min) (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return const_iterator1 (*this, rank, i, j, itv, index2_data_.begin () + filled2_); @@ -3015,7 +3015,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) 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 = zero_based (*it); @@ -3025,7 +3025,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == index2_data_.begin () + zero_based (*itv)) return const_iterator1 (*this, rank, i, j, itv, it); i = zero_based (*(it - 1)); @@ -3040,8 +3040,8 @@ 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 (;;) { - array_size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - array_size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + array_size_type address1 (layout_type::index_M (i, j)); + array_size_type address2 (layout_type::index_m (i, j)); vector_subiterator_type itv (index1_data_.begin () + (std::min) (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return iterator1 (*this, rank, i, j, itv, index2_data_.begin () + filled2_); @@ -3055,7 +3055,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) 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 = zero_based (*it); @@ -3065,7 +3065,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == index2_data_.begin () + zero_based (*itv)) return iterator1 (*this, rank, i, j, itv, it); i = zero_based (*(it - 1)); @@ -3080,8 +3080,8 @@ 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 (;;) { - array_size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - array_size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + array_size_type address1 (layout_type::index_M (i, j)); + array_size_type address2 (layout_type::index_m (i, j)); vector_const_subiterator_type itv (index1_data_.begin () + (std::min) (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return const_iterator2 (*this, rank, i, j, itv, index2_data_.begin () + filled2_); @@ -3095,7 +3095,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) 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 = zero_based (*it); @@ -3105,7 +3105,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == index2_data_.begin () + zero_based (*itv)) return const_iterator2 (*this, rank, i, j, itv, it); j = zero_based (*(it - 1)); @@ -3120,8 +3120,8 @@ 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 (;;) { - array_size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - array_size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + array_size_type address1 (layout_type::index_M (i, j)); + array_size_type address2 (layout_type::index_m (i, j)); vector_subiterator_type itv (index1_data_.begin () + (std::min) (filled1_ - 1, address1)); if (filled1_ <= address1 + 1) return iterator2 (*this, rank, i, j, itv, index2_data_.begin () + filled2_); @@ -3135,7 +3135,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) 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 = zero_based (*it); @@ -3145,7 +3145,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == index2_data_.begin () + zero_based (*itv)) return iterator2 (*this, rank, i, j, itv, it); j = zero_based (*(it - 1)); @@ -3186,7 +3186,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 { i_ = index1 () + 1; @@ -3197,7 +3197,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 { i_ = index1 () - 1; @@ -3257,8 +3257,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_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return i_; } @@ -3266,8 +3266,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return j_; } @@ -3338,7 +3338,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 { i_ = index1 () + 1; @@ -3349,7 +3349,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 { i_ = index1 () - 1; @@ -3409,8 +3409,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_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return i_; } @@ -3418,8 +3418,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return j_; } @@ -3495,7 +3495,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 { j_ = index2 () + 1; @@ -3506,7 +3506,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 { j_ = index2 () - 1; @@ -3565,8 +3565,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return i_; } @@ -3575,8 +3575,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_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return j_; } @@ -3647,7 +3647,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 { j_ = index2 () + 1; @@ -3658,7 +3658,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 { j_ = index2 (); @@ -3717,8 +3717,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return i_; } @@ -3727,8 +3727,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_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m (itv_ - (*this) ().index1_data_.begin (), (*this) ().zero_based (*it_)); } else { return j_; } @@ -3817,10 +3817,10 @@ namespace boost { namespace numeric { namespace ublas { private: void storage_invariants () const { - BOOST_UBLAS_CHECK (layout_type::size1 (size1_, size2_) + 1 == index1_data_.size (), internal_logic ()); + BOOST_UBLAS_CHECK (layout_type::size_M (size1_, size2_) + 1 == index1_data_.size (), internal_logic ()); BOOST_UBLAS_CHECK (capacity_ == index2_data_.size (), internal_logic ()); BOOST_UBLAS_CHECK (capacity_ == value_data_.size (), internal_logic ()); - BOOST_UBLAS_CHECK (filled1_ > 0 && filled1_ <= layout_type::size1 (size1_, size2_) + 1, internal_logic ()); + BOOST_UBLAS_CHECK (filled1_ > 0 && filled1_ <= layout_type::size_M (size1_, size2_) + 1, internal_logic ()); BOOST_UBLAS_CHECK (filled2_ <= capacity_, internal_logic ()); BOOST_UBLAS_CHECK (index1_data_ [filled1_ - 1] == k_based (filled2_), internal_logic ()); } @@ -4045,8 +4045,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE const_pointer find_element (size_type i, size_type j) const { sort (); - size_type element1 (layout_type::element1 (i, size1_, j, size2_)); - size_type element2 (layout_type::element2 (i, size1_, j, size2_)); + size_type element1 (layout_type::index_M (i, j)); + size_type element2 (layout_type::index_m (i, j)); vector_const_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (element1), std::less ())); vector_const_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (element1), std::less ())); if (itv_begin == itv_end) @@ -4087,8 +4087,8 @@ namespace boost { namespace numeric { namespace ublas { if (filled_ >= capacity_) reserve (2 * filled_, true); BOOST_UBLAS_CHECK (filled_ < capacity_, internal_logic ()); - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); index1_data_ [filled_] = k_based (element1); index2_data_ [filled_] = k_based (element2); value_data_ [filled_] = t; @@ -4104,8 +4104,8 @@ namespace boost { namespace numeric { namespace ublas { } BOOST_UBLAS_INLINE void erase_element (size_type i, size_type j) { - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); sort (); vector_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (element1), std::less ())); vector_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (element1), std::less ())); @@ -4284,8 +4284,8 @@ namespace boost { namespace numeric { namespace ublas { // Back element insertion and erasure BOOST_UBLAS_INLINE void push_back (size_type i, size_type j, const_reference t) { - size_type element1 = layout_type::element1 (i, size1_, j, size2_); - size_type element2 = layout_type::element2 (i, size1_, j, size2_); + size_type element1 = layout_type::index_M (i, j); + size_type element2 = layout_type::index_m (i, j); // must maintain sort order BOOST_UBLAS_CHECK (sorted_ && (filled_ == 0 || @@ -4342,8 +4342,8 @@ namespace boost { namespace numeric { namespace ublas { const_iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) const { sort (); for (;;) { - size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + size_type address1 (layout_type::index_M (i, j)); + size_type address2 (layout_type::index_m (i, j)); vector_const_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); vector_const_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); @@ -4357,7 +4357,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) 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 = zero_based (*it); @@ -4367,7 +4367,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == index2_data_.begin () + zero_based (*itv)) return const_iterator1 (*this, rank, i, j, itv, it); i = zero_based (*(it - 1)); @@ -4383,8 +4383,8 @@ namespace boost { namespace numeric { namespace ublas { iterator1 find1 (int rank, size_type i, size_type j, int direction = 1) { sort (); for (;;) { - size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + size_type address1 (layout_type::index_M (i, j)); + size_type address2 (layout_type::index_m (i, j)); vector_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); vector_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); @@ -4398,7 +4398,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) 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 = zero_based (*it); @@ -4408,7 +4408,7 @@ namespace boost { namespace numeric { namespace ublas { ++ i; } } else /* if (direction < 0) */ { - if (layout_type::fast1 ()) { + if (layout_type::fast_i ()) { if (it == index2_data_.begin () + zero_based (*itv)) return iterator1 (*this, rank, i, j, itv, it); i = zero_based (*(it - 1)); @@ -4424,8 +4424,8 @@ namespace boost { namespace numeric { namespace ublas { const_iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) const { sort (); for (;;) { - size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + size_type address1 (layout_type::index_M (i, j)); + size_type address2 (layout_type::index_m (i, j)); vector_const_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); vector_const_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); @@ -4439,7 +4439,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) 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 = zero_based (*it); @@ -4449,7 +4449,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == index2_data_.begin () + zero_based (*itv)) return const_iterator2 (*this, rank, i, j, itv, it); j = zero_based (*(it - 1)); @@ -4465,8 +4465,8 @@ namespace boost { namespace numeric { namespace ublas { iterator2 find2 (int rank, size_type i, size_type j, int direction = 1) { sort (); for (;;) { - size_type address1 (layout_type::address1 (i, size1_, j, size2_)); - size_type address2 (layout_type::address2 (i, size1_, j, size2_)); + size_type address1 (layout_type::index_M (i, j)); + size_type address2 (layout_type::index_m (i, j)); vector_subiterator_type itv_begin (detail::lower_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); vector_subiterator_type itv_end (detail::upper_bound (index1_data_.begin (), index1_data_.begin () + filled_, k_based (address1), std::less ())); @@ -4480,7 +4480,7 @@ namespace boost { namespace numeric { namespace ublas { if (it != it_end && zero_based (*it) == address2) 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 = zero_based (*it); @@ -4490,7 +4490,7 @@ namespace boost { namespace numeric { namespace ublas { ++ j; } } else /* if (direction < 0) */ { - if (layout_type::fast2 ()) { + if (layout_type::fast_j ()) { if (it == index2_data_.begin () + zero_based (*itv)) return iterator2 (*this, rank, i, j, itv, it); j = zero_based (*(it - 1)); @@ -4531,7 +4531,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 { i_ = index1 () + 1; @@ -4542,7 +4542,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 { i_ = index1 () - 1; @@ -4602,8 +4602,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 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return i_; } @@ -4611,8 +4611,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return j_; } @@ -4683,7 +4683,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 { i_ = index1 () + 1; @@ -4694,7 +4694,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 { i_ = index1 () - 1; @@ -4754,8 +4754,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 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return i_; } @@ -4763,8 +4763,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index2 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return j_; } @@ -4840,7 +4840,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 { j_ = index2 () + 1; @@ -4851,7 +4851,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 { j_ = index2 () - 1; @@ -4910,8 +4910,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return i_; } @@ -4920,8 +4920,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 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return j_; } @@ -4992,7 +4992,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 { j_ = index2 () + 1; @@ -5003,7 +5003,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 { j_ = index2 (); @@ -5062,8 +5062,8 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE size_type index1 () const { if (rank_ == 1) { - BOOST_UBLAS_CHECK (layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); - return layout_type::index1 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size1 (), bad_index ()); + return layout_type::index_M ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return i_; } @@ -5072,8 +5072,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 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); - return layout_type::index2 ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); + BOOST_UBLAS_CHECK (layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)) < (*this) ().size2 (), bad_index ()); + return layout_type::index_m ((*this) ().zero_based (*itv_), (*this) ().zero_based (*it_)); } else { return j_; } diff --git a/include/boost/numeric/ublas/vector_of_vector.hpp b/include/boost/numeric/ublas/vector_of_vector.hpp index bbc48cc7..3a1f6fb8 100644 --- a/include/boost/numeric/ublas/vector_of_vector.hpp +++ b/include/boost/numeric/ublas/vector_of_vector.hpp @@ -64,7 +64,7 @@ namespace boost { namespace numeric { namespace ublas { generalized_vector_of_vector (): matrix_container (), 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 (), - 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, size_type non_zeros = 0): matrix_container (), - 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::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 ()); }