diff --git a/doc/banded.htm b/doc/banded.htm index 84581ae4..32cc9ead 100644 --- a/doc/banded.htm +++ b/doc/banded.htm @@ -1,1206 +1,604 @@ + -
- - -
Banded Matrix
+Banded MatrixThe templated class banded_matrix<T, F, A> is
-the base container adaptor for banded matrices. For a (m x n)-dimensional
-banded matrix with l lower and u upper
-diagonals and 0 <= i < m, 0 <= j < n
-holds bi, j = 0, if i
-> j + l or i < j - u. The storage of banded
-matrices is packed.
The templated class banded_matrix<T, F, A> is the base
+container adaptor for banded matrices. For a (m x n)-dimensional
+banded matrix with l lower and u upper diagonals and
+0 <= i < m, 0 <= j < n holds b
+i, j = 0, if i > j + l or i < j -
+u. The storage of banded matrices is packed.
int main () {
- using namespace boost::numeric::ublas;
- banded_matrix<double> m (3, 3, 1, 1);
- for (int i = 0; i < m.size1 (); ++ i)
- for (int j = std::max (i - 1, 0); j < std::min (i + 2, m.size2 ()); ++ j)
- m (i, j) = 3 * i + j;
- std::cout << m << std::endl;
-}
-
+
+#include <boost/numeric/ublas/banded.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
banded_matrix<double> m (3, 3, 1, 1);
for (signed i = 0; i < signed (m.size1 ()); ++ i)
for (signed j = std::max (i - 1, 0); j < std::min (i + 2, signed (m.size2 ())); ++ j)
m (i, j) = 3 * i + j;
std::cout << m << std::endl;
}
Defined in the header banded.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
T |
- The type of object stored in the matrix. | -- |
F |
- Functor describing the storage organization. [1] | -row_major |
-
A |
- The type of the adapted array. [2] | -unbounded_array<T> |
- Parameter | +Description | +Default | + +
T |
+ The type of object stored in the matrix. | ++ |
F |
+ Functor describing the storage organization. +[1] + | +row_major |
+
A |
+ The type of the adapted array. [2] + | +unbounded_array<T> |
+
Matrix +.
+None, except for those imposed by the requirements of Matrix.
- + +None, except for those imposed by the requirements of +Matrix +.
+matrix_expression<banded_matrix<T, F, A> >
-
matrix_expression<banded_matrix<T, F, A> >
| Member | -Description | -
|---|---|
banded_matrix () |
- Allocates an uninitialized banded_matrix
- that holds zero rows of zero elements. |
-
banded_matrix (size_type size1, size_type
- size2, size_type lower = 0, size_type upper = 0) |
- Allocates an uninitialized banded_matrix
- that holds (lower + 1 + upper) diagonals
- around the main diagonal of a matrix with size1
- rows of size2 elements. |
-
banded_matrix (const banded_matrix &m) |
- The copy constructor. | -
template<class AE> |
- The extended copy constructor. | -
void resize (size_type size1, size_type size2,
- size_type lower = 0, size_type upper = 0) |
- Reallocates a banded_matrix to hold (lower
- + 1 + upper) diagonals around the main diagonal of
- a matrix with size1 rows of size2
- elements. The content of the banded_matrix
- is not preserved. |
-
size_type size1 () const |
- Returns the number of rows. | -
size_type size2 () const |
- Returns the number of columns. | -
size_type lower () const |
- Returns the number of diagonals below the main - diagonal. | -
size_type upper () const |
- Returns the number of diagonals above the main - diagonal. | -
const_reference operator () (size_type i,
- size_type j) const |
- Returns a const reference 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. |
-
banded_matrix &operator = (const
- banded_matrix &m) |
- The assignment operator. | -
banded_matrix &assign_temporary
- (banded_matrix &m) |
- Assigns a temporary. May change the banded matrix m. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a matrix expression to the banded 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 banded matrix. | -
template<class AE> |
- Adds a matrix expression to the banded 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 banded matrix. | -
template<class AE> |
- Subtracts a matrix expression from the banded matrix. - Left and right hand side of the assignment should be - independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the banded - matrix with a scalar. | -
template<class AT> |
- A computed assignment operator. Divides the banded - matrix through a scalar. | -
void swap (banded_matrix &m) |
- Swaps the contents of the banded 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 elemenst of
- the i-th row. |
-
void clear () |
- Clears the matrix. | -
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the banded_matrix. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the banded_matrix. |
-
iterator1 begin1 () |
- Returns a iterator1 pointing to the
- beginning of the banded_matrix. |
-
iterator1 end1 () |
- Returns a iterator1 pointing to the end
- of the banded_matrix. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the banded_matrix. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the banded_matrix. |
-
iterator2 begin2 () |
- Returns a iterator2 pointing to the
- beginning of the banded_matrix. |
-
iterator2 end2 () |
- Returns a iterator2 pointing to the end
- of the banded_matrix. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed banded_matrix.
- |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed banded_matrix.
- |
-
reverse_iterator1 rbegin1 () |
- Returns a reverse_iterator1 pointing to
- the beginning of the reversed banded_matrix.
- |
-
reverse_iterator1 rend1 () |
- Returns a reverse_iterator1 pointing to
- the end of the reversed banded_matrix. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed banded_matrix.
- |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed banded_matrix.
- |
-
reverse_iterator2 rbegin2 () |
- Returns a reverse_iterator2 pointing to
- the beginning of the reversed banded_matrix.
- |
-
reverse_iterator2 rend2 () |
- Returns a reverse_iterator2 pointing to
- the end of the reversed banded_matrix. |
- Member | +Description | + +
banded_matrix () |
+ Allocates an uninitialized banded_matrix
+ that holds zero rows of zero elements. |
+
banded_matrix (size_type size1, size_type size2,
+size_type lower = 0, size_type upper = 0) |
+ Allocates an uninitialized banded_matrix
+ that holds (lower + 1 + upper) diagonals around the
+main diagonal of a matrix with size1 rows of size2
+ elements. |
+
banded_matrix (const banded_matrix &m) |
+ The copy constructor. | +
template<class AE> |
+ The extended copy constructor. | +
void resize (size_type size1, size_type size2,
+ size_type lower = 0, size_type upper = 0) |
+ Reallocates a banded_matrix to hold (lower
+ + 1 + upper) diagonals around the main diagonal of
+ a matrix with size1 rows of size2 elements.
+The content of the banded_matrix is not preserved. |
+
size_type size1 () const |
+ Returns the number of rows. | +
size_type size2 () const |
+ Returns the number of columns. | +
size_type lower () const |
+ Returns the number of diagonals below the main diagonal. + | +
size_type upper () const |
+ Returns the number of diagonals above the main diagonal. + | +
const_reference operator () (size_type i, size_type
+j) const |
+ Returns a const reference 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. |
+
banded_matrix &operator = (const banded_matrix
+&m) |
+ The assignment operator. | +
banded_matrix &assign_temporary (banded_matrix
+&m) |
+ Assigns a temporary. May change the banded matrix m
+. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a matrix expression to the banded 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 banded matrix. | +
template<class AE> |
+ Adds a matrix expression to the banded 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 banded matrix. | +
template<class AE> |
+ Subtracts a matrix expression from the banded matrix. + Left and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the banded + matrix with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the banded matrix +through a scalar. | +
void swap (banded_matrix &m) |
+ Swaps the contents of the banded 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 elemenst of
+ the i-th row. |
+
void clear () |
+ Clears the matrix. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to the
+beginning of the banded_matrix. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to the
+end of the banded_matrix. |
+
iterator1 begin1 () |
+ Returns a iterator1 pointing to the beginning
+of the banded_matrix. |
+
iterator1 end1 () |
+ Returns a iterator1 pointing to the end
+ of the banded_matrix. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to the
+beginning of the banded_matrix. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to the
+end of the banded_matrix. |
+
iterator2 begin2 () |
+ Returns a iterator2 pointing to the beginning
+of the banded_matrix. |
+
iterator2 end2 () |
+ Returns a iterator2 pointing to the end
+ of the banded_matrix. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed banded_matrix. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed banded_matrix. |
+
reverse_iterator1 rbegin1 () |
+ Returns a reverse_iterator1 pointing to
+ the beginning of the reversed banded_matrix. |
+
reverse_iterator1 rend1 () |
+ Returns a reverse_iterator1 pointing to
+ the end of the reversed banded_matrix. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed banded_matrix. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed banded_matrix. |
+
reverse_iterator2 rbegin2 () |
+ Returns a reverse_iterator2 pointing to
+ the beginning of the reversed banded_matrix. |
+
reverse_iterator2 rend2 () |
+ Returns a reverse_iterator2 pointing to
+ the end of the reversed banded_matrix. |
+
[1] Supported parameters for the
-storage organization are row_major and column_major.
[2] Supported parameters for the
-adapted array are unbounded_array<T>, bounded_array<T>
-and std::vector<T>.
[1]
+ Supported parameters for the storage organization are row_major
+ and column_major.
[2]
+ Supported parameters for the adapted array are unbounded_array<T>
+, bounded_array<T> and std::vector<T>
+.
// Array based banded matrix class
- template<class T, class F, class A>
- class banded_matrix:
- public matrix_expression<banded_matrix<T, F, A> > {
- 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 A array_type;
- typedef const A const_array_type;
- typedef const banded_matrix<T, F, A> const_self_type;
- typedef banded_matrix<T, F, A> self_type;
- typedef const matrix_const_reference<const_self_type> const_closure_type;
- typedef matrix_reference<self_type> closure_type;
- typedef packed_tag storage_category;
- typedef typename F::orientation_category orientation_category;
-
- // Construction and destruction
- banded_matrix ();
- banded_matrix (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0);
- banded_matrix (const banded_matrix &m);
- template<class AE>
- banded_matrix (const matrix_expression<AE> &ae, size_type lower = 0, size_type upper = 0);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- size_type lower () const;
- size_type upper () const;
- const_array_type &data () const;
- array_type &data ();
-
- // Resizing
- void resize (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0);
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
- reference operator () (size_type i, size_type j);
-
- // Assignment
- banded_matrix &operator = (const banded_matrix &m);
- banded_matrix &assign_temporary (banded_matrix &m);
- template<class AE>
- banded_matrix &operator = (const matrix_expression<AE> &ae);
- template<class AE>
- banded_matrix &reset (const matrix_expression<AE> &ae);
- template<class AE>
- banded_matrix &assign (const matrix_expression<AE> &ae);
- template<class AE>
- banded_matrix& operator += (const matrix_expression<AE> &ae);
- template<class AE>
- banded_matrix &plus_assign (const matrix_expression<AE> &ae);
- template<class AE>
- banded_matrix& operator -= (const matrix_expression<AE> &ae);
- template<class AE>
- banded_matrix &minus_assign (const matrix_expression<AE> &ae);
- template<class AT>
- banded_matrix& operator *= (const AT &at);
- template<class AT>
- banded_matrix& operator /= (const AT &at);
-
- // Swapping
- void swap (banded_matrix &m);
- friend void swap (banded_matrix &m1, banded_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 indices.
-
- class const_iterator1:
- public container_const_reference<banded_matrix>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename banded_matrix::difference_type difference_type;
- typedef typename banded_matrix::value_type value_type;
- typedef typename banded_matrix::const_reference reference;
- typedef typename banded_matrix::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const banded_matrix &m, size_type it1, size_type it2);
- const_iterator1 (const iterator1 &it);
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator < (const const_iterator1 &it) const;
- };
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class iterator1:
- public container_reference<banded_matrix>,
- public random_access_iterator_base<iterator1, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename banded_matrix::difference_type difference_type;
- typedef typename banded_matrix::value_type value_type;
- typedef typename banded_matrix::reference reference;
- typedef typename banded_matrix::pointer pointer;
- typedef iterator2 dual_iterator_type;
- typedef reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator1 ();
- iterator1 (banded_matrix &m, size_type it1, size_type it2);
-
- // Arithmetic
- iterator1 &operator ++ ();
- iterator1 &operator -- ();
- iterator1 &operator += (difference_type n);
- iterator1 &operator -= (difference_type n);
- difference_type operator - (const iterator1 &it) const;
-
- // 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;
- bool operator < (const iterator1 &it) const;
- };
-
- iterator1 begin1 ();
- iterator1 end1 ();
-
- class const_iterator2:
- public container_const_reference<banded_matrix>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename banded_matrix::difference_type difference_type;
- typedef typename banded_matrix::value_type value_type;
- typedef typename banded_matrix::const_reference reference;
- typedef typename banded_matrix::const_pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const banded_matrix &m, size_type it1, size_type it2);
- const_iterator2 (const iterator2 &it);
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator < (const const_iterator2 &it) const;
- };
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- class iterator2:
- public container_reference<banded_matrix>,
- public random_access_iterator_base<iterator2, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename banded_matrix::difference_type difference_type;
- typedef typename banded_matrix::value_type value_type;
- typedef typename banded_matrix::reference reference;
- typedef typename banded_matrix::pointer pointer;
- typedef iterator1 dual_iterator_type;
- typedef reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator2 ();
- iterator2 (banded_matrix &m, size_type it1, size_type it2);
-
- // Arithmetic
- iterator2 &operator ++ ();
- iterator2 &operator -- ();
- iterator2 &operator += (difference_type n);
- iterator2 &operator -= (difference_type n);
- difference_type operator - (const iterator2 &it) const;
-
- // 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;
- 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 ();
- };
-
- // Array based banded matrix class
template<class T, class F, class A>
class banded_matrix:
public matrix_expression<banded_matrix<T, F, A> > {
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 A array_type;
typedef const A const_array_type;
typedef const banded_matrix<T, F, A> const_self_type;
typedef banded_matrix<T, F, A> self_type;
typedef const matrix_const_reference<const_self_type> const_closure_type;
typedef matrix_reference<self_type> closure_type;
typedef packed_tag storage_category;
typedef typename F::orientation_category orientation_category;
// Construction and destruction
banded_matrix ();
banded_matrix (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0);
banded_matrix (const banded_matrix &m);
template<class AE>
banded_matrix (const matrix_expression<AE> &ae, size_type lower = 0, size_type upper = 0);
// Accessors
size_type size1 () const;
size_type size2 () const;
size_type lower () const;
size_type upper () const;
const_array_type &data () const;
array_type &data ();
// Resizing
void resize (size_type size1, size_type size2, size_type lower = 0, size_type upper = 0);
// Element access
const_reference operator () (size_type i, size_type j) const;
reference operator () (size_type i, size_type j);
// Assignment
banded_matrix &operator = (const banded_matrix &m);
banded_matrix &assign_temporary (banded_matrix &m);
template<class AE>
banded_matrix &operator = (const matrix_expression<AE> &ae);
template<class AE>
banded_matrix &reset (const matrix_expression<AE> &ae);
template<class AE>
banded_matrix &assign (const matrix_expression<AE> &ae);
template<class AE>
banded_matrix& operator += (const matrix_expression<AE> &ae);
template<class AE>
banded_matrix &plus_assign (const matrix_expression<AE> &ae);
template<class AE>
banded_matrix& operator -= (const matrix_expression<AE> &ae);
template<class AE>
banded_matrix &minus_assign (const matrix_expression<AE> &ae);
template<class AT>
banded_matrix& operator *= (const AT &at);
template<class AT>
banded_matrix& operator /= (const AT &at);
// Swapping
void swap (banded_matrix &m);
friend void swap (banded_matrix &m1, banded_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 indices.
class const_iterator1:
public container_const_reference<banded_matrix>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename banded_matrix::difference_type difference_type;
typedef typename banded_matrix::value_type value_type;
typedef typename banded_matrix::const_reference reference;
typedef typename banded_matrix::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const banded_matrix &m, size_type it1, size_type it2);
const_iterator1 (const iterator1 &it);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator < (const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class iterator1:
public container_reference<banded_matrix>,
public random_access_iterator_base<iterator1, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename banded_matrix::difference_type difference_type;
typedef typename banded_matrix::value_type value_type;
typedef typename banded_matrix::reference reference;
typedef typename banded_matrix::pointer pointer;
typedef iterator2 dual_iterator_type;
typedef reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
iterator1 ();
iterator1 (banded_matrix &m, size_type it1, size_type it2);
// Arithmetic
iterator1 &operator ++ ();
iterator1 &operator -- ();
iterator1 &operator += (difference_type n);
iterator1 &operator -= (difference_type n);
difference_type operator - (const iterator1 &it) const;
// 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;
bool operator < (const iterator1 &it) const;
};
iterator1 begin1 ();
iterator1 end1 ();
class const_iterator2:
public container_const_reference<banded_matrix>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename banded_matrix::difference_type difference_type;
typedef typename banded_matrix::value_type value_type;
typedef typename banded_matrix::const_reference reference;
typedef typename banded_matrix::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const banded_matrix &m, size_type it1, size_type it2);
const_iterator2 (const iterator2 &it);
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator < (const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
class iterator2:
public container_reference<banded_matrix>,
public random_access_iterator_base<iterator2, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename banded_matrix::difference_type difference_type;
typedef typename banded_matrix::value_type value_type;
typedef typename banded_matrix::reference reference;
typedef typename banded_matrix::pointer pointer;
typedef iterator1 dual_iterator_type;
typedef reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
iterator2 ();
iterator2 (banded_matrix &m, size_type it1, size_type it2);
// Arithmetic
iterator2 &operator ++ ();
iterator2 &operator -- ();
iterator2 &operator += (difference_type n);
iterator2 &operator -= (difference_type n);
difference_type operator - (const iterator2 &it) const;
// Dereference
reference operator * () const;
iterat
+or1 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;
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 banded_adaptor<M> is a
-banded matrix adaptor for other matrices.
The templated class banded_adaptor<M> is a banded matrix
+adaptor for other matrices.
int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- banded_adaptor<matrix<double> > ba (m, 1, 1);
- for (int i = 0; i < ba.size1 (); ++ i)
- for (int j = std::max (i - 1, 0); j < std::min (i + 2, ba.size2 ()); ++ j)
- ba (i, j) = 3 * i + j;
- std::cout << ba << std::endl;
-}
-
+
+#include <boost/numeric/ublas/banded.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
banded_adaptor<matrix<double> > ba (m, 1, 1);
for (signed i = 0; i < signed (ba.size1 ()); ++ i)
for (signed j = std::max (i - 1, 0); j < std::min (i + 2, signed (ba.size2 ())); ++ j)
ba (i, j) = 3 * i + j;
std::cout << ba << std::endl;
}
Defined in the header banded.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
M |
- The type of the adapted matrix. | -- | Parameter | +Description | +Default | + +
M |
+ The type of the adapted matrix. | ++ |
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of +Matrix Expression +.
+matrix_expression<banded_adaptor<M> >
-
matrix_expression<banded_adaptor<M> >
| Member | -Description | -
|---|---|
banded_adaptor () |
- Constructs a banded_adaptor that holds
- zero rows of zero elements. |
-
banded_adaptor (matrix_type &data,
- size_type lower = 0, size_type upper = 0) |
- Constructs a banded_adaptor that holds (lower
- + 1 + upper) diagonals around the main diagonal of
- a matrix. |
-
banded_adaptor (const banded_adaptor &m) |
- The copy constructor. | -
template<class AE> |
- The extended copy constructor. | -
size_type size1 () const |
- Returns the number of rows. | -
size_type size2 () const |
- Returns the number of columns. | -
size_type lower () const |
- Returns the number of diagonals below the main - diagonal. | -
size_type upper () const |
- Returns the number of diagonals above the main - diagonal. | -
const_reference operator () (size_type i,
- size_type j) const |
- Returns a const reference 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. |
-
banded_adaptor &operator = (const
- banded_adaptor &m) |
- The assignment operator. | -
banded_adaptor &assign_temporary
- (banded_adaptor &m) |
- Assigns a temporary. May change the banded adaptor m. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a matrix expression to the banded adaptor. - Left and right hand side of the assignment should be - independent. | -
template<class AE> |
- A computed assignment operator. Adds the matrix - expression to the banded adaptor. | -
template<class AE> |
- Adds a matrix expression to the banded adaptor. Left - and right hand side of the assignment should be - independent. | -
template<class AE> |
- A computed assignment operator. Subtracts the matrix - expression from the banded adaptor. | -
template<class AE> |
- Subtracts a matrix expression from the banded - adaptor. Left and right hand side of the assignment - should be independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the banded - adaptor with a scalar. | -
template<class AT> |
- A computed assignment operator. Divides the banded - adaptor through a scalar. | -
void swap (banded_adaptor &m) |
- Swaps the contents of the banded adaptors. | -
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the banded_adaptor. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the banded_adaptor. |
-
iterator1 begin1 () |
- Returns a iterator1 pointing to the
- beginning of the banded_adaptor. |
-
iterator1 end1 () |
- Returns a iterator1 pointing to the end
- of the banded_adaptor. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the banded_adaptor. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the banded_adaptor. |
-
iterator2 begin2 () |
- Returns a iterator2 pointing to the
- beginning of the banded_adaptor. |
-
iterator2 end2 () |
- Returns a iterator2 pointing to the end
- of the banded_adaptor. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed banded_adaptor.
- |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed banded_adaptor.
- |
-
reverse_iterator1 rbegin1 () |
- Returns a reverse_iterator1 pointing to
- the beginning of the reversed banded_adaptor.
- |
-
reverse_iterator1 rend1 () |
- Returns a reverse_iterator1 pointing to
- the end of the reversed banded_adaptor. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed banded_adaptor.
- |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed banded_adaptor.
- |
-
reverse_iterator2 rbegin2 () |
- Returns a reverse_iterator2 pointing to
- the beginning of the reversed banded_adaptor.
- |
-
reverse_iterator2 rend2 () |
- Returns a reverse_iterator2 pointing to
- the end of the reversed banded_adaptor. |
- Member | +Description | + +
banded_adaptor () |
+ Constructs a banded_adaptor that holds
+zero rows of zero elements. |
+
banded_adaptor (matrix_type &data, size_type
+lower = 0, size_type upper = 0) |
+ Constructs a banded_adaptor that holds (lower
+ + 1 + upper) diagonals around the main diagonal of
+ a matrix. |
+
banded_adaptor (const banded_adaptor &m) |
+ The copy constructor. | +
template<class AE> |
+ The extended copy constructor. | +
size_type size1 () const |
+ Returns the number of rows. | +
size_type size2 () const |
+ Returns the number of columns. | +
size_type lower () const |
+ Returns the number of diagonals below the main diagonal. + | +
size_type upper () const |
+ Returns the number of diagonals above the main diagonal. + | +
const_reference operator () (size_type i, size_type
+j) const |
+ Returns a const reference 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. |
+
banded_adaptor &operator = (const banded_adaptor
+&m) |
+ The assignment operator. | +
banded_adaptor &assign_temporary (banded_adaptor
+&m) |
+ Assigns a temporary. May change the banded adaptor m
+. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a matrix expression to the banded adaptor. Left +and right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Adds the matrix expression +to the banded adaptor. | +
template<class AE> |
+ Adds a matrix expression to the banded adaptor. Left + and right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Subtracts the matrix + expression from the banded adaptor. | +
template<class AE> |
+ Subtracts a matrix expression from the banded adaptor. +Left and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the banded + adaptor with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the banded adaptor +through a scalar. | +
void swap (banded_adaptor &m) |
+ Swaps the contents of the banded adaptors. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to the
+beginning of the banded_adaptor. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to the
+end of the banded_adaptor. |
+
iterator1 begin1 () |
+ Returns a iterator1 pointing to the beginning
+of the banded_adaptor. |
+
iterator1 end1 () |
+ Returns a iterator1 pointing to the end
+ of the banded_adaptor. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to the
+beginning of the banded_adaptor. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to the
+end of the banded_adaptor. |
+
iterator2 begin2 () |
+ Returns a iterator2 pointing to the beginning
+of the banded_adaptor. |
+
iterator2 end2 () |
+ Returns a iterator2 pointing to the end
+ of the banded_adaptor. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed banded_adaptor. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed banded_adaptor. |
+
reverse_iterator1 rbegin1 () |
+ Returns a reverse_iterator1 pointing to
+ the beginning of the reversed banded_adaptor. |
+
reverse_iterator1 rend1 () |
+ Returns a reverse_iterator1 pointing to
+ the end of the reversed banded_adaptor. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed banded_adaptor. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed banded_adaptor. |
+
reverse_iterator2 rbegin2 () |
+ Returns a reverse_iterator2 pointing to
+ the beginning of the reversed banded_adaptor. |
+
reverse_iterator2 rend2 () |
+ Returns a reverse_iterator2 pointing to
+ the end of the reversed banded_adaptor. |
+
// Banded matrix adaptor class
- template<class M>
- class banded_adaptor:
- public matrix_expression<banded_adaptor<M> > {
- public:
- typedef const M const_matrix_type;
- typedef M matrix_type;
- typedef typename M::size_type size_type;
- typedef typename M::difference_type difference_type;
- typedef typename M::value_type value_type;
- typedef typename M::const_reference const_reference;
- typedef typename M::reference reference;
- typedef typename M::const_pointer const_pointer;
- typedef typename M::pointer pointer;
- typedef const banded_adaptor<M> const_self_type;
- typedef banded_adaptor<M> self_type;
- typedef const matrix_const_reference<const_self_type> const_closure_type;
- typedef matrix_reference<self_type> closure_type;
- typedef typename storage_restrict_traits<typename M::storage_category,
- packed_proxy_tag>::storage_category storage_category;
- typedef typename M::orientation_category orientation_category;
-
- // Construction and destruction
- banded_adaptor ();
- banded_adaptor (matrix_type &data, size_type lower = 0, size_type upper = 0);
- banded_adaptor (const banded_adaptor &m);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- size_type lower () const;
- size_type upper () const;
- const_matrix_type &data () const;
- matrix_type &data ();
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
- reference operator () (size_type i, size_type j);
-
- // Assignment
- banded_adaptor &operator = (const banded_adaptor &m);
- banded_adaptor &assign_temporary (banded_adaptor &m);
- template<class AE>
- banded_adaptor &operator = (const matrix_expression<AE> &ae);
- template<class AE>
- banded_adaptor &assign (const matrix_expression<AE> &ae);
- template<class AE>
- banded_adaptor& operator += (const matrix_expression<AE> &ae);
- template<class AE>
- banded_adaptor &plus_assign (const matrix_expression<AE> &ae);
- template<class AE>
- banded_adaptor& operator -= (const matrix_expression<AE> &ae);
- template<class AE>
- banded_adaptor &minus_assign (const matrix_expression<AE> &ae);
- template<class AT>
- banded_adaptor& operator *= (const AT &at);
- template<class AT>
- banded_adaptor& operator /= (const AT &at);
-
- // Swapping
- void swap (banded_adaptor &m);
- friend void swap (banded_adaptor &m1, banded_adaptor &m2);
-
- 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 indices.
-
- class const_iterator1:
- public container_const_reference<banded_adaptor>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename banded_adaptor::difference_type difference_type;
- typedef typename banded_adaptor::value_type value_type;
- typedef typename banded_adaptor::const_reference reference;
- typedef typename banded_adaptor::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const banded_adaptor &m, size_type it1, size_type it2);
- const_iterator1 (const iterator1 &it);
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator < (const const_iterator1 &it) const;
- };
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class iterator1:
- public container_reference<banded_adaptor>,
- public random_access_iterator_base<iterator1, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename banded_adaptor::difference_type difference_type;
- typedef typename banded_adaptor::value_type value_type;
- typedef typename banded_adaptor::reference reference;
- typedef typename banded_adaptor::pointer pointer;
- typedef iterator2 dual_iterator_type;
- typedef reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator1 ();
- iterator1 (banded_adaptor &m, size_type it1, size_type it2);
-
- // Arithmetic
- iterator1 &operator ++ ();
- iterator1 &operator -- ();
- iterator1 &operator += (difference_type n);
- iterator1 &operator -= (difference_type n);
- difference_type operator - (const iterator1 &it) const;
-
- // 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;
- bool operator < (const iterator1 &it) const;
- };
-
- iterator1 begin1 ();
- iterator1 end1 ();
-
- class const_iterator2:
- public container_const_reference<banded_adaptor>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename banded_adaptor::difference_type difference_type;
- typedef typename banded_adaptor::value_type value_type;
- typedef typename banded_adaptor::const_reference reference;
- typedef typename banded_adaptor::const_pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const banded_adaptor &m, size_type it1, size_type it2);
- const_iterator2 (const iterator2 &it);
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator < (const const_iterator2 &it) const;
- };
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- class iterator2:
- public container_reference<banded_adaptor>,
- public random_access_iterator_base<iterator2, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename banded_adaptor::difference_type difference_type;
- typedef typename banded_adaptor::value_type value_type;
- typedef typename banded_adaptor::reference reference;
- typedef typename banded_adaptor::pointer pointer;
- typedef iterator1 dual_iterator_type;
- typedef reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator2 ();
- iterator2 (banded_adaptor &m, size_type it1, size_type it2);
-
- // Arithmetic
- iterator2 &operator ++ ();
- iterator2 &operator -- ();
- iterator2 &operator += (difference_type n);
- iterator2 &operator -= (difference_type n);
- difference_type operator - (const iterator2 &it) const;
-
- // 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;
- 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
-Permission to copy, use, modify, sell and distribute this
-document is granted provided this copyright notice appears in all
-copies. This document is provided ``as is'' without express or
-implied warranty, and with no claim as to its suitability for any
-purpose.
// Banded matrix adaptor class
template<class M>
class banded_adaptor:
public matrix_expression<banded_adaptor<M> > {
public:
typedef const M const_matrix_type;
typedef M matrix_type;
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
typedef typename M::pointer pointer;
typedef const banded_adaptor<M> const_self_type;
typedef banded_adaptor<M> self_type;
typedef const matrix_const_reference<const_self_type> const_closure_type;
typedef matrix_reference<self_type> closure_type;
typedef typename storage_restrict_traits<typename M::storage_category,
packed_proxy_tag>::storage_category storage_category;
typedef typename M::orientation_category orientation_category;
// Construction and destruction
banded_adaptor ();
banded_adaptor (matrix_type &data, size_type lower = 0, size_type upper = 0);
banded_adaptor (const banded_adaptor &m);
// Accessors
size_type size1 () const;
size_type size2 () const;
size_type lower () const;
size_type upper () const;
const_matrix_type &data () const;
matrix_type &data ();
// Element access
const_reference operator () (size_type i, size_type j) const;
reference operator () (size_type i, size_type j);
// Assignment
banded_adaptor &operator = (const banded_adaptor &m);
banded_adaptor &assign_temporary (banded_adaptor &m);
template<class AE>
banded_adaptor &operator = (const matrix_expression<AE> &ae);
template<class AE>
banded_adaptor &assign (const matrix_expression<AE> &ae);
template<class AE>
banded_adaptor& operator += (const matrix_expression<AE> &ae);
template<class AE>
banded_adaptor &plus_assign (const matrix_expression<AE> &ae);
template<class AE>
banded_adaptor& operator -= (const matrix_expression<AE> &ae);
template<class AE>
banded_adaptor &minus_assign (const matrix_expression<AE> &ae);
template<class AT>
banded_adaptor& operator *= (const AT &at);
template<class AT>
banded_adaptor& operator /= (const AT &at);
// Swapping
void swap (banded_adaptor &m);
friend void swap (banded_adaptor &m1, banded_adaptor &m2);
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 indices.
class const_iterator1:
public container_const_reference<banded_adaptor>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename banded_adaptor::difference_type difference_type;
typedef typename banded_adaptor::value_type value_type;
typedef typename banded_adaptor::const_reference reference;
typedef typename banded_adaptor::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const banded_adaptor &m, size_type it1, size_type it2);
const_iterator1 (const iterator1 &it);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator < (const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class iterator1:
public container_reference<banded_adaptor>,
public random_access_iterator_base<iterator1, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename banded_adaptor::difference_type difference_type;
typedef typename banded_adaptor::value_type value_type;
typedef typename banded_adaptor::reference reference;
typedef typename banded_adaptor::pointer pointer;
typedef iterator2 dual_iterator_type;
typedef reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
iterator1 ();
iterator1 (banded_adaptor &m, size_type it1, size_type it2);
// Arithmetic
iterator1 &operator ++ ();
iterator1 &operator -- ();
iterator1 &operator += (difference_type n);
iterator1 &operator -= (difference_type n);
difference_type operator - (const iterator1 &it) const;
// 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;
bool operator < (const iterator1 &it) const;
};
iterator1 begin1 ();
iterator1 end1 ();
class const_iterator2:
public container_const_reference<banded_adaptor>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename banded_adaptor::difference_type difference_type;
typedef typename banded_adaptor::value_type value_type;
typedef typename banded_adaptor::const_reference reference;
typedef typename banded_adaptor::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const banded_adaptor &m, size_type it1, size_type it2);
const_iterator2 (const iterator2 &it);
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator < (const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
class iterator2:
public container_reference<banded_adaptor>,
public random_access_iterator_base<iterator2, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename banded_adaptor::difference_type difference_type;
typedef typename banded_adaptor::value_type value_type;
typedef typename banded_adaptor::reference reference;
typedef typename banded_adaptor::pointer pointer;
typedef iterator1 dual_iterator_type;
typedef reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
iterator2 ();
iterator2 (banded_adaptor &m, size_type it1, size_type it2);
// Arithmetic
iterator2 &operator ++ ();
iterator2 &operator -- ();
iterator2 &operator += (difference_type n);
iterator2 &operator -= (difference_type n);
difference_type operator - (const iterator2 &it) const;
// 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;
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
+ Permission to copy, use, modify, sell and distribute this document is granted
+provided this copyright notice appears in all copies. This document is provided
+``as is'' without express or implied warranty, and with no claim as to its
+suitability for any purpose.
Last revised: 8/3/2002
+ diff --git a/doc/container.htm b/doc/container.htm index 6c435171..1e4aed8d 100644 --- a/doc/container.htm +++ b/doc/container.htm @@ -1,393 +1,422 @@ + - - - -
Container Concepts
+Container ConceptsA Vector describes common aspects of dense, packed and sparse vectors. + +
A Vector describes common aspects of dense, packed and sparse vectors.
- +| Value type | -value_type |
- The type of the vector. | -
| Distance type | -difference_type |
- A signed integral type used to represent the distance - between two of the vector's iterators. | -
| Size type | -size_type |
- An unsigned integral type that can represent any - nonnegative value of the vector's distance type. | -Value type | +value_type |
+ The type of the vector. | + +
| Distance type | +difference_type |
+ A signed integral type used to represent the distance + between two of the vector's iterators. | +
| Size type | +size_type |
+ An unsigned integral type that can represent any nonnegative +value of the vector's distance type. | +
V |
- A type that is a model of Vector | -
v |
- Objects of type V |
-
n, i |
- Objects of a type convertible to size_type
- |
-
t |
- Object of a type convertible to value_type
- |
- V |
+ A type that is a model of Vector | + +
v |
+ Objects of type V |
+
n, i |
+ Objects of a type convertible to size_type
+ |
+
t |
+ Object of a type convertible to value_type
+ |
+
In addition to the expressions defined in Vector Expression the -following expressions must be valid.
- + +In addition to the expressions defined in +Vector Expression + the following expressions must be valid.
+| Name | -Expression | -Type requirements | -Return type | -
|---|---|---|---|
| Sizing constructor | -V v (n) |
- - | V |
-
| Insert | -v.insert (i, t) |
- v is mutable. |
- void |
-
| Erase | -v.erase (i) |
- v is mutable. |
- void |
-
| Clear | -v.clear () |
- v is mutable. |
- void |
-
| Resize | -v.resize (n) |
- v is mutable. |
- void |
- Name | +Expression | +Type requirements | +Return type | + +
| Sizing constructor | +V v (n) |
+ + | V |
+
| Insert | +v.insert (i, t) |
+ v is mutable. |
+ void |
+
| Erase | +v.erase (i) |
+ v is mutable. |
+ void |
+
| Clear | +v.clear () |
+ v is mutable. |
+ void |
+
| Resize | +v.resize (n) |
+ v is mutable. |
+ void |
+
Semantics of an expression is defined only where it differs -from, or is not defined in Vector Expression.
- + +Semantics of an expression is defined only where it differs from, or is +not defined in Vector Expression +.
+| Name | -Expression | -Precondition | -Semantics | -Postcondition | -
|---|---|---|---|---|
| Sizing constructor | -V v (n) |
- n >= 0 |
- Creates a vector of n elements. |
- v.size () == n. |
-
| Insert | -v.insert (i, t) |
- 0 <= i < v.size () and - v (i) is a copy of value_type (). |
- A copy of t is inserted in v.
- |
- v (i) is a copy of t. |
-
| Erase | -v.erase (i) |
- 0 <= i < v.size () |
- Destroys the element v (i) and replaces
- it with value_type (). |
- v (i) is a copy of value_type ().
- |
-
| Clear | -v.clear () |
- - | Equivalent to - for (i = 0; i < v.size (); ++ i)- v.erase (i); |
- - |
| Resize | -v.resize (n) |
- - | Modifies the vector so that it can hold n
- elements. |
- v.size () == n. |
- Name | +Expression | +Precondition | +Semantics | +Postcondition | + +
| Sizing constructor | +V v (n) |
+ n >= 0 |
+ Creates a vector of n elements. |
+ v.size () == n. |
+
| Insert | +v.insert (i, t) |
+ 0 <= i < v.size () and + v (i) is a copy of value_type (). |
+ A copy of t is inserted in v.
+ |
+ v (i) is a copy of t. |
+
| Erase | +v.erase (i) |
+ 0 <= i < v.size () |
+ Destroys the element v (i) and replaces
+ it with value_type (). |
+ v (i) is a copy of value_type ().
+ |
+
| Clear | +v.clear () |
+ + | Equivalent to + for (i = 0; i < v.size (); ++ i)+ v.erase (i); |
+ + |
| Resize | +v.resize (n) |
+ + | Modifies the vector so that it can hold n
+ elements. |
+ v.size () == n. |
+
The run-time complexity of the sizing constructor is linear in -the vector's size.
- -The run-time complexity of insert and erase is specific for -the vector.
- + +The run-time complexity of the sizing constructor is linear in the vector's +size.
+ +The run-time complexity of insert and erase is specific for the vector.
+vector<T, A>unit_vector<T>zero_vector<T>sparse_vector<T, A>vector<T, A>unit_vector<T>zero_vector<T>sparse_vector<T, A>A Matrix describes common aspects of dense, packed and sparse -matrices.
- + +A Matrix describes common aspects of dense, packed and sparse matrices. +
+| Value type | -value_type |
- The type of the matrix. | -
| Distance type | -difference_type |
- A signed integral type used to represent the distance - between two of the matrix's iterators. | -
| Size type | -size_type |
- An unsigned integral type that can represent any - nonnegative value of the matrix's distance type. | -Value type | +value_type |
+ The type of the matrix. | + +
| Distance type | +difference_type |
+ A signed integral type used to represent the distance + between two of the matrix's iterators. | +
| Size type | +size_type |
+ An unsigned integral type that can represent any nonnegative +value of the matrix's distance type. | +
M |
- A type that is a model of Matrix | -
m |
- Objects of type M |
-
n1, n2, i, j |
- Objects of a type convertible to size_type
- |
-
t |
- Object of a type convertible to value_type
- |
- M |
+ A type that is a model of Matrix | + +
m |
+ Objects of type M |
+
n1, n2, i, j |
+ Objects of a type convertible to size_type
+ |
+
t |
+ Object of a type convertible to value_type
+ |
+
In addition to the expressions defined in Matrix Expression the -following expressions must be valid.
- + +In addition to the expressions defined in +Matrix Expression + the following expressions must be valid.
+| Name | -Expression | -Type requirements | -Return type | -
|---|---|---|---|
| Sizing constructor | -M m (n1, n2) |
- - | M |
-
| Insert | -m.insert (i, j, t) |
- m is mutable. |
- void |
-
| Erase | -m.erase (i, j) |
- m is mutable. |
- void |
-
| Clear | -m.clear () |
- m is mutable. |
- void |
-
| Resize | -m.resize (n1, n2) |
- m is mutable. |
- void |
- Name | +Expression | +Type requirements | +Return type | + +
| Sizing constructor | +M m (n1, n2) |
+ + | M |
+
| Insert | +m.insert (i, j, t) |
+ m is mutable. |
+ void |
+
| Erase | +m.erase (i, j) |
+ m is mutable. |
+ void |
+
| Clear | +m.clear () |
+ m is mutable. |
+ void |
+
| Resize | +m.resize (n1, n2) |
+ m is mutable. |
+ void |
+
Semantics of an expression is defined only where it differs -from, or is not defined in Matrix Expression.
- + +Semantics of an expression is defined only where it differs from, or is +not defined in Matrix Expression +.
+| Name | -Expression | -Precondition | -Semantics | -Postcondition | -||||
|---|---|---|---|---|---|---|---|---|
| Sizing constructor | -M m (n1, n2) |
- n1 >= 0 and n2 >= 0 |
- Creates a matrix of n1 rows and n2
- columns. |
- m.size1 () == n1 and m.size2 () ==
- n2. |
- ||||
| Insert | -m.insert (i, j, t) |
- 0 <= i < m.size1 (), - 0 <= j < m.size2 ()and is a copy of value_type (). |
- A copy of t is inserted in m.
- |
- m (i, j) is a copy of t. |
- ||||
| Erase | -m.erase (i, j) |
- 0 <= i < m.size1 ()and |
- Destroys the element m (i, j) and
- replaces it with value_type (). |
- m (i, j) is a copy of value_type
- (). |
- ||||
| Clear | -m.clear () |
- - | Equivalent to - for (i = 0; i < m.size1 (); ++ i)- for (j = 0; j < m.size2 (); ++ j)- m.erase (i, j); |
- - | ||||
| Resize | -m.resize (n1, n2) |
- - | Modifies the vector so that it can hold n1 rows
+ | Name | +Expression | +Precondition | +Semantics | +Postcondition | +
| Sizing constructor | +M m (n1, n2) |
+ n1 >= 0 and n2 >= 0 |
+ Creates a matrix of n1 rows and n2
+ columns. |
+ m.size1 () == n1 and m.size2 () ==
+ n2. |
+ ||||
| Insert | +m.insert (i, j, t) |
+ 0 <= i < m.size1 (), + 0 <= j < m.size2 ()and is a copy of value_type (). |
+ A copy of t is inserted in m.
+ |
+ m (i, j) is a copy of t. |
+ ||||
| Erase | +m.erase (i, j) |
+ 0 <= i < m.size1 ()and |
+ Destroys the element m (i, j) and replaces
+it with value_type (). |
+ m (i, j) is a copy of value_type
+(). |
+ ||||
| Clear | +m.clear () |
+ + | Equivalent to + for (i = 0; i < m.size1 (); ++ i)+ for (j = 0; j < m.size2 (); ++ j)+ m.erase (i, j); |
+ + | ||||
| Resize | +m.resize (n1, n2) |
+ + | Modifies the vector so that it can hold n1 rows
and n2 columns. |
- m.size1 () == n1 and m.size2 () ==
- n2. |
- m.size1 () == n1 and m.size2 () ==
+ n2. |
+
+
+
The run-time complexity of the sizing constructor is quadratic -in the matrix's size.
- -The run-time complexity of insert and erase is specific for -the matrix.
- + +The run-time complexity of the sizing constructor is quadratic in the +matrix's size.
+ +The run-time complexity of insert and erase is specific for the matrix.
+matrix<T, F, A>identity_matrix<T>zero_matrix<T>triangular_matrix<T, F1, F2, A>symmetric_matrix<T, F1, F2, A>banded_matrix<T, F, A>sparse_matrix<T, F, A>matrix<T, F, A>identity_matrix<T>zero_matrix<T>triangular_matrix<T, F1, F2, A>symmetric_matrix<T, F1, F2, A>banded_matrix<T, F, A>sparse_matrix<T, F, A>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document is granted
-provided this copyright notice appears in all copies. This document is provided
-``as is'' without express or implied warranty, and with no claim as to its suitability
-for any purpose.
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+ Permission to copy, use, modify, sell and distribute this document is granted
+provided this copyright notice appears in all copies. This document is provided
+``as is'' without express or implied warranty, and with no claim as to its
+suitability for any purpose.
Last revised: 8/3/2002
- + diff --git a/doc/expression.htm b/doc/expression.htm index 1aa6ecf4..675835bb 100644 --- a/doc/expression.htm +++ b/doc/expression.htm @@ -1,1033 +1,1077 @@ + - - - -
Expression Concepts
+Expression ConceptsA Scalar Expression is an expression convertible to a scalar -type.
- + +A Scalar Expression is an expression convertible to a scalar type.
+Default Constructible.
- +| Value type | -value_type |
- The type of the scalar expression. | -Value type | +value_type |
+ The type of the scalar expression. | + + +
S |
- A type that is a model of Scalar Expression | -S |
+ A type that is a model of Scalar Expression | + + +
In addition to the expressions defined in Default -Constructible the following expressions must be valid.
- + +In addition to the expressions defined in Default Constructible the following +expressions must be valid.
+| Name | -Expression | -Type requirements | -Return type | -
|---|---|---|---|
| Evaluation | -operator value_type () const |
- - | value_type |
- Name | +Expression | +Type requirements | +Return type | + +
| Evaluation | +operator value_type () const |
+ + | value_type |
+
Semantics of an expression is defined only where it differs -from, or is not defined in Default Constructible.
- + +Semantics of an expression is defined only where it differs from, or is +not defined in Default Constructible.
+| Name | -Expression | -Precondition | -Semantics | -Postcondition | -
|---|---|---|---|---|
| Evaluation | -operator value_type () const |
- - | Evaluates the scalar expression. | -- | Name | +Expression | +Precondition | +Semantics | +Postcondition | + +
| Evaluation | +operator value_type () const |
+ + | Evaluates the scalar expression. | ++ |
The run-time complexity of the evaluation is specific for the -evaluated scalar expression.
- + +The run-time complexity of the evaluation is specific for the evaluated +scalar expression.
+vector_scalar_unary<E, F>vector_scalar_binary<E1, E2, F>vector_scalar_unary<E, F>vector_scalar_binary<E1, E2, F>A Vector Expression is an expression evaluatable to a vector. -Vector Expression provides an Indexed -Bidirectional Iterator or an Indexed Random -Access Iterator.
- + +A Vector Expression is an expression evaluatable to a vector. Vector Expression +provides an Indexed +Bidirectional Iterator + or an Indexed Random +Access Iterator +.
+Default Constructible.
- +| Value type | -value_type |
- The type of the vector expression. | -
| Const iterator type | -const_iterator |
- A type of iterator that may be used to examine a - vector expression's elements. | -
| Iterator type | -iterator |
- A type of iterator that may be used to modify a - vector expression's elements. | -
| Distance type | -difference_type |
- A signed integral type used to represent the distance - between two of the vector expression's iterators. | -
| Size type | -size_type |
- An unsigned integral type that can represent any - nonnegative value of the vector expression's distance - type. | -
| Const reverse iterator type | -const_reverse_iterator |
- A Reverse Iterator adaptor whose base iterator type - is the vector expression's const iterator type. | -
| Reverse iterator type | -reverse_iterator |
- A Reverse Iterator adaptor whose base iterator type - is the vector expression's iterator type. | -Value type | +value_type |
+ The type of the vector expression. | + +
| Const iterator type | +const_iterator |
+ A type of iterator that may be used to examine a vector +expression's elements. | +
| Iterator type | +iterator |
+ A type of iterator that may be used to modify a vector +expression's elements. | +
| Distance type | +difference_type |
+ A signed integral type used to represent the distance + between two of the vector expression's iterators. | +
| Size type | +size_type |
+ An unsigned integral type that can represent any nonnegative +value of the vector expression's distance type. | +
| Const reverse iterator type | +const_reverse_iterator |
+ A Reverse Iterator adaptor whose base iterator type +is the vector expression's const iterator type. | +
| Reverse iterator type | +reverse_iterator |
+ A Reverse Iterator adaptor whose base iterator type +is the vector expression's iterator type. | +
V |
- A type that is a model of Vector Expression | -
v, v1, v2 |
- Object of type V |
-
i |
- Object of a type convertible to size_type
- |
-
t |
- Object of a type convertible to value_type |
- V |
+ A type that is a model of Vector Expression | + +
v, v1, v2 |
+ Object of type V |
+
i |
+ Object of a type convertible to size_type
+ |
+
t |
+ Object of a type convertible to value_type |
+
In addition to the expressions defined in Default -Constructible the following expressions must be valid.
- + +In addition to the expressions defined in Default Constructible the following +expressions must be valid.
+| Name | -Expression | -Type requirements | -Return type | -
|---|---|---|---|
| Beginning of range | -v.begin () |
- - | const_iterator |
-
v.begin () |
- v is mutable. |
- iterator |
- |
| End of range | -v.end () |
- - | const_iterator |
-
v.end () |
- v is mutable. |
- iterator |
- |
| Size | -v.size () |
- - | size_type |
-
| Swap | -v1.swap (v2) |
- v1 and v2 are mutable. |
- void |
-
| Beginning of reverse range | -v.rbegin () |
- - | const_reverse_iterator |
-
v.rbegin () |
- v is mutable. |
- reverse_iterator |
- |
| End of reverse range | -v.rend () |
- - | const_reverse_iterator |
-
v.rend () |
- v is mutable. |
- reverse_iterator |
- |
| Element access | -v (i) |
- i is convertible to size_type.
- |
- Convertible to value_type. |
-
| Assignment | -v2 = v1 |
- v2 is mutable and v1 is
- convertible to V. |
- V & |
-
v2.assign (v1) |
- v2 is mutable and v1 is
- convertible to V. |
- V & |
- |
| Computed assignment | -v2 += v1 |
- v2 is mutable and v1 is
- convertible to V. |
- V & |
-
v2.plus_assign (v1) |
- v2 is mutable and v1 is
- convertible to V. |
- V & |
- |
v2 -= v1 |
- v2 is mutable and v1 is
- convertible to V. |
- V & |
- |
v2.minus_assign (v1) |
- v2 is mutable and v1 is
- convertible to V. |
- V & |
- |
v *= t |
- v is mutable and t is
- convertible to value_type. |
- V & |
- Name | +Expression | +Type requirements | +Return type | + +
| Beginning of range | +v.begin () |
+ + | const_iterator |
+
v.begin () |
+ v is mutable. |
+ iterator |
+ |
| End of range | +v.end () |
+ + | const_iterator |
+
v.end () |
+ v is mutable. |
+ iterator |
+ |
| Size | +v.size () |
+ + | size_type |
+
| Swap | +v1.swap (v2) |
+ v1 and v2 are mutable. |
+ void |
+
| Beginning of reverse range | +v.rbegin () |
+ + | const_reverse_iterator |
+
v.rbegin () |
+ v is mutable. |
+ reverse_iterator |
+ |
| End of reverse range | +v.rend () |
+ + | const_reverse_iterator |
+
v.rend () |
+ v is mutable. |
+ reverse_iterator |
+ |
| Element access | +v (i) |
+ i is convertible to size_type.
+ |
+ Convertible to value_type. |
+
| Assignment | +v2 = v1 |
+ v2 is mutable and v1 is convertible
+to V. |
+ V & |
+
v2.assign (v1) |
+ v2 is mutable and v1 is convertible
+to V. |
+ V & |
+ |
| Computed assignment | +v2 += v1 |
+ v2 is mutable and v1 is convertible
+to V. |
+ V & |
+
v2.plus_assign (v1) |
+ v2 is mutable and v1 is convertible
+to V. |
+ V & |
+ |
v2 -= v1 |
+ v2 is mutable and v1 is convertible
+to V. |
+ V & |
+ |
v2.minus_assign (v1) |
+ v2 is mutable and v1 is convertible
+to V. |
+ V & |
+ |
v *= t |
+ v is mutable and t is convertible
+to value_type. |
+ V & |
+
Semantics of an expression is defined only where it differs -from, or is not defined in Default Constructible.
- + +Semantics of an expression is defined only where it differs from, or is +not defined in Default Constructible.
+| Name | -Expression | -Precondition | -Semantics | -Postcondition | -
|---|---|---|---|---|
| Beginning of range | -v.begin () |
- - | Returns an iterator pointing to the first element in - the vector expression. | -v.begin () is either dereferenceable or
- past-the-end. It is past-the-end if and only if v.size
- () == 0. |
-
| End of range | -v.end () |
- - | Returns an iterator pointing one past the last - element in the vector expression. | -v.end () is past-the-end. |
-
| Size | -v.size () |
- - | Returns the size of the vector expression, that is, - its number of elements. | -v.size () >= 0 |
-
| Swap | -v1.swap (v2) |
- - | Equivalent to swap (v1, v2). |
- - |
| Beginning of reverse range | -v.rbegin () |
- - | Equivalent to reverse_iterator (v.end ()).
- |
- v.rbegin () is either dereferenceable or
- past-the-end. It is past-the-end if and only if v.size
- () == 0. |
-
| End of reverse range | -v.rend () |
- - | Equivalent to reverse_iterator (v.begin ()).
- |
- v.rend () is past-the-end. |
-
| Element access | -v (i) |
- 0 <= i < v.size () |
- Returns the i-th element of the vector
- expression. |
- - |
| Assignment | -v2 = v1 |
- v1.size () == v2.size () |
- Assigns every element of the evaluated vector
- expression v1 to the corresponding element
- of v2. |
- - |
v2.assign (v1) |
- v1.size () == v2.size () |
- Assigns every element of v1 to the
- corresponding element of v2. |
- - | |
| Computed assignment | -v2 += v1 |
- v1.size () == v2.size () |
- Adds every element of the evaluated vector expression
- v1 to the corresponding element of v2. |
- - |
v2.plus_assign (v1) |
- v1.size () == v2.size () |
- Adds every element of v1 to the
- corresponding element of v2. |
- - | |
v2 -= v1 |
- v1.size () == v2.size () |
- Subtracts every element of the evaluated vector
- expression v1 from the corresponding element
- of v2. |
- - | |
v2.minus_assign (v1) |
- v1.size () == v2.size () |
- Subtracts every element of v1 from the
- corresponding element of v2. |
- - | |
v *= t |
- - | Multiplies every element of v with t. |
- - | Name | +Expression | +Precondition | +Semantics | +Postcondition | + +
| Beginning of range | +v.begin () |
+ + | Returns an iterator pointing to the first element in + the vector expression. | +v.begin () is either dereferenceable or
+ past-the-end. It is past-the-end if and only if v.size ()
+== 0. |
+
| End of range | +v.end () |
+ + | Returns an iterator pointing one past the last element +in the vector expression. | +v.end () is past-the-end. |
+
| Size | +v.size () |
+ + | Returns the size of the vector expression, that is, +its number of elements. | +v.size () >= 0 |
+
| Swap | +v1.swap (v2) |
+ + | Equivalent to swap (v1, v2). |
+ + |
| Beginning of reverse range | +v.rbegin () |
+ + | Equivalent to reverse_iterator (v.end ()).
+ |
+ v.rbegin () is either dereferenceable or
+ past-the-end. It is past-the-end if and only if v.size ()
+== 0. |
+
| End of reverse range | +v.rend () |
+ + | Equivalent to reverse_iterator (v.begin ()).
+ |
+ v.rend () is past-the-end. |
+
| Element access | +v (i) |
+ 0 <= i < v.size () |
+ Returns the i-th element of the vector
+expression. |
+ + |
| Assignment | +v2 = v1 |
+ v1.size () == v2.size () |
+ Assigns every element of the evaluated vector expression
+ v1 to the corresponding element of v2
+. |
+ + |
v2.assign (v1) |
+ v1.size () == v2.size () |
+ Assigns every element of v1 to the corresponding
+element of v2. |
+ + | |
| Computed assignment | +v2 += v1 |
+ v1.size () == v2.size () |
+ Adds every element of the evaluated vector expression
+ v1 to the corresponding element of v2. |
+ + |
v2.plus_assign (v1) |
+ v1.size () == v2.size () |
+ Adds every element of v1 to the corresponding
+element of v2. |
+ + | |
v2 -= v1 |
+ v1.size () == v2.size () |
+ Subtracts every element of the evaluated vector expression
+ v1 from the corresponding element of v2
+. |
+ + | |
v2.minus_assign (v1) |
+ v1.size () == v2.size () |
+ Subtracts every element of v1 from the
+corresponding element of v2. |
+ + | |
v *= t |
+ + | Multiplies every element of v with t
+. |
+ + |
The run-time complexity of begin () and end
-() is specific for the evaluated vector expression,
-typically amortized constant time.
The run-time complexity of size () is constant
-time.
The run-time complexity of swap () is specific
-for the evaluated vector expression, typically constant time.
The run-time complexity of rbegin () and rend
-() is specific for the evaluated vector expression,
-typically amortized constant time.
The run-time complexity of the element access is specific for -the evaluated vector expression, typically amortized constant -time for the dense and logarithmic for the sparse case.
- -The run-time complexity of the arithmetic operations is -specific for the evaluated vector expressions, typically linear -in the size of the expressions.
- + +The run-time complexity of begin () and end ()
+is specific for the evaluated vector expression, typically amortized constant
+time.
The run-time complexity of size () is constant time.
The run-time complexity of swap () is specific for the evaluated
+vector expression, typically constant time.
The run-time complexity of rbegin () and rend ()
+ is specific for the evaluated vector expression, typically amortized constant
+time.
The run-time complexity of the element access is specific for the evaluated +vector expression, typically amortized constant time for the dense and logarithmic +for the sparse case.
+ +The run-time complexity of the arithmetic operations is specific for the +evaluated vector expressions, typically linear in the size of the expressions.
+| Valid range | -For any vector expression v, [v.begin
- (), v.end ()) is a valid range. |
-
| Completeness | -An algorithm that iterates through the range [v.begin
- (), v.end ()) will pass through every element of v.
- |
-
| Valid reverse range | -[v.rbegin (), v.rend ()) is a valid
- range. |
-
| Equivalence of ranges | -The distance from v.begin () to v.end
- () is the same as the distance from v.rbegin
- () to v.rend (). |
- Valid range | +For any vector expression v, [v.begin
+ (), v.end ()) is a valid range. |
+
+
| Completeness | +An algorithm that iterates through the range [v.begin
+ (), v.end ()) will pass through every element of v
+. |
+
| Valid reverse range | +[v.rbegin (), v.rend ()) is a valid range.
+ |
+
| Equivalence of ranges | +The distance from v.begin () to v.end
+ () is the same as the distance from v.rbegin ()
+ to v.rend (). |
+
vector_range<V>vector_slice<V>matrix_row<M>matrix_column<M>matrix_vector_range<M>matrix_vector_slice<M>vector_unary<E, F>vector_binary<E1, E2, F>vector_binary_scalar1<E1, E2, F>vector_binary_scalar2<E1, E2, F>matrix_vector_unary1<E>matrix_vector_unary2<E>matrix_vector_binary1<E1, E2, F>matrix_vector_binary2<E1, E2, F>vector_range<V>vector_slice<V>matrix_row<M>matrix_column<M>matrix_vector_range<M>matrix_vector_slice<M>vector_unary<E, F>vector_binary<E1, E2, F>vector_binary_scalar1<E1, E2, F>vector_binary_scalar2<E1, E2, F>matrix_vector_unary1<E>matrix_vector_unary2<E>matrix_vector_binary1<E1, E2, F>matrix_vector_binary2<E1, E2, F>A Matrix Expression is an expression evaluatable to a matrix. -Matrix Expression provides an Indexed -Bidirectional Column/Row Iterator or an Indexed -Random Access Column/Row Iterator.
- + +A Matrix Expression is an expression evaluatable to a matrix. Matrix Expression +provides an Indexed +Bidirectional Column/Row Iterator + or an Indexed Random +Access Column/Row Iterator +.
+Default Constructible.
- +| Value type | -value_type |
- The type of the matrix expression. | -
| Const iterator types | -const_iterator1 |
- A type of column iterator that may be used to examine - a matrix expression's elements. | -
const_iterator2 |
- A type of row iterator that may be used to examine a - matrix expression's elements. | -|
| Iterator types | -iterator1 |
- A type of column iterator that may be used to modify - a matrix expression's elements. | -
iterator2 |
- A type of row iterator that may be used to modify a - matrix expression's elements. | -|
| Distance type | -difference_type |
- A signed integral type used to represent the distance - between two of the matrix expression's iterators. | -
| Size type | -size_type |
- An unsigned integral type that can represent any - nonnegative value of the matrix expression's distance - type. | -
| Const reverse iterator types | -const_reverse_iterator1 |
- A Reverse Iterator adaptor whose base iterator type - is the matrix expression's const column iterator type. | -
const_reverse_iterator2 |
- A Reverse Iterator adaptor whose base iterator type - is the matrix expression's const row iterator type. | -|
| Reverse iterator types | -reverse_iterator1 |
- A Reverse Iterator adaptor whose base iterator type - is the matrix expression's column iterator type. | -
reverse_iterator2 |
- A Reverse Iterator adaptor whose base iterator type - is the matrix expression's row iterator type. | -Value type | +value_type |
+ The type of the matrix expression. | + +
| Const iterator types | +const_iterator1 |
+ A type of column iterator that may be used to examine + a matrix expression's elements. | +
const_iterator2 |
+ A type of row iterator that may be used to examine a + matrix expression's elements. | +|
| Iterator types | +iterator1 |
+ A type of column iterator that may be used to modify + a matrix expression's elements. | +
iterator2 |
+ A type of row iterator that may be used to modify a +matrix expression's elements. | +|
| Distance type | +difference_type |
+ A signed integral type used to represent the distance + between two of the matrix expression's iterators. | +
| Size type | +size_type |
+ An unsigned integral type that can represent any nonnegative +value of the matrix expression's distance type. | +
| Const reverse iterator types | +const_reverse_iterator1 |
+ A Reverse Iterator adaptor whose base iterator type +is the matrix expression's const column iterator type. | +
const_reverse_iterator2 |
+ A Reverse Iterator adaptor whose base iterator type +is the matrix expression's const row iterator type. | +|
| Reverse iterator types | +reverse_iterator1 |
+ A Reverse Iterator adaptor whose base iterator type +is the matrix expression's column iterator type. | +
reverse_iterator2 |
+ A Reverse Iterator adaptor whose base iterator type +is the matrix expression's row iterator type. | +
M |
- A type that is a model of Matrix Expression | -
m, m1, m2 |
- Object of type M |
-
i, j |
- Objects of a type convertible to size_type
- |
-
t |
- Object of a type convertible to value_type |
- M |
+ A type that is a model of Matrix Expression | + +
m, m1, m2 |
+ Object of type M |
+
i, j |
+ Objects of a type convertible to size_type
+ |
+
t |
+ Object of a type convertible to value_type |
+
In addition to the expressions defined in Default -Constructible the following expressions must be valid.
- + +In addition to the expressions defined in Default Constructible the following +expressions must be valid.
+| Name | -Expression | -Type requirements | -Return type | -
|---|---|---|---|
| Beginning of range | -m.begin1 () |
- - | const_iterator1 |
-
m.begin2 () |
- - | const_iterator2 |
- |
m.begin1 () |
- m is mutable. |
- iterator1 |
- |
m.begin2 () |
- m is mutable. |
- iterator2 |
- |
| End of range | -m.end1 () |
- - | const_iterator1 |
-
m.end2 () |
- - | const_iterator2 |
- |
m.end1 () |
- m is mutable. |
- iterator1 |
- |
m.end2 () |
- m is mutable. |
- iterator2 |
- |
| Size | -m.size1 () |
- - | size_type |
-
m.size2 () |
- - | size_type |
- |
| Swap | -m1.swap (m2) |
- m1 and m2 are
- mutable. |
- void |
-
| Beginning of reverse range | -m.rbegin1 () |
- - | const_reverse_iterator1 |
-
m.rbegin2 () |
- - | const_reverse_iterator2 |
- |
m.rbegin1 () |
- m is mutable. |
- reverse_iterator1 |
- |
m.rbegin2 () |
- m is mutable. |
- reverse_iterator2 |
- |
| End of reverse range | -m.rend1 () |
- - | const_reverse_iterator1 |
-
m.rend2 () |
- - | const_reverse_iterator2 |
- |
m.rend1 () |
- m is mutable. |
- reverse_iterator1 |
- |
m.rend2 () |
- m is mutable. |
- reverse_iterator2 |
- |
| Element access | -m (i, j) |
- i and j are convertible to size_type.
- |
- Convertible to value_type. |
-
| Assignment | -m2 = m1 |
- m2 is mutable and m1 is
- convertible to M. |
- M & |
-
m2.assign (m1) |
- m2 is mutable and m1 is
- convertible to M. |
- M & |
- |
| Computed assignment | -m2 += m1 |
- m2 is mutable and m1 is
- convertible to M. |
- M & |
-
m2.plus_assign (m1) |
- m2 is mutable and m1 is
- convertible to M. |
- M & |
- |
m2 -= m1 |
- m2 is mutable and m1 is
- convertible to M. |
- M & |
- |
m2.minus_assign (m1) |
- m2 is mutable and m1 is
- convertible to M. |
- M & |
- |
m *= t |
- m is mutable and t is
- convertible to value_type. |
- M & |
- Name | +Expression | +Type requirements | +Return type | + +
| Beginning of range | +m.begin1 () |
+ + | const_iterator1 |
+
m.begin2 () |
+ + | const_iterator2 |
+ |
m.begin1 () |
+ m is mutable. |
+ iterator1 |
+ |
m.begin2 () |
+ m is mutable. |
+ iterator2 |
+ |
| End of range | +m.end1 () |
+ + | const_iterator1 |
+
m.end2 () |
+ + | const_iterator2 |
+ |
m.end1 () |
+ m is mutable. |
+ iterator1 |
+ |
m.end2 () |
+ m is mutable. |
+ iterator2 |
+ |
| Size | +m.size1 () |
+ + | size_type |
+
m.size2 () |
+ + | size_type |
+ |
| Swap | +m1.swap (m2) |
+ m1 and m2 are mutable.
+ |
+ void |
+
| Beginning of reverse range | +m.rbegin1 () |
+ + | const_reverse_iterator1 |
+
m.rbegin2 () |
+ + | const_reverse_iterator2 |
+ |
m.rbegin1 () |
+ m is mutable. |
+ reverse_iterator1 |
+ |
m.rbegin2 () |
+ m is mutable. |
+ reverse_iterator2 |
+ |
| End of reverse range | +m.rend1 () |
+ + | const_reverse_iterator1 |
+
m.rend2 () |
+ + | const_reverse_iterator2 |
+ |
m.rend1 () |
+ m is mutable. |
+ reverse_iterator1 |
+ |
m.rend2 () |
+ m is mutable. |
+ reverse_iterator2 |
+ |
| Element access | +m (i, j) |
+ i and j are convertible to size_type
+. |
+ Convertible to value_type. |
+
| Assignment | +m2 = m1 |
+ m2 is mutable and m1 is convertible
+to M. |
+ M & |
+
m2.assign (m1) |
+ m2 is mutable and m1 is convertible
+to M. |
+ M & |
+ |
| Computed assignment | +m2 += m1 |
+ m2 is mutable and m1 is convertible
+to M. |
+ M & |
+
m2.plus_assign (m1) |
+ m2 is mutable and m1 is convertible
+to M. |
+ M & |
+ |
m2 -= m1 |
+ m2 is mutable and m1 is convertible
+to M. |
+ M & |
+ |
m2.minus_assign (m1) |
+ m2 is mutable and m1 is convertible
+to M. |
+ M & |
+ |
m *= t |
+ m is mutable and t is convertible
+to value_type. |
+ M & |
+
Semantics of an expression is defined only where it differs -from, or is not defined in Default Constructible.
- + +Semantics of an expression is defined only where it differs from, or is +not defined in Default Constructible.
+| Name | -Expression | -Precondition | -Semantics | -Postcondition | -||||
|---|---|---|---|---|---|---|---|---|
| Beginning of range | -m.begin1 () |
- - | Returns an iterator pointing to the first element in - the first column of a matrix expression. | -m.begin1 () is either dereferenceable or
- past-the-end. It is past-the-end if and only if m.size1
- () == 0. |
- ||||
m.begin2 () |
- - | Returns an iterator pointing to the first element in - the first row of a matrix expression. | -m.begin2 () is either dereferenceable or
- past-the-end. It is past-the-end if and only if m.size2
- () == 0. |
- |||||
| End of range | -m.end1 () |
- - | Returns an iterator pointing one past the last - element in the matrix expression. | -m.end1 () is past-the-end. |
- ||||
m.end2 () |
- - | Returns an iterator pointing one past the last - element in the matrix expression. | -m.end2 () is past-the-end. |
- |||||
| Size | -m.size1 () |
- - | Returns the number of rows of the matrix expression. | -m.size1 () >= 0 |
- ||||
m.size2 () |
- - | Returns the number of columns of the matrix - expression. | -m.size2 () >= 0 |
- |||||
| Swap | -m1.swap (m2) |
- - | Equivalent to swap (m1, m2). |
- - | ||||
| Beginning of reverse range | -m.rbegin1 () |
- - | Equivalent to reverse_iterator1 (m.end1 ()).
- |
- m.rbegin1 () is either dereferenceable
- or past-the-end. It is past-the-end if and only if m.size1
- () == 0. |
- ||||
m.rbegin2 () |
- - | Equivalent to reverse_iterator2 (m.end2 ()).
- |
- m.rbegin2 () is either dereferenceable
- or past-the-end. It is past-the-end if and only if m.size2
- () == 0. |
- |||||
| End of reverse range | -m.rend1 () |
- - | Equivalent to reverse_iterator1 (m.begin1 ()).
- |
- m.rend1 () is past-the-end. |
- ||||
m.rend2 () |
- - | Equivalent to reverse_iterator2 (m.begin2 ()).
- |
- m.rend2 () is past-the-end. |
- |||||
| Element access | -m (i, j) |
- 0 <= i < m.size1 () and 0
- <= j < m.size2 () |
- Returns the j-th element of the i-th
+ | Name | +Expression | +Precondition | +Semantics | +Postcondition | +
| Beginning of range | +m.begin1 () |
+ + | Returns an iterator pointing to the first element in + the first column of a matrix expression. | +m.begin1 () is either dereferenceable or
+ past-the-end. It is past-the-end if and only if m.size1 ()
+== 0. |
+ ||||
m.begin2 () |
+ + | Returns an iterator pointing to the first element in + the first row of a matrix expression. | +m.begin2 () is either dereferenceable or
+ past-the-end. It is past-the-end if and only if m.size2 ()
+== 0. |
+ |||||
| End of range | +m.end1 () |
+ + | Returns an iterator pointing one past the last element +in the matrix expression. | +m.end1 () is past-the-end. |
+ ||||
m.end2 () |
+ + | Returns an iterator pointing one past the last element +in the matrix expression. | +m.end2 () is past-the-end. |
+ |||||
| Size | +m.size1 () |
+ + | Returns the number of rows of the matrix expression. | +m.size1 () >= 0 |
+ ||||
m.size2 () |
+ + | Returns the number of columns of the matrix expression. + | +m.size2 () >= 0 |
+ |||||
| Swap | +m1.swap (m2) |
+ + | Equivalent to swap (m1, m2). |
+ + | ||||
| Beginning of reverse range | +m.rbegin1 () |
+ + | Equivalent to reverse_iterator1 (m.end1 ()).
+ |
+ m.rbegin1 () is either dereferenceable
+or past-the-end. It is past-the-end if and only if m.size1
+() == 0. |
+ ||||
m.rbegin2 () |
+ + | Equivalent to reverse_iterator2 (m.end2 ()).
+ |
+ m.rbegin2 () is either dereferenceable
+or past-the-end. It is past-the-end if and only if m.size2
+() == 0. |
+ |||||
| End of reverse range | +m.rend1 () |
+ + | Equivalent to reverse_iterator1 (m.begin1 ()).
+ |
+ m.rend1 () is past-the-end. |
+ ||||
m.rend2 () |
+ + | Equivalent to reverse_iterator2 (m.begin2 ()).
+ |
+ m.rend2 () is past-the-end. |
+ |||||
| Element access | +m (i, j) |
+ 0 <= i < m.size1 () and 0 <=
+j < m.size2 () |
+ Returns the j-th element of the i-th
row of the matrix expression. |
- - | ||||
| Assignment | -m2 = m1 |
- m1.size1 () == m2.size1 () and |
- Assigns every element of the evaluated matrix
- expression m1 to the corresponding element
- of m2. |
- - | ||||
m2.assign (m1) |
- m1.size1 () == m2.size1 () and |
- Assigns every element of m1 to the
- corresponding element of m2. |
- - | |||||
| Computed assignment | -m2 += m1 |
- m1.size1 () == m2.size1 () and |
- Adds every element of the evaluated matrix expression
- m1 to the corresponding element of m2. |
- - | ||||
m2.plus_assign (m1) |
- m1.size1 () == m2.size1 () and |
- Adds every element of m1 to the
- corresponding element of m2. |
- - | |||||
m2 -= m1 |
- m1.size1 () == m2.size1 () and |
- Subtracts every element of the evaluated matrix
- expression m1 from the corresponding element
- of m2. |
- - | |||||
m2.minus_assign (m1) |
- m1.size1 () == m2.size1 () and |
- Subtracts every element of m1 from the
- corresponding element of m2. |
- - | |||||
m *= t |
- - | Multiplies every element of m with t. |
- - | + + | ||||
| Assignment | +m2 = m1 |
+ m1.size1 () == m2.size1 () and |
+ Assigns every element of the evaluated matrix expression
+ m1 to the corresponding element of m2
+. |
+ + | ||||
m2.assign (m1) |
+ m1.size1 () == m2.size1 () and |
+ Assigns every element of m1 to the corresponding
+element of m2. |
+ + | |||||
| Computed assignment | +m2 += m1 |
+ m1.size1 () == m2.size1 () and |
+ Adds every element of the evaluated matrix expression
+ m1 to the corresponding element of m2. |
+ + | ||||
m2.plus_assign (m1) |
+ m1.size1 () == m2.size1 () and |
+ Adds every element of m1 to the corresponding
+element of m2. |
+ + | |||||
m2 -= m1 |
+ m1.size1 () == m2.size1 () and |
+ Subtracts every element of the evaluated matrix expression
+ m1 from the corresponding element of m2
+. |
+ + | |||||
m2.minus_assign (m1) |
+ m1.size1 () == m2.size1 () and |
+ Subtracts every element of m1 from the
+corresponding element of m2. |
+ + | |||||
m *= t |
+ + | Multiplies every element of m with t
+. |
+ + |
The run-time complexity of begin1 (),
-begin2 (), end1 () and end2 () is
-specific for the evaluated matrix expression.
The run-time complexity of size1 () and size2
-() is constant time.
The run-time complexity of swap () is specific
-for the evaluated matrix expression, typically constant time.
The run-time complexity of rbegin1 (),
-rbegin2 (), rend1 () and rend2 () is
-specific for the evaluated matrix expression.
The run-time complexity of the element access is specific for -the evaluated matrix expression, typically amortized constant -time for the dense and logarithmic for the sparse case.
- -The run-time complexity of the arithmetic operations is -specific for the evaluated matrix expressions, typically -quadratic in the size of the proxies.
- + +The run-time complexity of begin1 (), begin2 ()
+, end1 () and end2 () is specific for the evaluated
+matrix expression.
The run-time complexity of size1 () and size2 ()
+is constant time.
The run-time complexity of swap () is specific for the evaluated
+matrix expression, typically constant time.
The run-time complexity of rbegin1 (), rbegin2 ()
+, rend1 () and rend2 () is specific for the evaluated
+matrix expression.
The run-time complexity of the element access is specific for the evaluated +matrix expression, typically amortized constant time for the dense and logarithmic +for the sparse case.
+ +The run-time complexity of the arithmetic operations is specific for the +evaluated matrix expressions, typically quadratic in the size of the proxies.
+| Valid range | -For any matrix expression m, [m.begin1
- (), m.end1 ()) and [m.begin2 (), m.end2 ())
- are valid ranges. |
- ||
| Completeness | -An algorithm that iterates through the range [m.begin1
- (), m.end1 ()) will pass through every row of m,
- an algorithm that iterates through the range [m.begin2
- (), m.end2 ()) will pass through every column of m. |
- ||
| Valid reverse range | -[m.rbegin1 (), m.rend1 ()) and [m.rbegin2
+ | ||
| Completeness | +An algorithm that iterates through the range [m.begin1
+ (), m.end1 ()) will pass through every row of m
+, an algorithm that iterates through the range [m.begin2
+ (), m.end2 ()) will pass through every column of m
+. |
+ ||
| Valid reverse range | +[m.rbegin1 (), m.rend1 ()) and [m.rbegin2
(), m.rend2 ()) are valid ranges. |
- ||
| Equivalence of ranges | -The distance from m.begin1 () to m.end1
- () is the same as the distance from m.rbegin1
- () to m.rend1 () and the distance
- from m.begin2 () to m.end2 ()
- is the same as the distance from m.rbegin2 ()
- to m.rend2 (). |
- ||
| Equivalence of ranges | +The distance from m.begin1 () to m.end1
+ () is the same as the distance from m.rbegin1
+ () to m.rend1 () and the distance from
+m.begin2 () to m.end2 () is the same as the distance
+from m.rbegin2 () to m.rend2 (). |
+
matrix_range<M>matrix_slice<M>triangular_adaptor<M, F>symmetric_adaptor<M, F>banded_adaptor<M>vector_matrix_binary<E1, E2, F>matrix_unary1<E, F>matrix_unary2<E, F>matrix_binary<E1, E2, F>matrix_binary_scalar1<E1, E2, F>matrix_binary_scalar2<E1, E2, F>matrix_matrix_binary<E1, E2, F>matrix_range<M>matrix_slice<M>triangular_adaptor<M, F>symmetric_adaptor<M, F>banded_adaptor<M>vector_matrix_binary<E1, E2, F>matrix_unary1<E, F>matrix_unary2<E, F>matrix_binary<E1, E2, F>matrix_binary_scalar1<E1, E2, F>matrix_binary_scalar2<E1, E2, F>matrix_matrix_binary<E1, E2, F>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this document is granted
-provided this copyright notice appears in all copies. This document is provided
-``as is'' without express or implied warranty, and with no claim as to its suitability
-for any purpose.
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+ Permission to copy, use, modify, sell and distribute this document is granted
+provided this copyright notice appears in all copies. This document is provided
+``as is'' without express or implied warranty, and with no claim as to its
+suitability for any purpose.
Last revised: 8/3/2002
- + diff --git a/doc/hermitian.htm b/doc/hermitian.htm index 8a7abc25..7c115999 100644 --- a/doc/hermitian.htm +++ b/doc/hermitian.htm @@ -1,1208 +1,605 @@ + - - - -
Hermitian Matrix
+ Hermitian MatrixThe templated class hermitian_matrix<T, F1, F2, A>
-is the base container adaptor for hermitian matrices. For
-a (n x n)-dimensional hermitian matrix and 0 <= i
-< n, 0 <= j < n holds hi,
-j = hj, i-.
-The storage of hermitian matrices is packed.
The templated class hermitian_matrix<T, F1, F2, A>
+ is the base container adaptor for hermitian matrices. For a (n x n
+ )-dimensional hermitian matrix and 0 <= i < n, 0 <=
+j < n holds hi, j = h
+ j, i-. The storage of hermitian matrices
+is packed.
int main () {
- using namespace boost::numeric::ublas;
- hermitian_matrix<std::complex<double>, lower> ml (3, 3);
- for (int i = 0; i < ml.size1 (); ++ i)
- for (int j = 0; j <= i; ++ j)
- ml (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
- std::cout << ml << std::endl;
- hermitian_matrix<std::complex<double>, upper> mu (3, 3);
- for (int i = 0; i < m.size1 (); ++ i)
- for (int j = i; j < m.size2 (); ++ j)
- mu (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
- std::cout << mu << std::endl;
-}
-
+
+#include <boost/numeric/ublas/hermitian.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
hermitian_matrix<std::complex<double>, lower> ml (3, 3);
for (unsigned i = 0; i < ml.size1 (); ++ i) {
for (unsigned j = 0; j < i; ++ j)
ml (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
ml (i, i) = std::complex<double> (4 * i, 0);
}
std::cout << ml << std::endl;
hermitian_matrix<std::complex<double>, upper> mu (3, 3);
for (unsigned i = 0; i < mu.size1 (); ++ i) {
mu (i, i) = std::complex<double> (4 * i, 0);
for (unsigned j = i + 1; j < mu.size2 (); ++ j)
mu (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
}
std::cout << mu << std::endl;
}
Defined in the header hermitian.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
T |
- The type of object stored in the matrix. | -- |
F1 |
- Functor describing the type of the hermitian matrix. [1] | -lower |
-
F2 |
- Functor describing the storage organization. [2] | -row_major |
-
A |
- The type of the adapted array. [3] | -unbounded_array<T> |
-
| Parameter | +Description | +Default | +
T |
+ The type of object stored in the matrix. | ++ |
F1 |
+ Functor describing the type of the hermitian matrix. + [1] + | +lower |
+
F2 |
+ Functor describing the storage organization. + [2] + | +row_major |
+
A |
+ The type of the adapted array. + [3] + | +unbounded_array<T> |
+
Matrix + .
+None, except for those imposed by the requirements of Matrix.
- + +None, except for those imposed by the requirements of + Matrix + .
+matrix_expression<hermitian_matrix<T, F1, F2,
-A> >
matrix_expression<hermitian_matrix<T, F1, F2, A> >
+
| Member | -Description | -
|---|---|
hermitian_matrix () |
- Allocates an uninitialized hermitian_matrix
- that holds zero rows of zero elements. |
-
hermitian_matrix (size_type size) |
- Allocates an uninitialized hermitian_matrix
- that holds size rows of size
- elements. |
-
hermitian_matrix (const hermitian_matrix
- &m) |
- The copy constructor. | -
template<class AE> |
- The extended copy constructor. | -
void resize (size_type size) |
- Reallocates a hermitian_matrix to hold size
- rows of size elements. The content of the hermitian_matrix
- is not 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 a const reference 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. |
-
hermitian_matrix &operator = (const
- hermitian_matrix &m) |
- The assignment operator. | -
hermitian_matrix &assign_temporary
- (hermitian_matrix &m) |
- Assigns a temporary. May change the hermitian matrix m. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a matrix expression to the hermitian 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 hermitian matrix. | -
template<class AE> |
- Adds a matrix expression to the hermitian 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 hermitian matrix. | -
template<class AE> |
- Subtracts a matrix expression from the hermitian - matrix. Left and right hand side of the assignment should - be independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the - hermitian matrix with a scalar. | -
template<class AT> |
- A computed assignment operator. Divides the hermitian - matrix through a scalar. | -
void swap (hermitian_matrix &m) |
- Swaps the contents of the hermitian 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 elemenst of
- the i-th row. |
-
void clear () |
- Clears the matrix. | -
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the hermitian_matrix. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the hermitian_matrix. |
-
iterator1 begin1 () |
- Returns a iterator1 pointing to the
- beginning of the hermitian_matrix. |
-
iterator1 end1 () |
- Returns a iterator1 pointing to the end
- of the hermitian_matrix. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the hermitian_matrix. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the hermitian_matrix. |
-
iterator2 begin2 () |
- Returns a iterator2 pointing to the
- beginning of the hermitian_matrix. |
-
iterator2 end2 () |
- Returns a iterator2 pointing to the end
- of the hermitian_matrix. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed hermitian_matrix.
- |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed hermitian_matrix.
- |
-
reverse_iterator1 rbegin1 () |
- Returns a reverse_iterator1 pointing to
- the beginning of the reversed hermitian_matrix.
- |
-
reverse_iterator1 rend1 () |
- Returns a reverse_iterator1 pointing to
- the end of the reversed hermitian_matrix. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed hermitian_matrix.
- |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed hermitian_matrix.
- |
-
reverse_iterator2 rbegin2 () |
- Returns a reverse_iterator2 pointing to
- the beginning of the reversed hermitian_matrix.
- |
-
reverse_iterator2 rend2 () |
- Returns a reverse_iterator2 pointing to
- the end of the reversed hermitian_matrix. |
-
| Member | +Description | +
hermitian_matrix () |
+ Allocates an uninitialized hermitian_matrix
+ that holds zero rows of zero elements. |
+
hermitian_matrix (size_type size) |
+ Allocates an uninitialized hermitian_matrix
+ that holds size rows of size elements. |
+
hermitian_matrix (const hermitian_matrix &m) |
+ The copy constructor. | +
template<class AE> |
+ The extended copy constructor. | +
void resize (size_type size) |
+ Reallocates a hermitian_matrix to hold size
+ rows of size elements. The content of the hermitian_matrix
+ is not 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 a const reference 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. |
+
hermitian_matrix &operator = (const hermitian_matrix
+&m) |
+ The assignment operator. | +
hermitian_matrix &assign_temporary (hermitian_matrix
+&m) |
+ Assigns a temporary. May change the hermitian matrix
+m . |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a matrix expression to the hermitian 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 hermitian matrix. | +
template<class AE> |
+ Adds a matrix expression to the hermitian 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 hermitian matrix. | +
template<class AE> |
+ Subtracts a matrix expression from the hermitian matrix. +Left and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the hermitian +matrix with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the hermitian + matrix through a scalar. | +
void swap (hermitian_matrix &m) |
+ Swaps the contents of the hermitian 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 elemenst of
+ the i-th row. |
+
void clear () |
+ Clears the matrix. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to
+the beginning of the hermitian_matrix. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to
+the end of the hermitian_matrix. |
+
iterator1 begin1 () |
+ Returns a iterator1 pointing to the beginning
+of the hermitian_matrix. |
+
iterator1 end1 () |
+ Returns a iterator1 pointing to the end
+ of the hermitian_matrix. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to
+the beginning of the hermitian_matrix. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to
+the end of the hermitian_matrix. |
+
iterator2 begin2 () |
+ Returns a iterator2 pointing to the beginning
+of the hermitian_matrix. |
+
iterator2 end2 () |
+ Returns a iterator2 pointing to the end
+ of the hermitian_matrix. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed hermitian_matrix. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed hermitian_matrix. |
+
reverse_iterator1 rbegin1 () |
+ Returns a reverse_iterator1 pointing to
+ the beginning of the reversed hermitian_matrix. |
+
reverse_iterator1 rend1 () |
+ Returns a reverse_iterator1 pointing to
+ the end of the reversed hermitian_matrix. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed hermitian_matrix. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed hermitian_matrix. |
+
reverse_iterator2 rbegin2 () |
+ Returns a reverse_iterator2 pointing to
+ the beginning of the reversed hermitian_matrix. |
+
reverse_iterator2 rend2 () |
+ Returns a reverse_iterator2 pointing to
+ the end of the reversed hermitian_matrix. |
+
[1] Supported parameters for
-the type of the hermitian matrix are lower and upper.
[2] Supported parameters for
-the storage organization are row_major and column_major.
[3] Supported parameters for
-the adapted array are unbounded_array<T>, bounded_array<T>
-and std::vector<T>.
[1]
+ Supported parameters for the type of the hermitian matrix are lower
+ and upper.
[2]
+ Supported parameters for the storage organization are row_major
+ and column_major.
[3]
+ Supported parameters for the adapted array are unbounded_array<T>
+ , bounded_array<T> and std::vector<T>
+ .
// Array based hermitian matrix class
- template<class T, class F1, class F2, class A>
- class hermitian_matrix:
- public matrix_expression<hermitian_matrix<T, F1, F2, A> > {
- 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 F1 functor1_type;
- typedef F2 functor2_type;
- typedef A array_type;
- typedef const A const_array_type;
- typedef const hermitian_matrix<T, F1, F2, A> const_self_type;
- typedef hermitian_matrix<T, F1, F2, A> self_type;
- typedef const matrix_const_reference<const_self_type> const_closure_type;
- typedef matrix_reference<self_type> closure_type;
- typedef packed_tag storage_category;
- typedef typename F1::packed_category packed_category;
- typedef typename F2::orientation_category orientation_category;
-
- // Construction and destruction
- hermitian_matrix ();
- hermitian_matrix (size_type size);
- hermitian_matrix (size_type size1, size_type size2);
- hermitian_matrix (const hermitian_matrix &m);
- template<class AE>
- hermitian_matrix (const matrix_expression<AE> &ae);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- const_array_type &data () const;
- array_type &data ();
-
- // Resizing
- void resize (size_type size);
- void resize (size_type size1, size_type size2);
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
- reference operator () (size_type i, size_type j);
-
- // Assignment
- hermitian_matrix &operator = (const hermitian_matrix &m);
- hermitian_matrix &assign_temporary (hermitian_matrix &m);
- template<class AE>
- hermitian_matrix &operator = (const matrix_expression<AE> &ae);
- template<class AE>
- hermitian_matrix &reset (const matrix_expression<AE> &ae);
- template<class AE>
- hermitian_matrix &assign (const matrix_expression<AE> &ae);
- template<class AE>
- hermitian_matrix& operator += (const matrix_expression<AE> &ae);
- template<class AE>
- hermitian_matrix &plus_assign (const matrix_expression<AE> &ae);
- template<class AE>
- hermitian_matrix& operator -= (const matrix_expression<AE> &ae);
- template<class AE>
- hermitian_matrix &minus_assign (const matrix_expression<AE> &ae);
- template<class AT>
- hermitian_matrix& operator *= (const AT &at);
- template<class AT>
- hermitian_matrix& operator /= (const AT &at);
-
- // Swapping
- void swap (hermitian_matrix &m);
- friend void swap (hermitian_matrix &m1, hermitian_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 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 indices.
-
- class const_iterator1:
- public container_const_reference<hermitian_matrix>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename hermitian_matrix::difference_type difference_type;
- typedef typename hermitian_matrix::value_type value_type;
- typedef typename hermitian_matrix::const_reference reference;
- typedef typename hermitian_matrix::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const hermitian_matrix &m, size_type it1, size_type it2);
- const_iterator1 (const iterator1 &it);
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator < (const const_iterator1 &it) const;
- };
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class iterator1:
- public container_reference<hermitian_matrix>,
- public random_access_iterator_base<iterator1, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename hermitian_matrix::difference_type difference_type;
- typedef typename hermitian_matrix::value_type value_type;
- typedef typename hermitian_matrix::reference reference;
- typedef typename hermitian_matrix::pointer pointer;
- typedef iterator2 dual_iterator_type;
- typedef reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator1 ();
- iterator1 (hermitian_matrix &m, size_type it1, size_type it2);
-
- // Arithmetic
- iterator1 &operator ++ ();
- iterator1 &operator -- ();
- iterator1 &operator += (difference_type n);
- iterator1 &operator -= (difference_type n);
- difference_type operator - (const iterator1 &it) const;
-
- // 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;
- bool operator < (const iterator1 &it) const;
- };
-
- iterator1 begin1 ();
- iterator1 end1 ();
-
- class const_iterator2:
- public container_const_reference<hermitian_matrix>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename hermitian_matrix::difference_type difference_type;
- typedef typename hermitian_matrix::value_type value_type;
- typedef typename hermitian_matrix::const_reference reference;
- typedef typename hermitian_matrix::const_pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const hermitian_matrix &m, size_type it1, size_type it2);
- const_iterator2 (const iterator2 &it);
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator < (const const_iterator2 &it) const;
- };
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- class iterator2:
- public container_reference<hermitian_matrix>,
- public random_access_iterator_base<iterator2, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename hermitian_matrix::difference_type difference_type;
- typedef typename hermitian_matrix::value_type value_type;
- typedef typename hermitian_matrix::reference reference;
- typedef typename hermitian_matrix::pointer pointer;
- typedef iterator1 dual_iterator_type;
- typedef reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator2 ();
- iterator2 (hermitian_matrix &m, size_type it1, size_type it2);
-
- // Arithmetic
- iterator2 &operator ++ ();
- iterator2 &operator -- ();
- iterator2 &operator += (difference_type n);
- iterator2 &operator -= (difference_type n);
- difference_type operator - (const iterator2 &it) const;
-
- // 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;
- 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 ();
- };
-
- // Array based hermitian matrix class
template<class T, class F1, class F2, class A>
class hermitian_matrix:
public matrix_expression<hermitian_matrix<T, F1, F2, A> > {
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 F1 functor1_type;
typedef F2 functor2_type;
typedef A array_type;
typedef const A const_array_type;
typedef const hermitian_matrix<T, F1, F2, A> const_self_type;
typedef hermitian_matrix<T, F1, F2, A> self_type;
typedef const matrix_const_reference<const_self_type> const_closure_type;
typedef matrix_reference<self_type> closure_type;
typedef packed_tag storage_category;
typedef typename F1::packed_category packed_category;
typedef typename F2::orientation_category orientation_category;
// Construction and destruction
hermitian_matrix ();
hermitian_matrix (size_type size);
hermitian_matrix (size_type size1, size_type size2);
hermitian_matrix (const hermitian_matrix &m);
template<class AE>
hermitian_matrix (const matrix_expression<AE> &ae);
// Accessors
size_type size1 () const;
size_type size2 () const;
const_array_type &data () const;
array_type &data ();
// Resizing
void resize (size_type size);
void resize (size_type size1, size_type size2);
// Element access
const_reference operator () (size_type i, size_type j) const;
reference operator () (size_type i, size_type j);
// Assignment
hermitian_matrix &operator = (const hermitian_matrix &m);
hermitian_matrix &assign_temporary (hermitian_matrix &m);
template<class AE>
hermitian_matrix &operator = (const matrix_expression<AE> &ae);
template<class AE>
hermitian_matrix &reset (const matrix_expression<AE> &ae);
template<class AE>
hermitian_matrix &assign (const matrix_expression<AE> &ae);
template<class AE>
hermitian_matrix& operator += (const matrix_expression<AE> &ae);
template<class AE>
hermitian_matrix &plus_assign (const matrix_expression<AE> &ae);
template<class AE>
hermitian_matrix& operator -= (const matrix_expression<AE> &ae);
template<class AE>
hermitian_matrix &minus_assign (const matrix_expression<AE> &ae);
template<class AT>
hermitian_matrix& operator *= (const AT &at);
template<class AT>
hermitian_matrix& operator /= (const AT &at);
// Swapping
void swap (hermitian_matrix &m);
friend void swap (hermitian_matrix &m1, hermitian_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 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 indices.
class const_iterator1:
public container_const_reference<hermitian_matrix>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename hermitian_matrix::difference_type difference_type;
typedef typename hermitian_matrix::value_type value_type;
typedef typename hermitian_matrix::const_reference reference;
typedef typename hermitian_matrix::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const hermitian_matrix &m, size_type it1, size_type it2);
const_iterator1 (const iterator1 &it);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator < (const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class iterator1:
public container_reference<hermitian_matrix>,
public random_access_iterator_base<iterator1, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename hermitian_matrix::difference_type difference_type;
typedef typename hermitian_matrix::value_type value_type;
typedef typename hermitian_matrix::reference reference;
typedef typename hermitian_matrix::pointer pointer;
typedef iterator2 dual_iterator_type;
typedef reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
iterator1 ();
iterator1 (hermitian_matrix &m, size_type it1, size_type it2);
// Arithmetic
iterator1 &operator ++ ();
iterator1 &operator -- ();
iterator1 &operator += (difference_type n);
iterator1 &operator -= (difference_type n);
difference_type operator - (const iterator1 &it) const;
// 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;
bool operator < (const iterator1 &it) const;
};
iterator1 begin1 ();
iterator1 end1 ();
class const_iterator2:
public container_const_reference<hermitian_matrix>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename hermitian_matrix::difference_type difference_type;
typedef typename hermitian_matrix::value_type value_type;
typedef typename hermitian_matrix::const_reference reference;
typedef typename hermitian_matrix::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const hermitian_matrix &m, size_type it1, size_type it2);
const_iterator2 (const iterator2 &it);
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator < (const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
class iterator2:
public container_reference<hermitian_matrix>,
public random_access_iterator_base<iterator2, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename hermitian_matrix::difference_type difference_type;
typedef typename hermitian_matrix::value_type value_type;
typedef typename hermitian_matrix::reference reference;
typedef typename hermitian_matrix::pointer pointer;
typedef iterator1 dual_iterator_type;
typedef reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
iterator2 ();<
+br> iterator2 (hermitian_matrix &m, size_type it1, size_type it2);
// Arithmetic
iterator2 &operator ++ ();
iterator2 &operator -- ();
iterator2 &operator += (difference_type n);
iterator2 &operator -= (difference_type n);
difference_type operator - (const iterator2 &it) const;
// 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;
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 hermitian_adaptor<M, F> is
-a hermitian matrix adaptor for other matrices.
The templated class hermitian_adaptor<M, F> is a hermitian
+matrix adaptor for other matrices.
int main () {
- using namespace boost::numeric::ublas;
- matrix<std::complex<double> > m (3, 3);
- hermitian_adaptor<matrix<std::complex<double> >, lower> hal (m);
- for (int i = 0; i < hal.size1 (); ++ i)
- for (int j = 0; j <= i; ++ j)
- hal (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
- std::cout << hal << std::endl;
- hermitian_adaptor<matrix<std::complex<double> >, upper> hau (m);
- for (int i = 0; i < hau.size1 (); ++ i)
- for (int j = i; j < hau.size2 (); ++ j)
- hau (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
- std::cout << sau << std::endl;
-}
-
+
+#include <boost/numeric/ublas/hermitian.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<std::complex<double> > m (3, 3);
hermitian_adaptor<matrix<std::complex<double> >, lower> hal (m);
for (unsigned i = 0; i < hal.size1 (); ++ i) {
for (unsigned j = 0; j < i; ++ j)
hal (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
hal (i, i) = std::complex<double> (4 * i, 0);
}
std::cout << hal << std::endl;
hermitian_adaptor<matrix<std::complex<double> >, upper> hau (m);
for (unsigned i = 0; i < hau.size1 (); ++ i) {
hau (i, i) = std::complex<double> (4 * i, 0);
for (unsigned j = i + 1; j < hau.size2 (); ++ j)
hau (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
}
std::cout << hau << std::endl;
}
Defined in the header hermitian.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
M |
- The type of the adapted matrix. | -- |
F |
- Functor describing the type of the hermitian adaptor. - [1] | -lower |
-
| Parameter | +Description | +Default | +
M |
+ The type of the adapted matrix. | ++ |
F |
+ Functor describing the type of the hermitian adaptor. + [1] + | +lower |
+
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of + Matrix Expression + .
+matrix_expression<hermitian_adaptor<M, F> >
-
matrix_expression<hermitian_adaptor<M, F> >
| Member | -Description | -
|---|---|
hermitian_adaptor () |
- Constructs a hermitian_adaptor that
- holds zero rows of zero elements. |
-
hermitian_adaptor (matrix_type &data) |
- Constructs a hermitian_adaptor of a
- matrix. |
-
hermitian_adaptor (const hermitian_adaptor
- &m) |
- The copy constructor. | -
template<class AE> |
- The extended copy constructor. | -
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 a const reference 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. |
-
hermitian_adaptor &operator = (const
- hermitian_adaptor &m) |
- The assignment operator. | -
hermitian_adaptor &assign_temporary
- (hermitian_adaptor &m) |
- Assigns a temporary. May change the hermitian adaptor
- m. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a matrix expression to the hermitian adaptor. - Left and right hand side of the assignment should be - independent. | -
template<class AE> |
- A computed assignment operator. Adds the matrix - expression to the hermitian adaptor. | -
template<class AE> |
- Adds a matrix expression to the hermitian adaptor. - Left and right hand side of the assignment should be - independent. | -
template<class AE> |
- A computed assignment operator. Subtracts the matrix - expression from the hermitian adaptor. | -
template<class AE> |
- Subtracts a matrix expression from the hermitian - adaptor. Left and right hand side of the assignment - should be independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the - hermitian adaptor with a scalar. | -
template<class AT> |
- A computed assignment operator. Divides the hermitian - adaptor through a scalar. | -
void swap (hermitian_adaptor &m) |
- Swaps the contents of the hermitian adaptors. | -
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the hermitian_adaptor. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the hermitian_adaptor. |
-
iterator1 begin1 () |
- Returns a iterator1 pointing to the
- beginning of the hermitian_adaptor. |
-
iterator1 end1 () |
- Returns a iterator1 pointing to the end
- of the hermitian_adaptor. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the hermitian_adaptor. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the hermitian_adaptor. |
-
iterator2 begin2 () |
- Returns a iterator2 pointing to the
- beginning of the hermitian_adaptor. |
-
iterator2 end2 () |
- Returns a iterator2 pointing to the end
- of the hermitian_adaptor. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed hermitian_adaptor.
- |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed hermitian_adaptor.
- |
-
reverse_iterator1 rbegin1 () |
- Returns a reverse_iterator1 pointing to
- the beginning of the reversed hermitian_adaptor.
- |
-
reverse_iterator1 rend1 () |
- Returns a reverse_iterator1 pointing to
- the end of the reversed hermitian_adaptor. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed hermitian_adaptor.
- |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed hermitian_adaptor.
- |
-
reverse_iterator2 rbegin2 () |
- Returns a reverse_iterator2 pointing to
- the beginning of the reversed hermitian_adaptor.
- |
-
reverse_iterator2 rend2 () |
- Returns a reverse_iterator2 pointing to
- the end of the reversed hermitian_adaptor. |
-
| Member | +Description | +
hermitian_adaptor () |
+ Constructs a hermitian_adaptor that holds
+zero rows of zero elements. |
+
hermitian_adaptor (matrix_type &data) |
+ Constructs a hermitian_adaptor of a matrix. |
+
hermitian_adaptor (const hermitian_adaptor &m) |
+ The copy constructor. | +
template<class AE> |
+ The extended copy constructor. | +
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 a const reference 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. |
+
hermitian_adaptor &operator = (const hermitian_adaptor
+&m) |
+ The assignment operator. | +
hermitian_adaptor &assign_temporary (hermitian_adaptor
+&m) |
+ Assigns a temporary. May change the hermitian adaptor
+ m. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a matrix expression to the hermitian adaptor. + Left and right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Adds the matrix expression +to the hermitian adaptor. | +
template<class AE> |
+ Adds a matrix expression to the hermitian adaptor. +Left and right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Subtracts the matrix + expression from the hermitian adaptor. | +
template<class AE> |
+ Subtracts a matrix expression from the hermitian adaptor. +Left and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the hermitian +adaptor with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the hermitian + adaptor through a scalar. | +
void swap (hermitian_adaptor &m) |
+ Swaps the contents of the hermitian adaptors. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to
+the beginning of the hermitian_adaptor. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to
+the end of the hermitian_adaptor. |
+
iterator1 begin1 () |
+ Returns a iterator1 pointing to the beginning
+of the hermitian_adaptor. |
+
iterator1 end1 () |
+ Returns a iterator1 pointing to the end
+ of the hermitian_adaptor. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to
+the beginning of the hermitian_adaptor. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to
+the end of the hermitian_adaptor. |
+
iterator2 begin2 () |
+ Returns a iterator2 pointing to the beginning
+of the hermitian_adaptor. |
+
iterator2 end2 () |
+ Returns a iterator2 pointing to the end
+ of the hermitian_adaptor. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed hermitian_adaptor.
+ |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed hermitian_adaptor. |
+
reverse_iterator1 rbegin1 () |
+ Returns a reverse_iterator1 pointing to
+ the beginning of the reversed hermitian_adaptor. |
+
reverse_iterator1 rend1 () |
+ Returns a reverse_iterator1 pointing to
+ the end of the reversed hermitian_adaptor. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed hermitian_adaptor.
+ |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed hermitian_adaptor. |
+
reverse_iterator2 rbegin2 () |
+ Returns a reverse_iterator2 pointing to
+ the beginning of the reversed hermitian_adaptor. |
+
reverse_iterator2 rend2 () |
+ Returns a reverse_iterator2 pointing to
+ the end of the reversed hermitian_adaptor. |
+
[1] Supported parameters
-for the type of the hermitian adaptor are lower and upper.
[1]
+ Supported parameters for the type of the hermitian adaptor are lower
+ and upper.
// Hermitian matrix adaptor class
- template<class M, class F>
- class hermitian_adaptor:
- public matrix_expression<hermitian_adaptor<M, F> > {
- public:
- typedef const M const_matrix_type;
- typedef M matrix_type;
- typedef F functor_type;
- typedef typename M::size_type size_type;
- typedef typename M::difference_type difference_type;
- typedef typename M::value_type value_type;
- typedef typename M::value_type const_reference;
- typedef typename M::reference reference;
- typedef typename M::const_pointer const_pointer;
- typedef typename M::pointer pointer;
- typedef const hermitian_adaptor<M, F> const_self_type;
- typedef hermitian_adaptor<M, F> self_type;
- typedef const matrix_const_reference<const_self_type> const_closure_type;
- typedef matrix_reference<self_type> closure_type;
- typedef typename storage_restrict_traits<typename M::storage_category,
- packed_proxy_tag>::storage_category storage_category;
- typedef typename F::packed_category packed_category;
- typedef typename M::orientation_category orientation_category;
-
- // Construction and destruction
- hermitian_adaptor ();
- hermitian_adaptor (matrix_type &data);
- hermitian_adaptor (const hermitian_adaptor &m);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- const_matrix_type &data () const;
- matrix_type &data ();
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
- reference operator () (size_type i, size_type j);
-
- // Assignment
- hermitian_adaptor &operator = (const hermitian_adaptor &m);
- hermitian_adaptor &assign_temporary (hermitian_adaptor &m);
- template<class AE>
- hermitian_adaptor &operator = (const matrix_expression<AE> &ae);
- template<class AE>
- hermitian_adaptor &assign (const matrix_expression<AE> &ae);
- template<class AE>
- hermitian_adaptor& operator += (const matrix_expression<AE> &ae);
- template<class AE>
- hermitian_adaptor &plus_assign (const matrix_expression<AE> &ae);
- template<class AE>
- hermitian_adaptor& operator -= (const matrix_expression<AE> &ae);
- template<class AE>
- hermitian_adaptor &minus_assign (const matrix_expression<AE> &ae);
- template<class AT>
- hermitian_adaptor& operator *= (const AT &at);
- template<class AT>
- hermitian_adaptor& operator /= (const AT &at);
-
- // Swapping
- void swap (hermitian_adaptor &m);
- friend void swap (hermitian_adaptor &m1, hermitian_adaptor &m2);
-
- 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 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 indices.
-
- class const_iterator1:
- public container_const_reference<hermitian_adaptor>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename hermitian_adaptor::difference_type difference_type;
- typedef typename hermitian_adaptor::value_type value_type;
- typedef typename hermitian_adaptor::const_reference reference;
- typedef typename hermitian_adaptor::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const hermitian_adaptor &m, size_type it1, size_type it2);
- const_iterator1 (const iterator1 &it);
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator < (const const_iterator1 &it) const;
- };
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class iterator1:
- public container_reference<hermitian_adaptor>,
- public random_access_iterator_base<iterator1, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename hermitian_adaptor::difference_type difference_type;
- typedef typename hermitian_adaptor::value_type value_type;
- typedef typename hermitian_adaptor::reference reference;
- typedef typename hermitian_adaptor::pointer pointer;
- typedef iterator2 dual_iterator_type;
- typedef reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator1 ();
- iterator1 (hermitian_adaptor &m, size_type it1, size_type it2);
-
- // Arithmetic
- iterator1 &operator ++ ();
- iterator1 &operator -- ();
- iterator1 &operator += (difference_type n);
- iterator1 &operator -= (difference_type n);
- difference_type operator - (const iterator1 &it) const;
-
- // 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;
- bool operator < (const iterator1 &it) const;
- };
-
- iterator1 begin1 ();
- iterator1 end1 ();
-
- class const_iterator2:
- public container_const_reference<hermitian_adaptor>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename hermitian_adaptor::difference_type difference_type;
- typedef typename hermitian_adaptor::value_type value_type;
- typedef typename hermitian_adaptor::const_reference reference;
- typedef typename hermitian_adaptor::const_pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const hermitian_adaptor &m, size_type it1, size_type it2);
- const_iterator2 (const iterator2 &it);
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator < (const const_iterator2 &it) const;
- };
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- class iterator2:
- public container_reference<hermitian_adaptor>,
- public random_access_iterator_base<iterator2, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename hermitian_adaptor::difference_type difference_type;
- typedef typename hermitian_adaptor::value_type value_type;
- typedef typename hermitian_adaptor::reference reference;
- typedef typename hermitian_adaptor::pointer pointer;
- typedef iterator1 dual_iterator_type;
- typedef reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator2 ();
- iterator2 (hermitian_adaptor &m, size_type it1, size_type it2);
-
- // Arithmetic
- iterator2 &operator ++ ();
- iterator2 &operator -- ();
- iterator2 &operator += (difference_type n);
- iterator2 &operator -= (difference_type n);
- difference_type operator - (const iterator2 &it) const;
-
- // 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;
- 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
-Permission to copy, use, modify, sell and distribute this
-document is granted provided this copyright notice appears in all
-copies. This document is provided ``as is'' without express or
-implied warranty, and with no claim as to its suitability for any
-purpose.
// Hermitian matrix adaptor class
template<class M, class F>
class hermitian_adaptor:
public matrix_expression<hermitian_adaptor<M, F> > {
public:
typedef const M const_matrix_type;
typedef M matrix_type;
typedef F functor_type;
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
typedef typename M::value_type const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
typedef typename M::pointer pointer;
typedef const hermitian_adaptor<M, F> const_self_type;
typedef hermitian_adaptor<M, F> self_type;
typedef const matrix_const_reference<const_self_type> const_closure_type;
typedef matrix_reference<self_type> closure_type;
typedef typename storage_restrict_traits<typename M::storage_category,
packed_proxy_tag>::storage_category storage_category;
typedef typename F::packed_category packed_category;
typedef typename M::orientation_category orientation_category;
// Construction and destruction
hermitian_adaptor ();
hermitian_adaptor (matrix_type &data);
hermitian_adaptor (const hermitian_adaptor &m);
// Accessors
size_type size1 () const;
size_type size2 () const;
const_matrix_type &data () const;
matrix_type &data ();
// Element access
const_reference operator () (size_type i, size_type j) const;
reference operator () (size_type i, size_type j);
// Assignment
hermitian_adaptor &operator = (const hermitian_adaptor &m);
hermitian_adaptor &assign_temporary (hermitian_adaptor &m);
template<class AE>
hermitian_adaptor &operator = (const matrix_expression<AE> &ae);
template<class AE>
hermitian_adaptor &assign (const matrix_expression<AE> &ae);
template<class AE>
hermitian_adaptor& operator += (const matrix_expression<AE> &ae);
template<class AE>
hermitian_adaptor &plus_assign (const matrix_expression<AE> &ae);
template<class AE>
hermitian_adaptor& operator -= (const matrix_expression<AE> &ae);
template<class AE>
hermitian_adaptor &minus_assign (const matrix_expression<AE> &ae);
template<class AT>
hermitian_adaptor& operator *= (const AT &at);
template<class AT>
hermitian_adaptor& operator /= (const AT &at);
// Swapping
void swap (hermitian_adaptor &m);
friend void swap (hermitian_adaptor &m1, hermitian_adaptor &m2);
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 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 indices.
class const_iterator1:
public container_const_reference<hermitian_adaptor>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename hermitian_adaptor::difference_type difference_type;
typedef typename hermitian_adaptor::value_type value_type;
typedef typename hermitian_adaptor::const_reference reference;
typedef typename hermitian_adaptor::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const hermitian_adaptor &m, size_type it1, size_type it2);
const_iterator1 (const iterator1 &it);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator < (const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class iterator1:
public container_reference<hermitian_adaptor>,
public random_access_iterator_base<iterator1, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename hermitian_adaptor::difference_type difference_type;
typedef typename hermitian_adaptor::value_type value_type;
typedef typename hermitian_adaptor::reference reference;
typedef typename hermitian_adaptor::pointer pointer;
typedef iterator2 dual_iterator_type;
typedef reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
iterator1 ();
iterator1 (hermitian_adaptor &m, size_type it1, size_type it2);
// Arithmetic
iterator1 &operator ++ ();
iterator1 &operator -- ();
iterator1 &operator += (difference_type n);
iterator1 &operator -= (difference_type n);
difference_type operator - (const iterator1 &it) const;
// 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;
bool operator < (const iterator1 &it) const;
};
iterator1 begin1 ();
iterator1 end1 ();
class const_iterator2:
public container_const_reference<hermitian_adaptor>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename hermitian_adaptor::difference_type difference_type;
typedef typename hermitian_adaptor::value_type value_type;
typedef typename hermitian_adaptor::const_reference reference;
typedef typename hermitian_adaptor::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const hermitian_adaptor &m, size_type it1, size_type it2);
const_iterator2 (const iterator2 &it);
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator < (const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
class iterator2:
public container_reference<hermitian_adaptor>,
public random_access_iterator_base<iterator2, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename hermitian_adaptor::difference_type difference_type;
typedef typename hermitian_adaptor::value_type value_type;
typedef typename hermitian_adaptor::reference reference;
typedef typename hermitian_adaptor::pointer pointer;
typedef iterator1 dual_iterator_type;
typedef reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
iterator2 ();
iterator2 (hermitian_adaptor &m, size_type it1, size_type it2);
// Arithmetic
iterator2 &operator ++ ();
iterator2 &operator -- ();
iterator2 &operator += (difference_type n);
iterator2 &operator -= (difference_type n);
difference_type operator - (const iterator2 &it) const;
// 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;
bool operator <(const iterator2 &it) const;<
+br> };
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
+ Permission to copy, use, modify, sell and distribute this document is granted
+provided this copyright notice appears in all copies. This document is provided
+``as is'' without express or implied warranty, and with no claim as to its
+suitability for any purpose.
Last revised: 8/3/2002
+ diff --git a/doc/index.htm b/doc/index.htm index fa0a6674..0ac63a58 100644 --- a/doc/index.htm +++ b/doc/index.htm @@ -1,324 +1,400 @@ + - - - -
Basic Linear AlgebrauBLAS is a C++ template class library that provides BLAS level 1, 2, 3 -functionality for dense, packed and sparse matrices. The design -and implementation unify mathematical notation via operator -overloading and efficient code generation via expression -templates.
- + + +
+ Basic Linear AlgebrauBLAS is a C++ template class library that provides + BLAS + level 1, 2, 3 functionality for dense, packed and sparse matrices. The +design and implementation unify mathematical notation via operator overloading +and efficient code generation via expression templates.
+uBLAS provides templated C++ classes for dense, unit and -sparse vectors, dense, identity, triangular, banded, symmetric, -hermitian and sparse matrices. Views into vectors and matrices -can be constructed via ranges or slices and adaptor classes. The -library covers the usual basic linear algebra operations on -vectors and matrices: reductions like different norms, addition -and subtraction of vectors and matrices and multiplication with a -scalar, inner and outer products of vectors, matrix vector and -matrix matrix products and triangular solver. The glue between -containers, views and expression templated operations is a mostly -STL conforming iterator -interface.
- -Dense, packed and sparse matrix classes are being tested with the CLAPACK test suite.
- + +uBLAS provides templated C++ classes for dense, unit and sparse vectors, +dense, identity, triangular, banded, symmetric, hermitian and sparse matrices. +Views into vectors and matrices can be constructed via ranges or slices and +adaptor classes. The library covers the usual basic linear algebra operations +on vectors and matrices: reductions like different norms, addition and subtraction +of vectors and matrices and multiplication with a scalar, inner and outer +products of vectors, matrix vector and matrix matrix products and triangular +solver. The glue between containers, views and expression templated operations +is a mostly STL + conforming iterator interface.
+ +Dense, packed and sparse matrix classes are being tested with the + CLAPACK + test suite.
+Known limitations:
- -As main development platform for uBLAS we used MSVC 6.0 with -Dinkumware STL. Other compilers known to accept the library are
- + +As main development platform for uBLAS we used MSVC 6.0 with Dinkumware +STL. Other compilers known to accept the library are
+You can download the current stable release of the source code -from here. -Prerequisite is the latest stable release of the Boost libraries Configuration, -Timer and optionally SmartPointer.
- + +You can download the current stable release of the source code from + here + . Prerequisite is the latest stable release of the + Boost + libraries Configuration, Timer and optionally SmartPointer.
+You can also check out the latest version via anonymous CVS. -Here's how:
- -cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost login - (password is empty) - cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost checkout boost/boost/numeric/ublas - cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost checkout boost/libs/numeric/ublas- -
If you have gzip installed on your system, you can speed up -the transfer using
- -cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost -z9 checkout boost/boost/numeric/ublas - cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost -z9 checkout boost/libs/numeric/ublas- -
You can also view -the CVS archive. You may find the library here. -Documentation and test programs reside here.
- + +You can also check out the latest version via anonymous CVS. Here's how: +
+ +cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost login+ +
(password is empty)
cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost checkout boost/boost/numeric/ublas
cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost checkout boost/libs/numeric/ublas
If you have gzip installed on your system, you can speed up the transfer +using
+ +cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost -z9 checkout boost/boost/numeric/ublas+ +
cvs -d:pserver:anonymous@cvs.boost.sourceforge.net:/cvsroot/boost -z9 checkout boost/libs/numeric/ublas
You can also + view + the CVS archive. You may find the library + here + . Documentation and test programs reside + here + .
+uBLAS has no dedicated mailing list. Feel free to use the -mailing lists of Boost.
- + +uBLAS has no dedicated mailing list. Feel free to use the mailing lists +of Boost + .
+uBLAS initially was written by Joerg Walter and Mathias Koch. -We would like to thank all, which supported the development of -this library: David Abrahams, Ed Brey, Fernando Cacciola, Beman Dawes, -Bob Fletcher, Kresimir Fresl, Joachim Kessel, Toon Knapen, John Maddock, -Jens Maurer, Alexei Novakov, Gary Powell, Joachim Pyras, Peter Schmitteckert, -Jeremy Siek, Markus Steffl, Michael Stevens, Benedikt Weber, Martin Weiser, -Marc Zimmermann and the members of Boost
- + +uBLAS initially was written by Joerg Walter and Mathias Koch. We would +like to thank all, which supported the development of this library: David +Abrahams, Ed Brey, Fernando Cacciola, Beman Dawes, Bob Fletcher, Kresimir +Fresl, Joachim Kessel, Toon Knapen, John Maddock, Jens Maurer, Alexei Novakov, +Gary Powell, Joachim Pyras, Peter Schmitteckert, Jeremy Siek, Markus Steffl, +Michael Stevens, Benedikt Weber, Martin Weiser, Marc Zimmermann and the members +of Boost +
+Q: I'm running the uBLAS dense vector and matrix benchmarks.
-Why do I see a significant performance difference between the
-native C and library implementations?
-A: uBLAS distinguishes debug mode (size and type conformance
-checks enabled, expression templates disabled) and release mode
-(size and type conformance checks disabled, expression templates
-enabled). Please check, if the preprocessor symbol NDEBUG
-of cassert is defined. NDEBUG enables
-release mode, which in turn uses expression templates.
Q: I've written some uBLAS tests, which try to incorrectly
-assign different matrix types or overrun vector and matrix
-dimensions. Why don't I get a compile time or runtime diagnostic?
-A: uBLAS distinguishes debug mode (size and type conformance
-checks enabled, expression templates disabled) and release mode
-(size and type conformance checks disabled, expression templates
-enabled). Please check, if the preprocessor symbol NDEBUG
-of cassert is defined. NDEBUG disables
-debug mode, which is needed to get size and type conformance
-checks.
Q: I've written some uBLAS benchmarks to measure the
-performance of matrix chain multiplications like prod (A,
-prod (B, C)) and see a significant performance penalty due
-to the use of expression templates. How can I disable expression
-templates?
-A: You do not need to disable expression templates. Please try
-reintroducing temporaries using either prod (A, matrix_type
-(prod (B, C))) or prod (A, prod<matrix_type>
-(B, C)).
Q: I'm running the uBLAS dense vector and matrix benchmarks. Why do I see
+a significant performance difference between the native C and library implementations?
+ A: uBLAS distinguishes debug mode (size and type conformance checks enabled,
+expression templates disabled) and release mode (size and type conformance
+checks disabled, expression templates enabled). Please check, if the preprocessor
+symbol NDEBUG of cassert is defined. NDEBUG
+ enables release mode, which in turn uses expression templates.
Q: I've written some uBLAS tests, which try to incorrectly assign different
+matrix types or overrun vector and matrix dimensions. Why don't I get a compile
+time or runtime diagnostic?
+ A: uBLAS distinguishes debug mode (size and type conformance checks enabled,
+expression templates disabled) and release mode (size and type conformance
+checks disabled, expression templates enabled). Please check, if the preprocessor
+symbol NDEBUG of cassert is defined. NDEBUG
+ disables debug mode, which is needed to get size and type conformance checks.
Q: I've written some uBLAS benchmarks to measure the performance of matrix
+chain multiplications like prod (A, prod (B, C)) and see a significant
+performance penalty due to the use of expression templates. How can I disable
+expression templates?
+ A: You do not need to disable expression templates. Please try reintroducing
+temporaries using either prod (A, matrix_type
+ (prod (B, C))) or prod (A, prod<matrix_type
+ > (B, C)).
If you have a problem, or have found a bug, please send us a note.
- -Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this
-document is granted provided this copyright notice appears in all
-copies. This document is provided ``as is'' without express or
-implied warranty, and with no claim as to its suitability for any
-purpose.
If you have a problem, or have found a bug, please send us a + note + .
+ +Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+ Permission to copy, use, modify, sell and distribute this document is granted
+provided this copyright notice appears in all copies. This document is provided
+``as is'' without express or implied warranty, and with no claim as to its
+suitability for any purpose.
Last revised: 8/3/2002
+ diff --git a/doc/iterator.htm b/doc/iterator.htm index 0a476816..1a52f197 100644 --- a/doc/iterator.htm +++ b/doc/iterator.htm @@ -1,1251 +1,1304 @@ + - - - -
Iterator ConceptsAn Iterator is a restricted pointer-like object pointing into -a vector or matrix container.
- -
+Iterator ConceptsAn Iterator is a restricted pointer-like object pointing into a vector +or matrix container.
+ +An Indexed Bidirectional Iterator is an iterator of a -container that can be dereferenced, incremented, decremented and -carries index information.
- -Assignable, Equality Comparable, Default Constructible.
- -| Value type | -The type of the value obtained by dereferencing a - Indexed Bidirectional Iterator | -
| Container type | -The type of the container a Indexed Bidirectional - Iterator points into. | -
I |
- A type that is a model of Indexed Bidirectional - Iterator | -
T |
- The value type of I |
-
C |
- The container type of I |
-
it, itt, it1, it2 |
- Objects of type I |
-
t |
- Object of type T |
-
c |
- Object of type C |
-
A Indexed Bidirectional Iterator may be mutable, -meaning that the values referred to by objects of that type may -be modified, or constant, meaning that they may not. If an -iterator type is mutable, this implies that its value type is a -model of Assignable; the converse, though, is not necessarily -true.
- -A Indexed Bidirectional Iterator may have a singular -value, meaning that the results of most operations, including -comparison for equality, are undefined. The only operation that -is guaranteed to be supported is assigning a nonsingular iterator -to a singular iterator.
- -A Indexed Bidirectional Iterator may have a dereferenceable -value, meaning that dereferencing it yields a well-defined value. -Dereferenceable iterators are always nonsingular, but the -converse is not true.
- -An Indexed Bidirectional Iterator is past-the-end if it -points beyond the last element of a container. Past-the-end -values are nonsingular and nondereferenceable.
- -In addition to the expressions defined for Assignable, -Equality Comparable and Default Constructible, the following -expressions must be valid.
- -| Name | -Expression | -Type requirements | -Return type | -
|---|---|---|---|
| Default constructor | -I it |
- - | - |
| Dereference | -*it |
- - | Convertible to T. |
-
| Dereference assignment | -*it = t |
- I is mutable. |
- - |
| Member access | -it->m |
- T is a type for which t.m
- is defined. |
- - |
| Preincrement | -++ it |
- - | I & |
-
| Postincrement | -it ++ |
- - | I |
-
| Predecrement | --- it |
- - | I & |
-
| Postdecrement | -it -- |
- - | I |
-
| Function call | -it () |
- - | Convertible to C &. |
-
| Index | -it.index () |
- - | C::size_type |
-
Semantics of an expression is defined only where it differs -from, or is not defined in, Assignable, Equality Comparable and -Default Constructible.
- -| Name | -Expression | -Precondition | -Semantics | -Postcondition | -
|---|---|---|---|---|
| Default constructor | -I it |
- - | - | it is singular. |
-
| Dereference | -*it |
- it is dereferenceable. |
- - | - |
| Dereference assignment | -*it = t |
- Same as for *it. |
- - | *it is a copy of t. |
-
| Member access | -it->m |
- it is dereferenceable. |
- Equivalent to (*it).m |
- - |
| Preincrement | -++ it |
- it is dereferenceable. |
- it is modified to point to the next
- element. |
- it is dereferenceable or past-the-end. . - If it1 == it2, - then ++ it1 == ++ it2. |
-
| Postincrement | -it ++ |
- Same as for ++ it. |
- Equivalent to - { |
- it is dereferenceable or past-the-end. |
-
| Predecrement | --- it |
- it is dereferenceable or past-the-end. - There exists a dereferenceable iterator itt
- such that it == ++ itt. |
- it is modified to point to the previous
- element. |
- it is dereferenceable. - &it = &-- it. - If it1 == it2, - then -- it1 == -- it2. |
-
| Postdecrement | -it -- |
- Same as for -- it. |
- Equivalent to - { |
- it is dereferenceable. |
-
| Function call | -it () |
- it is dereferenceable or past-the-end. |
- If it points into container c
- then it () = c. |
- - |
| Index | -it.index () |
- it is dereferenceable or past-the-end. |
- it.index () >= 0- and - it.index () <= it ().size () |
- If it1 == it2, - then it1.index () == it2.index ().- If it1 == it2, - then it1.index () < (++ it2).index
- ().- If it1 == it2, - then it1.index () > (-- it2).index
- (). |
-
The complexity of operations on indexed bidirectional -iterators is guaranteed to be amortized constant time.
- -| Identity | -it1 == it2 if and only if &*it1
- == &*it2. |
-
| Symmetry of increment and decrement | -If it is dereferenceable, then ++
- it; --it; is a null operation. Similarly, --
- it; ++ it; is a null operation. |
-
| Relation between iterator index and container element - operator | -If it is dereferenceable, *it ==
- it () (it.index ()). |
-
sparse_vector<T>::iterator An Indexed Random Access Iterator is an iterator of a -container that can be dereferenced, moved forward, moved backward -and carries index information.
- -LessThanComparable, Indexed -Bidirectional Iterator.
- -| Value type | -The type of the value obtained by dereferencing a - Indexed Random Access Iterator | -
| Container type | -The type of the container a Indexed Random Access - Iterator points into. | -
I |
- A type that is a model of Indexed Random Access - Iterator | -
T |
- The value type of I |
-
C |
- The container type of I |
-
it, itt, it1, it2 |
- Objects of type I |
-
t |
- Object of type T |
-
n |
- Object of type C::difference_type |
-
An Indexed Random Access Iterator it1 is reachable
-from an Indexed Random Access Iterator it2 if, after
-applying operator ++ to it2 a finite
-number of times, it1 == it2.
In addition to the expressions defined for Indexed Bidirectional -Iterator, the following expressions must be valid.
- -| Name | -Expression | -Type requirements | -Return type | -
|---|---|---|---|
| Forward motion | -it += n |
- - | I & |
-
| Iterator addition | -it + n |
- - | I |
-
| Backward motion | -i -= n |
- - | I & |
-
| Iterator subtraction | -it - n |
- - | I |
-
| Difference | -it1 - it2 |
- - | C::difference_type |
-
| Element operator | -it [n] |
- - | Convertible to T. |
-
| Element assignment | -it [n] = t |
- I is mutable |
- Convertible to T. |
-
Semantics of an expression is defined only where it differs -from, or is not defined in, Indexed Bidirectional -Iterator.
- -| Name | -Expression | -Precondition | -Semantics | -Postcondition | -
|---|---|---|---|---|
| Forward motion | -it += n |
- Including it itself, there must be n
- dereferenceable or past-the-end iterators following or
- preceding it, depending on whether n
- is positive or negative. |
- If n > 0, equivalent to executing ++
- it n times. If n < 0,
- equivalent to executing -- it n
- times. If n == 0, this is a null operation. |
- it is dereferenceable or past-the-end. |
-
| Iterator addition | -it + n |
- Same as for i += n. |
- Equivalent to - { |
- Result is dereferenceable or past-the-end. | -
| Backward motion | -it -= n |
- Including it itself, there must be n
- dereferenceable or past-the-end iterators preceding or
- following it, depending on whether n
- is positive or negative. |
- Equivalent to it += (-n). |
- it is dereferenceable or past-the-end. |
-
| Iterator subtraction | -it - n |
- Same as for i -= n. |
- Equivalent to - { |
- Result is dereferenceable or past-the-end. | -
| Difference | -it1 - it2 |
- Either it1 is reachable from it2
- or it2 is reachable from it1,
- or both. |
- Returns a number n such that it1
- == it2 + n |
- - |
| Element operator | -it [n] |
- it + n exists and is dereferenceable. |
- Equivalent to *(it + n) |
- - |
| Element assignment | -i[n] = t |
- Same as for it [n]. |
- Equivalent to *(it + n) = t |
- - |
The complexity of operations on indexed random access -iterators is guaranteed to be amortized constant time.
- -| Symmetry of addition and subtraction | -If it + n is well-defined, then it
- += n; it -= n; and (it + n) - n are
- null operations. Similarly, if it - n is
- well-defined, then it -= n; it += n; and (it
- - n) + n are null operations. |
-
| Relation between distance and addition | -If it1 - it2 is well-defined, then it1
- == it2 + (it1 - it2). |
-
| Reachability and distance | -If it1 is reachable from it2,
- then it1 - it2 >= 0. |
-
vector<T>::iterator An Indexed Bidirectional Column/Row Iterator is an iterator of -a container that can be dereferenced, incremented, decremented -and carries index information.
- -Assignable, Equality Comparable, Default Constructible.
- -| Value type | -The type of the value obtained by dereferencing a - Indexed Bidirectional Column/Row Iterator | -
| Container type | -The type of the container a Indexed Bidirectional - Column/Row Iterator points into. | -
I1 |
- A type that is a model of Indexed Bidirectional - Column/Row Iterator | -
I2 |
- A type that is a model of Indexed Bidirectional - Row/Column Iterator | -
T |
- The value type of I1 and I2 |
-
C |
- The container type of I1 and I2 |
-
it1, it1t, it11, it12
- |
- Objects of type I1 |
-
it2, it2t |
- Objects of type I2 |
-
t |
- Object of type T |
-
c |
- Object of type C |
-
In addition to the expressions defined for Assignable, -Equality Comparable and Default Constructible, the following -expressions must be valid.
- -| Name | -Expression | -Type requirements | -Return type | -
|---|---|---|---|
| Default constructor | -I1 it1 |
- - | - |
| Dereference | -*it1 |
- - | Convertible to T. |
-
| Dereference assignment | -*it1 = t |
- I1 is mutable. |
- - |
| Member access | -it1->m |
- T is a type for which t.m
- is defined. |
- - |
| Preincrement | -++ it1 |
- - | I1 & |
-
| Postincrement | -it1 ++ |
- - | I1 |
-
| Predecrement | --- it1 |
- - | I1 & |
-
| Postdecrement | -it1 -- |
- - | I1 |
-
| Function call | -it1 () |
- - | Convertible to C &. |
-
| Row Index | -it1.index1 () |
- - | C::size_type |
-
| Column Index | -it1.index2 () |
- - | C::size_type |
-
| Row/Column Begin | -it1.begin () |
- - | I2 |
-
| Row/Column End | -it1.end () |
- - | I2 |
-
| Reverse Row/Column Begin | -it1.rbegin () |
- - | reverse_iterator<I2> |
-
| Reverse Row/Column End | -it1.rend () |
- - | reverse_iterator<I2> |
-
Semantics of an expression is defined only where it differs -from, or is not defined in, Assignable, Equality Comparable and -Default Constructible.
- -| Name | -Expression | -Precondition | -Semantics | -Postcondition | -
|---|---|---|---|---|
| Default constructor | -I1 it1 |
- - | - | it1 is singular. |
-
| Dereference | -*it1 |
- it1 is dereferenceable. |
- - | - |
| Dereference assignment | -*it1 = t |
- Same as for *it1. |
- - | *it1 is a copy of t. |
-
| Member access | -it1->m |
- it1 is dereferenceable. |
- Equivalent to (*it1).m |
- - |
| Preincrement | -++ it1 |
- it1 is dereferenceable. |
- it1 is modified to point to the next
- element. |
- it1 is dereferenceable or past-the-end. . - If it11 == it12, - then ++ it11 == ++ it12. |
-
| Postincrement | -it1 ++ |
- Same as for ++ it1. |
- Equivalent to - { |
- it1 is dereferenceable or past-the-end. |
-
| Predecrement | --- it1 |
- it1 is dereferenceable or past-the-end. - There exists a dereferenceable iterator it1t
- such that it1 == ++ it1t. |
- it1 is modified to point to the previous
- element. |
- it1 is dereferenceable. - &it1 = &-- it1. - If it11 == it12, - then -- it11 == -- it12. |
-
| Postdecrement | -it1 -- |
- Same as for -- it1. |
- Equivalent to - { |
- it1 is dereferenceable. |
-
| Function call | -it1 () |
- it1 is dereferenceable or past-the-end. |
- If it1 points into container c
- then it1 () = c. |
- - |
| Row Index | -it1.index1 () |
- it1 is dereferenceable or past-the-end. |
- it1.index1 () >= 0 and- it1.index1 () <= it () .size1 () |
- If it11 == it12, - then it11.index1 () == it12.index1 ().- If it11, it12 are Indexed
- Bidirectional Row Iterators with it11 == it12,
- - then it11.index1 () < (++ it12).index1
- ().- If it11, it12 are Indexed
- Bidirectional Row Iterators with it11 == it12,
- - then it11.index1 () > (-- it12).index1
- (). |
-
| Column Index | -it1.index2 () |
- it1 is dereferenceable or past-the-end. |
- it1.index2 () >= 0 and- it1.index2 () <= it () .size2 () |
- If it11 == it12, - then it11.index2 () == it12.index2 ().- If it11, it12 are Indexed
- Bidirectional Column Iterators with it11 == it12,
- - then it11.index2 () < (++ it12).index2
- ().- If it11, it12 are Indexed
- Bidirectional Column Iterators with it11 == it12,
- - then it11.index2 () > (-- it12).index2
- (). |
-
| Row/Column Begin | -it1.begin () |
- it1 is dereferenceable. |
- If it1 is a Indexed Bidirectional Column
- Iterator, - then it2 = it1.begin () is a Indexed
- Bidirectional Row Iterator - with it2.index1 () == it1.index1 ().If |
- - |
| Row/Column End | -it1.end () |
- it1 is dereferenceable. |
- If it1 is a Indexed Bidirectional Column
- Iterator, - then it2 = it1.end () is a Indexed
- Bidirectional Row Iterator - with it2.index1 () == it1.index1 ().If |
- - |
| Reverse Row/Column Begin | -it1.rbegin () |
- it1 is dereferenceable. |
- Equivalent to reverse_iterator<I2>
- (it1.end ()). |
- - |
| Reverse Row/Column End | -it1.rend () |
- it1 is dereferenceable. |
- Equivalent to reverse_iterator<I2>
- (it1.begin ()). |
- - |
The complexity of operations on indexed bidirectional -column/row iterators is guaranteed to be logarithmic depending on -the size of the container. The complexity of one iterator -(depending on the storage layout) can be lifted to be amortized -constant time. The complexity of the other iterator (depending on -the storage layout and the container) can be lifted to be -amortized constant time for the first row/first column -respectively.
- -| Identity | -it11 == it12 if and only if &*it11
- == &*it12. |
-
| Symmetry of increment and decrement | -If it1 is dereferenceable, then ++
- it1; --it1; is a null operation. Similarly, --
- it1; ++ it1; is a null operation. |
-
| Relation between iterator index and container element - operator | -If it1 is dereferenceable, *it1 ==
- it1 () (it1.index1 (), it2.index2 ()) |
-
| Relation between iterator column/row begin and - iterator index | -If it1 is a Indexed Bidirectional Column
- Iterator and it2 = it1.begin () then
- it2.index2 () < it2t.index2 () for all it2t
- with it2t () == it2 () and it2t
- ().index1 () == it2 ().index1 ().If |
-
| Relation between iterator column/row end and iterator - index | -If it1 is a Indexed Bidirectional Column
- Iterator and it2 = it1.end () then
- it2.index2 () > it2t.index2 () for all it2t
- with it2t () == it2 () and it2t
- ().index1 () == it2 ().index1 ().If |
-
sparse_matrix<T>::iterator1sparse_matrix<T>::iterator2An Indexed Random Access Column/Row Iterator is an iterator of -a container that can be dereferenced, incremented, decremented -and carries index information.
- -Indexed -Bidirectional Column/Row Iterator.
- -| Value type | -The type of the value obtained by dereferencing a - Indexed Random Access Column/Row Iterator | -
| Container type | -The type of the container a Indexed Random Access - Column/Row Iterator points into. | -
I |
- A type that is a model of Indexed Random Access - Column/Row Iterator | -
T |
- The value type of I |
-
C |
- The container type of I |
-
it, itt, it1, it2 |
- Objects of type I |
-
t |
- Object of type T |
-
c |
- Object of type C |
-
In addition to the expressions defined for Indexed Bidirectional -Column/Row Iterator, the following expressions must be valid. + +
An Indexed Bidirectional Iterator is an iterator of a container that can +be dereferenced, incremented, decremented and carries index information.
- + +Assignable, Equality Comparable, Default Constructible.
+ +| Name | -Expression | -Type requirements | -Return type | -
|---|---|---|---|
| Forward motion | -it += n |
- - | I & |
-
| Iterator addition | -it + n |
- - | I |
-
| Backward motion | -i -= n |
- - | I & |
-
| Iterator subtraction | -it - n |
- - | I |
-
| Difference | -it1 - it2 |
- - | C::difference_type |
-
| Element operator | -it [n] |
- - | Convertible to T. |
-
| Element assignment | -it [n] = t |
- I is mutable |
- Convertible to T. |
- Value type | +The type of the value obtained by dereferencing a Indexed +Bidirectional Iterator | + +
| Container type | +The type of the container a Indexed Bidirectional Iterator +points into. | +
I |
+ A type that is a model of Indexed Bidirectional Iterator + | +
T |
+ The value type of I |
+
C |
+ The container type of I |
+
it, itt, it1, it2 |
+ Objects of type I |
+
t |
+ Object of type T |
+
c |
+ Object of type C |
+
A Indexed Bidirectional Iterator may be mutable, meaning that the +values referred to by objects of that type may be modified, or constant +, meaning that they may not. If an iterator type is mutable, this implies +that its value type is a model of Assignable; the converse, though, is not +necessarily true.
+ +A Indexed Bidirectional Iterator may have a singular value, meaning +that the results of most operations, including comparison for equality, are +undefined. The only operation that is guaranteed to be supported is assigning +a nonsingular iterator to a singular iterator.
+ +A Indexed Bidirectional Iterator may have a dereferenceable value, +meaning that dereferencing it yields a well-defined value. Dereferenceable +iterators are always nonsingular, but the converse is not true.
+ +An Indexed Bidirectional Iterator is past-the-end if it points +beyond the last element of a container. Past-the-end values are nonsingular +and nondereferenceable.
+ +In addition to the expressions defined for Assignable, Equality Comparable +and Default Constructible, the following expressions must be valid.
+ +| Name | +Expression | +Type requirements | +Return type | +
|---|---|---|---|
| Default constructor | +I it |
+ + | + |
| Dereference | +*it |
+ + | Convertible to T. |
+
| Dereference assignment | +*it = t |
+ I is mutable. |
+ + |
| Member access | +it->m |
+ T is a type for which t.m
+is defined. |
+ + |
| Preincrement | +++ it |
+ + | I & |
+
| Postincrement | +it ++ |
+ + | I |
+
| Predecrement | +-- it |
+ + | I & |
+
| Postdecrement | +it -- |
+ + | I |
+
| Function call | +it () |
+ + | Convertible to C &. |
+
| Index | +it.index () |
+ + | C::size_type |
+
Semantics of an expression is defined only where it differs -from, or is not defined in, Indexed Bidirectional -Column/Row Iterator.
- + +Semantics of an expression is defined only where it differs from, or is +not defined in, Assignable, Equality Comparable and Default Constructible.
+| Name | -Expression | -Precondition | -Semantics | -Postcondition | -
|---|---|---|---|---|
| Forward motion | -it += n |
- Including it itself, there must be n
- dereferenceable or past-the-end iterators following or
- preceding it, depending on whether n
- is positive or negative. |
- If n > 0, equivalent to executing ++
- it n times. If n < 0,
- equivalent to executing -- it n
- times. If n == 0, this is a null operation. |
- it is dereferenceable or past-the-end. |
-
| Iterator addition | -it + n |
- Same as for i += n. |
- Equivalent to - { |
- Result is dereferenceable or past-the-end. | -
| Backward motion | -it -= n |
- Including it itself, there must be n
- dereferenceable or past-the-end iterators preceding or
- following it, depending on whether n
- is positive or negative. |
- Equivalent to it += (-n). |
- it is dereferenceable or past-the-end. |
-
| Iterator subtraction | -it - n |
- Same as for i -= n. |
- Equivalent to - { |
- Result is dereferenceable or past-the-end. | -
| Difference | -it1 - it2 |
- Either it1 is reachable from it2
- or it2 is reachable from it1,
- or both. |
- Returns a number n such that it1
- == it2 + n |
- - |
| Element operator | -it [n] |
- it + n exists and is dereferenceable. |
- Equivalent to *(it + n) |
- - |
| Element assignment | -i[n] = t |
- Same as for it [n]. |
- Equivalent to *(it + n) = t |
- - | Name | +Expression | +Precondition | +Semantics | +Postcondition | + +
| Default constructor | +I it |
+ + | + | it is singular. |
+
| Dereference | +*it |
+ it is dereferenceable. |
+ + | + |
| Dereference assignment | +*it = t |
+ Same as for *it. |
+ + | *it is a copy of t. |
+
| Member access | +it->m |
+ it is dereferenceable. |
+ Equivalent to (*it).m |
+ + |
| Preincrement | +++ it |
+ it is dereferenceable. |
+ it is modified to point to the next element.
+ |
+ it is dereferenceable or past-the-end. . + If it1 == it2, + then ++ it1 == ++ it2. |
+
| Postincrement | +it ++ |
+ Same as for ++ it. |
+ Equivalent to + { |
+ it is dereferenceable or past-the-end. |
+
| Predecrement | +-- it |
+ it is dereferenceable or past-the-end. + There exists a dereferenceable iterator itt
+ such that it == ++ itt. |
+ it is modified to point to the previous
+ element. |
+ it is dereferenceable. + &it = &-- it. + If it1 == it2, + then -- it1 == -- it2. |
+
| Postdecrement | +it -- |
+ Same as for -- it. |
+ Equivalent to + { |
+ it is dereferenceable. |
+
| Function call | +it () |
+ it is dereferenceable or past-the-end. |
+ If it points into container c
+ then it () = c. |
+ + |
| Index | +it.index () |
+ it is dereferenceable or past-the-end. |
+ it.index () >= 0+ and + it.index () <= it ().size () |
+ If it1 == it2, + then it1.index () == it2.index ().+ If it1 == it2, + then it1.index () < (++ it2).index
+ ().+ If it1 == it2, + then it1.index () > (-- it2).index
+ (). |
+
The complexity of operations on indexed random access -Column/Row iterators is guaranteed to be amortized constant time.
- + +The complexity of operations on indexed bidirectional iterators is guaranteed +to be amortized constant time.
+| Symmetry of addition and subtraction | -If it + n is well-defined, then it
- += n; it -= n; and (it + n) - n are
- null operations. Similarly, if it - n is
- well-defined, then it -= n; it += n; and (it
- - n) + n are null operations. |
-
| Relation between distance and addition | -If it1 - it2 is well-defined, then it1
- == it2 + (it1 - it2). |
-
| Reachability and distance | -If it1 is reachable from it2,
- then it1 - it2 >= 0. |
- Identity | +it1 == it2 if and only if &*it1
+ == &*it2. |
+
+
| Symmetry of increment and decrement | +If it is dereferenceable, then ++
+ it; --it; is a null operation. Similarly, -- it; ++
+it; is a null operation. |
+
| Relation between iterator index and container element + operator | +If it is dereferenceable, *it ==
+it () (it.index ()). |
+
matrix<T>::iterator1matrix<T>::iterator2sparse_vector<T>::iterator Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this
-document is granted provided this copyright notice appears in all
-copies. This document is provided ``as is'' without express or
-implied warranty, and with no claim as to its suitability for any
-purpose.
An Indexed Random Access Iterator is an iterator of a container that can +be dereferenced, moved forward, moved backward and carries index information. +
+ +LessThanComparable, Indexed Bidirectional +Iterator +.
+ +| Value type | +The type of the value obtained by dereferencing a Indexed +Random Access Iterator | +
| Container type | +The type of the container a Indexed Random Access Iterator +points into. | +
I |
+ A type that is a model of Indexed Random Access Iterator + | +
T |
+ The value type of I |
+
C |
+ The container type of I |
+
it, itt, it1, it2 |
+ Objects of type I |
+
t |
+ Object of type T |
+
n |
+ Object of type C::difference_type |
+
An Indexed Random Access Iterator it1 is reachable
+ from an Indexed Random Access Iterator it2 if, after applying
+operator ++ to it2 a finite number of times,
+it1 == it2.
In addition to the expressions defined for +Indexed Bidirectional Iterator +, the following expressions must be valid.
+ +| Name | +Expression | +Type requirements | +Return type | +
|---|---|---|---|
| Forward motion | +it += n |
+ + | I & |
+
| Iterator addition | +it + n |
+ + | I |
+
| Backward motion | +i -= n |
+ + | I & |
+
| Iterator subtraction | +it - n |
+ + | I |
+
| Difference | +it1 - it2 |
+ + | C::difference_type |
+
| Element operator | +it [n] |
+ + | Convertible to T. |
+
| Element assignment | +it [n] = t |
+ I is mutable |
+ Convertible to T. |
+
Semantics of an expression is defined only where it differs from, or is +not defined in, Indexed Bidirectional +Iterator +.
+ +| Name | +Expression | +Precondition | +Semantics | +Postcondition | +
|---|---|---|---|---|
| Forward motion | +it += n |
+ Including it itself, there must be n
+ dereferenceable or past-the-end iterators following or preceding
+ it, depending on whether n is positive
+or negative. |
+ If n > 0, equivalent to executing ++
+ it n times. If n < 0,
+equivalent to executing -- it n times.
+If n == 0, this is a null operation. |
+ it is dereferenceable or past-the-end. |
+
| Iterator addition | +it + n |
+ Same as for i += n. |
+ Equivalent to + { |
+ Result is dereferenceable or past-the-end. | +
| Backward motion | +it -= n |
+ Including it itself, there must be n
+ dereferenceable or past-the-end iterators preceding or following
+ it, depending on whether n is positive
+or negative. |
+ Equivalent to it += (-n). |
+ it is dereferenceable or past-the-end. |
+
| Iterator subtraction | +it - n |
+ Same as for i -= n. |
+ Equivalent to + { |
+ Result is dereferenceable or past-the-end. | +
| Difference | +it1 - it2 |
+ Either it1 is reachable from it2
+ or it2 is reachable from it1, or
+both. |
+ Returns a number n such that it1
+== it2 + n |
+ + |
| Element operator | +it [n] |
+ it + n exists and is dereferenceable. |
+ Equivalent to *(it + n) |
+ + |
| Element assignment | +i[n] = t |
+ Same as for it [n]. |
+ Equivalent to *(it + n) = t |
+ + |
The complexity of operations on indexed random access iterators is guaranteed +to be amortized constant time.
+ +| Symmetry of addition and subtraction | +If it + n is well-defined, then it
+ += n; it -= n; and (it + n) - n are null operations.
+Similarly, if it - n is well-defined, then it
+-= n; it += n; and (it - n) + n are null operations.
+ |
+
| Relation between distance and addition | +If it1 - it2 is well-defined, then it1
+ == it2 + (it1 - it2). |
+
| Reachability and distance | +If it1 is reachable from it2,
+ then it1 - it2 >= 0. |
+
vector<T>::iterator An Indexed Bidirectional Column/Row Iterator is an iterator of a container +that can be dereferenced, incremented, decremented and carries index information. +
+ +Assignable, Equality Comparable, Default Constructible.
+ +| Value type | +The type of the value obtained by dereferencing a Indexed +Bidirectional Column/Row Iterator | +
| Container type | +The type of the container a Indexed Bidirectional Column/Row +Iterator points into. | +
I1 |
+ A type that is a model of Indexed Bidirectional Column/Row +Iterator | +
I2 |
+ A type that is a model of Indexed Bidirectional Row/Column +Iterator | +
T |
+ The value type of I1 and I2 |
+
C |
+ The container type of I1 and I2 |
+
it1, it1t, it11, it12
+ |
+ Objects of type I1 |
+
it2, it2t |
+ Objects of type I2 |
+
t |
+ Object of type T |
+
c |
+ Object of type C |
+
In addition to the expressions defined for Assignable, Equality Comparable +and Default Constructible, the following expressions must be valid.
+ +| Name | +Expression | +Type requirements | +Return type | +
|---|---|---|---|
| Default constructor | +I1 it1 |
+ + | + |
| Dereference | +*it1 |
+ + | Convertible to T. |
+
| Dereference assignment | +*it1 = t |
+ I1 is mutable. |
+ + |
| Member access | +it1->m |
+ T is a type for which t.m
+is defined. |
+ + |
| Preincrement | +++ it1 |
+ + | I1 & |
+
| Postincrement | +it1 ++ |
+ + | I1 |
+
| Predecrement | +-- it1 |
+ + | I1 & |
+
| Postdecrement | +it1 -- |
+ + | I1 |
+
| Function call | +it1 () |
+ + | Convertible to C &. |
+
| Row Index | +it1.index1 () |
+ + | C::size_type |
+
| Column Index | +it1.index2 () |
+ + | C::size_type |
+
| Row/Column Begin | +it1.begin () |
+ + | I2 |
+
| Row/Column End | +it1.end () |
+ + | I2 |
+
| Reverse Row/Column Begin | +it1.rbegin () |
+ + | reverse_iterator<I2> |
+
| Reverse Row/Column End | +it1.rend () |
+ + | reverse_iterator<I2> |
+
Semantics of an expression is defined only where it differs from, or is +not defined in, Assignable, Equality Comparable and Default Constructible.
+ +| Name | +Expression | +Precondition | +Semantics | +Postcondition | +
|---|---|---|---|---|
| Default constructor | +I1 it1 |
+ + | + | it1 is singular. |
+
| Dereference | +*it1 |
+ it1 is dereferenceable. |
+ + | + |
| Dereference assignment | +*it1 = t |
+ Same as for *it1. |
+ + | *it1 is a copy of t. |
+
| Member access | +it1->m |
+ it1 is dereferenceable. |
+ Equivalent to (*it1).m |
+ + |
| Preincrement | +++ it1 |
+ it1 is dereferenceable. |
+ it1 is modified to point to the next element.
+ |
+ it1 is dereferenceable or past-the-end. . + If it11 == it12, + then ++ it11 == ++ it12. |
+
| Postincrement | +it1 ++ |
+ Same as for ++ it1. |
+ Equivalent to + { |
+ it1 is dereferenceable or past-the-end. |
+
| Predecrement | +-- it1 |
+ it1 is dereferenceable or past-the-end. + There exists a dereferenceable iterator it1t
+ such that it1 == ++ it1t. |
+ it1 is modified to point to the previous
+ element. |
+ it1 is dereferenceable. + &it1 = &-- it1. + If it11 == it12, + then -- it11 == -- it12. |
+
| Postdecrement | +it1 -- |
+ Same as for -- it1. |
+ Equivalent to + { |
+ it1 is dereferenceable. |
+
| Function call | +it1 () |
+ it1 is dereferenceable or past-the-end. |
+ If it1 points into container c
+ then it1 () = c. |
+ + |
| Row Index | +it1.index1 () |
+ it1 is dereferenceable or past-the-end. |
+ it1.index1 () >= 0 and+ it1.index1 () <= it () .size1 () |
+ If it11 == it12, + then it11.index1 () == it12.index1 ().+ If it11, it12 are Indexed Bidirectional
+Row Iterators with it11 == it12, + then it11.index1 () < (++ it12).index1
+ ().+ If it11, it12 are Indexed Bidirectional
+Row Iterators with it11 == it12, + then it11.index1 () > (-- it12).index1
+ (). |
+
| Column Index | +it1.index2 () |
+ it1 is dereferenceable or past-the-end. |
+ it1.index2 () >= 0 and+ it1.index2 () <= it () .size2 () |
+ If it11 == it12, + then it11.index2 () == it12.index2 ().+ If it11, it12 are Indexed Bidirectional
+Column Iterators with it11 == it12, + then it11.index2 () < (++ it12).index2
+ ().+ If it11, it12 are Indexed Bidirectional
+Column Iterators with it11 == it12, + then it11.index2 () > (-- it12).index2
+ (). |
+
| Row/Column Begin | +it1.begin () |
+ it1 is dereferenceable. |
+ If it1 is a Indexed Bidirectional Column
+ Iterator, + then it2 = it1.begin () is a Indexed Bidirectional
+Row Iterator + with it2.index1 () == it1.index1 ().
+ If |
+ + |
| Row/Column End | +it1.end () |
+ it1 is dereferenceable. |
+ If it1 is a Indexed Bidirectional Column
+ Iterator, + then it2 = it1.end () is a Indexed Bidirectional
+Row Iterator + with it2.index1 () == it1.index1 ().
+ If |
+ + |
| Reverse Row/Column Begin | +it1.rbegin () |
+ it1 is dereferenceable. |
+ Equivalent to reverse_iterator<I2> (it1.end
+()). |
+ + |
| Reverse Row/Column End | +it1.rend () |
+ it1 is dereferenceable. |
+ Equivalent to reverse_iterator<I2> (it1.begin
+()). |
+ + |
The complexity of operations on indexed bidirectional column/row iterators +is guaranteed to be logarithmic depending on the size of the container. The +complexity of one iterator (depending on the storage layout) can be lifted +to be amortized constant time. The complexity of the other iterator (depending +on the storage layout and the container) can be lifted to be amortized constant +time for the first row/first column respectively.
+ +| Identity | +it11 == it12 if and only if &*it11
+ == &*it12. |
+
| Symmetry of increment and decrement | +If it1 is dereferenceable, then ++
+ it1; --it1; is a null operation. Similarly, -- it1;
+++ it1; is a null operation. |
+
| Relation between iterator index and container element + operator | +If it1 is dereferenceable, *it1 ==
+ it1 () (it1.index1 (), it2.index2 ()) |
+
| Relation between iterator column/row begin and iterator +index | +If it1 is a Indexed Bidirectional Column
+ Iterator and it2 = it1.begin () then it2.index2
+() < it2t.index2 () for all it2t with
+it2t () == it2 () and it2t ().index1 () == it2 ().index1
+().
+ If |
+
| Relation between iterator column/row end and iterator + index | +If it1 is a Indexed Bidirectional Column
+ Iterator and it2 = it1.end () then it2.index2
+() > it2t.index2 () for all it2t with
+it2t () == it2 () and it2t ().index1 () == it2 ().index1
+().
+ If |
+
sparse_matrix<T>::iterator1sparse_matrix<T>::iterator2An Indexed Random Access Column/Row Iterator is an iterator of a container +that can be dereferenced, incremented, decremented and carries index information. +
+ +Indexed Bidirectional Column/Row +Iterator +.
+ +| Value type | +The type of the value obtained by dereferencing a Indexed +Random Access Column/Row Iterator | +
| Container type | +The type of the container a Indexed Random Access Column/Row +Iterator points into. | +
I |
+ A type that is a model of Indexed Random Access Column/Row +Iterator | +
T |
+ The value type of I |
+
C |
+ The container type of I |
+
it, itt, it1, it2 |
+ Objects of type I |
+
t |
+ Object of type T |
+
c |
+ Object of type C |
+
In addition to the expressions defined for +Indexed Bidirectional Column/Row Iterator +, the following expressions must be valid.
+ +| Name | +Expression | +Type requirements | +Return type | +
|---|---|---|---|
| Forward motion | +it += n |
+ + | I & |
+
| Iterator addition | +it + n |
+ + | I |
+
| Backward motion | +i -= n |
+ + | I & |
+
| Iterator subtraction | +it - n |
+ + | I |
+
| Difference | +it1 - it2 |
+ + | C::difference_type |
+
| Element operator | +it [n] |
+ + | Convertible to T. |
+
| Element assignment | +it [n] = t |
+ I is mutable |
+ Convertible to T. |
+
Semantics of an expression is defined only where it differs from, or is +not defined in, Indexed Bidirectional +Column/Row Iterator +.
+ +| Name | +Expression | +Precondition | +Semantics | +Postcondition | +
|---|---|---|---|---|
| Forward motion | +it += n |
+ Including it itself, there must be n
+ dereferenceable or past-the-end iterators following or preceding
+ it, depending on whether n is positive
+or negative. |
+ If n > 0, equivalent to executing ++
+ it n times. If n < 0,
+equivalent to executing -- it n times.
+If n == 0, this is a null operation. |
+ it is dereferenceable or past-the-end. |
+
| Iterator addition | +it + n |
+ Same as for i += n. |
+ Equivalent to + { |
+ Result is dereferenceable or past-the-end. | +
| Backward motion | +it -= n |
+ Including it itself, there must be n
+ dereferenceable or past-the-end iterators preceding or following
+ it, depending on whether n is positive
+or negative. |
+ Equivalent to it += (-n). |
+ it is dereferenceable or past-the-end. |
+
| Iterator subtraction | +it - n |
+ Same as for i -= n. |
+ Equivalent to + { |
+ Result is dereferenceable or past-the-end. | +
| Difference | +it1 - it2 |
+ Either it1 is reachable from it2
+ or it2 is reachable from it1, or
+both. |
+ Returns a number n such that it1
+== it2 + n |
+ + |
| Element operator | +it [n] |
+ it + n exists and is dereferenceable. |
+ Equivalent to *(it + n) |
+ + |
| Element assignment | +i[n] = t |
+ Same as for it [n]. |
+ Equivalent to *(it + n) = t |
+ + |
The complexity of operations on indexed random access Column/Row iterators +is guaranteed to be amortized constant time.
+ +| Symmetry of addition and subtraction | +If it + n is well-defined, then it
+ += n; it -= n; and (it + n) - n are null operations.
+Similarly, if it - n is well-defined, then it
+-= n; it += n; and (it - n) + n are null operations.
+ |
+
| Relation between distance and addition | +If it1 - it2 is well-defined, then it1
+ == it2 + (it1 - it2). |
+
| Reachability and distance | +If it1 is reachable from it2,
+ then it1 - it2 >= 0. |
+
matrix<T>::iterator1matrix<T>::iterator2Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+ Permission to copy, use, modify, sell and distribute this document is granted
+provided this copyright notice appears in all copies. This document is provided
+``as is'' without express or implied warranty, and with no claim as to its
+suitability for any purpose.
Last revised: 8/3/2002
+ diff --git a/doc/matrix.htm b/doc/matrix.htm index e8df6ef8..6450dc83 100644 --- a/doc/matrix.htm +++ b/doc/matrix.htm @@ -1,1242 +1,630 @@ + - - - -
Matrix
+MatrixThe templated class matrix<T, F, A> is the
-base container adaptor for dense matrices. For a (m x n)-dimensional
-matrix and 0 <= i < m, 0 <= j < n
-every 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.
The templated class matrix<T, F, A> is the base container
+adaptor for dense matrices. For a (m x n)-dimensional matrix and
+0 <= i < m, 0 <= j < n every element m
+i, 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.
int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (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;
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned j = 0; j < m.size2 (); ++ j)
m (i, j) = 3 * i + j;
std::cout << m << std::endl;
}
Defined in the header matrix.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
T |
- The type of object stored in the matrix. | -- |
F |
- Functor describing the storage organization. [1] | -row_major |
-
A |
- The type of the adapted array. [2] | -unbounded_array<T> |
- Parameter | +Description | +Default | + +
T |
+ The type of object stored in the matrix. | ++ |
F |
+ Functor describing the storage organization. +[1] + | +row_major |
+
A |
+ The type of the adapted array. [2] + | +unbounded_array<T> |
+
Matrix +.
+None, except for those imposed by the requirements of Matrix.
- + +None, except for those imposed by the requirements of +Matrix +.
+matrix_expression<matrix<T, F, A> >
| Member | -Description | -
|---|---|
matrix () |
- Allocates an uninitialized matrix that
- holds zero rows of zero elements. |
-
matrix (size_type size1, size_type size2) |
- Allocates an uninitialized matrix that
- holds size1 rows of size2
- elements. |
-
matrix (const matrix &m) |
- The copy constructor. | -
template<class AE> |
- The extended copy constructor. | -
void resize (size_type size1, size_type size2) |
- Reallocates a matrix to hold size1
- rows of size2 elements. The content of the matrix
- is not 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 a const reference 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. |
-
matrix &operator = (const matrix &m) |
- The assignment operator. | -
matrix &assign_temporary (matrix &m) |
- Assigns a temporary. May change the matrix m. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a matrix expression to the 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 matrix. | -
template<class AE> |
- Adds a matrix expression to the 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 matrix. | -
template<class AE> |
- Subtracts a matrix expression from the matrix. Left - and right hand side of the assignment should be - independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the matrix - with a scalar. | -
template<class AT> |
- A computed assignment operator. Divides the matrix - through a scalar. | -
void swap (matrix &m) |
- Swaps the contents of the 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 matrix. | -
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the matrix. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the matrix. |
-
iterator1 begin1 () |
- Returns a iterator1 pointing to the
- beginning of the matrix. |
-
iterator1 end1 () |
- Returns a iterator1 pointing to the end
- of the matrix. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the matrix. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the matrix. |
-
iterator2 begin2 () |
- Returns a iterator2 pointing to the
- beginning of the matrix. |
-
iterator2 end2 () |
- Returns a iterator2 pointing to the end
- of the matrix. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed matrix.
- |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed matrix. |
-
reverse_iterator1 rbegin1 () |
- Returns a reverse_iterator1 pointing to
- the beginning of the reversed matrix. |
-
reverse_iterator1 rend1 () |
- Returns a reverse_iterator1 pointing to
- the end of the reversed matrix. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed matrix.
- |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed matrix. |
-
reverse_iterator2 rbegin2 () |
- Returns a reverse_iterator2 pointing to
- the beginning of the reversed matrix. |
-
reverse_iterator2 rend2 () |
- Returns a reverse_iterator2 pointing to
- the end of the reversed matrix. |
- Member | +Description | + +
matrix () |
+ Allocates an uninitialized matrix that
+holds zero rows of zero elements. |
+
matrix (size_type size1, size_type size2) |
+ Allocates an uninitialized matrix that
+holds size1 rows of size2 elements. |
+
matrix (const matrix &m) |
+ The copy constructor. | +
template<class AE> |
+ The extended copy constructor. | +
void resize (size_type size1, size_type size2) |
+ Reallocates a matrix to hold size1
+ rows of size2 elements. The content of the matrix
+ is not 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 a const reference 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. |
+
matrix &operator = (const matrix &m) |
+ The assignment operator. | +
matrix &assign_temporary (matrix &m) |
+ Assigns a temporary. May change the matrix m. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a matrix expression to the 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 matrix. | +
template<class AE> |
+ Adds a matrix expression to the 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 matrix. | +
template<class AE> |
+ Subtracts a matrix expression from the matrix. Left +and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the matrix + with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the matrix through +a scalar. | +
void swap (matrix &m) |
+ Swaps the contents of the 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 matrix. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to the
+beginning of the matrix. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to the
+end of the matrix. |
+
iterator1 begin1 () |
+ Returns a iterator1 pointing to the beginning
+of the matrix. |
+
iterator1 end1 () |
+ Returns a iterator1 pointing to the end
+ of the matrix. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to the
+beginning of the matrix. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to the
+end of the matrix. |
+
iterator2 begin2 () |
+ Returns a iterator2 pointing to the beginning
+of the matrix. |
+
iterator2 end2 () |
+ Returns a iterator2 pointing to the end
+ of the matrix. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed matrix. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed matrix. |
+
reverse_iterator1 rbegin1 () |
+ Returns a reverse_iterator1 pointing to
+ the beginning of the reversed matrix. |
+
reverse_iterator1 rend1 () |
+ Returns a reverse_iterator1 pointing to
+ the end of the reversed matrix. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed matrix. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed matrix. |
+
reverse_iterator2 rbegin2 () |
+ Returns a reverse_iterator2 pointing to
+ the beginning of the reversed matrix. |
+
reverse_iterator2 rend2 () |
+ Returns a reverse_iterator2 pointing to
+ the end of the reversed matrix. |
+
[1] Supported parameters for the
-storage organization are row_major and column_major.
[2] Supported parameters for the
-adapted array are unbounded_array<T>, bounded_array<T>
-and std::vector<T>.
[1]
+ Supported parameters for the storage organization are row_major
+ and column_major.
[2]
+ Supported parameters for the adapted array are unbounded_array<T>
+, bounded_array<T> and std::vector<T>
+.
// Array based matrix class
- template<class T, class F, class A>
- class matrix:
- public matrix_expression<matrix<T, F, A> > {
- 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 A array_type;
- typedef const A const_array_type;
- typedef const matrix<T, F, A> const_self_type;
- typedef matrix<T, F, A> 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 dense_tag storage_category;
- typedef typename F::orientation_category orientation_category;
-
- // Construction and destruction
- matrix ();
- matrix (size_type size1, size_type size2);
- matrix (const matrix &m);
- template<class AE>
- matrix (const matrix_expression<AE> &ae);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- const_array_type &data () const;
- array_type &data ();
-
- // Resizing
- void resize (size_type size1, size_type size2);
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
- reference operator () (size_type i, size_type j);
-
- // Assignment
- matrix &operator = (const matrix &m);
- matrix &assign_temporary (matrix &m);
- template<class AE>
- matrix &operator = (const matrix_expression<AE> &ae);
- template<class AE>
- matrix &reset (const matrix_expression<AE> &ae);
- template<class AE>
- matrix &assign (const matrix_expression<AE> &ae);
- template<class AE>
- matrix& operator += (const matrix_expression<AE> &ae);
- template<class AE>
- matrix &plus_assign (const matrix_expression<AE> &ae);
- template<class AE>
- matrix& operator -= (const matrix_expression<AE> &ae);
- template<class AE>
- matrix &minus_assign (const matrix_expression<AE> &ae);
- template<class AT>
- matrix& operator *= (const AT &at);
- template<class AT>
- matrix& operator /= (const AT &at);
-
- // Swapping
- void swap (matrix &m);
- friend void swap (matrix &m1, 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<matrix>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef dense_random_access_iterator_tag iterator_category;
- typedef typename matrix::difference_type difference_type;
- typedef typename matrix::value_type value_type;
- typedef typename matrix::const_reference reference;
- typedef typename matrix::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const matrix &m, const const_iterator_type &it);
- const_iterator1 (const iterator1 &it);
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator <(const const_iterator1 &it) const;
- };
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class iterator1:
- public container_reference<matrix>,
- public random_access_iterator_base<iterator1, value_type> {
- public:
- typedef dense_random_access_iterator_tag iterator_category;
- typedef typename matrix::difference_type difference_type;
- typedef typename matrix::value_type value_type;
- typedef typename matrix::reference reference;
- typedef typename matrix::pointer pointer;
- typedef iterator2 dual_iterator_type;
- typedef reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator1 ();
- iterator1 (matrix &m, const iterator_type &it);
-
- // Arithmetic
- iterator1 &operator ++ ();
- iterator1 &operator -- ();
- iterator1 &operator += (difference_type n);
- iterator1 &operator -= (difference_type n);
- difference_type operator - (const iterator1 &it) const;
-
- // 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;
- bool operator <(const iterator1 &it) const;
- };
-
- iterator1 begin1 ();
- iterator1 end1 ();
-
- class const_iterator2:
- public container_const_reference<matrix>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef dense_random_access_iterator_tag iterator_category;
- typedef typename matrix::difference_type difference_type;
- typedef typename matrix::value_type value_type;
- typedef typename matrix::const_reference reference;
- typedef typename matrix::const_pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const matrix &m, const const_iterator_type &it);
- const_iterator2 (const iterator2 &it);
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator <(const const_iterator2 &it) const;
- };
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- class iterator2:
- public container_reference<matrix>,
- public random_access_iterator_base<iterator2, value_type> {
- public:
- typedef dense_random_access_iterator_tag iterator_category;
- typedef typename matrix::difference_type difference_type;
- typedef typename matrix::value_type value_type;
- typedef typename matrix::reference reference;
- typedef typename matrix::pointer pointer;
- typedef iterator1 dual_iterator_type;
- typedef reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator2 ();
- iterator2 (matrix &m, const iterator_type &it);
-
- // Arithmetic
- iterator2 &operator ++ ();
- iterator2 &operator -- ();
- iterator2 &operator += (difference_type n);
- iterator2 &operator -= (difference_type n);
- difference_type operator - (const iterator2 &it) const;
-
- // 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;
- 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 ();
- };
-
- // Array based matrix class
template<class T, class F, class A>
class matrix:
public matrix_expression<matrix<T, F, A> > {
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 A array_type;
typedef const A const_array_type;
typedef const matrix<T, F, A> const_self_type;
typedef matrix<T, F, A> 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 dense_tag storage_category;
typedef typename F::orientation_category orientation_category;
// Construction and destruction
matrix ();
matrix (size_type size1, size_type size2);
matrix (const matrix &m);
template<class AE>
matrix (const matrix_expression<AE> &ae);
// Accessors
size_type size1 () const;
size_type size2 () const;
const_array_type &data () const;
array_type &data ();
// Resizing
void resize (size_type size1, size_type size2);
// Element access
const_reference operator () (size_type i, size_type j) const;
reference operator () (size_type i, size_type j);
// Assignment
matrix &operator = (const matrix &m);
matrix &assign_temporary (matrix &m);
template<class AE>
matrix &operator = (const matrix_expression<AE> &ae);
template<class AE>
matrix &reset (const matrix_expression<AE> &ae);
template<class AE>
matrix &assign (const matrix_expression<AE> &ae);
template<class AE>
matrix& operator += (const matrix_expression<AE> &ae);
template<class AE>
matrix &plus_assign (const matrix_expression<AE> &ae);
template<class AE>
matrix& operator -= (const matrix_expression<AE> &ae);
template<class AE>
matrix &minus_assign (const matrix_expression<AE> &ae);
template<class AT>
matrix& operator *= (const AT &at);
template<class AT>
matrix& operator /= (const AT &at);
// Swapping
void swap (matrix &m);
friend void swap (matrix &m1, 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<matrix>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef dense_random_access_iterator_tag iterator_category;
typedef typename matrix::difference_type difference_type;
typedef typename matrix::value_type value_type;
typedef typename matrix::const_reference reference;
typedef typename matrix::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const matrix &m, const const_iterator_type &it);
const_iterator1 (const iterator1 &it);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator <(const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class iterator1:
public container_reference<matrix>,
public random_access_iterator_base<iterator1, value_type> {
public:
typedef dense_random_access_iterator_tag iterator_category;
typedef typename matrix::difference_type difference_type;
typedef typename matrix::value_type value_type;
typedef typename matrix::reference reference;
typedef typename matrix::pointer pointer;
typedef iterator2 dual_iterator_type;
typedef reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
iterator1 ();
iterator1 (matrix &m, const iterator_type &it);
// Arithmetic
iterator1 &operator ++ ();
iterator1 &operator -- ();
iterator1 &operator += (difference_type n);
iterator1 &operator -= (difference_type n);
difference_type operator - (const iterator1 &it) const;
// 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;
bool operator <(const iterator1 &it) const;
};
iterator1 begin1 ();
iterator1 end1 ();
class const_iterator2:
public container_const_reference<matrix>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef dense_random_access_iterator_tag iterator_category;
typedef typename matrix::difference_type difference_type;
typedef typename matrix::value_type value_type;
typedef typename matrix::const_reference reference;
typedef typename matrix::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const matrix &m, const const_iterator_type &it);
const_iterator2 (const iterator2 &it);
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator <(const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
class iterator2:
public container_reference<matrix>,
public random_access_iterator_base<iterator2, value_type> {
public:
typedef dense_random_access_iterator_tag iterator_category;
typedef typename matrix::difference_type difference_type;
typedef typename matrix::value_type value_type;
typedef typename matrix::reference reference;
typedef typename matrix::pointer pointer;
typedef iterator1 dual_iterator_type;
typedef reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
iterator2 ();
iterator2 (matrix &m, const iterator_type &it);
// Arithmetic
iterator2 &operator ++ ();
iterator2 &operator -- ();
iterator2 &operator += (difference_type n);
iterator2 &operator -= (difference_type n);
difference_type operator - (const iterator2 &it) const;
// 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;
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 identity_matrix<T> represents
-identity matrices. For a (m x n)-dimensional identity
-matrix and 0 <= i < m, 0 <= j < n
-holds idi, j = 0, if i
-<> j, and idi, i= 1.
The templated class identity_matrix<T> represents identity
+matrices. For a (m x n)-dimensional identity matrix and 0 <=
+i < m, 0 <= j < n holds idi, j
+ = 0, if i <> j, and idi, i
+= 1.
int main () {
- using namespace boost::numeric::ublas;
- identity_matrix<double> m (3);
- std::cout << m << std::endl;
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
identity_matrix<double> m (3);
std::cout << m << std::endl;
}
Defined in the header matrix.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
T |
- The type of object stored in the matrix. | -- | Parameter | +Description | +Default | + +
T |
+ The type of object stored in the matrix. | ++ |
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of +Matrix Expression +.
+matrix_expression<identity_matrix<T> >
-
matrix_expression<identity_matrix<T> >
| Member | -Description | -
|---|---|
identity_matrix () |
- Constructs an identity_matrix that holds
- zero rows of zero elements. |
-
identity_matrix (size_type size) |
- Constructs an identity_matrix that holds
- size rows of size elements. |
-
identity_matrix (const identity_matrix &m) |
- The copy constructor. | -
void resize (size_type size) |
- Resizes a identity_matrix to hold size
- rows of size elements. |
-
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. |
-
identity_matrix &operator = (const
- identity_matrix &m) |
- The assignment operator. | -
identity_matrix &assign_temporary
- (identity_matrix &m) |
- Assigns a temporary. May change the identity matrix m. |
-
void swap (identity_matrix &m) |
- Swaps the contents of the identity matrices. | -
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the identity_matrix. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the identity_matrix. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the identity_matrix. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the identity_matrix. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed identity_matrix.
- |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed identity_matrix.
- |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed identity_matrix.
- |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed identity_matrix.
- |
- Member | +Description | + +
identity_matrix () |
+ Constructs an identity_matrix that holds
+ zero rows of zero elements. |
+
identity_matrix (size_type size) |
+ Constructs an identity_matrix that holds
+ size rows of size elements. |
+
identity_matrix (const identity_matrix &m) |
+ The copy constructor. | +
void resize (size_type size) |
+ Resizes a identity_matrix to hold size
+ rows of size elements. |
+
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. |
+
identity_matrix &operator = (const identity_matrix
+&m) |
+ The assignment operator. | +
identity_matrix &assign_temporary (identity_matrix
+&m) |
+ Assigns a temporary. May change the identity matrix m
+. |
+
void swap (identity_matrix &m) |
+ Swaps the contents of the identity matrices. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to the
+beginning of the identity_matrix. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to the
+end of the identity_matrix. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to the
+beginning of the identity_matrix. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to the
+end of the identity_matrix. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed identity_matrix. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed identity_matrix. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed identity_matrix. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed identity_matrix. |
+
// Identity matrix class
- template<class T>
- class identity_matrix:
- public matrix_expression<identity_matrix<T> > {
- 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 const identity_matrix<T> const_self_type;
- typedef identity_matrix<T> self_type;
- typedef const matrix_const_reference<const_self_type> const_closure_type;
- typedef size_type const_iterator_type;
- typedef packed_tag storage_category;
- typedef unknown_orientation_tag orientation_category;
-
- // Construction and destruction
- identity_matrix ();
- identity_matrix (size_type size);
- identity_matrix (size_type size1, size_type size2);
- identity_matrix (const identity_matrix &m);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
-
- // Resizing
- void resize (size_type size);
- void resize (size_type size1, size_type size2);
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
-
- // Assignment
- identity_matrix &operator = (const identity_matrix &m);
- identity_matrix &assign_temporary (identity_matrix &m);
-
- // Swapping
- void swap (identity_matrix &m);
- friend void swap (identity_matrix &m1, identity_matrix &m2);
-
- class const_iterator1;
- class const_iterator2;
- typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
- typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
-
- // Element lookup
- const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
- const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
- const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
- const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
-
- // Iterators simply are indices.
-
- class const_iterator1:
- public container_const_reference<identity_matrix>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename identity_matrix::difference_type difference_type;
- typedef typename identity_matrix::value_type value_type;
- typedef typename identity_matrix::const_reference reference;
- typedef typename identity_matrix::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const identity_matrix &m, const const_iterator_type &it1, const const_iterator_type &it2);
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator <(const const_iterator1 &it) const;
- };
-
- typedef const_iterator1 iterator1;
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class const_iterator2:
- public container_const_reference<identity_matrix>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef packed_random_access_iterator_tag iterator_category;
- typedef typename identity_matrix::difference_type difference_type;
- typedef typename identity_matrix::value_type value_type;
- typedef typename identity_matrix::const_reference reference;
- typedef typename identity_matrix::const_pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const identity_matrix &m, const const_iterator_type &it1, const const_iterator_type &it2);
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator <(const const_iterator2 &it) const;
- };
-
- typedef const_iterator2 iterator2;
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- // Reverse iterators
-
- const_reverse_iterator1 rbegin1 () const;
- const_reverse_iterator1 rend1 () const;
-
- const_reverse_iterator2 rbegin2 () const;
- const_reverse_iterator2 rend2 () const;
- };
-
- // Identity matrix class
template<class T>
class identity_matrix:
public matrix_expression<identity_matrix<T> > {
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 const identity_matrix<T> const_self_type;
typedef identity_matrix<T> self_type;
typedef const matrix_const_reference<const_self_type> const_closure_type;
typedef size_type const_iterator_type;
typedef packed_tag storage_category;
typedef unknown_orientation_tag orientation_category;
// Construction and destruction
identity_matrix ();
identity_matrix (size_type size);
identity_matrix (size_type size1, size_type size2);
identity_matrix (const identity_matrix &m);
// Accessors
size_type size1 () const;
size_type size2 () const;
// Resizing
void resize (size_type size);
void resize (size_type size1, size_type size2);
// Element access
const_reference operator () (size_type i, size_type j) const;
// Assignment
identity_matrix &operator = (const identity_matrix &m);
identity_matrix &assign_temporary (identity_matrix &m);
// Swapping
void swap (identity_matrix &m);
friend void swap (identity_matrix &m1, identity_matrix &m2);
class const_iterator1;
class const_iterator2;
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
// Element lookup
const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
// Iterators simply are indices.
class const_iterator1:
public container_const_reference<identity_matrix>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename identity_matrix::difference_type difference_type;
typedef typename identity_matrix::value_type value_type;
typedef typename identity_matrix::const_reference reference;
typedef typename identity_matrix::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const identity_matrix &m, const const_iterator_type &it1, const const_iterator_type &it2);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator <(const const_iterator1 &it) const;
};
typedef const_iterator1 iterator1;
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class const_iterator2:
public container_const_reference<identity_matrix>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef packed_random_access_iterator_tag iterator_category;
typedef typename identity_matrix::difference_type difference_type;
typedef typename identity_matrix::value_type value_type;
typedef typename identity_matrix::const_reference reference;
typedef typename identity_matrix::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const identity_matrix &m, const const_iterator_type &it1, const const_iterator_type &it2);
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator <(const const_iterator2 &it) const;
};
typedef const_iterator2 iterator2;
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
// Reverse iterators
const_reverse_iterator1 rbegin1 () const;
const_reverse_iterator1 rend1 () const;
const_reverse_iterator2 rbegin2 () const;
const_reverse_iterator2 rend2 () const;
};
+
+The templated class zero_matrix<T> represents
-zero matrices. For a (m x n)-dimensional zero matrix and
-0 <= i < m, 0 <= j < n holds zi,
-j = 0.
The templated class zero_matrix<T> represents zero
+matrices. For a (m x n)-dimensional zero matrix and 0 <=
+i < m, 0 <= j < n holds zi, j
+ = 0.
int main () {
- using namespace boost::numeric::ublas;
- zero_matrix<double> m (3, 3);
- std::cout << m << std::endl;
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
zero_matrix<double> m (3, 3);
std::cout << m << std::endl;
}
Defined in the header matrix.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
T |
- The type of object stored in the matrix. | -- | Parameter | +Description | +Default | + +
T |
+ The type of object stored in the matrix. | ++ |
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of +Matrix Expression +.
+matrix_expression<zero_matrix<T> >
| Member | -Description | -
|---|---|
zero_matrix () |
- Constructs a zero_matrix that holds zero
- rows of zero elements. |
-
zero_matrix (size_type size1, size_type size2) |
- Constructs a zero_matrix that holds size1
- rows of size2 elements. |
-
zero_matrix (const zero_matrix &m) |
- The copy constructor. | -
void resize (size_type size1, size_type size2) |
- Resizes a zero_matrix to hold size1
- rows of size2 elements. |
-
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. |
-
zero_matrix &operator = (const zero_matrix
- &m) |
- The assignment operator. | -
zero_matrix &assign_temporary (zero_matrix
- &m) |
- Assigns a temporary. May change the zero matrix m. |
-
void swap (zero_matrix &m) |
- Swaps the contents of the zero matrices. | -
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the zero_matrix. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the zero_matrix. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the zero_matrix. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the zero_matrix. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed zero_matrix.
- |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed zero_matrix.
- |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed zero_matrix.
- |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed zero_matrix.
- |
- Member | +Description | + +
zero_matrix () |
+ Constructs a zero_matrix that holds zero
+ rows of zero elements. |
+
zero_matrix (size_type size1, size_type size2) |
+ Constructs a zero_matrix that holds size1
+ rows of size2 elements. |
+
zero_matrix (const zero_matrix &m) |
+ The copy constructor. | +
void resize (size_type size1, size_type size2) |
+ Resizes a zero_matrix to hold size1
+ rows of size2 elements. |
+
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. |
+
zero_matrix &operator = (const zero_matrix
+ &m) |
+ The assignment operator. | +
zero_matrix &assign_temporary (zero_matrix
+ &m) |
+ Assigns a temporary. May change the zero matrix m
+. |
+
void swap (zero_matrix &m) |
+ Swaps the contents of the zero matrices. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to the
+beginning of the zero_matrix. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to the
+end of the zero_matrix. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to the
+beginning of the zero_matrix. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to the
+end of the zero_matrix. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed zero_matrix. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed zero_matrix. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed zero_matrix. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed zero_matrix. |
+
// Zero matrix class
- template<class T>
- class zero_matrix:
- public matrix_expression<zero_matrix<T> > {
- 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 const zero_matrix<T> const_self_type;
- typedef zero_matrix<T> self_type;
- typedef const matrix_const_reference<const_self_type> const_closure_type;
- typedef size_type const_iterator_type;
- typedef sparse_tag storage_category;
- typedef unknown_orientation_tag orientation_category;
-
- // Construction and destruction
- zero_matrix ();
- zero_matrix (size_type size1, size_type size2);
- zero_matrix (const zero_matrix &m);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
-
- // Resizing
- void resize (size_type size1, size_type size2);
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
-
- // Assignment
- zero_matrix &operator = (const zero_matrix &m);
- zero_matrix &assign_temporary (zero_matrix &m);
-
- // Swapping
- void swap (zero_matrix &m);
- friend void swap (zero_matrix &m1, zero_matrix &m2);
-
- class const_iterator1;
- class const_iterator2;
- typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
- typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
-
- // Element lookup
- const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
- const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
- const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
- const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
-
- // Iterators simply are indices.
-
- class const_iterator1:
- public container_const_reference<zero_matrix>,
- public bidirectional_iterator_base<const_iterator1, value_type> {
- public:
- typedef sparse_bidirectional_iterator_tag iterator_category;
- typedef typename zero_matrix::difference_type difference_type;
- typedef typename zero_matrix::value_type value_type;
- typedef typename zero_matrix::const_reference reference;
- typedef typename zero_matrix::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const zero_matrix &m, const const_iterator_type &it1, const const_iterator_type &it2);
-
- // 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;
- };
-
- typedef const_iterator1 iterator1;
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class const_iterator2:
- public container_const_reference<zero_matrix>,
- public bidirectional_iterator_base<const_iterator2, value_type> {
- public:
- typedef sparse_bidirectional_iterator_tag iterator_category;
- typedef typename zero_matrix::difference_type difference_type;
- typedef typename zero_matrix::value_type value_type;
- typedef typename zero_matrix::const_reference reference;
- typedef typename zero_matrix::const_pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const zero_matrix &m, const const_iterator_type &it1, const const_iterator_type &it2);
-
- // 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;
- };
-
- typedef const_iterator2 iterator2;
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- // Reverse iterators
-
- const_reverse_iterator1 rbegin1 () const;
- const_reverse_iterator1 rend1 () const;
-
- const_reverse_iterator2 rbegin2 () const;
- const_reverse_iterator2 rend2 () const;
- };
-
-Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this
-document is granted provided this copyright notice appears in all
-copies. This document is provided ``as is'' without express or
-implied warranty, and with no claim as to its suitability for any
-purpose.
// Zero matrix class
template<class T>
class zero_matrix:
public matrix_expression<zero_matrix<T> > {
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 const zero_matrix<T> const_self_type;
typedef zero_matrix<T> self_type;
typedef const matrix_const_reference<const_self_type> const_closure_type;
typedef size_type const_iterator_type;
typedef sparse_tag storage_category;
typedef unknown_orientation_tag orientation_category;
// Construction and destruction
zero_matrix ();
zero_matrix (size_type size1, size_type size2);
zero_matrix (const zero_matrix &m);
// Accessors
size_type size1 () const;
size_type size2 () const;
// Resizing
void resize (size_type size1, size_type size2);
// Element access
const_reference operator () (size_type i, size_type j) const;
// Assignment
zero_matrix &operator = (const zero_matrix &m);
zero_matrix &assign_temporary (zero_matrix &m);
// Swapping
void swap (zero_matrix &m);
friend void swap (zero_matrix &m1, zero_matrix &m2);
class const_iterator1;
class const_iterator2;
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
// Element lookup
const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
// Iterators simply are indices.
class const_iterator1:
public container_const_reference<zero_matrix>,
public bidirectional_iterator_base<const_iterator1, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename zero_matrix::difference_type difference_type;
typedef typename zero_matrix::value_type value_type;
typedef typename zero_matrix::const_reference reference;
typedef typename zero_matrix::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const zero_matrix &m, const const_iterator_type &it1, const const_iterator_type &it2);
// 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;
};
typedef const_iterator1 iterator1;
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class const_iterator2:
public container_const_reference<zero_matrix>,
public bidirectional_iterator_base<const_iterator2, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename zero_matrix::difference_type difference_type;
typedef typename zero_matrix::value_type value_type;
typedef typename zero_matrix::const_reference reference;
typedef typename zero_matrix::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const zero_matrix &m, const const_iterator_type &it1, const const_iterator_type &it2);
// 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;
};
typedef const_iterator2 iterator2;
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
// Reverse iterators
const_reverse_iterator1 rbegin1 () const;
const_reverse_iterator1 rend1 () const;
const_reverse_iterator2 rbegin2 () const;
const_reverse_iterator2 rend2 () const;
};
+
+Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+ Permission to copy, use, modify, sell and distribute this document is granted
+provided this copyright notice appears in all copies. This document is provided
+``as is'' without express or implied warranty, and with no claim as to its
+suitability for any purpose.
Last revised: 8/3/2002
+ diff --git a/doc/matrix_expression.htm b/doc/matrix_expression.htm index 8a08c5ba..f44c4de3 100644 --- a/doc/matrix_expression.htm +++ b/doc/matrix_expression.htm @@ -1,1624 +1,852 @@ + - - - -
Matrix Expressions
+ Matrix ExpressionsThe templated class matrix_expression<E> forms
-the base for all static derived matrix expression classes
-including class matrix itself.
The templated class matrix_expression<E> forms the base
+for all static derived matrix expression classes including class matrix
+ itself.
Defined in the header matrix_expression.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
E |
- The type of the matrix expression. | -- |
| Parameter | +Description | +Default | +
E |
+ The type of the matrix expression. | ++ |
None.
- +None.
- +None.
- +| Member | -Description | -
|---|---|
const expression_type &operator () () const |
- Returns a const reference of the
- expression. |
-
expression_type &operator () () |
- Returns a reference of the expression. | -
| Member | +Description | +
const expression_type &operator () () const |
+ Returns a const reference of the expression.
+ |
+
expression_type &operator () () |
+ Returns a reference of the expression. | +
// Base class for the Barton Nackman trick
- template<class E>
- struct matrix_expression {
- typedef E expression_type;
- typedef matrix_tag type_category;
-
- // This class could define an common interface for all
- // statically derived expression type classes.
- // Due to a compiler deficiency - one can not reference class typedefs of E
- // on MSVC 6.0 (error C2027) - we only implement the casts.
-
- const expression_type &operator () () const;
- expression_type &operator () ();
- };
-
- // Base class for the Barton Nackman trick
template<class E>
struct matrix_expression {
typedef E expression_type;
typedef matrix_tag type_category;
// This class could define an common interface for all
// statically derived expression type classes.
// Due to a compiler deficiency - one can not reference class typedefs of E
// on MSVC 6.0 (error C2027) - we only implement the casts.
const expression_type &operator () () const;
expression_type &operator () ();
};
+
+The templated class matrix_const_reference<E> contains
-a constant reference to a matrix expression.
Defined in the header matrix_expression.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
E |
- The type of the matrix expression. | -- |
| Parameter | +Description | +Default | +
E |
+ The type of the matrix expression. | ++ |
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of + Matrix Expression + .
+matrix_expression<matrix_const_reference<E>
->
matrix_expression<matrix_const_reference<E> >
| Member | -Description | -
|---|---|
matrix_const_reference (const expression_type
- &e) |
- Constructs a constant reference of the expression. | -
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. |
-
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the expression. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the expression. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the expression. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the expression. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed expression. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed expression. |
-
| Member | +Description | +
matrix_const_reference (const expression_type
+ &e) |
+ Constructs a constant reference of the expression. | +
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. |
+
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to
+the beginning of the expression. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to
+the end of the expression. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to
+the beginning of the expression. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to
+the end of the expression. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed expression. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed expression. |
+
Interface
- - template<class E>
- class matrix_const_reference:
- public matrix_expression<matrix_const_reference<E> > {
- public:
- typedef E expression_type;
- typedef typename E::size_type size_type;
- typedef typename E::difference_type difference_type;
- typedef typename E::value_type value_type;
- typedef typename E::const_reference const_reference;
- typedef const_reference reference;
- typedef typename E::const_pointer const_pointer;
- typedef const_pointer pointer;
- typedef typename E::orientation_category orientation_category;
- typedef typename E::const_iterator1 const_iterator1_type;
- typedef typename E::const_iterator2 const_iterator2_type;
- typedef unknown_storage_tag storage_category;
-
- // Construction and destruction
- matrix_const_reference ();
- matrix_const_reference (const expression_type &e);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- const expression_type &expression () const;
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
-
- typedef const_iterator1_type const_iterator1;
- typedef const_iterator1 iterator1;
- typedef const_iterator2_type const_iterator2;
- typedef const_iterator2 iterator2;
-
- // Element lookup
- const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
- const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
- const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
- const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
-
- // Iterators are the iterators of the referenced expression.
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- // Reverse iterators
-
- typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
-
- const_reverse_iterator1 rbegin1 () const;
- const_reverse_iterator1 rend1 () const;
-
- typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
-
- const_reverse_iterator2 rbegin2 () const;
- const_reverse_iterator2 rend2 () const;
- };
-
+
+ template<class E>
class matrix_const_reference:
public matrix_expression<matrix_const_reference<E> > {
public:
typedef E expression_type;
typedef typename E::size_type size_type;
typedef typename E::difference_type difference_type;
typedef typename E::value_type value_type;
typedef typename E::const_reference const_reference;
typedef const_reference reference;
typedef typename E::const_pointer const_pointer;
typedef const_pointer pointer;
typedef typename E::orientation_category orientation_category;
typedef typename E::const_iterator1 const_iterator1_type;
typedef typename E::const_iterator2 const_iterator2_type;
typedef unknown_storage_tag storage_category;
// Construction and destruction
matrix_const_reference ();
matrix_const_reference (const expression_type &e);
// Accessors
size_type size1 () const;
size_type size2 () const;
const expression_type &expression () const;
// Element access
const_reference operator () (size_type i, size_type j) const;
typedef const_iterator1_type const_iterator1;
typedef const_iterator1 iterator1;
typedef const_iterator2_type const_iterator2;
typedef const_iterator2 iterator2;
// Element lookup
const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
// Iterators are the iterators of the referenced expression.
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
// Reverse iterators
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
const_reverse_iterator1 rbegin1 () const;
const_reverse_iterator1 rend1 () const;
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
const_reverse_iterator2 rbegin2 () const;
const_reverse_iterator2 rend2 () const;
};
+
The templated class matrix_reference<E> contains
-a reference to a matrix expression.
The templated class matrix_reference<E> contains a reference
+to a matrix expression.
Defined in the header matrix_expression.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
E |
- The type of the matrix expression. | -- |
| Parameter | +Description | +Default | +
E |
+ The type of the matrix expression. | ++ |
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of + Matrix Expression + .
+matrix_expression<matrix_reference<E> >
| Member | -Description | -
|---|---|
matrix_reference (expression_type &e)
- |
- Constructs a constant reference of the expression. | -
void resize (size_type size1, size2) |
- Resizes the expression to hold at most size1 rows
- of size2 elements. |
-
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. |
-
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the expression. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the expression. |
-
iterator1 begin1 () |
- Returns a iterator1 pointing to the
- beginning of the expression. |
-
iterator1 end1 () |
- Returns a iterator1 pointing to the end
- of the expression. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the expression. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the expression. |
-
iterator2 begin2 () |
- Returns a iterator2 pointing to the
- beginning of the expression. |
-
iterator2 end2 () |
- Returns a iterator2 pointing to the end
- of the expression. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed expression. |
-
reverse_iterator1 rbegin1 () |
- Returns a reverse_iterator1 pointing to
- the beginning of the reversed expression. |
-
reverse_iterator1 rend1 () |
- Returns a reverse_iterator1 pointing to
- the end of the reversed expression. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed expression. |
-
reverse_iterator2 rbegin2 () |
- Returns a reverse_iterator2 pointing to
- the beginning of the reversed expression. |
-
reverse_iterator2 rend2 () |
- Returns a reverse_iterator2 pointing to
- the end of the reversed expression. |
-
| Member | +Description | +
matrix_reference (expression_type &e)
+ |
+ Constructs a constant reference of the expression. | +
void resize (size_type size1, size2) |
+ Resizes the expression to hold at most size1 rows
+ of size2 elements. |
+
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. |
+
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to
+the beginning of the expression. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to
+the end of the expression. |
+
iterator1 begin1 () |
+ Returns a iterator1 pointing to the beginning
+of the expression. |
+
iterator1 end1 () |
+ Returns a iterator1 pointing to the end
+ of the expression. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to
+the beginning of the expression. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to
+the end of the expression. |
+
iterator2 begin2 () |
+ Returns a iterator2 pointing to the beginning
+of the expression. |
+
iterator2 end2 () |
+ Returns a iterator2 pointing to the end
+ of the expression. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed expression. |
+
reverse_iterator1 rbegin1 () |
+ Returns a reverse_iterator1 pointing to
+ the beginning of the reversed expression. |
+
reverse_iterator1 rend1 () |
+ Returns a reverse_iterator1 pointing to
+ the end of the reversed expression. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed expression. |
+
reverse_iterator2 rbegin2 () |
+ Returns a reverse_iterator2 pointing to
+ the beginning of the reversed expression. |
+
reverse_iterator2 rend2 () |
+ Returns a reverse_iterator2 pointing to
+ the end of the reversed expression. |
+
template<class E>
- class matrix_reference:
- public matrix_expression<matrix_reference<E> > {
- public:
- typedef E expression_type;
- typedef typename E::size_type size_type;
- typedef typename E::difference_type difference_type;
- typedef typename E::value_type value_type;
- typedef typename E::const_reference const_reference;
- typedef typename E::reference reference;
- typedef typename E::const_pointer const_pointer;
- typedef typename E::pointer pointer;
- typedef typename E::orientation_category orientation_category;
- typedef typename E::const_iterator1 const_iterator1_type;
- typedef typename E::iterator1 iterator1_type;
- typedef typename E::const_iterator2 const_iterator2_type;
- typedef typename E::iterator2 iterator2_type;
- typedef unknown_storage_tag storage_category;
-
- // Construction and destruction
- matrix_reference ();
- matrix_reference (expression_type &e);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- const expression_type &expression () const;
- expression_type &expression ();
-
- // Resizing
- void resize (size_type size1, size_type size2);
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
- reference operator () (size_type i, size_type j);
-
- typedef const_iterator1_type const_iterator1;
- typedef iterator1_type iterator1;
- typedef const_iterator2_type const_iterator2;
- typedef iterator2_type iterator2;
-
- // Element lookup
- 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 are the iterators of the referenced expression.
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- iterator1 begin1 ();
- iterator1 end1 ();
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- iterator2 begin2 ();
- iterator2 end2 ();
-
- // Reverse iterators
-
- typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
-
- const_reverse_iterator1 rbegin1 () const;
- const_reverse_iterator1 rend1 () const;
-
- typedef reverse_iterator_base1<iterator1> reverse_iterator1;
-
- reverse_iterator1 rbegin1 ();
- reverse_iterator1 rend1 ();
-
- typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
-
- const_reverse_iterator2 rbegin2 () const;
- const_reverse_iterator2 rend2 () const;
-
- typedef reverse_iterator_base2<iterator2> reverse_iterator2;
-
- reverse_iterator2 rbegin2 ();
- reverse_iterator2 rend2 ();
- };
-
- template<class E>
class matrix_reference:
public matrix_expression<matrix_reference<E> > {
public:
typedef E expression_type;
typedef typename E::size_type size_type;
typedef typename E::difference_type difference_type;
typedef typename E::value_type value_type;
typedef typename E::const_reference const_reference;
typedef typename E::reference reference;
typedef typename E::const_pointer const_pointer;
typedef typename E::pointer pointer;
typedef typename E::orientation_category orientation_category;
typedef typename E::const_iterator1 const_iterator1_type;
typedef typename E::iterator1 iterator1_type;
typedef typename E::const_iterator2 const_iterator2_type;
typedef typename E::iterator2 iterator2_type;
typedef unknown_storage_tag storage_category;
// Construction and destruction
matrix_reference ();
matrix_reference (expression_type &e);
// Accessors
size_type size1 () const;
size_type size2 () const;
const expression_type &expression () const;
expression_type &expression ();
// Resizing
void resize (size_type size1, size_type size2);
// Element access
const_reference operator () (size_type i, size_type j) const;
reference operator () (size_type i, size_type j);
typedef const_iterator1_type const_iterator1;
typedef iterator1_type iterator1;
typedef const_iterator2_type const_iterator2;
typedef iterator2_type iterator2;
// Element lookup
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 are the iterators of the referenced expression.
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
iterator1 begin1 ();
iterator1 end1 ();
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
iterator2 begin2 ();
iterator2 end2 ();
// Reverse iterators
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
const_reverse_iterator1 rbegin1 () const;
const_reverse_iterator1 rend1 () const;
typedef reverse_iterator_base1<iterator1> reverse_iterator1;
reverse_iterator1 rbegin1 ();
reverse_iterator1 rend1 ();
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
const_reverse_iterator2 rbegin2 () const;
const_reverse_iterator2 rend2 () const;
typedef reverse_iterator_base2<iterator2> reverse_iterator2;
reverse_iterator2 rbegin2 ();
reverse_iterator2 rend2 ();
};
+
+The templated classes matrix_unary1<E, F> and
-matrix_unary2<E, F> describe unary matrix
-operations.
The templated classes matrix_unary1<E, F> and
+ matrix_unary2<E, F> describe unary matrix operations.
Defined in the header matrix_expression.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
E |
- The type of the matrix expression. | -- |
F |
- The type of the operation. | -- |
| Parameter | +Description | +Default | +
E |
+ The type of the matrix expression. | ++ |
F |
+ The type of the operation. | ++ |
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of + Matrix Expression + .
+matrix_expression<matrix_unary1<E, F> > and
-matrix_expression<matrix_unary2<E, F> > resp.
| Member | -Description | -
|---|---|
matrix_unary1 (const expression_type &e)
- |
- Constructs a description of the expression. | -
matrix_unary2 (const expression_type &e) |
- Constructs a description of the expression. | -
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. |
-
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the expression. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the expression. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the expression. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the expression. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed expression. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed expression. |
-
| Member | +Description | +
matrix_unary1 (const expression_type &e)
+ |
+ Constructs a description of the expression. | +
matrix_unary2 (const expression_type &e) |
+ Constructs a description of the expression. | +
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. |
+
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to
+the beginning of the expression. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to
+the end of the expression. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to
+the beginning of the expression. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to
+the end of the expression. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed expression. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed expression. |
+
template<class E, class F>
- class matrix_unary1:
- public matrix_expression<matrix_unary1<E, F> > {
- public:
- typedef E expression_type;
- typedef F functor_type;
- typedef typename E::size_type size_type;
- typedef typename E::difference_type difference_type;
- typedef typename F::result_type value_type;
- typedef value_type const_reference;
- typedef const_reference reference;
- typedef const value_type *const_pointer;
- typedef const_pointer pointer;
- typedef const matrix_unary1<E, F> const_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;
- typedef unknown_storage_tag storage_category;
-
- // Construction and destruction
- matrix_unary1 ();
- matrix_unary1 (const expression_type &e);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- const expression_type &expression () const;
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
-
- class const_iterator1;
- typedef const_iterator1 iterator1;
- class const_iterator2;
- typedef const_iterator2 iterator2;
- typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
- typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
-
- // Element lookup
- const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
- const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
- const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
- const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
-
- // Iterators enhance the iterators of the referenced expression
- // with the unary functor.
-
- class const_iterator1:
- public container_const_reference<matrix_unary1>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef typename E::const_iterator1::iterator_category iterator_category;
- typedef typename matrix_unary1::difference_type difference_type;
- typedef typename matrix_unary1::value_type value_type;
- typedef typename matrix_unary1::const_reference reference;
- typedef typename matrix_unary1::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const matrix_unary1 &mu, const const_iterator1_type &it);
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator <(const const_iterator1 &it) const;
- };
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class const_iterator2:
- public container_const_reference<matrix_unary1>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef typename E::const_iterator2::iterator_category iterator_category;
- typedef typename matrix_unary1::difference_type difference_type;
- typedef typename matrix_unary1::value_type value_type;
- typedef typename matrix_unary1::const_reference reference;
- typedef typename matrix_unary1::const_pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const matrix_unary1 &mu, const const_iterator2_type &it);
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator <(const const_iterator2 &it) const;
- };
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- // Reverse iterators
-
- const_reverse_iterator1 rbegin1 () const;
- const_reverse_iterator1 rend1 () const;
-
- const_reverse_iterator2 rbegin2 () const;
- const_reverse_iterator2 rend2 () const;
- };
-
- template<class E, class F>
- class matrix_unary2:
- public matrix_expression<matrix_unary2<E, F> > {
- public:
- typedef E expression_type;
- typedef F functor_type;
- typedef typename E::size_type size_type;
- typedef typename E::difference_type difference_type;
- typedef typename F::result_type value_type;
- typedef value_type const_reference;
- typedef const_reference reference;
- typedef const value_type *const_pointer;
- typedef const_pointer pointer;
- typedef const matrix_unary2<E, F> const_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;
- typedef unknown_storage_tag storage_category;
-
- // Construction and destruction
- matrix_unary2 ();
- matrix_unary2 (const expression_type &e);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- const expression_type &expression () const;
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
-
- class const_iterator1;
- typedef const_iterator1 iterator1;
- class const_iterator2;
- typedef const_iterator2 iterator2;
- typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
- typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
-
- // Element lookup
- const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
- const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
- const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
- const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
-
- // Iterators enhance the iterators of the referenced expression
- // with the unary functor.
-
- class const_iterator1:
- public container_const_reference<matrix_unary2>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef typename E::const_iterator2::iterator_category iterator_category;
- typedef typename matrix_unary2::difference_type difference_type;
- typedef typename matrix_unary2::value_type value_type;
- typedef typename matrix_unary2::const_reference reference;
- typedef typename matrix_unary2::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const matrix_unary2 &mu, const const_iterator1_type &it);
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator <(const const_iterator1 &it) const;
- };
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class const_iterator2:
- public container_const_reference<matrix_unary2>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef typename E::const_iterator1::iterator_category iterator_category;
- typedef typename matrix_unary2::difference_type difference_type;
- typedef typename matrix_unary2::value_type value_type;
- typedef typename matrix_unary2::const_reference reference;
- typedef typename matrix_unary2::const_pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const matrix_unary2 &mu, const const_iterator2_type &it);
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator <(const const_iterator2 &it) const;
- };
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- // Reverse iterators
-
- const_reverse_iterator1 rbegin1 () const;
- const_reverse_iterator1 rend1 () const;
-
- const_reverse_iterator2 rbegin2 () const;
- const_reverse_iterator2 rend2 () const;
- };
-
+
+ template<class E, class F>
class matrix_unary1:
public matrix_expression<matrix_unary1<E, F> > {
public:
typedef E expression_type;
typedef F functor_type;
typedef typename E::size_type size_type;
typedef typename E::difference_type difference_type;
typedef typename F::result_type value_type;
typedef value_type const_reference;
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
typedef const matrix_unary1<E, F> const_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;
typedef unknown_storage_tag storage_category;
// Construction and destruction
matrix_unary1 ();
matrix_unary1 (const expression_type &e);
// Accessors
size_type size1 () const;
size_type size2 () const;
const expression_type &expression () const;
// Element access
const_reference operator () (size_type i, size_type j) const;
class const_iterator1;
typedef const_iterator1 iterator1;
class const_iterator2;
typedef const_iterator2 iterator2;
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
// Element lookup
const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
// Iterators enhance the iterators of the referenced expression
// with the unary functor.
class const_iterator1:
public container_const_reference<matrix_unary1>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef typename E::const_iterator1::iterator_category iterator_category;
typedef typename matrix_unary1::difference_type difference_type;
typedef typename matrix_unary1::value_type value_type;
typedef typename matrix_unary1::const_reference reference;
typedef typename matrix_unary1::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const matrix_unary1 &mu, const const_iterator1_type &it);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator <(const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class const_iterator2:
public container_const_reference<matrix_unary1>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef typename E::const_iterator2::iterator_category iterator_category;
typedef typename matrix_unary1::difference_type difference_type;
typedef typename matrix_unary1::value_type value_type;
typedef typename matrix_unary1::const_reference reference;
typedef typename matrix_unary1::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const matrix_unary1 &mu, const const_iterator2_type &it);
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator <(const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
// Reverse iterators
const_reverse_iterator1 rbegin1 () const;
const_reverse_iterator1 rend1 () const;
const_reverse_iterator2 rbegin2 () const;
const_reverse_iterator2 rend2 () const;
};
template<class E, class F>
class matrix_unary2:
public matrix_expression<matrix_unary2<E, F> > {
public:
typedef E expression_type;
typedef F functor_type;
typedef typename E::size_type size_type;
typedef typename E::difference_type difference_type;
typedef typename F::result_type value_type;
typedef value_type const_reference;
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
typedef const matrix_unary2<E, F> const_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;
typedef unknown_storage_tag storage_category;
// Construction and destruction
matrix_unary2 ();
matrix_unary2 (const expression_type &e);
// Accessors
size_type size1 () const;
size_type size2 () const;
const expression_type &expression () const;
// Element access
const_reference operator () (size_type i, size_type j) const;
class const_iterator1;
typedef const_iterator1 iterator1;
class const_iterator2;
typedef const_iterator2 iterator2;
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
// Element lookup
const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
// Iterators enhance the iterators of the referenced expression
// with the unary functor.
class const_iterator1:
public container_const_reference<matrix_unary2>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef typename E::const_iterator2::iterator_category iterator_category;
typedef typename matrix_unary2::difference_type difference_type;
typedef typename matrix_unary2::value_type value_type;
typedef typename matrix_unary2::const_reference reference;
typedef typename matrix_unary2::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const matrix_unary2 &mu, const const_iterator1_type &it);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator <(const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class const_iterator2:
public container_const_reference<matrix_unary2>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef typename E::const_iterator1::iterator_catego
+ry iterator_category;
typedef typename matrix_unary2::difference_type difference_type;
typedef typename matrix_unary2::value_type value_type;
typedef typename matrix_unary2::const_reference reference;
typedef typename matrix_unary2::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const matrix_unary2 &mu, const const_iterator2_type &it);
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator <(const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
// Reverse iterators
const_reverse_iterator1 rbegin1 () const;
const_reverse_iterator1 rend1 () const;
const_reverse_iterator2 rbegin2 () const;
const_reverse_iterator2 rend2 () const;
};
+
template<class E, class F>
- struct matrix_unary1_traits {
- typedef matrix_unary1<typename E::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (- m) [i] [j] = - m [i] [j]
- template<class E>
- typename matrix_unary1_traits<E, scalar_negate<typename E::value_type> >::result_type
- operator - (const matrix_expression<E> &e);
-
- // (conj m) [i] [j] = conj (m [i] [j])
- template<class E>
- typename matrix_unary1_traits<E, scalar_conj<typename E::value_type> >::result_type
- conj (const matrix_expression<E> &e);
-
- // (real m) [i] [j] = real (m [i] [j])
- template<class E>
- typename matrix_unary1_traits<E, scalar_real<typename E::value_type> >::result_type
- real (const matrix_expression<E> &e);
-
- // (imag m) [i] [j] = imag (m [i] [j])
- template<class E>
- typename matrix_unary1_traits<E, scalar_imag<typename E::value_type> >::result_type
- imag (const matrix_expression<E> &e);
-
- template<class E, class F>
- struct matrix_unary2_traits {
- typedef matrix_unary2<typename E::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (trans m) [i] [j] = m [j] [i]
- template<class E>
- typename matrix_unary2_traits<E, scalar_identity<typename E::value_type> >::result_type
- trans (const matrix_expression<E> &e);
-
- // (herm m) [i] [j] = conj (m [j] [i])
- template<class E>
- typename matrix_unary2_traits<E, scalar_conj<typename E::value_type> >::result_type
- herm (const matrix_expression<E> &e);
-
+
+ template<class E, class F>
struct matrix_unary1_traits {
typedef matrix_unary1<typename E::const_closure_type, F> expression_type;
typedef expression_type result_type;
};
// (- m) [i] [j] = - m [i] [j]
template<class E>
typename matrix_unary1_traits<E, scalar_negate<typename E::value_type> >::result_type
operator - (const matrix_expression<E> &e);
// (conj m) [i] [j] = conj (m [i] [j])
template<class E>
typename matrix_unary1_traits<E, scalar_conj<typename E::value_type> >::result_type
conj (const matrix_expression<E> &e);
// (real m) [i] [j] = real (m [i] [j])
template<class E>
typename matrix_unary1_traits<E, scalar_real<typename E::value_type> >::result_type
real (const matrix_expression<E> &e);
// (imag m) [i] [j] = imag (m [i] [j])
template<class E>
typename matrix_unary1_traits<E, scalar_imag<typename E::value_type> >::result_type
imag (const matrix_expression<E> &e);
template<class E, class F>
struct matrix_unary2_traits {
typedef matrix_unary2<typename E::const_closure_type, F> expression_type;
typedef expression_type result_type;
};
// (trans m) [i] [j] = m [j] [i]
template<class E>
typename matrix_unary2_traits<E, scalar_identity<typename E::value_type> >::result_type
trans (const matrix_expression<E> &e);
// (herm m) [i] [j] = conj (m [j] [i])
template<class E>
typename matrix_unary2_traits<E, scalar_conj<typename E::value_type> >::result_type
herm (const matrix_expression<E> &e);
+
operator - computes the additive inverse of a
-matrix expression. conj computes the complex
-conjugate of a matrix expression. real and imag
-compute the real and imaginary parts of a matrix expression. trans
-computes the transpose of a matrix expression. herm computes
-the hermitian, i.e. the complex conjugate of the transpose of a
-matrix expression.
operator - computes the additive inverse of a matrix expression.
+conj computes the complex conjugate of a matrix expression.
+ real and imag compute the real and imaginary parts
+of a matrix expression. trans computes the transpose of a matrix
+expression. herm computes the hermitian, i.e. the complex conjugate
+of the transpose of a matrix expression.
Defined in the header matrix_expression.hpp.
- +E is a model of Matrix Expression.E is a model of
+ Matrix Expression
+ .None.
- +Quadratic depending from the size of the matrix expression.
- +int main () {
- using namespace boost::numeric::ublas;
- matrix<std::complex<double> > m (3, 3);
- for (int i = 0; i < m.size1 (); ++ i)
- for (int j = 0; j < m.size2 (); ++ j)
- m (i, j) = std::complex (3 * i + j, 3 * i + j);
-
- std::cout << - m << std::endl;
- std::cout << conj (m) << std::endl;
- std::cout << real (m) << std::endl;
- std::cout << imag (m) << std::endl;
- std::cout << trans (m) << std::endl;
- std::cout << herm (m) << std::endl;
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>+
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<std::complex<double> > m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned j = 0; j < m.size2 (); ++ j)
m (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
std::cout << - m << std::endl;
std::cout << conj (m) << std::endl;
std::cout << real (m) << std::endl;
std::cout << imag (m) << std::endl;
std::cout << trans (m) << std::endl;
std::cout << herm (m) << std::endl;
}
The templated class matrix_binary<E1, E2, F> describes
-a binary matrix operation.
Defined in the header matrix_expression.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
E1 |
- The type of the first matrix expression. | -- |
E2 |
- The type of the second matrix expression. | -- |
F |
- The type of the operation. | -- |
| Parameter | +Description | +Default | +
E1 |
+ The type of the first matrix expression. | ++ |
E2 |
+ The type of the second matrix expression. | ++ |
F |
+ The type of the operation. | ++ |
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of + Matrix Expression + .
+matrix_expression<matrix_binary<E1, E2, F> >.
| Member | -Description | -
|---|---|
matrix_binary (const expression1_type &e1,
- const expression2_type &e2) |
- Constructs a description of the expression. | -
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. |
-
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the expression. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the expression. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the expression. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the expression. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed expression. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed expression. |
-
| Member | +Description | +
matrix_binary (const expression1_type &e1,
+ const expression2_type &e2) |
+ Constructs a description of the expression. | +
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. |
+
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to
+the beginning of the expression. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to
+the end of the expression. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to
+the beginning of the expression. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to
+the end of the expression. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed expression. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed expression. |
+
template<class E1, class E2, class F>
- class matrix_binary:
- public matrix_expression<matrix_binary<E1, E2, F> > {
- public:
- typedef E1 expression1_type;
- typedef E2 expression2_type;
- typedef F functor_type;
- typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;
- typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;
- typedef typename F::result_type value_type;
- typedef value_type const_reference;
- typedef const_reference reference;
- typedef const value_type *const_pointer;
- typedef const_pointer pointer;
- typedef const matrix_binary<E1, E2, F> const_closure_type;
- typedef unknown_orientation_tag orientation_category;
- typedef typename E1::const_iterator1 const_iterator11_type;
- typedef typename E1::const_iterator2 const_iterator12_type;
- typedef typename E2::const_iterator1 const_iterator21_type;
- typedef typename E2::const_iterator2 const_iterator22_type;
- typedef unknown_storage_tag storage_category;
-
- // Construction and destruction
- matrix_binary ();
- matrix_binary (const E1 &e1, const E2 &e2);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- const expression1_type &expression1 () const;
- const expression2_type &expression2 () const;
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
-
- class const_iterator1;
- typedef const_iterator1 iterator1;
- class const_iterator2;
- typedef const_iterator2 iterator2;
- typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
- typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
-
- // Element lookup
- const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
- const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
- const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
- const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
-
- // Iterators enhance the iterators of the referenced expression
- // with the binary functor.
-
- class const_iterator1:
- public container_const_reference<matrix_binary>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef typename restrict_traits<typename E1::const_iterator1::iterator_category,
- typename E2::const_iterator1::iterator_category>::iterator_category iterator_category;
- typedef typename matrix_binary::difference_type difference_type;
- typedef typename matrix_binary::value_type value_type;
- typedef typename matrix_binary::const_reference reference;
- typedef typename matrix_binary::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const matrix_binary &mb, size_type i, size_type j,
- const const_iterator11_type &it1, const const_iterator11_type &it1_end,
- const const_iterator21_type &it2, const const_iterator21_type &it2_end);
-
- // Dense specializations
- void increment (dense_random_access_iterator_tag);
- void decrement (dense_random_access_iterator_tag);
- value_type dereference (dense_random_access_iterator_tag) const;
-
- // Packed specializations
- void increment (packed_random_access_iterator_tag);
- void decrement (packed_random_access_iterator_tag);
- value_type dereference (packed_random_access_iterator_tag) const;
-
- // Sparse specializations
- void increment (sparse_bidirectional_iterator_tag);
- void decrement (sparse_bidirectional_iterator_tag);
- value_type dereference (sparse_bidirectional_iterator_tag) const;
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator <(const const_iterator1 &it) const;
- };
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class const_iterator2:
- public container_const_reference<matrix_binary>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef typename restrict_traits<typename E1::const_iterator2::iterator_category,
- typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;
- typedef typename matrix_binary::difference_type difference_type;
- typedef typename matrix_binary::value_type value_type;
- typedef typename matrix_binary::const_reference reference;
- typedef typename matrix_binary::const_pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const matrix_binary &mb, size_type i, size_type j,
- const const_iterator12_type &it1, const const_iterator12_type &it1_end,
- const const_iterator22_type &it2, const const_iterator22_type &it2_end);
-
- // Dense specializations
- void increment (dense_random_access_iterator_tag);
- void decrement (dense_random_access_iterator_tag);
- value_type dereference (dense_random_access_iterator_tag) const;
-
- // Packed specializations
- void increment (packed_random_access_iterator_tag);
- void decrement (packed_random_access_iterator_tag);
- value_type dereference (packed_random_access_iterator_tag) const;
-
- // Sparse specializations
- void increment (sparse_bidirectional_iterator_tag);
- void decrement (sparse_bidirectional_iterator_tag);
- value_type dereference (sparse_bidirectional_iterator_tag) const;
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator <(const const_iterator2 &it) const;
- };
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- // Reverse iterators
-
- const_reverse_iterator1 rbegin1 () const;
- const_reverse_iterator1 rend1 () const;
-
- const_reverse_iterator2 rbegin2 () const;
- const_reverse_iterator2 rend2 () const;
- };
-
+
+ template<class E1, class E2, class F>
class matrix_binary:
public matrix_expression<matrix_binary<E1, E2, F> > {
public:
typedef E1 expression1_type;
typedef E2 expression2_type;
typedef F functor_type;
typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;
typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;
typedef typename F::result_type value_type;
typedef value_type const_reference;
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
typedef const matrix_binary<E1, E2, F> const_closure_type;
typedef unknown_orientation_tag orientation_category;
typedef typename E1::const_iterator1 const_iterator11_type;
typedef typename E1::const_iterator2 const_iterator12_type;
typedef typename E2::const_iterator1 const_iterator21_type;
typedef typename E2::const_iterator2 const_iterator22_type;
typedef unknown_storage_tag storage_category;
// Construction and destruction
matrix_binary ();
matrix_binary (const E1 &e1, const E2 &e2);
// Accessors
size_type size1 () const;
size_type size2 () const;
const expression1_type &expression1 () const;
const expression2_type &expression2 () const;
// Element access
const_reference operator () (size_type i, size_type j) const;
class const_iterator1;
typedef const_iterator1 iterator1;
class const_iterator2;
typedef const_iterator2 iterator2;
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
// Element lookup
const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
// Iterators enhance the iterators of the referenced expression
// with the binary functor.
class const_iterator1:
public container_const_reference<matrix_binary>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef typename restrict_traits<typename E1::const_iterator1::iterator_category,
typename E2::const_iterator1::iterator_category>::iterator_category iterator_category;
typedef typename matrix_binary::difference_type difference_type;
typedef typename matrix_binary::value_type value_type;
typedef typename matrix_binary::const_reference reference;
typedef typename matrix_binary::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const matrix_binary &mb, size_type i, size_type j,
const const_iterator11_type &it1, const const_iterator11_type &it1_end,
const const_iterator21_type &it2, const const_iterator21_type &it2_end);
// Dense specializations
void increment (dense_random_access_iterator_tag);
void decrement (dense_random_access_iterator_tag);
value_type dereference (dense_random_access_iterator_tag) const;
// Packed specializations
void increment (packed_random_access_iterator_tag);
void decrement (packed_random_access_iterator_tag);
value_type dereference (packed_random_access_iterator_tag) const;
// Sparse specializations
void increment (sparse_bidirectional_iterator_tag);
void decrement (sparse_bidirectional_iterator_tag);
value_type dereference (sparse_bidirectional_iterator_tag) const;
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator <(const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class const_iterator2:
public container_const_reference<matrix_binary>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef typename restrict_traits<typename E1::const_iterator2::iterator_category,
typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;
typedef typename matrix_binary::difference_type difference_type;
typedef typename matrix_binary::value_type value_type;
typedef typename matrix_binary::const_reference reference;
typedef typename matrix_binary::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const matrix_binary &mb, size_type i, size_type j,
const const_iterator12_type &it1, const const_iterator12_type &it1_end,
const const_iterator22_type &it2, const const_iterator22_type &it2_end);
// Dense specializations
void increment (dense_random_access_iterator_tag);
void decrement (dense_random_access_iterator_tag);
value_type dereference (dense_random_access_iterator_tag) const;
// Packed specializations
void increment (packed_random_access_iterator_tag);
void decrement (packed_random_access_iterator_tag);
value_type dereference (packed_random_access_iterator_tag) const;
// Sparse specializations
void increment (sparse_bidirectional_iterator_tag);
void decrement (sparse_bidirectional_iterator_tag);
value_type dereference (sparse_bidirectional_iterator_tag) const;
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator <(const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
// Reverse iterators
const_reverse_iterator1 rbegin1 () const;
const_reverse_iterator1 rend1 () const;
const_reverse_iterator2 rbegin2 () const;
const_reverse_iterator2 rend2 () const;
};
+
template<class E1, class E2, class F>
- struct matrix_binary_traits {
- typedef matrix_binary<typename E1::const_closure_type,
- typename E2::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (m1 + m2) [i] [j] = m1 [i] [j] + m2 [i] [j]
- template<class E1, class E2>
- typename matrix_binary_traits<E1, E2, scalar_plus<typename E1::value_type,
- typename E2::value_type> >::result_type
- operator + (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- // (m1 - m2) [i] [j] = m1 [i] [j] - m2 [i] [j]
- template<class E1, class E2>
- typename matrix_binary_traits<E1, E2, scalar_minus<typename E1::value_type,
- typename E2::value_type> >::result_type
- operator - (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
+
+ template<class E1, class E2, class F>
struct matrix_binary_traits {
typedef matrix_binary<typename E1::const_closure_type,
typename E2::const_closure_type, F> expression_type;
typedef expression_type result_type;
};
// (m1 + m2) [i] [j] = m1 [i] [j] + m2 [i] [j]
template<class E1, class E2>
typename matrix_binary_traits<E1, E2, scalar_plus<typename E1::value_type,
typename E2::value_type> >::result_type
operator + (const matrix_expression<E1> &e1,
const matrix_expression<E2> &e2);
// (m1 - m2) [i] [j] = m1 [i] [j] - m2 [i] [j]
template<class E1, class E2>
typename matrix_binary_traits<E1, E2, scalar_minus<typename E1::value_type,
typename E2::value_type> >::result_type
operator - (const matrix_expression<E1> &e1,
const matrix_expression<E2> &e2);
+
operator + computes the sum of two matrix
-expressions. operator - computes the difference of
-two matrix expressions.
operator + computes the sum of two matrix expressions.
+ operator - computes the difference of two matrix expressions.
Defined in the header matrix_expression.hpp.
- +E1 is a model of Matrix Expression.
- E2 is a model of Matrix Expression.
- E1 is a model of
+ Matrix Expression
+ . E2 is a model of
+ Matrix Expression
+ . e1 ().size1 () == e2 ().size1 () e1 ().size2 () == e2 ().size2 ()e1 ().size1 () == e2 ().size1 () e1 ().size2 () == e2 ().size2 ()Quadratic depending from the size of the matrix expressions.
- +int main () {
- using namespace boost::numeric::ublas;
- matrix<double > m1 (3, 3), m (3, 3);
- for (int i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
- for (int j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)
- m1 (i, j) = m2 (i, j) = 3 * i + j;
-
- std::cout << m1 + m2 << std::endl;
- std::cout << m1 - m2 << std::endl;
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>+
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m1 (3, 3), m2 (3, 3);
for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)
m1 (i, j) = m2 (i, j) = 3 * i + j;
std::cout << m1 + m2 << std::endl;
std::cout << m1 - m2 << std::endl;
}
The templated classes matrix_binary_scalar1<E1, E2,
-F> and matrix_binary_scalar2<E1, E2, F>
-describe binary operations between a scalar and a matrix.
The templated classes matrix_binary_scalar1<E1, E2, F>
+ and matrix_binary_scalar2<E1, E2, F> describe binary
+operations between a scalar and a matrix.
Defined in the header matrix_expression.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
E1/E2 |
- The type of the scalar expression. | -- |
E2/E1 |
- The type of the matrix expression. | -- |
F |
- The type of the operation. | -- |
| Parameter | +Description | +Default | +
E1/E2 |
+ The type of the scalar expression. | ++ |
E2/E1 |
+ The type of the matrix expression. | ++ |
F |
+ The type of the operation. | ++ |
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of + Matrix Expression + .
+matrix_expression<matrix_binary_scalar1<E1, E2,
-F> > and
-matrix_expression<matrix_binary_scalar2<E1, E2, F> > resp.
matrix_expression<matrix_binary_scalar1<E1, E2, F> >
+ and matrix_expression<matrix_binary_scalar2<E1, E2, F> >
+resp.
| Member | -Description | -
|---|---|
matrix_binary_scalar1 (const expression1_type
- &e1, const expression2_type &e2) |
- Constructs a description of the expression. | -
matrix_binary_scalar1 (const expression1_type
- &e1, const expression2_type &e2) |
- Constructs a description of the expression. | -
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. |
-
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the expression. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the expression. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the expression. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the expression. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed expression. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed expression. |
-
| Member | +Description | +
matrix_binary_scalar1 (const expression1_type
+ &e1, const expression2_type &e2) |
+ Constructs a description of the expression. | +
matrix_binary_scalar1 (const expression1_type
+ &e1, const expression2_type &e2) |
+ Constructs a description of the expression. | +
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. |
+
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to
+the beginning of the expression. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to
+the end of the expression. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to
+the beginning of the expression. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to
+the end of the expression. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed expression. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed expression. |
+
template<class E1, class E2, class F>
- class matrix_binary_scalar1:
- public matrix_expression<matrix_binary_scalar1<E1, E2, F> > {
- public:
- typedef E1 expression1_type;
- typedef E2 expression2_type;
- typedef F functor_type;
- typedef typename E2::size_type size_type;
- typedef typename E2::difference_type difference_type;
- typedef typename F::result_type value_type;
- typedef value_type const_reference;
- typedef const_reference reference;
- typedef const value_type *const_pointer;
- typedef const_pointer pointer;
- typedef const matrix_binary_scalar1<E1, E2, F> const_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;
- typedef typename E2::const_iterator2 const_iterator22_type;
- typedef unknown_storage_tag storage_category;
-
- // Construction and destruction
- matrix_binary_scalar1 ();
- matrix_binary_scalar1 (const expression1_type &e1, const expression2_type &e2);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- const expression1_type &expression1 () const;
- const expression2_type &expression2 () const;
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
-
- class const_iterator1;
- typedef const_iterator1 iterator1;
- class const_iterator2;
- typedef const_iterator2 iterator2;
- typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
- typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
-
- // Element lookup
- const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
- const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
- const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
- const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
-
- // Iterators enhance the iterators of the referenced expression
- // with the binary functor.
-
- class const_iterator1:
- public container_const_reference<matrix_binary_scalar1>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef typename E2::const_iterator1::iterator_category iterator_category;
- typedef typename matrix_binary_scalar1::difference_type difference_type;
- typedef typename matrix_binary_scalar1::value_type value_type;
- typedef typename matrix_binary_scalar1::const_reference reference;
- typedef typename matrix_binary_scalar1::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const matrix_binary_scalar1 &mbs, const const_iterator1_type &it1, const const_iterator21_type &it2);
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator <(const const_iterator1 &it) const;
- };
-
+
+ template<class E1, class E2, class F>
class matrix_binary_scalar1:
public matrix_expression<matrix_binary_scalar1<E1, E2, F> > {
public:
typedef E1 expression1_type;
typedef E2 expression2_type;
typedef F functor_type;
typedef typename E2::size_type size_type;
typedef typename E2::difference_type difference_type;
typedef typename F::result_type value_type;
typedef value_type const_reference;
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
typedef const matrix_binary_scalar1<E1, E2, F> const_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;
typedef typename E2::const_iterator2 const_iterator22_type;
typedef unknown_storage_tag storage_category;
// Construction and destruction
matrix_binary_scalar1 ();
matrix_binary_scalar1 (const expression1_type &e1, const expression2_type &e2);
// Accessors
size_type size1 () const;
size_type size2 () const;
const expression1_type &expression1 () const;
const expression2_type &expression2 () const;
// Element access
const_reference operator () (size_type i, size_type j) const;
class const_iterator1;
typedef const_iterator1 iterator1;
class const_iterator2;
typedef const_iterator2 iterator2;
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
// Element lookup
const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
// Iterators enhance the iterators of the referenced expression
// with the binary functor.
class const_iterator1:
public container_const_reference<matrix_binary_scalar1>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef typename E2::const_iterator1::iterator_category iterator_category;
typedef typename matrix_binary_scalar1::difference_type difference_type;
typedef typename matrix_binary_scalar1::value_type value_type;
typedef typename matrix_binary_scalar1::const_reference reference;
typedef typename matrix_binary_scalar1::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const matrix_binary_scalar1 &mbs, const const_iterator1_type &it1, const const_iterator21_type &it2);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator <(const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
@@ -1719,1284 +947,468 @@ matrix_expression<matrix_binary_scalar2<E1, E2, F> > resp.
-
+ const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
// Iterators enhance the iterators of the referenced expression
// with the binary functor.
class const_iterator1:
public container_const_reference<matrix_binary_scalar2>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef typename E1::const_iterator1::iterator_category iterator_category;
typedef typename matrix_binary_scalar2::difference_type difference_type;
typedef typename matrix_binary_scalar2::value_type value_type;
typedef typename matrix_binary_scalar2::const_reference reference;
typedef typename matrix_binary_scalar2::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const matrix_binary_scalar2 &mbs, const const_iterator11_type &it1, const const_iterator2_type &it2);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator <(const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class const_iterator2:
public container_const_reference<matrix_binary_scalar2>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef typename E1::const_iterator2::iterator_category iterator_category;
typedef typename matrix_binary_scalar2::difference_type difference_type;
typedef typename matrix_binary_scalar2::value_type value_type;
typedef typename matrix_binary_scalar2::const_reference reference;
typedef typename matrix_binary_scalar2::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const matrix_binary_scalar2 &mbs, const const_iterator12_type &it1, const const_iterator2_type &it2);
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator <(const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
// Reverse iterators
const_reverse_iterator1 rbegin1 () const;
const_reverse_iterator1 rend1 () const;
const_reverse_iterator2 rbegin2 () const;
const_reverse_iterator2 rend2 () const;
};
+
template<class T1, class E2, class F>
- struct matrix_binary_scalar1_traits {
- typedef matrix_binary_scalar1<scalar_const_reference<T1>,
- typename E2::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (t * m) [i] [j] = t * m [i] [j]
- template<class T1, class E2>
- typename matrix_binary_scalar1_traits<T1, E2, scalar_multiplies<T1, typename E2::value_type> >::result_type
- operator * (const T1 &e1,
- const matrix_expression<E2> &e2);
-
- template<class E1, class T2, class F>
- struct matrix_binary_scalar2_traits {
- typedef matrix_binary_scalar2<typename E1::const_closure_type,
- scalar_const_reference<T2>, F> expression_type;
- typedef expression_type result_type;
- };
-
- // (m * t) [i] [j] = m [i] [j] * t
- template<class E1, class T2>
- typename matrix_binary_scalar2_traits<E1, T2, scalar_multiplies<typename E1::value_type, T2> >::result_type
- operator * (const matrix_expression<E1> &e1,
- const T2 &e2);
-
- // (m / t) [i] [j] = m [i] [j] / t
- template<class E1, class T2>
- typename matrix_binary_scalar2_traits<E1, T2, scalar_divides<typename E1::value_type, T2> >::result_type
- operator / (const matrix_expression<E1> &e1,
- const T2 &e2);
-
+
+ template<class T1, class E2, class F>
struct matrix_binary_scalar1_traits {
typedef matrix_binary_scalar1<scalar_const_reference<T1>,
typename E2::const_closure_type, F> expression_type;
typedef expression_type result_type;
};
// (t * m) [i] [j] = t * m [i] [j]
template<class T1, class E2>
typename matrix_binary_scalar1_traits<T1, E2, scalar_multiplies<T1, typename E2::value_type> >::result_type
operator * (const T1 &e1,
const matrix_expression<E2> &e2);
template<class E1, class T2, class F>
struct matrix_binary_scalar2_traits {
typedef matrix_binary_scalar2<typename E1::const_closure_type,
scalar_const_reference<T2>, F> expression_type;
typedef expression_type result_type;
};
// (m * t) [i] [j] = m [i] [j] * t
template<class E1, class T2>
typename matrix_binary_scalar2_traits<E1, T2, scalar_multiplies<typename E1::value_type, T2> >::result_type
operator * (const matrix_expression<E1> &e1,
const T2 &e2);
// (m / t) [i] [j] = m [i] [j] / t
template<class E1, class T2>
typename matrix_binary_scalar2_traits<E1, T2, scalar_divides<typename E1::value_type, T2> >::result_type
operator / (const matrix_expression<E1> &e1,
const T2 &e2);
+
operator * computes the product of a scalar and a
-matrix expression. operator / multiplies the matrix
-with the reciprocal of the scalar.
operator * computes the product of a scalar and a matrix expression.
+operator / multiplies the matrix with the reciprocal of the
+scalar.
Defined in the header matrix_expression.hpp.
- +T1/T2 is a model of Scalar Expression.
- E2/E1 is a model of Matrix Expression.T1/T2 is a model of
+ Scalar Expression
+ . E2/E1 is a model of
+ Matrix Expression
+ .None.
- +Quadratic depending from the size of the matrix expression.
- +int main () {
- using namespace boost::numeric::ublas;
- matrix<double > m (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 << 2.0 * m << std::endl;
- std::cout << m * 2.0 << std::endl;
-}
-
- template<class M>
- matrix_row<M> row (M &data, std::size_t i);
-
- template<class M>
- matrix_column<M> column (M &data, std::size_t j);
-
-row returns the the i-th row of a
-matrix expression. column returns the the j-th row
-of a matrix expression.
Defined in the header matrix_proxy.hpp.
- -E is a model of Matrix Expression.i < e ().size1 () j < e ().size2 ()Linear depending from the size of the matrix expression.
- -int main () {
- using namespace boost::numeric::ublas;
- matrix<double > m (3, 3);
- for (int i = 0; i < m.size1 (); ++ i)
- for (int j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
-
- for (int i = 0; i < m.size1 (); ++ i)
- std::cout << row (m, i) << std::endl;
- for (int j = 0; j < m.size2 (); ++ j)
- std::cout << column (m, j) << std::endl;
-}
-
-#include <boost/numeric/ublas/matrix.hpp>+ + + + + +
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned j = 0; j < m.size2 (); ++ j)
m (i, j) = 3 * i + j;
std::cout << 2.0 * m << std::endl;
std::cout << m * 2.0 << std::endl;
}
The templated classes matrix_vector_binary1<E1, E2,
-F> and matrix_vector_binary2<E1, E2, F> describe
-binary matrix vector operations.
The templated classes matrix_vector_binary1<E1, E2, F>
+ and matrix_vector_binary2<E1, E2, F> describe binary
+matrix vector operations.
Defined in the header matrix_expression.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
E1 |
- The type of the matrix or vector expression. | -- |
E2 |
- The type of the vector or matrix expression. | -- |
F |
- The type of the operation. | -- |
| Parameter | +Description | +Default | +
E1 |
+ The type of the matrix or vector expression. | ++ |
E2 |
+ The type of the vector or matrix expression. | ++ |
F |
+ The type of the operation. | ++ |
None, except for those imposed by the requirements of Vector Expression.
- + +None, except for those imposed by the requirements of + Vector Expression + .
+vector_expression<matrix_vector_binary1<E1, E2,
-F> > and vector_expression<matrix_vector_binary2<E1,
-E2, F> > resp.
vector_expression<matrix_vector_binary1<E1, E2, F> >
+ and vector_expression<matrix_vector_binary2<E1, E2, F> >
+ resp.
| Member | -Description | -
|---|---|
matrix_vector_binary1 (const expression1_type
- &e1, const expression2_type &e2) |
- Constructs a description of the expression. | -
matrix_vector_binary2 (const expression1_type
- &e1, const expression2_type &e2) |
- Constructs a description of the expression. | -
size_type size () const |
- Returns the size of the expression. | -
const_reference operator () (size_type i) const |
- Returns the value of the i-th element. |
-
const_iterator begin () const |
- Returns a const_iterator pointing to the
- beginning of the expression. |
-
const_iterator end () const |
- Returns a const_iterator pointing to the
- end of the expression. |
-
const_reverse_iterator rbegin () const |
- Returns a const_reverse_iterator
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator rend () const |
- Returns a const_reverse_iterator
- pointing to the end of the reversed expression. |
-
| Member | +Description | +
matrix_vector_binary1 (const expression1_type
+ &e1, const expression2_type &e2) |
+ Constructs a description of the expression. | +
matrix_vector_binary2 (const expression1_type
+ &e1, const expression2_type &e2) |
+ Constructs a description of the expression. | +
size_type size () const |
+ Returns the size of the expression. | +
const_reference operator () (size_type i) const |
+ Returns the value of the i-th element. |
+
const_iterator begin () const |
+ Returns a const_iterator pointing to the
+ beginning of the expression. |
+
const_iterator end () const |
+ Returns a const_iterator pointing to the
+ end of the expression. |
+
const_reverse_iterator rbegin () const |
+ Returns a const_reverse_iterator pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator rend () const |
+ Returns a const_reverse_iterator pointing
+to the end of the reversed expression. |
+
template<class E1, class E2, class F>
- class matrix_vector_binary1:
- public vector_expression<matrix_vector_binary1<E1, E2, F> > {
- public:
- typedef E1 expression1_type;
- typedef E2 expression2_type;
- typedef F functor_type;
- typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;
- typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;
- typedef typename F::result_type value_type;
- typedef value_type const_reference;
- typedef const_reference reference;
- typedef const value_type *const_pointer;
- typedef const_pointer pointer;
- typedef const matrix_vector_binary1<E1, E2, F> const_closure_type;
- typedef typename E1::const_iterator1 const_iterator1_type;
- typedef typename E2::const_iterator const_iterator2_type;
- typedef unknown_storage_tag storage_category;
-
- // Construction and destruction
- matrix_vector_binary1 ();
- matrix_vector_binary1 (const expression1_type &e1, const expression2_type &e2);
-
- // Accessors
- size_type size () const;
- const expression1_type &expression1 () const;
- const expression2_type &expression2 () const;
-
- // Element access
- const_reference operator () (size_type i) const;
-
- class const_iterator;
- typedef const_iterator iterator;
-
- // Element lookup
- const_iterator find_first (size_type i) const;
- const_iterator find_last (size_type i) const;
-
- // Iterator simply is a pointer.
-
- class const_iterator:
- public container_const_reference<matrix_vector_binary1>,
- public random_access_iterator_base<const_iterator, value_type> {
- public:
- typedef typename restrict_traits<typename E1::const_iterator1::iterator_category,
- typename E2::const_iterator::iterator_category>::iterator_category iterator_category;
- typedef typename matrix_vector_binary1::difference_type difference_type;
- typedef typename matrix_vector_binary1::value_type value_type;
- typedef typename matrix_vector_binary1::const_reference reference;
- typedef typename matrix_vector_binary1::const_pointer pointer;
-
- // Construction and destruction
- const_iterator ();
- const_iterator (const matrix_vector_binary1 &mvb, const const_iterator1_type &it1);
-
- // Dense random access specialization
- value_type dereference (dense_random_access_iterator_tag) const;
-
- // Packed bidirectional specialization
- value_type dereference (packed_bidirectional_iterator_tag) const;
-
- // Sparse bidirectional specialization
- value_type dereference (sparse_bidirectional_iterator_tag) const;
-
- // Arithmetic
- const_iterator &operator ++ ();
- const_iterator &operator -- ();
- const_iterator &operator += (difference_type n);
- const_iterator &operator -= (difference_type n);
- difference_type operator - (const const_iterator &it) const;
-
- // 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;
- bool operator <(const const_iterator &it) const;
- };
-
- const_iterator begin () const;
- const_iterator end () const;
-
- // Reverse iterator
-
- typedef reverse_iterator_base<const_iterator> const_reverse_iterator;
-
- const_reverse_iterator rbegin () const;
- const_reverse_iterator rend () const;
- };
-
- template<class E1, class E2, class F>
- class matrix_vector_binary2:
- public vector_expression<matrix_vector_binary2<E1, E2, F> > {
- public:
- typedef E1 expression1_type;
- typedef E2 expression2_type;
- typedef F functor_type;
- typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;
- typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;
- typedef typename F::result_type value_type;
- typedef value_type const_reference;
- typedef const_reference reference;
- typedef const value_type *const_pointer;
- typedef const_pointer pointer;
- typedef const matrix_vector_binary2<E1, E2, F> const_closure_type;
- typedef typename E1::const_iterator const_iterator1_type;
- typedef typename E2::const_iterator2 const_iterator2_type;
- typedef unknown_storage_tag storage_category;
-
- // Construction and destruction
- matrix_vector_binary2 ();
- matrix_vector_binary2 (const expression1_type &e1, const expression2_type &e2);
-
- // Accessors
- size_type size () const;
- const expression1_type &expression1 () const;
- const expression2_type &expression2 () const;
-
- // Element access
- const_reference operator () (size_type j) const;
-
- class const_iterator;
- typedef const_iterator iterator;
-
- // Element lookup
- const_iterator find_first (size_type j) const;
- const_iterator find_last (size_type j) const;
-
- // Iterator simply is a pointer.
-
- class const_iterator:
- public container_const_reference<matrix_vector_binary2>,
- public random_access_iterator_base<const_iterator, value_type> {
- public:
- typedef typename restrict_traits<typename E1::const_iterator::iterator_category,
- typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;
- typedef typename matrix_vector_binary2::difference_type difference_type;
- typedef typename matrix_vector_binary2::value_type value_type;
- typedef typename matrix_vector_binary2::const_reference reference;
- typedef typename matrix_vector_binary2::const_pointer pointer;
-
- // Construction and destruction
- const_iterator ();
- const_iterator (const matrix_vector_binary2 &mvb, const const_iterator2_type &it2);
-
- // Dense random access specialization
- value_type dereference (dense_random_access_iterator_tag) const;
-
- // Packed bidirectional specialization
- value_type dereference (packed_bidirectional_iterator_tag) const;
-
- // Sparse bidirectional specialization
- value_type dereference (sparse_bidirectional_iterator_tag) const;
-
- // Arithmetic
- const_iterator &operator ++ ();
- const_iterator &operator -- ();
- const_iterator &operator += (difference_type n);
- const_iterator &operator -= (difference_type n);
- difference_type operator - (const const_iterator &it) const;
-
- // 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;
- bool operator <(const const_iterator &it) const;
- };
-
- const_iterator begin () const;
- const_iterator end () const;
-
- // Reverse iterator
-
- typedef reverse_iterator_base<const_iterator> const_reverse_iterator;
-
- const_reverse_iterator rbegin () const;
- const_reverse_iterator rend () const;
- };
-
+
+ template<class E1, class E2, class F>
class matrix_vector_binary1:
public vector_expression<matrix_vector_binary1<E1, E2, F> > {
public:
typedef E1 expression1_type;
typedef E2 expression2_type;
typedef F functor_type;
typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;
typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;
typedef typename F::result_type value_type;
typedef value_type const_reference;
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
typedef const matrix_vector_binary1<E1, E2, F> const_closure_type;
typedef typename E1::const_iterator1 const_iterator1_type;
typedef typename E2::const_iterator const_iterator2_type;
typedef unknown_storage_tag storage_category;
// Construction and destruction
matrix_vector_binary1 ();
matrix_vector_binary1 (const expression1_type &e1, const expression2_type &e2);
// Accessors
size_type size () const;
const expression1_type &expression1 () const;
const expression2_type &expression2 () const;
// Element access
const_reference operator () (size_type i) const;
class const_iterator;
typedef const_iterator iterator;
// Element lookup
const_iterator find_first (size_type i) const;
const_iterator find_last (size_type i) const;
// Iterator simply is a pointer.
class const_iterator:
public container_const_reference<matrix_vector_binary1>,
public random_access_iterator_base<const_iterator, value_type> {
public:
typedef typename restrict_traits<typename E1::const_iterator1::iterator_category,
typename E2::const_iterator::iterator_category>::iterator_category iterator_category;
typedef typename matrix_vector_binary1::difference_type difference_type;
typedef typename matrix_vector_binary1::value_type value_type;
typedef typename matrix_vector_binary1::const_reference reference;
typedef typename matrix_vector_binary1::const_pointer pointer;
// Construction and destruction
const_iterator ();
const_iterator (const matrix_vector_binary1 &mvb, const const_iterator1_type &it1);
// Dense random access specialization
value_type dereference (dense_random_access_iterator_tag) const;
// Packed bidirectional specialization
value_type dereference (packed_bidirectional_iterator_tag) const;
// Sparse bidirectional specialization
value_type dereference (sparse_bidirectional_iterator_tag) const;
// Arithmetic
const_iterator &operator ++ ();
const_iterator &operator -- ();
const_iterator &operator += (difference_type n);
const_iterator &operator -= (difference_type n);
difference_type operator - (const const_iterator &it) const;
// 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;
bool operator <(const const_iterator &it) const;
};
const_iterator begin () const;
const_iterator end () const;
// Reverse iterator
typedef reverse_iterator_base<const_iterator> const_reverse_iterator;
const_reverse_iterator rbegin () const;
const_reverse_iterator rend () const;
};
template<class E1, class E2, class F>
class matrix_vector_binary2:
public vector_expression<matrix_vector_binary2<E1, E2, F> > {
public:
typedef E1 expression1_type;
typedef E2 expression2_type;
typedef F functor_type;
typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;
typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;
typedef typename F::result_type value_type;
typedef value_type const_reference;
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
typedef const matrix_vector_binary2<E1, E2, F> const_closure_type;
typedef typename E1::const_iterator const_iterator1_type;
typedef typename E2::const_iterator2 const_iterator2_type;
typedef unknown_storage_tag storage_category;
// Construction and destruction
matrix_vector_binary2 ();
matrix_vector_binary2 (const expression1_type &e1, const expression2_type &e2);
// Accessors
size_type size () const;
const expression1_type &expression1 () const;
const expression2_type &expression2 () const;
// Element access
const_reference operator () (size_type j) const;
class const_iterator;
typedef const_iterator iterator;
// Element lookup
const_iterator find_first (size_type j) const;
const_iterator find_last (size_type j) const;
// Iterator simply is a pointer.
class const_iterator:
public container_const_reference<matrix_vector_binary2>,
public random_access_iterator_base<const_iterator, value_type> {
public:
typedef typename restrict_traits<typename E1::const_iterator::iterator_category,
typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;
typedef typename matrix_vector_binary2::difference_type difference_type;
typedef typename matrix_vector_binary2::value_type value_type;
typedef typename matrix_vector_binary2::const_reference reference;
typedef typename matrix_vector_binary2::const_pointer pointer;
// Construction and destruction
const_iterator ();
const_iterator (const matrix_vector_binary2 &mvb, const const_iterator2_type &it2);
// Dense random access specialization
value_type dereference (dense_random_access_iterator_tag) const;
// Packed bidirectional specialization
value_type dereference (packed_bidirectional_iterator_tag) const;
// Sparse bidirectional specialization
value_type dereference (sparse_bidirectional_iterator_tag) const;
// Arithmetic
const_iterator &operator ++ ();
const_iterator &operator -- ();
const_iterator &operator += (difference_type n);
const_iterator &operator -= (difference_type n);
difference_type operator - (const const_iterator &it) const;
// 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;
bool operator <(const const_iterator &it) const;
};
const_iterator begin () const;
const_iterator end () const;
// Reverse iterator
typedef reverse_iterator_base<const_iterator> const_reverse_iterator;
const_reverse_iterator rbegin () const;
const_reverse_iterator rend () const;
};
+
template<class T1, class E1, class T2, class E2>
- struct matrix_vector_binary1_traits {
- typedef row_major_tag dispatch_category;
- typedef typename promote_traits<T1, T2>::promote_type promote_type;
- typedef matrix_vector_binary1<typename E1::const_closure_type,
- typename E2::const_closure_type,
- matrix_vector_prod1<T1, T2, promote_type> > expression_type;
- typedef expression_type result_type;
- };
-
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2,
- row_major_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
-
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2,
- row_major_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
-
- template<class V, class E1, class E2>
- V
- prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
-
- template<class V, class E1, class E2>
- V
- prec_prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
-
- template<class T1, class E1, class T2, class E2>
- struct matrix_vector_binary2_traits {
- typedef column_major_tag dispatch_category;
- typedef typename promote_traits<T1, T2>::promote_type promote_type;
- typedef matrix_vector_binary2<typename E1::const_closure_type,
- typename E2::const_closure_type,
- matrix_vector_prod2<T1, T2, promote_type> > expression_type;
- typedef expression_type result_type;
- };
-
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- column_major_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- column_major_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class V, class E1, class E2>
- V
- prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class V, class E1, class E2>
- V
- prec_prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
+
+ template<class T1, class E1, class T2, class E2>
struct matrix_vector_binary1_traits {
typedef row_major_tag dispatch_category;
typedef typename promote_traits<T1, T2>::promote_type promote_type;
typedef matrix_vector_binary1<typename E1::const_closure_type,
typename E2::const_closure_type,
matrix_vector_prod1<T1, T2, promote_type> > expression_type;
typedef expression_type result_type;
};
template<class E1, class E2>
typename matrix_vector_binary1_traits<typename E1::value_type, E1,
typename E2::value_type, E2>::result_type
prod (const matrix_expression<E1> &e1,
const vector_expression<E2> &e2,
row_major_tag);
// Dispatcher
template<class E1, class E2>
typename matrix_vector_binary1_traits<typename E1::value_type, E1,
typename E2::value_type, E2>::result_type
prod (const matrix_expression<E1> &e1,
const vector_expression<E2> &e2);
template<class E1, class E2>
typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
prec_prod (const matrix_expression<E1> &e1,
const vector_expression<E2> &e2,
row_major_tag);
// Dispatcher
template<class E1, class E2>
typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
prec_prod (const matrix_expression<E1> &e1,
const vector_expression<E2> &e2);
template<class V, class E1, class E2>
V
prod (const matrix_expression<E1> &e1,
const vector_expression<E2> &e2);
template<class V, class E1, class E2>
V
prec_prod (const matrix_expression<E1> &e1,
const vector_expression<E2> &e2);
template<class T1, class E1, class T2, class E2>
struct matrix_vector_binary2_traits {
typedef column_major_tag dispatch_category;
typedef typename promote_traits<T1, T2>::promote_type promote_type;
typedef matrix_vector_binary2<typename E1::const_closure_type,
typename E2::const_closure_type,
matrix_vector_prod2<T1, T2, promote_type> > expression_type;
typedef expression_type result_type;
};
template<class E1, class E2>
typename matrix_vector_binary2_traits<typename E1::value_type, E1,
typename E2::value_type, E2>::result_type
prod (const vector_expression<E1> &e1,
const matrix_expression<E2> &e2,
column_major_tag);
// Dispatcher
template<class E1, class E2>
typename matrix_vector_binary2_traits<typename E1::value_type, E1,
typename E2::value_type, E2>::result_type
prod (const vector_expression<E1> &e1,
const matrix_expression<E2> &e2);
template<class E1, class E2>
typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
prec_prod (const vector_expression<E1> &e1,
const matrix_expression<E2> &e2,
column_major_tag);
// Dispatcher
template<class E1, class E2>
typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
prec_prod (const vector_expression<E1> &e1,
const matrix_expression<E2> &e2);
template<class V, class E1, class E2>
V
prod (const vector_expression<E1> &e1,
const matrix_expression<E2> &e2);
template<class V, class E1, class E2>
V
prec_prod (const vector_expression<E1> &e1,
const matrix_expression<E2> &e2);
+
prod computes the product of the matrix and the
-vector expression. prec_prod computes the double
-precision product of the matrix and the vector expression.
prod computes the product of the matrix and the vector expression.
+ prec_prod computes the double precision product of the matrix and
+the vector expression.
Defined in the header matrix_expression.hpp.
- +E1 is a model of Matrix Expression or
- Vector
- Expression. E2 is a model of Vector Expression
- or Matrix
- Expression.E1 is a model of
+ Matrix Expression
+ or Vector
+ Expression
+ . E2 is a model of
+ Vector Expression
+ or Matrix Expression
+ .e1 ().size2 () == e2 ().size () e1 ().size () == e2 ().size1 ()e1 ().size2 () == e2 ().size () e1 ().size () == e2 ().size1 ()Quadratic depending from the size of the matrix expression.
- +int main () {
- using namespace boost::numeric::ublas;
- matrix<double > m (3, 3), v (3);
- for (int i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {
- for (int j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
- v (i) = i
- }
-
- std::cout << prod (m, v) << std::endl;
- std::cout << prod (v, m) << std::endl;
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>+
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
vector<double> v (3);
for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {
for (unsigned j = 0; j < m.size2 (); ++ j)
m (i, j) = 3 * i + j;
v (i) = i;
}
std::cout << prod (m, v) << std::endl;
std::cout << prod (v, m) << std::endl;
}
template<class E1, class E2>
- struct matrix_vector_solve_traits {
- typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;
- typedef vector<promote_type> result_type;
- };
-
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- lower_tag,
- vector_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- upper_tag,
- vector_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_lower_tag,
- vector_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_upper_tag,
- vector_tag);
-
- template<class E1, class E2, class C>
- typename matrix_vector_solve_traits<E1, E2>::result_type
- solve (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2,
- C);
-
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- lower_tag);
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- upper_tag);
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- unit_lower_tag);
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- unit_upper_tag);
-
- template<class E1, class E2, class C>
- typename matrix_vector_solve_traits<E1, E2>::result_type
- solve (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- C);
-
+
+ template<class E1, class E2>
struct matrix_vector_solve_traits {
typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;
typedef vector<promote_type> result_type;
};
template<class E1, class E2>
void inplace_solve (const matrix_expression<E1> &e1,
E2 &e2,
lower_tag,
vector_tag);
template<class E1, class E2>
void inplace_solve (const matrix_expression<E1> &e1,
E2 &e2,
upper_tag,
vector_tag);
template<class E1, class E2>
void inplace_solve (const matrix_expression<E1> &e1,
E2 &e2,
unit_lower_tag,
vector_tag);
template<class E1, class E2>
void inplace_solve (const matrix_expression<E1> &e1,
E2 &e2,
unit_upper_tag,
vector_tag);
template<class E1, class E2, class C>
typename matrix_vector_solve_traits<E1, E2>::result_type
solve (const matrix_expression<E1> &e1,
const vector_expression<E2> &e2,
C);
template<class E1, class E2>
void inplace_solve (E1 &e1,
const matrix_expression<E2> &e2,
vector_tag,
lower_tag);
template<class E1, class E2>
void inplace_solve (E1 &e1,
const matrix_expression<E2> &e2,
vector_tag,
upper_tag);
template<class E1, class E2>
void inplace_solve (E1 &e1,
const matrix_expression<E2> &e2,
vector_tag,
unit_lower_tag);
template<class E1, class E2>
void inplace_solve (E1 &e1,
const matrix_expression<E2> &e2,
vector_tag,
unit_upper_tag);
template<class E1, class E2, class C>
typename matrix_vector_solve_traits<E1, E2>::result_type
solve (const vector_expression<E1> &e1,
const matrix_expression<E2> &e2,
C);
+
solve solves a linear equation for lower or upper
-(unit) triangular matrices.
solve solves a linear equation for lower or upper (unit) triangular
+matrices.
Defined in the header triangular.hpp.
- +E1 is a model of Matrix Expression
- or Vector
- Expression. E2 is a model of Vector Expression
- or Matrix
- Expression.E1 is a model of
+ Matrix Expression
+ or Vector Expression
+ . E2 is a model of
+ Vector Expression
+ or Matrix Expression
+ .e1 ().size1 () == e1 ().size2 () e1 ().size2 () == e2 ().size () e1 ().size () == e2 ().size1 () e2 ().size1 () == e2 ().size2 ()e1 ().size1 () == e1 ().size2 () e1 ().size2 () == e2 ().size () e1 ().size () == e2 ().size1 () e2 ().size1 () == e2 ().size2 ()Quadratic depending from the size of the matrix expression.
- +int main () {
- using namespace boost::numeric::ublas;
- matrix<double > m (3, 3), v (3);
- for (int i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {
- for (int j = 0; j <= i; ++ j)
- m (i, j) = 3 * i + j;
- v (i) = i
- }
-
- std::cout << solve (m, v, lower_tag ()) << std::endl;
- std::cout << solve (v, m, lower_tag ()) << std::endl;
-}
-
-#include <boost/numeric/ublas/triangular.hpp>+ +
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
vector<double> v (3);
for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {
for (unsigned j = 0; j <= i; ++ j)
m (i, j) = 3 * i + j + 1;
v (i) = i;
}
std::cout << solve (m, v, lower_tag ()) << std::endl;
std::cout << solve (v, m, lower_tag ()) << std::endl;
}
The templated class matrix_matrix_binary<E1, E2,
-F> describes a binary matrix operation.
The templated class matrix_matrix_binary<E1, E2, F>
+ describes a binary matrix operation.
Defined in the header matrix_expression.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
E1 |
- The type of the first matrix expression. | -- |
E2 |
- The type of the second matrix expression. | -- |
F |
- The type of the operation. | -- |
| Parameter | +Description | +Default | +
E1 |
+ The type of the first matrix expression. | ++ |
E2 |
+ The type of the second matrix expression. | ++ |
F |
+ The type of the operation. | ++ |
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of + Matrix Expression + .
+matrix_expression<matrix_matrix_binary<E1, E2,
-F> >.
matrix_expression<matrix_matrix_binary<E1, E2, F> >
+ .
| Member | -Description | -
|---|---|
matrix_matrix_binary (const expression1_type
- &e1, const expression2_type &e2) |
- Constructs a description of the expression. | -
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. |
-
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the expression. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the expression. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the expression. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the expression. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed expression. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed expression. |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed expression. |
-
| Member | +Description | +
matrix_matrix_binary (const expression1_type
+&e1, const expression2_type &e2) |
+ Constructs a description of the expression. | +
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. |
+
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to
+the beginning of the expression. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to
+the end of the expression. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to
+the beginning of the expression. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to
+the end of the expression. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed expression. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed expression. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed expression. |
+
template<class E1, class E2, class F>
- class matrix_matrix_binary:
- public matrix_expression<matrix_matrix_binary<E1, E2, F> > {
- public:
- typedef E1 expression1_type;
- typedef E2 expression2_type;
- typedef F functor_type;
- typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;
- typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;
- typedef typename F::result_type value_type;
- typedef value_type const_reference;
- typedef const_reference reference;
- typedef const value_type *const_pointer;
- typedef const_pointer pointer;
- typedef const matrix_matrix_binary<E1, E2, F> const_closure_type;
- typedef unknown_orientation_tag orientation_category;
- typedef typename E1::const_iterator1 const_iterator11_type;
- typedef typename E1::const_iterator2 const_iterator12_type;
- typedef typename E2::const_iterator1 const_iterator21_type;
- typedef typename E2::const_iterator2 const_iterator22_type;
- typedef unknown_storage_tag storage_category;
-
- // Construction and destruction
- matrix_matrix_binary ();
- matrix_matrix_binary (const expression1_type &e1, const expression2_type &e2);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- const expression1_type &expression1 () const;
- const expression2_type &expression2 () const;
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
-
- class const_iterator1;
- typedef const_iterator1 iterator1;
- class const_iterator2;
- typedef const_iterator2 iterator2;
- typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
- typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
-
- // Element lookup
- const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
- const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
- const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
- const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
-
- // Iterators simply are pointers.
-
- class const_iterator1:
- public container_const_reference<matrix_matrix_binary>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef typename restrict_traits<typename E1::const_iterator1::iterator_category,
- typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;
- typedef typename matrix_matrix_binary::difference_type difference_type;
- typedef typename matrix_matrix_binary::value_type value_type;
- typedef typename matrix_matrix_binary::const_reference reference;
- typedef typename matrix_matrix_binary::const_pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const matrix_matrix_binary &mmb, const const_iterator11_type &it1, const const_iterator22_type &it2);
-
- // Random access specialization
- value_type dereference (dense_random_access_iterator_tag) const;
-
- // Packed bidirectional specialization
- value_type dereference (packed_bidirectional_iterator_tag) const;
-
- // Sparse bidirectional specialization
- value_type dereference (sparse_bidirectional_iterator_tag) const;
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator <(const const_iterator1 &it) const;
- };
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class const_iterator2:
- public container_const_reference<matrix_matrix_binary>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef typename restrict_traits<typename E1::const_iterator1::iterator_category,
- typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;
- typedef typename matrix_matrix_binary::difference_type difference_type;
- typedef typename matrix_matrix_binary::value_type value_type;
- typedef typename matrix_matrix_binary::const_reference reference;
- typedef typename matrix_matrix_binary::const_pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const matrix_matrix_binary &mmb, const const_iterator11_type &it1, const const_iterator22_type &it2);
-
- // Random access specialization
- value_type dereference (dense_random_access_iterator_tag) const;
-
- // Packed bidirectional specialization
- value_type dereference (packed_bidirectional_iterator_tag) const;
-
- // Sparse bidirectional specialization
- value_type dereference (sparse_bidirectional_iterator_tag) const;
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator <(const const_iterator2 &it) const;
- };
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- // Reverse iterators
-
- const_reverse_iterator1 rbegin1 () const;
- const_reverse_iterator1 rend1 () const;
-
- const_reverse_iterator2 rbegin2 () const;
- const_reverse_iterator2 rend2 () const;
- };
-
+
+ template<class E1, class E2, class F>
class matrix_matrix_binary:
public matrix_expression<matrix_matrix_binary<E1, E2, F> > {
public:
typedef E1 expression1_type;
typedef E2 expression2_type;
typedef F functor_type;
typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;
typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;
typedef typename F::result_type value_type;
typedef value_type const_reference;
typedef const_reference reference;
typedef const value_type *const_pointer;
typedef const_pointer pointer;
typedef const matrix_matrix_binary<E1, E2, F> const_closure_type;
typedef unknown_orientation_tag orientation_category;
typedef typename E1::const_iterator1 const_iterator11_type;
typedef typename E1::const_iterator2 const_iterator12_type;
typedef typename E2::const_iterator1 const_iterator21_type;
typedef typename E2::const_iterator2 const_iterator22_type;
typedef unknown_storage_tag storage_category;
// Construction and destruction
matrix_matrix_binary ();
matrix_matrix_binary (const expression1_type &e1, const expression2_type &e2);
// Accessors
size_type size1 () const;
size_type size2 () const;
const expression1_type &expression1 () const;
const expression2_type &expression2 () const;
// Element access
const_reference operator () (size_type i, size_type j) const;
class const_iterator1;
typedef const_iterator1 iterator1;
class const_iterator2;
typedef const_iterator2 iterator2;
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
// Element lookup
const_iterator1 find_first1 (int rank, size_type i, size_type j) const;
const_iterator1 find_last1 (int rank, size_type i, size_type j) const;
const_iterator2 find_first2 (int rank, size_type i, size_type j) const;
const_iterator2 find_last2 (int rank, size_type i, size_type j) const;
// Iterators simply are pointers.
class const_iterator1:
public container_const_reference<matrix_matrix_binary>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef typename restrict_traits<typename E1::const_iterator1::iterator_category,
typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;
typedef typename matrix_matrix_binary::difference_type difference_type;
typedef typename matrix_matrix_binary::value_type value_type;
typedef typename matrix_matrix_binary::const_reference reference;
typedef typename matrix_matrix_binary::const_pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const matrix_matrix_binary &mmb, const const_iterator11_type &it1, const const_iterator22_type &it2);
// Random access specialization
value_type dereference (dense_random_access_iterator_tag) const;
// Packed bidirectional specialization
value_type dereference (packed_bidirectional_iterator_tag) const;
// Sparse bidirectional specialization
value_type dereference (sparse_bidirectional_iterator_tag) const;
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator <(const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class const_iterator2:
public container_const_reference<matrix_matrix_binary>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef typename restrict_traits<typename E1::const_iterator1::iterator_category,
typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;
typedef typename matrix_matrix_binary::difference_type difference_type;
typedef typename matrix_matrix_binary::value_type value_type;
typedef typename matrix_matrix_binary::const_reference reference;
typedef typename matrix_matrix_binary::const_pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const matrix_matrix_binary &mmb, const const_iterator11_type &it1, const const_iterator22_type &it2);
// Random access specialization
value_type dereference (dense_random_access_iterator_tag) const;
// Packed bidirectional specialization
value_type dereference (packed_bidirectional_iterator_tag) const;
// Sparse bidirectional specialization
value_type dereference (sparse_bidirectional_iterator_tag) const;
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator <(const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
// Reverse iterators
const_reverse_iterator1 rbegin1 () const;
const_reverse_iterator1 rend1 () const;
const_reverse_iterator2 rbegin2 () const;
const_reverse_iterator2 rend2 () const;
};
+
template<class T1, class E1, class T2, class E2>
- struct matrix_matrix_binary_traits {
- typedef unknown_orientation_tag dispatch_category;
- typedef typename promote_traits<T1, T2>::promote_type promote_type;
- typedef matrix_matrix_binary<typename E1::const_closure_type,
- typename E2::const_closure_type,
- matrix_matrix_prod<T1, T2, promote_type> > expression_type;
- typedef expression_type result_type;
- };
-
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- unknown_orientation_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- unknown_orientation_tag);
-
- // Dispatcher
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class M, class E1, class E2>
- M
- prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
- template<class M, class E1, class E2>
- M
- prec_prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
-
+
+ template<class T1, class E1, class T2, class E2>
struct matrix_matrix_binary_traits {
typedef unknown_orientation_tag dispatch_category;
typedef typename promote_traits<T1, T2>::promote_type promote_type;
typedef matrix_matrix_binary<typename E1::const_closure_type,
typename E2::const_closure_type,
matrix_matrix_prod<T1, T2, promote_type> > expression_type;
typedef expression_type result_type;
};
template<class E1, class E2>
typename matrix_matrix_binary_traits<typename E1::value_type, E1,
typename E2::value_type, E2>::result_type
prod (const matrix_expression<E1> &e1,
const matrix_expression<E2> &e2,
unknown_orientation_tag);
// Dispatcher
template<class E1, class E2>
typename matrix_matrix_binary_traits<typename E1::value_type, E1,
typename E2::value_type, E2>::result_type
prod (const matrix_expression<E1> &e1,
const matrix_expression<E2> &e2);
template<class E1, class E2>
typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
prec_prod (const matrix_expression<E1> &e1,
const matrix_expression<E2> &e2,
unknown_orientation_tag);
// Dispatcher
template<class E1, class E2>
typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
prec_prod (const matrix_expression<E1> &e1,
const matrix_expression<E2> &e2);
template<class M, class E1, class E2>
M
prod (const matrix_expression<E1> &e1,
const matrix_expression<E2> &e2);
template<class M, class E1, class E2>
M
prec_prod (const matrix_expression<E1> &e1,
const matrix_expression<E2> &e2);
+
prod computes the product of the matrix
-expressions. prec_prod computes the double precision
-product of the matrix expressions.
prod computes the product of the matrix expressions.
+ prec_prod computes the double precision product of the matrix expressions.
Defined in the header matrix_expression.hpp.
- +E1 is a model of Matrix Expression.
- E2 is a model of Matrix Expression.E1 is a model of
+ Matrix Expression
+ . E2 is a model of
+ Matrix Expression
+ .e1 ().size2 () == e2 ().size1 ()e1 ().size2 () == e2 ().size1 ()Cubic depending from the size of the matrix expression.
- +int main () {
- using namespace boost::numeric::ublas;
- matrix<double > m1 (3, 3), m2 (3, 3);
- for (int i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
- for (int j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)
- m1 (i, j) = m2 (i, j) = 3 * i + j;
-
- std::cout << prod (m1, m2) << std::endl;
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>+
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m1 (3, 3), m2 (3, 3);
for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)
m1 (i, j) = m2 (i, j) = 3 * i + j;
std::cout << prod (m1, m2) << std::endl;
}
template<class E1, class E2>
- struct matrix_matrix_solve_traits {
- typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;
- typedef matrix<promote_type> result_type;
- };
-
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- lower_tag,
- matrix_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- upper_tag,
- matrix_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_lower_tag,
- matrix_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_upper_tag,
- matrix_tag);
-
- template<class E1, class E2, class C>
- typename matrix_matrix_solve_traits<E1, E2>::result_type
- solve (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- C);
-
+
+ template<class E1, class E2>
struct matrix_matrix_solve_traits {
typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;
typedef matrix<promote_type> result_type;
};
template<class E1, class E2>
void inplace_solve (const matrix_expression<E1> &e1,
E2 &e2,
lower_tag,
matrix_tag);
template<class E1, class E2>
void inplace_solve (const matrix_expression<E1> &e1,
E2 &e2,
upper_tag,
matrix_tag);
template<class E1, class E2>
void inplace_solve (const matrix_expression<E1> &e1,
E2 &e2,
unit_lower_tag,
matrix_tag);
template<class E1, class E2>
void inplace_solve (const matrix_expression<E1> &e1,
E2 &e2,
unit_upper_tag,
matrix_tag);
template<class E1, class E2, class C>
typename matrix_matrix_solve_traits<E1, E2>::result_type
solve (const matrix_expression<E1> &e1,
const matrix_expression<E2> &e2,
C);
+
solve solves a linear equation for lower or upper
-(unit) triangular matrices.
solve solves a linear equation for lower or upper (unit) triangular
+matrices.
Defined in the header triangular.hpp.
- +E1 is a model of Matrix Expression.
- E2 is a model of Matrix Expression.E1 is a model of
+ Matrix Expression
+ . E2 is a model of
+ Matrix Expression
+ .e1 ().size1 () == e1 ().size2 () e1 ().size2 () == e2 ().size1 ()e1 ().size1 () == e1 ().size2 () e1 ().size2 () == e2 ().size1 ()Cubic depending from the size of the matrix expressions.
- +int main () {
- using namespace boost::numeric::ublas;
- matrix<double > m1 (3, 3), m2 (3, 3);
- for (int i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
- for (int j = 0; j <= i; ++ j)
- m1 (i, j) = m2 (i, j) = 3 * i + j;
-
- std::cout << solve (m1, m2, lower_tag ()) << std::endl;
-}
-
-Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this
-document is granted provided this copyright notice appears in all
-copies. This document is provided ``as is'' without express or
-implied warranty, and with no claim as to its suitability for any
-purpose.
#include <boost/numeric/ublas/triangular.hpp>+ +
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m1 (3, 3), m2 (3, 3);
for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
for (unsigned j = 0; j <= i; ++ j)
m1 (i, j) = m2 (i, j) = 3 * i + j + 1;
std::cout << solve (m1, m2, lower_tag ()) << std::endl;
}
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+ Permission to copy, use, modify, sell and distribute this document is granted
+provided this copyright notice appears in all copies. This document is provided
+``as is'' without express or implied warranty, and with no claim as to its
+suitability for any purpose.
Last revised: 8/3/2002
+ diff --git a/doc/matrix_proxy.htm b/doc/matrix_proxy.htm index b4c9ce61..272c7392 100644 --- a/doc/matrix_proxy.htm +++ b/doc/matrix_proxy.htm @@ -1,2727 +1,1413 @@ + - - - -
Matrix Proxies
+Matrix ProxiesThe templated class matrix_row<M> allows
-addressing a row of a matrix.
The templated class matrix_row<M> allows addressing
+a row of a matrix.
int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (int i = 0; i < m.size1 (); ++ i) {
- matrix_row<matrix<double> > mr (m, i);
- for (int j = 0; j < mr.size (); ++ j)
- mr (j) = 3 * i + j;
- std::cout << mr << std::endl;
- }
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i) {
matrix_row<matrix<double> > mr (m, i);
for (unsigned j = 0; j < mr.size (); ++ j)
mr (j) = 3 * i + j;
std::cout << mr << std::endl;
}
}
Defined in the header matrix_proxy.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
M |
- The type of matrix referenced. | -- | Parameter | +Description | +Default | + +
M |
+ The type of matrix referenced. | ++ |
None, except for those imposed by the requirements of Vector Expression.
- + +None, except for those imposed by the requirements of +Vector Expression +.
+vector_expression<matrix_row<M> >
| Member | -Description | -
|---|---|
matrix_row (matrix_type &data, size_type i) |
- Constructs a sub vector. | -
size_type size () const |
- Returns the size of the sub 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.
- |
-
matrix_row &operator = (const matrix_row
- &mr) |
- The assignment operator. | -
matrix_row &assign_temporary (matrix_row
- &mr) |
- Assigns a temporary. May change the matrix row mr. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a vector expression to the sub vector. Left - and right hand side of the assignment should be - independent. | -
template<class AE> |
- A computed assignment operator. Adds the vector - expression to the sub vector. | -
template<class AE> |
- Adds a vector expression to the sub vector. Left and - right hand side of the assignment should be independent. | -
template<class AE> |
- A computed assignment operator. Subtracts the vector - expression from the sub vector. | -
template<class AE> |
- Subtracts a vector expression from the sub vector. - Left and right hand side of the assignment should be - independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the sub - vector with a scalar. | -
template<class AT> |
- A computed assignment operator. Divides the sub - vector through a scalar. | -
void swap (matrix_row &mr) |
- Swaps the contents of the sub vectors. | -
const_iterator begin () const |
- Returns a const_iterator pointing to the
- beginning of the matrix_row. |
-
const_iterator end () const |
- Returns a const_iterator pointing to the
- end of the matrix_row. |
-
iterator begin () |
- Returns a iterator pointing to the
- beginning of the matrix_row. |
-
iterator end () |
- Returns a iterator pointing to the end
- of the matrix_row. |
-
const_reverse_iterator rbegin () const |
- Returns a const_reverse_iterator
- pointing to the beginning of the reversed matrix_row.
- |
-
const_reverse_iterator rend () const |
- Returns a const_reverse_iterator
- pointing to the end of the reversed matrix_row.
- |
-
reverse_iterator rbegin () |
- Returns a reverse_iterator pointing to
- the beginning of the reversed matrix_row. |
-
reverse_iterator rend () |
- Returns a reverse_iterator pointing to
- the end of the reversed matrix_row. |
- Member | +Description | + +
matrix_row (matrix_type &data, size_type i) |
+ Constructs a sub vector. | +
size_type size () const |
+ Returns the size of the sub 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.
+ |
+
matrix_row &operator = (const matrix_row &mr) |
+ The assignment operator. | +
matrix_row &assign_temporary (matrix_row &mr) |
+ Assigns a temporary. May change the matrix row mr
+. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a vector expression to the sub vector. Left +and right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Adds the vector expression +to the sub vector. | +
template<class AE> |
+ Adds a vector expression to the sub vector. Left and + right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Subtracts the vector + expression from the sub vector. | +
template<class AE> |
+ Subtracts a vector expression from the sub vector. Left +and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the sub vector +with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the sub vector +through a scalar. | +
void swap (matrix_row &mr) |
+ Swaps the contents of the sub vectors. | +
const_iterator begin () const |
+ Returns a const_iterator pointing to the
+ beginning of the matrix_row. |
+
const_iterator end () const |
+ Returns a const_iterator pointing to the
+ end of the matrix_row. |
+
iterator begin () |
+ Returns a iterator pointing to the beginning
+of the matrix_row. |
+
iterator end () |
+ Returns a iterator pointing to the end
+of the matrix_row. |
+
const_reverse_iterator rbegin () const |
+ Returns a const_reverse_iterator pointing
+to the beginning of the reversed matrix_row. |
+
const_reverse_iterator rend () const |
+ Returns a const_reverse_iterator pointing
+to the end of the reversed matrix_row. |
+
reverse_iterator rbegin () |
+ Returns a reverse_iterator pointing to
+the beginning of the reversed matrix_row. |
+
reverse_iterator rend () |
+ Returns a reverse_iterator pointing to
+the end of the reversed matrix_row. |
+
// Matrix based row vector class
- template<class M>
- class matrix_row:
- public vector_expression<matrix_row<M> > {
- public:
- typedef const M const_matrix_type;
- typedef M matrix_type;
- typedef typename M::size_type size_type;
- typedef typename M::difference_type difference_type;
- typedef typename M::value_type value_type;
- typedef typename M::const_reference const_reference;
- typedef typename M::reference reference;
- typedef typename M::const_pointer const_pointer;
- typedef typename M::pointer pointer;
- typedef const vector_const_reference<const matrix_row<matrix_type> > const_closure_type;
- typedef vector_reference<matrix_row<matrix_type> > closure_type;
- typedef typename M::const_iterator2 const_iterator_type;
- typedef typename M::iterator2 iterator_type;
- typedef typename storage_restrict_traits<typename M::storage_category,
- dense_proxy_tag>::storage_category storage_category;
-
- // Construction and destruction
- matrix_row ();
- matrix_row (matrix_type &data, size_type i);
-
- // Accessors
- size_type size () const;
- const_matrix_type &data () const;
- matrix_type &data ();
-
-
- // Element access
- const_reference operator () (size_type j) const;
- reference operator () (size_type j);
-
- const_reference operator [] (size_type j) const;
- reference operator [] (size_type j);
-
- // Assignment
- matrix_row &operator = (const matrix_row &mr);
- matrix_row &assign_temporary (matrix_row &mr);
- template<class AE>
- matrix_row &operator = (const vector_expression<AE> &ae);
- template<class AE>
- matrix_row &assign (const vector_expression<AE> &ae);
- template<class AE>
- matrix_row &operator += (const vector_expression<AE> &ae);
- template<class AE>
- matrix_row &plus_assign (const vector_expression<AE> &ae);
- template<class AE>
- matrix_row &operator -= (const vector_expression<AE> &ae);
- template<class AE>
- matrix_row &minus_assign (const vector_expression<AE> &ae);
- template<class AT>
- matrix_row &operator *= (const AT &at);
- template<class AT>
- matrix_row &operator /= (const AT &at);
-
- // Swapping
- void swap (matrix_row &mr);
- friend void swap (matrix_row &mr1, matrix_row &mr2);
-
- class const_iterator;
- class iterator;
-
- // Element lookup
- const_iterator find_first (size_type j) const;
- iterator find_first (size_type j);
- const_iterator find_last (size_type j) const;
- iterator find_last (size_type j);
-
- // Iterators simply are pointers.
-
- class const_iterator:
- public container_const_reference<matrix_row>,
- public random_access_iterator_base<const_iterator, value_type> {
- public:
- typedef typename const_iterator_type::iterator_category iterator_category;
- typedef typename const_iterator_type::difference_type difference_type;
- typedef typename const_iterator_type::value_type value_type;
- typedef typename const_iterator_type::reference reference;
- typedef typename const_iterator_type::pointer pointer;
-
- // Construction and destruction
- const_iterator ();
- const_iterator (const matrix_row &mr, const const_iterator_type &it);
- const_iterator (const iterator &it);
-
- // Arithmetic
- const_iterator &operator ++ ();
- const_iterator &operator -- ();
- const_iterator &operator += (difference_type n);
- const_iterator &operator -= (difference_type n);
- difference_type operator - (const const_iterator &it) const;
-
- // 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;
- bool operator <(const const_iterator &it) const;
- };
-
- const_iterator begin () const;
- const_iterator end () const;
-
- class iterator:
- public container_reference<matrix_row>,
- public random_access_iterator_base<iterator, value_type> {
- public:
- typedef typename iterator_type::iterator_category iterator_category;
- typedef typename iterator_type::difference_type difference_type;
- typedef typename iterator_type::value_type value_type;
- typedef typename iterator_type::reference reference;
- typedef typename iterator_type::pointer pointer;
-
- // Construction and destruction
- iterator ();
- iterator (matrix_row &mr, const iterator_type &it);
-
- // Arithmetic
- iterator &operator ++ ();
- iterator &operator -- ();
- iterator &operator += (difference_type n);
- iterator &operator -= (difference_type n);
- difference_type operator - (const iterator &it) const;
-
- // Dereference
- reference operator * () const;
-
- // Index
- size_type index () const;
-
- // Assignment
- iterator &operator = (const iterator &it);
-
- // Comparison
- bool operator == (const iterator &it) const;
- 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 ();
- };
-
+
+ // Matrix based row vector class
template<class M>
class matrix_row:
public vector_expression<matrix_row<M> > {
public:
typedef const M const_matrix_type;
typedef M matrix_type;
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
typedef typename M::pointer pointer;
typedef const vector_const_reference<const matrix_row<matrix_type> > const_closure_type;
typedef vector_reference<matrix_row<matrix_type> > closure_type;
typedef typename M::const_iterator2 const_iterator_type;
typedef typename M::iterator2 iterator_type;
typedef typename storage_restrict_traits<typename M::storage_category,
dense_proxy_tag>::storage_category storage_category;
// Construction and destruction
matrix_row ();
matrix_row (matrix_type &data, size_type i);
// Accessors
size_type size () const;
const_matrix_type &data () const;
matrix_type &data ();
// Element access
const_reference operator () (size_type j) const;
reference operator () (size_type j);
const_reference operator [] (size_type j) const;
reference operator [] (size_type j);
// Assignment
matrix_row &operator = (const matrix_row &mr);
matrix_row &assign_temporary (matrix_row &mr);
template<class AE>
matrix_row &operator = (const vector_expression<AE> &ae);
template<class AE>
matrix_row &assign (const vector_expression<AE> &ae);
template<class AE>
matrix_row &operator += (const vector_expression<AE> &ae);
template<class AE>
matrix_row &plus_assign (const vector_expression<AE> &ae);
template<class AE>
matrix_row &operator -= (const vector_expression<AE> &ae);
template<class AE>
matrix_row &minus_assign (const vector_expression<AE> &ae);
template<class AT>
matrix_row &operator *= (const AT &at);
template<class AT>
matrix_row &operator /= (const AT &at);
// Swapping
void swap (matrix_row &mr);
friend void swap (matrix_row &mr1, matrix_row &mr2);
class const_iterator;
class iterator;
// Element lookup
const_iterator find_first (size_type j) const;
iterator find_first (size_type j);
const_iterator find_last (size_type j) const;
iterator find_last (size_type j);
// Iterators simply are pointers.
class const_iterator:
public container_const_reference<matrix_row>,
public random_access_iterator_base<const_iterator, value_type> {
public:
typedef typename const_iterator_type::iterator_category iterator_category;
typedef typename const_iterator_type::difference_type difference_type;
typedef typename const_iterator_type::value_type value_type;
typedef typename const_iterator_type::reference reference;
typedef typename const_iterator_type::pointer pointer;
// Construction and destruction
const_iterator ();
const_iterator (const matrix_row &mr, const const_iterator_type &it);
const_iterator (const iterator &it);
// Arithmetic
const_iterator &operator ++ ();
const_iterator &operator -- ();
const_iterator &operator += (difference_type n);
const_iterator &operator -= (difference_type n);
difference_type operator - (const const_iterator &it) const;
// 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;
bool operator <(const const_iterator &it) const;
};
const_iterator begin () const;
const_iterator end () const;
class iterator:
public container_reference<matrix_row>,
public random_access_iterator_base<iterator, value_type> {
public:
typedef typename iterator_type::iterator_category iterator_category;
typedef typename iterator_type::difference_type difference_type;
typedef typename iterator_type::value_type value_type;
typedef typename iterator_type::reference reference;
typedef typename iterator_type::pointer pointer;
// Construction and destruction
iterator ();
iterator (matrix_row &mr, const iterator_type &it);
// Arithmetic
iterator &operator ++ ();
iterator &operator -- ();
iterator &operator += (difference_type n);
iterator &operator -= (difference_type n);
difference_type operator - (const iterator &it) const;
// Dereference
reference operator * () const;
// Index
size_type index () const;
// Assignment
iterator &operator = (const iterator &it);
// Comparison
bool operator == (const iterator &it) const;
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 ();
};
+
template<class M>
- matrix_row<M> row (M &data, std::size_t i);
- template<class M>
- const matrix_row<const M> row (const M &data, std::size_t i);
-
+
+ template<class M>
matrix_row<M> row (M &data, std::size_t i);
template<class M>
const matrix_row<const M> row (const M &data, std::size_t i);
+
The free row functions support the construction
-of matrix rows.
The free row functions support the construction of matrix
+rows.
Defined in the header matrix_proxy.hpp.
- +M is a model of Matrix Expression.M is a model of
+Matrix Expression
+.i < data.size1 ()i < data.size1 ()Linear depending from the size of the row.
- +int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (int i = 0; i < m.size1 (); ++ i) {
- for (int j = 0; j < m.size2 (); ++ j)
- row (m, i) (j) = 3 * i + j;
- std::cout << row (m, i) << std::endl;
- }
-}
-
-#include <boost/numeric/ublas/matrix.hpp>+
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i) {
for (unsigned j = 0; j < m.size2 (); ++ j)
row (m, i) (j) = 3 * i + j;
std::cout << row (m, i) << std::endl;
}
}
The templated class matrix_column<M> allows
-addressing a column of a matrix.
The templated class matrix_column<M> allows addressing
+a column of a matrix.
int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (int j = 0; j < m.size2 (); ++ j) {
- matrix_column<matrix<double> > mc (m, j);
- for (int i = 0; i < mc.size (); ++ i)
- mc (i) = 3 * i + j;
- std::cout << mc << std::endl;
- }
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned j = 0; j < m.size2 (); ++ j) {
matrix_column<matrix<double> > mc (m, j);
for (unsigned i = 0; i < mc.size (); ++ i)
mc (i) = 3 * i + j;
std::cout << mc << std::endl;
}
}
Defined in the header matrix_proxy.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
M |
- The type of matrix referenced. | -- | Parameter | +Description | +Default | + +
M |
+ The type of matrix referenced. | ++ |
None, except for those imposed by the requirements of Vector Expression.
- + +None, except for those imposed by the requirements of +Vector Expression +.
+vector_expression<matrix_column<M> >
| Member | -Description | -
|---|---|
matrix_column (matrix_type &data, size_type
- j) |
- Constructs a sub vector. | -
size_type size () const |
- Returns the size of the sub 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.
- |
-
matrix_column &operator = (const
- matrix_column &mc) |
- The assignment operator. | -
matrix_column &assign_temporary
- (matrix_column &mc) |
- Assigns a temporary. May change the matrix column mc. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a vector expression to the sub vector. Left - and right hand side of the assignment should be - independent. | -
template<class AE> |
- A computed assignment operator. Adds the vector - expression to the sub vector. | -
template<class AE> |
- Adds a vector expression to the sub vector. Left and - right hand side of the assignment should be independent. | -
template<class AE> |
- A computed assignment operator. Subtracts the vector - expression from the sub vector. | -
template<class AE> |
- Subtracts a vector expression from the sub vector. - Left and right hand side of the assignment should be - independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the sub - vector with a scalar. | -
template<class AT> |
- A computed assignment operator. Divides the sub - vector through a scalar. | -
void swap (matrix_column &mc) |
- Swaps the contents of the sub vectors. | -
const_iterator begin () const |
- Returns a const_iterator pointing to the
- beginning of the matrix_column. |
-
const_iterator end () const |
- Returns a const_iterator pointing to the
- end of the matrix_column. |
-
iterator begin () |
- Returns a iterator pointing to the
- beginning of the matrix_column. |
-
iterator end () |
- Returns a iterator pointing to the end
- of the matrix_column. |
-
const_reverse_iterator rbegin () const |
- Returns a const_reverse_iterator
- pointing to the beginning of the reversed matrix_column.
- |
-
const_reverse_iterator rend () const |
- Returns a const_reverse_iterator
- pointing to the end of the reversed matrix_column.
- |
-
reverse_iterator rbegin () |
- Returns a reverse_iterator pointing to
- the beginning of the reversed matrix_column.
- |
-
reverse_iterator rend () |
- Returns a reverse_iterator pointing to
- the end of the reversed matrix_column. |
- Member | +Description | + +
matrix_column (matrix_type &data, size_type
+ j) |
+ Constructs a sub vector. | +
size_type size () const |
+ Returns the size of the sub 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.
+ |
+
matrix_column &operator = (const matrix_column
+&mc) |
+ The assignment operator. | +
matrix_column &assign_temporary (matrix_column
+&mc) |
+ Assigns a temporary. May change the matrix column mc
+. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a vector expression to the sub vector. Left +and right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Adds the vector expression +to the sub vector. | +
template<class AE> |
+ Adds a vector expression to the sub vector. Left and + right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Subtracts the vector + expression from the sub vector. | +
template<class AE> |
+ Subtracts a vector expression from the sub vector. Left +and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the sub vector +with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the sub vector +through a scalar. | +
void swap (matrix_column &mc) |
+ Swaps the contents of the sub vectors. | +
const_iterator begin () const |
+ Returns a const_iterator pointing to the
+ beginning of the matrix_column. |
+
const_iterator end () const |
+ Returns a const_iterator pointing to the
+ end of the matrix_column. |
+
iterator begin () |
+ Returns a iterator pointing to the beginning
+of the matrix_column. |
+
iterator end () |
+ Returns a iterator pointing to the end
+of the matrix_column. |
+
const_reverse_iterator rbegin () const |
+ Returns a const_reverse_iterator pointing
+to the beginning of the reversed matrix_column. |
+
const_reverse_iterator rend () const |
+ Returns a const_reverse_iterator pointing
+to the end of the reversed matrix_column. |
+
reverse_iterator rbegin () |
+ Returns a reverse_iterator pointing to
+the beginning of the reversed matrix_column. |
+
reverse_iterator rend () |
+ Returns a reverse_iterator pointing to
+the end of the reversed matrix_column. |
+
// Matrix based column vector class
- template<class M>
- class matrix_column:
- public vector_expression<matrix_column<M> > {
- public:
- typedef const M const_matrix_type;
- typedef M matrix_type;
- typedef typename M::size_type size_type;
- typedef typename M::difference_type difference_type;
- typedef typename M::value_type value_type;
- typedef typename M::const_reference const_reference;
- typedef typename M::reference reference;
- typedef typename M::const_pointer const_pointer;
- typedef typename M::pointer pointer;
- typedef const vector_const_reference<const matrix_column<matrix_type> > const_closure_type;
- typedef vector_reference<matrix_column<matrix_type> > closure_type;
- typedef typename M::const_iterator1 const_iterator_type;
- typedef typename M::iterator1 iterator_type;
- typedef typename storage_restrict_traits<typename M::storage_category,
- dense_proxy_tag>::storage_category storage_category;
-
- // Construction and destruction
- matrix_column ();
- matrix_column (matrix_type &data, size_type j);
-
- // Accessors
- size_type size () const;
- const_matrix_type &data () const;
- matrix_type &data ();
-
-
- // 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
- matrix_column &operator = (const matrix_column &mc);
- matrix_column &assign_temporary (matrix_column &mc);
- template<class AE>
- matrix_column &operator = (const vector_expression<AE> &ae);
- template<class AE>
- matrix_column &assign (const vector_expression<AE> &ae);
- template<class AE>
- matrix_column &operator += (const vector_expression<AE> &ae);
- template<class AE>
- matrix_column &plus_assign (const vector_expression<AE> &ae);
- template<class AE>
- matrix_column &operator -= (const vector_expression<AE> &ae);
- template<class AE>
- matrix_column &minus_assign (const vector_expression<AE> &ae);
- template<class AT>
- matrix_column &operator *= (const AT &at);
- template<class AT>
- matrix_column &operator /= (const AT &at);
-
- // Swapping
- void swap (matrix_column &mc);
- friend void swap (matrix_column &mc1, matrix_column &mc2);
-
- class const_iterator;
- class iterator;
-
- // Element lookup
- 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<matrix_column>,
- public random_access_iterator_base<const_iterator, value_type> {
- public:
- typedef typename const_iterator_type::iterator_category iterator_category;
- typedef typename const_iterator_type::difference_type difference_type;
- typedef typename const_iterator_type::value_type value_type;
- typedef typename const_iterator_type::reference reference;
- typedef typename const_iterator_type::pointer pointer;
-
- // Construction and destruction
- const_iterator ();
- const_iterator (const matrix_column &mc, const const_iterator_type &it);
- const_iterator (const iterator &it);
-
- // Arithmetic
- const_iterator &operator ++ ();
- const_iterator &operator -- ();
- const_iterator &operator += (difference_type n);
- const_iterator &operator -= (difference_type n);
- difference_type operator - (const const_iterator &it) const;
-
- // 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;
- bool operator <(const const_iterator &it) const;
- };
-
- const_iterator begin () const;
- const_iterator end () const;
-
- class iterator:
- public container_reference<matrix_column>,
- public random_access_iterator_base<iterator, value_type> {
- public:
- typedef typename iterator_type::iterator_category iterator_category;
- typedef typename iterator_type::difference_type difference_type;
- typedef typename iterator_type::value_type value_type;
- typedef typename iterator_type::reference reference;
- typedef typename iterator_type::pointer pointer;
-
- // Construction and destruction
- iterator ();
- iterator (matrix_column &mc, const iterator_type &it);
-
- // Arithmetic
- iterator &operator ++ ();
- iterator &operator -- ();
- iterator &operator += (difference_type n);
- iterator &operator -= (difference_type n);
- difference_type operator - (const iterator &it) const;
-
- // Dereference
- reference operator * () const;
-
- // Index
- size_type index () const;
-
- // Assignment
- iterator &operator = (const iterator &it);
-
- // Comparison
- bool operator == (const iterator &it) const;
- 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 ();
- };
-
+
+ // Matrix based column vector class
template<class M>
class matrix_column:
public vector_expression<matrix_column<M> > {
public:
typedef const M const_matrix_type;
typedef M matrix_type;
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
typedef typename M::pointer pointer;
typedef const vector_const_reference<const matrix_column<matrix_type> > const_closure_type;
typedef vector_reference<matrix_column<matrix_type> > closure_type;
typedef typename M::const_iterator1 const_iterator_type;
typedef typename M::iterator1 iterator_type;
typedef typename storage_restrict_traits<typename M::storage_category,
dense_proxy_tag>::storage_category storage_category;
// Construction and destruction
matrix_column ();
matrix_column (matrix_type &data, size_type j);
// Accessors
size_type size () const;
const_matrix_type &data () const;
matrix_type &data ();
// 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
matrix_column &operator = (const matrix_column &mc);
matrix_column &assign_temporary (matrix_column &mc);
template<class AE>
matrix_column &operator = (const vector_expression<AE> &ae);
template<class AE>
matrix_column &assign (const vector_expression<AE> &ae);
template<class AE>
matrix_column &operator += (const vector_expression<AE> &ae);
template<class AE>
matrix_column &plus_assign (const vector_expression<AE> &ae);
template<class AE>
matrix_column &operator -= (const vector_expression<AE> &ae);
template<class AE>
matrix_column &minus_assign (const vector_expression<AE> &ae);
template<class AT>
matrix_column &operator *= (const AT &at);
template<class AT>
matrix_column &operator /= (const AT &at);
// Swapping
void swap (matrix_column &mc);
friend void swap (matrix_column &mc1, matrix_column &mc2);
class const_iterator;
class iterator;
// Element lookup
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<matrix_column>,
public random_access_iterator_base<const_iterator, value_type> {
public:
typedef typename const_iterator_type::iterator_category iterator_category;
typedef typename const_iterator_type::difference_type difference_type;
typedef typename const_iterator_type::value_type value_type;
typedef typename const_iterator_type::reference reference;
typedef typename const_iterator_type::pointer pointer;
// Construction and destruction
const_iterator ();
const_iterator (const matrix_column &mc, const const_iterator_type &it);
const_iterator (const iterator &it);
// Arithmetic
const_iterator &operator ++ ();
const_iterator &operator -- ();
const_iterator &operator += (difference_type n);
const_iterator &operator -= (difference_type n);
difference_type operator - (const const_iterator &it) const;
// 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;
bool operator <(const const_iterator &it) const;
};
const_iterator begin () const;
const_iterator end () const;
class iterator:
public container_reference<matrix_column>,
public random_access_iterator_base<iterator, value_type> {
public:
typedef typename iterator_type::iterator_category iterator_category;
typedef typename iterator_type::difference_type difference_type;
typedef typename iterator_type::value_type value_type;
typedef typename iterator_type::reference reference;
typedef typename iterator_type::pointer pointer;
// Construction and destruction
iterator ();
iterator (matrix_column &mc, const iterator_type &it);
// Arithmetic
iterator &operator ++ ();
iterator &operator -- ();
iterator &operator += (difference_type n);
iterator &operator -= (difference_type n);
difference_type operator - (const iterator &it) const;
// Dereference
reference operator * () const;
// Index
size_type index () const;
// Assignment
iterator &operator = (const iterator &it);
// Comparison
bool operator == (const iterator &it) const;
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 ();
};
+
template<class M>
- matrix_column<M> column (M &data, std::size_t j);
- template<class M>
- const matrix_column<const M> column (const M &data, std::size_t j);
-
+
+ template<class M>
matrix_column<M> column (M &data, std::size_t j);
template<class M>
const matrix_column<const M> column (const M &data, std::size_t j);
+
The free column functions support the
-construction of matrix columns.
The free column functions support the construction of matrix
+columns.
Defined in the header matrix_proxy.hpp.
- +M is a model of Matrix Expression.M is a model of
+Matrix Expression
+.j < data.size2 ()j < data.size2 ()Linear depending from the size of the column.
- +int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (int j = 0; j < m.size2 (); ++ j) {
- for (int i = 0; i < m.size1 (); ++ i)
- column (m, j) (i) = 3 * i + j;
- std::cout << column (m, j) << std::endl;
- }
-}
-
-#include <boost/numeric/ublas/matrix.hpp>+
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned j = 0; j < m.size2 (); ++ j) {
for (unsigned i = 0; i < m.size1 (); ++ i)
column (m, j) (i) = 3 * i + j;
std::cout << column (m, j) << std::endl;
}
}
The templated class matrix_vector_range<M> allows
-addressing a sub vector of a matrix.
The templated class matrix_vector_range<M> allows addressing
+a sub vector of a matrix.
int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (int i = 0; i < m.size1 (); ++ i)
- for (int j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
-
- matrix_vector_range<matrix<double> > mvr (m, range (0, 3), range (0, 3));
- std::cout << mvr << std::endl;
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned j = 0; j < m.size2 (); ++ j)
m (i, j) = 3 * i + j;
matrix_vector_range<matrix<double> > mvr (m, range (0, 3), range (0, 3));
std::cout << mvr << std::endl;
}
Defined in the header matrix_proxy.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
M |
- The type of matrix referenced. | -- | Parameter | +Description | +Default | + +
M |
+ The type of matrix referenced. | ++ |
None, except for those imposed by the requirements of Vector Expression.
- + +None, except for those imposed by the requirements of +Vector Expression +.
+vector_expression<matrix_vector_range<M> >
-
vector_expression<matrix_vector_range<M> >
| Member | -Description | -
|---|---|
matrix_vector_range (matrix_type &data, |
- Constructs a sub vector. | -
size_type size () const |
- Returns the size of the sub 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.
- |
-
matrix_vector_range &operator = (const
- matrix_vector_range &mvr) |
- The assignment operator. | -
matrix_vector_range &assign_temporary
- (matrix_vector_range &mvr) |
- Assigns a temporary. May change the matrix vector
- range mvr. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a vector expression to the sub vector. Left - and right hand side of the assignment should be - independent. | -
template<class AE> |
- A computed assignment operator. Adds the vector - expression to the sub vector. | -
template<class AE> |
- Adds a vector expression to the sub vector. Left and - right hand side of the assignment should be independent. | -
template<class AE> |
- A computed assignment operator. Subtracts the vector - expression from the sub vector. | -
template<class AE> |
- Subtracts a vector expression from the sub vector. - Left and right hand side of the assignment should be - independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the sub - vector with a scalar. | -
template<class AT> |
- A computed assignment operator. Divides the sub - vector through a scalar. | -
void swap (matrix_vector_range &mvr) |
- Swaps the contents of the sub vectors. | -
const_iterator begin () const |
- Returns a const_iterator pointing to the
- beginning of the matrix_vector_range. |
-
const_iterator end () const |
- Returns a const_iterator pointing to the
- end of the matrix_vector_range. |
-
iterator begin () |
- Returns a iterator pointing to the
- beginning of the matrix_vector_range. |
-
iterator end () |
- Returns a iterator pointing to the end
- of the matrix_vector_range. |
-
const_reverse_iterator rbegin () const |
- Returns a const_reverse_iterator
- pointing to the beginning of the matrix_vector_range.
- |
-
const_reverse_iterator rend () const |
- Returns a const_reverse_iterator
- pointing to the end of the reversed matrix_vector_range.
- |
-
reverse_iterator rbegin () |
- Returns a reverse_iterator pointing to
- the beginning of the reversed matrix_vector_range.
- |
-
reverse_iterator rend () |
- Returns a reverse_iterator pointing to
- the end of the reversed matrix_vector_range.
- |
- Member | +Description | + +
matrix_vector_range (matrix_type &data, |
+ Constructs a sub vector. | +
size_type size () const |
+ Returns the size of the sub 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.
+ |
+
matrix_vector_range &operator = (const matrix_vector_range
+&mvr) |
+ The assignment operator. | +
matrix_vector_range &assign_temporary (matrix_vector_range
+&mvr) |
+ Assigns a temporary. May change the matrix vector range
+ mvr. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a vector expression to the sub vector. Left +and right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Adds the vector expression +to the sub vector. | +
template<class AE> |
+ Adds a vector expression to the sub vector. Left and + right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Subtracts the vector + expression from the sub vector. | +
template<class AE> |
+ Subtracts a vector expression from the sub vector. Left +and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the sub vector +with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the sub vector +through a scalar. | +
void swap (matrix_vector_range &mvr) |
+ Swaps the contents of the sub vectors. | +
const_iterator begin () const |
+ Returns a const_iterator pointing to the
+ beginning of the matrix_vector_range. |
+
const_iterator end () const |
+ Returns a const_iterator pointing to the
+ end of the matrix_vector_range. |
+
iterator begin () |
+ Returns a iterator pointing to the beginning
+of the matrix_vector_range. |
+
iterator end () |
+ Returns a iterator pointing to the end
+of the matrix_vector_range. |
+
const_reverse_iterator rbegin () const |
+ Returns a const_reverse_iterator pointing
+to the beginning of the matrix_vector_range. |
+
const_reverse_iterator rend () const |
+ Returns a const_reverse_iterator pointing
+to the end of the reversed matrix_vector_range. |
+
reverse_iterator rbegin () |
+ Returns a reverse_iterator pointing to
+the beginning of the reversed matrix_vector_range. |
+
reverse_iterator rend () |
+ Returns a reverse_iterator pointing to
+the end of the reversed matrix_vector_range. |
+
// Matrix based vector range class
- template<class M>
- class matrix_vector_range:
- public vector_expression<matrix_vector_range<M> > {
- public:
- typedef const M const_matrix_type;
- typedef M matrix_type;
- typedef typename M::size_type size_type;
- typedef typename M::difference_type difference_type;
- typedef typename M::value_type value_type;
- typedef typename M::const_reference const_reference;
- typedef typename M::reference reference;
- typedef typename M::const_pointer const_pointer;
- typedef typename M::pointer pointer;
- typedef const vector_const_reference<const matrix_vector_range<matrix_type> > const_closure_type;
- typedef vector_reference<matrix_vector_range<matrix_type> > closure_type;
- typedef range::const_iterator const_iterator1_type;
- typedef range::const_iterator iterator1_type;
- typedef range::const_iterator const_iterator2_type;
- typedef range::const_iterator iterator2_type;
- typedef typename storage_restrict_traits<typename M::storage_category,
- dense_proxy_tag>::storage_category storage_category;
-
- // Construction and destruction
- matrix_vector_range ();
- matrix_vector_range (matrix_type &data, const range &r1, const range &r2);
-
- // Accessors
- size_type size () const;
- const_matrix_type &data () const;
- matrix_type &data ();
-
-
- // 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
- matrix_vector_range &operator = (const matrix_vector_range &mvr);
- matrix_vector_range &assign_temporary (matrix_vector_range &mvr);
- template<class AE>
- matrix_vector_range &operator = (const vector_expression<AE> &ae);
- template<class AE>
- matrix_vector_range &assign (const vector_expression<AE> &ae);
- template<class AE>
- matrix_vector_range &operator += (const vector_expression<AE> &ae);
- template<class AE>
- matrix_vector_range &plus_assign (const vector_expression<AE> &ae);
- template<class AE>
- matrix_vector_range &operator -= (const vector_expression<AE> &ae);
- template<class AE>
- matrix_vector_range &minus_assign (const vector_expression<AE> &ae);
- template<class AT>
- matrix_vector_range &operator *= (const AT &at);
- template<class AT>
- matrix_vector_range &operator /= (const AT &at);
-
- // Swapping
- void swap (matrix_vector_range &mvr);
- friend void swap (matrix_vector_range &mvr1, matrix_vector_range &mvr2);
-
- class const_iterator;
- class iterator;
-
- // Element lookup
- 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 indices.
-
- class const_iterator:
- public container_const_reference<matrix_vector_range>,
- public random_access_iterator_base<const_iterator, value_type> {
- public:
- typedef typename restrict_traits<typename M::const_iterator1::iterator_category,
- typename M::const_iterator2::iterator_category>::iterator_category iterator_category;
- typedef typename matrix_vector_range::difference_type difference_type;
- typedef typename matrix_vector_range::value_type value_type;
- typedef typename matrix_vector_range::const_reference reference;
- typedef typename matrix_vector_range::const_pointer pointer;
-
- // Construction and destruction
- const_iterator ();
- const_iterator (const matrix_vector_range &mvr, const const_iterator1_type &it1, const const_iterator2_type &it2);
- const_iterator (const iterator &it);
-
- // Arithmetic
- const_iterator &operator ++ ();
- const_iterator &operator -- ();
- const_iterator &operator += (difference_type n);
- const_iterator &operator -= (difference_type n);
- difference_type operator - (const const_iterator &it) const;
-
- // 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;
- bool operator <(const const_iterator &it) const;
- };
-
- const_iterator begin () const;
- const_iterator end () const;
-
- class iterator:
- public container_reference<matrix_vector_range>,
- public random_access_iterator_base<iterator, value_type> {
- public:
- typedef typename restrict_traits<typename M::iterator1::iterator_category,
- typename M::iterator2::iterator_category>::iterator_category iterator_category;
- typedef typename matrix_vector_range::difference_type difference_type;
- typedef typename matrix_vector_range::value_type value_type;
- typedef typename matrix_vector_range::reference reference;
- typedef typename matrix_vector_range::pointer pointer;
-
- // Construction and destruction
- iterator ();
- iterator (matrix_vector_range &mvr, const iterator1_type &it1, const iterator2_type &it2);
-
- // Arithmetic
- iterator &operator ++ ();
- iterator &operator -- ();
- iterator &operator += (difference_type n);
- iterator &operator -= (difference_type n);
- difference_type operator - (const iterator &it) const;
-
- // Dereference
- reference operator * () const;
-
- // Index
- size_type index () const;
-
- // Assignment
- iterator &operator = (const iterator &it);
-
- // Comparison
- bool operator == (const iterator &it) const;
- 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 ();
- };
-
- // Matrix based vector range class
template<class M>
class matrix_vector_range:
public vector_expression<matrix_vector_range<M> > {
public:
typedef const M const_matrix_type;
typedef M matrix_type;
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
typedef typename M::pointer pointer;
typedef const vector_const_reference<const matrix_vector_range<matrix_type> > const_closure_type;
typedef vector_reference<matrix_vector_range<matrix_type> > closure_type;
typedef range::const_iterator const_iterator1_type;
typedef range::const_iterator iterator1_type;
typedef range::const_iterator const_iterator2_type;
typedef range::const_iterator iterator2_type;
typedef typename storage_restrict_traits<typename M::storage_category,
dense_proxy_tag>::storage_category storage_category;
// Construction and destruction
matrix_vector_range ();
matrix_vector_range (matrix_type &data, const range &r1, const range &r2);
// Accessors
size_type size () const;
const_matrix_type &data () const;
matrix_type &data ();
// 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
matrix_vector_range &operator = (const matrix_vector_range &mvr);
matrix_vector_range &assign_temporary (matrix_vector_range &mvr);
template<class AE>
matrix_vector_range &operator = (const vector_expression<AE> &ae);
template<class AE>
matrix_vector_range &assign (const vector_expression<AE> &ae);
template<class AE>
matrix_vector_range &operator += (const vector_expression<AE> &ae);
template<class AE>
matrix_vector_range &plus_assign (const vector_expression<AE> &ae);
template<class AE>
matrix_vector_range &operator -= (const vector_expression<AE> &ae);
template<class AE>
matrix_vector_range &minus_assign (const vector_expression<AE> &ae);
template<class AT>
matrix_vector_range &operator *= (const AT &at);
template<class AT>
matrix_vector_range &operator /= (const AT &at);
// Swapping
void swap (matrix_vector_range &mvr);
friend void swap (matrix_vector_range &mvr1, matrix_vector_range &mvr2);
class const_iterator;
class iterator;
// Element lookup
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 indices.
class const_iterator:
public container_const_reference<matrix_vector_range>,
public random_access_iterator_base<const_iterator, value_type> {
public:
typedef typename restrict_traits<typename M::const_iterator1::iterator_category,
typename M::const_iterator2::iterator_category>::iterator_category iterator_category;
typedef typename matrix_vector_range::difference_type difference_type;
typedef typename matrix_vector_range::value_type value_type;
typedef typename matrix_vector_range::const_reference reference;
typedef typename matrix_vector_range::const_pointer pointer;
// Construction and destruction
const_iterator ();
const_iterator (const matrix_vector_range &mvr, const const_iterator1_type &it1, const const_iterator2_type &it2);
const_iterator (const iterator &it);
// Arithmetic
const_iterator &operator ++ ();
const_iterator &operator -- ();
const_iterator &operator += (difference_type n);
const_iterator &operator -= (difference_type n);
difference_type operator - (const const_iterator &it) const;
// 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;
bool operator <(const const_iterator &it) const;
};
const_iterator begin () const;
const_iterator end () const;
class iterator:
public container_reference<matrix_vector_range>,
public random_access_iterator_base<iterator, value_type> {
public:
typedef typename restrict_traits<typename M::iterator1::iterator_category,
typename M::iterator2::iterator_category>::iterator_category iterator_category;
typedef typename matrix_vector_range::difference_type difference_type;
typedef typename matrix_vector_range::value_type value_type;
typedef typename matrix_vector_range::reference reference;
typedef typename matrix_vector_range::pointer pointer;
// Construction and destruction
iterator ();
iterator (matrix_vector_range &mvr, const iterator1_type &it1, const iterator2_type &it2);
// Arithmetic
iterator &operator ++ ();
iterator &operator -- ();
iterator &operator += (difference_type n);
iterator &operator -= (difference_type n);
difference_type operator - (const iterator &it) const;
// Dereference
reference operator * () const;
// Index
size_type index () const;
// Assignment
iterator &operator = (const iterator &it);
// Comparison
bool operator == (const iterator &it) const;
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 ();
};
+
+The templated class matrix_vector_slice<M> allows
-addressing a sliced sub vector of a matrix.
The templated class matrix_vector_slice<M> allows addressing
+a sliced sub vector of a matrix.
int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (int i = 0; i < m.size1 (); ++ i)
- for (int j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
-
- matrix_vector_range<matrix<double> > mvs (m, slice (0, 1, 3), slice (0, 1, 3));
- std::cout << mvs << std::endl;
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned j = 0; j < m.size2 (); ++ j)
m (i, j) = 3 * i + j;
matrix_vector_slice<matrix<double> > mvs (m, slice (0, 1, 3), slice (0, 1, 3));
std::cout << mvs << std::endl;
}
Defined in the header matrix_proxy.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
M |
- The type of matrix referenced. | -- | Parameter | +Description | +Default | + +
M |
+ The type of matrix referenced. | ++ |
None, except for those imposed by the requirements of Vector Expression.
- + +None, except for those imposed by the requirements of +Vector Expression +.
+vector_expression<matrix_vector_slice<M> >
-
vector_expression<matrix_vector_slice<M> >
| Member | -Description | -
|---|---|
matrix_vector_slice (matrix_type &data, |
- Constructs a sub vector. | -
size_type size () const |
- Returns the size of the sub 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.
- |
-
matrix_vector_slice &operator = (const
- matrix_vector_slice &mvs) |
- The assignment operator. | -
matrix_vector_slice &assign_temporary
- (matrix_vector_slice &mvs) |
- Assigns a temporary. May change the matrix vector
- slice vs. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a vector expression to the sub vector. Left - and right hand side of the assignment should be - independent. | -
template<class AE> |
- A computed assignment operator. Adds the vector - expression to the sub vector. | -
template<class AE> |
- Adds a vector expression to the sub vector. Left and - right hand side of the assignment should be independent. | -
template<class AE> |
- A computed assignment operator. Subtracts the vector - expression from the sub vector. | -
template<class AE> |
- Subtracts a vector expression from the sub vector. - Left and right hand side of the assignment should be - independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the sub - vector with a scalar. | -
template<class AT> |
- A computed assignment operator. Divides the sub - vector through a scalar. | -
void swap (matrix_vector_slice &mvs) |
- Swaps the contents of the sub vectors. | -
const_iterator begin () const |
- Returns a const_iterator pointing to the
- beginning of the matrix_vector_slice. |
-
const_iterator end () const |
- Returns a const_iterator pointing to the
- end of the matrix_vector_slice. |
-
iterator begin () |
- Returns a iterator pointing to the
- beginning of the matrix_vector_slice. |
-
iterator end () |
- Returns a iterator pointing to the end
- of the matrix_vector_slice. |
-
const_reverse_iterator rbegin () const |
- Returns a const_reverse_iterator
- pointing to the beginning of the reversed matrix_vector_slice.
- |
-
const_reverse_iterator rend () const |
- Returns a const_reverse_iterator
- pointing to the end of the reversed matrix_vector_slice.
- |
-
reverse_iterator rbegin () |
- Returns a reverse_iterator pointing to
- the beginning of the reversed matrix_vector_slice.
- |
-
reverse_iterator rend () |
- Returns a reverse_iterator pointing to
- the end of the reversed matrix_vector_slice.
- |
- Member | +Description | + +
matrix_vector_slice (matrix_type &data, |
+ Constructs a sub vector. | +
size_type size () const |
+ Returns the size of the sub 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.
+ |
+
matrix_vector_slice &operator = (const matrix_vector_slice
+&mvs) |
+ The assignment operator. | +
matrix_vector_slice &assign_temporary (matrix_vector_slice
+&mvs) |
+ Assigns a temporary. May change the matrix vector slice
+ vs. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a vector expression to the sub vector. Left +and right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Adds the vector expression +to the sub vector. | +
template<class AE> |
+ Adds a vector expression to the sub vector. Left and + right hand side of the assignment should be independent. | +
template<class AE> |
+ A computed assignment operator. Subtracts the vector + expression from the sub vector. | +
template<class AE> |
+ Subtracts a vector expression from the sub vector. Left +and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the sub vector +with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the sub vector +through a scalar. | +
void swap (matrix_vector_slice &mvs) |
+ Swaps the contents of the sub vectors. | +
const_iterator begin () const |
+ Returns a const_iterator pointing to the
+ beginning of the matrix_vector_slice. |
+
const_iterator end () const |
+ Returns a const_iterator pointing to the
+ end of the matrix_vector_slice. |
+
iterator begin () |
+ Returns a iterator pointing to the beginning
+of the matrix_vector_slice. |
+
iterator end () |
+ Returns a iterator pointing to the end
+of the matrix_vector_slice. |
+
const_reverse_iterator rbegin () const |
+ Returns a const_reverse_iterator pointing
+to the beginning of the reversed matrix_vector_slice.
+ |
+
const_reverse_iterator rend () const |
+ Returns a const_reverse_iterator pointing
+to the end of the reversed matrix_vector_slice. |
+
reverse_iterator rbegin () |
+ Returns a reverse_iterator pointing to
+the beginning of the reversed matrix_vector_slice. |
+
reverse_iterator rend () |
+ Returns a reverse_iterator pointing to
+the end of the reversed matrix_vector_slice. |
+
// Matrix based vector slice class
- template<class M>
- class matrix_vector_slice:
- public vector_expression<matrix_vector_slice<M> > {
- public:
- typedef const M const_matrix_type;
- typedef M matrix_type;
- typedef typename M::size_type size_type;
- typedef typename M::difference_type difference_type;
- typedef typename M::value_type value_type;
- typedef typename M::const_reference const_reference;
- typedef typename M::reference reference;
- typedef typename M::const_pointer const_pointer;
- typedef typename M::pointer pointer;
- typedef const vector_const_reference<const matrix_vector_slice<matrix_type> > const_closure_type;
- typedef vector_reference<matrix_vector_slice<matrix_type> > closure_type;
- typedef slice::const_iterator const_iterator1_type;
- typedef slice::const_iterator iterator1_type;
- typedef slice::const_iterator const_iterator2_type;
- typedef slice::const_iterator iterator2_type;
- typedef typename storage_restrict_traits<typename M::storage_category,
- dense_proxy_tag>::storage_category storage_category;
-
- // Construction and destruction
- matrix_vector_slice ();
- matrix_vector_slice (matrix_type &data, const slice &s1, const slice &s2);
-
- // Accessors
- size_type size () const;
- const_matrix_type &data () const;
- matrix_type &data ();
-
-
- // 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
- matrix_vector_slice &operator = (const matrix_vector_slice &mvs);
- matrix_vector_slice &assign_temporary (matrix_vector_slice &mvs);
- template<class AE>
- matrix_vector_slice &operator = (const vector_expression<AE> &ae);
- template<class AE>
- matrix_vector_slice &assign (const vector_expression<AE> &ae);
- template<class AE>
- matrix_vector_slice &operator += (const vector_expression<AE> &ae);
- template<class AE>
- matrix_vector_slice &plus_assign (const vector_expression<AE> &ae);
- template<class AE>
- matrix_vector_slice &operator -= (const vector_expression<AE> &ae);
- template<class AE>
- matrix_vector_slice &minus_assign (const vector_expression<AE> &ae);
- template<class AT>
- matrix_vector_slice &operator *= (const AT &at);
- template<class AT>
- matrix_vector_slice &operator /= (const AT &at);
-
- // Swapping
- void swap (matrix_vector_slice &mvs);
- friend void swap (matrix_vector_slice &mvs1, matrix_vector_slice &mvs2);
-
- class const_iterator;
- class iterator;
-
- // Element lookup
- 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 indices.
-
- class const_iterator:
- public container_const_reference<matrix_vector_slice>,
- public random_access_iterator_base<const_iterator, value_type> {
- public:
- typedef typename restrict_traits<typename M::const_iterator1::iterator_category,
- typename M::const_iterator2::iterator_category>::iterator_category iterator_category;
- typedef typename matrix_vector_slice::difference_type difference_type;
- typedef typename matrix_vector_slice::value_type value_type;
- typedef typename matrix_vector_slice::const_reference reference;
- typedef typename matrix_vector_slice::const_pointer pointer;
-
- // Construction and destruction
- const_iterator ();
- const_iterator (const matrix_vector_slice &mvs, const const_iterator1_type &it1, const const_iterator2_type &it2);
- const_iterator (const iterator &it);
-
- // Arithmetic
- const_iterator &operator ++ ();
- const_iterator &operator -- ();
- const_iterator &operator += (difference_type n);
- const_iterator &operator -= (difference_type n);
- difference_type operator - (const const_iterator &it) const;
-
- // 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;
- bool operator <(const const_iterator &it) const;
- };
-
- const_iterator begin () const;
- const_iterator end () const;
-
- class iterator:
- public container_reference<matrix_vector_slice>,
- public random_access_iterator_base<iterator, value_type> {
- public:
- typedef typename restrict_traits<typename M::iterator1::iterator_category,
- typename M::iterator2::iterator_category>::iterator_category iterator_category;
- typedef typename matrix_vector_slice::difference_type difference_type;
- typedef typename matrix_vector_slice::value_type value_type;
- typedef typename matrix_vector_slice::reference reference;
- typedef typename matrix_vector_slice::pointer pointer;
-
- // Construction and destruction
- iterator ();
- iterator (matrix_vector_slice &mvs, const iterator1_type &it1, const iterator2_type &it2);
-
- // Arithmetic
- iterator &operator ++ ();
- iterator &operator -- ();
- iterator &operator += (difference_type n);
- iterator &operator -= (difference_type n);
- difference_type operator - (const iterator &it) const;
-
- // Dereference
- reference operator * () const;
-
- // Index
- size_type index () const;
-
- // Assignment
- iterator &operator = (const iterator &it);
-
- // Comparison
- bool operator == (const iterator &it) const;
- 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 ();
- };
-
- // Matrix based vector slice class
template<class M>
class matrix_vector_slice:
public vector_expression<matrix_vector_slice<M> > {
public:
typedef const M const_matrix_type;
typedef M matrix_type;
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
typedef typename M::pointer pointer;
typedef const vector_const_reference<const matrix_vector_slice<matrix_type> > const_closure_type;
typedef vector_reference<matrix_vector_slice<matrix_type> > closure_type;
typedef slice::const_iterator const_iterator1_type;
typedef slice::const_iterator iterator1_type;
typedef slice::const_iterator const_iterator2_type;
typedef slice::const_iterator iterator2_type;
typedef typename storage_restrict_traits<typename M::storage_category,
dense_proxy_tag>::storage_category storage_category;
// Construction and destruction
matrix_vector_slice ();
matrix_vector_slice (matrix_type &data, const slice &s1, const slice &s2);
// Accessors
size_type size () const;
const_matrix_type &data () const;
matrix_type &data ();
// 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
matrix_vector_slice &operator = (const matrix_vector_slice &mvs);
matrix_vector_slice &assign_temporary (matrix_vector_slice &mvs);
template<class AE>
matrix_vector_slice &operator = (const vector_expression<AE> &ae);
template<class AE>
matrix_vector_slice &assign (const vector_expression<AE> &ae);
template<class AE>
matrix_vector_slice &operator += (const vector_expression<AE> &ae);
template<class AE>
matrix_vector_slice &plus_assign (const vector_expression<AE> &ae);
template<class AE>
matrix_vector_slice &operator -= (const vector_expression<AE> &ae);
template<class AE>
matrix_vector_slice &minus_assign (const vector_expression<AE> &ae);
template<class AT>
matrix_vector_slice &operator *= (const AT &at);
template<class AT>
matrix_vector_slice &operator /= (const AT &at);
// Swapping
void swap (matrix_vector_slice &mvs);
friend void swap (matrix_vector_slice &mvs1, matrix_vector_slice &mvs2);
class const_iterator;
class iterator;
// Element lookup
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 indices.
class const_iterator:
public container_const_reference<matrix_vector_slice>,
public random_access_iterator_base<const_iterator, value_type> {
public:
typedef typename restrict_traits<typename M::const_iterator1::iterator_category,
typename M::const_iterator2::iterator_category>::iterator_category iterator_category;
typedef typename matrix_vector_slice::difference_type difference_type;
typedef typename matrix_vector_slice::value_type value_type;
typedef typename matrix_vector_slice::const_reference reference;
typedef typename matrix_vector_slice::const_pointer pointer;
// Construction and destruction
const_iterator ();
const_iterator (const matrix_vector_slice &mvs, const const_iterator1_type &it1, const const_iterator2_type &it2);
const_iterator (const iterator &it);
// Arithmetic
const_iterator &operator ++ ();
const_iterator &operator -- ();
const_iterator &operator += (difference_type n);
const_iterator &operator -= (difference_type n);
difference_type operator - (const const_iterator &it) const;
// 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;
bool operator <(const const_iterator &it) const;
};
const_iterator begin () const;
const_iterator end () const;
class iterator:
public container_reference<matrix_vector_slice>,
public random_access_iterator_base<iterator, value_type> {
public:
typedef typename restrict_traits<typename M::iterator1::iterator_category,
typename M::iterator2::iterator_category>::iterator_category iterator_category;
typedef typename matrix_vector_slice::difference_type difference_type;
typedef typename matrix_vector_slice::value_type value_type;
typedef typename matrix_vector_slice::reference reference;
typedef typename matrix_vector_slice::pointer pointer;
// Construction and destruction
iterator ();
iterator (matrix_vector_slice &mvs, const iterator1_type &it1, const iterator2_type &it2);
// Arithmetic
iterator &operator ++ ();
iterator &operator -- ();
iterator &operator += (difference_type n);
iterator &operator -= (difference_type n);
difference_type operator - (const iterator &it) const;
// Dereference
reference operator * () const;
// Index
size_type index () const;
// Assignment
iterator &operator = (const iterator &it);
// Comparison
bool operator == (const iterator &it) const;
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 ();
};
+
+The templated class matrix_range<M> allows
-addressing a sub matrix of a matrix.
The templated class matrix_range<M> allows addressing
+a sub matrix of a matrix.
int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- matrix_range<matrix<double> > mr (m, range (0, 3), range (0, 3));
- for (int i = 0; i < mr.size1 (); ++ i)
- for (int j = 0; j < mr.size2 (); ++ j)
- mr (i, j) = 3 * i + j;
- std::cout << mr << std::endl;
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
matrix_range<matrix<double> > mr (m, range (0, 3), range (0, 3));
for (unsigned i = 0; i < mr.size1 (); ++ i)
for (unsigned j = 0; j < mr.size2 (); ++ j)
mr (i, j) = 3 * i + j;
std::cout << mr << std::endl;
}
Defined in the header matrix_proxy.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
M |
- The type of matrix referenced. | -- | Parameter | +Description | +Default | + +
M |
+ The type of matrix referenced. | ++ |
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of +Matrix Expression +.
+matrix_expression<matrix_range<M> >
| Member | -Description | -
|---|---|
matrix_range (matrix_type &data, |
- Constructs a sub matrix. | -
size_type start1 () const |
- Returns the index of the first row. | -
size_type size1 () const |
- Returns the number of rows. | -
size_type start2 () const |
- Returns the index of the first column. | -
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. |
-
matrix_range &operator = (const
- matrix_range &mr) |
- The assignment operator. | -
matrix_range &assign_temporary
- (matrix_range &mr) |
- Assigns a temporary. May change the matrix range mr. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a matrix expression to the sub 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 sub matrix. | -
template<class AE> |
- Adds a matrix expression to the sub 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 sub matrix. | -
template<class AE> |
- Subtracts a matrix expression from the sub matrix. - Left and right hand side of the assignment should be - independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the sub - matrix with a scalar. | -
template<class AT> |
- A computed assignment operator. Divides the sub - matrix through a scalar. | -
void swap (matrix_range &mr) |
- Swaps the contents of the sub matrices. | -
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the matrix_range. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the matrix_range. |
-
iterator1 begin1 () |
- Returns a iterator1 pointing to the
- beginning of the matrix_range. |
-
iterator1 end1 () |
- Returns a iterator1 pointing to the end
- of the matrix_range. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the matrix_range. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the matrix_range. |
-
iterator2 begin2 () |
- Returns a iterator2 pointing to the
- beginning of the matrix_range. |
-
iterator2 end2 () |
- Returns a iterator2 pointing to the end
- of the matrix_range. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed matrix_range.
- |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed matrix_range.
- |
-
reverse_iterator1 rbegin1 () |
- Returns a reverse_iterator1 pointing to
- the beginning of the reversed matrix_range. |
-
reverse_iterator1 rend1 () |
- Returns a reverse_iterator1 pointing to
- the end of the reversed matrix_range. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed matrix_range.
- |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed matrix_range.
- |
-
reverse_iterator2 rbegin2 () |
- Returns a reverse_iterator2 pointing to
- the beginning of the reversed matrix_range. |
-
reverse_iterator2 rend2 () |
- Returns a reverse_iterator2 pointing to
- the end of reversed the matrix_range. |
- Member | +Description | + +
matrix_range (matrix_type &data, |
+ Constructs a sub matrix. | +
size_type start1 () const |
+ Returns the index of the first row. | +
size_type size1 () const |
+ Returns the number of rows. | +
size_type start2 () const |
+ Returns the index of the first column. | +
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. |
+
matrix_range &operator = (const matrix_range
+&mr) |
+ The assignment operator. | +
matrix_range &assign_temporary (matrix_range
+&mr) |
+ Assigns a temporary. May change the matrix range mr
+. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a matrix expression to the sub 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 sub matrix. | +
template<class AE> |
+ Adds a matrix expression to the sub 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 sub matrix. | +
template<class AE> |
+ Subtracts a matrix expression from the sub matrix. Left +and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the sub matrix +with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the sub matrix +through a scalar. | +
void swap (matrix_range &mr) |
+ Swaps the contents of the sub matrices. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to the
+beginning of the matrix_range. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to the
+end of the matrix_range. |
+
iterator1 begin1 () |
+ Returns a iterator1 pointing to the beginning
+of the matrix_range. |
+
iterator1 end1 () |
+ Returns a iterator1 pointing to the end
+ of the matrix_range. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to the
+beginning of the matrix_range. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to the
+end of the matrix_range. |
+
iterator2 begin2 () |
+ Returns a iterator2 pointing to the beginning
+of the matrix_range. |
+
iterator2 end2 () |
+ Returns a iterator2 pointing to the end
+ of the matrix_range. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed matrix_range. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed matrix_range. |
+
reverse_iterator1 rbegin1 () |
+ Returns a reverse_iterator1 pointing to
+ the beginning of the reversed matrix_range. |
+
reverse_iterator1 rend1 () |
+ Returns a reverse_iterator1 pointing to
+ the end of the reversed matrix_range. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed matrix_range. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed matrix_range. |
+
reverse_iterator2 rbegin2 () |
+ Returns a reverse_iterator2 pointing to
+ the beginning of the reversed matrix_range. |
+
reverse_iterator2 rend2 () |
+ Returns a reverse_iterator2 pointing to
+ the end of reversed the matrix_range. |
+
// Matrix based range class
- template<class M>
- class matrix_range:
- public matrix_expression<matrix_range<M> > {
- public:
- typedef const M const_matrix_type;
- typedef M matrix_type;
- typedef typename M::size_type size_type;
- typedef typename M::difference_type difference_type;
- typedef typename M::value_type value_type;
- typedef typename M::const_reference const_reference;
- typedef typename M::reference reference;
- typedef typename M::const_pointer const_pointer;
- typedef typename M::pointer pointer;
- typedef const matrix_const_reference<const matrix_range<matrix_type> > const_closure_type;
- typedef matrix_reference<matrix_range<matrix_type> > closure_type;
- typedef typename M::const_iterator1 const_iterator1_type;
- typedef typename M::iterator1 iterator1_type;
- typedef typename M::const_iterator2 const_iterator2_type;
- typedef typename M::iterator2 iterator2_type;
- typedef typename storage_restrict_traits<typename M::storage_category,
- dense_proxy_tag>::storage_category storage_category;
- typedef typename M::orientation_category orientation_category;
-
- // Construction and destruction
- matrix_range ();
- matrix_range (matrix_type &data, const range &r1, const range &r2);
-
- // Accessors
- size_type start1 () const;
- size_type size1 () const;
- size_type start2() const;
- size_type size2 () const;
- const_matrix_type &data () const;
- matrix_type &data ();
-
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
- reference operator () (size_type i, size_type j);
-
- matrix_range<matrix_type> project (const range &r1, const range &r2) const;
-
- // Assignment
- matrix_range &operator = (const matrix_range &mr);
- matrix_range &assign_temporary (matrix_range &mr);
- template<class AE>
- matrix_range &operator = (const matrix_expression<AE> &ae);
- template<class AE>
- matrix_range &assign (const matrix_expression<AE> &ae);
- template<class AE>
- matrix_range& operator += (const matrix_expression<AE> &ae);
- template<class AE>
- matrix_range &plus_assign (const matrix_expression<AE> &ae);
- template<class AE>
- matrix_range& operator -= (const matrix_expression<AE> &ae);
- template<class AE>
- matrix_range &minus_assign (const matrix_expression<AE> &ae);
- template<class AT>
- matrix_range& operator *= (const AT &at);
- template<class AT>
- matrix_range& operator /= (const AT &at);
-
- // Swapping
- void swap (matrix_range &mr);
- friend void swap (matrix_range &mr1, matrix_range &mr2);
-
- 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 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<matrix_range>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef typename const_iterator1_type::iterator_category iterator_category;
- typedef typename const_iterator1_type::difference_type difference_type;
- typedef typename const_iterator1_type::value_type value_type;
- typedef typename const_iterator1_type::reference reference;
- typedef typename const_iterator1_type::pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const matrix_range &mr, const const_iterator1_type &it);
- const_iterator1 (const iterator1 &it);
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator <(const const_iterator1 &it) const;
- };
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class iterator1:
- public container_reference<matrix_range>,
- public random_access_iterator_base<iterator1, value_type> {
- public:
- typedef typename iterator1_type::iterator_category iterator_category;
- typedef typename iterator1_type::difference_type difference_type;
- typedef typename iterator1_type::value_type value_type;
- typedef typename iterator1_type::reference reference;
- typedef typename iterator1_type::pointer pointer;
- typedef iterator2 dual_iterator_type;
- typedef reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator1 ();
- iterator1 (matrix_range &mr, const iterator1_type &it);
-
- // Arithmetic
- iterator1 &operator ++ ();
- iterator1 &operator -- ();
- iterator1 &operator += (difference_type n);
- iterator1 &operator -= (difference_type n);
- difference_type operator - (const iterator1 &it) const;
-
- // 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;
- bool operator <(const iterator1 &it) const;
- };
-
- iterator1 begin1 ();
- iterator1 end1 ();
-
- class const_iterator2:
- public container_const_reference<matrix_range>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef typename const_iterator2_type::iterator_category iterator_category;
- typedef typename const_iterator2_type::difference_type difference_type;
- typedef typename const_iterator2_type::value_type value_type;
- typedef typename const_iterator2_type::reference reference;
- typedef typename const_iterator2_type::pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const matrix_range &mr, const const_iterator2_type &it);
- const_iterator2 (const iterator2 &it);
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator <(const const_iterator2 &it) const;
- };
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- class iterator2:
- public container_reference<matrix_range>,
- public random_access_iterator_base<iterator2, value_type> {
- public:
- typedef typename iterator2_type::iterator_category iterator_category;
- typedef typename iterator2_type::difference_type difference_type;
- typedef typename iterator2_type::value_type value_type;
- typedef typename iterator2_type::reference reference;
- typedef typename iterator2_type::pointer pointer;
- typedef iterator1 dual_iterator_type;
- typedef reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator2 ();
- iterator2 (matrix_range &mr, const iterator2_type &it);
-
- // Arithmetic
- iterator2 &operator ++ ();
- iterator2 &operator -- ();
- iterator2 &operator += (difference_type n);
- iterator2 &operator -= (difference_type n);
- difference_type operator - (const iterator2 &it) const;
-
- // 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;
- 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 ();
- };
-
+
+ // Matrix based range class
template<class M>
class matrix_range:
public matrix_expression<matrix_range<M> > {
public:
typedef const M const_matrix_type;
typedef M matrix_type;
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
typedef typename M::pointer pointer;
typedef const matrix_const_reference<const matrix_range<matrix_type> > const_closure_type;
typedef matrix_reference<matrix_range<matrix_type> > closure_type;
typedef typename M::const_iterator1 const_iterator1_type;
typedef typename M::iterator1 iterator1_type;
typedef typename M::const_iterator2 const_iterator2_type;
typedef typename M::iterator2 iterator2_type;
typedef typename storage_restrict_traits<typename M::storage_category,
dense_proxy_tag>::storage_category storage_category;
typedef typename M::orientation_category orientation_category;
// Construction and destruction
matrix_range ();
matrix_range (matrix_type &data, const range &r1, const range &r2);
// Accessors
size_type start1 () const;
size_type size1 () const;
size_type start2() const;
size_type size2 () const;
const_matrix_type &data () const;
matrix_type &data ();
// Element access
const_reference operator () (size_type i, size_type j) const;
reference operator () (size_type i, size_type j);
matrix_range<matrix_type> project (const range &r1, const range &r2) const;
// Assignment
matrix_range &operator = (const matrix_range &mr);
matrix_range &assign_temporary (matrix_range &mr);
template<class AE>
matrix_range &operator = (const matrix_expression<AE> &ae);
template<class AE>
matrix_range &assign (const matrix_expression<AE> &ae);
template<class AE>
matrix_range& operator += (const matrix_expression<AE> &ae);
template<class AE>
matrix_range &plus_assign (const matrix_expression<AE> &ae);
template<class AE>
matrix_range& operator -= (const matrix_expression<AE> &ae);
template<class AE>
matrix_range &minus_assign (const matrix_expression<AE> &ae);
template<class AT>
matrix_range& operator *= (const AT &at);
template<class AT>
matrix_range& operator /= (const AT &at);
// Swapping
void swap (matrix_range &mr);
friend void swap (matrix_range &mr1, matrix_range &mr2);
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 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<matrix_range>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef typename const_iterator1_type::iterator_category iterator_category;
typedef typename const_iterator1_type::difference_type difference_type;
typedef typename const_iterator1_type::value_type value_type;
typedef typename const_iterator1_type::reference reference;
typedef typename const_iterator1_type::pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const matrix_range &mr, const const_iterator1_type &it);
const_iterator1 (const iterator1 &it);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator <(const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class iterator1:
public container_reference<matrix_range>,
public random_access_iterator_base<iterator1, value_type> {
public:
typedef typename iterator1_type::iterator_category iterator_category;
typedef typename iterator1_type::difference_type difference_type;
typedef typename iterator1_type::value_type value_type;
typedef typename iterator1_type::reference reference;
typedef typename iterator1_type::pointer pointer;
typedef iterator2 dual_iterator_type;
typedef reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
iterator1 ();
iterator1 (matrix_range &mr, const iterator1_type &it);
// Arithmetic
iterator1 &operator ++ ();
iterator1 &operator -- ();
iterator1 &operator += (difference_type n);
iterator1 &operator -= (difference_type n);
difference_type operator - (const iterator1 &it) const;
// 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;
bool operator <(const iterator1 &it) const;
};
iterator1 begin1 ();
iterator1 end1 ();
class const_iterator2:
public container_const_reference<matrix_range>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef typename const_iterator2_type::iterator_category iterator_category;
typedef typename const_iterator2_type::difference_type difference_type;
typedef typename const_iterator2_type::value_type value_type;
typedef typename const_iterator2_type::reference reference;
typedef typename const_iterator2_type::pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const matrix_range &mr, const const_iterator2_type &it);
const_iterator2 (const iterator2 &it);
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator <(const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
class iterator2:
public container_reference<matrix_range>,
public random_access_iterator_base<iterator2, value_type> {
public:
typedef typename iterator2_type::iterator_category iterator_category;
typedef typename iterator2_type::difference_type difference_type;
typedef typename iterator2_type::value_type value_type;
typedef typename iterator2_type::reference reference;
typedef typename iterator2_type::pointer pointer;
typedef iterator1 dual_iterator_type;
typedef reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
iterator2 ();
iterator2 (matrix_range &mr, const iterator2_type &it);
// Arithmetic
iterator2 &operator ++ ();
iterator2 &operator -- ();
iterator2 &operator += (difference_type n);
iterator2 &operator -= (difference_type n);
difference_type operator - (const iterator2 &it) const;
// 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;
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 ();
};
+
template<class M>
- matrix_range<M> project (M &data, const range &r1, const range &r2);
- template<class M>
- const matrix_range<const M> project (const M &data, const range &r1, const range &r2);
- template<class M>
- matrix_range<M> project (const matrix_range<M> &data, const range &r1, const range &r2);
-
+
+ template<class M>
matrix_range<M> project (M &data, const range &r1, const range &r2);
template<class M>
const matrix_range<const M> project (const M &data, const range &r1, const range &r2);
template<class M>
matrix_range<M> project (const matrix_range<M> &data, const range &r1, const range &r2);
+
The free project functions support the
-construction of matrix ranges.
The free project functions support the construction of matrix
+ranges.
Defined in the header matrix_proxy.hpp.
- +M is a model of Matrix Expression.M is a model of
+Matrix Expression
+.r1.start () + r1.size () <= data.size1 ()
- r2.start () + r2.size () <= data.size2 ()
- r1.start () + r1.size () <= data.size1 () r2.start () + r2.size () <= data.size2 () Quadratic depending from the size of the ranges.
- +int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (int i = 0; i < m.size1 (); ++ i)
- for (int j = 0; j < m.size2 (); ++ j)
- project (m, range (0, 3), range (0, 3)) (i, j) = 3 * i + j;
- std::cout << project (m, range (0, 3), range (0, 3)) << std::endl;
-}
-
-#include <boost/numeric/ublas/matrix.hpp>+
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned j = 0; j < m.size2 (); ++ j)
project (m, range (0, 3), range (0, 3)) (i, j) = 3 * i + j;
std::cout << project (m, range (0, 3), range (0, 3)) << std::endl;
}
The templated class matrix_slice<M> allows
-addressing a sliced sub matrix of a matrix.
The templated class matrix_slice<M> allows addressing
+a sliced sub matrix of a matrix.
int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- matrix_slice<matrix<double> > ms (m, slice (0, 1, 3), slice (0, 1, 3));
- for (int i = 0; i < ms.size1 (); ++ i)
- for (int j = 0; j < ms.size2 (); ++ j)
- ms (i, j) = 3 * i + j;
- std::cout << ms << std::endl;
-}
-
+
+#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
matrix_slice<matrix<double> > ms (m, slice (0, 1, 3), slice (0, 1, 3));
for (unsigned i = 0; i < ms.size1 (); ++ i)
for (unsigned j = 0; j < ms.size2 (); ++ j)
ms (i, j) = 3 * i + j;
std::cout << ms << std::endl;
}
Defined in the header matrix_proxy.hpp.
- +| Parameter | -Description | -Default | -
|---|---|---|
M |
- The type of matrix referenced. | -- | Parameter | +Description | +Default | + +
M |
+ The type of matrix referenced. | ++ |
None, except for those imposed by the requirements of Matrix Expression.
- + +None, except for those imposed by the requirements of +Matrix Expression +.
+matrix_expression<matrix_slice<M> >
| Member | -Description | -
|---|---|
matrix_slice (matrix_type &data, |
- Constructs a sub matrix. | -
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. |
-
matrix_slice &operator = (const
- matrix_slice &ms) |
- The assignment operator. | -
matrix_slice &assign_temporary
- (matrix_slice &ms) |
- Assigns a temporary. May change the matrix slice ms. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a matrix expression to the sub 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 sub matrix. | -
template<class AE> |
- Adds a matrix expression to the sub 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 sub matrix. | -
template<class AE> |
- Subtracts a matrix expression from the sub matrix. - Left and right hand side of the assignment should be - independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the sub - matrix with a scalar. | -
template<class AT> |
- A computed assignment operator. Multiplies the sub - matrix through a scalar. | -
void swap (matrix_slice &ms) |
- Swaps the contents of the sub matrices. | -
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the matrix_slice. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the matrix_slice. |
-
iterator1 begin1 () |
- Returns a iterator1 pointing to the
- beginning of the matrix_slice. |
-
iterator1 end1 () |
- Returns a iterator1 pointing to the end
- of the matrix_slice. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the matrix_slice. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the matrix_slice. |
-
iterator2 begin2 () |
- Returns a iterator2 pointing to the
- beginning of the matrix_slice. |
-
iterator2 end2 () |
- Returns a iterator2 pointing to the end
- of the matrix_slice. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed matrix_slice.
- |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed matrix_slice.
- |
-
reverse_iterator1 rbegin1 () |
- Returns a reverse_iterator1 pointing to
- the beginning of the reversed matrix_slice. |
-
reverse_iterator1 rend1 () |
- Returns a reverse_iterator1 pointing to
- the end of the reversed matrix_slice. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed matrix_slice.
- |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed matrix_slice.
- |
-
reverse_iterator2 rbegin2 () |
- Returns a reverse_iterator2 pointing to
- the beginning of the reversed matrix_slice. |
-
reverse_iterator2 rend2 () |
- Returns a reverse_iterator2 pointing to
- the end of the reversed matrix_slice. |
- Member | +Description | + +
matrix_slice (matrix_type &data, |
+ Constructs a sub matrix. | +
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. |
+
matrix_slice &operator = (const matrix_slice
+&ms) |
+ The assignment operator. | +
matrix_slice &assign_temporary (matrix_slice
+&ms) |
+ Assigns a temporary. May change the matrix slice ms
+. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a matrix expression to the sub 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 sub matrix. | +
template<class AE> |
+ Adds a matrix expression to the sub 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 sub matrix. | +
template<class AE> |
+ Subtracts a matrix expression from the sub matrix. Left +and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the sub matrix +with a scalar. | +
template<class AT> |
+ A computed assignment operator. Multiplies the sub matrix +through a scalar. | +
void swap (matrix_slice &ms) |
+ Swaps the contents of the sub matrices. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to the
+beginning of the matrix_slice. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to the
+end of the matrix_slice. |
+
iterator1 begin1 () |
+ Returns a iterator1 pointing to the beginning
+of the matrix_slice. |
+
iterator1 end1 () |
+ Returns a iterator1 pointing to the end
+ of the matrix_slice. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to the
+beginning of the matrix_slice. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to the
+end of the matrix_slice. |
+
iterator2 begin2 () |
+ Returns a iterator2 pointing to the beginning
+of the matrix_slice. |
+
iterator2 end2 () |
+ Returns a iterator2 pointing to the end
+ of the matrix_slice. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed matrix_slice. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed matrix_slice. |
+
reverse_iterator1 rbegin1 () |
+ Returns a reverse_iterator1 pointing to
+ the beginning of the reversed matrix_slice. |
+
reverse_iterator1 rend1 () |
+ Returns a reverse_iterator1 pointing to
+ the end of the reversed matrix_slice. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed matrix_slice. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed matrix_slice. |
+
reverse_iterator2 rbegin2 () |
+ Returns a reverse_iterator2 pointing to
+ the beginning of the reversed matrix_slice. |
+
reverse_iterator2 rend2 () |
+ Returns a reverse_iterator2 pointing to
+ the end of the reversed matrix_slice. |
+
// Matrix based slice class
- template<class M>
- class matrix_slice:
- public matrix_expression<matrix_slice<M> > {
- public:
- typedef const M const_matrix_type;
- typedef M matrix_type;
- typedef typename M::size_type size_type;
- typedef typename M::difference_type difference_type;
- typedef typename M::value_type value_type;
- typedef typename M::const_reference const_reference;
- typedef typename M::reference reference;
- typedef typename M::const_pointer const_pointer;
- typedef typename M::pointer pointer;
- typedef const matrix_const_reference<const matrix_slice<matrix_type> > const_closure_type;
- typedef matrix_reference<matrix_slice<matrix_type> > closure_type;
- typedef slice::const_iterator const_iterator1_type;
- typedef slice::const_iterator iterator1_type;
- typedef slice::const_iterator const_iterator2_type;
- typedef slice::const_iterator iterator2_type;
- typedef typename storage_restrict_traits<typename M::storage_category,
- dense_proxy_tag>::storage_category storage_category;
- typedef typename M::orientation_category orientation_category;
-
- // Construction and destruction
- matrix_slice ();
- matrix_slice (matrix_type &data, const slice &s1, const slice &s2);
-
- // Accessors
- size_type size1 () const;
- size_type size2 () const;
- const_matrix_type &data () const;
- matrix_type &data ();
-
- // Element access
- const_reference operator () (size_type i, size_type j) const;
- reference operator () (size_type i, size_type j);
-
- matrix_slice<matrix_type> project (const range &r1, const range &r2) const;
- matrix_slice<matrix_type> project (const slice &s1, const slice &s2) const;
-
- // Assignment
- matrix_slice &operator = (const matrix_slice &ms);
- matrix_slice &assign_temporary (matrix_slice &ms);
- template<class AE>
- matrix_slice &operator = (const matrix_expression<AE> &ae);
- template<class AE>
- matrix_slice &assign (const matrix_expression<AE> &ae);
- template<class AE>
- matrix_slice& operator += (const matrix_expression<AE> &ae);
- template<class AE>
- matrix_slice &plus_assign (const matrix_expression<AE> &ae);
- template<class AE>
- matrix_slice& operator -= (const matrix_expression<AE> &ae);
- template<class AE>
- matrix_slice &minus_assign (const matrix_expression<AE> &ae);
- template<class AT>
- matrix_slice& operator *= (const AT &at);
- template<class AT>
- matrix_slice& operator /= (const AT &at);
-
- // Swapping
- void swap (matrix_slice &ms);
- friend void swap (matrix_slice &ms1, matrix_slice &ms2);
-
- 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 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 indices.
-
- class const_iterator1:
- public container_const_reference<matrix_slice>,
- public random_access_iterator_base<const_iterator1, value_type> {
- public:
- typedef typename M::const_iterator1::iterator_category iterator_category;
- typedef typename M::const_iterator1::difference_type difference_type;
- typedef typename M::const_iterator1::value_type value_type;
- typedef typename M::const_iterator1::reference reference;
- typedef typename M::const_iterator1::pointer pointer;
- typedef const_iterator2 dual_iterator_type;
- typedef const_reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator1 ();
- const_iterator1 (const matrix_slice &ms, const const_iterator1_type &it1, const const_iterator2_type &it2);
- const_iterator1 (const iterator1 &it);
-
- // Arithmetic
- const_iterator1 &operator ++ ();
- const_iterator1 &operator -- ();
- const_iterator1 &operator += (difference_type n);
- const_iterator1 &operator -= (difference_type n);
- difference_type operator - (const const_iterator1 &it) const;
-
- // 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;
- bool operator <(const const_iterator1 &it) const;
- };
-
- const_iterator1 begin1 () const;
- const_iterator1 end1 () const;
-
- class iterator1:
- public container_reference<matrix_slice>,
- public random_access_iterator_base<iterator1, value_type> {
- public:
- typedef typename M::iterator1::iterator_category iterator_category;
- typedef typename M::iterator1::difference_type difference_type;
- typedef typename M::iterator1::value_type value_type;
- typedef typename M::iterator1::reference reference;
- typedef typename M::iterator1::pointer pointer;
- typedef iterator2 dual_iterator_type;
- typedef reverse_iterator2 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator1 ();
- iterator1 (matrix_slice &ms, const iterator1_type &it1, const iterator2_type &it2);
-
- // Arithmetic
- iterator1 &operator ++ ();
- iterator1 &operator -- ();
- iterator1 &operator += (difference_type n);
- iterator1 &operator -= (difference_type n);
- difference_type operator - (const iterator1 &it) const;
-
- // 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;
- bool operator <(const iterator1 &it) const;
- };
-
- iterator1 begin1 ();
- iterator1 end1 ();
-
- class const_iterator2:
- public container_const_reference<matrix_slice>,
- public random_access_iterator_base<const_iterator2, value_type> {
- public:
- typedef typename M::const_iterator2::iterator_category iterator_category;
- typedef typename M::const_iterator2::difference_type difference_type;
- typedef typename M::const_iterator2::value_type value_type;
- typedef typename M::const_iterator2::reference reference;
- typedef typename M::const_iterator2::pointer pointer;
- typedef const_iterator1 dual_iterator_type;
- typedef const_reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- const_iterator2 ();
- const_iterator2 (const matrix_slice &ms, const const_iterator1_type &it1, const const_iterator2_type &it2);
- const_iterator2 (const iterator2 &it);
-
- // Arithmetic
- const_iterator2 &operator ++ ();
- const_iterator2 &operator -- ();
- const_iterator2 &operator += (difference_type n);
- const_iterator2 &operator -= (difference_type n);
- difference_type operator - (const const_iterator2 &it) const;
-
- // 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;
- bool operator <(const const_iterator2 &it) const;
- };
-
- const_iterator2 begin2 () const;
- const_iterator2 end2 () const;
-
- class iterator2:
- public container_reference<matrix_slice>,
- public random_access_iterator_base<iterator2, value_type> {
- public:
- typedef typename M::iterator2::iterator_category iterator_category;
- typedef typename M::iterator2::difference_type difference_type;
- typedef typename M::iterator2::value_type value_type;
- typedef typename M::iterator2::reference reference;
- typedef typename M::iterator2::pointer pointer;
- typedef iterator1 dual_iterator_type;
- typedef reverse_iterator1 dual_reverse_iterator_type;
-
- // Construction and destruction
- iterator2 ();
- iterator2 (matrix_slice &ms, const iterator1_type &it1, const iterator2_type &it2);
-
- // Arithmetic
- iterator2 &operator ++ ();
- iterator2 &operator -- ();
- iterator2 &operator += (difference_type n);
- iterator2 &operator -= (difference_type n);
- difference_type operator - (const iterator2 &it) const;
-
- // 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;
- 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 ();
- };
-
+
+ // Matrix based slice class
template<class M>
class matrix_slice:
public matrix_expression<matrix_slice<M> > {
public:
typedef const M const_matrix_type;
typedef M matrix_type;
typedef typename M::size_type size_type;
typedef typename M::difference_type difference_type;
typedef typename M::value_type value_type;
typedef typename M::const_reference const_reference;
typedef typename M::reference reference;
typedef typename M::const_pointer const_pointer;
typedef typename M::pointer pointer;
typedef const matrix_const_reference<const matrix_slice<matrix_type> > const_closure_type;
typedef matrix_reference<matrix_slice<matrix_type> > closure_type;
typedef slice::const_iterator const_iterator1_type;
typedef slice::const_iterator iterator1_type;
typedef slice::const_iterator const_iterator2_type;
typedef slice::const_iterator iterator2_type;
typedef typename storage_restrict_traits<typename M::storage_category,
dense_proxy_tag>::storage_category storage_category;
typedef typename M::orientation_category orientation_category;
// Construction and destruction
matrix_slice ();
matrix_slice (matrix_type &data, const slice &s1, const slice &s2);
// Accessors
size_type size1 () const;
size_type size2 () const;
const_matrix_type &data () const;
matrix_type &data ();
// Element access
const_reference operator () (size_type i, size_type j) const;
reference operator () (size_type i, size_type j);
matrix_slice<matrix_type> project (const range &r1, const range &r2) const;
matrix_slice<matrix_type> project (const slice &s1, const slice &s2) const;
// Assignment
matrix_slice &operator = (const matrix_slice &ms);
matrix_slice &assign_temporary (matrix_slice &ms);
template<class AE>
matrix_slice &operator = (const matrix_expression<AE> &ae);
template<class AE>
matrix_slice &assign (const matrix_expression<AE> &ae);
template<class AE>
matrix_slice& operator += (const matrix_expression<AE> &ae);
template<class AE>
matrix_slice &plus_assign (const matrix_expression<AE> &ae);
template<class AE>
matrix_slice& operator -= (const matrix_expression<AE> &ae);
template<class AE>
matrix_slice &minus_assign (const matrix_expression<AE> &ae);
template<class AT>
matrix_slice& operator *= (const AT &at);
template<class AT>
matrix_slice& operator /= (const AT &at);
// Swapping
void swap (matrix_slice &ms);
friend void swap (matrix_slice &ms1, matrix_slice &ms2);
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 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 indices.
class const_iterator1:
public container_const_reference<matrix_slice>,
public random_access_iterator_base<const_iterator1, value_type> {
public:
typedef typename M::const_iterator1::iterator_category iterator_category;
typedef typename M::const_iterator1::difference_type difference_type;
typedef typename M::const_iterator1::value_type value_type;
typedef typename M::const_iterator1::reference reference;
typedef typename M::const_iterator1::pointer pointer;
typedef const_iterator2 dual_iterator_type;
typedef const_reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
const_iterator1 ();
const_iterator1 (const matrix_slice &ms, const const_iterator1_type &it1, const const_iterator2_type &it2);
const_iterator1 (const iterator1 &it);
// Arithmetic
const_iterator1 &operator ++ ();
const_iterator1 &operator -- ();
const_iterator1 &operator += (difference_type n);
const_iterator1 &operator -= (difference_type n);
difference_type operator - (const const_iterator1 &it) const;
// 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;
bool operator <(const const_iterator1 &it) const;
};
const_iterator1 begin1 () const;
const_iterator1 end1 () const;
class iterator1:
public container_reference<matrix_slice>,
public random_access_iterator_base<iterator1, value_type> {
public:
typedef typename M::iterator1::iterator_category iterator_category;
typedef typename M::iterator1::difference_type difference_type;
typedef typename M::iterator1::value_type value_type;
typedef typename M::iterator1::reference reference;
typedef typename M::iterator1::pointer pointer;
typedef iterator2 dual_iterator_type;
typedef reverse_iterator2 dual_reverse_iterator_type;
// Construction and destruction
iterator1 ();
iterator1 (matrix_slice &ms, const iterator1_type &it1, const iterator2_type &it2);
// Arithmetic
iterator1 &operator ++ ();
iterator1 &operator -- ();
iterator1 &operator += (difference_type n);
iterator1 &operator -= (difference_type n);
difference_type operator - (const iterator1 &it) const;
// 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;
bool operator <(const iterator1 &it) const;
};
iterator1 begin1 ();
iterator1 end1 ();
class const_iterator2:
public container_const_reference<matrix_slice>,
public random_access_iterator_base<const_iterator2, value_type> {
public:
typedef typename M::const_iterator2::iterator_category iterator_category;
typedef typename M::const_iterator2::difference_type difference_type;
typedef typename M::const_iterator2::value_type value_type;
typedef typename M::const_iterator2::reference reference;
typedef typename M::const_iterator2::pointer pointer;
typedef const_iterator1 dual_iterator_type;
typedef const_reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
const_iterator2 ();
const_iterator2 (const matrix_slice &ms, const const_iterator1_type &it1, const const_iterator2_type &it2);
const_iterator2 (const iterator2 &it);
// Arithmetic
const_iterator2 &operator ++ ();
const_iterator2 &operator -- ();
const_iterator2 &operator += (difference_type n);
const_iterator2 &operator -= (difference_type n);
difference_type operator - (const const_iterator2 &it) const;
// 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;
bool operator <(const const_iterator2 &it) const;
};
const_iterator2 begin2 () const;
const_iterator2 end2 () const;
class iterator2:
public container_reference<matrix_slice>,
public random_access_iterator_base<iterator2, value_type> {
public:
typedef typename M::iterator2::iterator_category iterator_category;
typedef typename M::iterator2::difference_type difference_type;
typedef typename M::iterator2::value_type value_type;
typedef typename M::iterator2::reference reference;
typedef typename M::iterator2::pointer pointer;
typedef iterator1 dual_iterator_type;
typedef reverse_iterator1 dual_reverse_iterator_type;
// Construction and destruction
iterator2 ();
iterator2 (matrix_slice &ms, const iterator1_type &it1, const iterator2_type &it2);
// Arithmetic
iterator2 &operator ++ ();
iterator2 &operator -- ();
iterator2 &operator += (difference_type n);
iterator2 &operator -= (difference_type n);
difference_type operator - (const iterator2 &it) const;
// 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;
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 ();
};
+
template<class M>
- matrix_slice<M> project (const matrix_slice<M> &data, const range &r1, const range &r2);
- template<class M>
- matrix_slice<M> project (M &data, const slice &s1, const slice &s2);
- template<class M>
- const matrix_slice<const M> project (const M &data, const slice &s1, const slice &s2);
- template<class M>
- matrix_slice<M> project (const matrix_slice<M> &data, const slice &s1, const slice &s2);
-
+
+ template<class M>
matrix_slice<M> project (const matrix_slice<M> &data, const range &r1, const range &r2);
template<class M>
matrix_slice<M> project (M &data, const slice &s1, const slice &s2);
template<class M>
const matrix_slice<const M> project (const M &data, const slice &s1, const slice &s2);
template<class M>
matrix_slice<M> project (const matrix_slice<M> &data, const slice &s1, const slice &s2);
+
The free project functions support the
-construction of matrix slices.
The free project functions support the construction of matrix
+slices.
Defined in the header matrix_proxy.hpp.
- +M is a model of Matrix Expression.M is a model of
+Matrix Expression
+.s1.start () + s1.stride () * s1.size () <= data.size1 ()
- s2.start () + s2.stride () * s2.size () <= data.size2 ()
- s1.start () + s1.stride () * s1.size () <= data.size1 ()
+ s2.start () + s2.stride () * s2.size () <= data.size2 ()
+ Quadratic depending from the size of the slices.
- +int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (int i = 0; i < m.size1 (); ++ i)
- for (int j = 0; j < m.size2 (); ++ j)
- project (m, slice (0, 1, 3), slice (0, 1, 3)) (i, j) = 3 * i + j;
- std::cout << project (m, slice (0, 1, 3), slice (0, 1, 3)) << std::endl;
-}
-
-Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this
-document is granted provided this copyright notice appears in all
-copies. This document is provided ``as is'' without express or
-implied warranty, and with no claim as to its suitability for any
-purpose.
#include <boost/numeric/ublas/matrix.hpp>+
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned j = 0; j < m.size2 (); ++ j)
project (m, slice (0, 1, 3), slice (0, 1, 3)) (i, j) = 3 * i + j;
std::cout << project (m, slice (0, 1, 3), slice (0, 1, 3)) << std::endl;
}
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+ Permission to copy, use, modify, sell and distribute this document is granted
+provided this copyright notice appears in all copies. This document is provided
+``as is'' without express or implied warranty, and with no claim as to its
+suitability for any purpose.
Last revised: 8/3/2002
+ diff --git a/doc/matrix_sparse.htm b/doc/matrix_sparse.htm index 95b4df24..619e0420 100644 --- a/doc/matrix_sparse.htm +++ b/doc/matrix_sparse.htm @@ -1,1898 +1,1014 @@ + - - - -
Sparse Matrix
+Sparse MatrixThe 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
-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 associative container, 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.
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 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 associative container, 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 < j
+2 or (j1 = j2
+and i1 < i2
+) with column major orientation.
int main () {
- using namespace boost::numeric::ublas;
- sparse_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;
-}
-
+
+#include <boost/numeric/ublas/matrix_sparse.hpp>+
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
sparse_matrix<double> m (3, 3, 3 * 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned 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 sparse matrix. | -- |
F |
- Functor describing the storage organization. [1] | -row_major |
-
A |
- The type of the adapted array. [2] | -map_array<std::size_t, T> |
- Parameter | +Description | +Default | + +
T |
+ The type of object stored in the sparse matrix. | ++ |
F |
+ Functor describing the storage organization. +[1] + | +row_major |
+
A |
+ The type of the adapted array. [2] + | +map_array<std::size_t, T> |
+
Matrix +.
+None, except for those imposed by the requirements of Matrix.
- + +None, except for those imposed by the requirements of +Matrix +.
+matrix_expression<sparse_matrix<T, F, A> >
-
matrix_expression<sparse_matrix<T, F, A> >
| Member | -Description | -
|---|---|
sparse_matrix () |
- Allocates a sparse_matrix that holds at
- most zero rows of zero elements. |
-
sparse_matrix (size_type size1, size_type2,
- size_type non_zeros) |
- Allocates a sparse_matrix that holds at
- most size1 rows of size2 elements. |
-
sparse_matrix (const sparse_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 sparse_matrix to hold at
- most size1 rows of size2 elements.
- The content of the sparse_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. |
-
sparse_matrix &operator = (const
- sparse_matrix &m) |
- The assignment operator. | -
sparse_matrix &assign_temporary
- (sparse_matrix &m) |
- Assigns a temporary. May change the sparse matrix m. |
-
template<class AE> |
- The extended assignment operator. | -
template<class AE> |
- Assigns a matrix expression to the sparse 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 sparse matrix. | -
template<class AE> |
- Adds a matrix expression to the sparse 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 sparse matrix. | -
template<class AE> |
- Subtracts a matrix expression from the sparse matrix. - Left and right hand side of the assignment should be - independent. | -
template<class AT> |
- A computed assignment operator. Multiplies the sparse - matrix with a scalar. | -
template<class AT> |
- A computed assignment operator. Divides the sparse - matrix through a scalar. | -
void swap (sparse_matrix &m) |
- Swaps the contents of the sparse 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 sparse matrix. | -
const_iterator1 begin1 () const |
- Returns a const_iterator1 pointing to
- the beginning of the sparse_matrix. |
-
const_iterator1 end1 () const |
- Returns a const_iterator1 pointing to
- the end of the sparse_matrix. |
-
iterator1 begin1 () |
- Returns a iterator1 pointing to the
- beginning of the sparse_matrix. |
-
iterator1 end1 () |
- Returns a iterator1 pointing to the end
- of the sparse_matrix. |
-
const_iterator2 begin2 () const |
- Returns a const_iterator2 pointing to
- the beginning of the sparse_matrix. |
-
const_iterator2 end2 () const |
- Returns a const_iterator2 pointing to
- the end of the sparse_matrix. |
-
iterator2 begin2 () |
- Returns a iterator2 pointing to the
- beginning of the sparse_matrix. |
-
iterator2 end2 () |
- Returns a iterator2 pointing to the end
- of the sparse_matrix. |
-
const_reverse_iterator1 rbegin1 () const |
- Returns a const_reverse_iterator1
- pointing to the beginning of the reversed sparse_matrix.
- |
-
const_reverse_iterator1 rend1 () const |
- Returns a const_reverse_iterator1
- pointing to the end of the reversed sparse_matrix.
- |
-
reverse_iterator1 rbegin1 () |
- Returns a reverse_iterator1 pointing to
- the beginning of the reversed sparse_matrix.
- |
-
reverse_iterator1 rend1 () |
- Returns a reverse_iterator1 pointing to
- the end of the reversed sparse_matrix. |
-
const_reverse_iterator2 rbegin2 () const |
- Returns a const_reverse_iterator2
- pointing to the beginning of the reversed sparse_matrix.
- |
-
const_reverse_iterator2 rend2 () const |
- Returns a const_reverse_iterator2
- pointing to the end of the reversed sparse_matrix.
- |
-
reverse_iterator2 rbegin2 () |
- Returns a reverse_iterator2 pointing to
- the beginning of the reversed sparse_matrix.
- |
-
reverse_iterator2 rend2 () |
- Returns a reverse_iterator2 pointing to
- the end of the reversed sparse_matrix. |
- Member | +Description | + +
sparse_matrix () |
+ Allocates a sparse_matrix that holds at
+ most zero rows of zero elements. |
+
sparse_matrix (size_type size1, size_type2, size_type
+non_zeros) |
+ Allocates a sparse_matrix that holds at
+ most size1 rows of size2 elements. |
+
sparse_matrix (const sparse_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 sparse_matrix to hold at
+most size1 rows of size2 elements. The
+content of the sparse_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. |
+
sparse_matrix &operator = (const sparse_matrix
+&m) |
+ The assignment operator. | +
sparse_matrix &assign_temporary (sparse_matrix
+&m) |
+ Assigns a temporary. May change the sparse matrix m
+. |
+
template<class AE> |
+ The extended assignment operator. | +
template<class AE> |
+ Assigns a matrix expression to the sparse 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 sparse matrix. | +
template<class AE> |
+ Adds a matrix expression to the sparse 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 sparse matrix. | +
template<class AE> |
+ Subtracts a matrix expression from the sparse matrix. + Left and right hand side of the assignment should be independent. | +
template<class AT> |
+ A computed assignment operator. Multiplies the sparse + matrix with a scalar. | +
template<class AT> |
+ A computed assignment operator. Divides the sparse matrix +through a scalar. | +
void swap (sparse_matrix &m) |
+ Swaps the contents of the sparse 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 sparse matrix. | +
const_iterator1 begin1 () const |
+ Returns a const_iterator1 pointing to the
+beginning of the sparse_matrix. |
+
const_iterator1 end1 () const |
+ Returns a const_iterator1 pointing to the
+end of the sparse_matrix. |
+
iterator1 begin1 () |
+ Returns a iterator1 pointing to the beginning
+of the sparse_matrix. |
+
iterator1 end1 () |
+ Returns a iterator1 pointing to the end
+ of the sparse_matrix. |
+
const_iterator2 begin2 () const |
+ Returns a const_iterator2 pointing to the
+beginning of the sparse_matrix. |
+
const_iterator2 end2 () const |
+ Returns a const_iterator2 pointing to the
+end of the sparse_matrix. |
+
iterator2 begin2 () |
+ Returns a iterator2 pointing to the beginning
+of the sparse_matrix. |
+
iterator2 end2 () |
+ Returns a iterator2 pointing to the end
+ of the sparse_matrix. |
+
const_reverse_iterator1 rbegin1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the beginning of the reversed sparse_matrix. |
+
const_reverse_iterator1 rend1 () const |
+ Returns a const_reverse_iterator1 pointing
+to the end of the reversed sparse_matrix. |
+
reverse_iterator1 rbegin1 () |
+ Returns a reverse_iterator1 pointing to
+ the beginning of the reversed sparse_matrix. |
+
reverse_iterator1 rend1 () |
+ Returns a reverse_iterator1 pointing to
+ the end of the reversed sparse_matrix. |
+
const_reverse_iterator2 rbegin2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the beginning of the reversed sparse_matrix. |
+
const_reverse_iterator2 rend2 () const |
+ Returns a const_reverse_iterator2 pointing
+to the end of the reversed sparse_matrix. |
+
reverse_iterator2 rbegin2 () |
+ Returns a reverse_iterator2 pointing to
+ the beginning of the reversed sparse_matrix. |
+
reverse_iterator2 rend2 () |
+ Returns a reverse_iterator2 pointing to
+ the end of the reversed sparse_matrix. |
+
[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>.
[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>.
// Array based sparse matrix class
- template<class T, class F, class A>
- class sparse_matrix:
- public matrix_expression<sparse_matrix<T, F, A> > {
- 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 A array_type;
- typedef const A const_array_type;
- typedef const sparse_matrix<T, F, A> const_self_type;
- typedef sparse_matrix<T, F, A> 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
- sparse_matrix ();
- sparse_matrix (size_type size1, size_type size2, size_type non_zeros = 0);
- sparse_matrix (const sparse_matrix &m);
- template<class AE>
- sparse_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;
- const_array_type &data () const;
- array_type &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
- sparse_matrix &operator = (const sparse_matrix &m);
- sparse_matrix &assign_temporary (sparse_matrix &m);
- template<class AE>
- sparse_matrix &operator = (const matrix_expression<AE> &ae);
- template<class AE>
- sparse_matrix &reset (const matrix_expression<AE> &ae);
- template<class AE>
- sparse_matrix &assign (const matrix_expression<AE> &ae);
- template<class AE>
- sparse_matrix& operator += (const matrix_expression<AE> &ae);
- template<class AE>
- sparse_matrix &plus_assign (const matrix_expression<AE> &ae);
- template<class AE>
- sparse_matrix& operator -= (const matrix_expression<AE> &ae);
- template<class AE>
- sparse_matrix &minus_assign (const matrix_expression<AE> &ae);
- template<class AT>
- sparse_matrix& operator *= (const AT &at);
- template<class AT>
- sparse_matrix& operator /= (const AT &at);
-
- // Swapping
- void swap (sparse_matrix &m);
- friend void swap (sparse_matrix &m1, sparse_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<sparse_matrix>,
- public bidirectional_iterator_base<const_iterator1, value_type> {
- public:
- typedef sparse_bidirectional_iterator_tag iterator_category;
- typedef typename sparse_matrix::difference_type difference_type;
- typedef typename sparse_matrix::value_type value_type;
- typedef typename sparse_matrix::const_reference reference;
- typedef typename sparse_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 sparse_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<sparse_matrix>,
- public bidirectional_iterator_base<iterator1, value_type> {
- public:
- typedef sparse_bidirectional_iterator_tag iterator_category;
- typedef typename sparse_matrix::difference_type difference_type;
- typedef typename sparse_matrix::value_type value_type;
- typedef typename sparse_matrix::reference reference;
- typedef typename sparse_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 (sparse_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<sparse_matrix>,
- public bidirectional_iterator_base<const_iterator2, value_type> {
- public:
- typedef sparse_bidirectional_iterator_tag iterator_category;
- typedef typename sparse_matrix::difference_type difference_type;
- typedef typename sparse_matrix::value_type value_type;
- typedef typename sparse_matrix::const_reference reference;
- typedef typename sparse_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 sparse_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<sparse_matrix>,
- public bidirectional_iterator_base<iterator2, value_type> {
- public:
- typedef sparse_bidirectional_iterator_tag iterator_category;
- typedef typename sparse_matrix::difference_type difference_type;
- typedef typename sparse_matrix::value_type value_type;
- typedef typename sparse_matrix::reference reference;
- typedef typename sparse_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 (sparse_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 ();
- };
-
- // Array based sparse matrix class
template<class T, class F, class A>
class sparse_matrix:
public matrix_expression<sparse_matrix<T, F, A> > {
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 A array_type;
typedef const A const_array_type;
typedef const sparse_matrix<T, F, A> const_self_type;
typedef sparse_matrix<T, F, A> 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
sparse_matrix ();
sparse_matrix (size_type size1, size_type size2, size_type non_zeros = 0);
sparse_matrix (const sparse_matrix &m);
template<class AE>
sparse_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;
const_array_type &data () const;
array_type &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
sparse_matrix &operator = (const sparse_matrix &m);
sparse_matrix &assign_temporary (sparse_matrix &m);
template<class AE>
sparse_matrix &operator = (const matrix_expression<AE> &ae);
template<class AE>
sparse_matrix &reset (const matrix_expression<AE> &ae);
template<class AE>
sparse_matrix &assign (const matrix_expression<AE> &ae);
template<class AE>
sparse_matrix& operator += (const matrix_expression<AE> &ae);
template<class AE>
sparse_matrix &plus_assign (const matrix_expression<AE> &ae);
template<class AE>
sparse_matrix& operator -= (const matrix_expression<AE> &ae);
template<class AE>
sparse_matrix &minus_assign (const matrix_expression<AE> &ae);
template<class AT>
sparse_matrix& operator *= (const AT &at);
template<class AT>
sparse_matrix& operator /= (const AT &at);
// Swapping
void swap (sparse_matrix &m);
friend void swap (sparse_matrix &m1, sparse_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<sparse_matrix>,
public bidirectional_iterator_base<const_iterator1, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename sparse_matrix::difference_type difference_type;
typedef typename sparse_matrix::value_type value_type;
typedef typename sparse_matrix::const_reference reference;
typedef typename sparse_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 sparse_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<sparse_matrix>,
public bidirectional_iterator_base<iterator1, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename sparse_matrix::difference_type difference_type;
typedef typename sparse_matrix::value_type value_type;
typedef typename sparse_matrix::reference reference;
typedef typename sparse_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 (sparse_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<sparse_matrix>,
public bidirectional_iterator_base<const_iterator2, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename sparse_matrix::difference_type difference_type;
typedef typename sparse_matrix::value_type value_type;
typedef typename sparse_matrix::const_reference reference;
typedef typename sparse_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 sparse_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<sparse_matrix>,
public bidirectional_iterator_base<iterator2, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename sparse_matrix::difference_type difference_type;
typedef typename sparse_matrix::value_type value_type;
typedef typename sparse_matrix::reference reference;
typedef typename sparse_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 (sparse_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 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.
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 = mi
+1,j1
+ and k + 1 = mi2
+,j2 of the
+container holds i1 < i2
+ or (i1 = i2 and
+j1 < j2)
+ with row major orientation or j1 < j
+2 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;
-}
-
+
+#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
compressed_matrix<double> m (3, 3, 3 * 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned 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> |
- 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> |
+
Matrix +.
+None, except for those imposed by the requirements of Matrix.
- + +None, except for those imposed by the requirements of +Matrix +.
+matrix_expression<compressed_matrix<T, F, IB, IA,
-TA> >
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. |
- 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<>.
[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 ();
- };
-
- // 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 &operato
+r = (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.
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 = m
+i1,j
+1 and k + 1 = mi
+2,j2
+ of the container holds i1 <
+i2 or (i1 = i
+2 and j1 < j
+2) 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;
-}
-
+
+#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
coordinate_matrix<double> m (3, 3, 3 * 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned 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> |
- 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> |
+
Matrix +.
+None, except for those imposed by the requirements of Matrix.
- + +None, except for those imposed by the requirements of +Matrix +.
+matrix_expression<coordinate_matrix<T, F, IB, IA,
-TA> >
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. |
- 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<>.
[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
-Permission to copy, use, modify, sell and distribute this
-document is granted provided this copyright notice appears in all
-copies. This document is provided ``as is'' without express or
-implied warranty, and with no claim as to its suitability for any
-purpose.
// 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 ();<
+br> 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
+ Permission to copy, use, modify, sell and distribute this document is granted
+provided this copyright notice appears in all copies. This document is provided
+``as is'' without express or implied warranty, and with no claim as to its
+suitability for any purpose.
Last revised: 8/3/2002
+ diff --git a/doc/overview.htm b/doc/overview.htm index de8799f4..e5da6a00 100644 --- a/doc/overview.htm +++ b/doc/overview.htm @@ -1,1604 +1,1676 @@ + - - - -
uBLAS Overview
+ uBLAS OverviewIt would be nice if every kind of numeric software could -be written in C++ without loss of efficiency, but unless -something can be found that achieves this without compromising -the C++ type system it may be preferable to rely on Fortran, -assembler or architecture-specific extensions (Bjarne -Stroustrup).
- -This C++ library is directed towards scientific computing on -the level of basic linear algebra constructions with matrices and -vectors and their corresponding abstract operations. The primary -design goals were:
- -It would be nice if every kind of numeric software could be written +in C++ without loss of efficiency, but unless something can be found that +achieves this without compromising the C++ type system it may be preferable +to rely on Fortran, assembler or architecture-specific extensions (Bjarne + Stroustrup).
+ +This C++ library is directed towards scientific computing on the level +of basic linear algebra constructions with matrices and vectors and their +corresponding abstract operations. The primary design goals were:
+ +Another intention was to evaluate, if the abstraction penalty -resulting from the use of such matrix and vector classes is -acceptable.
- + +Another intention was to evaluate, if the abstraction penalty resulting +from the use of such matrix and vector classes is acceptable.
+The development of this library was guided by a couple of -similar efforts:
- -The development of this library was guided by a couple of similar efforts:
+ +BLAS seems to be the most widely used library for basic linear -algebra constructions, so it could be called a de-facto standard. -Its interface is procedural, the individual functions are -somewhat abstracted from simple linear algebra operations. Due to -the fact that is has been implemented using Fortran and its -optimizations, it also seems to be one of the fastest libraries -available. As we decided to design and implement our library in -an object-oriented way, the technical approaches are distinct. -However anyone should be able to express BLAS abstractions in -terms of our library operators and to compare the efficiency of -the implementations.
- -Blitz++ is an impressive library implemented in C++. Its main -design seems to be oriented towards multidimensional arrays and -their associated operators including tensors. The author of -Blitz++ states, that the library achieves performance on par or -better than corresponding Fortran code due to his implementation -technique using expression templates and template metaprograms. -However we see some reasons, to develop an own design and -implementation approach. We do not know whether anybody tries to -implement traditional linear algebra and other numerical -algorithms using Blitz++. We also presume that even today Blitz++ -needs the most advanced C++ compiler technology due to its -implementation idioms. On the other hand, Blitz++ convinced us, -that the use of expression templates is mandatory to reduce the -abstraction penalty to an acceptable limit.
- -POOMA's design goals seem to parallel Blitz++'s in many parts -. It extends Blitz++'s concepts with classes from the domains of -partial differential equations and theoretical physics. The -implementation supports even parallel architectures.
- -MTL is another approach supporting basic linear algebra -operations in C++. Its design mainly seems to be influenced by -BLAS and the C++ Standard Template Library. We share the insight -that a linear algebra library has to provide functionality -comparable to BLAS. On the other hand we think, that the concepts -of the C++ standard library have not yet been proven to support -numerical computations as needed. As another difference MTL -currently does not seem to use expression templates. This may -result in one of two consequences: a possible loss of -expressiveness or a possible loss of performance.
- + +BLAS seems to be the most widely used library for basic linear algebra +constructions, so it could be called a de-facto standard. Its interface is +procedural, the individual functions are somewhat abstracted from simple linear +algebra operations. Due to the fact that is has been implemented using Fortran +and its optimizations, it also seems to be one of the fastest libraries available. +As we decided to design and implement our library in an object-oriented way, +the technical approaches are distinct. However anyone should be able to express +BLAS abstractions in terms of our library operators and to compare the efficiency +of the implementations.
+ +Blitz++ is an impressive library implemented in C++. Its main design seems +to be oriented towards multidimensional arrays and their associated operators +including tensors. The author of Blitz++ states, that the library achieves +performance on par or better than corresponding Fortran code due to his implementation + technique using expression templates and template metaprograms. However +we see some reasons, to develop an own design and implementation approach. +We do not know whether anybody tries to implement traditional linear algebra +and other numerical algorithms using Blitz++. We also presume that even today +Blitz++ needs the most advanced C++ compiler technology due to its implementation +idioms. On the other hand, Blitz++ convinced us, that the use of expression +templates is mandatory to reduce the abstraction penalty to an acceptable +limit.
+ +POOMA's design goals seem to parallel Blitz++'s in many parts . It extends +Blitz++'s concepts with classes from the domains of partial differential equations +and theoretical physics. The implementation supports even parallel architectures.
+ +MTL is another approach supporting basic linear algebra operations in C++. +Its design mainly seems to be influenced by BLAS and the C++ Standard Template +Library. We share the insight that a linear algebra library has to provide +functionality comparable to BLAS. On the other hand we think, that the concepts +of the C++ standard library have not yet been proven to support numerical +computations as needed. As another difference MTL currently does not seem +to use expression templates. This may result in one of two consequences: +a possible loss of expressiveness or a possible loss of performance.
+The usage of mathematical notation may ease the development of -scientific algorithms. So a C++ library implementing basic linear -algebra concepts carefully should overload selected C++ operators -on matrix and vector classes.
- -We decided to use operator overloading for the following -primitives:
- + +The usage of mathematical notation may ease the development of scientific +algorithms. So a C++ library implementing basic linear algebra concepts carefully +should overload selected C++ operators on matrix and vector classes.
+ +We decided to use operator overloading for the following primitives:
+| Description | -Operator | -
|---|---|
| Indexing of vectors and matrices | -vector::operator(size_t i); |
-
| Assignment of vectors and matrices | -vector::operator = (const vector_expression
- &); |
-
| Unary operations on vectors and matrices | -vector_expression operator - (const
- vector_expression &); |
-
| Binary operations on vectors and matrices | -vector_expression operator + (const
- vector_expression &, const vector_expression &); |
-
| Multiplication of vectors and matrices with a scalar | -vector_expression operator * (const
- scalar_expression &, const vector_expression &); |
-
| Description | +Operator | +
| Indexing of vectors and matrices | +vector::operator(size_t i); |
+
| Assignment of vectors and matrices | +vector::operator = (const vector_expression &); |
+
| Unary operations on vectors and matrices | +vector_expression operator - (const vector_expression
+&); |
+
| Binary operations on vectors and matrices | +vector_expression operator + (const vector_expression
+&, const vector_expression &); |
+
| Multiplication of vectors and matrices with a scalar | +vector_expression operator * (const scalar_expression
+&, const vector_expression &); |
+
We decided to use no operator overloading for the following -other primitives:
- + +We decided to use no operator overloading for the following other primitives:
+| Description | -Function | -
|---|---|
| Left multiplication of vectors with a matrix | -vector_expression prod<vector_type>
- (const matrix_expression &, const vector_expression
- &); |
-
| Right multiplication of vectors with a matrix | -vector_expression prod<vector_type>
- (const vector_expression &, const matrix_expression
- &); |
-
| Multiplication of matrices | -matrix_expression prod<matrix_type>
- (const matrix_expression &, const matrix_expression
- &); |
-
| Inner product of vectors | -scalar_expression inner_prod (const
- vector_expression &, const vector_expression &); |
-
| Outer product of vectors | -matrix_expression outer_prod (const
- vector_expression &, const vector_expression &); |
-
| Transpose of a matrix | -matrix_expression trans (const
- matrix_expression &); |
-
| Description | +Function | +
| Left multiplication of vectors with a matrix | +vector_expression prod<vector_type
+ > (const matrix_expression &, const vector_expression
+ &); |
+
| Right multiplication of vectors with a matrix | +vector_expression prod<vector_type
+ > (const vector_expression &, const matrix_expression
+ &); |
+
| Multiplication of matrices | +matrix_expression prod<matrix_type
+ > (const matrix_expression &, const matrix_expression
+ &); |
+
| Inner product of vectors | +scalar_expression inner_prod (const vector_expression
+&, const vector_expression &); |
+
| Outer product of vectors | +matrix_expression outer_prod (const vector_expression
+&, const vector_expression &); |
+
| Transpose of a matrix | +matrix_expression trans (const matrix_expression
+&); |
+
To achieve the goal of efficiency for numerical computing, one -has to overcome two difficulties in formulating abstractions with -C++, namely temporaries and virtual function calls. Expression -templates solve these problems, but tend to slow down compilation -times.
- + +To achieve the goal of efficiency for numerical computing, one has to overcome +two difficulties in formulating abstractions with C++, namely temporaries +and virtual function calls. Expression templates solve these problems, but +tend to slow down compilation times.
+Abstract formulas on vectors and matrices normally compose a -couple of unary and binary operations. The conventional way of -evaluating such a formula is first to evaluate every leaf -operation of a composition into a temporary and next to evaluate -the composite resulting in another temporary. This method is -expensive in terms of time especially for small and space -especially for large vectors and matrices. The approach to solve -this problem is to use lazy evaluation as known from modern -functional programming languages. The principle of this approach -is to evaluate a complex expression element wise and to assign it -directly to the target.
- + +Abstract formulas on vectors and matrices normally compose a couple of +unary and binary operations. The conventional way of evaluating such a formula +is first to evaluate every leaf operation of a composition into a temporary +and next to evaluate the composite resulting in another temporary. This method +is expensive in terms of time especially for small and space especially for +large vectors and matrices. The approach to solve this problem is to use lazy +evaluation as known from modern functional programming languages. The principle +of this approach is to evaluate a complex expression element wise and to +assign it directly to the target.
+Two interesting and dangerous facts result.
- -First one may get serious side effects using element wise -evaluation on vectors or matrices. Consider the matrix vector -product x = A x. Evaluation of A1x -and assignment to x1 changes the -right hand side, so that the evaluation of A2x -returns a wrong result. Our solution for this problem is to -evaluate the right hand side of an assignment into a temporary -and then to assign this temporary to the left hand side. To allow -further optimizations, we provide a corresponding member function -for every assignment operator. By using this member function a -programmer can confirm, that the left and right hand sides of an -assignment are independent, so that element wise evaluation and -direct assignment to the target is safe.
- -Next one can get worse computational complexity under certain -cirumstances. Consider the chained matrix vector product A (B -x). Conventional evaluation of A (B x) is -quadratic. Deferred evaluation of B xi -is linear. As every element B xi is -needed linearly depending of the size, a completely deferred -evaluation of the chained matrix vector product A (B x) -is cubic. In such cases one needs to reintroduce temporaries in -the expression.
- + +First one may get serious side effects using element wise evaluation on +vectors or matrices. Consider the matrix vector product x = A x. +Evaluation of A1x and assignment to +x1 changes the right hand side, so that the evaluation +of A2x returns a wrong result. Our +solution for this problem is to evaluate the right hand side of an assignment +into a temporary and then to assign this temporary to the left hand side. +To allow further optimizations, we provide a corresponding member function + for every assignment operator. By using this member function a programmer +can confirm, that the left and right hand sides of an assignment are independent, +so that element wise evaluation and direct assignment to the target is safe.
+ +Next one can get worse computational complexity under certain cirumstances. +Consider the chained matrix vector product A (B x). Conventional +evaluation of A (B x) is quadratic. Deferred evaluation of B +xi is linear. As every element B x + i is needed linearly depending of the size, a completely deferred + evaluation of the chained matrix vector product A (B x) is cubic. +In such cases one needs to reintroduce temporaries in the expression.
+Lazy expression evaluation normally leads to the definition of -a class hierarchy of terms. This results in the usage of dynamic -polymorphism to access single elements of vectors and matrices, -which is also known to be expensive in terms of time. A solution -was found a couple of years ago independently by David -Vandervoorde and Todd Veldhuizen and is commonly called -expression templates. Expression templates contain lazy -evaluation and replace dynamic polymorphism with static, i.e. -compile time polymorphism. Expression templates heavily depend on -the famous Barton-Nackman trick, also coined 'curiously defined -recursive templates' by Jim Coplien.
- + +Lazy expression evaluation normally leads to the definition of a class +hierarchy of terms. This results in the usage of dynamic polymorphism to access +single elements of vectors and matrices, which is also known to be expensive +in terms of time. A solution was found a couple of years ago independently +by David Vandervoorde and Todd Veldhuizen and is commonly called expression +templates. Expression templates contain lazy evaluation and replace dynamic +polymorphism with static, i.e. compile time polymorphism. Expression templates +heavily depend on the famous Barton-Nackman trick, also coined 'curiously +defined recursive templates' by Jim Coplien.
+Expression templates form the base of our implementation.
- +It is also a well known fact, that expression templates -challenge currently available compilers. We were able to -significantly reduce the amount of needed expression templates -using the Barton-Nackman trick consequently.
- -We also decided to support a dual conventional implementation
-(i.e. not using expression templates) with extensive bounds and
-type checking of vector and matrix operations to support the
-development cycle. Switching from debug mode to release mode is
-controlled by the NDEBUG preprocessor symbol of <cassert>.
It is also a well known fact, that expression templates challenge currently +available compilers. We were able to significantly reduce the amount of needed +expression templates using the Barton-Nackman trick consequently.
+ +We also decided to support a dual conventional implementation (i.e. not
+using expression templates) with extensive bounds and type checking of vector
+and matrix operations to support the development cycle. Switching from debug
+mode to release mode is controlled by the NDEBUG preprocessor
+symbol of <cassert>.
Every C++ library supporting linear algebra will be measured -against the long-standing Fortran package BLAS. We now describe -how BLAS calls may be mapped onto our classes.
- + +Every C++ library supporting linear algebra will be measured against the +long-standing Fortran package BLAS. We now describe how BLAS calls may be +mapped onto our classes.
+| BLAS Call | -Mapped Library Expression | -Mathematical Description | -Comment | -
|---|---|---|---|
_asum |
- norm_1 (x) |
- sum |xi| | -Computes the sum norm of a vector. | -
_nrm2 |
- norm_2 (x) |
- sqrt (sum |xi|2) | -Computes the euclidean norm of a vector. | -
i_amax |
- norm_inf (x) |
- max |xi| | -Computes the maximum norm of a vector. - BLAS computes the index of the first element having this - value. |
-
_dot |
- inner_prod (x, y)or |
- xT y or - xH y |
- Computes the inner product of two vectors. - BLAS implements certain loop unrollment. |
-
dsdot |
- a + prec_inner_prod (x, y) |
- a + xT y | -Computes the inner product in double precision. | -
_copy |
- x = y |
- x <- y | -Copies one vector to another. - BLAS implements certain loop unrollment. |
-
_swap |
- swap (x, y) |
- x <-> y | -Swaps two vectors. - BLAS implements certain loop unrollment. |
-
_scal |
- x *= a |
- x <- a x | -Scales a vector. - BLAS implements certain loop unrollment. |
-
_axpy |
- y += a * x |
- y <- a x + y | -Adds a scaled vector. - BLAS implements certain loop unrollment. |
-
_rot |
- t.assign (a * x + b * y), |
- (x, y) <- (a x + b y, -b x + a y) | -Applies a plane rotation. | -
_rotg |
- - | (a, b) <- - (? a / sqrt (a2 + b2), - - ? b / sqrt (a2 + b2)) - or - (1, 0) <- (0, 0) |
- Constructs a plane rotation. | -
| BLAS Call | +Mapped Library Expression | +Mathematical Description | +Comment | +
_asum |
+ norm_1 (x) |
+ sum |xi| | +Computes the sum norm of a vector. | +
_nrm2 |
+ norm_2 (x) |
+ sqrt (sum |xi|2 + ) | +Computes the euclidean norm of a vector. | +
i_amax |
+ norm_inf (x) |
+ max |xi| | +Computes the maximum norm of a vector. + BLAS computes the index of the first element having this + value. |
+
_dot |
+ inner_prod (x, y)or |
+ xT y or + xH y |
+ Computes the inner product of two vectors. + BLAS implements certain loop unrollment. |
+
dsdot |
+ a + prec_inner_prod (x, y) |
+ a + xT y | +Computes the inner product in double precision. | +
_copy |
+ x = y |
+ x <- y | +Copies one vector to another. + BLAS implements certain loop unrollment. |
+
_swap |
+ swap (x, y) |
+ x <-> y | +Swaps two vectors. + BLAS implements certain loop unrollment. |
+
_scal |
+ x *= a |
+ x <- a x | +Scales a vector. + BLAS implements certain loop unrollment. |
+
_axpy |
+ y += a * x |
+ y <- a x + y | +Adds a scaled vector. + BLAS implements certain loop unrollment. |
+
_rot |
+ t.assign (a * x + b * y), |
+ (x, y) <- (a x + b y, -b x + a y) | +Applies a plane rotation. | +
_rotg |
+ + | (a, b) <- + (? a / sqrt (a2 + b + 2), + ? b / sqrt (a2 + b + 2)) or + (1, 0) <- (0, 0) |
+ Constructs a plane rotation. | +
| BLAS Call | -Mapped Library Expression | -Mathematical Description | -Comment | -
|---|---|---|---|
_t_mv |
- x = prod (A, x) or or |
- x <- A x or - x <- AT x or - x <- AH x |
- Computes the product of a matrix with a vector. | -
_t_sv |
- y = solve (A, x, tag) or- inplace_solve (A, x, tag) or- y = solve (trans (A), x, tag) orory = solve (herm (A), x, tag)or |
- y <- A-1 x or - x <- A-1 x or - y <- AT-1 - x or - x <- AT-1 - x or - y <- AH-1 - x or - x <- AH-1 - x |
- Solves a system of linear equations with triangular - form, i.e. A is triangular. | -
_g_mv |
- y = a * prod (A, x) + b * y oror |
- y <- a A x + b y or - y <- a AT x + b y - y <- a AH x + b y |
- Adds the scaled product of a matrix with a vector. | -
_g_r |
- A += a * outer_prod (x, y) or |
- A <- a x yT + A or - A <- a x yH + A |
- Performs a rank 1 update. | -
_s_r |
- A += a * outer_prod (x, x) or |
- A <- a x xT + A
- or - A <- a x xH + A |
- Performs a symmetric or hermitian rank 1 - update. | -
_s_r2 |
- A += a * outer_prod (x, y) +or |
- A <- a x yT + a y
- xT + A or - A <- a x yH + a- - y xH + A |
- Performs a symmetric or hermitian rank 2 - update. | -
| BLAS Call | +Mapped Library Expression | +Mathematical Description | +Comment | +
_t_mv |
+ x = prod (A, x) or or |
+ x <- A x or + x <- AT x or + x <- AH x |
+ Computes the product of a matrix with a vector. | +
_t_sv |
+ y = solve (A, x, tag) or+ inplace_solve (A, x, tag) or+ y = solve (trans (A), x, tag) orory = solve (herm (A), x, tag)or |
+ y <- A-1 x or + x <- A-1 x or + y <- AT-1 + x or + x <- AT-1 + x or + y <- AH-1 + x or + x <- AH-1 + x |
+ Solves a system of linear equations with triangular + form, i.e. A is triangular. | +
_g_mv |
+ y = a * prod (A, x) + b * y oror |
+ y <- a A x + b y or + y <- a AT x + b y + y <- a AH x + b y |
+ Adds the scaled product of a matrix with a vector. | +
_g_r |
+ A += a * outer_prod (x, y) or |
+ A <- a x yT + A or + A <- a x yH + A |
+ Performs a rank 1 update. | +
_s_r |
+ A += a * outer_prod (x, x) or |
+ A <- a x xT + A
+ or + A <- a x xH + A |
+ Performs a symmetric or hermitian rank 1 update. | +
_s_r2 |
+ A += a * outer_prod (x, y) +or |
+ A <- a x yT + a y
+ xT + A or + A <- a x yH + a- + y xH + A |
+ Performs a symmetric or hermitian rank 2 update. | +
| BLAS Call | -Mapped Library Expression | -Mathematical Description | -Comment | -
|---|---|---|---|
_t_mm |
- B = a * prod (A, B) or- B = a * prod (trans (A), B) or- B = a * prod (A, trans (B)) or- B = a * prod (trans (A), trans (B)) or- B = a * prod (herm (A), B) or- B = a * prod (A, herm (B)) or- B = a * prod (herm (A), trans (B)) or- B = a * prod (trans (A), herm (B)) or- B = a * prod (herm (A), herm (B)) |
- B <- a op (A) op (B) with - op (X) = X or - op (X) = XT or - op (X) = XH |
- Computes the scaled product of two matrices. | -
_t_sm |
- C = solve (A, B, tag) or- inplace_solve (A, B, tag) or- C = solve (trans (A), B, tag) oror or |
- C <- A-1 B or - B <- A-1 B or - C <- AT-1 - B or - B <- A-1 B or - C <- AH-1 - B or - B <- AH-1 - B |
- Solves a system of linear equations with triangular - form, i.e. A is triangular. | -
_g_mm |
- C = a * prod (A, B) + b * C or- C = a * prod (trans (A), B) + b * C or- C = a * prod (A, trans (B)) + b * C or- C = a * prod (trans (A), trans (B)) + b * C or- C = a * prod (herm (A), B) + b * C or- C = a * prod (A, herm (B)) + b * C or- C = a * prod (herm (A), trans (B)) + b * C or- C = a * prod (trans (A), herm (B)) + b * C or- C = a * prod (herm (A), herm (B)) + b * C |
- C <- a op (A) op (B) + b C with - op (X) = X or - op (X) = XT or - op (X) = XH |
- Adds the scaled product of two matrices. | -
_s_rk |
- B = a * prod (A, trans (A)) + b * B or- B = a * prod (trans (A), A) + b * B or- B = a * prod (A, herm (A)) + b * B or- B = a * prod (herm (A), A) + b * B |
- B <- a A AT + b B
- or - B <- a AT A + b B or - B <- a A AH + b B or - B <- a AH A + b B |
- Performs a symmetric or hermitian rank k - update. | -
_s_r2k |
- C = a * prod (A, trans (B)) +or- C = a * prod (trans (A), B) +or- C = a * prod (A, herm (B)) +or- C = a * prod (herm (A), B) + |
- C <- a A BT + a B
- AT + b C or - C <- a AT B + a BTA - + b C or - C <- a A BH + a- - B AH + b C or - C <- a AH B + a- - BH A + b C |
- Performs a symmetric or hermitian rank 2 k - update. | -
| BLAS Call | +Mapped Library Expression | +Mathematical Description | +Comment | +
_t_mm |
+ B = a * prod (A, B) or+ B = a * prod (trans (A), B) or+ B = a * prod (A, trans (B)) or+ B = a * prod (trans (A), trans (B)) or+ B = a * prod (herm (A), B) or+ B = a * prod (A, herm (B)) or+ B = a * prod (herm (A), trans (B)) or+ B = a * prod (trans (A), herm (B)) or+ B = a * prod (herm (A), herm (B)) |
+ B <- a op (A) op (B) with + op (X) = X or + op (X) = XT or + op (X) = XH |
+ Computes the scaled product of two matrices. | +
_t_sm |
+ C = solve (A, B, tag) or+ inplace_solve (A, B, tag) or+ C = solve (trans (A), B, tag) oror or |
+ C <- A-1 B or + B <- A-1 B or + C <- AT-1 + B or + B <- A-1 B or + C <- AH-1 + B or + B <- AH-1 + B |
+ Solves a system of linear equations with triangular + form, i.e. A is triangular. | +
_g_mm |
+ C = a * prod (A, B) + b * C or+ C = a * prod (trans (A), B) + b * C or+ C = a * prod (A, trans (B)) + b * C or+ C = a * prod (trans (A), trans (B)) + b * C or+ C = a * prod (herm (A), B) + b * C or+ C = a * prod (A, herm (B)) + b * C or+ C = a * prod (herm (A), trans (B)) + b * C or+ C = a * prod (trans (A), herm (B)) + b * C or+ C = a * prod (herm (A), herm (B)) + b * C |
+ C <- a op (A) op (B) + b C with + op (X) = X or + op (X) = XT or + op (X) = XH |
+ Adds the scaled product of two matrices. | +
_s_rk |
+ B = a * prod (A, trans (A)) + b * B or+ B = a * prod (trans (A), A) + b * B or+ B = a * prod (A, herm (A)) + b * B or+ B = a * prod (herm (A), A) + b * B |
+ B <- a A AT + b B
+ or + B <- a AT A + b B or + B <- a A AH + b B or + B <- a AH A + b B |
+ Performs a symmetric or hermitian rank k update. | +
_s_r2k |
+ C = a * prod (A, trans (B)) +or+ C = a * prod (trans (A), B) +or+ C = a * prod (A, herm (B)) +or+ C = a * prod (herm (A), B) + |
+ C <- a A BT + a B
+ AT + b C or + C <- a AT B + a B +T A + b C or + C <- a A BH + a- + B AH + b C or + C <- a AH B + a- + BH A + b C |
+ Performs a symmetric or hermitian rank 2 k + update. | +
The library supports conventional dense, packed and basic -sparse vector and matrix storage layouts. The description of the -most common constructions of vectors and matrices comes next.
- + +The library supports conventional dense, packed and basic sparse vector +and matrix storage layouts. The description of the most common constructions +of vectors and matrices comes next.
+| Construction | -Comment | -
|---|---|
vector<T, |
- Constructs a dense vector, storage is provided by a
- standard vector. - The storage layout usually is BLAS compliant. |
-
vector<T, |
- Constructs a dense vector, storage is provided by a
- heap-based array. - The storage layout usually is BLAS compliant. |
-
vector<T, |
- Constructs a dense vector, storage is provided by a
- stack-based array. - The storage layout usually is BLAS compliant. |
-
unit_vector<T> |
- Constructs the index-th canonical unit
- vector. |
-
zero_vector<T> |
- Constructs a zero vector. | -
sparse_vector<T, |
- Constructs a sparse vector, storage is provided by a - standard map. | -
sparse_vector<T, |
- Constructs a sparse vector, storage is provided by a - map array. | -
compressed_vector<T> |
- Constructs a compressed vector. - The storage layout usually is BLAS compliant. |
-
coordinate_vector<T> |
- Constructs a coordinate vector. - The storage layout usually is BLAS compliant. |
-
vector_range<V> |
- Constructs a sub vector of a dense, packed or sparse - vector. | -
vector_slice<V> |
- Constructs a sub vector of a dense, packed or sparse
- vector. - This class usually can be used to emulate BLAS vector - slices. |
-
matrix<T, |
- Constructs a dense matrix, orientation is row major, - storage is provided by a standard vector. | -
matrix<T, |
- Constructs a dense matrix, orientation is column
- major, storage is provided by a standard vector. - The storage layout usually is BLAS compliant. |
-
matrix<T, |
- Constructs a dense matrix, orientation is row major, - storage is provided by a heap-based array. | -
matrix<T, |
- Constructs a dense matrix, orientation is column
- major, storage is provided by a heap-based array. - The storage layout usually is BLAS compliant. |
-
matrix<T, |
- Constructs a dense matrix, orientation is row major, - storage is provided by a stack-based array. | -
matrix<T, |
- Constructs a dense matrix, orientation is column
- major, storage is provided by a stack-based array. - The storage layout usually is BLAS compliant. |
-
identity_matrix<T> |
- Constructs an identity matrix. | -
zero_matrix<T> |
- Constructs a zero matrix. | -
triangular_matrix<T, |
- Constructs a packed triangular matrix, orientation is - row major. | -
triangular_matrix<T, |
- Constructs a packed triangular matrix, orientation is
- column major. - The storage layout usually is BLAS compliant. |
-
banded_matrix<T, |
- Constructs a packed banded matrix, orientation is row - major. | -
banded_matrix<T, |
- Constructs a packed banded matrix, orientation is
- column major. - The storage layout usually is BLAS compliant. |
-
symmetric_matrix<T, |
- Constructs a packed symmetric matrix, orientation is - row major. | -
symmetric_matrix<T, |
- Constructs a packed symmetric matrix, orientation is
- column major. - The storage layout usually is BLAS compliant. |
-
hermitian_matrix<T, |
- Constructs a packed hermitian matrix, orientation is - row major. | -
hermitian_matrix<T, |
- Constructs a packed hermitian matrix, orientation is
- column major. - The storage layout usually is BLAS compliant. |
-
sparse_matrix<T, |
- Constructs a sparse matrix, orientation is row major, - storage is provided by a standard map. | -
sparse_matrix<T, |
- Constructs a sparse matrix, orientation is column - major, storage is provided by a standard map. | -
sparse_matrix<T, |
- Constructs a sparse matrix, orientation is row major, - storage is provided by a map array. | -
sparse_matrix<T, |
- Constructs a sparse matrix, orientation is column - major, storage is provided by a map array. | -
compressed_matrix<T, |
- Constructs a compressed matrix, orientation is row
- major. - The storage layout usually is BLAS compliant. |
-
compressed_matrix<T, |
- Constructs a compressed matrix, orientation is column
- major. - The storage layout usually is BLAS compliant. |
-
coordinate_matrix<T, |
- Constructs a coordinate matrix, orientation is row
- major. - The storage layout usually is BLAS compliant. |
-
coordinate_matrix<T, |
- Constructs a coordinate matrix, orientation is column
- major. - The storage layout usually is BLAS compliant. |
-
matrix_row<M> |
- Constructs a sub vector of a dense, packed or sparse - matrix, containing the i-th row. | -
matrix_column<M> |
- Constructs a sub vector of a dense, packed or sparse - matrix, containing the j-th column. | -
matrix_range<M> |
- Constructs a sub matrix of a dense, packed or sparse
- matrix. - This class usually can be used to emulate BLAS leading - dimensions. |
-
matrix_slice<M> |
- Constructs a sub matrix of a dense, packed or sparse - matrix. | -
triangular_adaptor<M, F> |
- Constructs a triangular view of a dense, packed or
- sparse matrix. - This class usually can be used to generate corresponding - BLAS matrix types. |
-
banded_adaptor<M> |
- Constructs a banded view of a dense, packed or sparse
- matrix. - This class usually can be used to generate corresponding - BLAS matrix types. |
-
symmetric_adaptor<M> |
- Constructs a symmetric view of a dense, packed or
- sparse matrix. - This class usually can be used to generate corresponding - BLAS matrix types. |
-
hermitian_adaptor<M> |
- Constructs a hermitian view of a dense, packed or
- sparse matrix. - This class usually can be used to generate corresponding - BLAS matrix types. |
-
| Construction | +Comment | +
vector<T, |
+ Constructs a dense vector, storage is provided by a
+ standard vector. + The storage layout usually is BLAS compliant. |
+
vector<T, |
+ Constructs a dense vector, storage is provided by a
+ heap-based array. + The storage layout usually is BLAS compliant. |
+
vector<T, |
+ Constructs a dense vector, storage is provided by a
+ stack-based array. + The storage layout usually is BLAS compliant. |
+
unit_vector<T> |
+ Constructs the index-th canonical unit
+ vector. |
+
zero_vector<T> |
+ Constructs a zero vector. | +
sparse_vector<T, |
+ Constructs a sparse vector, storage is provided by a + standard map. | +
sparse_vector<T, |
+ Constructs a sparse vector, storage is provided by a + map array. | +
compressed_vector<T> |
+ Constructs a compressed vector. + The storage layout usually is BLAS compliant. |
+
coordinate_vector<T> |
+ Constructs a coordinate vector. + The storage layout usually is BLAS compliant. |
+
vector_range<V> |
+ Constructs a sub vector of a dense, packed or sparse + vector. | +
vector_slice<V> |
+ Constructs a sub vector of a dense, packed or sparse
+ vector. + This class usually can be used to emulate BLAS vector slices. |
+
matrix<T, |
+ Constructs a dense matrix, orientation is row major, + storage is provided by a standard vector. | +
matrix<T, |
+ Constructs a dense matrix, orientation is column major,
+storage is provided by a standard vector. + The storage layout usually is BLAS compliant. |
+
matrix<T, |
+ Constructs a dense matrix, orientation is row major, + storage is provided by a heap-based array. | +
matrix<T, |
+ Constructs a dense matrix, orientation is column major,
+storage is provided by a heap-based array. + The storage layout usually is BLAS compliant. |
+
matrix<T, |
+ Constructs a dense matrix, orientation is row major, + storage is provided by a stack-based array. | +
matrix<T, |
+ Constructs a dense matrix, orientation is column major,
+storage is provided by a stack-based array. + The storage layout usually is BLAS compliant. |
+
identity_matrix<T> |
+ Constructs an identity matrix. | +
zero_matrix<T> |
+ Constructs a zero matrix. | +
triangular_matrix<T, |
+ Constructs a packed triangular matrix, orientation is + row major. | +
triangular_matrix<T, |
+ Constructs a packed triangular matrix, orientation is
+ column major. + The storage layout usually is BLAS compliant. |
+
banded_matrix<T, |
+ Constructs a packed banded matrix, orientation is row + major. | +
banded_matrix<T, |
+ Constructs a packed banded matrix, orientation is column
+major. + The storage layout usually is BLAS compliant. |
+
symmetric_matrix<T, |
+ Constructs a packed symmetric matrix, orientation is + row major. | +
symmetric_matrix<T, |
+ Constructs a packed symmetric matrix, orientation is
+ column major. + The storage layout usually is BLAS compliant. |
+
hermitian_matrix<T, |
+ Constructs a packed hermitian matrix, orientation is + row major. | +
hermitian_matrix<T, |
+ Constructs a packed hermitian matrix, orientation is
+ column major. + The storage layout usually is BLAS compliant. |
+
sparse_matrix<T, |
+ Constructs a sparse matrix, orientation is row major, + storage is provided by a standard map. | +
sparse_matrix<T, |
+ Constructs a sparse matrix, orientation is column major, +storage is provided by a standard map. | +
sparse_matrix<T, |
+ Constructs a sparse matrix, orientation is row major, + storage is provided by a map array. | +
sparse_matrix<T, |
+ Constructs a sparse matrix, orientation is column major, +storage is provided by a map array. | +
compressed_matrix<T, |
+ Constructs a compressed matrix, orientation is row
+major. + The storage layout usually is BLAS compliant. |
+
compressed_matrix<T, |
+ Constructs a compressed matrix, orientation is column
+ major. + The storage layout usually is BLAS compliant. |
+
coordinate_matrix<T, |
+ Constructs a coordinate matrix, orientation is row
+major. + The storage layout usually is BLAS compliant. |
+
coordinate_matrix<T, |
+ Constructs a coordinate matrix, orientation is column
+ major. + The storage layout usually is BLAS compliant. |
+
matrix_row<M> |
+ Constructs a sub vector of a dense, packed or sparse + matrix, containing the i-th row. | +
matrix_column<M> |
+ Constructs a sub vector of a dense, packed or sparse + matrix, containing the j-th column. | +
matrix_range<M> |
+ Constructs a sub matrix of a dense, packed or sparse
+ matrix. + This class usually can be used to emulate BLAS leading +dimensions. |
+
matrix_slice<M> |
+ Constructs a sub matrix of a dense, packed or sparse + matrix. | +
triangular_adaptor<M, F> |
+ Constructs a triangular view of a dense, packed or
+sparse matrix. + This class usually can be used to generate corresponding + BLAS matrix types. |
+
banded_adaptor<M> |
+ Constructs a banded view of a dense, packed or sparse
+ matrix. + This class usually can be used to generate corresponding + BLAS matrix types. |
+
symmetric_adaptor<M> |
+ Constructs a symmetric view of a dense, packed or sparse
+matrix. + This class usually can be used to generate corresponding + BLAS matrix types. |
+
hermitian_adaptor<M> |
+ Constructs a hermitian view of a dense, packed or sparse
+matrix. + This class usually can be used to generate corresponding + BLAS matrix types. |
+
For compatibility reasons we provide array like indexing for -vectors and matrices, although this could be expensive for -matrices due to the needed temporary proxy objects.
- -To support the most widely used C++ compilers our design and -implementation do not depend on partial template specialization -essentially.
- + +For compatibility reasons we provide array like indexing for vectors and +matrices, although this could be expensive for matrices due to the needed +temporary proxy objects.
+ +To support the most widely used C++ compilers our design and implementation +do not depend on partial template specialization essentially.
+The library presumes standard compliant allocation through operator
-new and operator delete. So programs which
-are intended to run under MSVC 6.0 should set a correct new
-handler throwing a std::bad_alloc exception via _set_new_handler
-to detect out of memory conditions.
To get the most performance out of the box with MSVC 6.0, you
-should change the preprocessor definition of BOOST_UBLAS_INLINE
-to __forceinline in the header file
-config.hpp. But we suspect this optimization to be fragile.
operator delete. So programs which are intended
+to run under MSVC 6.0 should set a correct new handler throwing a std::bad_alloc
+ exception via _set_new_handler to detect out of memory conditions.
+
+To get the most performance out of the box with MSVC 6.0, you should change
+the preprocessor definition of BOOST_UBLAS_INLINE to __forceinline
+in the header file config.hpp. But we suspect this optimization to
+be fragile.
The following tables contain results of one of our benchmarks.
-This benchmark compares a native C implementation ('C array') and
-some library based implementations. The safe variants based on
-the library assume aliasing, the fast variants do not use
-temporaries and are functionally equivalent to the native C
-implementation. Besides the generic vector and matrix classes the
-benchmark utilizes special classes c_vector and c_matrix,
-which are intended to avoid every overhead through genericity.
The benchmark program was compiled with MSVC 6.0 and run on an -Intel Pentium II with 333 Mhz. First we comment the results for -double vectors and matrices of dimension 3 and 3 x 3, -respectively.
- + +The following tables contain results of one of our benchmarks. This benchmark
+compares a native C implementation ('C array') and some library based implementations.
+The safe variants based on the library assume aliasing, the fast variants
+do not use temporaries and are functionally equivalent to the native C implementation.
+Besides the generic vector and matrix classes the benchmark utilizes special
+classes c_vector and c_matrix, which are intended
+to avoid every overhead through genericity.
The benchmark program was compiled with MSVC 6.0 and run on an Intel Pentium +II with 333 Mhz. First we comment the results for double vectors and matrices +of dimension 3 and 3 x 3, respectively.
+| Operation | -Implementation | -Elapsed [s] | -MFLOP/s | -Comment | -
|---|---|---|---|---|
| inner_prod | -C array | -0.1 | -47.6837 | -No significant abstraction penalty | -
| c_vector | -0.06 | -79.4729 | -||
| vector<unbounded_array> | -0.11 | -43.3488 | -||
| vector<std::vector> | -0.11 | -43.3488 | -||
| vector + vector | -C array | -0.05 | -114.441 | -Abstraction penalty: factor 2 | -
| c_vector safe | -0.22 | -26.0093 | -||
| c_vector fast | -0.11 | -52.0186 | -||
| vector<unbounded_array> safe | -1.05 | -5.44957 | -||
| vector<unbounded_array> fast | -0.16 | -35.7628 | -||
| vector<std::vector> safe | -1.16 | -4.9328 | -||
| vector<std::vector> fast | -0.16 | -35.7628 | -||
| outer_prod | -C array | -0.06 | -85.8307 | -Abstraction penalty: factor 2 | -
| c_matrix, c_vector safe | -0.22 | -23.4084 | -||
| c_matrix, c_vector fast | -0.11 | -46.8167 | -||
| matrix<unbounded_array>, - vector<unbounded_array> safe | -0.38 | -13.5522 | -||
| matrix<unbounded_array>, - vector<unbounded_array> fast | -0.16 | -32.1865 | -||
| matrix<std::vector>, vector<std::vector> - safe | -0.5 | -10.2997 | -||
| matrix<std::vector>, vector<std::vector> - fast | -0.11 | -46.8167 | -||
| prod (matrix, vector) | -C array | -0.06 | -71.5256 | -No significant abstraction penalty | -
| c_matrix, c_vector safe | -0.11 | -39.0139 | -||
| c_matrix, c_vector fast | -0.11 | -39.0139 | -||
| matrix<unbounded_array>, - vector<unbounded_array> safe | -0.33 | -13.0046 | -||
| matrix<unbounded_array>, - vector<unbounded_array> fast | -0.11 | -39.0139 | -||
| matrix<std::vector>, vector<std::vector> - safe | -0.38 | -11.2935 | -||
| matrix<std::vector>, vector<std::vector> - fast | -0.05 | -85.8307 | -||
| matrix + matrix | -C array | -0.11 | -46.8167 | -No significant abstraction penalty | -
| c_matrix safe | -0.17 | -30.2932 | -||
| c_matrix fast | -0.11 | -46.8167 | -||
| matrix<unbounded_array> safe | -0.44 | -11.7042 | -||
| matrix<unbounded_array> fast | -0.16 | -32.1865 | -||
| matrix<std::vector> safe | -0.6 | -8.58307 | -||
| matrix<std::vector> fast | -0.17 | -30.2932 | -||
| prod (matrix, matrix) | -C array | -0.11 | -39.0139 | -No significant abstraction penalty | -
| c_matrix safe | -0.11 | -39.0139 | -||
| c_matrix fast | -0.11 | -39.0139 | -||
| matrix<unbounded_array> safe | -0.22 | -19.507 | -||
| matrix<unbounded_array> fast | -0.11 | -39.0139 | -||
| matrix<std::vector> safe | -0.27 | -15.8946 | -||
| matrix<std::vector> fast | -0.11 | -39.0139 | -||
| Operation | +Implementation | +Elapsed [s] | +MFLOP/s | +Comment | +
| inner_prod | +C array | +0.1 | +47.6837 | +No significant abstraction penalty | +
| c_vector | +0.06 | +79.4729 | +||
| vector<unbounded_array> | +0.11 | +43.3488 | +||
| vector<std::vector> | +0.11 | +43.3488 | +||
| vector + vector | +C array | +0.05 | +114.441 | +Abstraction penalty: factor 2 | +
| c_vector safe | +0.22 | +26.0093 | +||
| c_vector fast | +0.11 | +52.0186 | +||
| vector<unbounded_array> safe | +1.05 | +5.44957 | +||
| vector<unbounded_array> fast | +0.16 | +35.7628 | +||
| vector<std::vector> safe | +1.16 | +4.9328 | +||
| vector<std::vector> fast | +0.16 | +35.7628 | +||
| outer_prod | +C array | +0.06 | +85.8307 | +Abstraction penalty: factor 2 | +
| c_matrix, c_vector safe | +0.22 | +23.4084 | +||
| c_matrix, c_vector fast | +0.11 | +46.8167 | +||
| matrix<unbounded_array>, vector<unbounded_array> +safe | +0.38 | +13.5522 | +||
| matrix<unbounded_array>, vector<unbounded_array> +fast | +0.16 | +32.1865 | +||
| matrix<std::vector>, vector<std::vector> + safe | +0.5 | +10.2997 | +||
| matrix<std::vector>, vector<std::vector> + fast | +0.11 | +46.8167 | +||
| prod (matrix, vector) | +C array | +0.06 | +71.5256 | +No significant abstraction penalty | +
| c_matrix, c_vector safe | +0.11 | +39.0139 | +||
| c_matrix, c_vector fast | +0.11 | +39.0139 | +||
| matrix<unbounded_array>, vector<unbounded_array> +safe | +0.33 | +13.0046 | +||
| matrix<unbounded_array>, vector<unbounded_array> +fast | +0.11 | +39.0139 | +||
| matrix<std::vector>, vector<std::vector> + safe | +0.38 | +11.2935 | +||
| matrix<std::vector>, vector<std::vector> + fast | +0.05 | +85.8307 | +||
| matrix + matrix | +C array | +0.11 | +46.8167 | +No significant abstraction penalty | +
| c_matrix safe | +0.17 | +30.2932 | +||
| c_matrix fast | +0.11 | +46.8167 | +||
| matrix<unbounded_array> safe | +0.44 | +11.7042 | +||
| matrix<unbounded_array> fast | +0.16 | +32.1865 | +||
| matrix<std::vector> safe | +0.6 | +8.58307 | +||
| matrix<std::vector> fast | +0.17 | +30.2932 | +||
| prod (matrix, matrix) | +C array | +0.11 | +39.0139 | +No significant abstraction penalty | +
| c_matrix safe | +0.11 | +39.0139 | +||
| c_matrix fast | +0.11 | +39.0139 | +||
| matrix<unbounded_array> safe | +0.22 | +19.507 | +||
| matrix<unbounded_array> fast | +0.11 | +39.0139 | +||
| matrix<std::vector> safe | +0.27 | +15.8946 | +||
| matrix<std::vector> fast | +0.11 | +39.0139 | +
We notice a twofold performance loss for small vectors and -matrices: first the general abstraction penalty for using -classes, and then a small loss when using the generic vector and -matrix classes. The difference w.r.t. alias assumptions is also -significant.
- -Next we comment the results for double vectors and matrices of -dimension 100 and 100 x 100, respectively.
- + +We notice a twofold performance loss for small vectors and matrices: first +the general abstraction penalty for using classes, and then a small loss when +using the generic vector and matrix classes. The difference w.r.t. alias assumptions +is also significant.
+ +Next we comment the results for double vectors and matrices of dimension +100 and 100 x 100, respectively.
+| Operation | -Implementation | -Elapsed [s] | -MFLOP/s | -Comment | -
|---|---|---|---|---|
| inner_prod | -C array | -0.05 | -113.869 | -No significant abstraction penalty | -
| c_vector | -0.06 | -94.8906 | -||
| vector<unbounded_array> | -0.05 | -113.869 | -||
| vector<std::vector> | -0.06 | -94.8906 | -||
| vector + vector | -C array | -0.05 | -114.441 | -No significant abstraction penalty | -
| c_vector safe | -0.11 | -52.0186 | -||
| c_vector fast | -0.11 | -52.0186 | -||
| vector<unbounded_array> safe | -0.11 | -52.0186 | -||
| vector<unbounded_array> fast | -0.06 | -95.3674 | -||
| vector<std::vector> safe | -0.17 | -33.6591 | -||
| vector<std::vector> fast | -0.11 | -52.0186 | -||
| outer_prod | -C array | -0.05 | -114.441 | -No significant abstraction penalty | -
| c_matrix, c_vector safe | -0.28 | -20.4359 | -||
| c_matrix, c_vector fast | -0.11 | -52.0186 | -||
| matrix<unbounded_array>, - vector<unbounded_array> safe | -0.27 | -21.1928 | -||
| matrix<unbounded_array>, - vector<unbounded_array> fast | -0.06 | -95.3674 | -||
| matrix<std::vector>, vector<std::vector> - safe | -0.28 | -20.4359 | -||
| matrix<std::vector>, vector<std::vector> - fast | -0.11 | -52.0186 | -||
| prod (matrix, vector) | -C array | -0.11 | -51.7585 | -No significant abstraction penalty | -
| c_matrix, c_vector safe | -0.11 | -51.7585 | -||
| c_matrix, c_vector fast | -0.05 | -113.869 | -||
| matrix<unbounded_array>, - vector<unbounded_array> safe | -0.11 | -51.7585 | -||
| matrix<unbounded_array>, - vector<unbounded_array> fast | -0.06 | -94.8906 | -||
| matrix<std::vector>, vector<std::vector> - safe | -0.1 | -56.9344 | -||
| matrix<std::vector>, vector<std::vector> - fast | -0.06 | -94.8906 | -||
| matrix + matrix | -C array | -0.22 | -26.0093 | -No significant abstraction penalty | -
| c_matrix safe | -0.49 | -11.6776 | -||
| c_matrix fast | -0.22 | -26.0093 | -||
| matrix<unbounded_array> safe | -0.39 | -14.6719 | -||
| matrix<unbounded_array> fast | -0.22 | -26.0093 | -||
| matrix<std::vector> safe | -0.44 | -13.0046 | -||
| matrix<std::vector> fast | -0.27 | -21.1928 | -||
| prod (matrix, matrix) | -C array | -0.06 | -94.8906 | -No significant abstraction penalty | -
| c_matrix safe | -0.06 | -94.8906 | -||
| c_matrix fast | -0.05 | -113.869 | -||
| matrix<unbounded_array> safe | -0.11 | -51.7585 | -||
| matrix<unbounded_array> fast | -0.17 | -33.4908 | -||
| matrix<std::vector> safe | -0.11 | -51.7585 | -||
| matrix<std::vector> fast | -0.16 | -35.584 | -||
| Operation | +Implementation | +Elapsed [s] | +MFLOP/s | +Comment | +
| inner_prod | +C array | +0.05 | +113.869 | +No significant abstraction penalty | +
| c_vector | +0.06 | +94.8906 | +||
| vector<unbounded_array> | +0.05 | +113.869 | +||
| vector<std::vector> | +0.06 | +94.8906 | +||
| vector + vector | +C array | +0.05 | +114.441 | +No significant abstraction penalty | +
| c_vector safe | +0.11 | +52.0186 | +||
| c_vector fast | +0.11 | +52.0186 | +||
| vector<unbounded_array> safe | +0.11 | +52.0186 | +||
| vector<unbounded_array> fast | +0.06 | +95.3674 | +||
| vector<std::vector> safe | +0.17 | +33.6591 | +||
| vector<std::vector> fast | +0.11 | +52.0186 | +||
| outer_prod | +C array | +0.05 | +114.441 | +No significant abstraction penalty | +
| c_matrix, c_vector safe | +0.28 | +20.4359 | +||
| c_matrix, c_vector fast | +0.11 | +52.0186 | +||
| matrix<unbounded_array>, vector<unbounded_array> +safe | +0.27 | +21.1928 | +||
| matrix<unbounded_array>, vector<unbounded_array> +fast | +0.06 | +95.3674 | +||
| matrix<std::vector>, vector<std::vector> + safe | +0.28 | +20.4359 | +||
| matrix<std::vector>, vector<std::vector> + fast | +0.11 | +52.0186 | +||
| prod (matrix, vector) | +C array | +0.11 | +51.7585 | +No significant abstraction penalty | +
| c_matrix, c_vector safe | +0.11 | +51.7585 | +||
| c_matrix, c_vector fast | +0.05 | +113.869 | +||
| matrix<unbounded_array>, vector<unbounded_array> +safe | +0.11 | +51.7585 | +||
| matrix<unbounded_array>, vector<unbounded_array> +fast | +0.06 | +94.8906 | +||
| matrix<std::vector>, vector<std::vector> + safe | +0.1 | +56.9344 | +||
| matrix<std::vector>, vector<std::vector> + fast | +0.06 | +94.8906 | +||
| matrix + matrix | +C array | +0.22 | +26.0093 | +No significant abstraction penalty | +
| c_matrix safe | +0.49 | +11.6776 | +||
| c_matrix fast | +0.22 | +26.0093 | +||
| matrix<unbounded_array> safe | +0.39 | +14.6719 | +||
| matrix<unbounded_array> fast | +0.22 | +26.0093 | +||
| matrix<std::vector> safe | +0.44 | +13.0046 | +||
| matrix<std::vector> fast | +0.27 | +21.1928 | +||
| prod (matrix, matrix) | +C array | +0.06 | +94.8906 | +No significant abstraction penalty | +
| c_matrix safe | +0.06 | +94.8906 | +||
| c_matrix fast | +0.05 | +113.869 | +||
| matrix<unbounded_array> safe | +0.11 | +51.7585 | +||
| matrix<unbounded_array> fast | +0.17 | +33.4908 | +||
| matrix<std::vector> safe | +0.11 | +51.7585 | +||
| matrix<std::vector> fast | +0.16 | +35.584 | +
For larger vectors and matrices the general abstraction -penalty for using classes seems to decrease, the small loss when -using generic vector and matrix classes seems to remain. The -difference w.r.t. alias assumptions remains visible, too.
- -Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
-Permission to copy, use, modify, sell and distribute this
-document is granted provided this copyright notice appears in all
-copies. This document is provided ``as is'' without express or
-implied warranty, and with no claim as to its suitability for any
-purpose.
For larger vectors and matrices the general abstraction penalty for using +classes seems to decrease, the small loss when using generic vector and matrix +classes seems to remain. The difference w.r.t. alias assumptions remains visible, +too.
+ +Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
+ Permission to copy, use, modify, sell and distribute this document is granted
+provided this copyright notice appears in all copies. This document is provided
+``as is'' without express or implied warranty, and with no claim as to its
+suitability for any purpose.
Last revised: 8/3/2002
+ diff --git a/doc/readme.txt b/doc/readme.txt index 2b27bf66..c70c8ed9 100644 --- a/doc/readme.txt +++ b/doc/readme.txt @@ -1,9 +1,9 @@ Welcome to the evaluation of our C++ matrix library. Installation: -Extract the zip-file to a (new) directory of your choice. Workspace and -project files for MSVC and simple makefiles for BCC and GCC are contained within -the archive. +Extract the zip-file to a (new) directory of your choice. Workspace and +project files for MSVC and Jamfiles for the Boost build system are contained +within the archive. Tests and benchmarks: Test1 contains a couple of basic tests for dense vectors and matrices. @@ -11,10 +11,15 @@ Test2 demonstrates how to emulate BLAS with this matrix library. Test3 contains a couple of basic tests for sparse vectors and matrices. Test4 contains a couple of basic tests for banded matrices. Test5 contains a couple of basic tests for triangular matrices. -Bench1 measures the abstraction penalty using certain dense matrix and vector +Test6 contains a couple of basic tests for symmetric matrices. +Test7 contains a couple of basic tests for dense vectors and matrices of +boost::numeric::interval(s). +Bench1 measures the abstraction penalty using certain dense matrix and vector operations. Bench2 measures the performance of sparse matrix and vector operations. Bench3 measures the performance of vector and matrix proxy's operations. +Bench4 measures the abstraction penalty using certain dense matrix and vector +operations with boost::numeric::interval(s). If you have any problems installing or using the library, please feel free to contact -us at mailto:ublas@genesys-e.org \ No newline at end of file +us at mailto:ublas@genesys-e.org diff --git a/doc/samples/Jamfile b/doc/samples/Jamfile new file mode 100644 index 00000000..e9f0ea4c --- /dev/null +++ b/doc/samples/Jamfile @@ -0,0 +1,365 @@ +subproject libs/numeric/ublas/doc/samples ; + +exe unbounded_array + : unbounded_array.cpp + :