Sparse Matricies
Mapped Matrix
Description
The templated class mapped_matrix<T, F, A>
is the base container
adaptor for sparse matricies using element maps. For a (m
xn)-dimensional sparse matrix and 0 < = i < m, 0 < = j < n the
non-zero elements hi,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.
Example
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
mapped_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;
}
Definition
Defined in the header matrix_sparse.hpp.
Template parameters
Parameter | Description | Default |
---|---|---|
|
The type of object stored in the mapped matrix. |
|
|
Functor describing the storage organization. [1] |
|
|
The type of the adapted array. [2] |
|
Model of
Matrix .
Type requirements
None, except for those imposed by the requirements of Matrix .
Public base classes
matrix_container<mapped_matrix<T, F, A> >
Members
Member | Description |
---|---|
|
Allocates a |
|
Allocates a |
|
The copy constructor. |
|
The extended copy constructor. |
|
Reallocates a |
|
Returns the number of rows. |
|
Returns the number of columns. |
|
Returns
the value of the |
|
Returns a reference
of the |
|
The assignment operator. |
|
Assigns a
temporary. May change the mapped matrix |
|
The extended assignment operator. |
|
Assigns a matrix expression to the mapped matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Adds the matrix expression to the mapped matrix. |
|
Adds a matrix expression to the mapped matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Subtracts the matrix expression from the mapped matrix. |
|
Subtracts a matrix expression from the mapped matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Multiplies the mapped matrix with a scalar. |
|
A computed assignment operator. Divides the mapped matrix through a scalar. |
|
Swaps the contents of the mapped matrices. |
|
Inserts the value |
|
Erases the value at
the |
|
Clears the mapped matrix. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
Notes
[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 map_std<std::size_t, T>
. The latter is
equivalent to std::map<std::size_t, T>
.
Compressed Matrix
Description
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,j1and 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 < i__2) with column major orientation.
Example
#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;
}
Definition
Defined in the header matrix_sparse.hpp.
Template parameters
Parameter | Description | Default |
---|---|---|
|
The type of object stored in the compressed matrix. |
|
|
Functor describing the storage organization. [1] |
|
|
The index base of the compressed vector. [2] |
|
|
The type of the adapted array for indices. [3] |
|
|
The type of the adapted array for values. [3] |
|
Model of
Matrix .
Type requirements
None, except for those imposed by the requirements of Matrix .
Public base classes
matrix_container<compressed_matrix<T, F, IB, IA, TA> >
Members
Member | Description |
---|---|
|
Allocates a |
|
Allocates a |
|
The copy constructor. |
|
The extended copy constructor. |
|
Reallocates a |
|
Returns the number of rows. |
|
Returns the number of columns. |
|
Returns
the value of the |
|
Returns a reference
of the |
|
The assignment operator. |
|
Assigns a
temporary. May change the compressed matrix |
|
The extended assignment operator. |
|
Assigns a matrix expression to the compressed matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Adds the matrix expression to the compressed matrix. |
|
Adds a matrix expression to the compressed matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Subtracts the matrix expression from the compressed matrix. |
|
Subtracts a matrix expression from the compressed matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Multiplies the compressed matrix with a scalar. |
|
A computed assignment operator. Divides the compressed matrix through a scalar. |
|
Swaps the contents of the compressed matrices. |
|
Inserts the value |
|
Erases the value at
the |
|
Clears the compressed matrix. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
Notes
[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<>
.
Coordinate Matrix
Description
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 < i__2) with column major orientation.
Example
#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;
}
Definition
Defined in the header matrix_sparse.hpp.
Template parameters
Parameter | Description | Default |
---|---|---|
|
The type of object stored in the coordinate matrix. |
|
|
Functor describing the storage organization. [1] |
|
|
The index base of the coordinate vector. [2] |
|
|
The type of the adapted array for indices. [3] |
|
|
The type of the adapted array for values. [3] |
|
Model of
Matrix .
Type requirements
None, except for those imposed by the requirements of Matrix .
Public base classes
matrix_container<coordinate_matrix<T, F, IB, IA, TA> >
Members
Member | Description |
---|---|
|
Allocates a |
|
Allocates a |
|
The copy constructor. |
|
The extended copy constructor. |
|
Reallocates a |
|
Returns the number of rows. |
|
Returns the number of columns. |
|
Returns
the value of the |
|
Returns a reference
of the |
|
The assignment operator. |
|
Assigns a
temporary. May change the coordinate matrix |
|
The extended assignment operator. |
|
Assigns a matrix expression to the coordinate matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Adds the matrix expression to the coordinate matrix. |
|
Adds a matrix expression to the coordinate matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Subtracts the matrix expression from the coordinate matrix. |
|
Subtracts a matrix expression from the coordinate matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Multiplies the coordinate matrix with a scalar. |
|
A computed assignment operator. Divides the coordinate matrix through a scalar. |
|
Swaps the contents of the coordinate matrices. |
|
Inserts the value |
|
Appends the value |
|
Erases the value at
the |
|
Clears the coordinate matrix. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
Notes
[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<>
.
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
Copyright (©) 2021 Shikhar Vashistha
Use, modification and distribution are subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt ).