diff --git a/doc/index.htm b/doc/index.htm index 9a70499d..d6d3b28a 100644 --- a/doc/index.htm +++ b/doc/index.htm @@ -103,6 +103,10 @@ href="http://www.netlib.org/clapack">CLAPACK test suite.
type="circle">The templated class sparse_matrix<T, F, A> is
the base container adaptor for sparse matrices. For a (m x n)-dimensional
sparse matrix and 0 <= i < m, 0 <= j < n
-every non-zero element mi, j is
-mapped to the (i x n + j)-th element of the container
-for row major orientation or the (i + j x m)-th element
-of the container for column major orientation.
Frow_majorAmap_array<std::size_t, T>[1] Supported parameters for the storage organization are
-row_major and column_major.
[1] Supported parameters for
+the storage organization are row_major and column_major.
[2] Supported parameters for the adapted array are
-map_array<std::size_t, T> and std::map<std::size_t, T>.
-
[2] Supported parameters for
+the adapted array are map_array<std::size_t, T>
+and std::map<std::size_t, T>.
The templated class compressed_matrix<T, F, IB, IA,
+TA> is the base container adaptor for compressed
+matrices. For a (m x n)-dimensional compressed matrix
+and 0 <= i < m, 0 <= j < n the
+non-zero elements mi, j are mapped
+via (i x n + j) for row major orientation or via (i
++ j x m) for column major orientation to consecutive
+elements of the index and value containers, i.e. for elements k
+= mi1,j1
+and k + 1 = mi2,j2
+of the container holds i1
+< i2 or (i1
+= i2 and j1
+< j2) with row major
+orientation or j1 < j2
+or (j1 = j2 and
+i1 < i2)
+with column major orientation.
int main () {
+ using namespace boost::numeric::ublas;
+ compressed_matrix<double> m (3, 3, 3 * 3);
+ for (int i = 0; i < m.size1 (); ++ i)
+ for (int j = 0; j < m.size2 (); ++ j)
+ m (i, j) = 3 * i + j;
+ std::cout << m << std::endl;
+}
+
+Defined in the header matrix_sparse.hpp.
+ +| Parameter | +Description | +Default | +
|---|---|---|
T |
+ The type of object stored in the compressed matrix. | ++ |
F |
+ Functor describing the storage organization. [1] | +row_major |
+
IB |
+ The index base of the compressed vector. [2] | +0 |
+
IA |
+ The type of the adapted array for indices. [3] | +unbounded_array<std::size_t> |
+
TA |
+ The type of the adapted array for values. [3] | +unbounded_array<T> |
+
None, except for those imposed by the requirements of Matrix.
+ +matrix_expression<compressed_matrix<T, F, IB, IA,
+TA> >
| Member | +Description | +
|---|---|
compressed_matrix () |
+ Allocates a compressed_matrix that holds
+ at most zero rows of zero elements. |
+
compressed_matrix (size_type size1, size_type2,
+ size_type non_zeros) |
+ Allocates a compressed_matrix that holds
+ at most size1 rows of size2 elements. |
+
compressed_matrix (const compressed_matrix
+ &m) |
+ The copy constructor. | +
template<class AE> |
+ The extended copy constructor. | +
void resize (size_type size1, size_type size2,
+ size_type non_zeros) |
+ Reallocates a compressed_matrix to hold
+ at most size1 rows of size2 elements.
+ The content of the compressed_matrix is
+ preserved. |
+
size_type size1 () const |
+ Returns the number of rows. | +
size_type size2 () const |
+ Returns the number of columns. | +
const_reference operator () (size_type i,
+ size_type j) const |
+ Returns the value of the j-th element in
+ the i-th row. |
+
reference operator () (size_type i, size_type
+ j) |
+ Returns a reference of the j-th element
+ in the i-th row. |
+
compressed_matrix &operator = (const
+ compressed_matrix &m) |
+ The assignment operator. | +
compressed_matrix &assign_temporary
+ (compressed_matrix &m) |
+ Assigns a temporary. May change the compressed matrix
+ m. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a matrix expression to the compressed matrix. + Left and right hand side of the assignment should be + independent. | +
template<class AE> |
+ A computed assignment operator. Adds the matrix + expression to the compressed matrix. | +
template<class AE> |
+ Adds a matrix expression to the compressed matrix. + Left and right hand side of the assignment should be + independent. | +
template<class AE> |
+ A computed assignment operator. Subtracts the matrix + expression from the compressed matrix. | +
template<class AE> |
+ Subtracts a matrix expression from the compressed + matrix. Left and right hand side of the assignment should + be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the + compressed matrix with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the + compressed matrix through a scalar. | +
void swap (compressed_matrix &m) |
+ Swaps the contents of the compressed matrices. | +
void insert (size_type i, size_type j,
+ const_reference t) |
+ Inserts the value t at the j-th
+ element of the i-th row. |
+
void erase (size_type i, size_type j) |
+ Erases the value at the j-th element of
+ the i-th row. |
+
void clear () |
+ Clears the compressed matrix. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to
+ the beginning of the compressed_matrix. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to
+ the end of the compressed_matrix. |
+
iterator1 begin1 () |
+ Returns a iterator1 pointing to the
+ beginning of the compressed_matrix. |
+
iterator1 end1 () |
+ Returns a iterator1 pointing to the end
+ of the compressed_matrix. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to
+ the beginning of the compressed_matrix. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to
+ the end of the compressed_matrix. |
+
iterator2 begin2 () |
+ Returns a iterator2 pointing to the
+ beginning of the compressed_matrix. |
+
iterator2 end2 () |
+ Returns a iterator2 pointing to the end
+ of the compressed_matrix. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1
+ pointing to the beginning of the reversed compressed_matrix.
+ |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1
+ pointing to the end of the reversed compressed_matrix.
+ |
+
reverse_iterator1 rbegin1 () |
+ Returns a reverse_iterator1 pointing to
+ the beginning of the reversed compressed_matrix.
+ |
+
reverse_iterator1 rend1 () |
+ Returns a reverse_iterator1 pointing to
+ the end of the reversed compressed_matrix. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2
+ pointing to the beginning of the reversed compressed_matrix.
+ |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2
+ pointing to the end of the reversed compressed_matrix.
+ |
+
reverse_iterator2 rbegin2 () |
+ Returns a reverse_iterator2 pointing to
+ the beginning of the reversed compressed_matrix.
+ |
+
reverse_iterator2 rend2 () |
+ Returns a reverse_iterator2 pointing to
+ the end of the reversed compressed_matrix. |
+
[1] Supported parameters
+for the storage organization are row_major and column_major.
[2] Supported parameters
+for the index base are 0 and 1 at
+least.
[3] Supported parameters
+for the adapted array are unbounded_array<>, bounded_array<>
+and std::vector<>.
// Array based sparse matrix class
+ template<class T, class F, std::size_t IB, class IA, class TA>
+ class compressed_matrix:
+ public matrix_expression<compressed_matrix<T, F, IB, IA, TA> > {
+ public:
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef T value_type;
+ typedef const T &const_reference;
+ typedef T &reference;
+ typedef const T *const_pointer;
+ typedef T *pointer;
+ typedef F functor_type;
+ typedef IA index_array_type;
+ typedef TA value_array_type;
+ typedef const compressed_matrix<T, F, IB, IA, TA> const_self_type;
+ typedef compressed_matrix<T, F, IB, IA, TA> self_type;
+ typedef const matrix_const_reference<const_self_type> const_closure_type;
+ typedef matrix_reference<self_type> closure_type;
+ typedef typename A::const_iterator const_iterator_type;
+ typedef typename A::iterator iterator_type;
+ typedef sparse_tag storage_category;
+ typedef typename F::orientation_category orientation_category;
+
+ // Construction and destruction
+ compressed_matrix ();
+ compressed_matrix (size_type size1, size_type size2, size_type non_zeros = 0);
+ compressed_matrix (const compressed_matrix &m);
+ template<class AE>
+ compressed_matrix (const matrix_expression<AE> &ae, size_type non_zeros = 0);
+
+ // Accessors
+ size_type size1 () const;
+ size_type size2 () const;
+ size_type non_zeros () const;
+ static size_type index_base ();
+ const index_array_type &index1_data () const;
+ index_array_type &index1_data ();
+ const index_array_type &index2_data () const;
+ index_array_type &index2_data ();
+ const value_array_type &value_data () const;
+ value_array_type &value_data ();
+
+ // Resizing
+ void resize (size_type size1, size_type size2, size_type non_zeros = 0);
+
+ // Element access
+ const_reference operator () (size_type i, size_type j) const;
+ reference operator () (size_type i, size_type j);
+
+ // Assignment
+ compressed_matrix &operator = (const compressed_matrix &m);
+ compressed_matrix &assign_temporary (compressed_matrix &m);
+ template<class AE>
+ compressed_matrix &operator = (const matrix_expression<AE> &ae);
+ template<class AE>
+ compressed_matrix &reset (const matrix_expression<AE> &ae);
+ template<class AE>
+ compressed_matrix &assign (const matrix_expression<AE> &ae);
+ template<class AE>
+ compressed_matrix& operator += (const matrix_expression<AE> &ae);
+ template<class AE>
+ compressed_matrix &plus_assign (const matrix_expression<AE> &ae);
+ template<class AE>
+ compressed_matrix& operator -= (const matrix_expression<AE> &ae);
+ template<class AE>
+ compressed_matrix &minus_assign (const matrix_expression<AE> &ae);
+ template<class AT>
+ compressed_matrix& operator *= (const AT &at);
+ template<class AT>
+ compressed_matrix& operator /= (const AT &at);
+
+ // Swapping
+ void swap (compressed_matrix &m);
+ friend void swap (compressed_matrix &m1, compressed_matrix &m2);
+
+ // Element insertion and erasure
+ void insert (size_type i, size_type j, const_reference t);
+ void erase (size_type i, size_type j);
+ void clear ();
+
+ class const_iterator1;
+ class iterator1;
+ class const_iterator2;
+ class iterator2;
+ typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
+ typedef reverse_iterator_base1<iterator1> reverse_iterator1;
+ typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
+ typedef reverse_iterator_base2<iterator2> reverse_iterator2;
+
+ // Element lookup
+ const_iterator1 find1 (int rank, size_type i, size_type j) const;
+ iterator1 find1 (int rank, size_type i, size_type j);
+ const_iterator2 find2 (int rank, size_type i, size_type j) const;
+ iterator2 find2 (int rank, size_type i, size_type j);
+ const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
+ iterator1 find_first1 (int rank, size_type i, size_type j);
+ const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
+ iterator1 find_last1 (int rank, size_type i, size_type j);
+ const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
+ iterator2 find_first2 (int rank, size_type i, size_type j);
+ const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
+ iterator2 find_last2 (int rank, size_type i, size_type j);
+
+ // Iterators simply are pointers.
+
+ class const_iterator1:
+ public container_const_reference<compressed_matrix>,
+ public bidirectional_iterator_base<const_iterator1, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename compressed_matrix::difference_type difference_type;
+ typedef typename compressed_matrix::value_type value_type;
+ typedef typename compressed_matrix::const_reference reference;
+ typedef typename compressed_matrix::const_pointer pointer;
+ typedef const_iterator2 dual_iterator_type;
+ typedef const_reverse_iterator2 dual_reverse_iterator_type;
+ typedef typename functor_type::functor1_type functor1_type;
+
+ // Construction and destruction
+ const_iterator1 ();
+ const_iterator1 (const compressed_matrix &m, int rank, size_type i, size_type j, const const_iterator_type &it);
+ const_iterator1 (const iterator1 &it);
+
+ // Arithmetic
+ const_iterator1 &operator ++ ();
+ const_iterator1 &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ const_iterator2 begin () const;
+ const_iterator2 end () const;
+ const_reverse_iterator2 rbegin () const;
+ const_reverse_iterator2 rend () const;
+
+ // Indices
+ size_type index1 () const;
+ size_type index2 () const;
+
+ // Assignment
+ const_iterator1 &operator = (const const_iterator1 &it);
+
+ // Comparison
+ bool operator == (const const_iterator1 &it) const;
+ };
+
+ const_iterator1 begin1 () const;
+ const_iterator1 end1 () const;
+
+ class iterator1:
+ public container_reference<compressed_matrix>,
+ public bidirectional_iterator_base<iterator1, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename compressed_matrix::difference_type difference_type;
+ typedef typename compressed_matrix::value_type value_type;
+ typedef typename compressed_matrix::reference reference;
+ typedef typename compressed_matrix::pointer pointer;
+ typedef iterator2 dual_iterator_type;
+ typedef reverse_iterator2 dual_reverse_iterator_type;
+ typedef typename functor_type::functor1_type functor1_type;
+
+ // Construction and destruction
+ iterator1 ();
+ iterator1 (compressed_matrix &m, int rank, size_type i, size_type j, const iterator_type &it);
+
+ // Arithmetic
+ iterator1 &operator ++ ();
+ iterator1 &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ iterator2 begin () const;
+ iterator2 end () const;
+ reverse_iterator2 rbegin () const;
+ reverse_iterator2 rend () const;
+
+ // Indices
+ size_type index1 () const;
+ size_type index2 () const;
+
+ // Assignment
+ iterator1 &operator = (const iterator1 &it);
+
+ // Comparison
+ bool operator == (const iterator1 &it) const;
+ };
+
+ iterator1 begin1 ();
+ iterator1 end1 ();
+
+ class const_iterator2:
+ public container_const_reference<compressed_matrix>,
+ public bidirectional_iterator_base<const_iterator2, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename compressed_matrix::difference_type difference_type;
+ typedef typename compressed_matrix::value_type value_type;
+ typedef typename compressed_matrix::const_reference reference;
+ typedef typename compressed_matrix::const_pointer pointer;
+ typedef const_iterator1 dual_iterator_type;
+ typedef const_reverse_iterator1 dual_reverse_iterator_type;
+ typedef typename functor_type::functor2_type functor2_type;
+
+ // Construction and destruction
+ const_iterator2 ();
+ const_iterator2 (const compressed_matrix &m, int rank, size_type i, size_type j, const const_iterator_type &it);
+ const_iterator2 (const iterator2 &it);
+
+ // Arithmetic
+ const_iterator2 &operator ++ ();
+ const_iterator2 &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ const_iterator1 begin () const;
+ const_iterator1 end () const;
+ const_reverse_iterator1 rbegin () const;
+ const_reverse_iterator1 rend () const;
+
+ // Indices
+ size_type index1 () const;
+ size_type index2 () const;
+
+ // Assignment
+ const_iterator2 &operator = (const const_iterator2 &it);
+
+ // Comparison
+ bool operator == (const const_iterator2 &it) const;
+ };
+
+ const_iterator2 begin2 () const;
+ const_iterator2 end2 () const;
+
+ class iterator2:
+ public container_reference<compressed_matrix>,
+ public bidirectional_iterator_base<iterator2, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename compressed_matrix::difference_type difference_type;
+ typedef typename compressed_matrix::value_type value_type;
+ typedef typename compressed_matrix::reference reference;
+ typedef typename compressed_matrix::pointer pointer;
+ typedef iterator1 dual_iterator_type;
+ typedef reverse_iterator1 dual_reverse_iterator_type;
+ typedef typename functor_type::functor2_type functor2_type;
+
+ // Construction and destruction
+ iterator2 ();
+ iterator2 (compressed_matrix &m, int rank, size_type i, size_type j, const iterator_type &it);
+
+ // Arithmetic
+ iterator2 &operator ++ ();
+ iterator2 &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ iterator1 begin () const;
+ iterator1 end () const;
+ reverse_iterator1 rbegin () const;
+ reverse_iterator1 rend () const;
+
+ // Indices
+ size_type index1 () const;
+ size_type index2 () const;
+
+ // Assignment
+ iterator2 &operator = (const iterator2 &it);
+
+ // Comparison
+ bool operator == (const iterator2 &it) const;
+ };
+
+ iterator2 begin2 ();
+ iterator2 end2 ();
+
+ // Reverse iterators
+
+ const_reverse_iterator1 rbegin1 () const;
+ const_reverse_iterator1 rend1 () const;
+
+ reverse_iterator1 rbegin1 ();
+ reverse_iterator1 rend1 ();
+
+ const_reverse_iterator2 rbegin2 () const;
+ const_reverse_iterator2 rend2 () const;
+
+ reverse_iterator2 rbegin2 ();
+ reverse_iterator2 rend2 ();
+ };
+
+The templated class coordinate_matrix<T, F, IB, IA,
+TA> is the base container adaptor for compressed
+matrices. For a (m x n)-dimensional sorted coordinate
+matrix and 0 <= i < m, 0 <= j < n
+the non-zero elements mi, j are
+mapped via (i x n + j) for row major orientation or via (i
++ j x m) for column major orientation to consecutive
+elements of the index and value containers, i.e. for elements k
+= mi1,j1
+and k + 1 = mi2,j2
+of the container holds i1
+< i2 or (i1
+= i2 and j1
+< j2) with row major
+orientation or j1 < j2
+or (j1 = j2 and
+i1 < i2)
+with column major orientation.
int main () {
+ using namespace boost::numeric::ublas;
+ coordinate_matrix<double> m (3, 3, 3 * 3);
+ for (int i = 0; i < m.size1 (); ++ i)
+ for (int j = 0; j < m.size2 (); ++ j)
+ m (i, j) = 3 * i + j;
+ std::cout << m << std::endl;
+}
+
+Defined in the header matrix_sparse.hpp.
+ +| Parameter | +Description | +Default | +
|---|---|---|
T |
+ The type of object stored in the coordinate matrix. | ++ |
F |
+ Functor describing the storage organization. [1] | +row_major |
+
IB |
+ The index base of the coordinate vector. [2] | +0 |
+
IA |
+ The type of the adapted array for indices. [3] | +unbounded_array<std::size_t> |
+
TA |
+ The type of the adapted array for values. [3] | +unbounded_array<T> |
+
None, except for those imposed by the requirements of Matrix.
+ +matrix_expression<coordinate_matrix<T, F, IB, IA,
+TA> >
| Member | +Description | +
|---|---|
coordinate_matrix () |
+ Allocates a coordinate_matrix that holds
+ at most zero rows of zero elements. |
+
coordinate_matrix (size_type size1, size_type2,
+ size_type non_zeros) |
+ Allocates a coordinate_matrix that holds
+ at most size1 rows of size2 elements. |
+
coordinate_matrix (const coordinate_matrix
+ &m) |
+ The copy constructor. | +
template<class AE> |
+ The extended copy constructor. | +
void resize (size_type size1, size_type size2,
+ size_type non_zeros) |
+ Reallocates a coordinate_matrix to hold
+ at most size1 rows of size2 elements.
+ The content of the coordinate_matrix is
+ preserved. |
+
size_type size1 () const |
+ Returns the number of rows. | +
size_type size2 () const |
+ Returns the number of columns. | +
const_reference operator () (size_type i,
+ size_type j) const |
+ Returns the value of the j-th element in
+ the i-th row. |
+
reference operator () (size_type i, size_type
+ j) |
+ Returns a reference of the j-th element
+ in the i-th row. |
+
coordinate_matrix &operator = (const
+ coordinate_matrix &m) |
+ The assignment operator. | +
coordinate_matrix &assign_temporary
+ (coordinate_matrix &m) |
+ Assigns a temporary. May change the coordinate matrix
+ m. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a matrix expression to the coordinate matrix. + Left and right hand side of the assignment should be + independent. | +
template<class AE> |
+ A computed assignment operator. Adds the matrix + expression to the coordinate matrix. | +
template<class AE> |
+ Adds a matrix expression to the coordinate matrix. + Left and right hand side of the assignment should be + independent. | +
template<class AE> |
+ A computed assignment operator. Subtracts the matrix + expression from the coordinate matrix. | +
template<class AE> |
+ Subtracts a matrix expression from the coordinate + matrix. Left and right hand side of the assignment should + be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the + coordinate matrix with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the + coordinate matrix through a scalar. | +
void swap (coordinate_matrix &m) |
+ Swaps the contents of the coordinate matrices. | +
void insert (size_type i, size_type j,
+ const_reference t) |
+ Inserts the value t at the j-th
+ element of the i-th row. |
+
void erase (size_type i, size_type j) |
+ Erases the value at the j-th element of
+ the i-th row. |
+
void clear () |
+ Clears the coordinate matrix. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to
+ the beginning of the coordinate_matrix. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to
+ the end of the coordinate_matrix. |
+
iterator1 begin1 () |
+ Returns a iterator1 pointing to the
+ beginning of the coordinate_matrix. |
+
iterator1 end1 () |
+ Returns a iterator1 pointing to the end
+ of the coordinate_matrix. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to
+ the beginning of the coordinate_matrix. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to
+ the end of the coordinate_matrix. |
+
iterator2 begin2 () |
+ Returns a iterator2 pointing to the
+ beginning of the coordinate_matrix. |
+
iterator2 end2 () |
+ Returns a iterator2 pointing to the end
+ of the coordinate_matrix. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1
+ pointing to the beginning of the reversed coordinate_matrix.
+ |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1
+ pointing to the end of the reversed coordinate_matrix.
+ |
+
reverse_iterator1 rbegin1 () |
+ Returns a reverse_iterator1 pointing to
+ the beginning of the reversed coordinate_matrix.
+ |
+
reverse_iterator1 rend1 () |
+ Returns a reverse_iterator1 pointing to
+ the end of the reversed coordinate_matrix. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2
+ pointing to the beginning of the reversed coordinate_matrix.
+ |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2
+ pointing to the end of the reversed coordinate_matrix.
+ |
+
reverse_iterator2 rbegin2 () |
+ Returns a reverse_iterator2 pointing to
+ the beginning of the reversed coordinate_matrix.
+ |
+
reverse_iterator2 rend2 () |
+ Returns a reverse_iterator2 pointing to
+ the end of the reversed coordinate_matrix. |
+
[1] Supported parameters
+for the storage organization are row_major and column_major.
[2] Supported parameters
+for the index base are 0 and 1 at
+least.
[3] Supported parameters
+for the adapted array are unbounded_array<>, bounded_array<>
+and std::vector<>.
// Array based sparse matrix class
+ template<class T, class F, std::size_t IB, class IA, class TA>
+ class coordinate_matrix:
+ public matrix_expression<coordinate_matrix<T, F, IB, IA, TA> > {
+ public:
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef T value_type;
+ typedef const T &const_reference;
+ typedef T &reference;
+ typedef const T *const_pointer;
+ typedef T *pointer;
+ typedef F functor_type;
+ typedef IA index_array_type;
+ typedef TA value_array_type;
+ typedef const coordinate_matrix<T, F, IB, IA, TA> const_self_type;
+ typedef coordinate_matrix<T, F, IB, IA, TA> self_type;
+ typedef const matrix_const_reference<const_self_type> const_closure_type;
+ typedef matrix_reference<self_type> closure_type;
+ typedef typename A::const_iterator const_iterator_type;
+ typedef typename A::iterator iterator_type;
+ typedef sparse_tag storage_category;
+ typedef typename F::orientation_category orientation_category;
+
+ // Construction and destruction
+ coordinate_matrix ();
+ coordinate_matrix (size_type size1, size_type size2, size_type non_zeros = 0);
+ coordinate_matrix (const coordinate_matrix &m);
+ template<class AE>
+ coordinate_matrix (const matrix_expression<AE> &ae, size_type non_zeros = 0);
+
+ // Accessors
+ size_type size1 () const;
+ size_type size2 () const;
+ size_type non_zeros () const;
+ static size_type index_base ();
+ const index_array_type &index1_data () const;
+ index_array_type &index1_data ();
+ const index_array_type &index2_data () const;
+ index_array_type &index2_data ();
+ const value_array_type &value_data () const;
+ value_array_type &value_data ();
+
+ // Resizing
+ void resize (size_type size1, size_type size2, size_type non_zeros = 0);
+
+ // Element access
+ const_reference operator () (size_type i, size_type j) const;
+ reference operator () (size_type i, size_type j);
+
+ // Assignment
+ coordinate_matrix &operator = (const coordinate_matrix &m);
+ coordinate_matrix &assign_temporary (coordinate_matrix &m);
+ template<class AE>
+ coordinate_matrix &operator = (const matrix_expression<AE> &ae);
+ template<class AE>
+ coordinate_matrix &reset (const matrix_expression<AE> &ae);
+ template<class AE>
+ coordinate_matrix &assign (const matrix_expression<AE> &ae);
+ template<class AE>
+ coordinate_matrix& operator += (const matrix_expression<AE> &ae);
+ template<class AE>
+ coordinate_matrix &plus_assign (const matrix_expression<AE> &ae);
+ template<class AE>
+ coordinate_matrix& operator -= (const matrix_expression<AE> &ae);
+ template<class AE>
+ coordinate_matrix &minus_assign (const matrix_expression<AE> &ae);
+ template<class AT>
+ coordinate_matrix& operator *= (const AT &at);
+ template<class AT>
+ coordinate_matrix& operator /= (const AT &at);
+
+ // Swapping
+ void swap (coordinate_matrix &m);
+ friend void swap (coordinate_matrix &m1, coordinate_matrix &m2);
+
+ // Element insertion and erasure
+ void insert (size_type i, size_type j, const_reference t);
+ void erase (size_type i, size_type j);
+ void clear ();
+
+ class const_iterator1;
+ class iterator1;
+ class const_iterator2;
+ class iterator2;
+ typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
+ typedef reverse_iterator_base1<iterator1> reverse_iterator1;
+ typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
+ typedef reverse_iterator_base2<iterator2> reverse_iterator2;
+
+ // Element lookup
+ const_iterator1 find1 (int rank, size_type i, size_type j) const;
+ iterator1 find1 (int rank, size_type i, size_type j);
+ const_iterator2 find2 (int rank, size_type i, size_type j) const;
+ iterator2 find2 (int rank, size_type i, size_type j);
+ const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
+ iterator1 find_first1 (int rank, size_type i, size_type j);
+ const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
+ iterator1 find_last1 (int rank, size_type i, size_type j);
+ const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
+ iterator2 find_first2 (int rank, size_type i, size_type j);
+ const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
+ iterator2 find_last2 (int rank, size_type i, size_type j);
+
+ // Iterators simply are pointers.
+
+ class const_iterator1:
+ public container_const_reference<coordinate_matrix>,
+ public bidirectional_iterator_base<const_iterator1, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename coordinate_matrix::difference_type difference_type;
+ typedef typename coordinate_matrix::value_type value_type;
+ typedef typename coordinate_matrix::const_reference reference;
+ typedef typename coordinate_matrix::const_pointer pointer;
+ typedef const_iterator2 dual_iterator_type;
+ typedef const_reverse_iterator2 dual_reverse_iterator_type;
+ typedef typename functor_type::functor1_type functor1_type;
+
+ // Construction and destruction
+ const_iterator1 ();
+ const_iterator1 (const coordinate_matrix &m, int rank, size_type i, size_type j, const const_iterator_type &it);
+ const_iterator1 (const iterator1 &it);
+
+ // Arithmetic
+ const_iterator1 &operator ++ ();
+ const_iterator1 &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ const_iterator2 begin () const;
+ const_iterator2 end () const;
+ const_reverse_iterator2 rbegin () const;
+ const_reverse_iterator2 rend () const;
+
+ // Indices
+ size_type index1 () const;
+ size_type index2 () const;
+
+ // Assignment
+ const_iterator1 &operator = (const const_iterator1 &it);
+
+ // Comparison
+ bool operator == (const const_iterator1 &it) const;
+ };
+
+ const_iterator1 begin1 () const;
+ const_iterator1 end1 () const;
+
+ class iterator1:
+ public container_reference<coordinate_matrix>,
+ public bidirectional_iterator_base<iterator1, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename coordinate_matrix::difference_type difference_type;
+ typedef typename coordinate_matrix::value_type value_type;
+ typedef typename coordinate_matrix::reference reference;
+ typedef typename coordinate_matrix::pointer pointer;
+ typedef iterator2 dual_iterator_type;
+ typedef reverse_iterator2 dual_reverse_iterator_type;
+ typedef typename functor_type::functor1_type functor1_type;
+
+ // Construction and destruction
+ iterator1 ();
+ iterator1 (coordinate_matrix &m, int rank, size_type i, size_type j, const iterator_type &it);
+
+ // Arithmetic
+ iterator1 &operator ++ ();
+ iterator1 &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ iterator2 begin () const;
+ iterator2 end () const;
+ reverse_iterator2 rbegin () const;
+ reverse_iterator2 rend () const;
+
+ // Indices
+ size_type index1 () const;
+ size_type index2 () const;
+
+ // Assignment
+ iterator1 &operator = (const iterator1 &it);
+
+ // Comparison
+ bool operator == (const iterator1 &it) const;
+ };
+
+ iterator1 begin1 ();
+ iterator1 end1 ();
+
+ class const_iterator2:
+ public container_const_reference<coordinate_matrix>,
+ public bidirectional_iterator_base<const_iterator2, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename coordinate_matrix::difference_type difference_type;
+ typedef typename coordinate_matrix::value_type value_type;
+ typedef typename coordinate_matrix::const_reference reference;
+ typedef typename coordinate_matrix::const_pointer pointer;
+ typedef const_iterator1 dual_iterator_type;
+ typedef const_reverse_iterator1 dual_reverse_iterator_type;
+ typedef typename functor_type::functor2_type functor2_type;
+
+ // Construction and destruction
+ const_iterator2 ();
+ const_iterator2 (const coordinate_matrix &m, int rank, size_type i, size_type j, const const_iterator_type &it);
+ const_iterator2 (const iterator2 &it);
+
+ // Arithmetic
+ const_iterator2 &operator ++ ();
+ const_iterator2 &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ const_iterator1 begin () const;
+ const_iterator1 end () const;
+ const_reverse_iterator1 rbegin () const;
+ const_reverse_iterator1 rend () const;
+
+ // Indices
+ size_type index1 () const;
+ size_type index2 () const;
+
+ // Assignment
+ const_iterator2 &operator = (const const_iterator2 &it);
+
+ // Comparison
+ bool operator == (const const_iterator2 &it) const;
+ };
+
+ const_iterator2 begin2 () const;
+ const_iterator2 end2 () const;
+
+ class iterator2:
+ public container_reference<coordinate_matrix>,
+ public bidirectional_iterator_base<iterator2, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename coordinate_matrix::difference_type difference_type;
+ typedef typename coordinate_matrix::value_type value_type;
+ typedef typename coordinate_matrix::reference reference;
+ typedef typename coordinate_matrix::pointer pointer;
+ typedef iterator1 dual_iterator_type;
+ typedef reverse_iterator1 dual_reverse_iterator_type;
+ typedef typename functor_type::functor2_type functor2_type;
+
+ // Construction and destruction
+ iterator2 ();
+ iterator2 (coordinate_matrix &m, int rank, size_type i, size_type j, const iterator_type &it);
+
+ // Arithmetic
+ iterator2 &operator ++ ();
+ iterator2 &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ iterator1 begin () const;
+ iterator1 end () const;
+ reverse_iterator1 rbegin () const;
+ reverse_iterator1 rend () const;
+
+ // Indices
+ size_type index1 () const;
+ size_type index2 () const;
+
+ // Assignment
+ iterator2 &operator = (const iterator2 &it);
+
+ // Comparison
+ bool operator == (const iterator2 &it) const;
+ };
+
+ iterator2 begin2 ();
+ iterator2 end2 ();
+
+ // Reverse iterators
+
+ const_reverse_iterator1 rbegin1 () const;
+ const_reverse_iterator1 rend1 () const;
+
+ reverse_iterator1 rbegin1 ();
+ reverse_iterator1 rend1 ();
+
+ const_reverse_iterator2 rbegin2 () const;
+ const_reverse_iterator2 rend2 () const;
+
+ reverse_iterator2 rbegin2 ();
+ reverse_iterator2 rend2 ();
+ };
+
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
diff --git a/doc/overview.htm b/doc/overview.htm
index 062db06c..de8799f4 100644
--- a/doc/overview.htm
+++ b/doc/overview.htm
@@ -419,15 +419,25 @@ how BLAS calls may be mapped onto our classes.
_t_svx = solve (A, x, tag) orx = solve (trans (A), x, tag) or
- x = solve (herm (A), x, tag)y = solve (A, x, tag) orinplace_solve (A, x, tag) ory = solve (trans (A), x, tag) or
+ inplace_solve (trans (A), x, tag) or
+ y = solve (herm (A), x, tag)or
+ inplace_solve (herm (A), x, tag)_g_mv
@@ -506,15 +516,23 @@ how BLAS calls may be mapped onto our classes.
_t_smB = solve (A, B, tag) orB = solve (trans (A), B, tag) or
- B = solve (herm (A), B, tag)C = solve (A, B, tag) orinplace_solve (A, B, tag) orC = solve (trans (A), B, tag) or
+ inplace_solve (trans (A), B, tag) or
+ C = solve (herm (A), B, tag) or
+ inplace_solve (herm (A), B, tag)_g_mm
@@ -634,6 +652,18 @@ most common constructions of vectors and matrices comes next.
Constructs a sparse vector, storage is provided by a
map array.
compressed_vector<T>
+ v (size, non_zeros)coordinate_vector<T>
+ v (size, non_zeros)vector_range<V>
vr (v, range)compressed_matrix<T,
+ row_major>
+ m (size1, size2, non_zeros)compressed_matrix<T,
+ column_major>
+ m (size1, size2, non_zeros)coordinate_matrix<T,
+ row_major>
+ m (size1, size2, non_zeros)coordinate_matrix<T,
+ column_major>
+ m (size1, size2, non_zeros)matrix_row<M>
mr (m, i)Aunbounded_array<T>[1] Supported parameters for the
+adapted array are unbounded_array<T>, bounded_array<T>
+and std::vector<T>.
// Array based vector class
diff --git a/doc/vector_sparse.htm b/doc/vector_sparse.htm
index ea782e01..ceed0dbb 100644
--- a/doc/vector_sparse.htm
+++ b/doc/vector_sparse.htm
@@ -18,9 +18,13 @@ width="277" height="86">Sparse Vector
The templated class sparse_vector<T, A> is
the base container adaptor for sparse vectors. For a n-dimensional
-sparse vector and 0 <= i < n every non-zero
-element vi is mapped to the i-th
-element of the container.
+sparse vector and 0 <= i < n the non-zero elements
+vi are mapped to consecutive
+elements of the associative container, i.e. for elements k
+= vi1
+and k + 1 = vi2
+of the container holds i1
+< i2.
Example
@@ -49,14 +53,10 @@ element of the container.
The type of object stored in the sparse vector.
-
- F
- Functor describing the storage organization.
- forward
-
A
- The type of the adapted array.
+ The type of the adapted array. [1]
map_array<std::size_t, T>
@@ -260,6 +260,12 @@ href="container.htm#vector">Vector.
+Notes
+
+[1] Supported parameters for
+the adapted array are map_array<std::size_t, T>
+and std::map<std::size_t, T>.
+
Interface
// Array based sparse vector class
@@ -274,7 +280,6 @@ href="container.htm#vector">Vector.
typedef T &reference;
typedef const T *const_pointer;
typedef T *pointer;
- typedef F functor_type;
typedef A array_type;
typedef const A const_array_type;
typedef const sparse_vector<T, A> const_self_type;
@@ -434,6 +439,904 @@ href="container.htm#vector">Vector.
reverse_iterator rend ();
};
+Compressed Vector
+
+Description
+
+The templated class compressed_vector<T, IB, IA,
+TA> is the base container adaptor for compressed
+vectors. For a n-dimensional compressed vector and 0
+<= i < n the non-zero elements vi
+are mapped to consecutive elements of the index and value
+container, i.e. for elements k = vi1
+and k + 1 = vi2
+of these containers holds i1
+< i2.
+
+Example
+
+int main () {
+ using namespace boost::numeric::ublas;
+ compressed_vector<double> v (3, 3);
+ for (int i = 0; i < v.size (); ++ i)
+ v (i) = i;
+ std::cout << v << std::endl;
+}
+
+Definition
+
+Defined in the header vector_sparse.hpp.
+
+Template parameters
+
+
+
+ Parameter
+ Description
+ Default
+
+
+ T
+ The type of object stored in the compressed vector.
+
+
+
+ IB
+ The index base of the compressed vector. [1]
+ 0
+
+
+ IA
+ The type of the adapted array for indices. [2]
+ unbounded_array<std::size_t>
+
+
+ TA
+ The type of the adapted array for values. [2]
+ unbounded_array<T>
+
+
+
+Model of
+
+
+
+Type requirements
+
+None, except for those imposed by the requirements of Vector.
+
+Public base classes
+
+vector_expression<compressed_vector<T, IB, IA,
+TA> >
+
+Members
+
+
+
+ Member
+ Description
+
+
+ compressed_vector ()
+ Allocates a compressed_vector that holds
+ zero elements.
+
+
+ compressed_vector (size_type size, size_type
+ non_zeros)
+ Allocates a compressed_vector that holds
+ at most size elements.
+
+
+ compressed_vector (const compressed_vector
+ &v)
+ The copy constructor.
+
+
+ template<class AE>
+ compressed_vector (size_type non_zeros, const
+ vector_expression<AE> &ae)
+ The extended copy constructor.
+
+
+ void resize (size_type size, size_type
+ non_zeros)
+ Reallocates a compressed_vector to hold
+ at most size elements. The content of the compressed_vector
+ is preserved.
+
+
+ size_type size () const
+ Returns the size of the compressed_vector.
+
+
+
+ const_reference operator () (size_type i) const
+ Returns the value of the i-th element.
+
+
+ reference operator () (size_type i)
+ Returns a reference of the i-th element.
+
+
+
+ const_reference operator [] (size_type i) const
+ Returns the value of the i-th element.
+
+
+ reference operator [] (size_type i)
+ Returns a reference of the i-th element.
+
+
+
+ compressed_vector &operator = (const
+ compressed_vector &v)
+ The assignment operator.
+
+
+ compressed_vector &assign_temporary
+ (compressed_vector &v)
+ Assigns a temporary. May change the compressed vector
+ v.
+
+
+ template<class AE>
+ compressed_vector &operator = (const
+ vector_expression<AE> &ae)
+ The extended assignment operator.
+
+
+ template<class AE>
+ compressed_vector &assign (const
+ vector_expression<AE> &ae)
+ Assigns a vector expression to the compressed vector.
+ Left and right hand side of the assignment should be
+ independent.
+
+
+ template<class AE>
+ compressed_vector &operator += (const
+ vector_expression<AE> &ae)
+ A computed assignment operator. Adds the vector
+ expression to the compressed vector.
+
+
+ template<class AE>
+ compressed_vector &plus_assign (const
+ vector_expression<AE> &ae)
+ Adds a vector expression to the compressed vector.
+ Left and right hand side of the assignment should be
+ independent.
+
+
+ template<class AE>
+ compressed_vector &operator -= (const
+ vector_expression<AE> &ae)
+ A computed assignment operator. Subtracts the vector
+ expression from the compressed vector.
+
+
+ template<class AE>
+ compressed_vector &minus_assign (const
+ vector_expression<AE> &ae)
+ Subtracts a vector expression from the compressed
+ vector. Left and right hand side of the assignment should
+ be independent.
+
+
+ template<class AT>
+ compressed_vector &operator *= (const AT &at)
+ A computed assignment operator. Multiplies the
+ compressed vector with a scalar.
+
+
+ template<class AT>
+ compressed_vector &operator /= (const AT &at)
+ A computed assignment operator. Divides the
+ compressed vector through a scalar.
+
+
+ void swap (compressed_vector &v)
+ Swaps the contents of the compressed vectors.
+
+
+ void insert (size_type i, const_reference t)
+ Inserts the value t at the i-th
+ element.
+
+
+ void erase (size_type i)
+ Erases the value at the i-th element.
+
+
+ void clear ()
+ Clears the compressed vector.
+
+
+ const_iterator begin () const
+ Returns a const_iterator pointing to the
+ beginning of the compressed_vector.
+
+
+ const_iterator end () const
+ Returns a const_iterator pointing to the
+ end of the compressed_vector.
+
+
+ iterator begin ()
+ Returns a iterator pointing to the
+ beginning of the compressed_vector.
+
+
+ iterator end ()
+ Returns a iterator pointing to the end
+ of the compressed_vector.
+
+
+ const_reverse_iterator rbegin () const
+ Returns a const_reverse_iterator
+ pointing to the beginning of the reversed compressed_vector.
+
+
+
+ const_reverse_iterator rend () const
+ Returns a const_reverse_iterator
+ pointing to the end of the reversed compressed_vector.
+
+
+
+ reverse_iterator rbegin ()
+ Returns a reverse_iterator pointing to
+ the beginning of the reversed compressed_vector.
+
+
+
+ reverse_iterator rend ()
+ Returns a reverse_iterator pointing to
+ the end of the reversed compressed_vector.
+
+
+
+Notes
+
+[1] Supported parameters
+for the index base are 0 and 1 at
+least.
+
+[2] Supported parameters
+for the adapted array are unbounded_array<>, bounded_array<>
+and std::vector<>.
+
+Interface
+
+ // Array based sparse vector class
+ template<class T, std::size_t IB, class IA, class TA>
+ class compressed_vector:
+ public vector_expression<compressed_vector<T, IB, IA, TA> > {
+ public:
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef T value_type;
+ typedef const T &const_reference;
+ typedef T &reference;
+ typedef const T *const_pointer;
+ typedef T *pointer;
+ typedef IA index_array_type;
+ typedef TA value_array_type;
+ typedef const compressed_vector<T, IB, IA, TA> const_self_type;
+ typedef compressed_vector<T, IB, IA, TA> self_type;
+ typedef const vector_const_reference<const_self_type> const_closure_type;
+ typedef vector_reference<self_type> closure_type;
+ typedef typename IA::const_iterator const_iterator_type;
+ typedef typename IA::iterator iterator_type;
+ typedef sparse_tag storage_category;
+
+ // Construction and destruction
+ compressed_vector ();
+ compressed_vector (size_type size, size_type non_zeros = 0);
+ compressed_vector (const compressed_vector &v);
+ template<class AE>
+ compressed_vector (const vector_expression<AE> &ae, size_type non_zeros = 0);
+
+ // Accessors
+ size_type size () const;
+ size_type non_zeros () const;
+ static size_type index_base ();
+ const index_array_type &index_data () const;
+ index_array_type &index_data ();
+ const value_array_type &value_data () const;
+ value_array_type &value_data ();
+
+ // Resizing
+ void resize (size_type size, size_type non_zeros = 0);
+
+ // Element access
+ const_reference operator () (size_type i) const;
+ reference operator () (size_type i);
+
+ const_reference operator [] (size_type i) const;
+ reference operator [] (size_type i);
+
+ // Assignment
+ compressed_vector &operator = (const compressed_vector &v);
+ compressed_vector &assign_temporary (compressed_vector &v);
+ template<class AE>
+ compressed_vector &operator = (const vector_expression<AE> &ae);
+ template<class AE>
+ compressed_vector &reset (const vector_expression<AE> &ae);
+ template<class AE>
+ compressed_vector &assign (const vector_expression<AE> &ae);
+ template<class AE>
+ compressed_vector &operator += (const vector_expression<AE> &ae);
+ template<class AE>
+ compressed_vector &plus_assign (const vector_expression<AE> &ae);
+ template<class AE>
+ compressed_vector &operator -= (const vector_expression<AE> &ae);
+ template<class AE>
+ compressed_vector &minus_assign (const vector_expression<AE> &ae);
+ template<class AT>
+ compressed_vector &operator *= (const AT &at);
+ template<class AT>
+ compressed_vector &operator /= (const AT &at);
+
+ // Swapping
+ void swap (compressed_vector &v);
+ friend void swap (compressed_vector &v1, compressed_vector &v2);
+
+ // Element insertion and erasure
+ void insert (size_type i, const_reference t);
+ void erase (size_type i);
+ void clear ();
+
+ class const_iterator;
+ class iterator;
+
+ // Element lookup
+ const_iterator find (size_type i) const;
+ iterator find (size_type i);
+ const_iterator find_first (size_type i) const;
+ iterator find_first (size_type i);
+ const_iterator find_last (size_type i) const;
+ iterator find_last (size_type i);
+
+ // Iterators simply are pointers.
+
+ class const_iterator:
+ public container_const_reference<compressed_vector>,
+ public bidirectional_iterator_base<const_iterator, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename compressed_vector::difference_type difference_type;
+ typedef typename compressed_vector::value_type value_type;
+ typedef typename compressed_vector::const_reference reference;
+ typedef typename compressed_vector::const_pointer pointer;
+
+ // Construction and destruction
+ const_iterator ();
+ const_iterator (const compressed_vector &v, const const_iterator_type &it);
+ const_iterator (const iterator &it);
+
+ // Arithmetic
+ const_iterator &operator ++ ();
+ const_iterator &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ // Index
+ size_type index () const;
+
+ // Assignment
+ const_iterator &operator = (const const_iterator &it);
+
+ // Comparison
+ bool operator == (const const_iterator &it) const;
+ };
+
+ const_iterator begin () const;
+ const_iterator end () const;
+
+ class iterator:
+ public container_reference<compressed_vector>,
+ public bidirectional_iterator_base<iterator, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename compressed_vector::difference_type difference_type;
+ typedef typename compressed_vector::value_type value_type;
+ typedef typename compressed_vector::reference reference;
+ typedef typename compressed_vector::pointer pointer;
+
+ // Construction and destruction
+ iterator ();
+ iterator (compressed_vector &v, const iterator_type &it);
+
+ // Arithmetic
+ iterator &operator ++ ();
+ iterator &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ // Index
+ size_type index () const;
+
+ // Assignment
+ iterator &operator = (const iterator &it);
+
+ // Comparison
+ bool operator == (const iterator &it) const;
+ };
+
+ iterator begin ();
+ iterator end ();
+
+ // Reverse iterator
+
+ typedef reverse_iterator_base<const_iterator> const_reverse_iterator;
+
+ const_reverse_iterator rbegin () const;
+ const_reverse_iterator rend () const;
+
+ typedef reverse_iterator_base<iterator> reverse_iterator;
+
+ reverse_iterator rbegin ();
+ reverse_iterator rend ();
+ };
+
+Coordinate Vector
+
+Description
+
+The templated class coordinate_vector<T, IB, IA,
+TA> is the base container adaptor for compressed
+vectors. For a n-dimensional sorted coordinate vector
+and 0 <= i < n the non-zero elements vi
+are mapped to consecutive elements of the index and value
+container, i.e. for elements k = vi1
+and k + 1 = vi2
+of these containers holds i1
+< i2.
+
+Example
+
+int main () {
+ using namespace boost::numeric::ublas;
+ coordinate_vector<double> v (3, 3);
+ for (int i = 0; i < v.size (); ++ i)
+ v (i) = i;
+ std::cout << v << std::endl;
+}
+
+Definition
+
+Defined in the header vector_sparse.hpp.
+
+Template parameters
+
+
+
+ Parameter
+ Description
+ Default
+
+
+ T
+ The type of object stored in the coordinate vector.
+
+
+
+ IB
+ The index base of the coordinate vector. [1]
+ 0
+
+
+ IA
+ The type of the adapted array for indices. [2]
+ unbounded_array<std::size_t>
+
+
+ TA
+ The type of the adapted array for values. [2]
+ unbounded_array<T>
+
+
+
+Model of
+
+
+
+Type requirements
+
+None, except for those imposed by the requirements of Vector.
+
+Public base classes
+
+vector_expression<coordinate_vector<T, IB, IA,
+TA> >
+
+Members
+
+
+
+ Member
+ Description
+
+
+ coordinate_vector ()
+ Allocates a coordinate_vector that holds
+ zero elements.
+
+
+ coordinate_vector (size_type size, size_type
+ non_zeros)
+ Allocates a coordinate_vector that holds
+ at most size elements.
+
+
+ coordinate_vector (const coordinate_vector
+ &v)
+ The copy constructor.
+
+
+ template<class AE>
+ coordinate_vector (size_type non_zeros, const
+ vector_expression<AE> &ae)
+ The extended copy constructor.
+
+
+ void resize (size_type size, size_type
+ non_zeros)
+ Reallocates a coordinate_vector to hold
+ at most size elements. The content of the coordinate_vector
+ is preserved.
+
+
+ size_type size () const
+ Returns the size of the coordinate_vector.
+
+
+
+ const_reference operator () (size_type i) const
+ Returns the value of the i-th element.
+
+
+ reference operator () (size_type i)
+ Returns a reference of the i-th element.
+
+
+
+ const_reference operator [] (size_type i) const
+ Returns the value of the i-th element.
+
+
+ reference operator [] (size_type i)
+ Returns a reference of the i-th element.
+
+
+
+ coordinate_vector &operator = (const
+ coordinate_vector &v)
+ The assignment operator.
+
+
+ coordinate_vector &assign_temporary
+ (coordinate_vector &v)
+ Assigns a temporary. May change the coordinate vector
+ v.
+
+
+ template<class AE>
+ coordinate_vector &operator = (const
+ vector_expression<AE> &ae)
+ The extended assignment operator.
+
+
+ template<class AE>
+ coordinate_vector &assign (const
+ vector_expression<AE> &ae)
+ Assigns a vector expression to the coordinate vector.
+ Left and right hand side of the assignment should be
+ independent.
+
+
+ template<class AE>
+ coordinate_vector &operator += (const
+ vector_expression<AE> &ae)
+ A computed assignment operator. Adds the vector
+ expression to the coordinate vector.
+
+
+ template<class AE>
+ coordinate_vector &plus_assign (const
+ vector_expression<AE> &ae)
+ Adds a vector expression to the coordinate vector.
+ Left and right hand side of the assignment should be
+ independent.
+
+
+ template<class AE>
+ coordinate_vector &operator -= (const
+ vector_expression<AE> &ae)
+ A computed assignment operator. Subtracts the vector
+ expression from the coordinate vector.
+
+
+ template<class AE>
+ coordinate_vector &minus_assign (const
+ vector_expression<AE> &ae)
+ Subtracts a vector expression from the coordinate
+ vector. Left and right hand side of the assignment should
+ be independent.
+
+
+ template<class AT>
+ coordinate_vector &operator *= (const AT &at)
+ A computed assignment operator. Multiplies the
+ coordinate vector with a scalar.
+
+
+ template<class AT>
+ coordinate_vector &operator /= (const AT &at)
+ A computed assignment operator. Divides the
+ coordinate vector through a scalar.
+
+
+ void swap (coordinate_vector &v)
+ Swaps the contents of the coordinate vectors.
+
+
+ void insert (size_type i, const_reference t)
+ Inserts the value t at the i-th
+ element.
+
+
+ void erase (size_type i)
+ Erases the value at the i-th element.
+
+
+ void clear ()
+ Clears the coordinate vector.
+
+
+ const_iterator begin () const
+ Returns a const_iterator pointing to the
+ beginning of the coordinate_vector.
+
+
+ const_iterator end () const
+ Returns a const_iterator pointing to the
+ end of the coordinate_vector.
+
+
+ iterator begin ()
+ Returns a iterator pointing to the
+ beginning of the coordinate_vector.
+
+
+ iterator end ()
+ Returns a iterator pointing to the end
+ of the coordinate_vector.
+
+
+ const_reverse_iterator rbegin () const
+ Returns a const_reverse_iterator
+ pointing to the beginning of the reversed coordinate_vector.
+
+
+
+ const_reverse_iterator rend () const
+ Returns a const_reverse_iterator
+ pointing to the end of the reversed coordinate_vector.
+
+
+
+ reverse_iterator rbegin ()
+ Returns a reverse_iterator pointing to
+ the beginning of the reversed coordinate_vector.
+
+
+
+ reverse_iterator rend ()
+ Returns a reverse_iterator pointing to
+ the end of the reversed coordinate_vector.
+
+
+
+Notes
+
+[1] Supported parameters
+for the index base are 0 and 1 at
+least.
+
+[2] Supported parameters
+for the adapted array are unbounded_array<>, bounded_array<>
+and std::vector<>.
+
+Interface
+
+ // Array based sparse vector class
+ template<class T, std::size_t IB, class IA, class TA>
+ class coordinate_vector:
+ public vector_expression<coordinate_vector<T, IB, IA, TA> > {
+ public:
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef T value_type;
+ typedef const T &const_reference;
+ typedef T &reference;
+ typedef const T *const_pointer;
+ typedef T *pointer;
+ typedef IA index_array_type;
+ typedef TA value_array_type;
+ typedef const coordinate_vector<T, IB, IA, TA> const_self_type;
+ typedef coordinate_vector<T, IB, IA, TA> self_type;
+ typedef const vector_const_reference<const_self_type> const_closure_type;
+ typedef vector_reference<self_type> closure_type;
+ typedef typename IA::const_iterator const_iterator_type;
+ typedef typename IA::iterator iterator_type;
+ typedef sparse_tag storage_category;
+
+ // Construction and destruction
+ coordinate_vector ();
+ coordinate_vector (size_type size, size_type non_zeros = 0);
+ coordinate_vector (const coordinate_vector &v);
+ template<class AE>
+ coordinate_vector (const vector_expression<AE> &ae, size_type non_zeros = 0);
+
+ // Accessors
+ size_type size () const;
+ size_type non_zeros () const;
+ static size_type index_base ();
+ const index_array_type &index_data () const;
+ index_array_type &index_data ();
+ const value_array_type &value_data () const;
+ value_array_type &value_data ();
+
+ // Resizing
+ void resize (size_type size, size_type non_zeros = 0);
+
+ // Element access
+ const_reference operator () (size_type i) const;
+ reference operator () (size_type i);
+
+ const_reference operator [] (size_type i) const;
+ reference operator [] (size_type i);
+
+ // Assignment
+ coordinate_vector &operator = (const coordinate_vector &v);
+ coordinate_vector &assign_temporary (coordinate_vector &v);
+ template<class AE>
+ coordinate_vector &operator = (const vector_expression<AE> &ae);
+ template<class AE>
+ coordinate_vector &reset (const vector_expression<AE> &ae);
+ template<class AE>
+ coordinate_vector &assign (const vector_expression<AE> &ae);
+ template<class AE>
+ coordinate_vector &operator += (const vector_expression<AE> &ae);
+ template<class AE>
+ coordinate_vector &plus_assign (const vector_expression<AE> &ae);
+ template<class AE>
+ coordinate_vector &operator -= (const vector_expression<AE> &ae);
+ template<class AE>
+ coordinate_vector &minus_assign (const vector_expression<AE> &ae);
+ template<class AT>
+ coordinate_vector &operator *= (const AT &at);
+ template<class AT>
+ coordinate_vector &operator /= (const AT &at);
+
+ // Swapping
+ void swap (coordinate_vector &v);
+ friend void swap (coordinate_vector &v1, coordinate_vector &v2);
+
+ // Element insertion and erasure
+ void insert (size_type i, const_reference t);
+ void erase (size_type i);
+ void clear ();
+
+ class const_iterator;
+ class iterator;
+
+ // Element lookup
+ const_iterator find (size_type i) const;
+ iterator find (size_type i);
+ const_iterator find_first (size_type i) const;
+ iterator find_first (size_type i);
+ const_iterator find_last (size_type i) const;
+ iterator find_last (size_type i);
+
+ // Iterators simply are pointers.
+
+ class const_iterator:
+ public container_const_reference<coordinate_vector>,
+ public bidirectional_iterator_base<const_iterator, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename coordinate_vector::difference_type difference_type;
+ typedef typename coordinate_vector::value_type value_type;
+ typedef typename coordinate_vector::const_reference reference;
+ typedef typename coordinate_vector::const_pointer pointer;
+
+ // Construction and destruction
+ const_iterator ();
+ const_iterator (const coordinate_vector &v, const const_iterator_type &it);
+ const_iterator (const iterator &it);
+
+ // Arithmetic
+ const_iterator &operator ++ ();
+ const_iterator &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ // Index
+ size_type index () const;
+
+ // Assignment
+ const_iterator &operator = (const const_iterator &it);
+
+ // Comparison
+ bool operator == (const const_iterator &it) const;
+ };
+
+ const_iterator begin () const;
+ const_iterator end () const;
+
+ class iterator:
+ public container_reference<coordinate_vector>,
+ public bidirectional_iterator_base<iterator, value_type> {
+ public:
+ typedef sparse_bidirectional_iterator_tag iterator_category;
+ typedef typename coordinate_vector::difference_type difference_type;
+ typedef typename coordinate_vector::value_type value_type;
+ typedef typename coordinate_vector::reference reference;
+ typedef typename coordinate_vector::pointer pointer;
+
+ // Construction and destruction
+ iterator ();
+ iterator (coordinate_vector &v, const iterator_type &it);
+
+ // Arithmetic
+ iterator &operator ++ ();
+ iterator &operator -- ();
+
+ // Dereference
+ reference operator * () const;
+
+ // Index
+ size_type index () const;
+
+ // Assignment
+ iterator &operator = (const iterator &it);
+
+ // Comparison
+ bool operator == (const iterator &it) const;
+ };
+
+ iterator begin ();
+ iterator end ();
+
+ // Reverse iterator
+
+ typedef reverse_iterator_base<const_iterator> const_reverse_iterator;
+
+ const_reverse_iterator rbegin () const;
+ const_reverse_iterator rend () const;
+
+ typedef reverse_iterator_base<iterator> reverse_iterator;
+
+ reverse_iterator rbegin ();
+ reverse_iterator rend ();
+ };
+
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
diff --git a/include/boost/numeric/ublas/banded.hpp b/include/boost/numeric/ublas/banded.hpp
index 03244972..6cc53065 100644
--- a/include/boost/numeric/ublas/banded.hpp
+++ b/include/boost/numeric/ublas/banded.hpp
@@ -989,7 +989,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
@@ -1003,11 +1003,18 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename detail::ct_if::value,
typename M::const_pointer,
typename M::pointer>::type pointer;
+#endif
+#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
+ typedef typename M::closure_type matrix_closure_type;
+#else
+ typedef typename detail::ct_if::value,
+ typename M::const_closure_type,
+ typename M::closure_type>::type matrix_closure_type;
#endif
typedef const banded_adaptor const_self_type;
typedef banded_adaptor self_type;
- typedef const matrix_const_reference const_closure_type;
- typedef matrix_reference closure_type;
+ typedef const_self_type const_closure_type;
+ typedef self_type closure_type;
typedef typename storage_restrict_traits::storage_category storage_category;
typedef typename M::orientation_category orientation_category;
@@ -1041,11 +1048,11 @@ namespace boost { namespace numeric { namespace ublas {
return upper_;
}
BOOST_UBLAS_INLINE
- const_matrix_type &data () const {
+ const matrix_closure_type &data () const {
return data_;
}
BOOST_UBLAS_INLINE
- matrix_type &data () {
+ matrix_closure_type &data () {
return data_;
}
@@ -1811,7 +1818,7 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
- matrix_type &data_;
+ matrix_closure_type data_;
size_type lower_;
size_type upper_;
static matrix_type nil_;
diff --git a/include/boost/numeric/ublas/concepts.hpp b/include/boost/numeric/ublas/concepts.hpp
index 544a7ada..1a90d8de 100644
--- a/include/boost/numeric/ublas/concepts.hpp
+++ b/include/boost/numeric/ublas/concepts.hpp
@@ -872,6 +872,7 @@ namespace boost { namespace numeric { namespace ublas {
ZeroElement (double) {
return 0.;
}
+#ifndef BOOST_MSVC
template<>
std::complex
ZeroElement (std::complex) {
@@ -880,8 +881,9 @@ namespace boost { namespace numeric { namespace ublas {
template<>
std::complex
ZeroElement (std::complex) {
- return std::complex (0.);
+ return std::complex (0.);
}
+#endif
template<>
vector
ZeroElement (vector) {
@@ -892,6 +894,7 @@ namespace boost { namespace numeric { namespace ublas {
ZeroElement (vector) {
return zero_vector ();
}
+#ifndef BOOST_MSVC
template<>
vector >
ZeroElement (vector >) {
@@ -902,6 +905,7 @@ namespace boost { namespace numeric { namespace ublas {
ZeroElement (vector >) {
return zero_vector > ();
}
+#endif
template<>
matrix
ZeroElement (matrix) {
@@ -912,6 +916,7 @@ namespace boost { namespace numeric { namespace ublas {
ZeroElement (matrix) {
return zero_matrix ();
}
+#ifndef BOOST_MSVC
template<>
matrix >
ZeroElement (matrix >) {
@@ -922,6 +927,7 @@ namespace boost { namespace numeric { namespace ublas {
ZeroElement (matrix >) {
return zero_matrix > ();
}
+#endif
template
T
@@ -936,6 +942,7 @@ namespace boost { namespace numeric { namespace ublas {
OneElement (double) {
return 1.;
}
+#ifndef BOOST_MSVC
template<>
std::complex
OneElement (std::complex) {
@@ -946,6 +953,7 @@ namespace boost { namespace numeric { namespace ublas {
OneElement (std::complex) {
return std::complex (1.);
}
+#endif
template<>
matrix
OneElement (matrix) {
@@ -956,6 +964,7 @@ namespace boost { namespace numeric { namespace ublas {
OneElement (matrix) {
return identity_matrix ();
}
+#ifndef BOOST_MSVC
template<>
matrix >
OneElement (matrix >) {
@@ -966,6 +975,7 @@ namespace boost { namespace numeric { namespace ublas {
OneElement (matrix >) {
return identity_matrix > ();
}
+#endif
template
bool
@@ -1641,6 +1651,7 @@ namespace boost { namespace numeric { namespace ublas {
VectorSpaceConcept >::constraints ();
LinearOperatorConcept, matrix >::constraints ();
+#ifndef BOOST_MSVC
AdditiveAbelianGroupConcept >::constraints ();
CommutativeRingWithIdentityConcept >::constraints ();
FieldConcept >::constraints ();
@@ -1656,6 +1667,7 @@ namespace boost { namespace numeric { namespace ublas {
RingWithIdentityConcept > >::constraints (0);
VectorSpaceConcept, matrix > >::constraints ();
LinearOperatorConcept, vector >, matrix > >::constraints ();
+#endif
#endif
}
diff --git a/include/boost/numeric/ublas/config.hpp b/include/boost/numeric/ublas/config.hpp
index fd0ddb4d..3912208c 100644
--- a/include/boost/numeric/ublas/config.hpp
+++ b/include/boost/numeric/ublas/config.hpp
@@ -24,122 +24,21 @@
#include
#include
-#ifdef BOOST_MSVC
-// Disable some MSVC specific warnings.
-#pragma warning (disable: 4355)
-#pragma warning (disable: 4503)
-#pragma warning (disable: 4786)
-#endif
-
-
-
-#ifdef BOOST_MSVC
-// MSVC doesn't always accept the 'typename' keyword.
-#define BOOST_UBLAS_TYPENAME
-// MSVC doesn't accept the 'using' keyword (at least for importing base members).
-#define BOOST_UBLAS_USING
-#else
-#define BOOST_UBLAS_TYPENAME typename
-#define BOOST_UBLAS_USING using
-#endif
-// This could be eliminated.
-#define BOOST_UBLAS_EXPLICIT explicit
-
-
-
-// #ifdef BOOST_MSVC
-// With MSVC we can could perform IO via basic_stream
-// #define BOOST_UBLAS_USE_BASIC_STREAM
-// #else
-// IO via streams
-#define BOOST_UBLAS_USE_STREAM
-// #endif
-
-
-
-// Enable different sparse element proxies
-// These fix a [1] = a [0] = 1, but probably won't work on broken compilers.
-// Thanks to Marc Duflot for spotting this.
-// #define BOOST_UBLAS_STRICT_STORAGE_SPARSE
-#define BOOST_UBLAS_STRICT_VECTOR_SPARSE
-#define BOOST_UBLAS_STRICT_MATRIX_SPARSE
-
-
-
-// Enable performance options in release mode
-#ifdef NDEBUG
-
-#ifdef BOOST_MSVC
-// MSVC has special inlining options
-#pragma inline_recursion (on)
-#pragma inline_depth (255)
-#pragma auto_inline (on)
-// #define BOOST_UBLAS_INLINE __forceinline
-#define BOOST_UBLAS_INLINE __inline
-#else
-#define BOOST_UBLAS_INLINE inline
-#endif
-
-// Do not check sizes!
-#define BOOST_UBLAS_USE_FAST_SAME
-
-// Use expression templates.
-#define BOOST_UBLAS_USE_ET
-
-// Disable performance options in debug mode
-#else
-
-#ifdef BOOST_MSVC
-// MSVC has special inlining options
-// #pragma inline_recursion (off)
-// #pragma inline_depth ()
-// #pragma auto_inline (off)
-#endif
-#define BOOST_UBLAS_INLINE
-
-#ifdef BOOST_MSVC
-// Use expression templates (otherwise we get many ICE's)
-#define BOOST_UBLAS_USE_ET
-#endif
-
-// Bounds check
-#define BOOST_UBLAS_BOUNDS_CHECK
-// Type check for non dense matrices
-#define BOOST_UBLAS_TYPE_CHECK
-
-#endif
-
-
-
-// Use invariant hoisting.
-#define BOOST_UBLAS_USE_INVARIANT_HOISTING
-
-// Use Duff's device
-// #define BOOST_UBLAS_USE_DUFF_DEVICE
-
-// Choose evaluation method for dense vectors and matrices
-#define BOOST_UBLAS_USE_INDEXING
-// #define BOOST_UBLAS_USE_ITERATING
-// #define BOOST_UBLAS_ITERATOR_THRESHOLD 0
-// #define BOOST_UBLAS_ITERATOR_THRESHOLD (std::numeric_limits::max ())
-
-// ET options
-#define BOOST_UBLAS_ET_VALUE
-// #define BOOST_UBLAS_ET_REFERENCE
-// #define BOOST_UBLAS_ET_CLOSURE_VALUE
-#define BOOST_UBLAS_ET_CLOSURE_REFERENCE
-
-// Use indexed iterators.
-// #define BOOST_UBLAS_USE_INDEXED_ITERATOR
-
// Compiler specific problems
#ifdef BOOST_MSVC
+// Disable some MSVC specific warnings.
+#pragma warning (disable: 4355)
+#pragma warning (disable: 4503)
+#pragma warning (disable: 4786)
+
// Open problems:
// MSVC lacks some specializations in
#define BOOST_UBLAS_C_MATH
+// MSVC lacks std::abort() in
+#define BOOST_UBLAS_C_STDLIB
// MSVC allows to implement free function as friends.
#define BOOST_UBLAS_FRIEND_FUNCTION
@@ -247,6 +146,112 @@
+#ifdef BOOST_MSVC
+// MSVC doesn't always accept the 'typename' keyword.
+#define BOOST_UBLAS_TYPENAME
+// MSVC doesn't accept the 'using' keyword (at least for importing base members).
+#define BOOST_UBLAS_USING
+#else
+#define BOOST_UBLAS_TYPENAME typename
+#define BOOST_UBLAS_USING using
+#endif
+// This could be eliminated.
+#define BOOST_UBLAS_EXPLICIT explicit
+
+
+
+// #ifdef BOOST_MSVC
+// With MSVC we could perform IO via basic_stream
+// #define BOOST_UBLAS_USE_BASIC_STREAM
+// #else
+// IO via streams
+#define BOOST_UBLAS_USE_STREAM
+// #endif
+
+// Enable assignment of non conformant proxies
+// Thanks to Michael Stevens for spotting this.
+#define BOOST_UBLAS_NON_CONFORMANT_PROXIES
+
+// Enable different sparse element proxies
+// These fix a [1] = a [0] = 1, but probably won't work on broken compilers.
+// Thanks to Marc Duflot for spotting this.
+#ifndef BOOST_MSVC_STD_ITERATOR
+// #define BOOST_UBLAS_STRICT_STORAGE_SPARSE
+#define BOOST_UBLAS_STRICT_VECTOR_SPARSE
+#define BOOST_UBLAS_STRICT_MATRIX_SPARSE
+#endif
+
+// Enable compile time typedefs for proxies
+#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+// Doesn't work under Borland
+#ifndef __BORLANDC__
+#define BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
+#define BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
+#endif
+#endif
+
+// Enable performance options in release mode
+#ifdef NDEBUG
+
+#ifdef BOOST_MSVC
+// MSVC has special inlining options
+#pragma inline_recursion (on)
+#pragma inline_depth (255)
+#pragma auto_inline (on)
+// #define BOOST_UBLAS_INLINE __forceinline
+#define BOOST_UBLAS_INLINE __inline
+#else
+#define BOOST_UBLAS_INLINE inline
+#endif
+
+// Do not check sizes!
+#define BOOST_UBLAS_USE_FAST_SAME
+
+// Use expression templates.
+#define BOOST_UBLAS_USE_ET
+
+// Disable performance options in debug mode
+#else
+
+#ifdef BOOST_MSVC
+// MSVC has special inlining options
+// #pragma inline_recursion (off)
+// #pragma inline_depth ()
+// #pragma auto_inline (off)
+#endif
+#define BOOST_UBLAS_INLINE
+
+#ifdef BOOST_MSVC
+// Use expression templates (otherwise we get many ICE's)
+#define BOOST_UBLAS_USE_ET
+#endif
+
+// Bounds check
+#define BOOST_UBLAS_BOUNDS_CHECK
+// Type check for non dense matrices
+#define BOOST_UBLAS_TYPE_CHECK
+
+#endif
+
+
+
+// Use invariant hoisting.
+#define BOOST_UBLAS_USE_INVARIANT_HOISTING
+
+// Use Duff's device
+// #define BOOST_UBLAS_USE_DUFF_DEVICE
+
+// Choose evaluation method for dense vectors and matrices
+#define BOOST_UBLAS_USE_INDEXING
+// #define BOOST_UBLAS_USE_ITERATING
+// #define BOOST_UBLAS_ITERATOR_THRESHOLD 0
+// #define BOOST_UBLAS_ITERATOR_THRESHOLD (std::numeric_limits::max ())
+
+// Use indexed iterators.
+// #define BOOST_UBLAS_USE_INDEXED_ITERATOR
+
+
+
// Forward declarations
namespace boost { namespace numeric { namespace ublas {
@@ -325,10 +330,10 @@ namespace boost { namespace numeric { namespace ublas {
template >
class sparse_vector;
- template, class TA = unbounded_array, std::size_t IB = 0>
+ template, class TA = unbounded_array >
class compressed_vector;
- template, class TA = unbounded_array, std::size_t IB = 0>
+ template, class TA = unbounded_array >
class coordinate_vector;
struct unknown_orientation_tag {};
@@ -390,10 +395,10 @@ namespace boost { namespace numeric { namespace ublas {
template > >
class sparse_vector_of_sparse_vector;
- template, class TA = unbounded_array, std::size_t IB = 0>
+ template, class TA = unbounded_array >
class compressed_matrix;
- template, class TA = unbounded_array, std::size_t IB = 0>
+ template, class TA = unbounded_array >
class coordinate_matrix;
template
diff --git a/include/boost/numeric/ublas/exception.hpp b/include/boost/numeric/ublas/exception.hpp
index 0a572177..ff9e21bd 100644
--- a/include/boost/numeric/ublas/exception.hpp
+++ b/include/boost/numeric/ublas/exception.hpp
@@ -17,6 +17,7 @@
#ifndef BOOST_UBLAS_EXCEPTION_H
#define BOOST_UBLAS_EXCEPTION_H
+#include
#include
#include
#include
@@ -39,7 +40,11 @@ namespace boost { namespace numeric { namespace ublas {
#if ! defined (BOOST_NO_EXCEPTIONS) && defined (BOOST_UBLAS_USE_EXCEPTIONS)
throw *this;
#else
- abort ();
+#ifdef BOOST_UBLAS_C_STDLIB
+ ::abort ();
+#else
+ std::abort ();
+#endif
#endif
}
};
@@ -57,7 +62,11 @@ namespace boost { namespace numeric { namespace ublas {
#if ! defined (BOOST_NO_EXCEPTIONS) && defined (BOOST_UBLAS_USE_EXCEPTIONS)
throw *this;
#else
- abort ();
+#ifdef BOOST_UBLAS_C_STDLIB
+ ::abort ();
+#else
+ std::abort ();
+#endif
#endif
}
};
@@ -75,7 +84,11 @@ namespace boost { namespace numeric { namespace ublas {
#if ! defined (BOOST_NO_EXCEPTIONS) && defined (BOOST_UBLAS_USE_EXCEPTIONS)
throw *this;
#else
- abort ();
+#ifdef BOOST_UBLAS_C_STDLIB
+ ::abort ();
+#else
+ std::abort ();
+#endif
#endif
}
};
@@ -93,7 +106,11 @@ namespace boost { namespace numeric { namespace ublas {
#if ! defined (BOOST_NO_EXCEPTIONS) && defined (BOOST_UBLAS_USE_EXCEPTIONS)
throw *this;
#else
- abort ();
+#ifdef BOOST_UBLAS_C_STDLIB
+ ::abort ();
+#else
+ std::abort ();
+#endif
#endif
}
};
@@ -111,7 +128,11 @@ namespace boost { namespace numeric { namespace ublas {
#if ! defined (BOOST_NO_EXCEPTIONS) && defined (BOOST_UBLAS_USE_EXCEPTIONS)
throw *this;
#else
- abort ();
+#ifdef BOOST_UBLAS_C_STDLIB
+ ::abort ();
+#else
+ std::abort ();
+#endif
#endif
}
};
@@ -129,7 +150,11 @@ namespace boost { namespace numeric { namespace ublas {
#if ! defined (BOOST_NO_EXCEPTIONS) && defined (BOOST_UBLAS_USE_EXCEPTIONS)
throw *this;
#else
- abort ();
+#ifdef BOOST_UBLAS_C_STDLIB
+ ::abort ();
+#else
+ std::abort ();
+#endif
#endif
}
};
@@ -147,7 +172,11 @@ namespace boost { namespace numeric { namespace ublas {
#if ! defined (BOOST_NO_EXCEPTIONS) && defined (BOOST_UBLAS_USE_EXCEPTIONS)
throw *this;
#else
- abort ();
+#ifdef BOOST_UBLAS_C_STDLIB
+ ::abort ();
+#else
+ std::abort ();
+#endif
#endif
}
};
@@ -165,7 +194,11 @@ namespace boost { namespace numeric { namespace ublas {
#if ! defined (BOOST_NO_EXCEPTIONS) && defined (BOOST_UBLAS_USE_EXCEPTIONS)
throw *this;
#else
- abort ();
+#ifdef BOOST_UBLAS_C_STDLIB
+ ::abort ();
+#else
+ std::abort ();
+#endif
#endif
}
};
diff --git a/include/boost/numeric/ublas/hermitian.hpp b/include/boost/numeric/ublas/hermitian.hpp
index 45fe6e2b..c2d22b4a 100644
--- a/include/boost/numeric/ublas/hermitian.hpp
+++ b/include/boost/numeric/ublas/hermitian.hpp
@@ -933,7 +933,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
// FIXME: no better way to not return the address of a temporary?
// typedef typename M::const_reference const_reference;
typedef typename M::value_type const_reference;
@@ -954,11 +954,18 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename detail::ct_if::value,
typename M::const_pointer,
typename M::pointer>::type pointer;
+#endif
+#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
+ typedef typename M::closure_type matrix_closure_type;
+#else
+ typedef typename detail::ct_if::value,
+ typename M::const_closure_type,
+ typename M::closure_type>::type matrix_closure_type;
#endif
typedef const hermitian_adaptor const_self_type;
typedef hermitian_adaptor self_type;
- typedef const matrix_const_reference const_closure_type;
- typedef matrix_reference closure_type;
+ typedef const_self_type const_closure_type;
+ typedef self_type closure_type;
typedef typename storage_restrict_traits::storage_category storage_category;
typedef typename F::packed_category packed_category;
@@ -966,7 +973,7 @@ namespace boost { namespace numeric { namespace ublas {
// Construction and destruction
BOOST_UBLAS_INLINE
- hermitian_adaptor ():
+ hermitian_adaptor ():
data_ (nil_) {
BOOST_UBLAS_CHECK (data_.size1 () == data_.size2 (), bad_size ());
}
@@ -991,11 +998,11 @@ namespace boost { namespace numeric { namespace ublas {
return data_.size2 ();
}
BOOST_UBLAS_INLINE
- const_matrix_type &data () const {
+ const matrix_closure_type &data () const {
return data_;
}
BOOST_UBLAS_INLINE
- matrix_type &data () {
+ matrix_closure_type &data () {
return data_;
}
@@ -1717,7 +1724,7 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
- matrix_type &data_;
+ matrix_closure_type data_;
static matrix_type nil_;
static value_type conj_;
};
diff --git a/include/boost/numeric/ublas/matrix_assign.hpp b/include/boost/numeric/ublas/matrix_assign.hpp
index b537a330..ec28e152 100644
--- a/include/boost/numeric/ublas/matrix_assign.hpp
+++ b/include/boost/numeric/ublas/matrix_assign.hpp
@@ -695,6 +695,7 @@ namespace boost { namespace numeric { namespace ublas {
functor_type () (*it2, value_type ());
++ it2;
} else if (compare > 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
// Sparse proxies don't need to be conformant.
// Thanks to Michael Stevens for suggesting this.
size_type index1 (it2e.index1 ()), index2 (it2e.index2 ());
@@ -702,8 +703,10 @@ namespace boost { namespace numeric { namespace ublas {
restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ());
// The proxies could reference the same container.
restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ());
+#endif
}
}
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
while (it2e != it2e_end) {
// Sparse proxies don't need to be conformant.
// Thanks to Michael Stevens for suggesting this.
@@ -712,6 +715,7 @@ namespace boost { namespace numeric { namespace ublas {
// The proxies could reference the same container.
restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ());
}
+#endif
while (it2 != it2_end) {
functor_type () (*it2, value_type ());
++ it2;
@@ -726,6 +730,7 @@ namespace boost { namespace numeric { namespace ublas {
}
++ it1;
} else if (compare > 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
typename E::const_iterator2 it2e (it1e.begin ());
typename E::const_iterator2 it2e_end (it1e.end ());
while (it2e != it2e_end) {
@@ -736,9 +741,11 @@ namespace boost { namespace numeric { namespace ublas {
// The proxies could reference the same container.
restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ());
}
+#endif
++ it1e;
}
}
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
while (it1e != it1e_end) {
typename E::const_iterator2 it2e (it1e.begin ());
typename E::const_iterator2 it2e_end (it1e.end ());
@@ -752,6 +759,7 @@ namespace boost { namespace numeric { namespace ublas {
}
++ it1e;
}
+#endif
while (it1 != it1_end) {
typename M::iterator2 it2 (it1.begin ());
typename M::iterator2 it2_end (it1.end ());
@@ -800,6 +808,7 @@ namespace boost { namespace numeric { namespace ublas {
functor_type () (*it1, value_type ());
++ it1;
} else if (compare > 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
// Sparse proxies don't need to be conformant.
// Thanks to Michael Stevens for suggesting this.
size_type index1 (it1e.index1 ()), index2 (it1e.index2 ());
@@ -807,8 +816,10 @@ namespace boost { namespace numeric { namespace ublas {
restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ());
// The proxies could reference the same container.
restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ());
+#endif
}
}
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
while (it1e != it1e_end) {
// Sparse proxies don't need to be conformant.
// Thanks to Michael Stevens for suggesting this.
@@ -817,6 +828,7 @@ namespace boost { namespace numeric { namespace ublas {
// The proxies could reference the same container.
restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ());
}
+#endif
while (it1 != it1_end) {
functor_type () (*it1, value_type ());
++ it1;
@@ -831,6 +843,7 @@ namespace boost { namespace numeric { namespace ublas {
}
++ it2;
} else if (compare > 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
typename E::const_iterator1 it1e (it2e.begin ());
typename E::const_iterator1 it1e_end (it2e.end ());
while (it1e != it1e_end) {
@@ -841,9 +854,11 @@ namespace boost { namespace numeric { namespace ublas {
// The proxies could reference the same container.
restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ());
}
+#endif
++ it2e;
}
}
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
while (it2e != it2e_end) {
typename E::const_iterator1 it1e (it2e.begin ());
typename E::const_iterator1 it1e_end (it2e.end ());
@@ -857,6 +872,7 @@ namespace boost { namespace numeric { namespace ublas {
}
++ it2e;
}
+#endif
while (it2 != it2_end) {
typename M::iterator1 it1 (it2.begin ());
typename M::iterator1 it1_end (it2.end ());
@@ -1008,6 +1024,7 @@ namespace boost { namespace numeric { namespace ublas {
functor_type () (*it2, *it2e);
++ it2, ++ it2e;
} else if (compare < 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
// Sparse proxies don't need to be conformant.
// Thanks to Michael Stevens for suggesting this.
size_type index1 (it2.index1 ()), index2 (it2.index2 ());
@@ -1015,7 +1032,9 @@ namespace boost { namespace numeric { namespace ublas {
restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ());
// The proxies could reference the same container.
restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ());
+#endif
} else if (compare > 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
// Sparse proxies don't need to be conformant.
// Thanks to Michael Stevens for suggesting this.
size_type index1 (it2e.index1 ()), index2 (it2e.index2 ());
@@ -1023,8 +1042,10 @@ namespace boost { namespace numeric { namespace ublas {
restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ());
// The proxies could reference the same container.
restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ());
+#endif
}
}
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
while (it2e != it2e_end) {
// Sparse proxies don't need to be conformant.
// Thanks to Michael Stevens for suggesting this.
@@ -1043,8 +1064,10 @@ namespace boost { namespace numeric { namespace ublas {
restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ());
restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ());
}
+#endif
++ it1, ++ it1e;
} else if (compare < 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
typename M::iterator2 it2 (it1.begin ());
typename M::iterator2 it2_end (it1.end ());
while (it2 != it2_end) {
@@ -1055,8 +1078,10 @@ namespace boost { namespace numeric { namespace ublas {
// The proxies could reference the same container.
restart (m, index1, index2, it1, it1_end, it2, it2_end, row_major_tag ());
}
+#endif
++ it1;
} else if (compare > 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
typename E::iterator2 it2e (it1e.begin ());
typename E::iterator2 it2e_end (it1e.end ());
while (it2e != it2e_end) {
@@ -1067,9 +1092,11 @@ namespace boost { namespace numeric { namespace ublas {
// The proxies could reference the same container.
restart (e, index1, index2, it1e, it1e_end, it2e, it2e_end, row_major_tag ());
}
+#endif
++ it1e;
}
}
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
while (it1e != it1e_end) {
typename E::iterator2 it2e (it1e.begin ());
typename E::iterator2 it2e_end (it1e.end ());
@@ -1096,6 +1123,7 @@ namespace boost { namespace numeric { namespace ublas {
}
++ it1;
}
+#endif
}
// Sparse (proxy) column major case
template
@@ -1124,6 +1152,7 @@ namespace boost { namespace numeric { namespace ublas {
functor_type () (*it1, *it1e);
++ it1, ++ it1e;
} else if (compare < 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
// Sparse proxies don't need to be conformant.
// Thanks to Michael Stevens for suggesting this.
size_type index1 (it1.index1 ()), index2 (it1.index2 ());
@@ -1131,7 +1160,9 @@ namespace boost { namespace numeric { namespace ublas {
restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ());
// The proxies could reference the same container.
restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ());
+#endif
} else if (compare > 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
// Sparse proxies don't need to be conformant.
// Thanks to Michael Stevens for suggesting this.
size_type index1 (it1e.index1 ()), index2 (it1e.index2 ());
@@ -1139,8 +1170,10 @@ namespace boost { namespace numeric { namespace ublas {
restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ());
// The proxies could reference the same container.
restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ());
+#endif
}
}
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
while (it1e != it1e_end) {
// Sparse proxies don't need to be conformant.
// Thanks to Michael Stevens for suggesting this.
@@ -1159,8 +1192,10 @@ namespace boost { namespace numeric { namespace ublas {
restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ());
restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ());
}
+#endif
++ it2, ++ it2e;
} else if (compare < 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
typename M::iterator1 it1 (it2.begin ());
typename M::iterator1 it1_end (it2.end ());
while (it1 != it1_end) {
@@ -1171,8 +1206,10 @@ namespace boost { namespace numeric { namespace ublas {
// The proxies could reference the same container.
restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ());
}
+#endif
++ it2;
} else if (compare > 0) {
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
typename E::iterator1 it1e (it2e.begin ());
typename E::iterator1 it1e_end (it2e.end ());
while (it1e != it1e_end) {
@@ -1183,9 +1220,11 @@ namespace boost { namespace numeric { namespace ublas {
// The proxies could reference the same container.
restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ());
}
+#endif
++ it2e;
}
}
+#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
while (it2e != it2e_end) {
typename E::iterator1 it1e (it2e.begin ());
typename E::iterator1 it1e_end (it2e.end ());
@@ -1212,6 +1251,7 @@ namespace boost { namespace numeric { namespace ublas {
}
++ it2;
}
+#endif
}
// Dispatcher
diff --git a/include/boost/numeric/ublas/matrix_expression.hpp b/include/boost/numeric/ublas/matrix_expression.hpp
index 6da89536..e96ea81b 100644
--- a/include/boost/numeric/ublas/matrix_expression.hpp
+++ b/include/boost/numeric/ublas/matrix_expression.hpp
@@ -243,7 +243,7 @@ namespace boost { namespace numeric { namespace ublas {
// Element access
BOOST_UBLAS_INLINE
const_reference operator () (size_type i, size_type j) const {
- return e_ (i, j);
+ return expression () (i, j);
}
typedef const_iterator1_type const_iterator1;
@@ -254,39 +254,39 @@ namespace boost { namespace numeric { namespace ublas {
// Element lookup
BOOST_UBLAS_INLINE
const_iterator1 find_first1 (int rank, size_type i, size_type j) const {
- return const_iterator1 (e_.find_first1 (rank, i, j));
+ return expression ().find_first1 (rank, i, j);
}
BOOST_UBLAS_INLINE
const_iterator1 find_last1 (int rank, size_type i, size_type j) const {
- return const_iterator1 (e_.find_last1 (rank, i, j));
+ return expression ().find_last1 (rank, i, j);
}
BOOST_UBLAS_INLINE
const_iterator2 find_first2 (int rank, size_type i, size_type j) const {
- return const_iterator2 (e_.find_first2 (rank, i, j));
+ return expression ().find_first2 (rank, i, j);
}
BOOST_UBLAS_INLINE
const_iterator2 find_last2 (int rank, size_type i, size_type j) const {
- return const_iterator2 (e_.find_last2 (rank, i, j));
+ return expression ().find_last2 (rank, i, j);
}
// Iterators are the iterators of the referenced expression.
BOOST_UBLAS_INLINE
const_iterator1 begin1 () const {
- return e_.begin1 ();
+ return expression ().begin1 ();
}
BOOST_UBLAS_INLINE
const_iterator1 end1 () const {
- return e_.end1 ();
+ return expression ().end1 ();
}
BOOST_UBLAS_INLINE
const_iterator2 begin2 () const {
- return e_.begin2 ();
+ return expression ().begin2 ();
}
BOOST_UBLAS_INLINE
const_iterator2 end2 () const {
- return e_.end2 ();
+ return expression ().end2 ();
}
// Reverse iterators
@@ -380,17 +380,17 @@ namespace boost { namespace numeric { namespace ublas {
// Resizing
BOOST_UBLAS_INLINE
void resize (size_type size1, size_type size2) {
- e_.resize (size1, size2);
+ expression ().resize (size1, size2);
}
// Element access
BOOST_UBLAS_INLINE
const_reference operator () (size_type i, size_type j) const {
- return e_ (i, j);
+ return expression () (i, j);
}
BOOST_UBLAS_INLINE
reference operator () (size_type i, size_type j) {
- return e_ (i, j);
+ return expression () (i, j);
}
typedef const_iterator1_type const_iterator1;
@@ -401,73 +401,73 @@ namespace boost { namespace numeric { namespace ublas {
// Element lookup
BOOST_UBLAS_INLINE
const_iterator1 find_first1 (int rank, size_type i, size_type j) const {
- return const_iterator1 (e_.find_first1 (rank, i, j));
+ return expression ().find_first1 (rank, i, j);
}
BOOST_UBLAS_INLINE
iterator1 find_first1 (int rank, size_type i, size_type j) {
- return iterator1 (e_.find_first1 (rank, i, j));
+ return expression ().find_first1 (rank, i, j);
}
BOOST_UBLAS_INLINE
const_iterator1 find_last1 (int rank, size_type i, size_type j) const {
- return const_iterator1 (e_.find_last1 (rank, i, j));
+ return expression ().find_last1 (rank, i, j);
}
BOOST_UBLAS_INLINE
iterator1 find_last1 (int rank, size_type i, size_type j) {
- return iterator1 (e_.find_last1 (rank, i, j));
+ return expression ().find_last1 (rank, i, j);
}
BOOST_UBLAS_INLINE
const_iterator2 find_first2 (int rank, size_type i, size_type j) const {
- return const_iterator2 (e_.find_first2 (rank, i, j));
+ return expression ().find_first2 (rank, i, j);
}
BOOST_UBLAS_INLINE
iterator2 find_first2 (int rank, size_type i, size_type j) {
- return iterator2 (e_.find_first2 (rank, i, j));
+ return expression ().find_first2 (rank, i, j);
}
BOOST_UBLAS_INLINE
const_iterator2 find_last2 (int rank, size_type i, size_type j) const {
- return const_iterator2 (e_.find_last2 (rank, i, j));
+ return expression ().find_last2 (rank, i, j);
}
BOOST_UBLAS_INLINE
iterator2 find_last2 (int rank, size_type i, size_type j) {
- return iterator2 (e_.find_last2 (rank, i, j));
+ return expression ().find_last2 (rank, i, j);
}
// Iterators are the iterators of the referenced expression.
BOOST_UBLAS_INLINE
const_iterator1 begin1 () const {
- return e_.begin1 ();
+ return expression ().begin1 ();
}
BOOST_UBLAS_INLINE
const_iterator1 end1 () const {
- return e_.end1 ();
+ return expression ().end1 ();
}
BOOST_UBLAS_INLINE
iterator1 begin1 () {
- return e_.begin1 ();
+ return expression ().begin1 ();
}
BOOST_UBLAS_INLINE
iterator1 end1 () {
- return e_.end1 ();
+ return expression ().end1 ();
}
BOOST_UBLAS_INLINE
const_iterator2 begin2 () const {
- return e_.begin2 ();
+ return expression ().begin2 ();
}
BOOST_UBLAS_INLINE
const_iterator2 end2 () const {
- return e_.end2 ();
+ return expression ().end2 ();
}
BOOST_UBLAS_INLINE
iterator2 begin2 () {
- return e_.begin2 ();
+ return expression ().begin2 ();
}
BOOST_UBLAS_INLINE
iterator2 end2 () {
- return e_.end2 ();
+ return expression ().end2 ();
}
// Reverse iterators
@@ -557,7 +557,10 @@ namespace boost { namespace numeric { namespace ublas {
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
+ typedef typename E1::const_closure_type expression1_closure_type;
+ typedef typename E2::const_closure_type expression2_closure_type;
typedef const vector_matrix_binary const_closure_type;
+ typedef const_closure_type closure_type;
typedef unknown_orientation_tag orientation_category;
typedef typename E1::const_iterator const_iterator1_type;
typedef typename E2::const_iterator const_iterator2_type;
@@ -581,11 +584,11 @@ namespace boost { namespace numeric { namespace ublas {
return e2_.size ();
}
BOOST_UBLAS_INLINE
- const expression1_type &expression1 () const {
+ const expression1_closure_type &expression1 () const {
return e1_;
}
BOOST_UBLAS_INLINE
- const expression2_type &expression2 () const {
+ const expression2_closure_type &expression2 () const {
return e2_;
}
@@ -1026,20 +1029,13 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
-#ifdef BOOST_UBLAS_ET_VALUE
- expression1_type e1_;
- expression2_type e2_;
-#endif
-#ifdef BOOST_UBLAS_ET_REFERENCE
- const expression1_type &e1_;
- const expression2_type &e2_;
-#endif
+ expression1_closure_type e1_;
+ expression2_closure_type e2_;
};
template
struct vector_matrix_binary_traits {
- typedef vector_matrix_binary expression_type;
+ typedef vector_matrix_binary expression_type;
#ifdef BOOST_UBLAS_USE_ET
typedef expression_type result_type;
#else
@@ -1073,7 +1069,9 @@ namespace boost { namespace numeric { namespace ublas {
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
+ typedef typename E::const_closure_type expression_closure_type;
typedef const matrix_unary1 const_closure_type;
+ typedef const_closure_type closure_type;
typedef typename E::orientation_category orientation_category;
typedef typename E::const_iterator1 const_iterator1_type;
typedef typename E::const_iterator2 const_iterator2_type;
@@ -1097,7 +1095,7 @@ namespace boost { namespace numeric { namespace ublas {
return e_.size2 ();
}
BOOST_UBLAS_INLINE
- const expression_type &expression () const {
+ const expression_closure_type &expression () const {
return e_;
}
@@ -1436,17 +1434,12 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
-#ifdef BOOST_UBLAS_ET_VALUE
- expression_type e_;
-#endif
-#ifdef BOOST_UBLAS_ET_REFERENCE
- const expression_type &e_;
-#endif
+ expression_closure_type e_;
};
template
struct matrix_unary1_traits {
- typedef matrix_unary1 expression_type;
+ typedef matrix_unary1 expression_type;
#ifdef BOOST_UBLAS_USE_ET
typedef expression_type result_type;
#else
@@ -1506,7 +1499,9 @@ namespace boost { namespace numeric { namespace ublas {
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
+ typedef typename E::const_closure_type expression_closure_type;
typedef const matrix_unary2 const_closure_type;
+ typedef const_closure_type closure_type;
typedef typename E::orientation_category orientation_category;
typedef typename E::const_iterator1 const_iterator2_type;
typedef typename E::const_iterator2 const_iterator1_type;
@@ -1530,7 +1525,7 @@ namespace boost { namespace numeric { namespace ublas {
return e_.size1 ();
}
BOOST_UBLAS_INLINE
- const expression_type &expression () const {
+ const expression_closure_type &expression () const {
return e_;
}
@@ -1869,17 +1864,12 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
-#ifdef BOOST_UBLAS_ET_VALUE
- expression_type e_;
-#endif
-#ifdef BOOST_UBLAS_ET_REFERENCE
- const expression_type &e_;
-#endif
+ expression_closure_type e_;
};
template
struct matrix_unary2_traits {
- typedef matrix_unary2 expression_type;
+ typedef matrix_unary2 expression_type;
#ifdef BOOST_UBLAS_USE_ET
typedef expression_type result_type;
#else
@@ -1922,7 +1912,10 @@ namespace boost { namespace numeric { namespace ublas {
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
+ typedef typename E1::const_closure_type expression1_closure_type;
+ typedef typename E2::const_closure_type expression2_closure_type;
typedef const matrix_binary const_closure_type;
+ typedef const_closure_type closure_type;
typedef unknown_orientation_tag orientation_category;
typedef typename E1::const_iterator1 const_iterator11_type;
typedef typename E1::const_iterator2 const_iterator12_type;
@@ -1948,11 +1941,11 @@ namespace boost { namespace numeric { namespace ublas {
return BOOST_UBLAS_SAME (e1_.size2 (), e2_.size2 ());
}
BOOST_UBLAS_INLINE
- const expression1_type &expression1 () const {
+ const expression1_closure_type &expression1 () const {
return e1_;
}
BOOST_UBLAS_INLINE
- const expression2_type &expression2 () const {
+ const expression2_closure_type &expression2 () const {
return e2_;
}
@@ -2571,20 +2564,13 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
-#ifdef BOOST_UBLAS_ET_VALUE
- expression1_type e1_;
- expression2_type e2_;
-#endif
-#ifdef BOOST_UBLAS_ET_REFERENCE
- const expression1_type &e1_;
- const expression2_type &e2_;
-#endif
+ expression1_closure_type e1_;
+ expression2_closure_type e2_;
};
template
struct matrix_binary_traits {
- typedef matrix_binary expression_type;
+ typedef matrix_binary expression_type;
#ifdef BOOST_UBLAS_USE_ET
typedef expression_type result_type;
#else
@@ -2633,7 +2619,10 @@ namespace boost { namespace numeric { namespace ublas {
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
+ typedef E1 expression1_closure_type;
+ typedef typename E2::const_closure_type expression2_closure_type;
typedef const matrix_binary_scalar1 const_closure_type;
+ typedef const_closure_type closure_type;
typedef typename E2::orientation_category orientation_category;
typedef typename E1::value_type const_iterator1_type;
typedef typename E2::const_iterator1 const_iterator21_type;
@@ -2658,11 +2647,11 @@ namespace boost { namespace numeric { namespace ublas {
return e2_.size2 ();
}
BOOST_UBLAS_INLINE
- const expression1_type &expression1 () const {
+ const expression1_closure_type &expression1 () const {
return e1_;
}
BOOST_UBLAS_INLINE
- const expression2_type &expression2 () const {
+ const expression2_closure_type &expression2 () const {
return e2_;
}
@@ -3013,20 +3002,13 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
-#ifdef BOOST_UBLAS_ET_VALUE
- expression1_type e1_;
- expression2_type e2_;
-#endif
-#ifdef BOOST_UBLAS_ET_REFERENCE
- const expression1_type &e1_;
- const expression2_type &e2_;
-#endif
+ expression1_closure_type e1_;
+ expression2_closure_type e2_;
};
template
struct matrix_binary_scalar1_traits {
- typedef matrix_binary_scalar1,
- typename E2::const_closure_type, F> expression_type;
+ typedef matrix_binary_scalar1, E2, F> expression_type;
#ifdef BOOST_UBLAS_USE_ET
typedef expression_type result_type;
#else
@@ -3061,7 +3043,10 @@ namespace boost { namespace numeric { namespace ublas {
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
+ typedef typename E1::const_closure_type expression1_closure_type;
+ typedef E2 expression2_closure_type;
typedef const matrix_binary_scalar2 const_closure_type;
+ typedef const_closure_type closure_type;
typedef typename E1::orientation_category orientation_category;
typedef typename E1::const_iterator1 const_iterator11_type;
typedef typename E1::const_iterator2 const_iterator12_type;
@@ -3086,11 +3071,11 @@ namespace boost { namespace numeric { namespace ublas {
return e1_.size2 ();
}
BOOST_UBLAS_INLINE
- const expression1_type &expression1 () const {
+ const expression1_closure_type &expression1 () const {
return e1_;
}
BOOST_UBLAS_INLINE
- const expression2_type &expression2 () const {
+ const expression2_closure_type &expression2 () const {
return e2_;
}
@@ -3441,20 +3426,13 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
-#ifdef BOOST_UBLAS_ET_VALUE
- expression1_type e1_;
- expression2_type e2_;
-#endif
-#ifdef BOOST_UBLAS_ET_REFERENCE
- const expression1_type &e1_;
- const expression2_type &e2_;
-#endif
+ expression1_closure_type e1_;
+ expression2_closure_type e2_;
};
template
struct matrix_binary_scalar2_traits {
- typedef matrix_binary_scalar2, F> expression_type;
+ typedef matrix_binary_scalar2, F> expression_type;
#ifdef BOOST_UBLAS_USE_ET
typedef expression_type result_type;
#else
@@ -3499,7 +3477,10 @@ namespace boost { namespace numeric { namespace ublas {
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
+ typedef typename E1::const_closure_type expression1_closure_type;
+ typedef typename E2::const_closure_type expression2_closure_type;
typedef const matrix_vector_binary1 const_closure_type;
+ typedef const_closure_type closure_type;
typedef typename E1::const_iterator1 const_iterator1_type;
typedef typename E2::const_iterator const_iterator2_type;
typedef unknown_storage_tag storage_category;
@@ -3518,11 +3499,11 @@ namespace boost { namespace numeric { namespace ublas {
return e1_.size1 ();
}
BOOST_UBLAS_INLINE
- const expression1_type &expression1 () const {
+ const expression1_closure_type &expression1 () const {
return e1_;
}
BOOST_UBLAS_INLINE
- const expression2_type &expression2 () const {
+ const expression2_closure_type &expression2 () const {
return e2_;
}
@@ -3755,14 +3736,8 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
-#ifdef BOOST_UBLAS_ET_VALUE
- expression1_type e1_;
- expression2_type e2_;
-#endif
-#ifdef BOOST_UBLAS_ET_REFERENCE
- const expression1_type &e1_;
- const expression2_type &e2_;
-#endif
+ expression1_closure_type e1_;
+ expression2_closure_type e2_;
};
template
@@ -3770,9 +3745,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef unknown_storage_tag storage_category;
typedef row_major_tag orientation_category;
typedef typename promote_traits::promote_type promote_type;
- typedef matrix_vector_binary1 > expression_type;
+ typedef matrix_vector_binary1 > expression_type;
#ifdef BOOST_UBLAS_USE_ET
typedef expression_type result_type;
#else
@@ -3867,7 +3840,10 @@ namespace boost { namespace numeric { namespace ublas {
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
+ typedef typename E1::const_closure_type expression1_closure_type;
+ typedef typename E2::const_closure_type expression2_closure_type;
typedef const matrix_vector_binary2 const_closure_type;
+ typedef const_closure_type closure_type;
typedef typename E1::const_iterator const_iterator1_type;
typedef typename E2::const_iterator2 const_iterator2_type;
typedef unknown_storage_tag storage_category;
@@ -3886,11 +3862,11 @@ namespace boost { namespace numeric { namespace ublas {
return e2_.size2 ();
}
BOOST_UBLAS_INLINE
- const expression1_type &expression1 () const {
+ const expression1_closure_type &expression1 () const {
return e1_;
}
BOOST_UBLAS_INLINE
- const expression2_type &expression2 () const {
+ const expression2_closure_type &expression2 () const {
return e2_;
}
@@ -4124,14 +4100,8 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
-#ifdef BOOST_UBLAS_ET_VALUE
- expression1_type e1_;
- expression2_type e2_;
-#endif
-#ifdef BOOST_UBLAS_ET_REFERENCE
- const expression1_type &e1_;
- const expression2_type &e2_;
-#endif
+ expression1_closure_type e1_;
+ expression2_closure_type e2_;
};
template
@@ -4139,9 +4109,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef unknown_storage_tag storage_category;
typedef column_major_tag orientation_category;
typedef typename promote_traits::promote_type promote_type;
- typedef matrix_vector_binary2 > expression_type;
+ typedef matrix_vector_binary2 > expression_type;
#ifdef BOOST_UBLAS_USE_ET
typedef expression_type result_type;
#else
@@ -4236,7 +4204,10 @@ namespace boost { namespace numeric { namespace ublas {
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
+ typedef typename E1::const_closure_type expression1_closure_type;
+ typedef typename E2::const_closure_type expression2_closure_type;
typedef const matrix_matrix_binary const_closure_type;
+ typedef const_closure_type closure_type;
typedef unknown_orientation_tag orientation_category;
typedef typename E1::const_iterator1 const_iterator11_type;
typedef typename E1::const_iterator2 const_iterator12_type;
@@ -4262,11 +4233,11 @@ namespace boost { namespace numeric { namespace ublas {
return e2_.size2 ();
}
BOOST_UBLAS_INLINE
- const expression1_type &expression1 () const {
+ const expression1_closure_type &expression1 () const {
return e1_;
}
BOOST_UBLAS_INLINE
- const expression2_type &expression2 () const {
+ const expression2_closure_type &expression2 () const {
return e2_;
}
@@ -4767,14 +4738,8 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
-#ifdef BOOST_UBLAS_ET_VALUE
- expression1_type e1_;
- expression2_type e2_;
-#endif
-#ifdef BOOST_UBLAS_ET_REFERENCE
- const expression1_type &e1_;
- const expression2_type &e2_;
-#endif
+ expression1_closure_type e1_;
+ expression2_closure_type e2_;
};
template
@@ -4782,9 +4747,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef unknown_storage_tag storage_category;
typedef unknown_orientation_tag orientation_category;
typedef typename promote_traits::promote_type promote_type;
- typedef matrix_matrix_binary > expression_type;
+ typedef matrix_matrix_binary > expression_type;
#ifdef BOOST_UBLAS_USE_ET
typedef expression_type result_type;
#else
@@ -4869,6 +4832,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef E expression_type;
typedef F functor_type;
typedef typename F::result_type value_type;
+ typedef typename E::const_closure_type expression_closure_type;
// Construction and destruction
BOOST_UBLAS_INLINE
@@ -4880,7 +4844,7 @@ namespace boost { namespace numeric { namespace ublas {
// Accessors
BOOST_UBLAS_INLINE
- const expression_type &expression () const {
+ const expression_closure_type &expression () const {
return e_;
}
@@ -4890,17 +4854,12 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
-#ifdef BOOST_UBLAS_ET_VALUE
- expression_type e_;
-#endif
-#ifdef BOOST_UBLAS_ET_REFERENCE
- const expression_type &e_;
-#endif
+ expression_closure_type e_;
};
template
struct matrix_scalar_unary_traits {
- typedef matrix_scalar_unary expression_type;
+ typedef matrix_scalar_unary expression_type;
#ifdef BOOST_UBLAS_USE_ET
typedef expression_type result_type;
#else
diff --git a/include/boost/numeric/ublas/matrix_proxy.hpp b/include/boost/numeric/ublas/matrix_proxy.hpp
index 5b9609a9..65a69dea 100644
--- a/include/boost/numeric/ublas/matrix_proxy.hpp
+++ b/include/boost/numeric/ublas/matrix_proxy.hpp
@@ -38,7 +38,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
@@ -53,15 +53,16 @@ namespace boost { namespace numeric { namespace ublas {
typename M::const_pointer,
typename M::pointer>::type pointer;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_REFERENCE
- typedef const vector_const_reference > const_closure_type;
- typedef vector_reference > closure_type;
+#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
+ typedef typename M::closure_type matrix_closure_type;
+#else
+ typedef typename detail::ct_if::value,
+ typename M::const_closure_type,
+ typename M::closure_type>::type matrix_closure_type;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_VALUE
typedef const matrix_row const_closure_type;
typedef matrix_row closure_type;
-#endif
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_iterator2 const_iterator_type;
typedef typename M::iterator2 iterator_type;
#else
@@ -94,11 +95,11 @@ namespace boost { namespace numeric { namespace ublas {
return i_;
}
BOOST_UBLAS_INLINE
- const_matrix_type &data () const {
+ const matrix_closure_type &data () const {
return data_;
}
BOOST_UBLAS_INLINE
- matrix_type &data () {
+ matrix_closure_type &data () {
return data_;
}
@@ -509,7 +510,7 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
- matrix_type &data_;
+ matrix_closure_type data_;
size_type i_;
static matrix_type nil_;
};
@@ -526,7 +527,7 @@ namespace boost { namespace numeric { namespace ublas {
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template
BOOST_UBLAS_INLINE
- const matrix_row row (const M &data, std::size_t i) {
+ matrix_row row (const M &data, std::size_t i) {
return matrix_row (data, i);
}
#endif
@@ -544,7 +545,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
@@ -559,15 +560,16 @@ namespace boost { namespace numeric { namespace ublas {
typename M::const_pointer,
typename M::pointer>::type pointer;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_REFERENCE
- typedef const vector_const_reference > const_closure_type;
- typedef vector_reference > closure_type;
+#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
+ typedef typename M::closure_type matrix_closure_type;
+#else
+ typedef typename detail::ct_if::value,
+ typename M::const_closure_type,
+ typename M::closure_type>::type matrix_closure_type;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_VALUE
typedef const matrix_column const_closure_type;
typedef matrix_column closure_type;
-#endif
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_iterator1 const_iterator_type;
typedef typename M::iterator1 iterator_type;
#else
@@ -600,11 +602,11 @@ namespace boost { namespace numeric { namespace ublas {
return j_;
}
BOOST_UBLAS_INLINE
- const_matrix_type &data () const {
+ const matrix_closure_type &data () const {
return data_;
}
BOOST_UBLAS_INLINE
- matrix_type &data () {
+ matrix_closure_type &data () {
return data_;
}
@@ -1015,7 +1017,7 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
- matrix_type &data_;
+ matrix_closure_type data_;
size_type j_;
static matrix_type nil_;
};
@@ -1032,7 +1034,7 @@ namespace boost { namespace numeric { namespace ublas {
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template
BOOST_UBLAS_INLINE
- const matrix_column column (const M &data, std::size_t j) {
+ matrix_column column (const M &data, std::size_t j) {
return matrix_column (data, j);
}
#endif
@@ -1050,7 +1052,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
@@ -1065,14 +1067,15 @@ namespace boost { namespace numeric { namespace ublas {
typename M::const_pointer,
typename M::pointer>::type pointer;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_REFERENCE
- typedef const vector_const_reference > const_closure_type;
- typedef vector_reference > closure_type;
+#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
+ typedef typename M::closure_type matrix_closure_type;
+#else
+ typedef typename detail::ct_if::value,
+ typename M::const_closure_type,
+ typename M::closure_type>::type matrix_closure_type;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_VALUE
typedef const matrix_vector_range const_closure_type;
typedef matrix_vector_range closure_type;
-#endif
#ifdef BOOST_UBLAS_ENABLE_INDEX_SET_ALL
typedef range<>::const_iterator const_iterator1_type;
typedef range<>::const_iterator iterator1_type;
@@ -1089,7 +1092,7 @@ namespace boost { namespace numeric { namespace ublas {
// Construction and destruction
BOOST_UBLAS_INLINE
- matrix_vector_range ():
+ matrix_vector_range ():
data_ (nil_), r1_ (), r2_ () {}
#ifdef BOOST_UBLAS_ENABLE_INDEX_SET_ALL
BOOST_UBLAS_INLINE
@@ -1121,11 +1124,11 @@ namespace boost { namespace numeric { namespace ublas {
return BOOST_UBLAS_SAME (r1_.size (), r2_.size ());
}
BOOST_UBLAS_INLINE
- const_matrix_type &data () const {
+ const matrix_closure_type &data () const {
return data_;
}
BOOST_UBLAS_INLINE
- matrix_type &data () {
+ matrix_closure_type &data () {
return data_;
}
@@ -1528,7 +1531,7 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
- matrix_type &data_;
+ matrix_closure_type data_;
#ifdef BOOST_UBLAS_ENABLE_INDEX_SET_ALL
range<> r1_;
range<> r2_;
@@ -1555,7 +1558,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
@@ -1570,14 +1573,15 @@ namespace boost { namespace numeric { namespace ublas {
typename M::const_pointer,
typename M::pointer>::type pointer;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_REFERENCE
- typedef const vector_const_reference > const_closure_type;
- typedef vector_reference > closure_type;
+#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
+ typedef typename M::closure_type matrix_closure_type;
+#else
+ typedef typename detail::ct_if::value,
+ typename M::const_closure_type,
+ typename M::closure_type>::type matrix_closure_type;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_VALUE
typedef const matrix_vector_slice const_closure_type;
typedef matrix_vector_slice closure_type;
-#endif
#ifdef BOOST_UBLAS_ENABLE_INDEX_SET_ALL
typedef slice<>::const_iterator const_iterator1_type;
typedef slice<>::const_iterator iterator1_type;
@@ -1629,14 +1633,14 @@ namespace boost { namespace numeric { namespace ublas {
// Accessors
BOOST_UBLAS_INLINE
size_type size () const {
- return BOOST_UBLAS_SAME (s1_.size (), s2_.size ());
+ return BOOST_UBLAS_SAME (s1_.size (), s2_.size ());
}
BOOST_UBLAS_INLINE
- const_matrix_type &data () const {
+ const matrix_closure_type &data () const {
return data_;
}
BOOST_UBLAS_INLINE
- matrix_type &data () {
+ matrix_closure_type &data () {
return data_;
}
@@ -2051,7 +2055,7 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
- matrix_type &data_;
+ matrix_closure_type data_;
#ifdef BOOST_UBLAS_ENABLE_INDEX_SET_ALL
slice<> s1_;
slice<> s2_;
@@ -2080,7 +2084,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
@@ -2095,14 +2099,15 @@ namespace boost { namespace numeric { namespace ublas {
typename M::const_pointer,
typename M::pointer>::type pointer;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_REFERENCE
- typedef const vector_const_reference > const_closure_type;
- typedef vector_reference > closure_type;
+#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
+ typedef typename M::closure_type matrix_closure_type;
+#else
+ typedef typename detail::ct_if::value,
+ typename M::const_closure_type,
+ typename M::closure_type>::type matrix_closure_type;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_VALUE
typedef const matrix_vector_indirect const_closure_type;
typedef matrix_vector_indirect closure_type;
-#endif
typedef typename IA::const_iterator const_iterator1_type;
typedef typename IA::const_iterator iterator1_type;
typedef typename IA::const_iterator const_iterator2_type;
@@ -2130,11 +2135,11 @@ namespace boost { namespace numeric { namespace ublas {
return BOOST_UBLAS_SAME (ia1_.size (), ia2_.size ());
}
BOOST_UBLAS_INLINE
- const_matrix_type &data () const {
+ const matrix_closure_type &data () const {
return data_;
}
BOOST_UBLAS_INLINE
- matrix_type &data () {
+ matrix_closure_type &data () {
return data_;
}
BOOST_UBLAS_INLINE
@@ -2553,7 +2558,7 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
- matrix_type &data_;
+ matrix_closure_type data_;
indirect_array_type ia1_;
indirect_array_type ia2_;
static matrix_type nil_;
@@ -2575,7 +2580,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
@@ -2590,15 +2595,16 @@ namespace boost { namespace numeric { namespace ublas {
typename M::const_pointer,
typename M::pointer>::type pointer;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_REFERENCE
- typedef const matrix_const_reference > const_closure_type;
- typedef matrix_reference > closure_type;
+#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
+ typedef typename M::closure_type matrix_closure_type;
+#else
+ typedef typename detail::ct_if::value,
+ typename M::const_closure_type,
+ typename M::closure_type>::type matrix_closure_type;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_VALUE
typedef const matrix_range const_closure_type;
typedef matrix_range closure_type;
-#endif
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_iterator1 const_iterator1_type;
typedef typename M::iterator1 iterator1_type;
typedef typename M::const_iterator2 const_iterator2_type;
@@ -2631,6 +2637,15 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_CHECK (r2_.start () <= data_.size2 () &&
r2_.start () + r2_.size () <= data_.size2 (), bad_index ());
}
+ BOOST_UBLAS_INLINE
+ matrix_range (const matrix_closure_type &data, const range<> &r1, const range<> &r2, int):
+ data_ (data), r1_ (r1.preprocess (data.size1 ())), r2_ (r2.preprocess (data.size2 ())) {
+ // Early checking of preconditions.
+ BOOST_UBLAS_CHECK (r1_.start () <= data_.size1 () &&
+ r1_.start () + r1_.size () <= data_.size1 (), bad_index ());
+ BOOST_UBLAS_CHECK (r2_.start () <= data_.size2 () &&
+ r2_.start () + r2_.size () <= data_.size2 (), bad_index ());
+ }
#else
BOOST_UBLAS_INLINE
matrix_range (matrix_type &data, const range &r1, const range &r2):
@@ -2641,31 +2656,40 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_CHECK (r2_.start () <= data_.size2 () &&
r2_.start () + r2_.size () <= data_.size2 (), bad_index ());
}
+ BOOST_UBLAS_INLINE
+ matrix_range (const matrix_closure_type &data, const range &r1, const range &r2, int):
+ data_ (data), r1_ (r1), r2_ (r2) {
+ // Early checking of preconditions.
+ BOOST_UBLAS_CHECK (r1_.start () <= data_.size1 () &&
+ r1_.start () + r1_.size () <= data_.size1 (), bad_index ());
+ BOOST_UBLAS_CHECK (r2_.start () <= data_.size2 () &&
+ r2_.start () + r2_.size () <= data_.size2 (), bad_index ());
+ }
#endif
// Accessors
BOOST_UBLAS_INLINE
size_type start1 () const {
- return r1_.start ();
+ return r1_.start ();
}
BOOST_UBLAS_INLINE
- size_type size1 () const {
+ size_type size1 () const {
return r1_.size ();
}
BOOST_UBLAS_INLINE
- size_type start2() const {
- return r2_.start ();
+ size_type start2() const {
+ return r2_.start ();
}
BOOST_UBLAS_INLINE
size_type size2 () const {
return r2_.size ();
}
BOOST_UBLAS_INLINE
- const_matrix_type &data () const {
+ const matrix_closure_type &data () const {
return data_;
}
BOOST_UBLAS_INLINE
- matrix_type &data () {
+ matrix_closure_type &data () {
return data_;
}
@@ -2698,23 +2722,23 @@ namespace boost { namespace numeric { namespace ublas {
#ifdef BOOST_UBLAS_ENABLE_INDEX_SET_ALL
BOOST_UBLAS_INLINE
matrix_range project (const range<> &r1, const range<> &r2) const {
- return matrix_range (data_, r1_.compose (r1), r2_.compose (r2));
+ return matrix_range (data_, r1_.compose (r1), r2_.compose (r2), 0);
}
#else
BOOST_UBLAS_INLINE
matrix_range project (const range &r1, const range &r2) const {
- return matrix_range (data_, r1_.compose (r1), r2_.compose (r2));
+ return matrix_range (data_, r1_.compose (r1), r2_.compose (r2), 0);
}
#endif
// Assignment
BOOST_UBLAS_INLINE
- matrix_range &operator = (const matrix_range &mr) {
- matrix_assign (scalar_assign (), *this, mr);
+ matrix_range &operator = (const matrix_range &mr) {
+ matrix_assign (scalar_assign (), *this, mr);
return *this;
}
BOOST_UBLAS_INLINE
- matrix_range &assign_temporary (matrix_range &mr) {
+ matrix_range &assign_temporary (matrix_range &mr) {
return *this = mr;
}
template
@@ -2744,7 +2768,7 @@ namespace boost { namespace numeric { namespace ublas {
template
BOOST_UBLAS_INLINE
matrix_range& operator -= (const matrix_expression &ae) {
- matrix_assign (scalar_assign (), *this, matrix (*this - ae));
+ matrix_assign (scalar_assign (), *this, matrix (*this - ae));
return *this;
}
template
@@ -2894,8 +2918,13 @@ namespace boost { namespace numeric { namespace ublas {
public iterator_base_traits::template
iterator_base::type {
#else
+#ifndef BOOST_MSVC
public random_access_iterator_base {
+#else
+ public random_access_iterator_base {
+#endif
#endif
public:
typedef typename const_iterator1_type::iterator_category iterator_category;
@@ -3019,8 +3048,13 @@ namespace boost { namespace numeric { namespace ublas {
public iterator_base_traits::template
iterator_base::type {
#else
+#ifndef BOOST_MSVC
public random_access_iterator_base {
+#else
+ public random_access_iterator_base {
+#endif
#endif
public:
typedef typename iterator1_type::iterator_category iterator_category;
@@ -3143,8 +3177,13 @@ namespace boost { namespace numeric { namespace ublas {
public iterator_base_traits::template
iterator_base::type {
#else
+#ifndef BOOST_MSVC
public random_access_iterator_base {
+#else
+ public random_access_iterator_base {
+#endif
#endif
public:
typedef typename const_iterator2_type::iterator_category iterator_category;
@@ -3268,8 +3307,13 @@ namespace boost { namespace numeric { namespace ublas {
public iterator_base_traits::template
iterator_base::type {
#else
+#ifndef BOOST_MSVC
public random_access_iterator_base {
+#else
+ public random_access_iterator_base {
+#endif
#endif
public:
typedef typename iterator2_type::iterator_category iterator_category;
@@ -3424,7 +3468,7 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
- matrix_type &data_;
+ matrix_closure_type data_;
#ifdef BOOST_UBLAS_ENABLE_INDEX_SET_ALL
range<> r1_;
range<> r2_;
@@ -3448,7 +3492,7 @@ namespace boost { namespace numeric { namespace ublas {
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template
BOOST_UBLAS_INLINE
- const matrix_range project (const M &data, const range<> &r1, const range<> &r2) {
+ matrix_range project (const M &data, const range<> &r1, const range<> &r2) {
return matrix_range (data, r1, r2);
}
template
@@ -3466,7 +3510,7 @@ namespace boost { namespace numeric { namespace ublas {
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template
BOOST_UBLAS_INLINE
- const matrix_range project (const M &data, const range &r1, const range &r2) {
+ matrix_range project (const M &data, const range &r1, const range &r2) {
return matrix_range (data, r1, r2);
}
template
@@ -3490,7 +3534,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
@@ -3505,14 +3549,15 @@ namespace boost { namespace numeric { namespace ublas {
typename M::const_pointer,
typename M::pointer>::type pointer;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_REFERENCE
- typedef const matrix_const_reference > const_closure_type;
- typedef matrix_reference > closure_type;
+#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
+ typedef typename M::closure_type matrix_closure_type;
+#else
+ typedef typename detail::ct_if::value,
+ typename M::const_closure_type,
+ typename M::closure_type>::type matrix_closure_type;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_VALUE
typedef const matrix_slice const_closure_type;
typedef matrix_slice closure_type;
-#endif
#ifdef BOOST_UBLAS_ENABLE_INDEX_SET_ALL
typedef slice<>::const_iterator const_iterator1_type;
typedef slice<>::const_iterator iterator1_type;
@@ -3542,6 +3587,15 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_CHECK (s2_.start () <= data_.size2 () &&
s2_.start () + s2_.stride () * (s2_.size () - (s2_.size () > 0)) <= data_.size2 (), bad_index ());
}
+ BOOST_UBLAS_INLINE
+ matrix_slice (const matrix_closure_type &data, const slice<> &s1, const slice<> &s2, int):
+ data_ (data), s1_ (s1.preprocess (data.size1 ())), s2_ (s2.preprocess (data.size2 ())) {
+ // Early checking of preconditions.
+ BOOST_UBLAS_CHECK (s1_.start () <= data_.size1 () &&
+ s1_.start () + s1_.stride () * (s1_.size () - (s1_.size () > 0)) <= data_.size1 (), bad_index ());
+ BOOST_UBLAS_CHECK (s2_.start () <= data_.size2 () &&
+ s2_.start () + s2_.stride () * (s2_.size () - (s2_.size () > 0)) <= data_.size2 (), bad_index ());
+ }
#else
BOOST_UBLAS_INLINE
matrix_slice (matrix_type &data, const slice &s1, const slice &s2):
@@ -3552,6 +3606,15 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_CHECK (s2_.start () <= data_.size2 () &&
s2_.start () + s2_.stride () * (s2_.size () - (s2_.size () > 0)) <= data_.size2 (), bad_index ());
}
+ BOOST_UBLAS_INLINE
+ matrix_slice (const matrix_closure_type &data, const slice &s1, const slice &s2, int):
+ data_ (data), s1_ (s1), s2_ (s2) {
+ // Early checking of preconditions.
+ BOOST_UBLAS_CHECK (s1_.start () <= data_.size1 () &&
+ s1_.start () + s1_.stride () * (s1_.size () - (s1_.size () > 0)) <= data_.size1 (), bad_index ());
+ BOOST_UBLAS_CHECK (s2_.start () <= data_.size2 () &&
+ s2_.start () + s2_.stride () * (s2_.size () - (s2_.size () > 0)) <= data_.size2 (), bad_index ());
+ }
#endif
// Accessors
@@ -3580,11 +3643,11 @@ namespace boost { namespace numeric { namespace ublas {
return s2_.size ();
}
BOOST_UBLAS_INLINE
- const_matrix_type &data () const {
+ const matrix_closure_type &data () const {
return data_;
}
BOOST_UBLAS_INLINE
- matrix_type &data () {
+ matrix_closure_type &data () {
return data_;
}
@@ -3617,20 +3680,20 @@ namespace boost { namespace numeric { namespace ublas {
#ifdef BOOST_UBLAS_ENABLE_INDEX_SET_ALL
BOOST_UBLAS_INLINE
matrix_slice project (const range<> &r1, const range<> &r2) const {
- return matrix_slice (data_, s1_.compose (r1), s2_.compose (r2));
+ return matrix_slice (data_, s1_.compose (r1), s2_.compose (r2), 0);
}
BOOST_UBLAS_INLINE
matrix_slice project (const slice<> &s1, const slice<> &s2) const {
- return matrix_slice (data_, s1_.compose (s1), s2_.compose (s2));
+ return matrix_slice (data_, s1_.compose (s1), s2_.compose (s2), 0);
}
#else
BOOST_UBLAS_INLINE
matrix_slice project (const range &r1, const range &r2) const {
- return matrix_slice (data_, s1_.compose (r1), s2_.compose (r2));
+ return matrix_slice (data_, s1_.compose (r1), s2_.compose (r2), 0);
}
BOOST_UBLAS_INLINE
matrix_slice project (const slice &s1, const slice &s2) const {
- return matrix_slice (data_, s1_.compose (s1), s2_.compose (s2));
+ return matrix_slice (data_, s1_.compose (s1), s2_.compose (s2), 0);
}
#endif
@@ -3671,7 +3734,7 @@ namespace boost { namespace numeric { namespace ublas {
template
BOOST_UBLAS_INLINE
matrix_slice& operator -= (const matrix_expression &ae) {
- matrix_assign (scalar_assign (), *this, matrix (*this - ae));
+ matrix_assign (scalar_assign (), *this, matrix (*this - ae));
return *this;
}
template
@@ -4343,7 +4406,7 @@ namespace boost { namespace numeric { namespace ublas {
}
private:
- matrix_type &data_;
+ matrix_closure_type data_;
#ifdef BOOST_UBLAS_ENABLE_INDEX_SET_ALL
slice<> s1_;
slice<> s2_;
@@ -4374,7 +4437,7 @@ namespace boost { namespace numeric { namespace ublas {
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template
BOOST_UBLAS_INLINE
- const matrix_slice project (const M &data, const slice<> &s1, const slice<> &s2) {
+ matrix_slice project (const M &data, const slice<> &s1, const slice<> &s2) {
return matrix_slice (data, s1, s2);
}
template
@@ -4399,7 +4462,7 @@ namespace boost { namespace numeric { namespace ublas {
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template
BOOST_UBLAS_INLINE
- const matrix_slice project (const M &data, const slice &s1, const slice &s2) {
+ matrix_slice project (const M &data, const slice &s1, const slice &s2) {
return matrix_slice (data, s1, s2);
}
template
@@ -4427,7 +4490,7 @@ namespace boost { namespace numeric { namespace ublas {
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
-#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
@@ -4442,14 +4505,15 @@ namespace boost { namespace numeric { namespace ublas {
typename M::const_pointer,
typename M::pointer>::type pointer;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_REFERENCE
- typedef const matrix_const_reference > const_closure_type;
- typedef matrix_reference > closure_type;
+#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS
+ typedef typename M::closure_type matrix_closure_type;
+#else
+ typedef typename detail::ct_if::value,
+ typename M::const_closure_type,
+ typename M::closure_type>::type matrix_closure_type;
#endif
-#ifdef BOOST_UBLAS_ET_CLOSURE_VALUE
typedef const matrix_indirect