Vector Proxies
Vector Range
Description
The templated class vector_range<V>
allows addressing a sub-range of a
vector’s element.
Example
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
vector<double> v (3);
vector_range<vector<double> > vr (v, range (0, 3));
for (unsigned i = 0; i < vr.size (); ++ i)
vr (i) = i;
std::cout << vr << std::endl;
}
Definition
Defined in the header vector_proxy.hpp.
Template parameters
Parameter |
Description |
Default |
|
The type of vector referenced. |
Model of
If the specified range falls outside that of the index range of the
vector, then the vector_range
is not a well formed Vector Expression.
That is, access to an element which is outside of index range of the
vector is undefined.
Type requirements
None, except for those imposed by the requirements of Vector Expression .
Public base classes
vector_expression<vector_range<V> >
Members
Member | Description |
---|---|
|
Constructs a sub vector. |
|
Returns the start of the sub vector. |
|
Returns the size of the sub vector. |
|
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 vector range |
|
The extended assignment operator. |
|
Assigns a vector expression to the sub vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Adds the vector expression to the sub vector. |
|
Adds a vector expression to the sub vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Subtracts the vector expression from the sub vector. |
|
Subtracts a vector expression from the sub vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Multiplies the sub vector with a scalar. |
|
A computed assignment operator. Divides the sub vector through a scalar. |
|
Swaps the contents of the sub vectors. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
Simple Projections
Description
The free subrange
functions support the construction of vector ranges.
Prototypes
template<class V>
vector_range<V> subrange (V &data,
V::size_type start, V::size_type stop);
template<class V>
const vector_range<const V> subrange (const V &data,
V::size_type start, V::size_type stop);
Generic Projections
Description
The free project
functions support the construction of vector ranges.
Existing matrix_range
's can be composed with a further range. The
resulting range is computed using this existing range’s compose
function.
Prototypes
template<class V>
vector_range<V> project (V &data, const range &r);
template<class V>
const vector_range<const V> project (const V &data, const range &r);
template<class V>
vector_range<V> project (vector_range<V> &data, const range &r);
template<class V>
const vector_range<V> project (const vector_range<V> &data, const range &r);
Definition
Defined in the header vector_proxy.hpp.
Type requirements
-
V
is a model of Vector Expression .
Complexity
Linear depending from the size of the range.
Examples
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
vector<double> v (3);
for (int i = 0; i < 3; ++ i)
project (v, range (0, 3)) (i) = i;
std::cout << project (v, range (0, 3)) << std::endl;
}
Vector Slice
Description
The templated class vector_slice<V>
allows addressing a slice of a
vector.
Example
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
vector<double> v (3);
vector_slice<vector<double> > vs (v, slice (0, 1, 3));
for (unsigned i = 0; i < vs.size (); ++ i)
vs (i) = i;
std::cout << vs << std::endl;
}
Definition
Defined in the header vector_proxy.hpp.
Template parameters
Parameter |
Description |
Default |
|
The type of vector referenced. |
Model of
If the specified slice falls outside that of the index range of the
vector, then the vector_slice
is not a well formed Vector Expression.
That is, access to an element which is outside of index range of the
vector is undefined.
Type requirements
None, except for those imposed by the requirements of Vector Expression .
Public base classes
vector_expression<vector_slice<V> >
Members
Member | Description |
---|---|
|
Constructs a sub vector. |
|
Returns the size of the sub vector. |
|
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 vector slice |
|
The extended assignment operator. |
|
Assigns a vector expression to the sub vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Adds the vector expression to the sub vector. |
|
Adds a vector expression to the sub vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Subtracts the vector expression from the sub vector. |
|
Subtracts a vector expression from the sub vector. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Multiplies the sub vector with a scalar. |
|
A computed assignment operator. Divides the sub vector through a scalar. |
|
Swaps the contents of the sub vectors. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a
|
|
Returns a
|
|
Returns a |
|
Returns a |
Simple Projections
Description
The free subslice
functions support the construction of vector slices.
Prototypes
template<class V>
vector_slice<V> subslice (V &data,
V::size_type start, V::difference_type stride, V::size_type size);
template<class V>
const vector_slice<const V> subslice (const V &data,
V::size_type start, V::difference_type stride, V::size_type size);
Generic Projections
Description
The free project
functions support the construction of vector slices.
Existing vector_slice
's can be composed with a further range or
slices. The resulting slice is computed using this existing slices’s
compose
function.
Prototypes
template<class V>
vector_slice<V> project (V &data, const slice &s);
template<class V>
const vector_slice<const V> project (const V &data, const slice &s);
template<class V>
vector_slice<V> project (vector_slice<V> &data, const range &r);
template<class V>
const vector_slice<V> project (const vector_slice<V> &data, const range &r);
template<class V>
vector_slice<V> project (vector_slice<V> &data, const slice &s);
template<class V>
const vector_slice<V> project (const vector_slice<V> &data, const slice &s);
Definition
Defined in the header vector_proxy.hpp.
Type requirements
-
V
is a model of Vector Expression .
Complexity
Linear depending from the size of the slice.
Examples
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
vector<double> v (3);
for (int i = 0; i < 3; ++ i)
project (v, slice (0, 1, 3)) (i) = i;
std::cout << project (v, slice (0, 1, 3)) << std::endl;
}
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 ).