Matrix Proxies
Matrix Row
Description
The templated class matrix_row<M>
allows addressing a row of a matrix.
Example
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i) {
matrix_row<matrix<double> > mr (m, i);
for (unsigned j = 0; j < mr.size (); ++ j)
mr (j) = 3 * i + j;
std::cout << mr << std::endl;
}
}
Definition
Defined in the header matrix_proxy.hpp.
Template parameters
Parameter |
Description |
Default |
|
The type of matrix referenced. |
Model of
If the specified row falls outside that of the row index range of the
matrix, then the matrix_row
is not a well formed Vector Expression.
That is, access to an element which is outside of the matrix is
undefined.
Type requirements
None, except for those imposed by the requirements of Vector Expression .
Public base classes
vector_expression<matrix_row<M> >
Members
Member | Description |
---|---|
|
Constructs a sub vector. |
|
Returns the size of the sub vector. |
|
Returns the value of
the |
|
Returns a reference of the
|
|
The assignment operator. |
|
Assigns a temporary.
May change the matrix row |
|
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 |
Projections
Description
The free row
functions support the construction of matrix rows.
Prototypes
template<class M>
matrix_row<M> row (M &data, std::size_t i);
template<class M>
const matrix_row<const M> row (const M &data, std::size_t i);
Definition
Defined in the header matrix_proxy.hpp.
Type requirements
-
M
is a model of Matrix Expression .
Complexity
Linear depending from the size of the row.
Examples
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i) {
for (unsigned j = 0; j < m.size2 (); ++ j)
row (m, i) (j) = 3 * i + j;
std::cout << row (m, i) << std::endl;
}
}
Matrix Column
Description
The templated class matrix_column<M>
allows addressing a column of a
matrix.
Example
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned j = 0; j < m.size2 (); ++ j) {
matrix_column<matrix<double> > mc (m, j);
for (unsigned i = 0; i < mc.size (); ++ i)
mc (i) = 3 * i + j;
std::cout << mc << std::endl;
}
}
Definition
Defined in the header matrix_proxy.hpp.
Template parameters
Parameter |
Description |
Default |
|
The type of matrix referenced. |
Model of
If the specified column falls outside that of the column index range of
the matrix, then the matrix_column
is not a well formed Vector
Expression. That is, access to an element which is outside of the matrix
is undefined.
Type requirements
None, except for those imposed by the requirements of Vector Expression .
Public base classes
vector_expression<matrix_column<M> >
Members
Member | Description |
---|---|
|
Constructs a sub vector. |
|
Returns the size of the sub vector. |
|
Returns the value of
the |
|
Returns a reference of the
|
|
The assignment operator. |
|
Assigns a
temporary. May change the matrix column |
|
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 |
Projections
Description
The free column
functions support the construction of matrix columns.
Prototypes
template<class M>
matrix_column<M> column (M &data, std::size_t j);
template<class M>
const matrix_column<const M> column (const M &data, std::size_t j);
Definition
Defined in the header matrix_proxy.hpp.
Type requirements
-
M
is a model of Matrix Expression .
Complexity
Linear depending from the size of the column.
Examples
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned j = 0; j < m.size2 (); ++ j) {
for (unsigned i = 0; i < m.size1 (); ++ i)
column (m, j) (i) = 3 * i + j;
std::cout << column (m, j) << std::endl;
}
}
Vector Range
Description
The templated class matrix_vector_range<M>
allows addressing a sub
vector of a matrix.
Example
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned j = 0; j < m.size2 (); ++ j)
m (i, j) = 3 * i + j;
matrix_vector_range<matrix<double> > mvr (m, range (0, 3), range (0, 3));
std::cout << mvr << std::endl;
}
Definition
Defined in the header matrix_proxy.hpp.
Template parameters
Parameter |
Description |
Default |
|
The type of matrix referenced. |
Model of
If the specified ranges fall outside that of the index range of the
matrix, then the matrix_vector_range
is not a well formed Vector
Expression. That is, access to an element which is outside of the matrix
is undefined.
Type requirements
None, except for those imposed by the requirements of Vector Expression .
Public base classes
vector_expression<matrix_vector_range<M> >
Members
Member | Description |
---|---|
|
Constructs a sub vector. |
|
Returns the size of the sub vector. |
|
Returns the value of
the |
|
Returns a reference of the
|
|
The assignment operator. |
|
Assigns a temporary. May change the matrix 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 |
Vector Slice
Description
The templated class matrix_vector_slice<M>
allows addressing a sliced
sub vector of a matrix.
Example
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned j = 0; j < m.size2 (); ++ j)
m (i, j) = 3 * i + j;
matrix_vector_slice<matrix<double> > mvs (m, slice (0, 1, 3), slice (0, 1, 3));
std::cout << mvs << std::endl;
}
Definition
Defined in the header matrix_proxy.hpp.
Template parameters
Parameter |
Description |
Default |
|
The type of matrix referenced. |
Model of
If the specified slices fall outside that of the index range of the
matrix, then the matrix_vector_slice
is not a well formed Vector
Expression. That is, access to an element which is outside of the matrix
is undefined.
Type requirements
None, except for those imposed by the requirements of Vector Expression .
Public base classes
vector_expression<matrix_vector_slice<M> >
Members
Member | Description |
---|---|
|
Constructs a sub vector. |
|
Returns the size of the sub vector. |
|
Returns the value of
the |
|
Returns a reference of the
|
|
The assignment operator. |
|
Assigns a temporary. May change the matrix 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 |
Matrix Range
Description
The templated class matrix_range<M>
allows addressing a sub matrix of
a matrix.
Example
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
matrix_range<matrix<double> > mr (m, range (0, 3), range (0, 3));
for (unsigned i = 0; i < mr.size1 (); ++ i)
for (unsigned j = 0; j < mr.size2 (); ++ j)
mr (i, j) = 3 * i + j;
std::cout << mr << std::endl;
}
Definition
Defined in the header matrix_proxy.hpp.
Template parameters
Parameter |
Description |
Default |
|
The type of matrix referenced. |
Model of
If the specified ranges fall outside that of the index range of the
matrix, then the matrix_range
is not a well formed Matrix Expression.
That is, access to an element which is outside of the matrix is
undefined.
Type requirements
None, except for those imposed by the requirements of Matrix Expression .
Public base classes
matrix_expression<matrix_range<M> >
Members
Member | Description |
---|---|
|
Constructs a sub matrix. |
|
Returns the index of the first row. |
|
Returns the number of rows. |
|
Returns the index of the first column. |
|
Returns the number of columns. |
|
Returns
the value of the |
|
Returns a reference
of the |
|
The assignment operator. |
|
Assigns a
temporary. May change the matrix range |
|
The extended assignment operator. |
|
Assigns a matrix expression to the sub matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Adds the matrix expression to the sub matrix. |
|
Adds a matrix expression to the sub matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Subtracts the matrix expression from the sub matrix. |
|
Subtracts a matrix expression from the sub matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Multiplies the sub matrix with a scalar. |
|
A computed assignment operator. Divides the sub matrix through a scalar. |
|
Swaps the contents of the sub matrices. |
|
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 |
Simple Projections
Description
The free subrange
functions support the construction of matrix ranges.
Prototypes
template<class M>
matrix_range<M> subrange (M &data,
M::size_type start1, M::size_type stop1, M::size_type start2, M::size_type, stop2);
template<class M>
const matrix_range<const M> subrange (const M &data,
M::size_type start1, M::size_type stop1, M::size_type start2, M::size_type, stop2);
Generic Projections
Description
The free project
functions support the construction of matrix ranges.
Existing matrix_range’s can be composed with further ranges. The
resulting ranges are computed using this existing ranges' `compose
function.
Prototypes
template<class M>
matrix_range<M> project (M &data, const range &r1, const range &r2);
template<class M>
const matrix_range<const M> project (const M &data, const range &r1, const range &r2);
template<class M>
matrix_range<M> project (matrix_range<M> &data, const range &r1, const range &r2);
template<class M>
const matrix_range<M> project (const matrix_range<M> &data, const range &r1, const range &r2);
Definition
Defined in the header matrix_proxy.hpp.
Type requirements
-
M
is a model of Matrix Expression .
Complexity
Quadratic depending from the size of the ranges.
Examples
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned j = 0; j < m.size2 (); ++ j)
project (m, range (0, 3), range (0, 3)) (i, j) = 3 * i + j;
std::cout << project (m, range (0, 3), range (0, 3)) << std::endl;
}
Matrix Slice
Description
The templated class matrix_slice<M>
allows addressing a sliced sub
matrix of a matrix.
Example
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
matrix_slice<matrix<double> > ms (m, slice (0, 1, 3), slice (0, 1, 3));
for (unsigned i = 0; i < ms.size1 (); ++ i)
for (unsigned j = 0; j < ms.size2 (); ++ j)
ms (i, j) = 3 * i + j;
std::cout << ms << std::endl;
}
Definition
Defined in the header matrix_proxy.hpp.
Template parameters
Parameter |
Description |
Default |
|
The type of matrix referenced. |
Model of
If the specified slices fall outside that of the index range of the
matrix, then the matrix_slice
is not a well formed Matrix Expression.
That is, access to an element which is outside of the matrix is
undefined.
Type requirements
None, except for those imposed by the requirements of Matrix Expression .
Public base classes
matrix_expression<matrix_slice<M> >
Members
Member | Description |
---|---|
|
Constructs a sub matrix. |
|
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 matrix slice |
|
The extended assignment operator. |
|
Assigns a matrix expression to the sub matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Adds the matrix expression to the sub matrix. |
|
Adds a matrix expression to the sub matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Subtracts the matrix expression from the sub matrix. |
|
Subtracts a matrix expression from the sub matrix. Left and right hand side of the assignment should be independent. |
|
A computed assignment operator. Multiplies the sub matrix with a scalar. |
|
A computed assignment operator. Multiplies the sub matrix through a scalar. |
|
Swaps the contents of the sub matrices. |
|
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 |
Simple Projections
Description
The free subslice
functions support the construction of matrix slices.
Prototypes
template<class M>
matrix_slice<M> subslice (M &data,
M::size_type start1, M::difference_type stride1, M::size_type size1,
M::size_type start2, M::difference_type stride2, M::size_type size2);
template<class M>
const matrix_slice<const M> subslice (const M &data,
M::size_type start1, M::difference_type stride1, M::size_type size1,
M::size_type start2, M::difference_type stride2, M::size_type size2);
Generic Projections
Description
The free project
functions support the construction of matrix slices.
Existing matrix_slice
's can be composed with further ranges or slices.
The resulting slices are computed using this existing slices' compose
function.
Prototypes
template<class M>
matrix_slice<M> project (M &data, const slice &s1, const slice &s2);
template<class M>
const matrix_slice<const M> project (const M &data, const slice &s1, const slice &s2);
template<class M>
matrix_slice<M> project (matrix_slice<M> &data, const range &r1, const range &r2);
template<class M>
const matrix_slice<M> project (const matrix_slice<M> &data, const range &r1, const range &r2);
template<class M>
matrix_slice<M> project (matrix_slice<M> &data, const slice &s1, const slice &s2);
template<class M>
const matrix_slice<M> project (const matrix_slice<M> &data, const slice &s1, const slice &s2);
Definition
Defined in the header matrix_proxy.hpp.
Type requirements
-
M
is a model of Matrix Expression .
Complexity
Quadratic depending from the size of the slices.
Examples
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
int main () {
using namespace boost::numeric::ublas;
matrix<double> m (3, 3);
for (unsigned i = 0; i < m.size1 (); ++ i)
for (unsigned j = 0; j < m.size2 (); ++ j)
project (m, slice (0, 1, 3), slice (0, 1, 3)) (i, j) = 3 * i + j;
std::cout << project (m, slice (0, 1, 3), 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 ).