Шаблонный класс banded_matrix<T, F, A>
является базовым контейнером-адаптером для ленточных матриц. Для (m x n)-размерной ленточной матрицы с l нижней и
u верхней диагоналями и 0 <= i < m, 0
<= j < n элементами являются bi, j =
0, если i > j + l или i < j - u. Хранилище (storage) ленточных матриц сжато.
#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; }Будет выведено на экран:
[3,3]((0,1,0),(3,4,5),(0,7,8))
Определено в заголовочном файле banded.hpp.
Параметр | Описание | Значение по-умолчанию |
---|---|---|
T |
Тип объектов, размещаемых в матрице. | |
F |
Функция, определяющая организацию хранения. [1] | row_major |
A |
Тип приспособленного (adapted) массива. [2] | unbounded_array<T> |
Для которых базовый класс матрица (matrix) .
matrix_container<banded_matrix<T, F, A>
>
Приведенные ниже функции-члены в основном аналогичны функциям, перевод которым дан в разделе матрица. Характерные только для banded_matrix
функции-члены переведены в таблице ниже.
Функция-член | Описание |
---|---|
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) |
Создает неинициализированную banded_matrix , которая содержит (lower + 1 + upper) диагоналей вокруг главной диагонали матрицы с size1 строками и size2 столбцами. |
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) |
Изменяет размер banded_matrix до содержащей (lower +
1 + upper) диагоналей вокруг главной диагонали матрицы с size1 строками и size2 столбцами. Существующие элементы banded_matrix сохраняются. |
size_type size1 () const |
Returns the number of rows. |
size_type size2 () const |
Returns the number of columns. |
size_type lower () const |
Возвращает число диагоналей под главной диагональю. |
size_type upper () const |
Возвращает число диагоналей над главной диагональю. |
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] Поддерживаемые параметры организации
хранения: row_major
и column_major
.
[2] Поддерживаемые параметры для приспособленного (adapted) массива unbounded_array<T>
,
bounded_array<T>
и
std::vector<T>
.
Шаблонный класс banded_adaptor<M>
является ленточным адаптером для других матриц.
#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; }Будет выведено на экран:
[3,3]((0,1,0),(3,4,5),(0,7,8))
Определено в заголовочном файле banded.hpp.
Параметр | Описание | Значение по-умолчанию |
---|---|---|
M |
Тип приспособленной (adapted) матрицы. |
матричного выражения (matrix expression) .
Для которых базовый класс матричное выражение (matrix expression) .
matrix_expression<banded_adaptor<M>
>
Приведенные ниже функции-члены в основном аналогичны функциям, перевод которым дан в разделе матрица. Характерные только для banded_matrix
функции-члены переведены в таблице ниже.
Функция-член | Описание |
---|---|
banded_adaptor (matrix_type &data, size_type lower =
0, size_type upper = 0) |
Создает banded_adaptor , которая содержит (lower + 1 + upper) диагоналей вокруг главной диагонали матрицы . |
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 |
Возвращает число диагоналей под главной диагональю. |
size_type upper () const |
Возвращает число диагоналей над главной диагональю. |
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.
Перевод с оригинала: Кулиш. В. И. 2006 год.