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 bi, j =
0, if i > j + l or i < j - u. The
storage of banded matrices is packed.
#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> |
Matrix .
None, except for those imposed by the requirements of Matrix .
matrix_container<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, bool preserve = true) |
Reallocates a banded_matrix to hold (lower +
1 + upper) diagonals around the main diagonal of a matrix
with size1 rows of size2 elements. The
existing elements of the banded_matrix are preseved
when specified. |
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>
.
The templated class banded_adaptor<M>
is a
banded matrix adaptor for other matrices.
#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. |
None, except for those imposed by the requirements of Matrix Expression .
matrix_expression<banded_adaptor<M>
>
Member | Description |
---|---|
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 . |
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.