Sparse Vector
Mapped Vector
Description
The templated class mapped_vector<T, A>
is the base container adaptor
for sparse vectors using element maps. For a n-dimensional sparse
vector and 0 < = i < n the non-zero elements vi are mapped to
consecutive elements of the associative container, i.e. for elements k
= vi1 and k + 1 = vi2 of the container holds
i1 < i2 .
Example
#include <boost/numeric/ublas/vector_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
mapped_vector<double> v (3, 3);
for (unsigned i = 0; i < v.size (); ++ i)
v (i) = i;
std::cout << v << std::endl;
}
Definition
Defined in the header vector_sparse.hpp.
Template parameters
Parameter | Description | Default |
---|---|---|
|
The type of object stored in the mapped vector. |
|
|
The type of the adapted array. [1] |
|
Model of
Vector .
Type requirements
None, except for those imposed by the requirements of Vector .
Public base classes
vector_container<mapped_vector<T, A> >
Members
Member | Description |
---|---|
|
Allocates a |
|
Allocates a
|
|
The copy constructor. |
|
The extended copy constructor. |
|
Reallocates a
|
|
Returns the size of the |
|
Returns the value of
the |
|
Returns a reference of the
|
|
Returns the value of
the |
|
Returns a reference of the
|
|
The assignment operator. |
|
Assigns a
temporary. May change the mapped vector |
|
The extended assignment operator. |
|
Assigns a vector expression to the mapped vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Adds the vector expression to the mapped vector. |
|
Adds a vector expression to the mapped vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Subtracts the vector expression from the mapped vector. |
|
Subtracts a vector expression from the mapped vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Multiplies the mapped vector with a scalar. |
|
A computed assignment operator. Divides the mapped vector through a scalar. |
|
Swaps the contents of the mapped vectors. |
|
Inserts the value |
|
Erases the value at the |
|
Clears the mapped vector. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
Notes
[1] 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 Vector
Description
The templated class compressed_vector<T, IB, IA, TA>
is the base
container adaptor for compressed vectors. For a n-dimensional
compressed vector and 0 ⇐ i < n the non-zero elements vi are
mapped to consecutive elements of the index and value container, i.e.
for elements k = vi1 and k + 1 = vi2 of
these containers holds i1 < i2 .
Example
#include <boost/numeric/ublas/vector_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
compressed_vector<double> v (3, 3);
for (unsigned i = 0; i < v.size (); ++ i)
v (i) = i;
std::cout << v << std::endl;
}
Definition
Defined in the header vector_sparse.hpp.
Template parameters
Parameter | Description | Default |
---|---|---|
|
The type of object stored in the compressed vector. |
|
|
The index base of the compressed vector. [1] |
|
|
The type of the adapted array for indices. [2] |
|
|
The type of the adapted array for values. [2] |
|
Model of
Vector .
Type requirements
None, except for those imposed by the requirements of Vector .
Public base classes
vector_container<compressed_vector<T, IB, IA, TA> >
Members
Member | Description |
---|---|
|
Allocates a |
|
Allocates a
|
|
The copy constructor. |
|
The extended copy constructor. |
|
Reallocates a
|
|
Returns the size of the |
|
Returns the value of
the |
|
Returns a reference of the
|
|
Returns the value of
the |
|
Returns a reference of the
|
|
The assignment operator. |
|
Assigns a
temporary. May change the compressed vector |
|
The extended assignment operator. |
|
Assigns a vector expression to the compressed vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Adds the vector expression to the compressed vector. |
|
Adds a vector expression to the compressed vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Subtracts the vector expression from the compressed vector. |
|
Subtracts a vector expression from the compressed vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Multiplies the compressed vector with a scalar. |
|
A computed assignment operator. Divides the compressed vector through a scalar. |
|
Swaps the contents of the compressed vectors. |
|
Inserts the value |
|
Erases the value at the |
|
Clears the compressed vector. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
Notes
[1] Supported parameters for the index base are
0
and 1
at least.
[2] Supported parameters for the adapted array
are unbounded_array<>
, bounded_array<>
and std::vector<>
.
Coordinate Vector
Description
The templated class coordinate_vector<T, IB, IA, TA>
is the base
container adaptor for compressed vectors. For a n-dimensional sorted
coordinate vector and 0 ⇐ i < n the non-zero elements vi are
mapped to consecutive elements of the index and value container, i.e.
for elements k = vi1 and k + 1 = vi2 of
these containers holds i1 < i2 .
Example
#include <boost/numeric/ublas/vector_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
coordinate_vector<double> v (3, 3);
for (unsigned i = 0; i < v.size (); ++ i)
v (i) = i;
std::cout << v << std::endl;
}
Definition
Defined in the header vector_sparse.hpp.
Template parameters
Parameter | Description | Default |
---|---|---|
|
The type of object stored in the coordinate vector. |
|
|
The index base of the coordinate vector. [1] |
|
|
The type of the adapted array for indices. [2] |
|
|
The type of the adapted array for values. [2] |
|
Model of
Vector .
Type requirements
None, except for those imposed by the requirements of Vector .
Public base classes
vector_container<coordinate_vector<T, IB, IA, TA> >
Members
Member | Description |
---|---|
|
Allocates a |
|
Allocates a
|
|
The copy constructor. |
|
The extended copy constructor. |
|
Reallocates a
|
|
Returns the size of the |
|
Returns the value of
the |
|
Returns a reference of the
|
|
Returns the value of
the |
|
Returns a reference of the
|
|
The assignment operator. |
|
Assigns a
temporary. May change the coordinate vector |
|
The extended assignment operator. |
|
Assigns a vector expression to the coordinate vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Adds the vector expression to the coordinate vector. |
|
Adds a vector expression to the coordinate vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Subtracts the vector expression from the coordinate vector. |
|
Subtracts a vector expression from the coordinate vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Multiplies the coordinate vector with a scalar. |
|
A computed assignment operator. Divides the coordinate vector through a scalar. |
|
Swaps the contents of the coordinate vectors. |
|
Inserts the value |
|
Appends the value |
|
Erases the value at the |
|
Clears the coordinate vector. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
Notes
[1] Supported parameters for the index base are
0
and 1
at least.
[2] Supported parameters for the adapted array
are unbounded_array<>
, bounded_array<>
and std::vector<>
.
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 ).